/* EV Delay – styles for static pages (privacy, terms, licences, 404).
   Sections 1–N: verbatim copy of web/evdelay-design/tokens.css (keep in sync); page styles at the end. */

/* =============================================================================
   EV Delay – design tokens + base components (vanilla CSS, no external requests)
   Spec: web/evdelay-design/DESIGN.md
   Colour method: data-viz reference instance (categorical slots 1–8, fixed order),
   validated with validate_palette (light on #fcfcfb, dark on #1a1a19).
   Theme: follows the OS; <html data-theme="light|dark"> overrides it both ways.
   ============================================================================= */

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

  /* planes & ink */
  --page: #f9f9f7;          /* page plane */
  --surface: #fcfcfb;       /* cards, chart surface (validator surface) */
  --surface-2: #f2f1ed;     /* inset fills: segmented control track, code */
  --ink: #0b0b0b;           /* primary text, hero numbers           19.2:1 */
  --ink-2: #52514e;         /* secondary text, labels                7.7:1 */
  --ink-3: #6b6a65;         /* hints, captions (AA small text)       5.3:1 */
  --muted: #898781;         /* axis ticks only (graphical text)      3.5:1 */
  --grid: #e1e0d9;          /* gridlines, row rules (hairline) */
  --axis: #c3c2b7;          /* baseline, table header rule */
  --ring: rgba(11, 11, 11, 0.10);        /* hairline card ring */
  --ring-strong: rgba(11, 11, 11, 0.28); /* chip / input ring on hover */
  --wash: rgba(11, 11, 11, 0.045);       /* hover wash */
  --shadow-pop: 0 8px 28px rgba(0, 0, 0, 0.12);
  --scroll-shade: rgba(11, 11, 11, 0.16);  /* edge shade of horizontally scrollable areas */
  --tap: 44px;                             /* minimum touch target */

  /* categorical – fixed order, never cycled (slot n = --s<n>) */
  --s1: #2a78d6;  /* blue    */
  --s2: #eb6834;  /* orange  */
  --s3: #1baf7a;  /* aqua    */
  --s4: #eda100;  /* yellow  */
  --s5: #e87ba4;  /* magenta */
  --s6: #008300;  /* green   */
  --s7: #6250d6;  /* violet  */
  --s8: #e34948;  /* red     */
  --s-other: #c3c2b7;       /* folded "Other" – always labelled */
  --mark-neutral: #6b6a65;  /* single non-model measure (e.g. data lag) */

  /* entity → slot (colour follows the entity, never its rank) */
  --m-ex60: var(--s1);
  --m-ix3:  var(--s2);
  --m-glc:  var(--s3);
  --c-pl: var(--s1); --c-nl: var(--s2); --c-es: var(--s3); --c-fi: var(--s4);
  --c-ee: var(--s5); --c-il: var(--s6); --c-de: var(--s7); --c-se: var(--s8);
  --v-1: var(--s1); --v-2: var(--s2); --v-3: var(--s3); /* versions in model order */

  /* delay scale 0–4 – ordinal plum ramp (OKLCH h≈328°, C 0.10), light → dark */
  --lvl-0: #d197ce; --lvl-1: #aa73a8; --lvl-2: #855083; --lvl-3: #612f60; --lvl-4: #3b1b3a;
  --lvl-0-on: #0b0b0b; --lvl-1-on: #0b0b0b; --lvl-2-on: #ffffff; --lvl-3-on: #ffffff; --lvl-4-on: #ffffff;

  /* status – fixed, never themed; always icon + label */
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --good-text: #006300;

  /* type */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-xs: 12px; --fs-s: 13px; --fs-m: 15px; --fs-l: 17px;
  --fs-h3: 15px; --fs-h2: 20px; --fs-h1: 28px;
  --fs-tile: 26px; --fs-hero: clamp(48px, 12vw, 76px);
  --lh: 1.5;

  /* space, radius, layout */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;
  --r-s: 6px; --r-m: 10px; --r-l: 14px; --r-pill: 999px;
  --wrap: 1120px; --gutter: 16px; --pad: 16px;
}
@media (min-width: 720px) { :root { --pad: 24px; --fs-h1: 32px; } }

