/* Sync2VA CRM — "refined & calm": white surfaces, hairline borders, colour only where it means something.
   Light and dark themes come from the same tokens; nothing below uses a raw colour except the tokens. */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  --bg: #f5f6f8;            /* page plane */
  --surface: #ffffff;       /* cards, tables */
  --surface-2: #fafbfc;     /* table heads, quiet panels */
  --surface-3: #f1f3f6;     /* hover, chips, tracks */
  --surface-4: #e8ebf0;     /* pressed, strong track */
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #475467;
  --text-3: #667085;        /* muted text, 4.8:1 on white */
  --text-4: #98a2b3;        /* placeholders, icons */
  --overlay: rgba(16, 24, 40, .45);

  --brand: #1d6fbb;         /* Sync2VA blue */
  --brand-hover: #185f9f;
  --brand-soft: #ebf3fb;
  --brand-ink: #175a99;
  --accent: #f28c28;        /* Sync2VA orange */
  --accent-soft: #fff4e8;
  --navy: #142030;
  --on-brand: #ffffff;
  --focus: rgba(29, 111, 187, .35);

  /* Stages: dot / bar colour, soft background, readable text */
  --st-paid: #1a9e5c;  --st-paid-bg: #e9f7ef;  --st-paid-ink: #10683c;
  --st-part: #eda100;  --st-part-bg: #fdf4dd;  --st-part-ink: #835600;
  --st-check: #2a78d6; --st-check-bg: #eaf2fc; --st-check-ink: #1c5aa8;
  --st-bad: #e34948;   --st-bad-bg: #fdecec;   --st-bad-ink: #b02a29;
  --st-none: #98a2b3;  --st-none-bg: #f1f3f6;  --st-none-ink: #475467;
  --st-dropped: #c2512b; --st-dropped-bg: #fbeee8; --st-dropped-ink: #973d1f;
  --st-done: #6250d6;  --st-done-bg: #f0eefc;  --st-done-ink: #4a3bb5;
  --track: #e9edf2;

  /* Programs (fixed order by program; validated light) */
  --p1: #2a78d6; --p2: #eb6834; --p3: #1baf7a; --p4: #eda100; --p5: #e87ba4; --p6: #008300; --p7: #6250d6; --p8: #e34948;
  --grid: #eef0f3;
  --axis: #d0d5dd;

  --success: #10683c; --success-bg: #e9f7ef; --success-border: #b7e3c9;
  --danger: #b02a29;  --danger-bg: #fdecec;  --danger-border: #f5c2c1;
  --info: #1c5aa8;    --info-bg: #eaf2fc;    --info-border: #c2d9f4;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 4px 12px -2px rgba(16, 24, 40, .08), 0 2px 4px -2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 20px 48px -12px rgba(16, 24, 40, .22), 0 4px 10px -4px rgba(16, 24, 40, .08);
  --sidebar-w: 248px;
  --header-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1117; --surface: #151a22; --surface-2: #181e27; --surface-3: #1f2630; --surface-4: #29313d;
    --border: #262e39; --border-strong: #354050;
    --text: #e8ecf1; --text-2: #b6c0cd; --text-3: #8d98a8; --text-4: #677385; --overlay: rgba(0, 0, 0, .6);
    --brand: #2f7fd0; --brand-hover: #3d8ddc; --brand-soft: #172a40; --brand-ink: #8cbdf0; --accent-soft: #33240f;
    --focus: rgba(76, 148, 224, .45);
    --st-paid: #22a06b;  --st-paid-bg: #12291f;  --st-paid-ink: #6fd3a1;
    --st-part: #c98500;  --st-part-bg: #2e2410;  --st-part-ink: #f0c25c;
    --st-check: #3987e5; --st-check-bg: #13253b; --st-check-ink: #8cbdf0;
    --st-bad: #e66767;   --st-bad-bg: #331a1c;   --st-bad-ink: #f4a0a0;
    --st-none: #6b7787;  --st-none-bg: #1f2630;  --st-none-ink: #b6c0cd;
    --st-dropped: #d9744f; --st-dropped-bg: #33201a; --st-dropped-ink: #f2a98c;
    --st-done: #9085e9;  --st-done-bg: #221f3d;  --st-done-ink: #c2bbf6;
    --track: #252d38;
    --p1: #3987e5; --p2: #d95926; --p3: #199e70; --p4: #c98500; --p5: #d55181; --p6: #008300; --p7: #9085e9; --p8: #e66767;
    --grid: #202833; --axis: #354050;
    --success: #6fd3a1; --success-bg: #12291f; --success-border: #1f4a36;
    --danger: #f4a0a0;  --danger-bg: #331a1c;  --danger-border: #5a2a2c;
    --info: #8cbdf0;    --info-bg: #13253b;    --info-border: #234467;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .35);
    --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, .45);
    --shadow-lg: 0 24px 56px -12px rgba(0, 0, 0, .65);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117; --surface: #151a22; --surface-2: #181e27; --surface-3: #1f2630; --surface-4: #29313d;
  --border: #262e39; --border-strong: #354050;
  --text: #e8ecf1; --text-2: #b6c0cd; --text-3: #8d98a8; --text-4: #677385; --overlay: rgba(0, 0, 0, .6);
  --brand: #2f7fd0; --brand-hover: #3d8ddc; --brand-soft: #172a40; --brand-ink: #8cbdf0; --accent-soft: #33240f;
  --focus: rgba(76, 148, 224, .45);
  --st-paid: #22a06b;  --st-paid-bg: #12291f;  --st-paid-ink: #6fd3a1;
  --st-part: #c98500;  --st-part-bg: #2e2410;  --st-part-ink: #f0c25c;
  --st-check: #3987e5; --st-check-bg: #13253b; --st-check-ink: #8cbdf0;
  --st-bad: #e66767;   --st-bad-bg: #331a1c;   --st-bad-ink: #f4a0a0;
  --st-none: #6b7787;  --st-none-bg: #1f2630;  --st-none-ink: #b6c0cd;
  --st-dropped: #d9744f; --st-dropped-bg: #33201a; --st-dropped-ink: #f2a98c;
  --st-done: #9085e9;  --st-done-bg: #221f3d;  --st-done-ink: #c2bbf6;
  --track: #252d38;
  --p1: #3987e5; --p2: #d95926; --p3: #199e70; --p4: #c98500; --p5: #d55181; --p6: #008300; --p7: #9085e9; --p8: #e66767;
  --grid: #202833; --axis: #354050;
  --success: #6fd3a1; --success-bg: #12291f; --success-border: #1f4a36;
  --danger: #f4a0a0;  --danger-bg: #331a1c;  --danger-border: #5a2a2c;
  --info: #8cbdf0;    --info-bg: #13253b;    --info-border: #234467;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .35);
  --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, .45);
  --shadow-lg: 0 24px 56px -12px rgba(0, 0, 0, .65);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 var(--font); font-feature-settings: 'cv11', 'ss01'; -webkit-font-smoothing: antialiased; }
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 24px; font-weight: 650; letter-spacing: -.022em; line-height: 1.2; margin-bottom: 4px; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; margin-bottom: 8px; }
h3 { font-size: 14px; font-weight: 600; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--brand-soft); }
.icon { flex: none; vertical-align: -3px; }
.mono { font-family: var(--mono); }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.eyebrow { font-size: 11px; letter-spacing: .08em; font-weight: 600; text-transform: uppercase; color: var(--text-3); margin: 0 0 6px; }
.hint { font-size: 12.5px; color: var(--text-3); margin: -4px 0 14px; }
.due, .num.due, td.due { color: var(--st-bad-ink); }
.num.ok { color: var(--st-paid-ink); }
.tick { color: var(--st-paid); font-weight: 700; }
.empty { color: var(--text-3); margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
html:not(.js) .js-only { display: none !important; }
code { font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
.num, .tnum, .table td.num { font-variant-numeric: tabular-nums; }

/* ---------- App shell ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--surface-2); border-right: 1px solid var(--border); padding: 14px 12px 12px; display: flex; flex-direction: column; z-index: 40; overflow-y: auto; transition: width .18s ease; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 650; color: var(--text); letter-spacing: -.01em; padding: 6px 8px; margin-bottom: 14px; }
.brand:hover { text-decoration: none; }
.brand small { display: block; font-size: 11.5px; font-weight: 500; color: var(--text-3); letter-spacing: 0; margin-top: -1px; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(140deg, #1d6fbb 0%, #3b8fe0 60%, #7bb8ee 100%); color: #fff; font: 700 15px var(--font); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18), 0 1px 2px rgba(16, 24, 40, .2); flex: none; }
.brand-text { line-height: 1.15; }
.sidebar nav { display: grid; gap: 1px; }
.nav-label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-4); font-weight: 600; padding: 14px 10px 6px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 10px; color: var(--text-2); padding: 7px 10px; border-radius: 8px; font: 500 13.5px var(--font); border: 0; background: none; width: 100%; cursor: pointer; text-align: left; white-space: nowrap; }
.nav-item .icon { color: var(--text-4); }
.nav-item:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-item:hover .icon { color: var(--text-2); }
.nav-item.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs), inset 0 0 0 1px var(--border); font-weight: 600; }
.nav-item.active .icon { color: var(--brand); }
.nav-item.small { font-size: 12.5px; padding: 6px 10px; }
.nav-count { margin-left: auto; background: var(--accent); color: #1b1206; border-radius: 99px; font-size: 11px; font-weight: 700; padding: 0 7px; min-width: 20px; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.sidebar-bottom { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); display: grid; gap: 2px; }
.profile { display: flex; align-items: center; gap: 10px; padding: 6px 8px 8px; min-width: 0; }
.profile b, .profile small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile b { font-size: 13px; font-weight: 600; }
.profile small { font-size: 11.5px; color: var(--text-3); }
.avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--av, #dbe7f5); color: var(--av-ink, #1c4f86); font-weight: 650; font-size: 11px; flex: none; letter-spacing: .02em; }
.avatar.sm { width: 26px; height: 26px; font-size: 10px; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.av-0 { --av: #dbe7f5; --av-ink: #1c4f86; } .av-1 { --av: #fde6d6; --av-ink: #8c3d12; } .av-2 { --av: #d7f2e6; --av-ink: #12603f; }
.av-3 { --av: #fbefc9; --av-ink: #7a5300; } .av-4 { --av: #fadfe9; --av-ink: #8c2c52; } .av-5 { --av: #e6e2fb; --av-ink: #45389e; }
.av-6 { --av: #d6f0f2; --av-ink: #105a62; } .av-7 { --av: #ececec; --av-ink: #444b55; }
:root[data-theme="dark"] .avatar { --av: #26303d; --av-ink: #c7d3e2; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { --av: #26303d; --av-ink: #c7d3e2; } }

.theme-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; background: var(--surface-3); border-radius: 8px; padding: 2px; margin: 4px 2px 6px; }
.theme-switch button { border: 0; background: none; color: var(--text-3); font: 500 12px var(--font); padding: 5px 0; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }

.collapse-btn { position: absolute; top: 18px; right: 10px; border: 0; background: none; color: var(--text-4); cursor: pointer; padding: 4px; border-radius: 6px; }
.collapse-btn:hover { background: var(--surface-3); color: var(--text); }
body.nav-collapsed { --sidebar-w: 68px; }
body.nav-collapsed .sidebar .nav-label, body.nav-collapsed .sidebar .brand-text, body.nav-collapsed .sidebar .nav-text,
body.nav-collapsed .sidebar .profile span:last-child, body.nav-collapsed .theme-switch .t-label { display: none; }
body.nav-collapsed .sidebar .nav-item { justify-content: center; padding: 8px; }
body.nav-collapsed .sidebar .nav-count { position: absolute; top: 2px; right: 4px; min-width: 16px; line-height: 15px; padding: 0 4px; font-size: 10px; }
body.nav-collapsed .collapse-btn { position: static; margin: 0 auto 8px; display: block; transform: rotate(180deg); }
body.nav-collapsed .theme-switch { grid-template-columns: 1fr; }
body.nav-collapsed .profile { justify-content: center; padding: 6px 0; }

.app-header { position: sticky; top: 0; z-index: 30; height: var(--header-h); display: flex; align-items: center; gap: 12px; padding: 0 32px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(180%) blur(10px); -webkit-backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid transparent; }
.app-header.scrolled { border-bottom-color: var(--border); }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 13px; min-width: 0; }
.crumbs b { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.search-trigger { display: inline-flex; align-items: center; gap: 8px; width: 300px; max-width: 40vw; height: 34px; padding: 0 8px 0 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text-4); font: 13px var(--font); cursor: pointer; box-shadow: var(--shadow-xs); text-decoration: none; }
.search-trigger:hover { border-color: var(--border-strong); color: var(--text-3); text-decoration: none; }
.search-trigger span { flex: 1; text-align: left; }
kbd, .kbd { font: 600 11px var(--font); color: var(--text-3); background: var(--surface-3); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; line-height: 17px; }
.topbar { display: none; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; transition: margin-left .18s ease; }
.content { max-width: 1600px; padding: 20px 32px 64px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p.muted { margin: 2px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-3); margin-bottom: 8px; }
.back:hover { color: var(--text); text-decoration: none; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow-xs); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.table-card { padding: 0; overflow: clip; }
.table-card > .card-head { padding: 14px 18px 10px; margin: 0; }
.table-card > .empty { padding: 18px 20px; }
.form-card { max-width: 880px; }
.narrow { max-width: 420px; margin: 0 auto; }
.narrow-left { max-width: 520px; }
.note { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

/* ---------- Stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow-xs); color: var(--text); min-width: 0; }
a.stat:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.stat > span { font-size: 12.5px; font-weight: 500; color: var(--text-3); }
.stat b { font-size: 24px; font-weight: 650; letter-spacing: -.02em; line-height: 1.25; }
.stat b.mono { font-family: var(--font); }
.stat b.sm { font-size: 15px; letter-spacing: -.01em; line-height: 1.4; }
.stat b.due { color: var(--st-bad-ink); }
.stat small { font-size: 12px; color: var(--text-3); }
.stat.accent b { color: var(--text); }
.delta { font-size: 12px; font-weight: 600; }
.delta.up { color: var(--st-paid-ink); }
.delta.down { color: var(--st-bad-ink); }
.spark { position: absolute; right: 14px; top: 14px; width: 84px; height: 28px; }
.spark path.line { fill: none; stroke: var(--text-4); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark path.area { fill: var(--brand); opacity: .08; }
.spark circle { fill: var(--brand); stroke: var(--surface); stroke-width: 2; }
.hero b { font-size: 28px; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; position: relative; } /* keeps screen-reader-only labels inside it (they are absolutely positioned) */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; color: var(--text-3); font-weight: 500; background: var(--surface-2); border-bottom: 1px solid var(--border); padding: 9px 14px; white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color .08s; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; white-space: nowrap; }
.table.compact td { padding: 7px 12px; }
.table tr.dropped td { color: var(--text-4); }
.table tr.dropped a { color: var(--text-3); }
.table tr.voided td { color: var(--text-4); text-decoration: line-through; text-decoration-color: var(--border-strong); }
.table tr.voided .pill, .table tr.voided .row-actions, .table tr.voided .small { text-decoration: none; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .btn { margin: 2px 0 2px 4px; }
.table td a b, .table td b.code { white-space: nowrap; }
.table td.details { max-width: 420px; word-break: break-word; color: var(--text-3); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-3); flex-wrap: wrap; }
.pager-links { display: flex; align-items: center; gap: 10px; }
.table tfoot td { font-weight: 600; border-top: 1px solid var(--border-strong); border-bottom: 0; background: var(--surface-2); }

/* ---------- Pills, stage badges, tags ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 550; padding: 1px 9px 1px 8px; border-radius: 99px; white-space: nowrap; background: var(--st-none-bg); color: var(--st-none-ink); line-height: 20px; vertical-align: middle; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; flex: none; }
h1 .pill { font-size: 12px; letter-spacing: 0; vertical-align: 4px; }
.pill.stage-paid, .pill-paid, .pill-ongoing, .pill-enrolled { background: var(--st-paid-bg); color: var(--st-paid-ink); }
.pill.stage-part, .pill-partial { background: var(--st-part-bg); color: var(--st-part-ink); }
.pill.stage-check, .pill-upcoming { background: var(--st-check-bg); color: var(--st-check-ink); }
.pill.stage-bad, .pill-unpaid { background: var(--st-bad-bg); color: var(--st-bad-ink); }
.pill.stage-none, .pill-completed { background: var(--st-none-bg); color: var(--st-none-ink); }
.pill.stage-dropped { background: var(--st-dropped-bg); color: var(--st-dropped-ink); }
.pill.stage-done { background: var(--st-done-bg); color: var(--st-done-ink); }
.tag { display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 500; padding: 0 7px; line-height: 19px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border); margin: 1px 4px 1px 0; white-space: nowrap; }
.to-verify { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--st-check-ink); font-weight: 600; margin-top: 3px; }
.to-verify::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--st-check); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: 8px; padding: 7px 12px; font: 550 13px/1.3 var(--font); cursor: pointer; box-shadow: var(--shadow-xs); transition: background-color .1s, border-color .1s, box-shadow .1s; text-decoration: none; }
.btn:hover { text-decoration: none; background: var(--surface-2); border-color: var(--text-4); }
.btn:active { background: var(--surface-3); }
.btn .icon { color: var(--text-3); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); box-shadow: 0 1px 2px rgba(16, 24, 40, .12), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-primary .icon { color: currentColor; opacity: .9; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--text); }
.btn-danger { background: #c23b3a; border-color: #c23b3a; color: #fff; }
.btn-danger:hover { background: #a93130; border-color: #a93130; }
.btn-sm { padding: 4px 9px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { padding: 10px 16px; font-size: 14px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-icon { padding: 6px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand-ink); cursor: pointer; font: inherit; }
.link-btn:hover { text-decoration: underline; }
.link-btn.small { font-size: 12px; }
.inline-form { display: inline; margin: 0; }

/* ---------- Forms ---------- */
.form label { display: block; font-size: 13px; font-weight: 550; color: var(--text-2); margin-bottom: 14px; }
.form label small { font-weight: 400; color: var(--text-3); }
.form input:not([type=checkbox]):not([type=radio]), .form select, .form textarea, .filters input:not([type=checkbox]), .filters select {
  display: block; width: 100%; margin-top: 6px; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); font: 13.5px var(--font); box-shadow: var(--shadow-xs); transition: border-color .1s, box-shadow .1s;
}
.form input[disabled] { background: var(--surface-3); color: var(--text-3); box-shadow: none; }
.form textarea { resize: vertical; line-height: 1.5; }
.form input:focus, .form select:focus, .form textarea:focus, .filters input:focus, .filters select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus); }
::placeholder { color: var(--text-4); }
.form .check, .check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); font-size: 13.5px; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); flex: none; }
.form fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px 2px; margin: 0 0 16px; }
.form legend { font-size: 12px; font-weight: 600; color: var(--text-3); padding: 0 6px; text-transform: uppercase; letter-spacing: .06em; }
.row-2, .row-3, .row-4 { display: grid; gap: 0 14px; }
.row-2 { grid-template-columns: 1fr 1fr; }
.row-3 { grid-template-columns: 1fr 1fr 1fr; }
.row-2 > *, .row-3 > *, .row-4 > * { min-width: 0; }
.field-error { display: block; color: var(--st-bad-ink); font-weight: 500; font-size: 12px; margin-top: 5px; }
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.form-actions.separated { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
h2.sub { font-size: 14px; margin: 22px 0 6px; }
.price-grid { display: grid; grid-template-columns: minmax(0, 1fr) 160px 56px; gap: 6px 10px; align-items: center; margin-bottom: 6px; }
.price-grid input:not([type=checkbox]) { margin-top: 0 !important; }
.price-grid .check { margin: 0; justify-content: center; }
.price-head { font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); margin-bottom: 4px; }
.price-head span:last-child { text-align: center; }
.price-error { grid-column: 1 / -1; margin-top: -2px; }
.tag-checks { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.tag-checks .check { margin: 0; font-size: 13px; padding: 5px 10px 5px 8px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface); cursor: pointer; }
.tag-checks .check:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); }
.pay-optional { border-style: dashed !important; background: var(--surface-2); }
.fill-balance { margin: -8px 0 12px; display: block; }

