/* ==========================================================================
   Portal design kit: tokens and base styles
   One stylesheet shared by the landing page and all five project reports.
   Layout concept: a deep ink masthead states the finding; the hero figure
   straddles its lower edge; everything after is quiet white plates on a
   cool paper plane, each figure numbered and captioned like an atlas plate.
   No external requests. System fonts only.
   ========================================================================== */

/* ---------- 1. Tokens ---------------------------------------------------- */
:root {
  color-scheme: light;

  /* Surfaces and ink (cool neutrals, biased toward the navy brand ink) */
  --plane:        #f2f4f7;   /* page background */
  --surface:      #ffffff;   /* cards, figures (chart surface) */
  --surface-2:    #f7f8fa;   /* insets, table header, quiet panels */
  --ink:          #0e1824;   /* primary text */
  --ink-2:        #44505e;   /* secondary text */
  --ink-3:        #5f6b79;   /* muted text, axis labels (4.5:1 on surface) */
  --rule:         #dde2e8;   /* hairlines */
  --rule-strong:  #c2cad4;   /* axis baselines, stronger dividers */

  /* Brand */
  --band:         #0c2037;   /* masthead ink band */
  --band-2:       #14304f;   /* raised element on the band */
  --on-band:      #f3f6f9;
  --on-band-2:    #b3c2d1;
  --on-band-rule: rgba(255, 255, 255, 0.14);
  --on-band-accent: #86b6ef;
  --accent:       #2a78d6;   /* interactive, emphasis marks (= series 1) */
  --accent-ink:   #1c5cab;   /* accent used as text or link */
  --accent-wash:  #e8f1fc;
  --focus:        #2a78d6;

  /* Chart: categorical slots. Fixed order. Never reorder, never cycle. */
  --series-1: #2a78d6;  /* blue    */
  --series-2: #eb6834;  /* orange  */
  --series-3: #1baf7a;  /* aqua    */
  --series-4: #eda100;  /* yellow  */
  --series-5: #e87ba4;  /* magenta */
  --series-6: #008300;  /* green   */
  --series-7: #6250d6;  /* violet  */
  --series-8: #e34948;  /* red     */
  --series-ref:  #2b3644;   /* the real-world benchmark / observed data */
  --series-mute: #aab3be;   /* context marks: "everything else" */

  /* Chart: sequential ramp (one hue; step 1 = least, step 5 = most) */
  --seq-1: #86b6ef;
  --seq-2: #5598e7;
  --seq-3: #2a78d6;
  --seq-4: #1c5cab;
  --seq-5: #0d366b;

  /* Chart: diverging pair around a neutral midpoint */
  --div-neg: #e34948;   /* below / under */
  --div-mid: #e6e9ed;
  --div-pos: #2a78d6;   /* above / over */

  /* Chart chrome */
  --chart-grid: #e6e9ee;
  --chart-base: #b9c2cd;
  --chart-band-outer: 0.16;   /* fill opacity of the widest uncertainty band */
  --chart-band-inner: 0.30;

  /* Status (reserved meaning; always with a dot and a label) */
  --status-good:     #0b8a0b;
  --status-warn:     #b97800;
  --status-serious:  #cc5a2b;
  --status-critical: #c63131;
  --status-neutral:  #5f6b79;

  /* Type */
  --font-display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;

  --fs-micro: 0.6875rem;  /* 11  kickers, figure numbers */
  --fs-small: 0.8125rem;  /* 13  captions, table cells, meta */
  --fs-body:  1rem;       /* 16 */
  --fs-lede:  1.1875rem;  /* 19 */
  --fs-h3:    1.1875rem;  /* 19 */
  --fs-h2:    clamp(1.5rem, 1.1rem + 1.6vw, 2rem);
  --fs-h1:    clamp(1.875rem, 1.1rem + 3.4vw, 3.25rem);
  --fs-stat:  clamp(1.75rem, 1.3rem + 1.6vw, 2.375rem);

  /* Space (4px base) */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;
  --s-8: 4.5rem;

  --radius:    8px;
  --radius-sm: 4px;
  --measure:   66ch;
  --wrap:      72rem;
  --shadow:    0 1px 2px rgba(14, 24, 36, 0.05), 0 8px 24px -12px rgba(14, 24, 36, 0.14);
  --shadow-lift: 0 2px 4px rgba(14, 24, 36, 0.06), 0 18px 40px -16px rgba(14, 24, 36, 0.28);
}