/* ---------- 2. Tokens: dark (selected steps, not an automatic flip) ---------- */
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #242422;
    --ink: #f0efec; --ink-2: #c3c2b7; --ink-3: #a3a29b; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835;
    --ring: rgba(255, 255, 255, 0.10); --ring-strong: rgba(255, 255, 255, 0.30); --wash: rgba(255, 255, 255, 0.06);
    --shadow-pop: 0 8px 28px rgba(0, 0, 0, 0.5); --scroll-shade: rgba(255, 255, 255, 0.14);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --s-other: #5f5e59; --mark-neutral: #a3a29b;
    --lvl-0: #723f71; --lvl-1: #945e92; --lvl-2: #b77fb4; --lvl-3: #dba1d8; --lvl-4: #f5cbf3;
    --lvl-0-on: #ffffff; --lvl-1-on: #ffffff; --lvl-2-on: #0b0b0b; --lvl-3-on: #0b0b0b; --lvl-4-on: #0b0b0b;
    --good-text: #0ca30c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #242422;
  --ink: #f0efec; --ink-2: #c3c2b7; --ink-3: #a3a29b; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835;
  --ring: rgba(255, 255, 255, 0.10); --ring-strong: rgba(255, 255, 255, 0.30); --wash: rgba(255, 255, 255, 0.06);
  --shadow-pop: 0 8px 28px rgba(0, 0, 0, 0.5); --scroll-shade: rgba(255, 255, 255, 0.14);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --s-other: #5f5e59; --mark-neutral: #a3a29b;
  --lvl-0: #723f71; --lvl-1: #945e92; --lvl-2: #b77fb4; --lvl-3: #dba1d8; --lvl-4: #f5cbf3;
  --lvl-0-on: #ffffff; --lvl-1-on: #ffffff; --lvl-2-on: #0b0b0b; --lvl-3-on: #0b0b0b; --lvl-4-on: #0b0b0b;
  --good-text: #0ca30c;
}

/* ---------- 3. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 120px; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: var(--fs-m)/var(--lh) var(--font);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, dl, dd, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: underline; text-decoration-color: var(--axis); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap {
  max-width: var(--wrap); margin: 0 auto;
  padding-left: max(var(--pad), env(safe-area-inset-left));
  padding-right: max(var(--pad), env(safe-area-inset-right));
}
.ext::after { content: " ↗"; font-size: 0.85em; }

/* ---------- 4. Site header, tabs ---------- */
.site { background: var(--page); padding-top: env(safe-area-inset-top); }
.site-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); height: 56px; }
.brand { font-weight: 680; font-size: 17px; letter-spacing: -0.02em; text-decoration: none; white-space: nowrap; }
.brand span { color: var(--ink-3); font-weight: 500; }
.site-tools { display: flex; align-items: center; gap: var(--sp-2); }
.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: var(--r-m);
  border: 1px solid var(--ring); background: var(--surface); color: var(--ink-2); cursor: pointer; font: inherit;
}
.icon-btn:hover { color: var(--ink); border-color: var(--ring-strong); }
.icon-btn svg { width: 16px; height: 16px; }

.tabs {
  display: flex; gap: var(--sp-1); overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--grid);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs, .chips, .secnav { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
@media (min-width: 1100px) { .tabs, .secnav { -webkit-mask-image: none; mask-image: none; } }
.tab {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; flex: none; min-height: 46px;
  padding: 10px 10px 11px; margin-bottom: -1px; font-size: var(--fs-m); font-weight: 560;
  color: var(--ink-3); text-decoration: none; border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink); }
.tab[aria-current="page"], .tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tab .sep { width: 1px; height: 16px; background: var(--grid); margin-left: 6px; }
.tabs .spacer { flex: 1 0 8px; }

/* identity keys: a coloured mark beside ink text – never coloured text */
.key { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 3px; background: var(--k, var(--s1)); }
.key.dot { border-radius: 50%; width: 8px; height: 8px; }
.key.line { width: 14px; height: 2px; border-radius: 1px; }
.key.hollow { background: var(--surface); box-shadow: inset 0 0 0 2px var(--k, var(--s1)); border-radius: 50%; width: 10px; height: 10px; }

