:root {
    /* FruitPopz brand palette (Brand Guideline):
       Primary  #00D3BE (teal)  + #F2B01C (orange)
       Secondary #268C7B (deep green) + #FFE165 (yellow) */
    --brand: #00D3BE;
    --teal: #00b8a6;            /* slightly deepened primary for UI fills */
    --teal-ink: #1b8474;        /* readable teal for text/links */
    --teal-dark: #268C7B;
    --teal-darker: #1b6a5c;
    --teal-soft: #e0faf6;
    --green: #35bd6a;
    --green-soft: #e6f7ec;
    --orange: #F2B01C;
    --orange-soft: #fdf3d9;
    --yellow: #FFE165;
    --purple: #8b5cf6;
    --purple-soft: #efe9fe;
    --red: #ef4444;
    --red-soft: #fdecec;
    --ink: #1f2a37;
    --muted: #6b7280;
    --line: #eef1f3;
    --bg: #f5f7f8;
    --card: #ffffff;
    --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
    --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
}

a { color: var(--teal-ink); text-decoration: none; }

/* ---------- Loading splash ---------- */
.loading-splash {
    position: fixed; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 16px; color: var(--muted);
    background: var(--bg);
}
.spinner {
    width: 38px; height: 38px; border-radius: 50%;
    border: 4px solid var(--teal-soft); border-top-color: var(--brand);
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 256px; flex-shrink: 0;
    background: linear-gradient(180deg, var(--teal-dark), var(--teal-darker));
    color: #cfe7e3; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 24px 24px 10px; text-align: center; }
.brand img { width: 132px; display: inline-block; }
.nav-label { font-size: 10.5px; letter-spacing: .12em; color: #7fb3ac; padding: 18px 24px 8px; text-transform: uppercase; }

.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 11px 20px; margin: 2px 12px;
    border-radius: 10px; color: #cfe7e3; font-weight: 500; cursor: pointer; position: relative;
}
.nav-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-item.active { background: #fff; color: var(--teal-dark); font-weight: 600; }
.nav-item .ico { width: 20px; text-align: center; }
.nav-item .badge {
    margin-left: auto; background: var(--orange); color: #fff; font-size: 11px;
    min-width: 20px; height: 20px; border-radius: 10px; display: inline-flex;
    align-items: center; justify-content: center; padding: 0 6px; font-weight: 700;
}
.nav-item.active .badge { background: var(--orange); }

.promo {
    margin: auto 16px 20px; background: #fff; border-radius: 14px; overflow: hidden; text-align: center;
    padding-bottom: 14px;
}
.promo .art {
    height: 120px; background: linear-gradient(135deg, var(--yellow), var(--orange) 70%);
    display: flex; align-items: center; justify-content: center; font-size: 44px;
}
.promo .cap { color: var(--teal-dark); font-weight: 700; margin-top: 10px; font-size: 13px; }
.promo .cap small { display: block; color: var(--muted); font-weight: 500; font-style: italic; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 16px; padding: 16px 32px; background: var(--bg);
}
.topbar .spacer { flex: 1; }
.bell { position: relative; font-size: 20px; color: var(--muted); cursor: pointer; }
.bell .dot {
    position: absolute; top: -6px; right: -8px; background: var(--red); color: #fff; font-size: 10px;
    min-width: 17px; height: 17px; border-radius: 9px; display: inline-flex; align-items: center;
    justify-content: center; font-weight: 700; padding: 0 4px;
}
.who { display: flex; align-items: center; gap: 10px; }
.who .avatar {
    width: 38px; height: 38px; border-radius: 50%; background: var(--teal); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.who .name { font-weight: 600; line-height: 1.1; }
.who .role { font-size: 11.5px; color: var(--muted); }

.content { padding: 8px 32px 40px; }
.page-title { font-size: 27px; font-weight: 800; margin: 4px 0 2px; font-family: 'Baloo 2', 'Poppins', sans-serif; color: var(--teal-dark); }
.page-sub { color: var(--muted); margin: 0 0 20px; }
.updated { color: var(--muted); font-size: 12.5px; }

/* ---------- Grid & cards ---------- */
.grid { display: grid; gap: 20px; }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.span-2 { grid-column: span 2; }
@media (max-width: 1100px) { .cols-4 { grid-template-columns: repeat(2, 1fr); } .cols-3 { grid-template-columns: 1fr; } .span-2 { grid-column: auto; } }
@media (max-width: 680px) { .cols-4, .cols-2 { grid-template-columns: 1fr; } .sidebar { display: none; } }

.card {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    border: 1px solid var(--line); padding: 22px;
}
.card h3 { margin: 0 0 16px; font-size: 16px; font-weight: 700; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-head h3 { margin: 0; }
.link-btn { color: var(--teal-ink); font-size: 12.5px; border: 1px solid var(--line); padding: 5px 12px; border-radius: 8px; background: #fff; cursor: pointer; }

/* ---------- KPI tiles ---------- */
.kpi { display: flex; align-items: center; gap: 16px; }
.kpi .icon {
    width: 54px; height: 54px; border-radius: 14px; display: flex; align-items: center;
    justify-content: center; font-size: 24px; flex-shrink: 0;
}
.i-teal { background: var(--teal-soft); color: var(--teal); }
.i-green { background: var(--green-soft); color: var(--green); }
.i-orange { background: var(--orange-soft); color: var(--orange); }
.i-purple { background: var(--purple-soft); color: var(--purple); }
.i-red { background: var(--red-soft); color: var(--red); }
.kpi .label { color: var(--muted); font-size: 12.5px; }
.kpi .value { font-size: 22px; font-weight: 800; margin: 2px 0; }
.kpi .value.teal { color: var(--teal-ink); }
.kpi .sub { color: var(--muted); font-size: 12px; }

/* ---------- Capital recovery ---------- */
.recovery { display: flex; align-items: center; gap: 22px; }
.recovery .figures { flex: 1; }
.fig-row { margin-bottom: 12px; }
.fig-row .l { color: var(--muted); font-size: 12.5px; }
.fig-row .v { font-size: 18px; font-weight: 700; }
.fig-row .v.teal { color: var(--teal-ink); }
.fig-row .v.red { color: var(--red); }
.note { background: #f3f8f7; color: var(--muted); border-radius: 10px; padding: 10px 12px; font-size: 12px; margin-top: 14px; display: flex; gap: 8px; }

/* ---------- Tables ---------- */
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
    text-align: left; font-size: 12px; color: var(--muted); font-weight: 600;
    padding: 10px 12px; border-bottom: 1px solid var(--line);
    white-space: nowrap; vertical-align: middle;
}
.tbl td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr.total td { font-weight: 700; color: var(--teal-ink); border-top: 2px solid var(--line); }
th.num, td.num, .num { text-align: right; font-variant-numeric: tabular-nums; }
/* Keep header and data columns locked to the same widths */
.card > table.tbl { display: block; overflow-x: auto; }
.card > table.tbl thead, .card > table.tbl tbody { display: table; width: 100%; table-layout: fixed; }
.card > table.tbl thead th, .card > table.tbl tbody td { overflow: hidden; text-overflow: ellipsis; }
.card > table.tbl thead th:first-child, .card > table.tbl tbody td:first-child { width: 20%; }
.card > table.tbl thead th:last-child, .card > table.tbl tbody td:last-child { width: 12%; }

/* ---------- Counter network ---------- */
.counter-summary { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.counter-summary .big { font-size: 40px; font-weight: 800; color: var(--teal-ink); }
.counter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.counter-tile { border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; }
.counter-tile .n { font-size: 26px; font-weight: 800; }
.counter-tile .t { font-size: 12px; }
.t-green { background: var(--green-soft); } .t-green .n, .t-green .t { color: #1f9d57; }
.t-orange { background: var(--orange-soft); } .t-orange .n, .t-orange .t { color: #c77f10; }
.t-red { background: var(--red-soft); } .t-red .n, .t-red .t { color: #cf3b3b; }
.t-gray { background: #f1f3f5; } .t-gray .n, .t-gray .t { color: #6b7280; }

/* ---------- Legend ---------- */
.legend { display: flex; flex-direction: column; gap: 10px; }
.legend .row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.legend .swatch { width: 12px; height: 12px; border-radius: 3px; }
.legend .pct { font-weight: 700; margin-left: auto; }

/* ---------- Notifications ---------- */
.notif { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.notif:last-child { border-bottom: none; }
.notif .dot { width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.notif .ttl { font-weight: 600; font-size: 13.5px; }
.notif .bd { color: var(--muted); font-size: 12.5px; }
.notif .tm { color: #9aa4af; font-size: 11.5px; margin-top: 3px; }

/* ---------- Badges / pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.pill.active { background: var(--green-soft); color: #1f9d57; }
.pill.pending, .pill.install { background: var(--orange-soft); color: #c77f10; }
.pill.suspended, .pill.inactive { background: var(--red-soft); color: #cf3b3b; }
.pill.closed { background: #f1f3f5; color: #6b7280; }
.pill.draft { background: #eef2ff; color: #4f5bd5; }
.pill.approved { background: var(--green-soft); color: #1f9d57; }
.pill.paid { background: #fff4d6; color: #b07d10; }

/* ---------- Buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; border: none; border-radius: 10px; padding: 10px 16px; font-weight: 600; font-size: 13.5px; cursor: pointer; }
.btn.primary { background: var(--teal-dark); color: #fff; }
.btn.primary:hover { background: var(--teal-darker); }
.btn.ghost { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.form-row input, .form-row select, .form-row textarea {
    width: 100%; padding: 10px 12px; border: 1px solid #dfe3e7; border-radius: 10px; font-size: 14px; font-family: inherit;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--teal-soft); }
.form-row input[type="checkbox"] { width: auto; padding: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }

/* ---------- Validation ---------- */
.validation-message { color: var(--red); font-size: 12px; margin-top: 4px; }
.validation-errors { background: var(--red-soft); color: #cf3b3b; border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 14px; }
.validation-errors ul { margin: 0; padding-left: 18px; }
input.invalid, select.invalid, textarea.invalid { border-color: var(--red) !important; }

/* ---------- LEAD account picker ---------- */
.acct-list { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.acct-item {
    display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 10px;
    padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; margin: 0;
}
.acct-item:last-child { border-bottom: none; }
.acct-item:hover { background: var(--teal-soft); }
.acct-item input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--teal-dark); }
.acct-item .acct-name { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-item .acct-id { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.alert { padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }
.alert.err { background: var(--red-soft); color: #cf3b3b; }
.alert.ok { background: var(--green-soft); color: #1f9d57; }

.assist-bar { display: flex; align-items: center; gap: 20px; background: var(--teal-soft); border-radius: var(--radius); padding: 18px 24px; margin-top: 20px; flex-wrap: wrap; }
.assist-bar .lead { font-weight: 700; color: var(--teal-dark); }
.assist-card { background: #fff; border-radius: 12px; padding: 12px 16px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--teal-dark), var(--teal-darker)); padding: 20px; }
.login-card { background: #fff; border-radius: 20px; padding: 36px; width: 100%; max-width: 400px; box-shadow: 0 20px 40px rgba(0,0,0,.2); }
.login-card .logo { text-align: center; }
.login-card .logo img { width: 168px; }
.login-card .sub { text-align: center; color: var(--muted); margin: 4px 0 24px; font-size: 13px; }
.demo-creds { margin-top: 18px; font-size: 12px; color: var(--muted); background: #f6f8f9; border-radius: 10px; padding: 12px; }
.demo-creds b { color: var(--ink); }

/* ---------- Blazor error banner (hidden unless a real unhandled error occurs) ---------- */
#blazor-error-ui {
    display: none;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
    background: #fff3cd; color: #664d03;
    padding: 12px 40px 12px 16px; font-size: 13.5px;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, .12);
}
#blazor-error-ui .reload { color: var(--teal-ink); font-weight: 600; margin-left: 8px; }
#blazor-error-ui .dismiss {
    position: absolute; right: 14px; top: 10px; cursor: pointer; font-weight: 700;
}

.access-denied, .loading-splash h3 { padding: 40px; text-align: center; }
.muted { color: var(--muted); }
.right { text-align: right; }
.mt { margin-top: 16px; }
.spacer-v { height: 16px; }