/* Dark values. Declared twice so an explicit data-theme wins either way. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane: #0a0f15; --surface: #141b24; --surface-2: #19222d;
    --ink: #edf1f5; --ink-2: #b7c1cc; --ink-3: #8e9aa7;
    --rule: #25303c; --rule-strong: #3a4654;
    --band: #101d2d; --band-2: #1a2c42;
    --accent: #3987e5; --accent-ink: #86b6ef; --accent-wash: #16283d; --focus: #86b6ef;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --series-ref: #dfe5ec; --series-mute: #55616f;
    --seq-1: #184f95; --seq-2: #256abf; --seq-3: #3987e5; --seq-4: #6da7ec; --seq-5: #b7d3f6;
    --div-neg: #e66767; --div-mid: #323c48; --div-pos: #3987e5;
    --chart-grid: #222c37; --chart-base: #44505e;
    --chart-band-outer: 0.20; --chart-band-inner: 0.36;
    --status-good: #2fb62f; --status-warn: #e0a021; --status-serious: #ec835a;
    --status-critical: #ee6a6a; --status-neutral: #8e9aa7;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.4), 0 18px 40px -16px rgba(0, 0, 0, 0.8);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0a0f15; --surface: #141b24; --surface-2: #19222d;
  --ink: #edf1f5; --ink-2: #b7c1cc; --ink-3: #8e9aa7;
  --rule: #25303c; --rule-strong: #3a4654;
  --band: #101d2d; --band-2: #1a2c42;
  --accent: #3987e5; --accent-ink: #86b6ef; --accent-wash: #16283d; --focus: #86b6ef;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --series-ref: #dfe5ec; --series-mute: #55616f;
  --seq-1: #184f95; --seq-2: #256abf; --seq-3: #3987e5; --seq-4: #6da7ec; --seq-5: #b7d3f6;
  --div-neg: #e66767; --div-mid: #323c48; --div-pos: #3987e5;
  --chart-grid: #222c37; --chart-base: #44505e;
  --chart-band-outer: 0.20; --chart-band-inner: 0.36;
  --status-good: #2fb62f; --status-warn: #e0a021; --status-serious: #ec835a;
  --status-critical: #ee6a6a; --status-neutral: #8e9aa7;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.4), 0 18px 40px -16px rgba(0, 0, 0, 0.8);
}

/* ---------- 2. Base ------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 4.5rem; }
body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}
img, svg { max-width: 100%; }
[hidden] { display: none !important; }

h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
h1, h2 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.012em; text-wrap: balance; }
h1 { font-size: var(--fs-h1); line-height: 1.08; }
h2 { font-size: var(--fs-h2); line-height: 1.15; }
h3 { font-size: var(--fs-h3); line-height: 1.3; font-weight: 650; letter-spacing: -0.005em; text-wrap: balance; }
h4 { font-size: var(--fs-body); line-height: 1.35; font-weight: 650; }
p, li { max-width: var(--measure); }
ul, ol { padding-left: 1.2em; }
li + li { margin-top: var(--s-1); }
strong { font-weight: 650; }
small, .small { font-size: var(--fs-small); }
.muted { color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; }

a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
::selection { background: var(--accent); color: #fff; }

code, kbd { font-family: var(--font-mono); font-size: 0.9em; background: var(--surface-2); border: 1px solid var(--rule); border-radius: 3px; padding: 0.05em 0.3em; }
pre { font-family: var(--font-mono); font-size: var(--fs-small); line-height: 1.55; background: var(--surface-2); border: 1px solid var(--rule); border-radius: var(--radius-sm); padding: var(--s-4); overflow-x: auto; margin: 0; }
pre code { background: none; border: 0; padding: 0; font-size: inherit; }
hr { border: 0; border-top: 1px solid var(--rule); margin: var(--s-6) 0; }

/* The small uppercase label used above titles, on figures, on tiles. */
.kicker {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  line-height: 1.4;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
  max-width: none;
}
.lede { font-size: var(--fs-lede); line-height: 1.5; color: var(--ink-2); }

