/* CashGuard — design tokens taken from billerbay.com */
:root {
  --ink: #12122c; --ink-2: #1b1b40; --ink-3: #26265a;
  --blue: #3f4cff; --blue-deep: #0410bd; --blue-50: #eff0ff; --blue-300: #a2a8ff;
  --cyan: #00cbde; --cyan-300: #94f2fa; --teal-deep: #007998;
  --grey-100: #f2f2f8; --grey-200: #e3e3f1; --grey-300: #babace; --grey-600: #676687;

  --bg: var(--grey-100); --surface: #fff; --surface-2: #f8f8fc; --text: var(--ink); --muted: var(--grey-600);
  --line: var(--grey-200); --accent: var(--blue); --accent-soft: var(--blue-50);
  --good: #1a8f6f; --good-soft: rgb(28 162 126 / .12);
  --warn: #a86a12; --warn-soft: rgb(196 132 29 / .14);
  --bad: #c93a52; --bad-soft: rgb(214 69 93 / .11);
  /* chart series (validated: light surface) */
  --s-matched: #3f4cff; --s-exempt: #00a3b5; --s-missing: #e8853d;
  --radius: 10px; --radius-sm: 6px;
  --shadow: 0 1px 2px rgb(18 18 44 / .04), 0 8px 20px -10px rgb(18 18 44 / .12);
  --shadow-lg: 0 24px 64px -16px rgb(18 18 44 / .3);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --side: 228px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0c1f; --surface: var(--ink-2); --surface-2: #161636; --text: #ececf7; --muted: #a3a3c2; --line: var(--ink-3);
    --accent: #7c85ff; --accent-soft: rgb(63 76 255 / .2);
    --good: #3ccf9f; --warn: #e2a947; --bad: #f07186;
    --s-matched: #7c85ff; --s-exempt: #159fb0; --s-missing: #d07a3e;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0c1f; --surface: var(--ink-2); --surface-2: #161636; --text: #ececf7; --muted: #a3a3c2; --line: var(--ink-3);
  --accent: #7c85ff; --accent-soft: rgb(63 76 255 / .2);
  --good: #3ccf9f; --warn: #e2a947; --bad: #f07186;
  --s-matched: #7c85ff; --s-exempt: #159fb0; --s-missing: #d07a3e;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 13.5px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { letter-spacing: -.02em; line-height: 1.2; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, td.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ───── Shell ───── */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.shell > div { min-width: 0; }
.side { background: var(--ink); color: #d9d9ea; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 14px; overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; letter-spacing: -.02em; font-size: 16px; padding: 2px 8px 8px; }
.logo i { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--blue), var(--cyan)); display: block; flex: none; }
.logo small { display: block; font-weight: 500; font-size: 12px; color: var(--grey-300); letter-spacing: 0; }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #8a8aac; padding: 12px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 5px 10px; font-size: 13px; border-radius: var(--radius-sm); color: #c9c9de; font-weight: 500; text-decoration: none; transition: background .15s, color .15s, box-shadow .2s var(--ease); }
.nav svg { width: 16px !important; height: 16px !important; }
.nav a:hover { background: var(--ink-2); color: #fff; }
.nav a.active { background: var(--ink-3); color: #fff; box-shadow: inset 3px 0 0 var(--cyan); }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav .count { margin-left: auto; background: var(--blue); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.nav .count.hot { background: #e8853d; color: var(--ink); }
.side-foot { margin-top: auto; padding: 12px 10px 0; position: sticky; bottom: -18px; background: var(--ink); padding-bottom: 4px; font-size: 12px; color: #8a8aac; border-top: 1px solid var(--ink-3); }
.side-foot b { color: #d9d9ea; font-weight: 600; }

.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px clamp(16px, 3vw, 32px); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top h1 { font-size: 17px; margin: 0; letter-spacing: -.01em; }
.top .crumb { color: var(--muted); font-size: 13px; }
.top .spacer { flex: 1; }
.top .menu-btn { display: none; }
.content { padding: 20px clamp(16px, 2.2vw, 28px) 56px; max-width: 1680px; margin-inline: auto; }
.demo-banner { display: none; background: var(--accent-soft); color: var(--accent); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 13px; font-weight: 500; margin-bottom: 16px; }
.is-demo .demo-banner { display: block; }

/* ───── Controls ───── */
.btn { appearance: none; border: 1px solid transparent; border-radius: var(--radius-sm); padding: 8px 14px; font-weight: 600; font-size: 13.5px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; background: none; text-decoration: none !important; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--blue); color: #fff; } .btn-primary:hover { background: #5763ff; }
.btn-cyan { background: var(--cyan); color: var(--ink); } .btn-cyan:hover { background: var(--cyan-300); }
.btn-ghost { border-color: var(--line); color: var(--text); background: var(--surface); } .btn-ghost:hover { border-color: var(--muted); }
.btn-danger { border-color: var(--bad-soft); color: var(--bad); background: var(--surface); } .btn-danger:hover { border-color: var(--bad); }
.btn-sm { padding: 3px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.input, select.input, textarea.input { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 6px 10px; min-width: 0; font-size: 13.5px; }
.input:focus, .btn:focus-visible, .nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters .grow { flex: 1 1 220px; }
label.field { display: grid; gap: 4px; font-size: 13px; font-weight: 600; }
label.field span { color: var(--muted); font-weight: 500; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 12px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.tabs a.active { color: var(--text); border-color: var(--accent); }
.tabs .count { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; font-size: 11.5px; padding: 0 7px; margin-left: 6px; color: var(--muted); }

/* ───── Surfaces ───── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s; }
a.card:hover, .card.click:hover { transform: translateY(-2px); box-shadow: 0 10px 28px -12px rgb(18 18 44 / .25); }
.panel { padding: 14px 16px; min-width: 0; }
.panel > h2 { font-size: 14px; margin: 0 0 2px; }
.panel > .hint { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.panel-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { font-size: 14px; margin: 0; }
.panel-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.panel-head .right { margin-left: auto; display: flex; gap: 8px; }
.grid { display: grid; gap: 12px; }
.g-kpi { grid-template-columns: repeat(5, 1fr); }
.g-2 { grid-template-columns: 1.6fr 1fr; }
.g-2e { grid-template-columns: 1fr 1fr; }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.stack { display: grid; gap: 16px; }

.kpi { padding: 12px 16px; }
.kpi { position: relative; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 20px; font-weight: 750; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 11.5px; }
.kpi .spark { position: absolute; right: 10px; bottom: 10px; width: 72px; height: 26px; opacity: .9; }
.kpi .spark path.line { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 200; stroke-dashoffset: 200; animation: draw 1s .2s var(--ease) forwards; }
.kpi .spark path.area { fill: var(--accent-soft); opacity: 0; animation: fadeIn .6s .5s forwards; }
.kpi.bad .spark path.line { stroke: var(--bad); } .kpi.good .spark path.line { stroke: var(--good); }
.kpi .sub { font-size: 12.5px; color: var(--muted); }
.kpi.good .value { color: var(--good); } .kpi.bad .value { color: var(--bad); }
a.kpi { color: inherit; text-decoration: none; display: block; } a.kpi:hover { border-color: var(--accent); }

/* ───── Tables ───── */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 13.5px; line-height: 1.35; height: 36px; white-space: nowrap; }
td.wrap, .finding td { white-space: normal; }
td.wrap .sub { white-space: normal; }
tbody tr { max-height: 48px; }
tr:last-child td { border-bottom: 0; }
th.num, td.num { text-align: right; white-space: nowrap; }
td.num { font-weight: 600; }
td.neg { color: var(--good); }
tbody tr.click { cursor: pointer; } tbody tr.click:hover { background: var(--surface-2); }
td .sub { display: block; font-size: 11.5px; line-height: 1.3; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
td b { font-weight: 600; }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn + .btn { margin-left: 4px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 4px 0; color: var(--muted); font-size: 13px; gap: 8px; flex-wrap: wrap; }
.empty { text-align: center; padding: 36px 12px; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.info { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; margin: 0 6px 6px 0; }
.chip button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 6px; font-size: 15px; line-height: 1; }

/* ───── Findings ───── */
.finding { display: grid; grid-template-columns: 4px 1fr auto; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.finding:first-child { border-top: 0; padding-top: 4px; }
.sev { border-radius: 3px; }
.sev.high { background: var(--bad); } .sev.medium { background: var(--warn); } .sev.low { background: var(--grey-300); }
.finding h3 { font-size: 13.5px; margin: 0 0 2px; letter-spacing: -.01em; }
.finding p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.finding .meta { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; align-items: center; }
.save { text-align: right; font-weight: 700; color: var(--good); white-space: nowrap; font-variant-numeric: tabular-nums; }
.save small { display: block; font-weight: 500; color: var(--muted); font-size: 11.5px; }

/* ───── Charts ───── */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11.5px; }
.chart .bar { transition: opacity .15s; }
.chart .col:hover .bar, .chart .row:hover .bar { opacity: .85; }
.chart .hit { fill: transparent; cursor: default; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tooltip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; border-radius: var(--radius-sm); padding: 8px 10px; font-size: 12.5px; box-shadow: var(--shadow-lg); white-space: nowrap; z-index: 5; opacity: 0; transition: opacity .1s; }
.tooltip.show { opacity: 1; }
.tooltip b { display: block; margin-bottom: 2px; }
.tooltip .row { display: flex; gap: 12px; justify-content: space-between; }
.tooltip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 140px) 1fr auto; gap: 10px; align-items: center; padding: 3px 0; font-size: 13px; }
.hbar .track { height: 10px; background: var(--surface-2); border-radius: 0 4px 4px 0; }
.hbar .fill { height: 100%; background: var(--s-matched); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font-weight: 600; font-size: 12.5px; }

/* ───── Lists ───── */
.list-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; min-height: 40px; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--good); flex: none; }
.dot.off { background: var(--grey-300); } .dot.bad { background: var(--bad); }
.attn { display: flex; align-items: center; gap: 12px; padding: 6px 12px; min-height: 44px; border-radius: var(--radius-sm); border: 1px solid var(--line); color: inherit; text-decoration: none !important; }
.attn:hover { border-color: var(--accent); }
.attn .n { font-size: 18px; font-weight: 800; min-width: 44px; font-variant-numeric: tabular-nums; }
.attn small { display: block; color: var(--muted); }

/* ───── Drawer / modal / toast ───── */
.scrim { position: fixed; inset: 0; background: rgb(12 12 31 / .45); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); background: var(--surface); z-index: 50; transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 18px; }
.drawer-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.drawer-head .x { margin-left: auto; }
.drawer-body { padding: 18px 20px 40px; overflow-y: auto; display: grid; gap: 20px; align-content: start; }
.drawer-body h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.drawer-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.big-amount { font-size: 30px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.flag { display: flex; gap: 8px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--text); font-size: 13px; }
.flag + .flag { margin-top: 6px; }
.flag::before { content: "!"; flex: none; width: 18px; height: 18px; border-radius: 50%; background: var(--warn); color: #fff; font-weight: 800; font-size: 12px; display: grid; place-items: center; }
.doc-preview { border: 1px solid var(--line); border-radius: var(--radius-sm); height: 420px; width: 100%; background: var(--surface-2); }
.doc-placeholder { border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 28px; text-align: center; color: var(--muted); background: var(--surface-2); }
.candidate { display: flex; gap: 12px; align-items: center; padding: 6px 10px; min-height: 44px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.candidate + .candidate { margin-top: 6px; }
.candidate .grow { flex: 1; min-width: 0; }
.score { font-size: 12px; font-weight: 700; color: var(--accent); }

.modal { position: fixed; inset: 0; z-index: 60; display: none; place-items: center; padding: 16px; }
.modal.open { display: grid; }
.modal > .scrim { z-index: 0; }
.modal .card { z-index: 1; width: min(520px, 100%); padding: 20px; box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto; }
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal p.hint { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.modal .row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 70; display: grid; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: 13.5px; animation: pop .2s ease; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

.steps { counter-reset: s; display: grid; gap: 10px; }
.steps li { list-style: none; display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start; }
.steps li::before { counter-increment: s; content: counter(s); width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12px; display: grid; place-items: center; }
.steps p { margin: 0; color: var(--muted); font-size: 13px; }
code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-size: 12.5px; }

/* ───── Entity switcher ───── */
.entity-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--surface); margin-left: 8px; }
.entity-switch .seg { border: 0; background: none; padding: 4px 12px; border-radius: 999px; font: 600 12.5px var(--font); color: var(--muted); cursor: pointer; white-space: nowrap; }
.entity-switch .seg small { font-weight: 500; opacity: .8; }
.entity-switch .seg.on { background: var(--ink); color: #fff; }
body[data-entity="pk"] .entity-switch .seg.on { background: #01411c; }
.entity-chip { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.scope-switch { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.scope-switch a { padding: 6px 10px; font-size: 12.5px; font-weight: 600; color: var(--muted); text-decoration: none; background: var(--surface); }
.scope-switch a.on { background: var(--accent-soft); color: var(--accent); }
.lane-note { font-size: 12.5px; color: var(--muted); margin: -6px 0 12px; }
@media (max-width: 860px) { .entity-switch { order: 4; margin-left: 0; } }

/* ───── Financial tables ───── */
table.fin td, table.fin th { white-space: nowrap; }
table.fin td:first-child { white-space: normal; min-width: 200px; }
table.fin tr.group td { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); height: 28px; }
table.fin td.indent { padding-left: 22px; }
table.fin tr.sub-total td { font-weight: 600; border-top: 1px solid var(--muted); }
table.fin tr.total td { font-weight: 700; background: var(--accent-soft); border-top: 2px solid var(--text); }
table.fin tr.strong td, td.strong { font-weight: 600; }
table.fin tr.adj td:first-child { padding-left: 22px; color: var(--text); }
td.neg-red { color: var(--bad); }
.link-btn.plain { color: var(--text); font-weight: 500; font-size: 13.5px; text-align: left; }
.link-btn.plain:hover { color: var(--accent); text-decoration: underline; }

/* ───── Upload ───── */
.dropzone { display: grid; place-items: center; gap: 4px; text-align: center; padding: 28px 16px; border: 2px dashed var(--line); border-radius: var(--radius); background: var(--surface-2); color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; margin-top: 8px; }
.dropzone b { color: var(--text); }
.dropzone span { font-size: 12.5px; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.filelist { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; max-height: 220px; overflow-y: auto; }
.filelist li { display: flex; align-items: center; gap: 10px; padding: 4px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 13px; }
.filelist .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filelist button { border: 0; background: none; cursor: pointer; color: var(--muted); }
.drop-overlay { position: fixed; inset: 0; z-index: 80; display: none; place-items: center; background: rgb(63 76 255 / .12); border: 3px dashed var(--blue); pointer-events: none; }
.drop-overlay div { background: var(--blue); color: #fff; font-weight: 700; padding: 14px 22px; border-radius: var(--radius); box-shadow: var(--shadow-lg); }
body.dragging .drop-overlay { display: grid; }

/* ───── Account menu ───── */
.me { display: flex; align-items: center; gap: 10px; }
.me .grow { min-width: 0; }
.me b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me small { color: #8a8aac; text-transform: capitalize; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--blue), var(--cyan)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }
.me-actions { display: flex; gap: 14px; margin-top: 10px; }
.me-actions a, .me-actions button { color: #b9b9d6; font-size: 12.5px; background: none; border: 0; padding: 0; cursor: pointer; }
.me-actions a:hover, .me-actions button:hover { color: #fff; text-decoration: none; }
.demo-chip { display: none; }
.is-demo .demo-chip { display: inline-flex; }

/* ───── Aging ───── */
.aging td.num.zero { color: var(--muted); font-weight: 400; }
.aging td.num.late { color: var(--bad); }
.bucket-bar { display: flex; height: 12px; border-radius: 4px; overflow: hidden; gap: 2px; background: var(--surface); margin: 8px 0 4px; }
.bucket-bar span { display: block; height: 100%; }

/* ───── Responsive ───── */
@media (max-width: 1200px) { .g-kpi { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1000px) { .g-2, .g-2e, .g-3 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 45; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .side { transform: none; }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .top .menu-btn { display: inline-flex; }
  .g-kpi { grid-template-columns: 1fr 1fr; }
  .top .crumb, .top .hide-sm { display: none; }
  .top { flex-wrap: wrap; row-gap: 8px; }
  .top h1 { font-size: 18px; }
  #topActions { order: 5; width: 100%; justify-content: flex-start !important; }
  #topActions:empty { display: none; }
}
@media (max-width: 520px) {
  .g-kpi { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 110px 1fr; }
  .panel { padding: 16px; }
}
@media (forced-colors: active) { .legend i, .bar, .fill { forced-color-adjust: none; } }

/* ───── Motion ───── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { to { opacity: 1; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes grow { from { transform: scaleY(0); } }
@keyframes fill { from { width: 0; } }
@keyframes shimmer { from { background-position: -400px 0; } to { background-position: 400px 0; } }
.page-enter > *, .page-enter .grid > .card { animation: fadeUp .38s var(--ease) both; }
.page-enter .grid > .card:nth-child(2) { animation-delay: .04s; } .page-enter .grid > .card:nth-child(3) { animation-delay: .08s; }
.page-enter .grid > .card:nth-child(4) { animation-delay: .12s; } .page-enter .grid > .card:nth-child(5) { animation-delay: .16s; }
.page-enter > *:nth-child(2) { animation-delay: .06s; } .page-enter > *:nth-child(3) { animation-delay: .12s; } .page-enter > *:nth-child(4) { animation-delay: .18s; }
.chart .bar { transform-box: fill-box; transform-origin: bottom; animation: grow .7s var(--ease) both; }
.chart .col:nth-child(n) .bar { animation-delay: calc(var(--i, 0) * 60ms); }
.hbar .fill { animation: fill .8s var(--ease) both; }
tbody tr { transition: background .12s; }
.btn { transition: background .15s, border-color .15s, transform .08s, box-shadow .15s; }
.btn:active { transform: scale(.97); }
.btn-primary { box-shadow: 0 1px 0 rgb(255 255 255 / .15) inset, 0 4px 12px -6px rgb(63 76 255 / .6); }
.tabs a { transition: color .15s, border-color .2s var(--ease); }
.pill { transition: background .2s; }
.drawer { transition: transform .32s var(--ease); }
.modal .card { animation: fadeUp .22s var(--ease) both; }
.skeleton { display: grid; gap: 12px; }
.skeleton .sk { border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-2) 0, var(--line) 50%, var(--surface-2) 100%) 0 0 / 800px 100%; animation: shimmer 1.2s linear infinite; }
.skeleton .row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ───── Flags ───── */
.cflag { width: 18px; height: 12px; border-radius: 2px; display: inline-block; vertical-align: -2px; box-shadow: 0 0 0 1px rgb(0 0 0 / .12); overflow: hidden; flex: none; }
.entity-switch .seg { display: inline-flex; align-items: center; gap: 6px; transition: background .2s var(--ease), color .2s; }

/* ───── Command palette ───── */
.search-btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: var(--radius-sm); padding: 6px 10px; font: 500 12.5px var(--font); cursor: pointer; min-width: 220px; transition: border-color .15s; }
.search-btn:hover { border-color: var(--muted); }
.search-btn kbd, .palette kbd { margin-left: auto; font: 600 11px var(--font); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; color: var(--muted); background: var(--surface-2); }
.palette { position: fixed; inset: 0; z-index: 90; display: none; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; background: rgb(12 12 31 / .4); backdrop-filter: blur(2px); }
.palette.open { display: flex; }
.palette .box { width: min(640px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; animation: fadeUp .18s var(--ease) both; }
.palette input { width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; font: 500 15px var(--font); background: transparent; color: var(--text); outline: none; }
.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.palette li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.palette li.on { background: var(--accent-soft); }
.palette li small { color: var(--muted); }
.palette li .right { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.palette .group { padding: 8px 10px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
@media (max-width: 860px) { .search-btn { min-width: 0; } .search-btn span { display: none; } }
