:root {
  color-scheme: light;
  /* Ahmed Seddiqi Holding brand: navy + bronze on white/near-black —
     lifted from seddiqiholding.com's own :root (--color-blue #2f3a6a,
     --color-dark-blue #152156, --color-dark-brown #88664e, body text
     #363636, dark2 #171717). Chart marks (--series-a/b) are a lighter,
     higher-chroma step of the same two hue families, since the literal
     brand tones fail the dataviz skill's lightness/chroma checks for a
     data mark — validated with validate_palette.js before shipping. */
  --ink-950: #17171a; --paper-50: #ffffff; --paper-100: #f2f1ee; --paper-200: #e7e5e0;
  --line: #dedcd5; --text-primary: #1b1b1a; --text-secondary: #3f3d38; --text-muted: #86816f;
  --surface-raised: #ffffff;
  --navy: #2f3a6a; --navy-strong: #152156; --navy-wash: #eaecf4;
  --brass: #88664e; --brass-strong: #6a4c36; --brass-wash: #f0e7db;
  --series-a: #2f66c2; --series-b: #b5713a; --good: #1a7a3d; --good-wash: #e2f0e5;
  --critical: #b8342a; --critical-wash: #f6e2df; --warn: #a9740c; --warn-wash: #f3e6cb;
  --shadow: 0 1px 2px rgba(23,23,26,.05), 0 10px 26px -14px rgba(23,23,26,.16); --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink-950: #121113; --paper-50: #1a191c; --paper-100: #201f22; --paper-200: #29282b;
    --line: #38373b; --text-primary: #f0efec; --text-secondary: #c4c1ba; --text-muted: #928d80;
    --surface-raised: #201f22;
    --navy: #86a6ea; --navy-strong: #aac2f2; --navy-wash: #202a42;
    --brass: #c99a6e; --brass-strong: #e3bd94; --brass-wash: #332a1f;
    --series-a: #4a7fd4; --series-b: #b97a3a; --good: #4fae74; --good-wash: #1c3226;
    --critical: #e0776b; --critical-wash: #3a221e; --warn: #cf9f3d; --warn-wash: #362b13;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 26px -14px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink-950: #121113; --paper-50: #1a191c; --paper-100: #201f22; --paper-200: #29282b;
  --line: #38373b; --text-primary: #f0efec; --text-secondary: #c4c1ba; --text-muted: #928d80;
  --surface-raised: #201f22;
  --navy: #86a6ea; --navy-strong: #aac2f2; --navy-wash: #202a42;
  --brass: #c99a6e; --brass-strong: #e3bd94; --brass-wash: #332a1f;
  --series-a: #4a7fd4; --series-b: #b97a3a; --good: #4fae74; --good-wash: #1c3226;
  --critical: #e0776b; --critical-wash: #3a221e; --warn: #cf9f3d; --warn-wash: #362b13;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 26px -14px rgba(0,0,0,.6);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--paper-50); color: var(--text-primary); font-family: "Archivo", ui-sans-serif, system-ui, sans-serif; font-size: 14px; line-height: 1.5; }
h1, h2, h3 { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 600; text-wrap: balance; margin: 0; }
.num, code, table.figures td { font-family: "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
a { color: var(--brass-strong); }

.topbar { display: flex; align-items: center; justify-content: space-between; background: var(--ink-950); color: var(--paper-100); padding: 10px 20px; position: sticky; top: 0; z-index: 20; }
.topbar-brand .mark { font-family: "Cormorant Garamond", serif; font-weight: 600; font-size: 18px; color: #f2f1ee; margin-right: 10px; }
.topbar-brand .sub { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: rgba(242,241,238,.55); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-guide { font-size: 12px; font-weight: 600; color: #d9b98c; text-decoration: none; border: 1px solid rgba(242,241,238,.2); border-radius: 999px; padding: 4px 12px; transition: border-color .12s, filter .12s; }
.topbar-guide:hover { border-color: #d9b98c; filter: brightness(1.2); }
.topbar-status { font-size: 11.5px; font-family: "IBM Plex Mono", monospace; color: rgba(242,241,238,.7); }
.topbar-status.ok::before { content: "●"; color: var(--good); margin-right: 5px; }
.topbar-status.bad::before { content: "●"; color: var(--critical); margin-right: 5px; }

.shell { display: flex; min-height: calc(100vh - 41px); }
.rail { width: 244px; flex: none; background: var(--ink-950); color: var(--paper-100); padding: 16px 14px; position: sticky; top: 41px; height: calc(100vh - 41px); overflow-y: auto; }
.steplist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 20px; }
/* Two rail sections get their own accent, drawn from the same navy/brass
   pair the rest of the app already uses for series-a/series-b — Analyse
   (the pages a working-level finance user opens day to day) reads blue,
   Admin (data/pipeline-facing pages) reads bronze, so the two are
   distinguishable by hue at a glance, not just by the text label. */
.railgroup[data-group="analyse"] { --rail-accent: 134,166,234; }
.railgroup[data-group="admin"] { --rail-accent: 201,154,110; }
.railgroup { list-style: none; }
.railgroup-label {
  font-size: 10.2px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: rgba(var(--rail-accent), .8); padding: 0 13px 8px; display: flex; align-items: center; gap: 7px;
}
.railgroup-label::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: rgba(var(--rail-accent), .9); flex: none; }
.railgroup-list {
  list-style: none; margin: 0; padding: 10px 0 10px 10px; display: flex; flex-direction: column; gap: 7px;
  border-left: 2px solid rgba(var(--rail-accent), .22);
}
.steplist button {
  all: unset; display: block; width: 100%; box-sizing: border-box; padding: 10px 13px;
  border-radius: 12px; cursor: pointer; background: rgba(242,241,238,.045); border: 1px solid rgba(242,241,238,.07);
  color: rgba(242,241,238,.68); font-size: 12.8px; transition: background .14s, border-color .14s, color .14s, transform .1s;
}
.railgroup-list button:hover { background: rgba(var(--rail-accent), .1); border-color: rgba(var(--rail-accent), .3); color: #f2f1ee; transform: translateY(-1px); }
.railgroup-list button.active { background: rgba(var(--rail-accent), .18); border-color: rgba(var(--rail-accent), .6); color: #f2f1ee; font-weight: 600; box-shadow: 0 4px 14px -6px rgba(0,0,0,.55); }
.steplist .stepclaim { display: block; font-size: 10.4px; color: rgba(242,241,238,.45); margin-top: 2px; font-weight: 400; }
.rail-foot { margin-top: 16px; padding: 12px 10px; border-top: 1px solid rgba(242,241,238,.12); font-size: 10.8px; color: rgba(242,241,238,.5); }
.main { flex: 1; min-width: 0; padding: 30px 40px 80px; max-width: 1180px; }
@media (max-width: 900px) { .shell { flex-direction: column; } .rail { position: static; width: 100%; height: auto; } .main { padding: 20px 16px 60px; } }

.eyebrow { text-transform: uppercase; letter-spacing: .09em; font-size: 11px; color: var(--brass); font-weight: 600; }
h1.title { font-size: 30px; font-weight: 600; margin: 5px 0 8px; }
.claim { font-size: 14.5px; color: var(--text-secondary); max-width: 68ch; margin: 0 0 20px; }
.loading { padding: 40px; color: var(--text-muted); font-style: italic; }

/* Sub-tabs: several related views sharing one rail entry (e.g. Incentives:
   variances / advisor / analytics / simulator), switched without leaving
   the page. h2.subtitle is the smaller heading each sub-view gets in
   place of the page-level h1 (see subshell() in app.js). */
.subtabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; border-bottom: 1px solid var(--line); padding-bottom: 16px; }
.subtab { all: unset; cursor: pointer; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-raised); color: var(--text-secondary); font: inherit; font-size: 13px; font-weight: 600; transition: border-color .12s, background .12s, color .12s; }
.subtab:hover { border-color: var(--navy); color: var(--navy); }
.subtab.active { background: var(--navy-wash); border-color: var(--navy); color: var(--navy); }
.subtab .subtabclaim { display: block; font-size: 10.5px; font-weight: 400; margin-top: 1px; opacity: .75; }
h2.subtitle { font-size: 22px; font-weight: 600; margin: 0 0 6px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 16px 0 22px; }
.tile { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tile .tlabel { font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.tile .tval { font-size: 20px; font-weight: 600; margin-top: 3px; }
.tile .tsub { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.tile.good .tval { color: var(--good); } .tile.critical .tval { color: var(--critical); }
button.tile.clickable { display: block; cursor: pointer; font: inherit; color: inherit; text-align: left; width: 100%; transition: border-color .12s, transform .12s; }
.tile.clickable:hover { border-color: var(--navy); transform: translateY(-1px); }
.tile.clickable:focus-visible { outline: 2px solid var(--navy); outline-offset: 1px; }
.tile .tgoto { font-size: 10.5px; color: var(--navy); margin-top: 5px; font-weight: 600; }
.tile.clickable:hover .tgoto::after { content: " \2192"; }

.panel { background: var(--surface-raised); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.panel h3 { font-size: 14.5px; margin-bottom: 3px; font-weight: 600; font-family: "Archivo", sans-serif; }
.panel .panelnote { font-size: 11.8px; color: var(--text-muted); margin: 0 0 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 760px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; font-size: 12.4px; }
table th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); padding: 6px 9px; border-bottom: 1px solid var(--line); font-weight: 600; white-space: nowrap; }
table th.sortable { cursor: pointer; user-select: none; }
table th.sortable:hover { color: var(--navy); }
table th.sorted::after { content: " ▾"; }
table th.sorted.asc::after { content: " ▴"; }
table td { padding: 6px 9px; border-bottom: 1px solid var(--paper-200); }
table tr:last-child td { border-bottom: none; }
table tr.clickable { cursor: pointer; }
table tr.clickable:hover { background: var(--paper-100); }
.tablewrap { overflow-x: auto; }
.right { text-align: right; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 10.6px; font-weight: 600; }
.pill.good { background: var(--good-wash); color: var(--good); }
.pill.critical { background: var(--critical-wash); color: var(--critical); }
.pill.warn { background: var(--warn-wash); color: var(--warn); }
.pill.neutral { background: var(--paper-100); color: var(--text-secondary); }
.code-inline { font-family: "IBM Plex Mono", monospace; background: var(--paper-100); padding: 1px 6px; border-radius: 6px; font-size: 11.6px; }

.controlbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.field input[type=text], .field input[type=search], .field select, .field input[type=date] {
  font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-raised); color: var(--text-primary); min-width: 150px;
}
.field input:focus, .field select:focus { outline: 2px solid var(--navy); outline-offset: -1px; }
.field select.placeholder { color: var(--text-muted); }
.field select.placeholder option { color: var(--text-primary); }

.slider-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.slider-row .slabel { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; gap: 8px; }
.slider-row .sfield { display: flex; align-items: center; gap: 6px; }
.slider-row .sval { font-family: "IBM Plex Mono", monospace; font-weight: 600; color: var(--navy); }
.slider-row .snum { width: 64px; font: inherit; font-family: "IBM Plex Mono", monospace; padding: 3px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-raised); color: var(--text-primary); text-align: right; }
.slider-row .snum-wide { width: 82px; }
.slider-row .snum:focus { outline: 2px solid var(--navy); outline-offset: -1px; }
input[type=range] { -webkit-appearance: none; width: 100%; height: 4px; border-radius: 3px; background: var(--line); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--navy); cursor: pointer; border: 2px solid var(--surface-raised); box-shadow: 0 0 0 1px var(--navy); }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--navy); cursor: pointer; border: 2px solid var(--surface-raised); }
.reset-link { font-size: 11.5px; font-weight: 600; color: var(--text-secondary); cursor: pointer; background: none; border: 1px solid var(--line); border-radius: 999px; font: inherit; padding: 6px 15px; transition: border-color .12s, color .12s; }
.reset-link:hover { border-color: var(--navy); color: var(--navy); }

.dialgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px 24px; margin-bottom: 6px; }
.dialgrid .slider-row { margin-bottom: 4px; }
.dialscope { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; line-height: 1.35; }