/* ---------- 3. Page shell ------------------------------------------------ */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
@media (min-width: 48rem) {
  .wrap { padding-left: max(32px, env(safe-area-inset-left, 0px)); padding-right: max(32px, env(safe-area-inset-right, 0px)); }
}

/* Sticky top bar: way home, report name, in-page sections. */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--band);
  color: var(--on-band);
  border-bottom: 1px solid var(--on-band-rule);
}
.topbar-inner { display: flex; align-items: center; gap: var(--s-4); min-height: 3rem; }
.topbar a { color: var(--on-band-2); text-decoration: none; }
.topbar a:hover, .topbar a[aria-current] { color: var(--on-band); }
.topbar .home {
  display: inline-flex; align-items: center; gap: 0.45em; flex: none;
  font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--on-band);
  padding: 0.4rem 0.7rem 0.4rem 0.55rem; margin-left: -0.55rem;
  border: 1px solid var(--on-band-rule); border-radius: 999px;
}
.topbar .home::before { content: ""; width: 0.45em; height: 0.45em; border-left: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); margin-left: 0.2em; }
.topbar .home:hover { background: var(--band-2); }
.topbar-title { font-size: var(--fs-small); font-weight: 600; color: var(--on-band); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar-nav { margin-left: auto; display: flex; gap: var(--s-5); font-size: var(--fs-small); overflow-x: auto; white-space: nowrap; min-width: 0; scrollbar-width: none; }
.topbar-nav::-webkit-scrollbar { display: none; }
@media (max-width: 47.99rem) {
  .topbar-title { display: none; }
  .topbar-nav { gap: var(--s-4); mask-image: linear-gradient(to right, transparent 0, #000 12px, #000 calc(100% - 20px), transparent 100%); -webkit-mask-image: linear-gradient(to right, transparent 0, #000 12px, #000 calc(100% - 20px), transparent 100%); padding-inline: 12px 20px; }
}

/* Masthead: the ink band that carries the headline finding. */
.masthead {
  position: relative;
  background-color: var(--band);
  background-image:
    linear-gradient(to bottom, transparent 40%, var(--band) 100%),
    linear-gradient(to right, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: auto, 40px 40px, 40px 40px;
  background-position: 0 0, -1px -1px, -1px -1px;
  color: var(--on-band);
  padding-block: var(--s-7) var(--s-7);
}
.masthead .wrap { display: grid; gap: var(--s-4); }
.masthead .kicker { color: var(--on-band-accent); }
.masthead h1 { max-width: 22ch; }
.masthead h1 em { font-style: italic; color: var(--on-band-accent); }
.masthead .lede { color: var(--on-band-2); max-width: 58ch; }
.masthead a { color: var(--on-band); }
/* When a hero figure follows, the band extends down behind its top half. */
.masthead--hero { padding-bottom: calc(var(--s-7) + 7rem); }
.masthead--hero + main > .figure--hero:first-child,
.masthead--hero + main > .hero:first-child { margin-top: -7rem; position: relative; }

/* Facts row in the masthead: sample, period, method, date. */
.meta { display: flex; flex-wrap: wrap; gap: var(--s-3) var(--s-6); margin-top: var(--s-3); padding-top: var(--s-4); border-top: 1px solid var(--on-band-rule); }
.meta > div { display: grid; gap: 2px; }
.meta dt { font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: 0.09em; text-transform: uppercase; color: var(--on-band-2); }
.meta dd { font-size: var(--fs-small); font-weight: 600; color: var(--on-band); }

main { display: grid; gap: var(--s-7); padding-bottom: var(--s-8); }
main > * { min-width: 0; }
.masthead:not(.masthead--hero) + main { padding-top: var(--s-7); }

.section { display: grid; gap: var(--s-5); scroll-margin-top: 4.5rem; }
.section > * { min-width: 0; }
.section-head { display: grid; gap: var(--s-2); padding-top: var(--s-5); border-top: 1px solid var(--rule-strong); }
.section-head p:not(.kicker) { color: var(--ink-2); }
.prose { display: grid; gap: var(--s-4); }
.prose > * { min-width: 0; }

.grid { display: grid; gap: var(--s-5); grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr)); }
.grid > * { min-width: 0; }
.cols-2 { display: grid; gap: var(--s-5); grid-template-columns: minmax(0, 1fr); }
.cols-2 > * { min-width: 0; }
@media (min-width: 60rem) {
  .cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-2--wide-left { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
}

.footer { padding-block: var(--s-5) var(--s-7); border-top: 1px solid var(--rule-strong); display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); justify-content: space-between; font-size: var(--fs-small); color: var(--ink-3); }
.footer p { max-width: none; }

/* ---------- 4. Cards, callouts, caveats ---------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: var(--s-5);
  display: grid; gap: var(--s-3); align-content: start;
}
.card > * { min-width: 0; }
.card p { color: var(--ink-2); }

/* Callout: a quiet inset for a method note or a definition. */
.callout {
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: var(--s-4) var(--s-5);
  display: grid; gap: var(--s-2);
}
.callout p { color: var(--ink-2); }
.callout .kicker { color: var(--accent-ink); }

/* Finding: the one sentence a reader should leave with. Inverse panel. */
.callout--finding {
  background: var(--band); border-color: transparent; color: var(--on-band);
  padding: var(--s-5) var(--s-5);
}
.callout--finding .kicker { color: var(--on-band-accent); }
.callout--finding p:not(.kicker):not(.small) { color: var(--on-band); font-family: var(--font-display); font-size: clamp(1.1875rem, 1rem + 0.8vw, 1.5rem); line-height: 1.35; max-width: 46ch; }
.callout--finding p.small { color: var(--on-band-2); line-height: 1.5; }

/* Limits and caveats: a first-class block, hatched like a drafting margin. */
.caveats {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: calc(var(--s-5) + 10px) var(--s-5) var(--s-5);
  display: grid; gap: var(--s-4);
  overflow: hidden;
}
.caveats::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 10px;
  background: repeating-linear-gradient(135deg, var(--ink-2) 0 1.5px, transparent 1.5px 7px);
  border-bottom: 1px solid var(--rule-strong);
  opacity: 0.55;
}
.caveats-head { display: grid; gap: var(--s-1); }
.caveats ul { list-style: none; padding: 0; display: grid; gap: var(--s-4) var(--s-6); grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); }
.caveats li { margin: 0; padding-left: 1.4rem; position: relative; color: var(--ink-2); font-size: 0.9375rem; line-height: 1.55; }
.caveats li::before { content: ""; position: absolute; left: 0; top: 0.5em; width: 0.7rem; height: 0.7rem; background: repeating-linear-gradient(135deg, var(--ink-2) 0 1.5px, transparent 1.5px 4px); border: 1px solid var(--ink-3); border-radius: 2px; }
.caveats li strong { color: var(--ink); display: block; }

