
  /* ============================================================
     Theme: warm editorial — cream ground, deep teal, serif figures.
     Swap this block alone to retheme the whole app.
     ============================================================ */
  :root {
    --bg: #f7f5f1;
    --surface: #fcfbf9;
    /* overlays stay pure white so they still lift off a card */
    --surface-raised: #ffffff;
    --surface-2: #faf8f4;
    --surface-3: #f1eee7;
    --border: #e8e3da;
    --border-strong: #d7d0c3;
    --text: #201e1a;
    /* headings, the logo, and every big serif figure */
    --title: hsl(30 14% 14% / 1);
    --text-muted: #8a847a;
    --accent: #1a6b6e;
    --accent-soft: #e7efee;
    --green: #2f7d5f;
    --green-bg: #e9f2ed;
    --red: #c1553a;
    --red-bg: #f8ece7;
    --amber: #a8802f;
    --amber-bg: #f9f2e2;
    --slate: #67798c;
    --slate-bg: #eef1f4;
    /* chart series */
    --c1: #1a6b6e;
    --c2: #cfa53f;
    --c3: #c1553a;
    --c4: #67798c;
    --c5: #7a6a8c;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(32,30,26,0.05);
    --ctl-h: 32px;   /* shared height for all toolbar controls */
    --sidebar-bg: hsl(38 26% 93% / 1);
    --sidebar-hover: hsl(40 15% 89% / 1);
    --sidebar-active: hsl(40 13% 85% / 1);
    --font-sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --font-serif: "Fraunces", Georgia, serif;
  }
  * { box-sizing: border-box; }
  body {
    margin: 0;
    font-family: var(--font-sans);
    color: var(--text);
    font-size: 13.5px;
    background: var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
  }
  /* hero figures use the serif face */
  .serif, header.top h1, .card .value, .ft-value, .yc-value, .sc-value,
  .donut-hole .dv, .month-summary-row .ft-value, .sidebar-brand .word,
  .modal-head h2, .rem-head .rid {
    font-family: var(--font-serif);
    font-weight: 500;
    font-optical-sizing: auto;
    letter-spacing: 0;
    color: var(--title);
  }
  .sidebar-brand .word, header.top h1 { font-weight: 600; }

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

  /* ---------- Sidebar ---------- */
  .sidebar {
    width: 250px;
    flex: 0 0 250px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 22px 14px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
  }
  .sidebar-brand {
    display: flex;
    align-items: center;
    padding: 0 12px 22px;
    margin-bottom: 6px;
  }
  .sidebar-brand .word { font-size: 20px; color: var(--title); line-height: 1.15; }
  .sidebar-brand .word .sub3 {
    display: block; font-family: var(--font-sans);
    font-size: 9.5px; font-weight: 600; color: var(--text-muted);
    margin-top: 3px; text-transform: uppercase; letter-spacing: .11em;
  }

  .sidebar-group-label {
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: .11em;
    font-weight: 650;
    color: var(--text-muted);
    padding: 18px 12px 8px;
  }
  nav.side-nav { display: flex; flex-direction: column; gap: 2px; }
  nav.side-nav button {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    border-radius: 11px;
    padding: 11px 13px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: background .14s ease, color .14s ease;
  }
  nav.side-nav button .ico {
    width: 16px; height: 16px; flex: 0 0 16px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    opacity: .85;
  }
  nav.side-nav button .ico svg { width: 16px; height: 16px; display: block; }
  nav.side-nav button:hover { background: var(--sidebar-hover); color: var(--text); }
  nav.side-nav button:hover .ico { color: var(--text); }
  nav.side-nav button.active .ico { color: var(--text); opacity: 1; }
  /* warm greige pill, a shade deeper than the sidebar */
  nav.side-nav button.active {
    background: var(--sidebar-active);
    color: var(--text);
    font-weight: 600;
  }
  nav.side-nav button.active:hover { background: var(--sidebar-active); }
  .sidebar-footer {
    margin-top: auto;
    padding: 12px 10px 4px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
  }
  .sidebar-footer a { color: var(--text-muted); text-decoration: none; }
  .sidebar-footer a:hover { color: var(--accent); }

  /* ---------- Main content ---------- */
  .main { flex: 1 1 auto; min-width: 0; }
  .wrap { max-width: 1320px; margin: 0 auto; padding: 30px 28px 72px; }
  header.top {
    margin-bottom: 24px;
    padding: 0 0 18px;
    border-bottom: 1px solid var(--border);
  }
  header.top h1 { font-size: 26px; margin: 0 0 5px; color: var(--title); }
  header.top .sub { color: var(--text-muted); font-size: 12.5px; }

  /* ---------- Cards: one format everywhere ---------- */
  .cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 14px;
    margin-bottom: 26px;
    align-items: stretch;
  }
  /* deterministic column counts so rows never leave an orphan */
  .cards.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cards.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .cards.c6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  @media (max-width: 1320px) { .cards.c6 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
  @media (max-width: 1180px) {
    .cards.c3, .cards.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cards.c6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  }
  @media (max-width: 680px) {
    .cards.c2, .cards.c3, .cards.c4, .cards.c6 { grid-template-columns: 1fr; }
  }
  .cards.compact { margin-bottom: 14px; }

  .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px 19px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    min-width: 0;
  }
  .card .label {
    font-size: 9.5px; color: var(--text-muted); text-transform: uppercase;
    letter-spacing: .11em; margin-bottom: 10px; font-weight: 650;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .card .value {
    font-size: 28px; line-height: 1.12;
    font-variant-numeric: tabular-nums;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .card .value.red { color: var(--red); }
  .card .value.green { color: var(--green); }
  /* the explanatory sentence wraps freely */
  .card .sub2 {
    font-size: 12.5px; color: var(--text-muted);
    margin-top: 9px; line-height: 1.6;
    white-space: normal; overflow: visible;
  }
  .card .sub2 strong { color: var(--text); font-weight: 600; }
  .mini-bar {
    display: flex; height: 5px; border-radius: 3px; overflow: hidden;
    background: var(--surface-3); margin-top: auto;
  }
  .card .mini-bar { margin-top: 16px; }
  .mini-bar span { display: block; height: 100%; border-radius: 3px; }

  /* three-way invoice status breakdown */
  .status-split { display: flex; gap: 18px; margin-bottom: 12px; }
  .status-split .ss-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .status-split .ss-n {
    font-family: var(--font-serif); font-weight: 500; font-optical-sizing: auto;
    font-size: 21px; line-height: 1.15; font-variant-numeric: tabular-nums;
  }
  .status-split .ss-l {
    font-size: 9px; text-transform: uppercase; letter-spacing: .09em;
    font-weight: 650; color: var(--text-muted);
  }
  .status-bar {
    display: flex; height: 4px; border-radius: 2px; overflow: hidden;
    background: var(--surface-3); margin-top: auto;
  }
  .status-bar span { display: block; height: 100%; }

  .panel { display: none; }
  .panel.active { display: block; }

  .toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    margin-bottom: 12px;
    align-items: flex-end;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 11px;
    box-shadow: var(--shadow);
  }
  /* every interactive control in the toolbar shares one height and sits on
     a common baseline, so labelled fields and bare buttons line up */
  .toolbar .field {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .toolbar .field .flabel {
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 650;
    color: var(--text-muted);
    line-height: 1.25;
  }
  .toolbar input[type=text], .toolbar input[type=date], .toolbar select {
    border: 1px solid var(--border);
    border-radius: 6px;
    height: var(--ctl-h);
    padding: 0 10px;
    font-size: 12.5px;
    background: var(--surface);
    color: var(--text);
    outline: none;
    font-family: inherit;
  }
  .toolbar input[type=text]:focus, .toolbar input[type=date]:focus, .toolbar select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  .toolbar input[type=text] { min-width: 220px; }
  .toolbar input[type=date] { min-width: 130px; }
  .toolbar .ms-btn { height: var(--ctl-h); padding: 0 10px; }
  .toolbar .date-sep {
    color: var(--text-muted); font-size: 12px;
    height: var(--ctl-h); display: flex; align-items: center;
  }
  .toolbar label.chk {
    display: flex;
    align-items: center;
    gap: 6px;
    height: var(--ctl-h);
    font-size: 12.5px;
    color: var(--text-muted);
    cursor: pointer;
  }
  .toolbar .btn-reset {
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    border-radius: 6px;
    height: var(--ctl-h);
    padding: 0 12px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background .12s ease, color .12s ease, border-color .12s ease;
  }
  .toolbar .btn-reset:hover { background: var(--red-bg); color: var(--red); border-color: var(--red-bg); }
  .toolbar .btn { height: var(--ctl-h); padding: 0 13px; }
  .toolbar .count {
    margin-left: auto; font-size: 11.5px; color: var(--text-muted);
    white-space: nowrap; height: var(--ctl-h); display: flex; align-items: center;
  }

  .filtered-total {
    display: flex;
    flex-wrap: wrap;
    gap: 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
  }
  .filtered-total .ft-item { display: flex; flex-direction: column; gap: 3px; }
  .filtered-total .ft-label { font-size: 9.5px; text-transform: uppercase; letter-spacing: .11em; font-weight: 650; color: var(--text-muted); }
  .filtered-total .ft-value { font-size: 21px; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.15; }
  .filtered-total .ft-value.red { color: var(--red); }
  .filtered-total .ft-value.green { color: var(--green); }

  /* ---------- Multi-select dropdown ---------- */
  .ms { position: relative; }
  .ms-btn {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    min-width: 150px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12.5px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
  }
  .ms-btn:hover { border-color: var(--border-strong); }
  .ms-btn.has-selection { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .ms-btn .caret { font-size: 9px; color: var(--text-muted); }
  .ms-btn.has-selection .caret { color: var(--accent); }
  .ms-panel {
    display: none;
    flex-direction: column;
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    z-index: 30;
    width: 230px;
    max-height: 320px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(20,24,31,0.14);
    padding: 6px;
  }
  .ms-panel.open { display: flex; }
  .ms-panel .ms-search-wrap { flex: 0 0 auto; padding: 0 0 6px; }
  .ms-panel .ms-search-input {
    display: block;
    box-sizing: border-box;
    width: 100%;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 12px;
    line-height: 1.3;
    font-family: inherit;
    background: var(--surface-2);
    color: var(--text);
    outline: none;
    vertical-align: middle;
  }
  .ms-panel .ms-search-input:focus { border-color: var(--accent); background: var(--surface); }
  .ms-panel .ms-clear {
    display: block;
    width: 100%;
    flex: 0 0 auto;
    text-align: left;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 6px 8px 8px;
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--accent);
    cursor: pointer;
  }
  .ms-panel .ms-opts { flex: 1 1 auto; overflow-y: auto; }
  .ms-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 5px;
    font-size: 12.5px;
    cursor: pointer;
    white-space: nowrap;
  }
  .ms-opt:hover { background: var(--surface-2); }
  .ms-opt input { cursor: pointer; accent-color: var(--accent); }
  .ms-panel .ms-empty { padding: 10px 8px; font-size: 12px; color: var(--text-muted); text-align: center; }

  .table-scroll {
    max-height: 620px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
  .table-scroll table { border: none; border-radius: 0; box-shadow: none; }
  .table-scroll thead th { position: sticky; top: 0; z-index: 1; }
  .table-scroll.fixed-h { height: 320px; max-height: 320px; }

  table {
    width: 100%; border-collapse: separate; border-spacing: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
  }
  thead th {
    text-align: left;
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--text-muted);
    font-weight: 650;
    padding: 12px 14px;
    background: var(--surface-3);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
  }
  thead th:hover { color: var(--text); }
  thead th .arrow { font-size: 9px; margin-left: 3px; opacity: .5; }
  tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    font-size: 12.5px;
  }
  tbody tr:last-child td { border-bottom: none; }
  tbody tr:nth-child(even) { background: transparent; }
  tbody tr:hover { background: var(--surface-2); }
  /* total rows: same rhythm as the body, set off with a rule and tint */
  tfoot td {
    padding: 12px 14px;
    font-size: 12.5px;
    font-weight: 600;
    background: var(--surface-2);
    border-top: 1px solid var(--border-strong);
  }
  td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

  .badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 600;
    text-transform: capitalize;
    border: 1px solid transparent;
  }
  .badge.paid { background: var(--green-bg); color: var(--green); }
  .badge.unpaid { background: var(--red-bg); color: var(--red); }
  .badge.draft { background: var(--slate-bg); color: var(--slate); }
  .badge.pending_payment { background: var(--amber-bg); color: var(--amber); }
  .badge.deposited { background: var(--green-bg); color: var(--green); }
  .badge.pending_deposit { background: var(--amber-bg); color: var(--amber); }
  .badge.active { background: var(--green-bg); color: var(--green); }
  .badge.awaiting_payment { background: var(--amber-bg); color: var(--amber); }
  .badge.completed { background: var(--slate-bg); color: var(--slate); }
  .badge.unknown { background: var(--slate-bg); color: var(--slate); }
  .deliverables-cell { max-width: 320px; color: var(--text-muted); font-size: 12px; white-space: normal; }

  /* shared styling for any expanded detail row (Campaigns, Cash Flow, By Year) */
  .detail-panel { padding: 16px 18px 18px; background: var(--surface-2); }
  .detail-panel .meta-grid {
    display: grid; grid-template-columns: 110px 1fr; row-gap: 10px; column-gap: 14px;
    margin-bottom: 18px; max-width: 780px;
  }
  .detail-panel .mk { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; font-weight: 650; color: var(--text-muted); padding-top: 2px; }
  .detail-panel .mv { font-size: 12.5px; color: var(--text); line-height: 1.55; }
  .detail-panel .sub-heading {
    font-size: 10px; text-transform: uppercase; letter-spacing: .05em; font-weight: 650;
    color: var(--text-muted); margin: 0 0 8px;
  }
  .detail-panel .sub-table-wrap { width: 100%; }
  .detail-panel .sub-table-wrap table {
    width: 100%; table-layout: fixed;
    border: 1px solid var(--border); border-radius: 10px; overflow: hidden; box-shadow: none;
  }
  .detail-panel .sub-table-wrap table thead th { background: var(--surface-2); padding: 9px 14px; }
  .detail-panel .sub-table-wrap table tbody td { padding: 10px 14px; overflow: hidden; text-overflow: ellipsis; }
  .detail-panel .sub-table-wrap table tbody tr:nth-child(even) { background: var(--surface); }
  .detail-panel .sub-table-wrap table tbody tr:hover { background: var(--surface-3); }
  .detail-panel .sub-table-wrap table tfoot td {
    padding: 9px 14px; border-top: 1px solid var(--border-strong);
    background: var(--surface); font-weight: 600;
  }
  /* let the label columns absorb the slack so the money columns stay readable */
  .detail-panel .sub-table-wrap col.c-inv { width: 26%; }
  .detail-panel .sub-table-wrap col.c-status { width: 16%; }
  .detail-panel .sub-table-wrap col.c-due { width: 22%; }
  .detail-panel .sub-table-wrap col.c-total { width: 18%; }
  .detail-panel .sub-table-wrap col.c-bal { width: 18%; }
  /* wider 6-col layout used by Cash Flow / By Year detail tables */
  .detail-panel .sub-table-wrap col.d-inv { width: 15%; }
  .detail-panel .sub-table-wrap col.d-brand { width: 15%; }
  .detail-panel .sub-table-wrap col.d-camp { width: 26%; }
  .detail-panel .sub-table-wrap col.d-due { width: 16%; }
  .detail-panel .sub-table-wrap col.d-status { width: 12%; }
  .detail-panel .sub-table-wrap col.d-amt { width: 16%; }
  .detail-panel .empty-note { font-size: 12px; color: var(--text-muted); }
  .overdue-flag { color: var(--red); font-weight: 650; font-size: 10.5px; }

  .brand-cell { font-weight: 600; }
  .muted { color: var(--text-muted); }
  .notes-cell { max-width: 260px; color: var(--text-muted); font-size: 12px; }

  .rem-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
  }
  .rem-head {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 11px 14px;
    cursor: pointer;
    flex-wrap: wrap;
  }
  .rem-head:hover { background: var(--surface-2); }
  .rem-head .rid { font-weight: 650; min-width: 84px; color: var(--accent); font-family: var(--font-serif); font-size: 14px; }
  .rem-head .dates { color: var(--text-muted); font-size: 12px; }
  .rem-head .amt { margin-left: auto; font-weight: 650; font-variant-numeric: tabular-nums; }
  .rem-head .toggle { font-size: 10px; color: var(--text-muted); width: 14px; text-align: center; }
  .rem-lines { display: none; border-top: 1px solid var(--border); }
  .rem-lines.open { display: block; }
  .rem-lines table { border: none; border-radius: 0; box-shadow: none; table-layout: fixed; width: 100%; }
  .rem-lines thead th { background: var(--surface-3); padding: 8px 14px; }
  .rem-lines tbody td { padding: 8px 14px; }
  .rem-lines tbody tr:nth-child(even) { background: transparent; }
  .rem-lines tbody tr:hover { background: var(--surface-2); }
  /* tight, readable columns — Note absorbs the leftover space */
  .rem-lines col.rl-inv { width: 150px; }
  .rem-lines col.rl-brand { width: 150px; }
  .rem-lines col.rl-amt { width: 130px; }
  .rem-lines col.rl-note { width: auto; }
  .rem-lines td { overflow: hidden; text-overflow: ellipsis; }
  .rem-lines tfoot td {
    padding: 8px 14px; border-top: 1px solid var(--border);
    background: var(--surface-2); font-size: 12px; color: var(--text-muted);
  }

  .section-title {
    font-size: 9.5px; font-weight: 650; margin: 28px 0 11px;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: .11em;
  }
  .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  @media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
  footer.note {
    margin-top: 26px; font-size: 11.5px; color: var(--text-muted); line-height: 1.6;
    border-top: 1px solid var(--border);
    padding: 14px 0 0;
  }

  .cf-chart {
    display: flex; align-items: flex-end; gap: 16px; height: 160px; padding: 14px 14px 0; margin-bottom: 12px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
  .cf-bar-col { display: flex; flex-direction: column; align-items: center; flex: 1; height: 100%; justify-content: flex-end; }
  .cf-bar-stack { width: 100%; max-width: 56px; display: flex; flex-direction: column-reverse; border-radius: 3px 3px 0 0; overflow: hidden; }
  .cf-bar-seg.due { background: var(--c1); }
  .cf-bar-seg.overdue { background: var(--c3); }
  .cf-bar-amt { font-size: 10.5px; color: var(--text-muted); margin-bottom: 4px; white-space: nowrap; font-weight: 600; }
  .cf-bar-label { font-size: 11.5px; color: var(--text-muted); margin-top: 8px; text-align: center; padding-bottom: 11px; }
  .cf-row-head { cursor: pointer; }
  .cf-row-head:hover td { background: var(--surface-2); }
  .cf-detail-row td { padding: 0; border-bottom: 1px solid var(--border); }
  .cf-detail-row.closed { display: none; }
  .cf-detail-row table { border: none; border-radius: 0; box-shadow: none; }
  .cf-detail-row thead th { background: var(--surface-2); }
  .cf-toggle { display: inline-block; width: 14px; font-size: 10px; color: var(--text-muted); }

  /* ---------- Insights ---------- */
  .insights-topbar {
    display: flex; align-items: flex-end; gap: 14px; margin-bottom: 14px;
  }
  .insights-topbar select {
    border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 12.5px;
    background: var(--surface); color: var(--text); font-family: inherit; font-weight: 600;
  }
  .ins-fy-label { font-size: 12px; color: var(--text-muted); padding-bottom: 7px; }
  nav.ins-subnav {
    display: flex; gap: 2px; margin-bottom: 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap;
  }
  nav.ins-subnav button {
    background: none; border: none; padding: 9px 14px; font-size: 12.5px; font-weight: 600;
    color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
    transition: color .14s ease, border-color .14s ease;
  }
  nav.ins-subnav button:hover { color: var(--text); }
  nav.ins-subnav button.active { color: var(--text); border-bottom-color: var(--accent); }
  .ins-page { display: none; }
  .ins-page.active { display: block; }

  .chart-box {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 18px; min-height: 220px;
  }
  .chart-box.hbar { min-height: auto; }
  .donut-box {
    display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 20px; min-height: 220px;
  }
  .donut { position: relative; width: 150px; height: 150px; border-radius: 50%; flex: 0 0 150px; }
  .donut .donut-hole {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
    width: 92px; height: 92px; border-radius: 50%; background: var(--surface);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    box-shadow: inset 0 0 0 1px var(--border);
  }
  .donut .donut-hole .dv {
    font-size: 18px; color: var(--text); line-height: 1.1;
    max-width: 86px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .donut .donut-hole .dl { font-size: 9.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; text-align: center; }
  .donut-legend { display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; flex: 1 1 160px; }
  .donut-legend .dl-row { display: flex; align-items: center; gap: 8px; }
  .donut-legend .dl-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
  .donut-legend .dl-label { color: var(--text); font-weight: 600; }
  .donut-legend .dl-value { color: var(--text-muted); margin-left: auto; font-variant-numeric: tabular-nums; }

  .insight-callout {
    margin-top: 14px; padding: 12px 16px; border-radius: var(--radius);
    background: var(--accent-soft); border: 1px solid var(--accent-soft); color: var(--text);
    font-size: 12.5px; line-height: 1.6;
  }
  .insight-callout strong { color: var(--accent); }

  nav.ins-month-nav {
    display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px;
  }
  nav.ins-month-nav button {
    display: flex; align-items: center; gap: 6px;
    border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
    padding: 6px 12px; font-size: 12px; font-weight: 600; color: var(--text-muted); cursor: pointer;
  }
  nav.ins-month-nav button .mb { background: var(--slate-bg); color: var(--slate); border-radius: 999px; padding: 1px 7px; font-size: 10.5px; font-weight: 700; }
  nav.ins-month-nav button.empty { opacity: .45; }
  nav.ins-month-nav button:hover { border-color: var(--border-strong); color: var(--text); }
  nav.ins-month-nav button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
  nav.ins-month-nav button.active .mb { background: var(--accent); color: #fff; }

  .month-summary-row { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 12px; }
  .month-summary-row .ft-item { display: flex; flex-direction: column; gap: 3px; }
  .month-summary-row .ft-label { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; font-weight: 650; color: var(--text-muted); }
  .month-summary-row .ft-value { font-size: 21px; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.15; }
  .month-empty-state {
    padding: 34px 20px; text-align: center; color: var(--text-muted); font-size: 13px;
    background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius);
  }

  .scenario-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 4px; }
  .scenario-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 16px;
  }
  .scenario-card.reco { border-color: var(--accent); background: var(--accent-soft); }
  .scenario-card .sc-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 650; color: var(--text-muted); }
  .scenario-card.reco .sc-label { color: var(--accent); }
  .scenario-card .sc-tag {
    display: inline-block; margin-left: 6px; background: var(--accent); color: #fff; border-radius: 999px;
    padding: 1px 7px; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; vertical-align: middle;
  }
  .scenario-card .sc-value { font-size: 26px; margin: 8px 0 4px; line-height: 1.1; }
  .scenario-card .sc-sub { font-size: 11.5px; color: var(--text-muted); }

  .ins-calendar { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 4px; }
  .ins-cal-cell {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 11px 13px; box-shadow: var(--shadow);
  }
  .ins-cal-cell .cc-month { font-size: 13px; font-weight: 650; color: var(--text); margin-bottom: 6px; }
  .ins-cal-tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
  .ins-cal-tag.peak { background: var(--red-bg); color: var(--red); }
  .ins-cal-tag.pitch { background: var(--amber-bg); color: var(--amber); }
  .ins-cal-tag.prospect { background: var(--slate-bg); color: var(--slate); }
  .ins-cal-cell .cc-sub { font-size: 11px; color: var(--text-muted); margin-top: 5px; }

  ul.ins-playbook { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
  ul.ins-playbook li {
    display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; line-height: 1.55;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 10px 14px; box-shadow: var(--shadow);
  }
  ul.ins-playbook li .pb-num {
    flex: 0 0 20px; height: 20px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
    display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700;
  }

  /* ---------- Buttons ---------- */
  .btn {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    border-radius: 6px; padding: 7px 13px; font-size: 12.5px; font-weight: 600;
    font-family: inherit; cursor: pointer;
    transition: background .12s ease, border-color .12s ease, color .12s ease;
  }
  .btn:hover { border-color: var(--border-strong); background: var(--surface-2); }
  .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
  .btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
  .btn.danger { color: var(--red); border-color: var(--border); }
  .btn.danger:hover { background: var(--red-bg); border-color: var(--red-bg); }
  .btn.ghost { border-color: transparent; background: transparent; color: var(--text-muted); }
  .btn.ghost:hover { background: var(--surface-2); color: var(--text); }
  .btn:disabled { opacity: .5; cursor: not-allowed; }
  .btn .ico svg { width: 14px; height: 14px; display: block; }

  /* row actions */
  td.actions-cell { white-space: nowrap; text-align: right; }
  .row-act {
    border: none; background: none; cursor: pointer; padding: 4px 6px;
    border-radius: 5px; color: var(--text-muted); font-size: 11.5px; font-weight: 600;
    transition: background .12s ease, color .12s ease;
  }
  .row-act:hover { background: var(--accent-soft); color: var(--accent); }
  .row-act.del:hover { background: var(--red-bg); color: var(--red); }

  /* ---------- Modal ---------- */
  .modal-backdrop {
    display: none; position: fixed; inset: 0; z-index: 300;
    background: rgba(20,24,31,.42); align-items: flex-start; justify-content: center;
    padding: 48px 16px; overflow-y: auto;
  }
  .modal-backdrop.open { display: flex; }
  .modal {
    background: var(--surface-raised); border-radius: 12px; width: 100%; max-width: 720px;
    box-shadow: 0 20px 60px rgba(20,24,31,.28); overflow: hidden;
  }
  .modal.narrow { max-width: 460px; }
  .modal-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
  }
  .modal-head h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }
  .modal-head .sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
  .modal-close {
    border: none; background: none; cursor: pointer; color: var(--text-muted);
    font-size: 20px; line-height: 1; padding: 2px 6px; border-radius: 5px;
  }
  .modal-close:hover { background: var(--surface-2); color: var(--text); }
  .modal-body { padding: 18px 20px; }
  .modal-foot {
    display: flex; align-items: center; justify-content: flex-end; gap: 8px;
    padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2);
  }
  .modal-foot .spacer { margin-right: auto; }

  /* ---------- Form ---------- */
  .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
  .form-field { display: flex; flex-direction: column; gap: 5px; }
  .form-field.full { grid-column: 1 / -1; }
  .form-field label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 650; color: var(--text-muted); }
  .form-field label .req { color: var(--red); margin-left: 2px; }
  .form-field input, .form-field select, .form-field textarea {
    border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px;
    font-size: 13px; font-family: inherit; background: var(--surface); color: var(--text);
    outline: none; width: 100%;
  }
  .form-field textarea { resize: vertical; min-height: 62px; line-height: 1.5; }
  .form-field input:focus, .form-field select:focus, .form-field textarea:focus {
    border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
  }
  .form-field.invalid input, .form-field.invalid select, .form-field.invalid textarea { border-color: var(--red); }
  /* combobox inside a form field matches the surrounding inputs */
  .form-field .ms { width: 100%; }
  .form-field .ms-btn {
    width: 100%; height: auto; padding: 8px 10px; font-size: 13px;
    justify-content: space-between;
  }
  .form-field .ms-btn .ms-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .form-field .ms-panel { width: 100%; max-height: 260px; }
  .ms-opt.one { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ms-opt.one.sel { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .form-field .hint { font-size: 11px; color: var(--text-muted); }
  .form-field .err { font-size: 11px; color: var(--red); font-weight: 600; display: none; }
  .form-field.invalid .err { display: block; }
  .form-field.invalid .hint { display: none; }
  .form-section-title {
    grid-column: 1 / -1; font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
    font-weight: 650; color: var(--text-muted); padding-top: 6px;
    border-top: 1px solid var(--border); margin-top: 4px;
  }
  .form-error-banner {
    display: none; background: var(--red-bg); color: var(--red); border-radius: 6px;
    padding: 9px 12px; font-size: 12.5px; font-weight: 600; margin-bottom: 14px;
  }
  .form-error-banner.show { display: block; }

  /* ---------- Pending changes ---------- */
  .pending-bar {
    display: none; align-items: center; gap: 12px; flex-wrap: wrap;
    background: var(--amber-bg); border: 1px solid var(--amber-bg);
    border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px;
  }
  .pending-bar.show { display: flex; }
  .pending-bar .pb-text { font-size: 12.5px; color: var(--amber); font-weight: 650; }
  .pending-bar .pb-note { font-size: 11.5px; color: var(--text-muted); font-weight: 500; }
  .pending-bar .pb-actions { margin-left: auto; display: flex; gap: 8px; }
  .pending-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
  .pending-item {
    display: flex; align-items: flex-start; gap: 10px; font-size: 12.5px;
    border: 1px solid var(--border); border-radius: 7px; padding: 9px 12px;
  }
  .op-tag {
    flex: 0 0 auto; padding: 2px 8px; border-radius: 4px;
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  }
  .op-tag.create { background: var(--green-bg); color: var(--green); }
  .op-tag.update { background: var(--accent-soft); color: var(--accent); }
  .op-tag.delete { background: var(--red-bg); color: var(--red); }
  .export-box {
    width: 100%; min-height: 130px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px; line-height: 1.5; border: 1px solid var(--border); border-radius: 7px;
    padding: 10px 12px; background: var(--surface-2); color: var(--text); resize: vertical;
    white-space: pre; overflow-wrap: normal; overflow-x: auto;
  }
  .tabs-mini { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
  .tabs-mini button {
    background: none; border: none; padding: 7px 12px; font-size: 12px; font-weight: 600;
    color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
  }
  .tabs-mini button.active { color: var(--accent); border-bottom-color: var(--accent); }
  .warn-box {
    background: var(--amber-bg); color: var(--amber); border-radius: 7px;
    padding: 10px 13px; font-size: 12.5px; line-height: 1.55; margin-top: 12px;
  }

  /* ---------- Interactive chart layer ---------- */
  .chart-tip {
    position: fixed; z-index: 200; pointer-events: none;
    background: #14181f; color: #fff; border-radius: 7px;
    padding: 8px 11px; font-size: 11.5px; line-height: 1.55;
    box-shadow: 0 8px 22px rgba(0,0,0,.24);
    opacity: 0; transition: opacity .1s ease; max-width: 260px;
    left: 0; top: 0;
  }
  .chart-tip.show { opacity: 1; }
  .chart-tip .tt-title { font-weight: 700; margin-bottom: 4px; white-space: nowrap; }
  .chart-tip .tt-row { display: flex; gap: 14px; justify-content: space-between; white-space: nowrap; }
  .chart-tip .tt-k { color: rgba(255,255,255,.68); }
  .chart-tip .tt-v { font-variant-numeric: tabular-nums; font-weight: 650; }
  .chart-tip .tt-hint { margin-top: 5px; color: rgba(255,255,255,.55); font-size: 10.5px; }

  svg .bar { transition: opacity .1s ease; }
  svg .bar.hot { opacity: .72; }
  svg .hit { fill: transparent; }
  svg .hit.clickable { cursor: pointer; }
  .chart-box.clickable-bars svg .hit { cursor: pointer; }

  .donut svg { display: block; }
  .donut-seg { transition: opacity .12s ease; }
  .donut.dimmed .donut-seg { opacity: .3; }
  .donut.dimmed .donut-seg.hot { opacity: 1; }
  .donut-legend .dl-row {
    padding: 3px 6px; margin: -3px -6px; border-radius: 5px;
    transition: background .12s ease; cursor: default;
  }
  .donut-legend .dl-row.hot { background: var(--surface-2); }
  .donut-legend .dl-total {
    border-top: 1px solid var(--border);
    margin-top: 6px; padding-top: 10px; cursor: default;
  }
  .donut-legend .dl-total .dl-label { font-weight: 650; }
  .donut-legend .dl-total .dl-value { color: var(--text); font-weight: 650; }
  .donut-legend .dl-total:hover { background: transparent; }

  .hbar-row { transition: background .12s ease; border-radius: 5px; padding: 2px 4px; margin: 0 -4px 6px; }
  .hbar-row:hover { background: var(--surface-2); }
  .hbar-fill { transition: filter .12s ease; }
  .hbar-row:hover .hbar-fill { filter: brightness(1.12); }

  .cf-bar-col { cursor: pointer; border-radius: 6px; transition: background .12s ease; }
  .cf-bar-col:hover { background: var(--surface-2); }
  .cf-bar-col.active { background: var(--accent-soft); }
  .cf-bar-seg { transition: opacity .12s ease; }
  .cf-bar-col:hover .cf-bar-seg { opacity: .8; }

  /* ---------- Year over Year ---------- */
  .yoy-topbar { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
  .yoy-topbar select {
    border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 12.5px;
    background: var(--surface); color: var(--text); font-family: inherit; font-weight: 600;
  }
  .yoy-vs { font-size: 12.5px; color: var(--text-muted); padding-bottom: 7px; font-weight: 600; }

  /* Year-over-year cards use the standard card shell; the delta gets its own
     line so it can never wrap or sit inconsistently beside the figure. */
  .yoy-card .yc-delta { margin-top: 9px; line-height: 1; }
  .yoy-card .yc-prior {
    font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums;
    margin-top: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .delta {
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    height: 20px; padding: 0 8px; border-radius: 999px;
    font-size: 11px; font-weight: 700; white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }
  .delta .arw { font-size: 8px; line-height: 1; }
  .delta.up { background: var(--green-bg); color: var(--green); }
  .delta.down { background: var(--red-bg); color: var(--red); }
  .delta.flat { background: var(--slate-bg); color: var(--slate); }

  .yoy-legend { display: flex; gap: 16px; align-items: center; font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
  .yoy-legend .lg { display: flex; align-items: center; gap: 6px; }
  .yoy-legend .lg-dot { width: 10px; height: 10px; border-radius: 3px; }

  .yoy-brand-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
  .yoy-brand-col .bc-head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    font-size: 13px; font-weight: 650; margin-bottom: 8px;
  }
  .yoy-brand-col .bc-count {
    background: var(--slate-bg); color: var(--slate); border-radius: 999px;
    padding: 1px 8px; font-size: 11px; font-weight: 700;
  }
  .yoy-brand-col.new .bc-count { background: var(--green-bg); color: var(--green); }
  .yoy-brand-col.lost .bc-count { background: var(--red-bg); color: var(--red); }
  .yoy-brand-col.kept .bc-count { background: var(--accent-soft); color: var(--accent); }


/* ---------- Hosted-app chrome ---------- */
.app-shell { visibility: hidden; }
.boot-screen, .login-screen {
  display: none; position: fixed; inset: 0; z-index: 500;
  background: var(--bg); align-items: center; justify-content: center;
  flex-direction: column; gap: 18px; text-align: center; padding: 24px;
}
.boot-screen.show, .login-screen.show { display: flex; }
.boot-title { font-family: var(--font-serif); font-size: 22px; font-weight: 600; color: var(--title); }
.boot-detail { font-size: 12.5px; color: var(--text-muted); max-width: 460px; line-height: 1.6; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(32,30,26,.10); padding: 30px 32px; width: 100%; max-width: 360px;
  text-align: left;
}
.login-card h1 { font-family: var(--font-serif); font-size: 24px; font-weight: 600; margin: 0 0 4px; color: var(--title); }
.login-card .sub { font-size: 12.5px; color: var(--text-muted); margin-bottom: 20px; }
.login-card input {
  width: 100%; border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; font-size: 14px; font-family: inherit;
  background: var(--surface-2); color: var(--text); outline: none;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.login-card button { width: 100%; margin-top: 12px; justify-content: center; }
.login-err { color: var(--red); font-size: 12px; font-weight: 600; margin-top: 10px; min-height: 16px; }

.sidebar-actions { display: flex; gap: 6px; padding: 10px 12px 0; }
.sidebar-actions button {
  flex: 1; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  border-radius: 7px; padding: 7px 8px; font-size: 11.5px; font-weight: 600;
  font-family: inherit; cursor: pointer; display: inline-flex; align-items: center;
  justify-content: center; gap: 5px;
}
.sidebar-actions button:hover { color: var(--text); border-color: var(--border-strong); }
.sidebar-actions button:disabled { opacity: .55; cursor: not-allowed; }
.sidebar-actions svg { width: 13px; height: 13px; }
.sidebar-actions .spinning svg { animation: spin .8s linear infinite; }


/* ---- cached-data pill ---------------------------------------------- */
.stale-hint {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(12px);
  z-index: 90;
  padding: 8px 16px;
  border-radius: 999px;
  background: hsl(200 30% 12% / .92);
  color: hsl(40 30% 96%);
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: .01em;
  box-shadow: 0 6px 22px hsl(200 30% 12% / .22);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}
.stale-hint.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.stale-hint.warn {
  background: hsl(28 60% 26% / .95);
}