/* ---------- Filters bar ---------- */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filters input:not([type=checkbox]), .filters select { margin-top: 0; width: auto; padding: 6px 10px; font-size: 13px; height: 34px; }
.filters select { padding-right: 28px; }
.filters .search { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 0 10px; flex: 1 1 240px; color: var(--text-4); height: 34px; box-shadow: var(--shadow-xs); max-width: 360px; }
.filters .search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus); }
.filters .search input { border: 0; outline: 0; padding: 0; width: 100%; box-shadow: none; height: 32px; background: transparent; }
.filters .search input:focus { box-shadow: none; }
.filters .inline { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-3); }
.filters .check { font-size: 13px; color: var(--text-2); white-space: nowrap; height: 34px; }
.filter-sep { display: inline-block; width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.result-note { font-size: 12.5px; color: var(--text-3); margin: -4px 0 12px; }

/* ---------- Flash & toasts ---------- */
.flash { border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 13.5px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; }
.flash-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.flash-error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.flash-info { background: var(--info-bg); border-color: var(--info-border); color: var(--info); }
.toasts { position: fixed; top: 14px; right: 18px; z-index: 90; display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); }
.toasts .flash { margin: 0; background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-lg); padding: 12px 12px 12px 14px; animation: toast-in .22s cubic-bezier(.2, .9, .3, 1.2); }
.toasts .flash::before { content: ''; width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--st-check); }
.toasts .flash-success::before { background: var(--st-paid); }
.toasts .flash-error { border-color: var(--danger-border); }
.toasts .flash-error::before { background: var(--st-bad); }
.toasts .flash .toast-text { flex: 1; }
.toast-close { border: 0; background: none; color: var(--text-4); cursor: pointer; padding: 0 2px; font-size: 18px; line-height: 1; }
.toast-close:hover { color: var(--text); }
.toasts .flash.leaving { opacity: 0; transform: translateY(-6px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Tabs & view switch ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; padding: 3px; background: var(--surface-3); border-radius: 10px; width: fit-content; max-width: 100%; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; color: var(--text-3); font-weight: 550; font-size: 13px; white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tab small { color: var(--text-4); font-weight: 500; font-size: 12px; }
.tab .dot { width: 8px; height: 8px; border-radius: 3px; flex: none; }
.board-tools { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.view-switch { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--surface-3); gap: 2px; }
.view-switch a { padding: 5px 10px; font-weight: 550; font-size: 12.5px; color: var(--text-3); display: inline-flex; gap: 6px; align-items: center; border-radius: 7px; }
.view-switch a:hover { text-decoration: none; color: var(--text); }
.view-switch a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }
.view-switch a.active .icon { color: var(--brand); }

/* ---------- Battery: payment stages as one bar ---------- */
.battery { display: flex; gap: 2px; height: 8px; border-radius: 99px; overflow: hidden; background: var(--track); min-width: 120px; }
.battery span { display: block; height: 100%; min-width: 3px; flex-shrink: 1; flex-basis: 0; }
.b-paid { background: var(--st-paid); } .b-part { background: var(--st-part); } .b-check { background: var(--st-check); } .b-bad { background: var(--st-bad); } .b-none { background: transparent; }
.battery.lg { height: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--text-2); margin: 0; padding: 0; list-style: none; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend .key { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend b { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.legend a { color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; border-radius: 6px; padding: 1px 4px; margin: -1px -4px; }
.legend a:hover { background: var(--surface-3); text-decoration: none; color: var(--text); }
.legend a.on { background: var(--brand-soft); color: var(--brand-ink); }
.key.k-paid { background: var(--st-paid); } .key.k-part { background: var(--st-part); } .key.k-check { background: var(--st-check); } .key.k-bad { background: var(--st-bad); } .key.k-none { background: var(--track); box-shadow: inset 0 0 0 1px var(--border-strong); }
.board-summary { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 14px; }
.board-summary .battery { flex: 1 1 260px; max-width: 520px; height: 10px; }
.board-summary .total { font-size: 13px; color: var(--text-3); white-space: nowrap; }
.board-summary .total b { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------- Board: one card per batch ---------- */
.group-card { padding: 0; overflow: clip; }
.group-card > summary { list-style: none; cursor: pointer; }
.group-card > summary::-webkit-details-marker { display: none; }
.group-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px 14px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.group-card:not([open]) .group-head { border-bottom: 0; }
.group-head .chev { color: var(--text-4); transition: transform .15s; display: inline-flex; }
.group-card[open] .group-head .chev { transform: rotate(90deg); }
.group-head .group-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.group-head h2 { margin: 0; font-size: 15px; font-weight: 650; }
.group-head h2 small { font-size: 12.5px; color: var(--text-3); font-weight: 500; margin-left: 6px; }
.group-head .when { font-size: 11.5px; font-weight: 600; color: var(--text-3); background: var(--surface-3); border-radius: 99px; padding: 0 8px; line-height: 20px; }
.group-head .when.soon { background: var(--accent-soft); color: color-mix(in srgb, var(--accent) 60%, var(--text)); }
.group-head .when.live { background: var(--st-paid-bg); color: var(--st-paid-ink); }
.group-meter { display: flex; align-items: center; gap: 10px; min-width: 0; }
.group-meter .battery { flex: 1 1 140px; max-width: 220px; }
.group-meter .ratio { font-size: 12px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.group-sums { display: flex; gap: 2px 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.group-sums b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.group-sums .due b { color: var(--st-bad-ink); }
.group-card.no-batch .group-head h2::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 8px; vertical-align: 1px; }
.moved-out { padding: 10px 16px; font-size: 12.5px; color: var(--text-3); border-top: 1px solid var(--border); margin: 0; background: var(--surface-2); }
.table.board td { padding-top: 8px; padding-bottom: 8px; }
.table.board tbody tr { cursor: default; }
.who { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.who > span:last-child { min-width: 0; }
.who b { display: block; font-weight: 600; color: var(--text); }
.who a:hover b { color: var(--brand-ink); }
.who small { display: block; color: var(--text-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.table.board .tags-cell { max-width: 200px; }
.peek-btn { opacity: 0; transition: opacity .1s; }
.table tbody tr:hover .peek-btn, .peek-btn:focus-visible { opacity: 1; }
@media (hover: none) { .peek-btn { opacity: 1; } }
.paybar { display: block; height: 4px; border-radius: 99px; background: var(--track); overflow: hidden; margin-top: 5px; min-width: 70px; }
.paybar i { display: block; height: 100%; background: var(--st-paid); border-radius: 99px; }
.paybar.part i { background: var(--st-part); }

/* ---------- Board: pipeline ---------- */
.pipeline { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(200px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 12px; align-items: start; scroll-snap-type: x proximity; }
.lane { background: var(--surface-3); border-radius: 12px; padding: 8px; min-width: 0; scroll-snap-align: start; border: 1px solid var(--border); }
.lane-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 6px 2px; }
.lane-head h2 { margin: 0; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.lane-head h2::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--st-none); }
.lane.stage-paid h2::before { background: var(--st-paid); } .lane.stage-part h2::before { background: var(--st-part); }
.lane.stage-check h2::before { background: var(--st-check); } .lane.stage-bad h2::before { background: var(--st-bad); }
.lane.stage-dropped h2::before { background: var(--st-dropped); } .lane.stage-done h2::before { background: var(--st-done); }
.lane-head .count { font-size: 11.5px; font-weight: 600; color: var(--text-3); background: var(--surface); border: 1px solid var(--border); border-radius: 99px; padding: 0 8px; line-height: 18px; font-variant-numeric: tabular-nums; }
.lane-sum { font-size: 12px; color: var(--text-3); padding: 0 6px 8px; font-variant-numeric: tabular-nums; }
.deal-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 11px; margin-bottom: 6px; color: var(--text); box-shadow: var(--shadow-xs); transition: border-color .1s, box-shadow .1s, transform .1s; }
.deal-card:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.dc-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.dc-name { font-weight: 600; display: block; line-height: 1.3; }
.dc-meta { font-size: 12px; color: var(--text-3); display: block; }
.dc-money { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0 8px; font-size: 12px; margin-top: 8px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.dc-money .due { color: var(--st-bad-ink); font-weight: 600; }
.deal-card .paybar { margin-top: 6px; }
.lane-empty { font-size: 12px; color: var(--text-4); padding: 10px 6px; margin: 0; text-align: center; border: 1px dashed var(--border-strong); border-radius: 10px; }
.lane-more { display: block; font-size: 12px; text-align: center; padding: 6px; }

/* ---------- Enrollee page ---------- */
.deal-hero { display: flex; align-items: center; gap: 14px; }
.deal-hero h1 { margin: 0 0 2px; }
.deal-hero p { margin: 0; }
.deal-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: 16px; align-items: start; }
.deal-main, .deal-side { min-width: 0; }
.facts { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 8px 12px; margin: 0; font-size: 13.5px; }
.facts dt { color: var(--text-3); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.sums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.sum { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.sum span { display: block; font-size: 12px; color: var(--text-3); font-weight: 500; }
.sum b { font-size: 19px; font-weight: 650; letter-spacing: -.015em; }
.sum small { display: block; font-size: 12px; }
.sum.due b { color: var(--st-bad-ink); }
.sum.ok b { color: var(--st-paid-ink); }
.pay-progress { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 12.5px; color: var(--text-3); }
.pay-progress .paybar { flex: 1; height: 6px; margin: 0; }
.pay-form { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 14px; }
.pay-form .row-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.check-actions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.check-more summary { cursor: pointer; font-size: 12px; color: var(--brand-ink); list-style: none; margin-top: 3px; }
.check-more summary::-webkit-details-marker { display: none; }
.pay-table td:nth-child(4) { min-width: 170px; }
.pay-table td:nth-child(5) { min-width: 130px; }
.pay-table .bank-cell b { font-weight: 600; }
.notes-list { list-style: none; margin: 12px 0 0; padding: 0; }
.notes-list li { border-top: 1px solid var(--border); padding: 12px 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; }
.notes-list li:first-child { border-top: 0; }
.note-meta { font-size: 12px; color: var(--text-3); margin: 0 0 2px; }
.note-meta b { color: var(--text); font-weight: 600; }
.note-body { overflow-wrap: anywhere; line-height: 1.55; }
#updates form + .empty { margin-top: 10px; }
.side-form + .side-form { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; }
.side-form label { margin-bottom: 10px; }
.history { list-style: none; padding: 0; margin: 0; }
.history li { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.history li:last-child { border-bottom: 0; }
.timeline { position: relative; }
.timeline li { position: relative; padding: 4px 0 10px 20px; border: 0; font-size: 13px; color: var(--text-2); }
.timeline li::before { content: ''; position: absolute; left: 4px; top: 11px; width: 7px; height: 7px; border-radius: 50%; background: var(--surface); box-shadow: 0 0 0 2px var(--border-strong); }
.timeline li::after { content: ''; position: absolute; left: 7px; top: 20px; bottom: -4px; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline .when { display: block; font-size: 11.5px; color: var(--text-4); }
.timeline b { color: var(--text); font-weight: 600; }

/* ---------- Charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick { fill: var(--text-3); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; font-weight: 400; }
.chart .bar { fill: var(--p1); transition: opacity .1s; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .hit:focus + .bar, .chart g.col:hover .bar { opacity: .78; }
.chart g.col:hover .seg { opacity: .8; }
.chart .today-label { fill: var(--text-2); font-size: 11px; font-weight: 600; font-family: var(--font); }
.chart-foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.p1 { fill: var(--p1); background: var(--p1); } .p2 { fill: var(--p2); background: var(--p2); } .p3 { fill: var(--p3); background: var(--p3); } .p4 { fill: var(--p4); background: var(--p4); }
.p5 { fill: var(--p5); background: var(--p5); } .p6 { fill: var(--p6); background: var(--p6); } .p7 { fill: var(--p7); background: var(--p7); } .p8 { fill: var(--p8); background: var(--p8); } .p0 { fill: var(--text-4); background: var(--text-4); }
.tooltip { position: fixed; z-index: 95; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 8px 10px; font-size: 12px; min-width: 120px; max-width: 260px; opacity: 0; transform: translateY(4px); transition: opacity .08s, transform .08s; }
.tooltip.on { opacity: 1; transform: none; }
.tooltip .tt-title { color: var(--text-3); font-size: 11.5px; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .tt-row span { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.tooltip .tt-row span i { width: 10px; height: 2px; border-radius: 2px; display: inline-block; }
.tooltip .tt-row b { font-weight: 650; font-variant-numeric: tabular-nums; }
.hbar { display: grid; grid-template-columns: minmax(90px, 160px) minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 5px 0; font-size: 13px; }
.hbar .track { height: 8px; border-radius: 0 4px 4px 0; position: relative; }
.hbar .fill { display: block; height: 100%; background: var(--p1); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .val { font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 12.5px; white-space: nowrap; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Dashboard ---------- */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.dash-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.greet h1 { font-size: 26px; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-top: 1px solid var(--border); }
.mini-list li:first-child { border-top: 0; }
.mini-list .grow { flex: 1; min-width: 0; }
.mini-list .grow b, .mini-list .grow small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list .grow small { color: var(--text-3); font-size: 12px; }
.mini-list .amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; }
.mini-list .amt small { display: block; font-weight: 400; color: var(--text-3); font-size: 11.5px; }

/* ---------- Reports ---------- */
.report-table td, .report-table th { white-space: nowrap; }
.ref-group > summary { cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; list-style: none; flex-wrap: wrap; }
.ref-group > summary::-webkit-details-marker { display: none; }
.ref-group > summary h2 { margin: 0; font-size: 14px; }
.ref-group[open] > summary { border-bottom: 1px solid var(--border); }
.referrers-layout { grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); }

/* ---------- Command menu (⌘K) ---------- */
.cmdk { position: fixed; inset: 0; z-index: 100; display: none; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; background: var(--overlay); backdrop-filter: blur(2px); }
.cmdk.open { display: flex; animation: fade-in .12s ease; }
.cmdk-box { width: min(640px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop-in .16s cubic-bezier(.2, .9, .3, 1.15); }
.cmdk-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); color: var(--text-4); }
.cmdk-input input { flex: 1; border: 0; outline: 0; background: none; color: var(--text); font: 15px var(--font); height: 52px; }
.cmdk-list { max-height: min(420px, 55vh); overflow-y: auto; padding: 6px; margin: 0; list-style: none; }
.cmdk-group { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; color: var(--text-4); padding: 10px 10px 4px; }
.cmdk-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); cursor: pointer; }
.cmdk-item .icon { color: var(--text-4); }
.cmdk-item .grow { flex: 1; min-width: 0; }
.cmdk-item .grow b, .cmdk-item .grow small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk-item .grow b { font-weight: 550; }
.cmdk-item .grow small { color: var(--text-3); font-size: 12px; }
.cmdk-item[aria-selected="true"] { background: var(--brand-soft); }
.cmdk-item[aria-selected="true"] .icon { color: var(--brand); }
.cmdk-empty { padding: 22px; text-align: center; color: var(--text-3); font-size: 13px; }
.cmdk-foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-4); background: var(--surface-2); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(.985); } to { opacity: 1; transform: none; } }

/* ---------- Quick view drawer ---------- */
/* closed = not displayed at all (an off-screen panel would widen the page on phones); it slides in when opened */
.drawer-backdrop { position: fixed; inset: 0; z-index: 80; background: var(--overlay); display: none; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 85; width: min(460px, 100vw); background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); display: none; flex-direction: column; }
body.drawer-open .drawer { display: flex; animation: drawer-in .22s cubic-bezier(.2, .8, .2, 1); }
body.drawer-open .drawer-backdrop { display: block; animation: fade-in .18s ease; }
@keyframes drawer-in { from { transform: translateX(100%); } to { transform: none; } }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.drawer-head .grow { flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px; }
.drawer-body.loading { opacity: .5; }
.peek h2 { font-size: 18px; margin: 0; }
.peek .facts { margin-top: 14px; }
.peek .sums { margin-top: 14px; }

/* ---------- Sign in (and other plain pages) ---------- */
body.plain { min-height: 100vh; background: var(--bg); }
.auth { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.auth-art { position: relative; overflow: hidden; background: radial-gradient(900px 500px at 15% 10%, rgba(59, 143, 224, .35), transparent 60%), radial-gradient(700px 500px at 90% 90%, rgba(242, 140, 40, .22), transparent 60%), #0f1a2a; color: #e8eef6; padding: 44px 52px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-art::before { content: ''; position: absolute; inset: 0; background-image: linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px); background-size: 36px 36px; mask-image: radial-gradient(ellipse at 30% 30%, #000 30%, transparent 75%); -webkit-mask-image: radial-gradient(ellipse at 30% 30%, #000 30%, transparent 75%); }
.auth-art > * { position: relative; }
.auth-art .brand { color: #fff; }
.auth-art .brand small { color: #9fb2c8; }
.auth-art h2 { font-size: 34px; line-height: 1.15; letter-spacing: -.03em; font-weight: 650; max-width: 440px; margin: 0 0 14px; color: #fff; }
.auth-art p { color: #a9bbd0; max-width: 420px; font-size: 15px; }
.auth-preview { margin-top: 28px; max-width: 420px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1); border-radius: 14px; padding: 14px; backdrop-filter: blur(6px); }
.auth-preview .row { display: flex; align-items: center; gap: 10px; padding: 7px 4px; font-size: 13px; color: #dce6f2; }
.auth-preview .row + .row { border-top: 1px solid rgba(255, 255, 255, .08); }
.auth-preview .row .grow { flex: 1; }
.auth-preview .battery { background: rgba(255, 255, 255, .12); width: 150px; min-width: 0; }
.auth-preview .pill { background: rgba(255, 255, 255, .1); color: #e8eef6; }
.auth-foot { font-size: 12px; color: #7f93ab; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.plain-main { width: min(400px, 100%); margin: 0 auto; }
.plain-main.wide { width: min(480px, 100%); padding: 8vh 16px 40px; }
.plain-brand { display: none; }
.login-card { border: 0; box-shadow: none; background: transparent; padding: 0; }
.login-card h1, .narrow h1 { font-size: 26px; }
.login-card .form input { padding: 10px 12px; }
.login-card .btn-block { margin-top: 4px; padding: 10px 14px; }
.login-card > p.small { margin-top: 16px; }
.error-card { text-align: left; }
.debug { white-space: pre-wrap; background: var(--danger-bg); padding: 10px; border-radius: 8px; font-size: 12px; }

/* ---------- System & misc ---------- */
.checklist { list-style: none; padding: 0; margin: 0 0 10px; }
.checklist li { padding: 5px 0; display: flex; align-items: center; gap: 8px; }
.checklist li span:first-child { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: 12px; font-weight: 700; flex: none; }
.checklist .ok span:first-child { background: var(--st-paid-bg); color: var(--st-paid-ink); }
.checklist .warn span:first-child { background: var(--st-part-bg); color: var(--st-part-ink); }
.temp-password { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); background: var(--accent-soft); }
.big { font-size: 22px; letter-spacing: 1px; margin: 0; }
.plain-list { list-style: none; margin: 6px 0 12px; padding: 0; }
.plain-list li { padding: 4px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.plain-list.bullets { list-style: disc; padding-left: 20px; }
.plain-list.bullets li { border: 0; padding: 3px 0; }
ol.plain-steps { margin: 0 0 8px; padding-left: 20px; line-height: 1.8; }
.result-note b { color: var(--text); }


/* ---------- Proportions (the page's security policy allows no inline styles, so widths come from classes) ---------- */
.fg-0 { flex-grow: 0; } .fg-1 { flex-grow: 1; } .fg-2 { flex-grow: 2; } .fg-3 { flex-grow: 3; } .fg-4 { flex-grow: 4; } .fg-5 { flex-grow: 5; } .fg-6 { flex-grow: 6; } .fg-7 { flex-grow: 7; } .fg-8 { flex-grow: 8; } .fg-9 { flex-grow: 9; } .fg-10 { flex-grow: 10; } .fg-11 { flex-grow: 11; } .fg-12 { flex-grow: 12; } .fg-13 { flex-grow: 13; } .fg-14 { flex-grow: 14; } .fg-15 { flex-grow: 15; } .fg-16 { flex-grow: 16; } .fg-17 { flex-grow: 17; } .fg-18 { flex-grow: 18; } .fg-19 { flex-grow: 19; } .fg-20 { flex-grow: 20; } .fg-21 { flex-grow: 21; } .fg-22 { flex-grow: 22; } .fg-23 { flex-grow: 23; } .fg-24 { flex-grow: 24; } .fg-25 { flex-grow: 25; } .fg-26 { flex-grow: 26; } .fg-27 { flex-grow: 27; } .fg-28 { flex-grow: 28; } .fg-29 { flex-grow: 29; } .fg-30 { flex-grow: 30; } .fg-31 { flex-grow: 31; } .fg-32 { flex-grow: 32; } .fg-33 { flex-grow: 33; } .fg-34 { flex-grow: 34; } .fg-35 { flex-grow: 35; } .fg-36 { flex-grow: 36; } .fg-37 { flex-grow: 37; } .fg-38 { flex-grow: 38; } .fg-39 { flex-grow: 39; } .fg-40 { flex-grow: 40; } .fg-41 { flex-grow: 41; } .fg-42 { flex-grow: 42; } .fg-43 { flex-grow: 43; } .fg-44 { flex-grow: 44; } .fg-45 { flex-grow: 45; } .fg-46 { flex-grow: 46; } .fg-47 { flex-grow: 47; } .fg-48 { flex-grow: 48; } .fg-49 { flex-grow: 49; } .fg-50 { flex-grow: 50; } .fg-51 { flex-grow: 51; } .fg-52 { flex-grow: 52; } .fg-53 { flex-grow: 53; } .fg-54 { flex-grow: 54; } .fg-55 { flex-grow: 55; } .fg-56 { flex-grow: 56; } .fg-57 { flex-grow: 57; } .fg-58 { flex-grow: 58; } .fg-59 { flex-grow: 59; } .fg-60 { flex-grow: 60; } .fg-61 { flex-grow: 61; } .fg-62 { flex-grow: 62; } .fg-63 { flex-grow: 63; } .fg-64 { flex-grow: 64; } .fg-65 { flex-grow: 65; } .fg-66 { flex-grow: 66; } .fg-67 { flex-grow: 67; } .fg-68 { flex-grow: 68; } .fg-69 { flex-grow: 69; } .fg-70 { flex-grow: 70; } .fg-71 { flex-grow: 71; } .fg-72 { flex-grow: 72; } .fg-73 { flex-grow: 73; } .fg-74 { flex-grow: 74; } .fg-75 { flex-grow: 75; } .fg-76 { flex-grow: 76; } .fg-77 { flex-grow: 77; } .fg-78 { flex-grow: 78; } .fg-79 { flex-grow: 79; } .fg-80 { flex-grow: 80; } .fg-81 { flex-grow: 81; } .fg-82 { flex-grow: 82; } .fg-83 { flex-grow: 83; } .fg-84 { flex-grow: 84; } .fg-85 { flex-grow: 85; } .fg-86 { flex-grow: 86; } .fg-87 { flex-grow: 87; } .fg-88 { flex-grow: 88; } .fg-89 { flex-grow: 89; } .fg-90 { flex-grow: 90; } .fg-91 { flex-grow: 91; } .fg-92 { flex-grow: 92; } .fg-93 { flex-grow: 93; } .fg-94 { flex-grow: 94; } .fg-95 { flex-grow: 95; } .fg-96 { flex-grow: 96; } .fg-97 { flex-grow: 97; } .fg-98 { flex-grow: 98; } .fg-99 { flex-grow: 99; } .fg-100 { flex-grow: 100; }
.w-0 { width: 0%; } .w-1 { width: 1%; } .w-2 { width: 2%; } .w-3 { width: 3%; } .w-4 { width: 4%; } .w-5 { width: 5%; } .w-6 { width: 6%; } .w-7 { width: 7%; } .w-8 { width: 8%; } .w-9 { width: 9%; } .w-10 { width: 10%; } .w-11 { width: 11%; } .w-12 { width: 12%; } .w-13 { width: 13%; } .w-14 { width: 14%; } .w-15 { width: 15%; } .w-16 { width: 16%; } .w-17 { width: 17%; } .w-18 { width: 18%; } .w-19 { width: 19%; } .w-20 { width: 20%; } .w-21 { width: 21%; } .w-22 { width: 22%; } .w-23 { width: 23%; } .w-24 { width: 24%; } .w-25 { width: 25%; } .w-26 { width: 26%; } .w-27 { width: 27%; } .w-28 { width: 28%; } .w-29 { width: 29%; } .w-30 { width: 30%; } .w-31 { width: 31%; } .w-32 { width: 32%; } .w-33 { width: 33%; } .w-34 { width: 34%; } .w-35 { width: 35%; } .w-36 { width: 36%; } .w-37 { width: 37%; } .w-38 { width: 38%; } .w-39 { width: 39%; } .w-40 { width: 40%; } .w-41 { width: 41%; } .w-42 { width: 42%; } .w-43 { width: 43%; } .w-44 { width: 44%; } .w-45 { width: 45%; } .w-46 { width: 46%; } .w-47 { width: 47%; } .w-48 { width: 48%; } .w-49 { width: 49%; } .w-50 { width: 50%; } .w-51 { width: 51%; } .w-52 { width: 52%; } .w-53 { width: 53%; } .w-54 { width: 54%; } .w-55 { width: 55%; } .w-56 { width: 56%; } .w-57 { width: 57%; } .w-58 { width: 58%; } .w-59 { width: 59%; } .w-60 { width: 60%; } .w-61 { width: 61%; } .w-62 { width: 62%; } .w-63 { width: 63%; } .w-64 { width: 64%; } .w-65 { width: 65%; } .w-66 { width: 66%; } .w-67 { width: 67%; } .w-68 { width: 68%; } .w-69 { width: 69%; } .w-70 { width: 70%; } .w-71 { width: 71%; } .w-72 { width: 72%; } .w-73 { width: 73%; } .w-74 { width: 74%; } .w-75 { width: 75%; } .w-76 { width: 76%; } .w-77 { width: 77%; } .w-78 { width: 78%; } .w-79 { width: 79%; } .w-80 { width: 80%; } .w-81 { width: 81%; } .w-82 { width: 82%; } .w-83 { width: 83%; } .w-84 { width: 84%; } .w-85 { width: 85%; } .w-86 { width: 86%; } .w-87 { width: 87%; } .w-88 { width: 88%; } .w-89 { width: 89%; } .w-90 { width: 90%; } .w-91 { width: 91%; } .w-92 { width: 92%; } .w-93 { width: 93%; } .w-94 { width: 94%; } .w-95 { width: 95%; } .w-96 { width: 96%; } .w-97 { width: 97%; } .w-98 { width: 98%; } .w-99 { width: 99%; } .w-100 { width: 100%; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .grid-2, .dash-grid, .referrers-layout { grid-template-columns: minmax(0, 1fr); }
  /* one column on the enrollee page, most useful first */
  .deal-layout { display: flex; flex-direction: column; align-items: stretch; gap: 0; }
  .deal-main, .deal-side { display: contents; }
  .o-1 { order: 1; } .o-2 { order: 2; } .o-3 { order: 3; } .o-4 { order: 4; } .o-5 { order: 5; } .o-6 { order: 6; } .o-7 { order: 7; }
}
@media (max-width: 900px) {
  .topbar { display: flex; position: sticky; top: 0; z-index: 50; align-items: center; justify-content: space-between; gap: 8px; background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 12px; height: 52px; }
  .topbar .brand { margin: 0; padding: 0; }
  .menu-btn { background: none; border: 0; color: var(--text); padding: 6px; cursor: pointer; border-radius: 8px; }
  .menu-btn:hover { background: var(--surface-3); }
  .sidebar { transform: translateX(-100%); transition: transform .2s; top: 52px; width: 272px; visibility: hidden; box-shadow: none; }
  .sidebar > .brand, .collapse-btn { display: none; }
  body.nav-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-lg); }
  body.nav-collapsed { --sidebar-w: 248px; }
  .main { margin-left: 0; }
  .app-header { display: none; }
  .content { padding: 16px 14px 48px; }
  h1 { font-size: 22px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat b { font-size: 20px; }
  .spark { display: none; }
  .row-2, .row-3 { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; }
  .card { padding: 16px; }
  .table-card { padding: 0; }
  .filters > * { flex: 1 1 140px; }
  .filters .search { max-width: none; flex-basis: 100%; }
  .pipeline { grid-auto-columns: minmax(78vw, 1fr); }
  .pay-form .row-4 { grid-template-columns: 1fr 1fr; }
  .facts { grid-template-columns: 110px minmax(0, 1fr); }
  .group-head { grid-template-columns: auto minmax(0, 1fr); padding: 12px; }
  .group-head .actions { grid-column: 1 / -1; }
  .group-meter .battery { max-width: none; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .plain-brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; margin-bottom: 24px; }
  .toasts { top: 62px; right: 12px; }
  .hbar { grid-template-columns: minmax(70px, 110px) minmax(0, 1fr) auto; }
}
/* the board fits the screen: the phone number moves under the name on laptops, columns step aside on small screens */
.who small.phone { display: none; }
@media (max-width: 1499px) {
  .table.board .col-contact { display: none; }
  .who small.phone { display: block; }
}
@media (max-width: 1100px) {
  .table.board .col-tags, .table.board .col-contract { display: none; }
}
@media (max-width: 640px) {
  /* the board on a phone: name, stage and balance; the rest is one tap away in the quick view */
  .table.board .col-price, .table.board .col-ref, .table.board .col-paid { display: none; }
  .table.board td, .table.board th { padding-left: 10px; padding-right: 10px; }
  .who { min-width: 0; }
  .who small { max-width: 150px; }
  .table.board .peek-btn { opacity: 1; }
}
@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr; }
  .sums { grid-template-columns: 1fr 1fr; }
  .sum b { font-size: 16px; }
  .pay-form .row-4 { grid-template-columns: 1fr; }
  .price-grid { grid-template-columns: minmax(0, 1fr) 92px 48px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media print {
  .sidebar, .app-header, .topbar, .toasts, .actions, .filters, .board-tools .actions { display: none !important; }
  .main { margin: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* ---------- Small additions ---------- */
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; }
h3.sub { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; margin: 18px 0 6px; }
.chart g.col { outline: none; }
.chart g.col:focus-visible .hit { fill: var(--surface-3); }
.peek .mini-list li { padding: 8px 0; }
.peek .pay-progress { margin-top: -2px; }

.price-cell b { display: block; font-weight: 500; white-space: nowrap; }
.price-cell small { display: block; color: var(--text-3); font-size: 11.5px; line-height: 1.35; max-width: 150px; }
.table.board td.ref { white-space: nowrap; }
.board-summary .legend { flex: 2 1 420px; }
.price-cell { min-width: 120px; }
