/*
 * Chartdesk: a calm, dense desk tool. One typeface, neutral grey, one blue.
 *
 * The blue does two jobs and nothing else: it is the data (bars, tiles) and the accent (links, the main button).
 * Score bars are grey on purpose, so a score never reads as data. Status colours are reserved for statuses and
 * always sit beside words. Dark mode swaps the same roles for dark values; the tile ramp runs the other way
 * there, so "more" is brighter on a dark page.
 */

:root {
  color-scheme: light dark;

  --page: #f1f1ee;
  --surface: #fcfcfb;
  --inset: #f5f5f2;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #66655f;
  --line: #e1e0d9;
  --rule: #c3c2b7;

  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-fill: #256abf;
  --on-accent: #ffffff;
  --accent-wash: #e6eefa;
  --focus: #2a78d6;

  --bar-grey: #898781;
  --track: #e6e5de;
  --meter-track: #cde2fb;

  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --danger-ink: #a62a2a;

  --risk-bg: #fff3d1;
  --risk-line: #e0b030;
  --risk-ink: #5c3b00;
  --check-bg: #0b0b0b;
  --check-ink: #ffffff;
  --nc-bg: #ebeae3;

  /* One hue, seven classes, light to dark. Ink on a tile flips where the fill gets dark. */
  --seq-0: #cde2fb;
  --seq-1: #9ec5f4;
  --seq-2: #6da7ec;
  --seq-3: #3987e5;
  --seq-4: #256abf;
  --seq-5: #184f95;
  --seq-6: #0d366b;
  --seq-ink-0: #0b0b0b;
  --seq-ink-1: #0b0b0b;
  --seq-ink-2: #0b0b0b;
  --seq-ink-3: #0b0b0b;
  --seq-ink-4: #ffffff;
  --seq-ink-5: #ffffff;
  --seq-ink-6: #ffffff;

  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #101010;
    --surface: #1a1a19;
    --inset: #212120;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --ink-3: #a3a198;
    --line: #2c2c2a;
    --rule: #444441;

    --accent: #3987e5;
    --accent-ink: #78aeee;
    --accent-fill: #3987e5;
    --on-accent: #0b0b0b;
    --accent-wash: #16263b;
    --focus: #6da7ec;

    --bar-grey: #898781;
    --track: #2c2c2a;
    --meter-track: #0d366b;

    --danger-ink: #f08a8a;

    --risk-bg: #3a2f10;
    --risk-line: #8a6a12;
    --risk-ink: #f5d98a;
    --check-bg: #f0efec;
    --check-ink: #0b0b0b;
    --nc-bg: #2a2a28;

    --seq-0: #0d366b;
    --seq-1: #184f95;
    --seq-2: #256abf;
    --seq-3: #3987e5;
    --seq-4: #6da7ec;
    --seq-5: #9ec5f4;
    --seq-6: #cde2fb;
    --seq-ink-0: #ffffff;
    --seq-ink-1: #ffffff;
    --seq-ink-2: #ffffff;
    --seq-ink-3: #0b0b0b;
    --seq-ink-4: #0b0b0b;
    --seq-ink-5: #0b0b0b;
    --seq-ink-6: #0b0b0b;
  }
}

/* ------------------------------------------------------------------ base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; }
a { color: var(--accent-ink); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
b, strong { font-weight: 600; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
main:focus { outline: none; }
[hidden] { display: none !important; }
.muted { color: var(--ink-3); }

#app {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 24px 64px;
  transition: opacity 0.12s;
}
#app.busy { opacity: 0.55; }
.loading, .noscript { padding: 48px 0; color: var(--ink-3); }

h1 { font-size: 24px; font-weight: 650; letter-spacing: -0.015em; line-height: 1.2; }
h2 { font-size: 16px; font-weight: 650; letter-spacing: -0.005em; line-height: 1.3; }

.page-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.page-sub { color: var(--ink-3); font-size: 14px; }

/* ------------------------------------------------------------------ top bar */