/* Glossary terms: a dotted underline that reveals a definition on hover
   or keyboard focus, so jargon (WAPE, clawback, honesty constraint...)
   is explained inline instead of assumed. */
.term { border-bottom: 1px dotted var(--text-muted); cursor: help; position: relative; }
.term:hover::after, .term:focus-visible::after {
  content: attr(data-def); position: absolute; left: 0; bottom: 130%; width: max-content; max-width: 260px;
  background: var(--ink-950); color: #f2f1ee; font-size: 11.2px; line-height: 1.45; padding: 8px 11px;
  border-radius: 10px; box-shadow: var(--shadow); z-index: 40; white-space: normal;
  font-family: "Archivo", sans-serif; font-weight: 400; text-transform: none; letter-spacing: normal;
}

/* Chart hover tooltip: a floating card that follows the crosshair guide
   drawn inside the SVG (see charts.js handleChartPointer). */
.chartwrap { position: relative; }
.chartwrap svg { cursor: crosshair; }
.chart-tooltip { position: absolute; top: 4px; display: none; pointer-events: none; background: var(--ink-950); color: #f2f1ee;
  border-radius: 10px; padding: 8px 11px; font-size: 11.5px; box-shadow: var(--shadow); z-index: 25; white-space: nowrap; }
.chart-tooltip.show { display: block; }
.chart-tooltip .tip-date { font-weight: 600; margin-bottom: 4px; font-family: "IBM Plex Mono", monospace; color: #f2f1ee; opacity: .8; }
.chart-tooltip .tip-row { display: flex; align-items: center; gap: 6px; }
.chart-tooltip .tip-row + .tip-row { margin-top: 2px; }
.chart-tooltip .tip-swatch { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.chart-tooltip .tip-val { font-family: "IBM Plex Mono", monospace; font-weight: 600; margin-left: 10px; }
.chart-tooltip .tip-band { opacity: .8; font-size: 10.8px; }

.pager { display: flex; gap: 8px; align-items: center; margin-top: 10px; font-size: 12px; }
.pager button { font: inherit; padding: 5px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-raised); cursor: pointer; transition: border-color .12s, color .12s; }
.pager button:not(:disabled):hover { border-color: var(--navy); color: var(--navy); }
.pager button:disabled { opacity: .4; cursor: default; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-secondary); margin-top: 6px; }
.legend .item { display: flex; align-items: center; gap: 6px; }
.legend .swatch { width: 12px; height: 4px; border-radius: 3px; }
.chartcaption { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
svg text { font-family: "IBM Plex Mono", monospace; fill: var(--text-secondary); }
svg .axislabel { font-size: 10px; } svg .dlabel { font-size: 11px; font-weight: 600; }

.script { background: var(--brass-wash); border: 1px dashed var(--brass); border-radius: 14px; padding: 12px 16px; margin: 6px 0 18px; }
.script .slabel { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--brass-strong); font-weight: 700; margin-bottom: 5px; }
.script p { margin: 0 0 6px; font-family: "Cormorant Garamond", serif; font-style: italic; font-size: 16px; }
.script p:last-child { margin-bottom: 0; }
.empty { color: var(--text-muted); font-style: italic; padding: 16px; text-align: center; }
.detail-row td { background: var(--paper-100); }
.subhead { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; margin: 22px 0 8px; }
.subhead:first-child { margin-top: 0; }