/* ---------- 5. Page head ---------- */
.page-head { padding-top: var(--sp-5); padding-bottom: var(--sp-4); }
.eyebrow { font-size: var(--fs-s); color: var(--ink-3); font-weight: 500; letter-spacing: 0.01em; }
.page-head h1 { font-size: var(--fs-h1); font-weight: 680; letter-spacing: -0.025em; line-height: 1.15; }
.lede { color: var(--ink-2); max-width: 640px; margin-top: var(--sp-2); }
.freshness { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: var(--sp-3); font-size: var(--fs-s); color: var(--ink-3); }
.freshness a { color: var(--ink-2); }

/* ---------- 6. Status (freshness) – icon + label, never colour alone ---------- */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-s); color: var(--ink-2); white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; }
.status.is-monthly::before { background: transparent; box-shadow: inset 0 0 0 2px var(--good); }
.status.is-late::before { background: var(--warning); border-radius: 1px; transform: rotate(45deg); width: 7px; height: 7px; }
.status.is-down::before { background: var(--critical); border-radius: 1px; }
.status.is-planned::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }

/* ---------- 7. Filter bar: country chips, segmented controls ---------- */
.filterbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--page) 90%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--grid);
  padding-top: env(safe-area-inset-top); /* PWA / landscape notch: stuck bar never slides under the status bar */
}
.filterbar .wrap { display: flex; align-items: center; gap: var(--sp-3); padding-top: 6px; padding-bottom: 6px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1 1 auto; min-width: 0; padding: 4px 28px 4px 1px; scroll-padding: 0 28px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  position: relative; display: inline-flex; align-items: center; gap: 7px; flex: none; height: 36px; padding: 0 12px 0 10px;
  border-radius: var(--r-pill); border: 1px solid var(--ring); background: var(--surface);
  font: inherit; font-size: var(--fs-s); font-weight: 560; color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.chip:hover { border-color: var(--ring-strong); }
.chip::after { content: ""; position: absolute; inset: -5px -3px; } /* 46 px touch target, visual 36 px */
.chip .n { color: var(--ink-3); font-weight: 500; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chip[aria-pressed="true"] .n { color: color-mix(in srgb, var(--surface) 72%, transparent); }
.chip[aria-disabled="true"] { color: var(--ink-3); background: transparent; border-style: dashed; cursor: not-allowed; }
.chip[aria-disabled="true"] .flag { filter: grayscale(1); opacity: 0.55; }
.chip.all { padding-left: 12px; }

.flag { width: 20px; height: 14px; flex: none; border-radius: 2px; box-shadow: 0 0 0 1px var(--ring); display: inline-block; vertical-align: -2px; overflow: hidden; }
.code { font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.04em; color: var(--ink-3); }

.seg { display: inline-flex; flex: none; background: var(--surface-2); border-radius: var(--r-m); padding: 3px; gap: 2px; }
.seg button, .seg a {
  font: inherit; font-size: var(--fs-s); font-weight: 520; color: var(--ink-2); background: none; border: 0;
  border-radius: 7px; padding: 4px 11px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg [aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--ring), 0 1px 2px rgba(0,0,0,.06); }
.seg [aria-disabled="true"] { color: var(--muted); cursor: not-allowed; }

.more-filters { flex: none; }
.more-filters > summary { list-style: none; }
.more-filters > summary::-webkit-details-marker { display: none; }

/* ---------- 8. Section nav (in-page) ---------- */
.secnav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; padding: var(--sp-2) 0 0; }
.secnav::-webkit-scrollbar { display: none; }
.secnav a { flex: none; display: inline-flex; align-items: center; min-height: var(--tap); font-size: var(--fs-s); color: var(--ink-3); text-decoration: none; padding: 0 10px; border-radius: var(--r-s); }
.secnav a:hover { background: var(--wash); color: var(--ink); }
.secnav a[aria-current="true"] { color: var(--ink); background: var(--wash); font-weight: 560; }

/* ---------- 9. Sections, cards, grid ---------- */
.section { padding: var(--sp-7) 0 0; }
.section-head { margin-bottom: var(--sp-4); }
.section-head h2 { font-size: var(--fs-h2); font-weight: 650; letter-spacing: -0.015em; line-height: 1.25; }
.section-head p { color: var(--ink-2); font-size: 14px; margin-top: 4px; max-width: 720px; }
.card { background: var(--surface); border: 1px solid var(--ring); border-radius: var(--r-l); padding: var(--sp-4); min-width: 0; }
@media (min-width: 720px) { .card { padding: 20px; } }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-2) var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.card-head h3 { font-size: var(--fs-h3); font-weight: 620; line-height: 1.35; }
.card-head .hint, .hint { font-size: var(--fs-s); color: var(--ink-3); }
.card-foot { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--grid); font-size: var(--fs-s); color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: space-between; }
.stack > * + * { margin-top: var(--gutter); }
.grid { display: grid; gap: var(--gutter); grid-template-columns: minmax(0, 1fr); align-items: start; }
/* charts go two-up only at >=1100 px (charts need ~480 px to keep 12 px text); text cards at >=720 px */
@media (min-width: 720px) { .grid.g2s { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) {
  .grid.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
  .span-2 { grid-column: span 2; }
}

/* ---------- 10. Hero number + stat tiles ---------- */
.hero { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-2) var(--sp-6); padding: var(--sp-2) 0 var(--sp-5); }
.hero-value { font-size: var(--fs-hero); font-weight: 680; letter-spacing: -0.04em; line-height: 0.95; }
.hero-cap { color: var(--ink-2); max-width: 420px; padding-bottom: 6px; }
.hero-cap b { color: var(--ink); font-weight: 600; }
.tiles { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1040px) { .tiles.t6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } .tiles.t4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--ring); border-radius: var(--r-m); padding: 12px 14px 13px; min-width: 0; }
.tile-label { font-size: var(--fs-s); color: var(--ink-2); line-height: 1.3; }
.tile-value { font-size: var(--fs-tile); font-weight: 640; letter-spacing: -0.02em; line-height: 1.15; margin-top: 6px; white-space: nowrap; }
.tile-value small { font-size: 15px; font-weight: 520; color: var(--ink-2); letter-spacing: 0; margin-left: 2px; }
.tile-meta { font-size: var(--fs-xs); color: var(--ink-3); margin-top: 3px; line-height: 1.35; }
.delta-up { color: var(--good-text); font-weight: 600; }
.tile.model { display: grid; gap: 2px; }
.tiles.t3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 479px) {
  .tiles.t3 { gap: 8px; }
  .tiles.t3 .tile { padding: 10px 10px 11px; }
  .tiles.t3 .tile-value { font-size: 22px; }
  .tiles.t3 .tile-label { font-size: var(--fs-xs); gap: 5px; }
}
.tile.model .tile-label { display: flex; align-items: center; gap: 7px; font-weight: 560; color: var(--ink); }