/* Flag: a small inline label, e.g. "Placeholder data", "Preliminary". */
.flag {
  display: inline-flex; align-items: center; gap: 0.4em;
  font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--ink-2); background: var(--surface-2);
  border: 1px dashed var(--rule-strong); border-radius: 3px; padding: 0.15em 0.5em; white-space: nowrap;
}
.masthead .flag, .callout--finding .flag { color: var(--on-band); background: transparent; border-color: var(--on-band-2); }

/* Status pill: dot plus label, never colour alone. */
.status { display: inline-flex; align-items: center; gap: 0.5em; font-size: var(--fs-small); font-weight: 600; color: var(--ink); --dot: var(--status-neutral); }
.status::before { content: ""; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--dot); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot) 22%, transparent); flex: none; }
.status[data-state="live"] { --dot: var(--status-good); }
.status[data-state="in-progress"] { --dot: var(--accent); }
.status[data-state="review"] { --dot: var(--status-warn); }
.status[data-state="blocked"] { --dot: var(--status-critical); }
.status[data-state="planned"]::before { background: transparent; border: 1.5px solid var(--status-neutral); box-shadow: none; }

/* ---------- 5. Stat tiles ------------------------------------------------ */
/* A row of figures inside one plate, divided by hairlines (not five boxes). */
.stats {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  overflow: hidden;
  gap: 1px; background-color: var(--rule);
}
.stat { background: var(--surface); padding: var(--s-5); display: grid; gap: var(--s-1); align-content: start; min-width: 0; }
.stat-label { font-size: var(--fs-small); color: var(--ink-2); font-weight: 550; }
.stat-value { font-size: var(--fs-stat); line-height: 1.1; font-weight: 650; letter-spacing: -0.02em; color: var(--ink); }
.stat-value .unit { font-size: 0.5em; font-weight: 600; letter-spacing: 0; color: var(--ink-2); margin-left: 0.15em; }
.stat-note { font-size: var(--fs-small); color: var(--ink-3); line-height: 1.4; }
.stat-delta { font-size: var(--fs-small); font-weight: 600; color: var(--ink-2); display: inline-flex; align-items: center; gap: 0.35em; }
.stat-delta::before { content: ""; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; }
.stat-delta[data-dir="up"]::before { border-bottom: 6px solid currentColor; }
.stat-delta[data-dir="down"]::before { border-top: 6px solid currentColor; }
.stat-delta[data-tone="good"] { color: var(--status-good); }
.stat-delta[data-tone="bad"] { color: var(--status-critical); }
.stat-spark { margin-top: var(--s-2); height: 36px; }
@media (max-width: 30rem) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: var(--s-4); }
}