.topbar { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; gap: 28px; min-height: 52px; }
.brand { font-size: 18px; font-weight: 700; letter-spacing: -0.025em; color: var(--ink); text-decoration: none; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 52px;
  padding: 0 12px;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); font-weight: 650; border-bottom-color: var(--accent); }

/* ------------------------------------------------------------------ buttons and fields */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font: 500 13.5px/1 var(--font);
  cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--inset); border-color: var(--bar-grey); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-fill); border-color: var(--accent-fill); filter: brightness(1.1); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-quiet:hover:not(:disabled) { background: var(--inset); border-color: transparent; color: var(--ink); }

input[type="text"], input[type="search"], input[type="url"], input[type="number"], input[type="password"], select {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font: 400 14px/1.3 var(--font);
}
select { padding-right: 6px; }
input::placeholder { color: var(--ink-3); opacity: 0.8; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent-fill); flex: none; }

.field { display: grid; gap: 4px; align-content: start; }
.field > label, .field-label { font-size: 12.5px; font-weight: 500; color: var(--ink-3); }
.field-hint { font-size: 12.5px; color: var(--ink-3); }
.field-error { font-size: 13px; color: var(--danger-ink); font-weight: 500; }
.field-error:empty { display: none; }
.form-note { font-size: 13.5px; color: var(--ink-2); }
.form-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 4px; }
.settings-form > .form-actions { margin: 6px 0 30px; }

/* ------------------------------------------------------------------ feed filters */

.filters { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; margin: 0 0 18px; padding: 12px 14px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
/* Widths belong to the fields by name, so adding one changes nothing for the others. The topic field takes what is left. */
.filters .field { flex: 0 0 auto; }
.filters .field-date { width: auto; }
.filters .field-status { width: 176px; }
.filters .field-source { width: 112px; }
.filters .field-topic { flex: 1 1 120px; min-width: 120px; }
.filters .field-geo { width: 104px; }
.filters .field-chart { width: 112px; }
.filters select { text-overflow: ellipsis; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; background: var(--surface); }
.seg button {
  min-height: 34px;
  padding: 0 9px;
  border: 0;
  border-right: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-2);
  font: 500 13.5px/1 var(--font);
  cursor: pointer;
}
.seg button:last-child { border-right: 0; }
/* The group clips its corners, so the focus ring goes inside the button where it cannot be cut off. */
.seg button:focus-visible { outline-offset: -3px; }
.seg button[aria-pressed="true"] { background: var(--accent-wash); color: var(--accent-ink); font-weight: 700; box-shadow: inset 0 -2px 0 var(--accent); }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; font-size: 14px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }

.feed-results { display: grid; gap: 12px; transition: opacity 0.12s; }
.feed-results.busy { opacity: 0.55; }
.skipped-note { margin-top: 12px; color: var(--ink-3); font-size: 13.5px; }
.skipped-note:empty { display: none; }

.empty { padding: 40px 20px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; display: grid; gap: 8px; justify-items: center; }
.empty-title { font-weight: 650; font-size: 16px; }
.empty-hint { color: var(--ink-3); max-width: 52ch; }

/* ------------------------------------------------------------------ feed card */

.card {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) 332px;
  grid-template-areas: "score head side" "score foot side";
  column-gap: 20px;
  padding: 18px 20px 16px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.card-score { grid-area: score; display: grid; align-content: start; justify-items: center; padding-right: 14px; border-right: 1px solid var(--line); }