/* ---------- 11. Charts ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: var(--fs-s); color: var(--ink-2); margin-bottom: var(--sp-3); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
/* Mockup device only: each chart ships three pre-rendered widths (n 310 / m 678 / w 1030|486 viewBox units)
   so 12 px text stays 11–14 px. The production app renders once at the measured width (ResizeObserver). */
.chart > .v-m, .chart > .v-w { display: none; }
@media (min-width: 600px) { .chart > .v-n { display: none; } .chart > .v-m { display: block; } }
@media (min-width: 1100px) { .chart > .v-m { display: none; } .chart > .v-w { display: block; } }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: var(--wash); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .today { stroke: var(--axis); stroke-width: 1; }
.chart text { fill: var(--muted); font: 12px var(--font); font-variant-numeric: tabular-nums; }
.chart text.lbl { fill: var(--ink-2); }
.chart text.val { fill: var(--ink); font-weight: 600; }
.chart .mark:hover { filter: brightness(1.12); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: 0.1; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .dot.hollow { fill: var(--surface); stroke-width: 2; }
.chart .xhair { stroke: var(--axis); stroke-width: 1; }

/* horizontal bar list (HTML, responsive without re-render) */
.hbars { display: grid; gap: 8px; }
.hbar { display: grid; grid-template-columns: minmax(84px, 34%) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 14px; }
.hbar .n { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--ink-2); }
.hbar .n > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 14px; display: flex; gap: 2px; min-width: 0; }
.hbar .fill { height: 100%; min-width: 2px; background: var(--k, var(--s1)); }
.hbar .fill:last-child { border-radius: 0 4px 4px 0; }
.hbar .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.hbar .v small { font-weight: 450; color: var(--ink-3); margin-left: 6px; }
/* long labels on phones: label on its own line above the bar */
@media (max-width: 599px) {
  .hbars.lab-top { gap: 12px; }
  .hbars.lab-top .hbar { grid-template-columns: minmax(0, 1fr) auto; row-gap: 4px; }
  .hbars.lab-top .hbar .n { grid-column: 1 / -1; }
}