/* ---------- 6. Figures and captions -------------------------------------- */
body { counter-reset: figure; }
.figure {
  counter-increment: figure;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: var(--s-5);
  display: grid; gap: var(--s-4); align-content: start;
}
.figure > * { min-width: 0; }
@media (max-width: 30rem) { .figure, .card { padding: var(--s-4); } }
.figure--hero { box-shadow: var(--shadow-lift); border-color: transparent; padding: clamp(1rem, 0.5rem + 2vw, 2rem); }
:root[data-theme="dark"] .figure--hero { border-color: var(--rule); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .figure--hero { border-color: var(--rule); } }

.figure-head { display: grid; gap: var(--s-1); }
.figure-head .kicker { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); }
.figure-num::before { content: "Figure " counter(figure); }
.figure-sub { font-size: var(--fs-small); color: var(--ink-3); max-width: 80ch; }

/* Caption: says what the chart shows and what it does not. */
.caption {
  border-top: 1px solid var(--rule);
  padding-top: var(--s-3);
  display: grid; gap: var(--s-2) var(--s-5);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  font-size: var(--fs-small); line-height: 1.5; color: var(--ink-2);
}
.caption p { max-width: 62ch; }
.caption b { display: block; font-family: var(--font-mono); font-weight: 500; font-size: var(--fs-micro); letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 1px; }
.caption .source { grid-column: 1 / -1; color: var(--ink-3); max-width: none; }

