/* ============================================================================
 * Blue Star Ledger — tokens.css
 * Full design system: tokens + base reset + component classes.
 * Blue & gold on a clean light UI; tasteful dark variant via prefers-color-scheme.
 * No external fonts, no CDNs. Pure CSS.
 * ========================================================================== */

/* ------------------------------- tokens ---------------------------------- */
:root {
  /* brand — navy ink + gold accent */
  --navy-950: #071122;
  --navy-900: #0B1B34;   /* THE ink / sidebar base */
  --navy-800: #10254A;
  --navy-700: #173464;
  --navy-600: #1E4380;
  --blue:       #1F4E96; /* primary interactive */
  --blue-strong:#173C77;
  --blue-soft:  #E8EFFA;
  --blue-text:  #1B4485;

  --gold:      #D4A72C;  /* THE accent */
  --gold-deep: #A87F14;  /* gold that passes on white for text */
  --gold-soft: #FAF3DC;
  --gold-ink:  #6B5410;
  --accent: var(--gold);

  /* surfaces */
  --bg: #F6F7FB;
  --surface: #FFFFFF;
  --surface-alt: #EFF2F8;
  --surface-hover: #F3F5FA;
  --border: #E3E7F0;
  --border-strong: #C9D1E0;

  /* text */
  --ink: #0B1B34;
  --ink-secondary: #33415C;
  --ink-muted: #5E6B85;
  --ink-inverse: #FFFFFF;

  /* semantic */
  --good: #177245;  --good-soft: #E4F3EA;
  --warn: #A16207;  --warn-soft: #FBF0D9;
  --bad:  #B3261E;  --bad-soft:  #FBEAE8;
  --info: #1D5FB8;  --info-soft: #E7F0FB;

  /* invoice-status pill pairs */
  --st-paid-bg:#E4F3EA;    --st-paid-fg:#14532D;
  --st-sent-bg:#E7F0FB;    --st-sent-fg:#123F79;
  --st-draft-bg:#EFF1F0;   --st-draft-fg:#4B5563;
  --st-partial-bg:#FAF3DC; --st-partial-fg:#6B5410;
  --st-overdue-bg:#FBEAE8; --st-overdue-fg:#7C1D18;
  --st-void-bg:#EFF1F0;    --st-void-fg:#6B7280;

  /* AR aging risk ramp (current -> 90+) */
  --age-0: #4C8C2B;
  --age-1: #C99B26;
  --age-2: #E08A2E;
  --age-3: #D4592F;
  --age-4: #B3261E;

  /* chart palette (used by app.js helpers via var()) */
  --chart-1: #2B62B5;
  --chart-2: #D4A72C;
  --chart-3: #3E8E5A;
  --chart-4: #8A5CB8;
  --chart-5: #C2543B;
  --chart-6: #5E6B85;
  --chart-grid: #E3E7F0;

  /* typography (system stack — offline-friendly) */
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-heading: var(--font-ui);
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-xs: 11px; --fs-sm: 12.5px; --fs-base: 14px; --fs-md: 15px;
  --fs-lg: 18px; --fs-xl: 22px; --fs-2xl: 28px; --fs-hero: 34px;

  /* spacing (4px base) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  /* radius */
  --r-sm: 6px; --r-md: 9px; --r-lg: 13px; --r-full: 999px;

  /* elevation */
  --e1: 0 1px 2px rgba(11,27,52,.06), 0 1px 1px rgba(11,27,52,.04);
  --e2: 0 4px 14px rgba(11,27,52,.09);
  --e3: 0 14px 36px rgba(11,27,52,.16);
  --focus: 0 0 0 3px rgba(212,167,44,.38);

  /* layout */
  --sidebar-w: 248px;
  --topbar-h: 60px;
  --content-max: 1280px;
}