/* 100 % distribution strip (delay levels) */
.dist { display: flex; gap: 2px; height: 12px; border-radius: 4px; overflow: hidden; min-width: 80px; }
.dist i { display: block; height: 100%; }

/* table view twin of every chart */
.tableview { margin-top: var(--sp-3); }
.tableview > summary { cursor: pointer; font-size: var(--fs-s); color: var(--ink-3); list-style: none; display: inline-flex; gap: 6px; align-items: center; }
.tableview > summary::-webkit-details-marker { display: none; }
.tableview > summary::before { content: "▸"; font-size: 10px; }
.tableview[open] > summary::before { content: "▾"; }
.tableview > summary:hover { color: var(--ink); }
.tableview .tablewrap { margin-top: var(--sp-2); }

/* tooltip */
.tip {
  position: absolute; z-index: 30; pointer-events: none; min-width: 132px;
  background: var(--surface); border: 1px solid var(--ring); border-radius: var(--r-m);
  box-shadow: var(--shadow-pop); padding: 8px 10px; font-size: var(--fs-s);
}
.tip-demo { display: none; } /* mockup: static hover state, shown where it does not cover the end labels */
@media (min-width: 1100px) { .tip-demo { display: block; } }
.tip .h { color: var(--ink-3); font-size: var(--fs-xs); margin-bottom: 4px; }
.tip .r { display: flex; align-items: center; gap: 8px; line-height: 1.65; }
.tip .r b { font-variant-numeric: tabular-nums; min-width: 30px; font-weight: 650; }
.tip .r span:last-child { color: var(--ink-2); }

/* ---------- 12. Tables ---------- */
.tablewrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
  background:
    linear-gradient(to right, var(--surface) 30%, transparent) left center / 32px 100%,
    linear-gradient(to left, var(--surface) 30%, transparent) right center / 32px 100%,
    radial-gradient(farthest-side at 0 50%, var(--scroll-shade), transparent) left center / 12px 100%,
    radial-gradient(farthest-side at 100% 50%, var(--scroll-shade), transparent) right center / 12px 100%;
  background-repeat: no-repeat; background-attachment: local, local, scroll, scroll;
}
.scroll-hint { display: none; font-size: var(--fs-xs); color: var(--ink-3); margin: -4px 0 6px; }
@media (max-width: 719px) { .scroll-hint { display: block; } }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th {
  text-align: left; font-weight: 520; color: var(--ink-3); font-size: var(--fs-xs); letter-spacing: 0.02em;
  padding: 8px 10px; border-bottom: 1px solid var(--axis); white-space: nowrap; vertical-align: bottom;
}
.t td { padding: 9px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t th:first-child, .t td:first-child { padding-left: 0; }
.t th:last-child, .t td:last-child { padding-right: 0; }
.t .r, .t .num { text-align: right; font-variant-numeric: tabular-nums; }
.t td.wrap-ok { white-space: normal; min-width: 180px; }
.t tbody tr:hover { background: var(--wash); }
.t .sub { display: block; font-size: var(--fs-xs); color: var(--ink-3); }
.t .ent { display: inline-flex; align-items: center; gap: 8px; }
.t tfoot td { border-top: 1px solid var(--axis); border-bottom: 0; font-weight: 600; }
.t .hide-s, .t .hide-m { }
@media (max-width: 599px) { .t .hide-s { display: none; } .t th, .t td { padding-left: 7px; padding-right: 7px; } }
@media (max-width: 1099px) { .t .hide-m { display: none; } }
.t .inbar { display: flex; align-items: center; gap: 10px; }
.t .inbar b { min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; }
.t .inbar i { display: block; height: 8px; border-radius: 0 3px 3px 0; background: var(--k, var(--s1)); }
.t .inbar + .sub { padding-left: calc(3.2em + 10px); }
.yes { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink); vertical-align: 1px; }
.no { color: var(--muted); }