/* ---------- 7. Tables ---------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-small); font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 0.55rem 0.8rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
.table thead th { background: var(--surface-2); font-family: var(--font-mono); font-weight: 500; font-size: var(--fs-micro); letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; border-bottom-color: var(--rule-strong); }
.table tbody tr:last-child > * { border-bottom: 0; }
.table tbody th { font-weight: 600; color: var(--ink); }
.table td.n, .table th.n { text-align: right; }
.table td:not(.n) { min-width: 11rem; }
.table tbody tr:hover > * { background: var(--surface-2); }

/* ---------- 8. Pipeline diagram ------------------------------------------ */
/* An ordered list of stages. Numbers are real sequence, so they are shown. */
.pipeline { list-style: none; padding: 0; margin: 0; counter-reset: stage; display: grid; gap: var(--s-5); grid-template-columns: repeat(auto-fit, minmax(min(100%, 11.5rem), 1fr)); }
.pipeline > li { counter-increment: stage; position: relative; margin: 0; max-width: none; background: var(--surface-2); border: 1px solid var(--rule); border-radius: var(--radius-sm); padding: var(--s-4); display: grid; gap: var(--s-1); align-content: start; }
.pipeline > li::before { content: counter(stage, decimal-leading-zero); font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: 0.09em; color: var(--accent-ink); }
.pipeline > li:not(:last-child)::after {
  content: ""; position: absolute; top: 50%; right: calc(var(--s-5) * -0.5 - 4px); width: 8px; height: 8px;
  border-top: 1.5px solid var(--ink-3); border-right: 1.5px solid var(--ink-3); transform: translateY(-50%) rotate(45deg);
}
.pipeline h4 { font-size: 0.9375rem; }
.pipeline p { font-size: var(--fs-small); color: var(--ink-2); line-height: 1.45; }
.pipeline .io { font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--ink-3); margin-top: var(--s-1); }
@media (max-width: 40rem) {
  .pipeline { grid-template-columns: minmax(0, 1fr); }
  .pipeline > li:not(:last-child)::after { top: auto; bottom: calc(var(--s-5) * -0.5 - 4px); right: auto; left: 1.25rem; transform: rotate(135deg); }
}

