:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  /* Status numbers as text (platform pill): dark enough for 4.5:1 on the light surface. */
  --good-ink: #087808; --warning-ink: #8a5a00; --critical-ink: #d03b3b;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  /* Transelectrica: pink, validated with blue and orange on every pair (src/sources.ts). */
  --series-tel: #c2389e;
  --seq-low: #cde2fb;
  --seq-high: #0d366b;
  /* Second sequential ramp (orange), for the Compare with direction on the price heatmaps: the blue ramp's lightness
     at both ends and in the middle, in the hue of --series-2, so one price is equally dark in blue and orange (lab
     lightness within 0.3 at every price). Blue runs --seq-low -> --series-1 -> --seq-high. The light middle is a
     deeper orange than --series-2 (L 49.6 like --series-1, --series-2 is 60.4); in dark mode --series-2 already matches. */
  --seq2-low: #f9d8cb;
  --seq2-mid: #c94b19;
  --seq2-high: #5a250f;
  /* Price row of Who won each hour: green, apart from the blue and orange direction colours. Text on the dark end. */
  --price-low: #d6f1dc;
  --price-high: #146c2e;
  /* Where these companies also win: share of hours won, green, apart from the blue that means Direction and JAO. */
  --share-low: #dcf2e2;
  --share-high: #0f5a27;
  --price-text-high: #ffffff;
  /* Timetable slots: one light fill per time slot, apart from the platform colours (blue, orange) on the border. */
  --slot-1: #7fcf7a; --slot-2: #b49be6; --slot-3: #f2d04a; --slot-4: #5fcdc4; --slot-5: #9fb3c8; --slot-6: #c3d15e; --slot-7: #bdbdbd; --slot-8: #d9a877;
  --neutral-mark: #c3c2b7;
  /* Companies on the capacity chart (Competition): 5 hues, none of them blue or orange, the Direction and Compare with
   colours of every other chart, so a company never reads as a direction. Then grey for "Other". Checked with the
   dataviz validator (all pairs): light and dark pass, pink vs aqua 6.1 / 6.6 for deutan, legal because every company
   is also named (legend, hover, table). */
  /* HHI bands (low, moderate, high): the status hues, drawn faint behind the data. */
  --band-low: #0ca30c; --band-mid: #fab219; --band-high: #d03b3b;
  --co-1: #1baf7a; --co-2: #eda100; --co-3: #e87ba4; --co-4: #008300; --co-5: #6250d6; --cat-other: #a3a29a;
  --accent-wash: rgba(42, 120, 214, 0.10);
  /* Highest-price marker: magenta, its own colour (red is the failed status). Validated against --series-1 for colour-blind separation. */
  --max-mark: #b0479e;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --good-ink: #0ca30c; --warning-ink: #fab219; --critical-ink: #f07070;
    --series-1: #3987e5;
    --max-mark: #d65db1;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-tel: #d659b3;
    --seq-low: #1c2a3d;
    --seq-high: #86b6ef;
    --seq2-low: #39231a;
    --seq2-mid: #d95926;
    --seq2-high: #e4a184;
    --price-low: #16301f;
    --price-high: #6fd58a;
    --share-low: #142a1b;
    --share-high: #7ad897;
    --price-text-high: #0b1f12;
    --slot-1: #2f7a37; --slot-2: #5d47a0; --slot-3: #6e5c10; --slot-4: #1f7a72; --slot-5: #3d5266; --slot-6: #677222; --slot-7: #555555; --slot-8: #7c5130;
    --neutral-mark: #52514e;
    --co-1: #12a8ac; --co-2: #c98500; --co-3: #d55181; --co-4: #008300; --co-5: #9085e9; --cat-other: #6b6a65;
    --accent-wash: rgba(57, 135, 229, 0.16);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --good-ink: #0ca30c; --warning-ink: #fab219; --critical-ink: #f07070;
  --series-1: #3987e5;
  --max-mark: #d65db1;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-tel: #d659b3;
  --seq-low: #1c2a3d;
  --seq-high: #86b6ef;
  --seq2-low: #39231a;
  --seq2-mid: #d95926;
  --seq2-high: #e4a184;
  --price-low: #16301f;
  --price-high: #6fd58a;
  --share-low: #142a1b;
  --share-high: #7ad897;
  --price-text-high: #0b1f12;
  --slot-1: #2f7a37; --slot-2: #5d47a0; --slot-3: #6e5c10; --slot-4: #1f7a72; --slot-5: #3d5266; --slot-6: #677222; --slot-7: #555555; --slot-8: #7c5130;
  --neutral-mark: #52514e;
  --co-1: #12a8ac; --co-2: #c98500; --co-3: #d55181; --co-4: #008300; --co-5: #9085e9; --cat-other: #6b6a65;
  --accent-wash: rgba(57, 135, 229, 0.16);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 0 16px 32px;
  max-width: 1440px;
  margin: 0 auto;
}
h1 { font-size: 20px; margin: 0; font-weight: 650; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
h3 { font-size: 13px; margin: 16px 0 6px; font-weight: 600; color: var(--text-secondary); }
.sub, .note { color: var(--text-secondary); margin: 2px 0 0; }
.note { font-size: 13px; }
/* Days of the range not loaded yet: one line above the charts (main.ts), the charts show them as gaps. */
.range-notice { margin: 0 0 12px; padding: 8px 12px; border: 1px solid var(--border); border-left: 3px solid var(--warning); border-radius: 6px; background: var(--surface-1); color: var(--text-primary); }

/* App header, one box: top left the title, top right the data status and Update with the update messages under
   them, and under both the filters for every tab on one row across the whole width (the left part alone is too
   narrow for all four, 19.11.2026). The messages fill the space next to the title and scroll,
   they never make the box taller. On a wide screen the whole box stays at the top while scrolling. */
.top {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title actions" "filters filters";
  gap: 4px 24px; margin: 16px 0 4px; padding: 16px 18px; background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 10px;
}
.top > .title { grid-area: title; min-width: 0; }
.top > .filters { grid-area: filters; }
.top > .top-actions { grid-area: actions; }
@media (min-width: 900px) and (min-height: 700px) { .top { position: sticky; top: 0; z-index: 5; } }
.filters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end; padding-top: 10px; }
@media (max-width: 899px) {
  .top { grid-template-columns: minmax(0, 1fr); grid-template-areas: "title" "actions" "filters"; padding: 12px; }
}
.field { display: flex; flex-direction: column; gap: 4px; }
.label { font-size: 12px; color: var(--text-muted); }
select, input.date-text, button {
  font: inherit; color: var(--text-primary); background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; min-height: 32px;
}
button { cursor: pointer; }
button:hover { background: var(--accent-wash); }
/* Range: the [Period | Calendar] switch, then the period buttons or the two dates (only one of them shows). */
.range-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.range-row > [hidden], .filters .field[hidden] { display: none; }
.range-row > .segmented { padding-right: 14px; border-right: 1px solid var(--border); }
.dates { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dates .dash { font-size: 13px; color: var(--text-muted); }
/* Every control in the range row is 32 px high, so switching Period / Calendar never moves the filter bar. */
.range-row button, .date-field > input.date-text, .date-field > button.cal { box-sizing: border-box; height: 32px; min-height: 32px; }
.date-field > input.date-text { width: calc(11ch + 18px); }
@media (max-width: 700px) { .range-row > .segmented { padding-right: 0; border-right: none; } }
.presets { display: flex; flex-wrap: wrap; gap: 4px; }
/* From / To: a typed Croatian date (12.11.2026.) and a calendar button joined into one box. The browser's date input
   sits invisible under the button, only so its picker opens there. */
.date-field { position: relative; display: inline-flex; }
input.date-text { width: 11ch; box-sizing: content-box; border-radius: 6px 0 0 6px; font-variant-numeric: tabular-nums; }
input.date-text[aria-invalid="true"] { border-color: var(--critical, #d03b3b); outline-color: var(--critical, #d03b3b); }
.date-field button.cal { border-left: none; border-radius: 0 6px 6px 0; padding: 5px 7px; color: var(--text-secondary); display: inline-flex; align-items: center; }
.date-field input.date-picker { position: absolute; right: 0; bottom: 0; width: 32px; height: 100%; opacity: 0; pointer-events: none; border: 0; padding: 0; }
.presets button[aria-pressed="true"] { font-weight: 650; border-color: var(--series-1); }
.presets button:disabled { cursor: not-allowed; opacity: .45; background: transparent; }

.tabs { display: flex; gap: 4px; padding: 12px 0; overflow-x: auto; }
.tabs button { border: none; background: transparent; padding: 6px 12px; border-radius: 6px; white-space: nowrap; color: var(--text-secondary); }
.tabs button[aria-selected="true"] { background: var(--surface-1); color: var(--text-primary); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }

main { transition: opacity 120ms; position: relative; min-height: 240px; }
/* Loading: the old view fades and a spinner sits in the middle of the window (seen however far down you scrolled). Shown after 150 ms, so fast answers do not flicker. */
main.loading > * { opacity: 0.45; pointer-events: none; transition: opacity 120ms 150ms; }
main.loading::before {
  content: ''; position: fixed; z-index: 20; left: 50%; top: 50%; width: 32px; height: 32px; margin: -16px 0 0 -16px;
  border: 3px solid var(--grid); border-top-color: var(--series-1); border-radius: 50%;
  animation: spin 0.8s linear infinite, appear 0s 150ms both;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes appear { from { visibility: hidden; } to { visibility: visible; } }
@media (prefers-reduced-motion: reduce) { main.loading::before { animation-duration: 2.4s, 0s; } }
.error-box { padding: 16px 0; }
.error-box .error { padding: 0 0 8px; }

.intro { color: var(--text-secondary); margin: 0 0 12px; max-width: 900px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 560px), 1fr)); gap: 16px; }
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; min-width: 0;
}
.card.wide { grid-column: 1 / -1; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: start; margin-bottom: 8px; }
.card-head > div:first-child { flex: 1 1 260px; min-width: 0; }
.card-head button { font-size: 12px; min-height: 26px; padding: 2px 8px; flex-shrink: 0; }
.card-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: end; min-width: 0; max-width: 100%; }
.segmented { display: flex; flex-wrap: wrap; gap: 2px; min-width: 0; max-width: 100%; }
.segmented button { flex-shrink: 1; min-width: 0; white-space: normal; }
/* Narrow screens: the toggle gets its own full-width row and the three buttons share it equally. */
@media (max-width: 560px) {
  .card-tools { flex-basis: 100%; justify-content: start; }
  .segmented { flex: 1 1 100%; }
  .segmented button { flex: 1 1 0; }
}
.segmented button[aria-pressed="true"] { font-weight: 650; border-color: var(--series-1); background: var(--accent-wash); }
.chart { width: 100%; overflow-x: auto; }
.chart svg { display: block; max-width: 100%; height: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-secondary); margin: 2px 0 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.legend i.box { width: 10px; height: 10px; border-radius: 2px; }
.legend i.box[style*="gradient"] { width: 28px; } /* a scale swatch (price low to high) */
.legend i.box[style*="repeating"] { width: 10px; border: 1px solid var(--text-muted); } /* a hatch swatch (unsold) */
.dir-legend { margin: 0 0 4px; }
.dir-legend .dir-facts { color: var(--text-muted); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 8px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.tile .v { font-size: 24px; font-weight: 650; }
.tile .k { font-size: 12px; color: var(--text-secondary); }
.tile .d { font-size: 12px; color: var(--text-muted); }

.table-wrap { overflow-x: auto; max-height: 520px; overflow-y: auto; margin-top: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 5px 8px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
th:first-child, td:first-child, th.l, td.l { text-align: left; }
th { position: sticky; top: 0; background: var(--surface-1); color: var(--text-secondary); font-weight: 600; cursor: default; }
th.sortable { cursor: pointer; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--accent-wash); }
tr.selected td { font-weight: 600; }

.picker { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end; margin-bottom: 12px; }
.empty { color: var(--text-secondary); padding: 24px 0; }
.error { color: #d03b3b; padding: 16px 0; }
.foot { color: var(--text-muted); font-size: 12px; margin-top: 28px; }

/* Plot tooltips follow the theme */
[aria-label="tip"] path { fill: var(--surface-1); stroke: var(--border); }
.pick-border { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tile .delta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.tile .delta span { font-size: 9px; vertical-align: 1px; }
.table-wrap .csv { font-size: 12px; min-height: 26px; padding: 2px 8px; margin-bottom: 6px; }

/* ---- data status and update ---- */
:root { --good: #0ca30c; --warning: #fab219; --critical: #d03b3b; }
/* Right part of the header: the JAO and SEE CAO pills and Update on one row, the status lines under them. The message
   box is laid out of the flow (absolute) inside a wrapper that takes the rest of the height, so its text can never
   stretch the header: what does not fit scrolls. #status only groups its two parts. */
.top-actions { display: flex; flex-direction: column; gap: 6px; min-width: 0; max-width: 100%; }
.status { display: contents; }
.status-row { display: flex; gap: 6px; align-items: center; justify-content: end; flex-wrap: wrap; }
.top-actions .pill { white-space: nowrap; }
/* Room for the longest normal status (the platforms line wrapped onto two, the update line, the notes line and
   Details), so nothing of it hides under the scroll: the box is no longer as tall as the title and the filters
   (19.11.2026). Only longer text (never shown today) scrolls. */
.status-msg-wrap { position: relative; flex: 1 1 auto; min-height: 97px; }
.status-msg {
  position: absolute; inset: 0; overflow-y: auto;
  display: flex; flex-direction: column; align-items: end; gap: 2px; font-size: 13px; line-height: 1.4; text-align: end;
}
.status-msg > * { margin: 0; max-width: 100%; }
.nowrap { white-space: nowrap; }
.status .sub { display: flex; gap: 4px; align-items: center; font-size: 13px; }
.icon { flex-shrink: 0; vertical-align: -3px; }
.pill { display: inline-flex; gap: 5px; align-items: center; padding: 3px 9px; border: 1px solid var(--border); border-radius: 999px; font-size: 13px; background: var(--surface-1); }
.pill.fresh .icon, .icon-ok { color: var(--good); }
.pill.pending .icon { color: var(--warning); }
.pill.failed .icon { color: var(--critical); }
/* Platform pill with counts: tomorrow's capacity and results, or today's results until tomorrow is checked. In / to come / failed. */
.pill.counts { gap: 8px; }
.pill-name { font-weight: 600; }
.pc { display: inline-flex; gap: 3px; align-items: baseline; }
.pc-label { color: var(--text-muted); font-size: 11px; margin-right: 1px; }
.pc-n { font-weight: 600; font-variant-numeric: tabular-nums; }
.pc-n.got { color: var(--good-ink); }
.pc-n.wait { color: var(--warning-ink); }
.pc-n.fail { color: var(--critical-ink); }
.pc-n.zero { color: var(--text-muted); font-weight: 400; }
.pc-none { color: var(--text-muted); font-size: 12px; }
.pill.counts.failed { border-color: var(--critical); }
.icon-failed { color: var(--critical); }
.icon-behind { color: var(--warning); }
/* A warning or failure line: its icon is yellow or red, the text stays readable ink, a bit stronger. */
.status-msg .warn, .status-msg .bad { color: var(--text-primary); }
.status-lines { display: flex; flex-direction: column; align-items: inherit; gap: 2px; }
.status-lines > p { margin: 0; }
.details[hidden] { display: none; }
.details.running .details-btn { display: none; }
.update-btn { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; }
.update-btn:disabled { cursor: progress; }
.spinning { animation: spin 0.9s linear infinite; color: var(--series-1); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinning { animation-duration: 3s; } }
.steps { list-style: none; margin: 2px 0 0; padding: 0; font-size: 13px; color: var(--text-secondary); }
.steps li { display: flex; gap: 6px; align-items: center; justify-content: end; }
.steps li.waiting, .steps li.skipped { color: var(--text-muted); }
/* Details: a small text button under the status lines, its popup over the page with every step in full. */
.details-btn { min-height: 0; padding: 0 2px; border: none; background: none; font-size: 13px; color: var(--series-1); text-decoration: underline; text-underline-offset: 2px; }
.details-btn:hover { background: none; color: var(--text-primary); }
.status-pop {
  text-align: start;
  position: fixed; inset: auto; margin: 0; width: max-content; overflow: auto;
  padding: 10px 14px; background: var(--surface-1); color: var(--text-primary);
  /* A thin coloured edge, so the popup stands out from the page under it. Its colour says the update's state. */
  border: 1.5px solid var(--border); border-radius: 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}
/* Finished: neon green with a faint glow. */
.status-pop.is-ok { border-color: #19e07f; box-shadow: 0 0 0 1px rgba(25, 224, 127, 0.18), 0 0 10px rgba(25, 224, 127, 0.35), 0 6px 24px rgba(0, 0, 0, 0.18); }
/* Failed: a thin darker red, no glow. */
.status-pop.is-failed { border-color: #a82a2a; box-shadow: 0 0 0 1px rgba(168, 42, 42, 0.15), 0 6px 24px rgba(0, 0, 0, 0.18); }
/* Running: blue, the glow pulses. */
.status-pop.is-running { border-color: #2f8cff; animation: pop-pulse 1.6s ease-in-out infinite; }
@keyframes pop-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(47, 140, 255, 0.15), 0 0 3px rgba(47, 140, 255, 0.25), 0 6px 24px rgba(0, 0, 0, 0.18); }
  50% { box-shadow: 0 0 0 1px rgba(47, 140, 255, 0.35), 0 0 16px rgba(47, 140, 255, 0.75), 0 6px 24px rgba(0, 0, 0, 0.18); }
}
@media (prefers-reduced-motion: reduce) {
  .status-pop.is-running { animation: none; box-shadow: 0 0 0 1px rgba(47, 140, 255, 0.3), 0 0 10px rgba(47, 140, 255, 0.5), 0 6px 24px rgba(0, 0, 0, 0.18); }
}
.status-pop .steps li { justify-content: start; }
.status-pop .pop-close { position: absolute; top: 6px; right: 6px; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; min-height: 0; padding: 0; border: none; border-radius: 6px; background: none; font-size: 20px; line-height: 1; color: var(--text-secondary); }
.status-pop .pop-close:hover { background: var(--page); color: var(--text-primary); }
.status-pop h4:first-of-type { margin-right: 32px; }
.status-pop h4:first-of-type { margin-top: 0; }
.status-pop h4 { margin: 10px 0 4px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.pub-notes { list-style: none; margin: 2px 0 0; padding: 0; font-size: 13px; color: var(--text-secondary); }
.pub-notes li { margin: 0 0 4px; }
.pub-notes .pn-when, .pub-notes b { margin-right: 6px; }
.pub-notes li.changed b { color: var(--critical); }
.pn-when { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.status-pop pre { margin: 0; font-size: 12px; white-space: pre-wrap; background: var(--page); border: 1px solid var(--border); padding: 8px; border-radius: 6px; }
@media (max-width: 899px) {
  .status-row { justify-content: start; }
  .status-msg { align-items: start; text-align: start; }
  .steps li { justify-content: start; }
}
/* ---- map link: in the header right after the title (it is no filter); opens the map overlay ---- */
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.map-link .icon { width: 15px; height: 15px; }
.map-link {
  position: relative; display: inline-flex; gap: 4px; align-items: center; min-height: 26px; padding: 2px 8px;
  font-size: 13px; font-weight: 600; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-1);
  color: var(--series-1); text-decoration: none;
}
.map-link:hover { background: var(--accent-wash); }
.map-link:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }
/* Hover/focus text, below the button, opening to the right (the button sits at the left, after the title). */
.map-link::after {
  content: attr(data-tip); position: absolute; top: calc(100% + 6px); left: 0; z-index: 6; /* above the sticky filter bar (5) */ width: max-content; max-width: 240px;
  padding: 6px 9px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-1); color: var(--text-primary);
  font-size: 12px; font-weight: 400; line-height: 1.35; white-space: normal; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  opacity: 0; visibility: hidden; pointer-events: none;
}
.map-link:hover::after, .map-link:focus-visible::after { opacity: 1; visibility: visible; }
/* Narrow screens: the button is near the right edge, the text opens to the left so it never leaves the window. */
@media (max-width: 600px) { .map-link::after { left: auto; right: 0; } }

/* Roomy HTML tooltip (withTip): the hovered item's name in its own colour, values in an aligned grid. */
.tip-wrap { position: relative; }
.ctip {
  /* Fixed: lies over the page, never inside a chart's scroll area (placed by placeTip in shared.ts). */
  position: fixed; z-index: 30; pointer-events: none; min-width: 220px; max-width: 300px;
  background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; font-size: 13px; line-height: 1.6; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
}
.ctip-name { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.ctip-name i { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.ctip dl { display: grid; grid-template-columns: fit-content(220px) minmax(0, 1fr); gap: 3px 18px; margin: 0; }
.ctip dt { color: var(--text-secondary); }
.ctip dd { margin: 0; min-width: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; overflow-wrap: anywhere; }
/* Label column: short labels stay on one line, a long name (a winner row) wraps at 220px instead of widening the box. */
.ctip dt { overflow-wrap: anywhere; }
/* A row without a value (a winner on a platform without MW): the label takes the whole row. */
.ctip dt.span { grid-column: 1 / -1; }
/* Competition: bigger hover text with more space on each row. */
.ctip.ctip-big { font-size: 15px; line-height: 1.5; max-width: 460px; padding: 14px 18px; }
.ctip.ctip-big .ctip-name { font-size: 17px; margin-bottom: 10px; }
.ctip.ctip-big dl { gap: 8px 22px; }
.ctip dt.hi { font-weight: 700; }
.ctip-note { margin: 10px 0 0; color: var(--text-secondary); font-size: 13px; line-height: 1.5; }

/* "?" help in a card's top right corner, its explanation in a box below it (help() in lib.ts). */
.card.has-help { position: relative; }
.card.has-help > .card-head, .card.has-help > h2 { padding-right: 34px; }
.help-btn {
  position: absolute; top: 12px; right: 12px; width: 24px; height: 24px; min-height: 0; padding: 0;
  border-radius: 50%; font-size: 13px; font-weight: 700; line-height: 1; color: var(--text-secondary);
  display: inline-flex; align-items: center; justify-content: center;
}
.help-btn[aria-expanded="true"] { color: var(--series-1); border-color: var(--series-1); background: var(--accent-wash); }
.help-pop {
  position: absolute; top: 42px; right: 12px; z-index: 4; width: min(360px, calc(100% - 24px));
  background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; font-size: 13px; line-height: 1.6; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
}

/* Tab row with the open tab's explanation behind a ? at its right end. */
.tabbar { display: flex; align-items: center; gap: 8px; }
/* Filters for the open tab only, right under the tabs: what sits here changes with the tab (main.ts). */
.tab-filters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end; padding: 0 0 12px; margin: 0 0 12px; border-bottom: 1px solid var(--border); }
.tab-filters .field[hidden], .tab-filters .tab-tools:empty { display: none; }
.tab-filters .tab-tools { margin: 0; align-self: end; min-height: 32px; }
.tab-filters .tab-tools.lead { order: -1; }
.tab-filters select option:disabled { color: var(--text-muted); }
/* Direction and Compare with: each marks the reverse of the other picker's direction, in the line colour it gets when
   picked. The text "(reverse, ...)" says it too, for browsers that draw their own list and ignore option colours
   (phones, macOS). */
#dir option, #vs option { color: var(--text-primary); font-weight: normal; }
#dir option.rev, #dir.is-rev { color: var(--series-1); font-weight: 600; }
#vs option.rev, #vs.is-rev { color: var(--series-2); font-weight: 600; }
#dir option:disabled, #vs option:disabled { color: var(--text-muted); }
/* A view's own control here (e.g. Count) gets its label above it, like the filters next to it. */
.tab-filters .view-tools .tool-group { flex-direction: column; align-items: start; gap: 4px; }
.tab-filters .view-tools .tool-group .label { flex: none; }
.tab-filters .view-tools .segmented button { min-height: 32px; }
.tabbar .tabs { flex: 1 1 auto; min-width: 0; }
.tab-help { position: relative; flex-shrink: 0; }
.tab-help .help-btn { position: static; }
.tab-help .help-pop { top: 34px; right: 0; width: min(420px, calc(100vw - 32px)); }

/* Tile row with its comparison note behind a ? at the right end. */
.tiles-wrap { position: relative; margin-bottom: 16px; }
.tiles-wrap.has-help { padding-right: 34px; }
.tiles-wrap > .help-btn { top: 0; right: 0; }
.tiles-wrap > .help-pop { top: 30px; right: 0; }
.tiles-wrap .tiles { margin-bottom: 0; }
.facts { font-size: 12px; color: var(--text-muted); margin: 0 0 6px; }
/* Touch screens: the ? keeps its look, its tap area grows to 40 px. */
@media (pointer: coarse) {
  .help-btn::after { content: ""; position: absolute; inset: -8px; }
}

/* Row above the Overview boxes: the measure both the chart (left) and its numbers (right) show. */
.view-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; }
.view-tools .segmented button { font-size: 13px; min-height: 30px; padding: 4px 12px; }
.view-tools { gap: 10px 22px; }
.view-tools .tool-group { display: flex; align-items: center; gap: 10px; min-width: 0; }
/* Narrow screens: each group (Show, per) takes its own full-width row. */
@media (max-width: 560px) {
  .view-tools .tool-group { flex: 1 1 100%; }
  .view-tools .tool-group .label { flex: 0 0 34px; }
}

/* Table cells with more text than shown: dotted underline, a tap or Enter shows the full text. */
td.expandable { cursor: pointer; text-decoration: underline dotted var(--text-muted); text-underline-offset: 3px; }
td.expandable:focus-visible { outline: 2px solid var(--series-1); outline-offset: -2px; }
td.expandable.expanded { white-space: normal; min-width: 16em; }

/* ---- map overlay (Map button): the border map on top of the dashboard, which keeps its state ---- */
.map-dialog {
  width: min(1500px, calc(100vw - 32px)); height: calc(100vh - 32px); max-width: none; max-height: none;
  padding: 0; border: 1px solid var(--border); border-radius: 10px; background: var(--page); color: var(--text-primary);
  overflow: hidden; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.map-dialog[open] { display: flex; flex-direction: column; }
.map-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.map-dialog-bar { display: flex; gap: 6px 14px; align-items: center; flex-wrap: wrap; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--border); }
.map-dialog-bar strong { font-size: 15px; }
.map-dialog-bar .sub { margin: 0; flex: 1 1 260px; min-width: 0; }
.map-close { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; border-radius: 6px; }
.map-dialog iframe { flex: 1; width: 100%; border: 0; background: var(--page); }
@media (max-width: 700px) { .map-dialog { width: 100vw; height: 100vh; border-radius: 0; border: 0; } }
/* One direction of the Day to day heatmap, opened by a click on its row: sized to the chart, not the whole screen. */
.dir-dialog { width: min(560px, calc(100vw - 32px)); height: fit-content; max-height: calc(100vh - 32px); }
.dir-dialog-body { overflow: auto; padding: 12px 16px 16px; }
.dir-dialog-body svg { width: 100%; height: auto; }
.heat-stack .tip-wrap [data-row], .heat-stack g[aria-label="y-axis tick label"] text { cursor: pointer; }

/* ---- timetable overlay (Timetable button): same frame as the map overlay, its own scrolling body ---- */
button.map-link { cursor: pointer; font-family: inherit; }
/* Light/dark switch: icon only, square. */
.theme-toggle { justify-content: center; min-width: 30px; padding: 2px 6px; }
.tt-body { flex: 1; overflow: auto; padding: 8px 16px 20px; }
.tt-h { font-size: 15px; margin: 14px 0 2px; }
/* Timetable heading with its explanation behind a ? at the right end (like the tab row). */
.tt-head { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tt-head .help-btn { position: static; flex-shrink: 0; }
.tt-head .help-pop { top: 34px; right: 0; width: min(420px, calc(100vw - 32px)); }
/* A ? with structure: a lead line, then bullets (sub-bullets for details). */
.help-pop .help-lead { margin: 0 0 6px; font-weight: 650; }
.help-pop .help-list { margin: 0; padding-left: 18px; }
.help-pop .help-list .help-list { margin-top: 2px; color: var(--text-secondary); }
.help-pop .help-list li + li { margin-top: 6px; }
.help-pop .help-list .help-list li + li { margin-top: 2px; }
.tt-split { border: 0; border-top: 1px solid var(--border); margin: 18px 0 4px; }
/* The popup scrolls as a whole: the direction table shows all its rows instead of a box of its own. */
.tt-body .table-wrap { max-height: none; overflow-y: visible; }
/* Timetable legend: the platform is the thick border of a bar. */
/* Timetable: each count is a grey pill (blue is JAO) that opens a row under it with those days (timeline, what happened, why). */
.inc-pill { font: inherit; font-size: 12px; font-variant-numeric: tabular-nums; min-width: 40px; min-height: 0; height: 20px; line-height: 18px; padding: 0 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--neutral-mark); background: var(--border); color: var(--text-primary); }
.inc-pill:hover, .inc-pill:focus-visible { border-color: var(--text-secondary); outline: none; }
.inc-pill[aria-expanded="true"] { background: var(--text-secondary); border-color: var(--text-secondary); color: var(--page); }
.tt-body tr.inc-row > td { padding: 6px 10px 12px 24px; background: var(--surface-1); }
.inc { padding: 10px 0; border-bottom: 1px solid var(--border); white-space: normal; text-align: left; }
.inc:last-child { border-bottom: 0; }
.inc-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 6px; }
.inc-sub { color: var(--text-muted); font-size: 12px; }
.inc-tag, .inc-why { font-size: 12px; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--border); }
.inc-why.w-confirmed { color: #2e7d32; border-color: currentColor; }
.inc-why.w-likely { color: #a06800; border-color: currentColor; }
.inc-why.w-open { color: var(--text-secondary); }
.inc p { margin: 4px 0; max-width: 900px; line-height: 1.45; }
.inc-tl-wrap { overflow-x: auto; }
.inc-tl { border-collapse: collapse; font-size: 12px; margin: 2px 0 6px; }
.inc-tl th, .inc-tl td { padding: 3px 12px 3px 0; text-align: left; white-space: nowrap; border: 0; }
.inc-tl th { color: var(--text-secondary); font-weight: 600; }
.inc-tl .out-cancelled { color: #c62828; font-weight: 600; }
/* A coloured dot in a table cell (Column.pip), before the text or after it. */
td .pip { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 7px -1px 0; vertical-align: baseline; }
td .pip.after { margin: 0 0 -1px 7px; }
.tt-list { list-style: none; margin: 4px 0 8px; padding: 0; font-size: 13px; line-height: 1.5; }
.tt-list li { margin: 0 0 6px; }
.tt-list .tt-swatch { display: inline-block; width: 14px; height: 14px; margin: 0 6px -2px 0; border: 3px solid; border-radius: 3px; box-sizing: border-box; }
.tt-list strong { margin-right: 4px; }
.legend i.box.edge { width: 12px; height: 12px; background: transparent !important; border: 3px solid currentColor; box-sizing: border-box; }

/* Competition "Who won each hour, per day": the day picker in the card head, one chart per direction. */
.day-pick { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.day-pick .label { font-size: 13px; color: var(--text-secondary); margin-right: 2px; }
.day-pick select { min-height: 32px; }
.day-pick .step { min-width: 32px; min-height: 32px; padding: 0 8px; font-size: 16px; line-height: 1; }
.day-pick .step:disabled { opacity: .4; cursor: default; }
.day-notice { display: flex; align-items: center; gap: 10px; margin: 4px 0 8px; padding: 6px 6px 6px 10px; border-radius: 6px; background: var(--accent-wash); color: var(--text-primary); font-size: 13px; }
.day-notice[hidden] { display: none; }
.day-notice span { flex: 1; }
.day-notice-x { flex: none; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--text-secondary); font-size: 18px; line-height: 1; cursor: pointer; }
.day-notice-x:hover { background: var(--grid); color: var(--text-primary); }
/* The day list after a jump to the filter's last day: a short yellow flash, so the eye goes to it. */
@keyframes day-flash { from { background: #ffe58a; } to { background: transparent; } }
.day-pick select.day-flash { animation: day-flash 1.4s ease-out; }
.day-dir { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-primary); margin: 10px 0 4px; }
.day-dir i { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.day-charts > .day-dir:first-child { margin-top: 0; }
/* Capacity per day: both directions side by side under one legend, stacked on a narrow screen. */
.cap-pair { display: grid; gap: 12px 16px; }
/* One price legend per direction above a heatmap (blue Direction, orange Compare with), side by side, wrapping. */
.ramp-legends { display: flex; flex-wrap: wrap; gap: 4px 24px; margin-bottom: 4px; }
/* What a card or a slot cannot draw (SEE CAO publishes no MW per company): one small line, the place stays. */
.missing-note { margin: 4px 0 0; font-size: 12px; color: var(--text-secondary); }
/* In the place of a grid that has nothing to draw: a framed box, so the empty place reads as a missing chart. */
.missing-graph { margin: 4px 0 8px; padding: 20px 16px; border: 1px dashed var(--grid); border-radius: 6px; text-align: center; font-size: 13px; color: var(--text-secondary); }
.cap-pair > div { min-width: 0; }
.cap-pair .day-dir { margin-top: 0; }
.card.loading .chart { opacity: .5; transition: opacity .15s; }

/* Day to day, All directions: one small chart per direction. */
.dir-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px 24px; }
.dir-panel { min-width: 0; }
.dir-panel svg { width: 100%; max-width: 100%; height: auto; }
.dir-head { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.dir-panel .empty { margin: 8px 0; }
.heat-stack .dir-head { margin-top: 8px; }
.span-line { margin: 0 0 8px; }

/* ---- login page (web/login.html) and the Log out button in the header, only on the server ---- */
.login { max-width: 320px; margin: 18vh auto 0; padding: 0 16px; }
.login h1 { margin-bottom: 16px; }
.login-form { display: grid; gap: 8px; }
.login-form label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.login-form input { padding: 8px 10px; font: inherit; color: var(--text-primary); background: var(--surface-1); border: 1px solid var(--axis); border-radius: 6px; }
.login-form input:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }
.login-form button { padding: 8px 10px; font: inherit; font-weight: 600; color: #fff; background: var(--series-1); border: 0; border-radius: 6px; cursor: pointer; }
.login-form .remember-row { position: relative; display: flex; align-items: center; gap: 8px; padding-bottom: 8px; }
/* The ? stays quiet next to the box: thin grey ring, no fill (the form's buttons are filled). */
.login-form .remember-row .help-btn, .login-form .remember-row .help-btn[aria-expanded="true"] {
  position: static; width: 20px; height: 20px; border-radius: 50%; font-size: 12px; font-weight: 600;
  color: var(--text-secondary); background: transparent; border: 1px solid var(--border);
}
.login-form .remember-row .help-btn:hover, .login-form .remember-row .help-btn[aria-expanded="true"] { border-color: var(--text-secondary); }
.login-form .remember-row .help-pop { top: 28px; right: 0; width: min(320px, calc(100vw - 32px)); }
.login-form .remember { display: flex; align-items: center; gap: 6px; font-weight: 400; color: var(--text-primary); }
.login-form .remember input { margin: 0; }
.login-form .error { margin: 4px 0 0; color: var(--critical-ink); font-size: 13px; }
/* Log out: a plain text link at the right end of the data line under the title (web/index.html .sub-row), a row away
   from the Timetable, Map and dark-mode buttons so it is not clicked by mistake. */
.sub-row { display: flex; align-items: baseline; gap: 16px; }
.sub-row .sub { flex: 1 1 auto; min-width: 0; }
.logout-form { margin: 2px 0 0; flex: none; }
.logout { display: inline-flex; align-items: center; gap: 5px; font: inherit; font-size: 13px; font-weight: 600; padding: 0; border: 0; background: none; color: var(--text-primary); cursor: pointer; }
.logout span { text-decoration: underline; text-underline-offset: 3px; }
.logout:hover span { text-decoration-thickness: 2px; }