/* stacked rows on phones: <table class="t t-stack"> + data-label on each td */
@media (max-width: 640px) {
  .t-stack thead { display: none; }
  .t-stack, .t-stack tbody, .t-stack td { display: block; width: auto; }
  .t-stack tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 14px; padding: 11px 0; border-bottom: 1px solid var(--grid); }
  .t-stack tr::before { content: ""; flex-basis: 100%; height: 0; order: 3; } /* line break after lead + end */
  .t-stack tbody tr:hover { background: none; }
  .t-stack td, .t-stack td.r, .t-stack td.num { order: 4; border: 0; padding: 0; white-space: normal; text-align: left; font-size: var(--fs-s); color: var(--ink-2); }
  .t-stack td.lead { order: 1; flex: 1 1 auto; min-width: 0; font-size: 14px; color: var(--ink); font-weight: 560; }
  .t-stack td.end { order: 2; text-align: right; }
  .t-stack td.wrap-ok { flex-basis: 100%; min-width: 0; }
  .t-stack td[data-label]:not(.lead):not(.end)::before { content: attr(data-label) " "; color: var(--ink-3); }
  .t-stack td.nil, .t-stack td.hide-s { display: none; }
}

/* ---------- 13. Lists: recent registrations, news ---------- */
.rows > li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 10px 0; border-top: 1px solid var(--grid); font-size: 14px; align-items: baseline; }
.rows > li:first-child { border-top: 0; padding-top: 2px; }
.rows .main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rows .when { color: var(--ink-3); font-size: var(--fs-s); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.rows .meta { grid-column: 1 / -1; color: var(--ink-3); font-size: var(--fs-s); }
.news > li { padding: 12px 0; border-top: 1px solid var(--grid); }
.news > li:first-child { border-top: 0; padding-top: 2px; }
.news .when { font-size: var(--fs-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.news p { margin-top: 2px; font-size: 14px; }
.news .src { font-size: var(--fs-s); color: var(--ink-3); margin-top: 2px; }

/* ---------- 14. Delay-scale badge ---------- */
.lvl {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: var(--fs-s); color: var(--ink-2);
}
.lvl b {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px;
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--lvl-0); color: var(--lvl-0-on);
}
.lvl[data-l="1"] b { background: var(--lvl-1); color: var(--lvl-1-on); }
.lvl[data-l="2"] b { background: var(--lvl-2); color: var(--lvl-2-on); }
.lvl[data-l="3"] b { background: var(--lvl-3); color: var(--lvl-3-on); }
.lvl[data-l="4"] b { background: var(--lvl-4); color: var(--lvl-4-on); }
.lvl.lg b { min-width: 30px; height: 30px; font-size: 15px; border-radius: 8px; }
.lvl.lg { font-size: 14px; color: var(--ink); font-weight: 560; }
.scale-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; }

/* ---------- 15. Order card ("Your order") ---------- */
.order { border: 1.5px solid var(--ink); }
.order-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-3); flex-wrap: wrap; }
.order-head h3 { font-size: var(--fs-h3); font-weight: 620; }
.order-head .what { font-size: var(--fs-s); color: var(--ink-3); margin-top: 2px; }
.order-big { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 24px; margin: var(--sp-4) 0 var(--sp-3); }
.order-big .v { font-size: 44px; font-weight: 680; letter-spacing: -0.035em; line-height: 1; }
.order-big .v small { font-size: 18px; font-weight: 560; letter-spacing: 0; color: var(--ink-2); margin-left: 4px; }
.order-big .c { color: var(--ink-2); font-size: 14px; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; margin-top: var(--sp-4); }
@media (min-width: 720px) { .facts { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.facts dt { font-size: var(--fs-xs); color: var(--ink-3); }
.facts dd { font-size: 15px; font-weight: 600; margin-top: 1px; }
.facts dd small { display: block; font-size: var(--fs-xs); font-weight: 450; color: var(--ink-3); }
/* order timeline: ordered ─ promised ─ today ─ current term */
.otl { position: relative; height: 62px; margin: 8px 2px 0; }
.otl .track { position: absolute; left: 0; right: 0; top: 24px; height: 4px; border-radius: 2px; background: var(--grid); }
.otl .done { position: absolute; top: 24px; height: 4px; border-radius: 2px 0 0 2px; background: var(--ink-2); }
.otl .late { position: absolute; top: 24px; height: 4px; background: var(--lvl-3); }
.otl .pin { position: absolute; top: 18px; width: 2px; height: 16px; background: var(--ink); transform: translateX(-1px); }
.otl .pin.soft { background: var(--muted); }
.otl .lab { position: absolute; top: 38px; font-size: var(--fs-xs); line-height: 1.3; color: var(--ink-3); white-space: nowrap; transform: translateX(-50%); }
.otl .lab b { display: block; color: var(--ink); font-weight: 600; }
.otl .lab.up { top: 0; }
.otl .lab.l { transform: none; } .otl .lab.r { transform: translateX(-100%); text-align: right; }

/* ---------- 16. Source panel ---------- */
.src-card { display: grid; gap: var(--sp-3); align-content: start; }
.src-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.src-head .flag { width: 28px; height: 20px; border-radius: 3px; }
.src-head h3 { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.src-head .status { margin-left: auto; }
.src-name { font-size: 14px; font-weight: 560; }
.src-name .pub { display: block; font-weight: 400; color: var(--ink-3); font-size: var(--fs-s); }
.kv { display: grid; grid-template-columns: minmax(110px, 38%) minmax(0, 1fr); gap: 0; font-size: 14px; }
.kv dt, .kv dd { padding: 7px 0; border-top: 1px solid var(--grid); }
.kv dt { color: var(--ink-3); font-size: var(--fs-s); padding-right: 12px; }
.kv dd { font-variant-numeric: tabular-nums; }
.kv dd .sub { display: block; color: var(--ink-3); font-size: var(--fs-xs); }
.fresh { display: grid; gap: 4px; }
.fresh .bar { position: relative; height: 6px; border-radius: 3px; background: var(--grid); }
.fresh .bar i { position: absolute; right: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--mark-neutral); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: var(--fs-xs); padding: 2px 8px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.tag.off { background: transparent; box-shadow: inset 0 0 0 1px var(--grid); color: var(--muted); text-decoration: line-through; }
.note { font-size: var(--fs-s); color: var(--ink-2); line-height: 1.5; }
.grade { display: inline-flex; gap: 2px; vertical-align: middle; }
.grade i { width: 6px; height: 10px; border-radius: 1px; background: var(--grid); }
.grade i.on { background: var(--ink-2); }

/* ---------- 17. Empty state, buttons, inputs ---------- */
.empty { display: grid; justify-items: start; gap: 6px; padding: var(--sp-5) var(--sp-4); border-radius: var(--r-m); background: repeating-linear-gradient(0deg, transparent 0 100%); box-shadow: inset 0 0 0 1px var(--grid); }
.empty .t1 { font-weight: 600; font-size: 14px; }
.empty .t2 { color: var(--ink-3); font-size: var(--fs-s); max-width: 520px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: var(--r-m);
  border: 1px solid var(--ring); background: var(--surface); color: var(--ink); font: inherit; font-size: var(--fs-s); font-weight: 520;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--ring-strong); }
.btn.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.input {
  height: 34px; padding: 0 12px; border-radius: var(--r-m); border: 1px solid var(--ring); background: var(--surface);
  color: var(--ink); font: inherit; font-size: 14px; min-width: 0; flex: 1 1 220px; max-width: 360px;
}
.input::placeholder { color: var(--ink-3); }
.tools { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; margin-bottom: var(--sp-3); }

/* touch: every control >= 44 px on phones / coarse pointers */
@media (max-width: 719px), (pointer: coarse) {
  .btn, .icon-btn, .input { min-height: var(--tap); height: auto; }
  .icon-btn { width: var(--tap); }
  .seg { padding: 3px; }
  .seg button, .seg a { position: relative; min-height: 38px; padding: 0 12px; display: inline-flex; align-items: center; }
  .seg button::after, .seg a::after { content: ""; position: absolute; inset: -3px 0; } /* 44 px target incl. track padding */
  .tableview > summary { min-height: var(--tap); }
  .rows a, .news a { padding: 4px 0; }
}

/* ---------- 18. Footer ---------- */
.site-foot { margin-top: var(--sp-8); padding: var(--sp-6) 0 calc(var(--sp-7) + env(safe-area-inset-bottom)); border-top: 1px solid var(--grid); font-size: var(--fs-s); color: var(--ink-2); }
.site-foot .cols { display: grid; gap: var(--sp-5); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 860px) { .site-foot .cols { grid-template-columns: 2fr 1fr 1fr; } }
.site-foot h4 { font-size: 14px; color: var(--ink); margin-bottom: 6px; }
.site-foot p + p { margin-top: 8px; }
.site-foot li { padding: 2px 0; }

/* ---------- 19. Motion, forced colours, print ---------- */
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
@media (forced-colors: active) {
  .key, .hbar .fill, .dist i, .lvl b { forced-color-adjust: none; outline: 1px solid CanvasText; }
  .chip[aria-pressed="true"] { outline: 2px solid Highlight; }
}
@media print {
  .filterbar, .site-tools, .secnav, .tableview > summary { display: none; }
  .tableview .tablewrap { display: block; }
  .card { break-inside: avoid; }
}

/* =============================================================================
   Static pages (privacy.html, terms.html, licences.html, 404.html)
   ============================================================================= */
body.doc { background: var(--page); color: var(--ink); font-family: var(--font); font-size: var(--fs-m); line-height: var(--lh); margin: 0; }
.l-pl [data-lang="en"], .l-en [data-lang="pl"] { display: none !important; }
.doc .site { border-bottom: 1px solid var(--grid); }
.doc .seg a { display: inline-flex; align-items: center; min-height: 32px; padding: 0 10px; border-radius: var(--r-s); font-size: var(--fs-s); text-decoration: none; color: var(--ink-2); }
.doc .seg a[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--ring), 0 1px 2px rgba(0,0,0,.06); }
.prose { max-width: 760px; padding-top: var(--sp-5); padding-bottom: var(--sp-6); }
.prose h1 { font-size: var(--fs-h1); font-weight: 680; letter-spacing: -0.025em; line-height: 1.15; margin-bottom: var(--sp-2); }
.prose .meta { color: var(--ink-3); font-size: var(--fs-s); margin-bottom: var(--sp-5); }
.prose h2 { font-size: var(--fs-h2); font-weight: 640; letter-spacing: -0.015em; margin: var(--sp-6) 0 var(--sp-2); }
.prose h3 { font-size: var(--fs-l); font-weight: 620; margin: var(--sp-5) 0 var(--sp-2); }
.prose p, .prose ul, .prose ol, .prose dl, .prose .table-wrap, .prose pre { margin-bottom: var(--sp-3); }
.prose ul { list-style: disc; padding-left: 1.3em; }
.prose ol { list-style: decimal; padding-left: 1.4em; }
.prose li + li { margin-top: 4px; }
.prose a { overflow-wrap: anywhere; }
.prose .note { background: var(--surface); border-radius: var(--r-m); box-shadow: 0 0 0 1px var(--ring); padding: var(--sp-3) var(--sp-4); color: var(--ink-2); }
.prose .attr { font-size: var(--fs-s); color: var(--ink-2); background: var(--surface-2); border-radius: var(--r-s); padding: 6px 10px; display: block; }
.prose .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.prose table { border-collapse: collapse; width: 100%; font-size: var(--fs-s); }
.prose th, .prose td { text-align: left; vertical-align: top; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--grid); }
.prose th { color: var(--ink-2); font-weight: 600; border-bottom-color: var(--axis); white-space: nowrap; }
.prose pre { white-space: pre-wrap; font-family: var(--mono); font-size: var(--fs-xs); color: var(--ink-2); background: var(--surface-2); border-radius: var(--r-s); padding: var(--sp-3); }
.prose .toc { font-size: var(--fs-s); }
.doc .site-foot { margin-top: 0; }
.doc .site-foot .cols { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 860px) { .doc .site-foot .cols { grid-template-columns: 2fr 1fr; } }
.err-code { font-size: var(--fs-hero); font-weight: 680; letter-spacing: -0.04em; line-height: 1; color: var(--ink-3); }

/* narrow screens: long source names/URLs must never widen the page */
@media (max-width: 640px) {
  .doc table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .doc td, .doc th { min-width: 7em; }
  .doc a, .doc .attr { overflow-wrap: anywhere; word-break: break-word; }
}