.score-num { font-size: 34px; font-weight: 650; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.score-of { margin-top: 5px; font-size: 11.5px; color: var(--ink-3); }
.card-head { grid-area: head; align-self: start; min-width: 0; display: grid; gap: 8px; }
.card-title { font-size: 19px; font-weight: 650; line-height: 1.28; letter-spacing: -0.01em; }
.card-title a { color: var(--ink); text-decoration: none; }
.card-title a:hover { color: var(--accent-ink); text-decoration: underline; }
.card-dek { color: var(--ink-2); }
.card-why { color: var(--ink-2); font-size: 14px; padding-left: 10px; border-left: 2px solid var(--rule); }
.card-why b { color: var(--ink); }
.card-side { grid-area: side; align-self: start; min-width: 0; }
.card-foot { grid-area: foot; align-self: end; min-width: 0; display: grid; gap: 8px; padding-top: 14px; }
.card-meta { font-size: 13px; color: var(--ink-3); }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.card-actions:empty { display: none; }
/* A text-only button first in the row lines its words up with the text above instead of its own padding. */
.card-actions > .btn-quiet:first-child { margin-left: -13px; }
.card-note { font-size: 13.5px; color: var(--ink-2); font-weight: 500; }
.card-note:empty { display: none; }
.card-gone { padding: 12px 16px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink-3); font-size: 14px; }
.card-gone b { color: var(--ink-2); }

.dismiss-form { display: grid; grid-template-columns: auto minmax(120px, 220px) auto auto; align-items: center; gap: 8px; }
.dismiss-form label { font-size: 13px; color: var(--ink-2); }
.dismiss-form .field-error { grid-column: 1 / -1; }

/* ------------------------------------------------------------------ badges */

.badge-block { min-width: 0; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badges:empty { display: none; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 3px;
  font: 600 12.5px/1.2 var(--font);
  text-decoration: none;
  max-width: 100%;
}
.badge-check { background: var(--check-bg); color: var(--check-ink); }
.badge-risk { background: var(--risk-bg); border-color: var(--risk-line); color: var(--risk-ink); cursor: pointer; }
.badge-risk[aria-expanded="true"] { box-shadow: inset 0 0 0 1px var(--risk-line); }
.badge-vc { background: var(--surface); border-color: var(--rule); color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
.badge-nc { background: var(--nc-bg); border-color: var(--line); color: var(--ink-2); }
.badge-state { background: var(--inset); border-color: var(--rule); color: var(--ink-2); }
.state-shortlisted { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-ink); }
.state-picked { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); }
.state-blocked { border-color: var(--critical); color: var(--danger-ink); }
.risk-list { margin: 8px 0 0; padding: 8px 12px 8px 28px; background: var(--risk-bg); border-left: 3px solid var(--risk-line); color: var(--risk-ink); font-size: 13.5px; border-radius: 0 3px 3px 0; }
.risk-list li + li { margin-top: 3px; }

/* ------------------------------------------------------------------ previews */

.preview { padding: 10px 14px 8px; background: var(--inset); border-radius: 6px; }
.preview-none { color: var(--ink-3); font-size: 13.5px; padding: 8px 0; }
.pv-svg { display: block; width: 100%; height: auto; overflow: visible; }
.pv-label { font-size: 12px; fill: var(--ink-2); }
.pv-value { font-size: 12px; font-weight: 600; fill: var(--ink); font-variant-numeric: tabular-nums; }
.pv-bar { fill: var(--accent); }
.pv-axis { stroke: var(--rule); stroke-width: 1; }

