/* finance-console — one stylesheet, no external fonts or assets (CSP: 'self' only). */

:root {
    /* Finance theme: navy for structure and trust, emerald for money in and primary actions,
       gold for highlights, red reserved for money out / overdrawn. */
    --bg: #f3f5f2;
    --panel: #ffffff;
    --panel-2: #f6f8f5;
    --ink: #10213a;
    --ink-2: #33445c;
    --muted: #66758a;
    --line: #e1e6e0;
    --line-2: #ccd4cd;
    --accent: #0f6b54;
    --accent-ink: #ffffff;
    --accent-soft: #e2f1eb;
    --gold: #b8860b;
    --gold-soft: #fbf3dc;
    --good: #12804a;
    --good-soft: #e3f3e9;
    --bad: #b3232c;
    --bad-soft: #fbe9ea;
    --warn: #946403;
    --warn-soft: #fbf1db;
    --info-soft: #e9f0f8;
    --excluded: #9aa4b2;
    --side: #0f2340;
    --side-2: #16305a;
    --side-ink: #dbe4f0;
    --side-muted: #8fa3bf;
    --shadow: 0 1px 2px rgba(16, 33, 58, .06), 0 4px 14px rgba(16, 33, 58, .05);
    --radius: 10px;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0a111c;
        --panel: #111a28;
        --panel-2: #152133;
        --ink: #e6ecf3;
        --ink-2: #c0cad8;
        --muted: #8795a9;
        --line: #1f2b3d;
        --line-2: #2c3b52;
        --accent: #34b58c;
        --accent-ink: #06231a;
        --accent-soft: #10302a;
        --gold: #d9a441;
        --gold-soft: #2c2412;
        --good: #45c486;
        --good-soft: #123023;
        --bad: #f0747a;
        --bad-soft: #341a1d;
        --warn: #e8b454;
        --warn-soft: #2d2413;
        --info-soft: #14223a;
        --excluded: #5c6778;
        --side: #08101c;
        --side-2: #13223a;
        --side-ink: #d5deea;
        --side-muted: #7d8ea7;
        --shadow: 0 1px 2px rgba(0, 0, 0, .45);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.neg { color: var(--bad); }
.pos { color: var(--good); }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }

/* ------------------------------------------------------------------ shell */

.shell { display: grid; grid-template-columns: 232px 1fr; height: 100vh; }