/* dark variant — tasteful navy dark, gold stays gold */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0A1424;
    --surface: #101E36;
    --surface-alt: #17263F;
    --surface-hover: #1B2C48;
    --border: #223451;
    --border-strong: #31466B;

    --ink: #E9EEF7;
    --ink-secondary: #C0CBDD;
    --ink-muted: #8B99B2;
    --ink-inverse: #0B1B34;

    --blue: #6FA0E8;
    --blue-strong: #8FB6F0;
    --blue-soft: #17304F;
    --blue-text: #9CBDF0;

    --gold-deep: #E4BC4E;
    --gold-soft: #33290E;
    --gold-ink: #EAD189;

    --good: #57C285;  --good-soft: #12301F;
    --warn: #E0A93E;  --warn-soft: #322611;
    --bad:  #EF7B70;  --bad-soft:  #391614;
    --info: #6FA0E8;  --info-soft: #14283F;

    --st-paid-bg:#12301F;   --st-paid-fg:#8FDCAF;
    --st-sent-bg:#14283F;   --st-sent-fg:#A6C8F2;
    --st-draft-bg:#1D2A40;  --st-draft-fg:#A7B4C9;
    --st-partial-bg:#33290E;--st-partial-fg:#EAD189;
    --st-overdue-bg:#391614;--st-overdue-fg:#F3A79E;
    --st-void-bg:#1D2A40;   --st-void-fg:#8B99B2;

    --chart-1: #6FA0E8;
    --chart-3: #5FBE88;
    --chart-4: #B491DE;
    --chart-5: #E2836C;
    --chart-6: #8B99B2;
    --chart-grid: #223451;

    --e1: 0 1px 2px rgba(0,0,0,.4);
    --e2: 0 4px 14px rgba(0,0,0,.45);
    --e3: 0 14px 36px rgba(0,0,0,.55);
  }
}

/* ------------------------------ base reset -------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { font-family: var(--font-heading); margin: 0; color: var(--ink); font-weight: 650; letter-spacing: -.01em; }
p { margin: 0 0 var(--s3); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
img, svg { max-width: 100%; vertical-align: middle; }
::selection { background: var(--gold-soft); }

/* utilities */
.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }
.mono { font-family: var(--font-mono); font-size: var(--fs-sm); }
.muted { color: var(--ink-muted); }
.small { font-size: var(--fs-sm); }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }
.grid { display: grid; gap: var(--s5); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
@media (max-width: 1000px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.flex { display: flex; align-items: center; gap: var(--s3); }
.spread { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.stack { display: flex; flex-direction: column; gap: var(--s3); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(94,107,133,.35); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }

/* ------------------------------- app shell -------------------------------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, var(--navy-950) 0%, var(--navy-900) 45%, var(--navy-800) 100%);
  color: #fff; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; z-index: 30;
}
.sidebar__brand { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s5); height: var(--topbar-h); flex: 0 0 auto; }
.sidebar__logo {
  width: 32px; height: 32px; border-radius: var(--r-md); flex: 0 0 auto;
  background: radial-gradient(circle at 35% 30%, var(--navy-700), var(--navy-950));
  border: 1px solid rgba(212,167,44,.55);
  display: grid; place-items: center; color: var(--gold);
}
.sidebar__logo svg { width: 18px; height: 18px; }
.sidebar__name { font-weight: 700; font-size: 15.5px; letter-spacing: -.01em; line-height: 1.15; }
.sidebar__name em { display: block; font-style: normal; font-weight: 500; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }

.nav { padding: var(--s3) var(--s3) var(--s5); flex: 1; }
.nav__label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: rgba(255,255,255,.42); padding: var(--s4) var(--s3) var(--s2); font-weight: 650; }
.nav__item {
  display: flex; align-items: center; gap: var(--s3); padding: 9px var(--s3); border-radius: var(--r-md);
  color: rgba(255,255,255,.80); font-size: 13.5px; font-weight: 520; margin-bottom: 2px;
  cursor: pointer; transition: background .12s, color .12s;
}
.nav__item:hover { background: rgba(255,255,255,.09); color: #fff; text-decoration: none; }
.nav__item.is-active { background: rgba(212,167,44,.14); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav__item svg { width: 18px; height: 18px; flex: 0 0 auto; opacity: .9; }
.nav__count { margin-left: auto; background: var(--gold); color: var(--navy-950); font-size: 11px; font-weight: 800; border-radius: var(--r-full); padding: 1px 7px; }
.sidebar__foot { padding: var(--s4) var(--s5); border-top: 1px solid rgba(255,255,255,.10); font-size: 11.5px; color: rgba(255,255,255,.55); }

/* topbar */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s5);
  position: sticky; top: 0; z-index: 20;
}
.topbar__burger { display: none; background: none; border: none; cursor: pointer; color: var(--ink-muted); padding: 6px; border-radius: var(--r-sm); }
.topbar__tenant { max-width: 280px; font-weight: 600; }
.topbar__search { flex: 1; max-width: 380px; }
.topbar__spacer { flex: 1; }
.topbar__plan {
  font-size: 10.5px; font-weight: 800; letter-spacing: .12em; color: var(--gold-ink);
  background: var(--gold-soft); border: 1px solid var(--gold); border-radius: var(--r-full);
  padding: 3px 11px; white-space: nowrap;
}
.avatar {
  width: 34px; height: 34px; border-radius: var(--r-full); flex: 0 0 auto;
  background: linear-gradient(135deg, var(--navy-700), var(--navy-900));
  color: var(--gold); font-size: 12.5px; font-weight: 800;
  display: grid; place-items: center; border: 1px solid var(--border-strong);
}

.content { padding: var(--s6); width: 100%; max-width: calc(var(--content-max) + var(--s6) * 2); margin: 0 auto; flex: 1; }
.footer { text-align: center; font-size: var(--fs-sm); color: var(--ink-muted); padding: var(--s5) var(--s4) var(--s6); }
.footer .star { color: var(--gold); }

/* page header */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s5); flex-wrap: wrap; }
.page-header__title { font-size: var(--fs-xl); }
.page-header__sub { color: var(--ink-muted); font-size: 13.5px; margin-top: 2px; }
.page-header__actions { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }

/* --------------------------------- card ----------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--e1); }
.card + .card { margin-top: var(--s5); }
.card__header { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); }
.card__title { font-size: var(--fs-md); font-weight: 650; display: flex; align-items: center; gap: var(--s2); }
.card__sub { font-size: var(--fs-sm); color: var(--ink-muted); }
.card__body { padding: var(--s5); }
.card__body--flush { padding: 0; }
.card__footer { padding: var(--s3) var(--s5); border-top: 1px solid var(--border); font-size: var(--fs-sm); color: var(--ink-muted); display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.card--gold { border-top: 3px solid var(--gold); }
.card--navy { background: linear-gradient(160deg, var(--navy-900), var(--navy-800)); border-color: var(--navy-700); color: #fff; }
.card--navy .card__title, .card--navy h1, .card--navy h2, .card--navy h3 { color: #fff; }
.card--navy .muted { color: rgba(255,255,255,.62); }
.card--navy .card__header, .card--navy .card__footer { border-color: rgba(255,255,255,.12); }

/* ------------------------------ kpi grid / stat ---------------------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: var(--s4); margin-bottom: var(--s5); }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s4) var(--s5); box-shadow: var(--e1); position: relative; }
.stat__label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-muted); font-weight: 650; display: flex; align-items: center; gap: var(--s2); }
.stat__value { font-size: 25px; font-weight: 750; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat__meta { font-size: var(--fs-sm); color: var(--ink-muted); margin-top: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.stat__delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 650; font-size: 12px; padding: 1px 7px; border-radius: var(--r-full); }
.stat__delta--up { color: var(--good); background: var(--good-soft); }
.stat__delta--down { color: var(--bad); background: var(--bad-soft); }
.stat__delta--flat { color: var(--ink-muted); background: var(--surface-alt); }
.stat--gold { border-top: 3px solid var(--gold); }

/* --------------------------------- table ----------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-muted); font-weight: 650; padding: 11px var(--s4);
  border-bottom: 1px solid var(--border); white-space: nowrap;
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.table td { padding: 12px var(--s4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-hover); }
.table.is-zebra tbody tr:nth-child(even) { background: var(--surface-alt); }
.table.is-compact td { padding: 7px var(--s4); }
.table.is-compact th { padding: 8px var(--s4); }
.table .right, .table th.right { text-align: right; }
.table tr.is-clickable { cursor: pointer; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--ink); }
.table th .caret { opacity: .35; margin-left: 4px; font-size: 10px; }
.table th.is-sorted { color: var(--blue-text); }
.table th.is-sorted .caret { opacity: 1; color: var(--gold-deep); }
.cell-main { display: flex; align-items: center; gap: 10px; font-weight: 550; }
.cell-sub { font-size: 12px; color: var(--ink-muted); font-weight: 400; }
.col-id { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-secondary); }

/* --------------------------------- badge ----------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border-radius: var(--r-full); font-size: 11.5px; font-weight: 700; line-height: 1.4;
  white-space: nowrap; background: var(--surface-alt); color: var(--ink-secondary);
}
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad  { background: var(--bad-soft);  color: var(--bad); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-gold { background: var(--gold-soft); color: var(--gold-ink); border: 1px solid var(--gold); }
.badge-sample {
  background: transparent; color: var(--gold-deep);
  border: 1px dashed var(--gold); text-transform: uppercase; letter-spacing: .08em;
  font-size: 10px; padding: 2px 8px;
}
/* invoice-status kinds */
.badge-paid    { background: var(--st-paid-bg);    color: var(--st-paid-fg); }
.badge-sent    { background: var(--st-sent-bg);    color: var(--st-sent-fg); }
.badge-draft   { background: var(--st-draft-bg);   color: var(--st-draft-fg); }
.badge-partial, .badge-partially_paid { background: var(--st-partial-bg); color: var(--st-partial-fg); }
.badge-overdue { background: var(--st-overdue-bg); color: var(--st-overdue-fg); }
.badge-void    { background: var(--st-void-bg);    color: var(--st-void-fg); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }

/* --------------------------------- button ---------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 16px; border-radius: var(--r-md);
  font-size: 13px; font-weight: 650; cursor: pointer; border: 1px solid transparent;
  transition: background .12s, border-color .12s, transform .04s;
  white-space: nowrap; text-decoration: none; background: transparent; color: var(--ink-secondary);
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--navy-900); color: #fff; }
.btn-primary:hover { background: var(--navy-700); text-decoration: none; }
.btn-gold { background: var(--gold); color: var(--navy-950); }
.btn-gold:hover { background: var(--gold-deep); color: #fff; text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--blue-text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-alt); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--ink-secondary); }
.btn-ghost:hover { background: var(--surface-alt); text-decoration: none; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { filter: brightness(.92); text-decoration: none; }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
@media (prefers-color-scheme: dark) {
  .btn-primary { background: var(--gold); color: var(--navy-950); }
  .btn-primary:hover { background: var(--gold-deep); color: var(--navy-950); }
}

/* ---------------------------------- tabs ------------------------------------ */
.tabs { display: flex; gap: var(--s5); border-bottom: 1px solid var(--border); margin-bottom: var(--s5); overflow-x: auto; }
.tab { padding: 10px 2px; font-size: 13px; font-weight: 650; color: var(--ink-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; background: none; border-top: none; border-left: none; border-right: none; }
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--blue-text); border-bottom-color: var(--gold); }

/* --------------------------------- forms ------------------------------------ */
.field { margin-bottom: var(--s4); }
.field__label { display: block; font-size: 12px; font-weight: 650; color: var(--ink-secondary); margin-bottom: 5px; }
.field__hint { font-size: 11.5px; color: var(--ink-muted); margin-top: 4px; }
.field__error { font-size: 11.5px; color: var(--bad); margin-top: 4px; }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 11px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  font-family: inherit; font-size: 13.5px; color: var(--ink); background: var(--surface);
  transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; padding: 9px 11px; min-height: 80px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--gold); box-shadow: var(--focus); }