.guide-toc { display: flex; flex-wrap: wrap; gap: 8px; }
.guide-toc a { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 5px 13px; transition: border-color .12s, color .12s; }
.guide-toc a:hover { border-color: var(--navy); color: var(--navy); }
#gd-glossary table th { text-transform: none; letter-spacing: 0; font-size: 12.4px; font-weight: 600; color: var(--text-primary); white-space: nowrap; vertical-align: top; padding-top: 8px; }
#gd-glossary table td { vertical-align: top; }

.acro-panel { background: var(--paper-100); box-shadow: none; margin-top: 4px; }
.acro-panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 10px; }
.acro-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 7px 20px; }
.acro-item { display: flex; gap: 9px; font-size: 12px; align-items: baseline; }
.acro-key { font-family: "IBM Plex Mono", monospace; font-weight: 700; color: var(--brass-strong); flex: none; }
.acro-def { color: var(--text-secondary); }

/* A chart panel that pops into a larger modal on click — cursor + a lift
   on hover signal it's interactive; the enlarge affordance in the corner
   confirms it before the click. */
.chart-clickable { cursor: zoom-in; transition: transform .12s ease, box-shadow .12s ease; position: relative; }
.chart-clickable:hover { transform: translateY(-3px); box-shadow: 0 14px 32px -12px rgba(23,23,26,.28); }
.chart-clickable:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.chart-clickable .expand-hint { position: absolute; top: 16px; right: 18px; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); opacity: 0; transition: opacity .12s ease; }
.chart-clickable:hover .expand-hint { opacity: 1; }