.side {
    background: linear-gradient(180deg, var(--side) 0%, var(--side) 70%, var(--side-2) 100%);
    color: var(--side-ink);
    display: flex;
    flex-direction: column;
    padding: 16px 12px;
    gap: 4px;
    overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand-mark {
    width: 30px; height: 30px; border-radius: 8px; background: var(--gold); color: #10213a;
    display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.brand-name { font-weight: 650; line-height: 1.1; }
.brand-sub { font-size: 11px; color: var(--side-muted); }
.side .brand-name { color: #fff; }

.nav-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; border: 0;
    background: none; cursor: pointer; text-align: left; color: var(--side-ink); width: 100%; opacity: .86;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); opacity: 1; }
.nav-item.active { background: rgba(255, 255, 255, .11); color: #fff; font-weight: 600; opacity: 1; box-shadow: inset 3px 0 0 var(--gold); }
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-badge { margin-left: auto; font-size: 11px; background: var(--bad-soft); color: var(--bad); padding: 1px 7px; border-radius: 99px; }
.nav-sep { height: 1px; background: rgba(255, 255, 255, .1); margin: 10px 4px; }
.side-foot { margin-top: auto; padding: 8px; font-size: 11px; color: var(--side-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.topbar {
    display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: var(--panel);
    border-bottom: 1px solid var(--line); min-height: 56px;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 650; }
.topbar .fy-lock { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--warn-soft); color: var(--warn); }

.content { flex: 1; overflow: auto; padding: 20px; min-height: 0; }
.content.flush { padding: 0; display: flex; flex-direction: column; overflow: hidden; }

/* ------------------------------------------------------------------ controls */

.btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 8px;
    border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; font-weight: 500;
    white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: none; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn svg { width: 15px; height: 15px; }

.input, select.input, textarea.input {
    padding: 7px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel);
    min-width: 0;
}
.input:focus, .btn:focus-visible, .cell-in:focus, .nav-item:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 1px;
}
textarea.input { width: 100%; resize: vertical; min-height: 64px; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 500; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px;
    border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; font-size: 12px; color: var(--ink-2);
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip .count { font-variant-numeric: tabular-nums; opacity: .8; }

.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 99px; font-weight: 600; white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.badge.plain { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }

/* ------------------------------------------------------------------ cards */

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 8px; padding: 14px 16px 0; }
.card-h h2, .card-h h3 { margin: 0; font-size: 14px; font-weight: 650; }
.card-b { padding: 14px 16px 16px; }
.section-title { font-size: 13px; font-weight: 650; color: var(--ink-2); margin: 22px 0 10px; text-transform: uppercase; letter-spacing: .04em; }

.party-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.party-card { padding: 16px; position: relative; overflow: hidden; }
.party-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--pc, var(--accent)); }
.party-card .who { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.party-card .role { font-size: 11px; color: var(--muted); font-weight: 500; }
.party-card .big { font-size: 26px; font-weight: 700; margin: 8px 0 2px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.party-card .big-l { font-size: 12px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; margin-top: 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }
.kv .total { border-top: 1px solid var(--line); padding-top: 3px; font-weight: 600; color: var(--ink); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.stat { padding: 12px 14px; }
.stat .l { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }

.alert { padding: 10px 14px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 13px; display: flex; gap: 8px; }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.info { background: var(--info-soft); color: var(--accent); }
.alert.good { background: var(--good-soft); color: var(--good); }

.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-top: 14px; }
@media (max-width: 1200px) { .dash-grid { grid-template-columns: 1fr; } }

.progress { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.progress > i { display: block; height: 100%; background: var(--good); }

.todo { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.todo:last-child { border-bottom: 0; }
.todo .n { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }

/* ------------------------------------------------------------------ tables */

table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th {
    text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 8px 10px;
    border-bottom: 1px solid var(--line); background: var(--panel-2); white-space: nowrap;
}
table.t td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tfoot td { font-weight: 650; border-top: 1px solid var(--line-2); }
table.t .num { text-align: right; }

/* ------------------------------------------------------------------ worksheet */

.ws-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.ws-bar .input { padding: 5px 8px; }
.ws-chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.ws-body { flex: 1; display: flex; min-height: 0; }
.ws-scroll { flex: 1; overflow: auto; min-width: 0; }

table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; min-width: 1260px; table-layout: fixed; }
table.grid thead th {
    position: sticky; top: 0; z-index: 2; background: var(--panel-2); text-align: left; font-size: 11.5px;
    font-weight: 600; color: var(--muted); padding: 8px 8px; border-bottom: 1px solid var(--line-2); white-space: nowrap;
}
table.grid td { border-bottom: 1px solid var(--line); padding: 4px 8px; vertical-align: middle; background: var(--panel); }
table.grid tr.sel td { background: var(--accent-soft); }
table.grid tr.focus td { box-shadow: inset 0 1px 0 var(--accent), inset 0 -1px 0 var(--accent); }
table.grid tr.focus td:first-child { box-shadow: inset 3px 0 0 var(--accent), inset 0 1px 0 var(--accent), inset 0 -1px 0 var(--accent); }
table.grid tr.need td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
table.grid tr.excluded td { color: var(--excluded); }
table.grid tr.excluded .amt { text-decoration: line-through; }
table.grid tr.credit .dep { color: var(--good); font-weight: 600; }
table.grid tfoot td { position: sticky; bottom: 0; background: var(--panel-2); font-weight: 650; border-top: 1px solid var(--line-2); padding: 8px; z-index: 1; }

col.c-check { width: 32px; }
col.c-date { width: 78px; }
col.c-narr { width: auto; }
col.c-amt { width: 108px; }
col.c-who { width: 156px; }
col.c-cat { width: 176px; }
col.c-just { width: 26%; }
col.c-docs { width: 58px; }
col.c-rev { width: 34px; }
td.c-date { white-space: nowrap; }
td.c-docs, td.c-rev { text-align: center; }
td.c-who { white-space: nowrap; }
td.c-who select { width: calc(100% - 34px); }

.narr { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.3; cursor: pointer; }
.narr:hover { color: var(--accent); }
.ref { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.cell-in {
    width: 100%; border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 4px 6px;
    font-size: 13px; min-width: 0;
}
.cell-in:hover:not(:disabled) { border-color: var(--line-2); background: var(--panel); }
.cell-in:disabled { opacity: 1; cursor: default; -webkit-appearance: none; appearance: none; }
select.cell-in.empty { color: var(--muted); font-style: italic; }
select.cell-in.who-set { font-weight: 600; }
.cell-in.saving { border-color: var(--warn); }
.cell-in.saved { border-color: var(--good); }
.cell-in.error { border-color: var(--bad); background: var(--bad-soft); }

.docs-btn {
    border: 1px solid var(--line-2); background: var(--panel); border-radius: 99px; padding: 2px 8px; cursor: pointer;
    font-size: 12px; display: inline-flex; gap: 4px; align-items: center; font-variant-numeric: tabular-nums;
}
.docs-btn.none { color: var(--bad); border-color: var(--bad-soft); background: var(--bad-soft); }
.docs-btn.ok { color: var(--good); border-color: var(--good-soft); background: var(--good-soft); }
.docs-btn.na { color: var(--muted); }
.docs-btn svg { width: 12px; height: 12px; }

.sugg { font-size: 10.5px; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 0 5px; margin-left: 4px; }

/* ------------------------------------------------------------------ drawer */

.drawer {
    width: 440px; flex: none; border-left: 1px solid var(--line); background: var(--panel); overflow-y: auto;
    display: flex; flex-direction: column;
}
.drawer-h { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: flex-start; position: sticky; top: 0; background: var(--panel); z-index: 1; }
.drawer-b { padding: 14px 16px; }
.drawer-b > section + section { margin-top: 18px; }
.drawer h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.amount-big { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

.dropzone {
    border: 1.5px dashed var(--line-2); border-radius: 10px; padding: 16px; text-align: center; color: var(--muted);
    cursor: pointer; background: var(--panel-2); transition: border-color .15s, background .15s;
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone strong { color: var(--ink); }

.doc { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.doc + .doc { margin-top: 6px; }
.doc .icon { width: 30px; height: 30px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 10px; font-weight: 700; flex: none; }
.doc .meta { min-width: 0; flex: 1; }
.doc .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }

.history { font-size: 12px; }
.history li { padding: 4px 0; border-bottom: 1px dashed var(--line); list-style: none; }
.history ul { padding: 0; margin: 0; }

.suggest-box { border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; font-size: 13px; }

/* ------------------------------------------------------------------ sharing */

.timeline { position: relative; height: 54px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel-2); }
.timeline .seg { position: absolute; top: 0; bottom: 18px; display: flex; flex-direction: column; justify-content: center; padding: 0 8px; color: #fff; font-size: 12px; font-weight: 600; overflow: hidden; white-space: nowrap; border-right: 1px solid rgba(255,255,255,.5); }
.timeline .gap { position: absolute; top: 0; bottom: 18px; background: repeating-linear-gradient(45deg, var(--bad-soft), var(--bad-soft) 6px, transparent 6px, transparent 12px); }
.timeline .months { position: absolute; left: 0; right: 0; bottom: 0; height: 18px; display: grid; grid-template-columns: repeat(12, 1fr); font-size: 10px; color: var(--muted); }
.timeline .months span { border-left: 1px solid var(--line); padding-left: 3px; }

.split-bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; min-width: 160px; }
.split-bar i { display: block; height: 100%; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ------------------------------------------------------------------ chart */

.chart svg { width: 100%; height: 220px; display: block; }
.chart .axis { stroke: var(--line); }
.chart text { fill: var(--muted); font-size: 10px; }

/* ------------------------------------------------------------------ modal / toast */

.overlay { position: fixed; inset: 0; background: rgba(15, 20, 27, .45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: var(--panel); border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.25); width: min(560px, 100%); max-height: 90vh; overflow: auto; }
.modal.wide { width: min(880px, 100%); }
.modal-h { padding: 16px 20px 0; display: flex; align-items: center; }
.modal-h h3 { margin: 0; font-size: 16px; }
.modal-b { padding: 14px 20px; }
.modal-f { padding: 12px 20px 16px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--line); }

.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 420px; font-size: 13px; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.good { background: var(--good); color: #fff; }

.secret { font-family: var(--mono); font-size: 15px; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; letter-spacing: .06em; word-break: break-all; user-select: all; }

/* ------------------------------------------------------------------ login */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background:
    radial-gradient(900px 500px at 0% 0%, rgba(184, 134, 11, .14), transparent),
    linear-gradient(160deg, var(--side) 0%, var(--side-2) 100%); }
.login { width: min(400px, 100%); padding: 28px; }
.login h1 { font-size: 20px; margin: 14px 0 4px; }
.login .brand-sub { color: var(--muted); }
.login .qr { width: 200px; height: 200px; margin: 8px auto; }
.login .qr svg { width: 100%; height: 100%; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state h3 { color: var(--ink); margin: 8px 0; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab { padding: 8px 14px; border: 0; background: none; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }

.spinner { width: 16px; height: 16px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.viewer { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.viewer-img { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto; }

@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .side { display: none; }
    .drawer { position: fixed; right: 0; top: 0; bottom: 0; width: 100%; z-index: 40; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------ analytics charts */
/* Chart series, validated for colour-blind separation in both modes: navy (company), gold and
   teal (directors). Revenue is the ink line; green/red stay reserved for money in/out figures. */
:root {
    --s-1: #1f5fa8; --s-2: #c98a12; --s-3: #16917f; --s-4: #6b7a90; --s-rev: #10213a; --s-ink: #66758a;
    --seq-1: #e2f1eb; --seq-2: #b5dccd; --seq-3: #7cc0a8; --seq-4: #3f9c80; --seq-5: #1c7d62; --seq-6: #0f5c48;
    --chart-grid: #e8ece7; --chart-base: #c3cbc4;
}
@media (prefers-color-scheme: dark) {
    :root {
        --s-1: #4a86d4; --s-2: #b7801f; --s-3: #1f9a86; --s-4: #8795a9; --s-rev: #e6ecf3; --s-ink: #8795a9;
        --seq-1: #10302a; --seq-2: #145040; --seq-3: #1c6a55; --seq-4: #25876b; --seq-5: #34b58c; --seq-6: #7fd6b6;
        --chart-grid: #1c2839; --chart-base: #2c3b52;
    }
}

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; background: var(--panel); }
.seg button { border: 0; background: none; padding: 6px 12px; cursor: pointer; color: var(--ink-2); font-size: 13px; }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.filters .range-note { font-size: 12px; color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-top: 14px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi { padding: 14px 16px; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 22px; font-weight: 700; margin-top: 4px; letter-spacing: -.01em; }
.kpi { border-top: 3px solid var(--kc, var(--line-2)); }
.kpi.in { --kc: var(--good); } .kpi.in .v { color: var(--good); }
.kpi.out { --kc: var(--bad); }
.kpi.gold { --kc: var(--gold); }
.kpi.navy { --kc: var(--s-1); }
.kpi .d { font-size: 12px; margin-top: 2px; color: var(--muted); }

.grid-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.grid-charts > .wide { grid-column: 1 / -1; }
@media (max-width: 1100px) { .grid-charts { grid-template-columns: 1fr; } }

.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .base { stroke: var(--chart-base); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; cursor: crosshair; outline: none; }
.chart .hit:hover, .chart .hit:focus-visible { fill: var(--ink); fill-opacity: .04; }
.chart .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.chart .dot { stroke: var(--panel); stroke-width: 2; pointer-events: none; }
.chart .line-mark { pointer-events: none; }
.chart .mark { pointer-events: none; }
.chart-tip { position: absolute; display: none; pointer-events: none; z-index: 5; min-width: 170px; background: var(--panel);
    border: 1px solid var(--line-2); border-radius: 8px; box-shadow: var(--shadow); padding: 8px 10px; font-size: 12px; }
.chart-tip-t { font-weight: 600; margin-bottom: 4px; color: var(--ink-2); }
.chart-tip-r { display: flex; align-items: center; gap: 8px; padding: 1px 0; }
.chart-tip-r i { width: 12px; height: 2px; flex: none; }
.chart-tip-r strong { font-variant-numeric: tabular-nums; }
.chart-tip-r span { color: var(--muted); }
.legend i.line { width: 16px; height: 0; border-top: 2px solid; border-radius: 0; vertical-align: 3px; background: none !important; }

.ranked { display: flex; flex-direction: column; gap: 8px; }
.ranked-row { display: grid; grid-template-columns: minmax(120px, 1.2fr) 2fr auto; gap: 10px; align-items: center; font-size: 13px; }
.ranked-l { display: flex; flex-direction: column; min-width: 0; }
.ranked-l span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ranked-bar { height: 10px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.ranked-bar i { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.ranked-v { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

table.heat { border-collapse: separate; border-spacing: 2px; font-size: 11px; width: 100%; }
table.heat th { font-weight: 500; color: var(--muted); text-align: left; white-space: nowrap; padding: 2px 6px; }
table.heat thead th { text-align: center; font-size: 10.5px; }
table.heat td { text-align: center; padding: 6px 4px; border-radius: 4px; color: var(--ink); font-variant-numeric: tabular-nums; min-width: 44px; }
table.heat td.dark { color: #fff; }
@media (prefers-color-scheme: dark) { table.heat td.dark { color: #06231a; } }
table.heat td.zero { background: var(--panel-2); }


.insights li { margin: 6px 0; }
.ai-text p { margin: 4px 0; }
.ai-text .ai-h { font-weight: 650; margin-top: 12px; }
.ai-text ul { margin: 4px 0; padding-left: 18px; }

/* ------------------------------------------------------------------ available balances */
.avail { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 9px 12px;
    border-radius: 8px; margin-top: 10px; font-size: 13px; }
.avail strong { font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.avail span { white-space: nowrap; }
.avail.good { background: var(--good-soft); color: var(--good); }
.avail.bad { background: var(--bad-soft); color: var(--bad); }


/* ------------------------------------------------------------------ balance cards */
.balances { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 16px; }
.bal-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.bal-head h2 { margin: 0; font-size: 16px; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line-2); color: var(--ink-2); }
.pill b { font-variant-numeric: tabular-nums; }
.pill.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.pill.plain { background: var(--panel-2); }
.bal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.bal-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px 12px; background: var(--panel);
    border-top: 4px solid var(--pc); display: flex; flex-direction: column; gap: 2px; }
.bal-top { display: flex; align-items: center; gap: 8px; }
.bal-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--pc); flex: none; }
.bal-role { font-size: 11px; color: var(--muted); }
.bal-state { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 8px; border-radius: 99px; }
.bal-card.good .bal-state { background: var(--good-soft); color: var(--good); }
.bal-card.bad .bal-state { background: var(--bad-soft); color: var(--bad); }
.bal-amt { font-size: 30px; font-weight: 750; letter-spacing: -.02em; margin-top: 8px; white-space: nowrap; }
.bal-card.good .bal-amt { color: var(--good); }
.bal-card.bad .bal-amt { color: var(--bad); }
.bal-sub { font-size: 12px; color: var(--muted); }
.bal-bars { display: flex; flex-direction: column; gap: 6px; margin: 14px 0 12px; }
.bal-row { display: grid; grid-template-columns: 68px 1fr; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.bal-track { display: flex; gap: 2px; height: 10px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.bal-track i { display: block; height: 100%; }
.bal-track i:last-child { border-radius: 0 4px 4px 0; }
.bal-track i.carried { background: var(--pc); opacity: .45; }
.bal-track i.share { background: var(--pc); }
.bal-track i.out { background: var(--ink-2); }
.bal-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.bal-nums span { display: block; font-size: 11px; color: var(--muted); }
.bal-nums b { font-size: 15px; font-variant-numeric: tabular-nums; }
.bal-foot { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 11.5px; color: var(--muted); }