.tile rect { fill: var(--seq-3); }
.tile text { font-size: 9.5px; font-weight: 600; pointer-events: none; }
.tile.s0 rect { fill: var(--seq-0); } .tile.s0 text { fill: var(--seq-ink-0); }
.tile.s1 rect { fill: var(--seq-1); } .tile.s1 text { fill: var(--seq-ink-1); }
.tile.s2 rect { fill: var(--seq-2); } .tile.s2 text { fill: var(--seq-ink-2); }
.tile.s3 rect { fill: var(--seq-3); } .tile.s3 text { fill: var(--seq-ink-3); }
.tile.s4 rect { fill: var(--seq-4); } .tile.s4 text { fill: var(--seq-ink-4); }
.tile.s5 rect { fill: var(--seq-5); } .tile.s5 text { fill: var(--seq-ink-5); }
.tile.s6 rect { fill: var(--seq-6); } .tile.s6 text { fill: var(--seq-ink-6); }
.tile.none rect { fill: none; stroke: var(--rule); stroke-width: 1; }
.tile.none text { fill: var(--ink-3); font-weight: 400; }
.tile-legend { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.tile-legend .lg-end { white-space: nowrap; }
.lg-ramp { display: flex; flex: 1; min-width: 40px; height: 10px; }
.lg-ramp i { flex: 1; }
.lg-ramp .s0 { background: var(--seq-0); } .lg-ramp .s1 { background: var(--seq-1); } .lg-ramp .s2 { background: var(--seq-2); }
.lg-ramp .s3 { background: var(--seq-3); } .lg-ramp .s4 { background: var(--seq-4); } .lg-ramp .s5 { background: var(--seq-5); }
.lg-ramp .s6 { background: var(--seq-6); }
.tile-note { margin-top: 4px; font-size: 12px; color: var(--ink-3); }
.tile-top { display: flex; align-items: baseline; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--ink-2); }
.tile-top-label { color: var(--ink-3); }
.tile-top ol { list-style: none; display: flex; flex-wrap: wrap; gap: 2px 14px; }
.tile-top li { white-space: nowrap; font-variant-numeric: tabular-nums; }
.tile-top b { color: var(--ink); font-weight: 650; }

/* ------------------------------------------------------------------ sub-scores */

.subs { list-style: none; margin: 10px 0 0; display: grid; gap: 3px; }
.sub { display: grid; grid-template-columns: 148px minmax(0, 1fr); align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); }
.sub-label { white-space: nowrap; }
.sub-label b { color: var(--ink); font-variant-numeric: tabular-nums; }
.sub-track { display: block; height: 6px; background: var(--track); }
.sub-fill { display: block; height: 100%; background: var(--bar-grey); border-radius: 0 3px 3px 0; }
.subs-long { gap: 9px; }
.subs-long .sub-reason { grid-column: 1 / -1; font-size: 12.5px; color: var(--ink-3); line-height: 1.4; }

/* ------------------------------------------------------------------ hidden releases */