.chart-modal { position: fixed; inset: 0; z-index: 200; display: none; align-items: center; justify-content: center; padding: 24px; }
.chart-modal.open { display: flex; }
.chart-modal-backdrop { position: absolute; inset: 0; background: rgba(16,15,13,.55); }
.chart-modal-card { position: relative; z-index: 1; background: var(--surface-raised); border-radius: 16px; padding: 28px 32px 24px; box-shadow: var(--shadow); max-width: min(1000px, 94vw); max-height: 90vh; overflow: auto; width: 100%; }
.chart-modal-card h3 { font-size: 17px; margin-bottom: 14px; padding-right: 30px; }
.chart-modal-close { all: unset; position: absolute; top: 18px; right: 20px; font-size: 22px; line-height: 1; cursor: pointer; color: var(--text-muted); padding: 4px; border-radius: 6px; }
.chart-modal-close:hover { color: var(--navy); background: var(--paper-100); }

/* Overview landing-page navigation cards. */
.stat-strip { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 12.5px; color: var(--text-secondary); margin: 4px 0 22px; }
.stat-strip strong { color: var(--text-primary); font-family: "IBM Plex Mono", monospace; }
.navcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin: 6px 0 22px; }
.navcard { all: unset; display: block; background: var(--surface-raised); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; cursor: pointer; box-shadow: var(--shadow); transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; box-sizing: border-box; }
.navcard:hover { transform: translateY(-3px); box-shadow: 0 14px 32px -12px rgba(23,23,26,.28); border-color: var(--navy); }
.navcard:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.navcard .navcard-eyebrow { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--brass); font-weight: 700; margin-bottom: 5px; }
.navcard h3 { font-size: 16px; margin-bottom: 7px; }
.navcard p { font-size: 12.3px; color: var(--text-secondary); margin: 0 0 12px; line-height: 1.45; }
.navcard .navcard-go { font-size: 11px; font-weight: 700; color: var(--navy); }
.navcard:hover .navcard-go::after { content: " \2192"; }