/* ---------- 9. Charts (used by charts.js) -------------------------------- */
.pc { display: grid; gap: var(--s-3); min-width: 0; }
.pc-plot { min-width: 0; position: relative; line-height: 0; }
.pc-plot svg { display: block; overflow: visible; max-width: none; }
.pc svg text { font-family: var(--font-body); fill: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.pc svg text.pc-cat { fill: var(--ink); font-size: 13px; }
.pc svg text.pc-value { fill: var(--ink); font-size: 12px; font-weight: 600; }
.pc svg text.pc-endlabel { fill: var(--ink); font-size: 12px; font-weight: 600; }
.pc svg text.pc-axis-title { fill: var(--ink-3); font-size: 12px; }
.pc svg text.pc-note { fill: var(--ink-2); font-size: 12px; }
.pc svg text.pc-halo { paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; fill: var(--ink); font-weight: 600; font-size: 12px; }
.pc-grid { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.pc-base { stroke: var(--chart-base); stroke-width: 1; shape-rendering: crispEdges; }
.pc-frame { fill: none; stroke: var(--chart-grid); stroke-width: 1; }
.pc-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.pc-dot { stroke: var(--surface); stroke-width: 2; }
.pc-whisker { stroke: var(--ink); stroke-width: 1.25; fill: none; }
.pc-cross { stroke: var(--ink-3); stroke-width: 1; shape-rendering: crispEdges; pointer-events: none; }
.pc-hover-band { fill: var(--ink); opacity: 0.05; pointer-events: none; }
.pc-annot { stroke: var(--ink-3); stroke-width: 1; shape-rendering: crispEdges; }
.pc-region { fill: none; stroke: var(--ink); stroke-width: 1.25; stroke-dasharray: 5 4; }
.pc-hit { fill: transparent; }

.pc-legend { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); font-size: var(--fs-small); color: var(--ink-2); line-height: 1.4; }
.pc-legend:empty { display: none; }
.pc-key { display: inline-flex; align-items: center; gap: 0.45em; }
.pc-swatch { flex: none; display: inline-block; width: 12px; height: 12px; border-radius: 2px; background: var(--c); }
.pc-swatch[data-kind="line"] { height: 2px; width: 16px; border-radius: 1px; }
.pc-swatch[data-kind="dash"] { height: 2px; width: 16px; border-radius: 0; background: repeating-linear-gradient(to right, var(--c) 0 5px, transparent 5px 8px); }
.pc-swatch[data-kind="dot"] { width: 9px; height: 9px; border-radius: 50%; }
.pc-swatch[data-kind="band"] { width: 16px; opacity: var(--o, 0.3); }
.pc-swatch[data-kind="whisker"] { width: 9px; height: 14px; border-radius: 0; border-block: 1.25px solid var(--ink); background: linear-gradient(var(--ink), var(--ink)) center / 1.25px 100% no-repeat; }
.pc-swatch[data-kind="interval"] { width: 18px; height: 3px; border-radius: 2px; opacity: 0.45; }
.pc-ramp { display: inline-flex; align-items: center; gap: 0.5em; }
.pc-ramp i { display: inline-flex; }
.pc-ramp i b { width: 18px; height: 10px; }
.pc-ramp i b:first-child { border-radius: 2px 0 0 2px; }
.pc-ramp i b:last-child { border-radius: 0 2px 2px 0; }

.pc-multiples { display: grid; gap: var(--s-5) var(--s-5); line-height: 1.4; }
.pc-panel { min-width: 0; display: grid; gap: var(--s-1); }
.pc-panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-2); font-size: var(--fs-small); border-bottom: 1px solid var(--rule); padding-bottom: 3px; }
.pc-panel-title { font-weight: 600; color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-panel-value { font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; flex: none; }

.pc-data { font-size: var(--fs-small); }
.pc-data > summary { cursor: pointer; color: var(--ink-3); width: fit-content; padding: 2px 0; list-style-position: inside; }
.pc-data > summary:hover { color: var(--ink); }
.pc-data[open] > summary { margin-bottom: var(--s-2); }
.pc-data .table-wrap { max-height: 22rem; overflow: auto; }

.pc-tip {
  position: fixed; z-index: 100; pointer-events: none; left: 0; top: 0;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--rule-strong); border-radius: 6px; box-shadow: var(--shadow-lift);
  padding: 8px 10px; font-size: 12px; line-height: 1.45; font-family: var(--font-body);
  max-width: min(280px, calc(100vw - 16px)); font-variant-numeric: tabular-nums;
}
.pc-tip-title { color: var(--ink-3); margin-bottom: 3px; font-weight: 550; }
.pc-tip-row { display: flex; align-items: center; gap: 8px; }
.pc-tip-row > i { flex: none; width: 12px; height: 2px; border-radius: 1px; background: var(--c); }
.pc-tip-row > i[data-kind="none"] { display: none; }
.pc-tip-row > span { color: var(--ink-2); flex: 1; }
.pc-tip-row > b { font-weight: 650; margin-left: 10px; white-space: nowrap; }

/* Sparkline (stat tiles) */
.pc-spark { display: block; width: 100%; height: 100%; overflow: visible; }
.pc-spark-line { fill: none; stroke: var(--series-mute); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.pc-spark-area { fill: var(--series-mute); opacity: 0.16; }
.pc-spark-end { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }

/* ---------- 10. Motion, print, forced colours ---------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media print {
  .topbar { position: static; }
  .topbar-nav, .pc-data { display: none; }
  .figure, .card, .caveats, .stats { break-inside: avoid; }
  body { background: #fff; }
}
@media (forced-colors: active) {
  .pc-swatch, .status::before { forced-color-adjust: none; }
}