.hidden-slot { margin-top: 28px; }
.hidden-releases { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.hidden-releases > summary { padding: 12px 16px; font-weight: 650; cursor: pointer; }
.hidden-intro { padding: 0 16px 10px; color: var(--ink-3); font-size: 13.5px; }
.hidden-group-title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; padding: 12px 16px 10px; border-top: 1px solid var(--line); font-size: 13px; font-weight: 500; color: var(--ink-3); }
.hidden-list { list-style: none; border-top: 1px solid var(--line); }
.hidden-item { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4px 24px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.hidden-item:last-child { border-bottom: 0; }
/* Titles and reasons are third-party or generated text: a long link or id must wrap, never push the page sideways. */
.hidden-title { font-weight: 550; overflow-wrap: anywhere; }
.hidden-meta { font-size: 13px; color: var(--ink-3); }
.hidden-reason { font-size: 13.5px; color: var(--ink-2); overflow-wrap: anywhere; }
.tag { display: inline-block; padding: 1px 7px; border: 1px solid var(--rule); border-radius: 3px; background: var(--inset); color: var(--ink-2); font-size: 12px; font-weight: 600; }
.tag-failed { border-color: var(--critical); color: var(--danger-ink); }

/* ------------------------------------------------------------------ story */

.story-head { display: grid; gap: 10px; max-width: 880px; margin-bottom: 24px; }
.back { font-size: 13.5px; width: fit-content; }
.story-title { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.story-dek { font-size: 17px; color: var(--ink-2); }
.story-meta { color: var(--ink-3); font-size: 14px; }
.blocked-note { padding: 10px 14px; border-left: 3px solid var(--critical); background: var(--surface); }

.story-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
.story-main { display: grid; gap: 28px; min-width: 0; }
.block h2 { margin-bottom: 10px; }
.plain-list { list-style: none; display: grid; gap: 8px; }
.plain-list li { padding-left: 14px; position: relative; }
.plain-list li::before { content: ""; position: absolute; left: 0; top: 0.7em; width: 6px; height: 2px; background: var(--bar-grey); }
.story-aside { display: grid; gap: 14px; min-width: 0; }
.panel { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; display: grid; gap: 8px; }
.panel h2 { margin-bottom: 0; }
.panel-score { display: flex; align-items: baseline; gap: 8px; }
.panel-score .score-num { font-size: 44px; }
.release-title { font-weight: 600; }
.release-meta, .release-summary { font-size: 13.5px; color: var(--ink-2); }
.sibling-list { list-style: none; display: grid; gap: 10px; font-size: 14px; }
.sibling-list li { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 8px; align-items: baseline; }
.sibling-score { font-weight: 650; font-size: 16px; color: var(--ink); font-variant-numeric: tabular-nums; }

.caveats { padding: 14px 16px; background: var(--inset); border-left: 3px solid var(--rule); border-radius: 0 6px 6px 0; color: var(--ink-2); font-size: 14px; }
.caveats h2 { font-size: 14px; color: var(--ink-2); margin-bottom: 4px; }
.caveats-note { font-size: 12.5px; color: var(--ink-3); margin-bottom: 8px; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; max-width: 100%; }
table { border-collapse: collapse; width: 100%; }
table.data { font-size: 14px; }
table.data th, table.data td { padding: 8px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data tr:last-child > * { border-bottom: 0; }
table.data thead th { background: var(--inset); white-space: nowrap; vertical-align: bottom; }
table.data tbody th { font-weight: 550; position: sticky; left: 0; background: var(--surface); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.sort-btn { display: grid; grid-template-columns: auto auto; grid-template-areas: "name glyph" "unit unit"; justify-content: start; column-gap: 6px; align-items: baseline; padding: 0; border: 0; background: none; color: var(--ink); font: 600 13.5px/1.25 var(--font); cursor: pointer; text-align: inherit; }
.num .sort-btn { justify-content: end; margin-left: auto; }
.sort-btn .col-name { grid-area: name; }
.sort-btn .col-unit { grid-area: unit; text-align: inherit; }
.sort-btn .sort-glyph { grid-area: glyph; }
.num .sort-btn .col-unit { justify-self: end; }
.col-unit { font-weight: 400; font-size: 12px; color: var(--ink-3); }
.sort-glyph { color: var(--ink-3); font-weight: 400; font-size: 12px; }
th[aria-sort="ascending"] .sort-glyph, th[aria-sort="descending"] .sort-glyph { color: var(--accent-ink); font-weight: 700; }
.no-value { color: var(--ink-3); }

.table-infos { list-style: none; display: grid; gap: 12px; margin-top: 14px; }
.table-info { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; display: grid; gap: 6px; }
.table-title { font-weight: 600; }
.badge-table { background: var(--inset); border-color: var(--rule); color: var(--ink-2); }
.badge-table.table-check3 { background: var(--check-bg); color: var(--check-ink); }
.badge-table.table-blocked { border-color: var(--critical); color: var(--danger-ink); }
.badge-level { background: var(--surface); border-color: var(--rule); color: var(--ink-2); }
.table-level, .table-fetched { font-size: 13px; color: var(--ink-3); }
.table-links { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 14px; }
.spot { font-size: 13.5px; padding: 8px 12px; background: var(--risk-bg); border-left: 3px solid var(--risk-line); color: var(--risk-ink); border-radius: 0 3px 3px 0; }
.spot ul { margin: 4px 0 0 18px; }

/* ------------------------------------------------------------------ calendar */

.week { margin-bottom: 22px; }
.week h2 { padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid var(--rule); }
.week-now { font-weight: 400; color: var(--ink-3); }
.week > p { padding: 8px 0; }
.events { list-style: none; }
.event { display: grid; grid-template-columns: 112px minmax(0, 1fr) minmax(0, 260px); gap: 4px 16px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.event-date { font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.event-title { font-weight: 550; }
.event-source { font-size: 13px; color: var(--ink-3); text-align: right; }
.held { margin-top: 36px; }

/* ------------------------------------------------------------------ sources */

table.sources { font-size: 13px; table-layout: auto; }
table.sources th, table.sources td { padding: 10px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.sources thead th { background: var(--inset); font-weight: 600; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
table.sources tbody th { font-weight: 600; min-width: 170px; }
table.sources tr:last-child > * { border-bottom: 0; }
table.sources tr.off > :not(.row-actions) { color: var(--ink-3); }
table.sources td[data-label="Group"] { white-space: nowrap; }
.src-name { display: block; font-size: 13.5px; }
.src-link { font-size: 12.5px; font-weight: 400; }
.status { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; white-space: nowrap; }
.status i { font-style: normal; display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; font-size: 11px; font-weight: 700; color: #0b0b0b; background: var(--bar-grey); }
.status-good i { background: var(--good); }
.status-warning i { background: var(--warning); }
.status-serious i { background: var(--serious); }
.status-critical i { background: var(--critical); color: #fff; }
.status-detail { font-size: 12.5px; color: var(--ink-3); font-weight: 400; margin-top: 3px; max-width: 220px; }
.tier { display: inline-block; font-weight: 600; font-size: 12.5px; padding: 1px 7px; border: 1px solid var(--rule); border-radius: 3px; background: var(--inset); }
.tier-note { margin-top: 5px; font-size: 12.5px; color: var(--ink-3); max-width: 300px; }
.row-actions { min-width: 150px; }
.row-box { display: grid; gap: 6px; justify-items: start; }
.row-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.row-controls .btn { min-height: 30px; }
.switch { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; cursor: pointer; }
.row-note { margin-top: 6px; font-size: 12.5px; color: var(--ink-3); white-space: normal; max-width: 170px; }
.row-note:empty { display: none; }
.tag { margin-right: 8px; }

.add-source { margin-top: 36px; max-width: 640px; }
.add-form { display: grid; gap: 14px; margin-top: 12px; }

/* ------------------------------------------------------------------ settings */

.settings-form { display: grid; gap: 0; max-width: 760px; }
.settings-block { padding: 18px 0 22px; border-top: 1px solid var(--rule); display: grid; gap: 14px; max-width: 760px; }
.settings-block:first-child { border-top: 0; padding-top: 0; }
.grid-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.spend { display: grid; gap: 6px; max-width: 420px; }
.meter { height: 8px; background: var(--meter-track); border-radius: 0 4px 4px 0; overflow: hidden; }
.meter-fill { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.spend-warn { font-size: 13.5px; font-weight: 600; color: var(--danger-ink); }
.radios { display: grid; gap: 10px; }
.radio { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.radio input { margin-top: 3px; }
.radio label { display: grid; gap: 3px; cursor: pointer; font-size: 14px; color: var(--ink-2); }
.radio label b { color: var(--ink); font-size: 15px; }
.facts { display: grid; grid-template-columns: minmax(170px, 1fr) minmax(0, auto); gap: 0; max-width: 560px; font-size: 14px; }
.facts dt, .facts dd { padding: 7px 0; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--ink-2); padding-right: 16px; }
.facts dd { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.facts dd.fact-note { font-weight: 400; text-align: left; padding-left: 16px; }
.cal-progress { display: grid; gap: 8px; max-width: 560px; margin-top: 14px; }
.cal-progress .meter { max-width: 420px; }
.facts-stages { margin-top: 2px; font-size: 13.5px; }
.cal-retry { display: grid; gap: 4px; max-width: 560px; margin-top: 14px; }
.cal-retry .form-actions { margin-top: 0; }
.calibration-note { padding: 10px 14px; background: var(--risk-bg); border-left: 3px solid var(--risk-line); color: var(--risk-ink); font-size: 14px; max-width: 560px; }

/* ------------------------------------------------------------------ login */

.login { display: grid; gap: 10px; max-width: 340px; margin: 12vh auto 0; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.login h1 { font-size: 26px; }
.login label { margin-top: 8px; font-size: 13px; font-weight: 500; color: var(--ink-3); }
.login .btn { margin-top: 6px; min-height: 38px; }

/* ------------------------------------------------------------------ narrow screens */

@media (max-width: 1020px) {
  .card { grid-template-columns: 52px minmax(0, 1fr); grid-template-areas: "score head" "side side" "foot foot"; column-gap: 14px; padding: 16px 16px 14px 14px; }
  .card-score { padding-right: 10px; }
  .score-num { font-size: 30px; }
  .card-side { margin-top: 14px; max-width: 460px; }
  .card-foot { padding-top: 12px; }
  .story-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  body { font-size: 15px; }
  #app { padding: 16px 16px 56px; }
  .topbar-inner { flex-wrap: wrap; padding: 0 16px; gap: 0 12px; }
  .brand { order: 1; padding: 12px 0 0; flex: 1; }
  .logout { order: 2; margin-top: 8px; }
  .nav { order: 3; flex-basis: 100%; margin: 0 -10px; }
  .nav a { min-height: 44px; padding: 0 10px; }
  h1 { font-size: 22px; }
  .story-title { font-size: 25px; }
  .btn, .seg button, input[type="text"], input[type="search"], input[type="url"], input[type="number"], input[type="password"], select { min-height: 42px; }
  .check { min-height: 42px; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; }
  .filters > *, .filters .field-status, .filters .field-source, .filters .field-geo, .filters .field-chart, .filters .field-topic { width: auto; min-width: 0; }
  .filters .field-date { grid-column: 1 / -1; order: 1; }
  .filters .field-topic { grid-column: 1 / -1; order: 2; }
  .filters .field-status { grid-column: 1 / -1; order: 3; }
  .filters .field-source { order: 4; }
  .filters .field-geo { order: 5; }
  .filters .field-chart { order: 6; }
  .filters .check { order: 7; align-self: end; }
  .grp-word { display: none; }
  .facts { grid-template-columns: minmax(0, 1fr); }
  .facts dt { padding: 9px 0 0; border-bottom: 0; font-size: 13.5px; }
  .facts dd, .facts dd.fact-note { padding: 1px 0 9px; text-align: left; }
  .seg { display: flex; }
  .seg button { flex: 1 1 0; min-width: 0; padding: 0 2px; font-size: 13px; white-space: nowrap; }
  .card-title { font-size: 18px; }
  .card-actions .btn { flex: 1 1 auto; }
  .dismiss-form { grid-template-columns: 1fr 1fr; }
  .dismiss-form label, .dismiss-form input { grid-column: 1 / -1; }
  .hidden-item { grid-template-columns: minmax(0, 1fr); }
  .event { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .event-source { text-align: left; }
  .panel-score .score-num { font-size: 38px; }
  .sub { grid-template-columns: 138px minmax(0, 1fr); }

  /* The sources table becomes a stack of labelled rows. */
  .sources-wrap { background: none; border: 0; overflow: visible; }
  table.sources, table.sources tbody { display: block; }
  table.sources thead { display: none; }
  table.sources tr { display: block; margin-bottom: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 4px 0; }
  table.sources th, table.sources td { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; border-bottom: 0; padding: 6px 14px; }
  table.sources tbody th { min-width: 0; }
  table.sources th::before, table.sources td::before { content: attr(data-label); font-size: 12.5px; font-weight: 500; color: var(--ink-3); }
  .status-detail, .tier-note, .row-note { max-width: none; }
  .row-actions { min-width: 0; }
  .login { margin-top: 6vh; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

@media print {
  .topbar, .card-actions, .filters { display: none; }
}