.input::placeholder, .textarea::placeholder { color: var(--ink-muted); opacity: .75; }
select.select {
  appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235E6B85' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--gold-deep); }
.filterbar { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; margin-bottom: var(--s4); }
.filterbar .input, .filterbar .select { height: 34px; width: auto; }
.filterbar__spacer { flex: 1; }
.seg { display: inline-flex; background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.seg button { border: none; background: transparent; padding: 6px 12px; border-radius: var(--r-sm); font-size: 12.5px; font-weight: 650; color: var(--ink-muted); cursor: pointer; }
.seg button.is-active { background: var(--surface); color: var(--blue-text); box-shadow: var(--e1); }

/* -------------------------------- progress ---------------------------------- */
.progress { height: 8px; background: var(--surface-alt); border-radius: var(--r-full); overflow: hidden; }
.progress__fill { height: 100%; border-radius: var(--r-full); background: var(--blue); transition: width .3s ease; }
.progress__fill--gold { background: var(--gold); }
.progress__fill--good { background: var(--good); }
.progress__fill--warn { background: var(--warn); }
.progress__fill--bad { background: var(--bad); }
.progress--lg { height: 12px; }

/* -------------------------------- aging bar --------------------------------- */
.aging { width: 100%; }
.aging-bar { display: flex; height: 18px; border-radius: var(--r-full); overflow: hidden; background: var(--surface-alt); }
.aging-bar__seg { height: 100%; min-width: 2px; }
.aging-legend { display: flex; gap: var(--s4) var(--s5); flex-wrap: wrap; font-size: 12px; margin-top: var(--s3); color: var(--ink-secondary); }
.aging-legend__row { display: flex; align-items: center; gap: 6px; }
.aging-legend__swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.aging-legend__val { font-weight: 650; font-variant-numeric: tabular-nums; }

/* -------------------------------- score ring -------------------------------- */
.score-ring { display: inline-grid; place-items: center; }
.score-ring text { font-family: var(--font-ui); }
.score-ring__num { font-weight: 800; fill: var(--ink); font-variant-numeric: tabular-nums; }
.score-ring__cap { font-weight: 650; fill: var(--ink-muted); letter-spacing: .08em; text-transform: uppercase; }
.card--navy .score-ring__num { fill: #fff; }
.card--navy .score-ring__cap { fill: rgba(255,255,255,.6); }

/* ------------------------------- empty state -------------------------------- */
.empty-state { text-align: center; padding: var(--s7) var(--s5); color: var(--ink-muted); }
.empty-state__emoji { font-size: 40px; line-height: 1; display: block; margin-bottom: var(--s4); }
.empty-state__title { font-size: 16px; font-weight: 650; color: var(--ink-secondary); margin-bottom: 6px; }
.empty-state__sub { font-size: 13.5px; max-width: 400px; margin: 0 auto var(--s4); }
.empty-state--celebrate .empty-state__title { color: var(--good); }

/* inline celebration row — the shared "that deserves a woohoo" strip */
.woohoo {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--good);
  background: var(--good-soft); border-radius: var(--r-md);
  padding: 8px 12px; margin-top: var(--s3);
}

/* ---------------------------------- modal ----------------------------------- */
.scrim { position: fixed; inset: 0; background: rgba(7,17,34,.5); z-index: 100; display: grid; place-items: center; padding: var(--s5); animation: bsl-fade .12s ease; }
@keyframes bsl-fade { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--e3); width: 100%; max-width: 540px; max-height: 90vh; display: flex; flex-direction: column; animation: bsl-pop .14s ease; }
.modal--wide { max-width: 860px; }
@keyframes bsl-pop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal__header { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.modal__title { font-size: 16px; font-weight: 650; }
.modal__body { padding: var(--s5); overflow: auto; flex: 1; }
.modal__footer { display: flex; justify-content: flex-end; gap: var(--s2); padding: var(--s4) var(--s5); border-top: 1px solid var(--border); flex: 0 0 auto; }
.modal__close { background: none; border: none; cursor: pointer; color: var(--ink-muted); padding: 6px; border-radius: var(--r-sm); font-size: 16px; line-height: 1; }
.modal__close:hover { background: var(--surface-alt); color: var(--ink); }

/* ---------------------------------- toast ----------------------------------- */
.toast-stack { position: fixed; bottom: var(--s5); right: var(--s5); z-index: 200; display: flex; flex-direction: column; gap: var(--s2); }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--info);
  border-radius: var(--r-md); box-shadow: var(--e2); padding: 12px 16px; max-width: 360px;
  font-size: 13px; animation: bsl-toast .18s ease;
}
@keyframes bsl-toast { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast--good { border-left-color: var(--good); }
.toast--warn { border-left-color: var(--warn); }
.toast--bad  { border-left-color: var(--bad); }
.toast--gold { border-left-color: var(--gold); }

/* ---------------------------------- charts ---------------------------------- */
.chart { display: block; }
.chart svg { display: block; max-width: 100%; height: auto; }
.chart-legend { display: flex; gap: var(--s3) var(--s4); flex-wrap: wrap; font-size: 12px; margin-top: var(--s2); color: var(--ink-secondary); }
.chart-legend__row { display: flex; align-items: center; gap: 6px; }
.chart-legend__swatch { width: 10px; height: 10px; border-radius: 3px; }
.chart-legend__val { font-weight: 650; font-variant-numeric: tabular-nums; }
.sparkline { vertical-align: middle; }

/* misc */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px var(--s4); font-size: 13px; }
.kv dt { color: var(--ink-muted); }
.kv dd { margin: 0; text-align: right; font-weight: 550; }
.divider { height: 1px; background: var(--border); margin: var(--s4) 0; border: none; }

/* ------------------------------- responsive --------------------------------- */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 240px; transform: translateX(-100%); transition: transform .2s; }
  .app.is-nav-open .sidebar { transform: none; box-shadow: var(--e3); }
  .topbar__burger { display: grid; place-items: center; }
  .topbar__search { display: none; }
  .content { padding: var(--s4); }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}
