/* Crash Watch (/crash-watch): instrument panel inside the public dashboard shell, in light and dark.
   Layout from the approved canvas of 7 Nov 2026; colours are the shared --id-* theme tokens (dashboard-theme.css),
   so the panel follows the site theme. The panel has no colours of its own: --cw-* only renames the tokens.
   Meaning colours (.t-ok / .t-mid / .t-high / .t-n) are --id-good / --id-warn / --id-bad / --id-faint, which keep
   3:1 (marks) and 4.5:1 (text) on every surface the panel uses in both themes. Fonts, sizes, cards, header and segmented control come from dashboard-ui.css (--id-*). */
main.cw {
  --cw-bg: var(--id-bg); --cw-card: var(--id-surface); --cw-cell: var(--id-surface-2); --cw-raised: var(--id-surface-3);
  --cw-line: var(--id-line); --cw-line2: var(--id-line-strong); --cw-btn-line: var(--id-line-strong);
  --cw-ink: var(--id-heading); --cw-ink2: var(--id-text); --cw-ink3: var(--id-text-2); --cw-mute: color-mix(in srgb, var(--id-mute) 60%, var(--id-text-2)); --cw-mute2: color-mix(in srgb, var(--id-mute) 75%, var(--id-text-2));
  --cw-blue: var(--id-series-1); --cw-link: var(--id-link); --cw-amber: var(--id-warn);
  --tone: var(--id-faint); --tone-text: var(--id-text-2);
  --cw-num: var(--id-font);
  min-height: calc(100vh - var(--dashboard-header-height, 76px));
  background: var(--cw-bg); color: var(--cw-ink);
}
.cw *, .cw *::before, .cw *::after { box-sizing: border-box; }
.cw button { font-family: inherit; }
.cw :focus-visible { outline: 2px solid var(--id-focus); outline-offset: 2px; }
/* meaning colours: a tone sets the mark colour (--tone) and the text colour (--tone-text) */
.t-ok { --tone: var(--id-good); --tone-text: var(--id-good); }
.t-mid { --tone: var(--id-warn); --tone-text: var(--id-warn); }
.t-high { --tone: var(--id-bad); --tone-text: var(--id-bad); }
.t-n { --tone: var(--id-faint); --tone-text: var(--id-text-2); }
.t-minor { --tone: var(--id-faint); --tone-text: var(--id-text-2); } /* a Minor flag: neutral, derived from the same tokens as .t-n */
.cw-level, .cw-ring-word, .cw-pill, .cw-cell-val.t-ok, .cw-cell-val.t-mid, .cw-cell-val.t-high, .cw-cell-val.t-n { color: var(--tone-text); }
.cw-wrap { display: flex; flex-direction: column; gap: 28px; } /* width, gutter and padding: .id-content */
.cw section { padding: 0; margin: 0; align-items: stretch; text-align: left; } /* the site styles every section */
.cw-label { color: var(--cw-mute); } /* size, case and spacing: .id-label */

/* header: .id-page-head, .id-kicker, .id-pill, .id-page-title, .id-asof, .id-seg (dashboard-ui.css) */
.cw-head { margin: 0; }
.cw-scen-line[hidden] { display: none; }

/* the two readings */
.cw-rings { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 16px; }
.cw-ring { display: flex; align-items: center; gap: 24px; padding: var(--id-card-pad); border-radius: var(--id-radius-card); background: var(--cw-card); border: 1px solid var(--cw-line); box-shadow: var(--id-shadow-card); color: var(--cw-ink); text-align: left; cursor: pointer; }
.cw-ring:hover, .cw-tile:hover, .cw-cell-btn:hover { border-color: var(--cw-btn-line); background: var(--cw-cell); }
.cw-ring-svg { width: 148px; height: 148px; flex: 0 0 auto; }
.cw-ring-num { font-family: var(--cw-num); font-size: calc(var(--id-fs-number) * 1.2); font-weight: 700; fill: var(--cw-ink); }
.cw-ring-sub { font-size: 12px; fill: var(--cw-mute); }
.cw-ring-text { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cw-ring-word { font-family: var(--cw-num); font-size: calc(var(--id-fs-number) * 1.3); line-height: 1.05; font-weight: 700; }
.cw-ring-cap { font-size: 14px; line-height: 1.4; color: var(--cw-ink3); }
.cw-ring-note { font-size: 12px; color: var(--cw-mute2); }
.cw-ring-line { display: block; margin-bottom: 4px; color: var(--cw-mute); }
.cw-more { font-size: 13px; font-weight: 600; color: var(--cw-link); }
.cw-noscript { margin: 0; padding: var(--id-card-pad); border: 1px solid var(--cw-line); border-radius: var(--id-radius-card); background: var(--cw-card); box-shadow: var(--id-shadow-card); color: var(--cw-ink2); }

/* flags: a compact list between the two gauges and the tiles */
.cw-flags { display: flex; flex-direction: column; gap: 10px; }
.cw-flags[hidden] { display: none; }
.cw-flags-head { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 14px; }
.cw-flags-head h2 { margin: 0; }
.cw-flags-note { font-size: 12px; color: var(--cw-mute); }
.cw-flags-about { margin-left: auto; min-height: 36px; padding: 0 4px; background: none; border: 0; color: var(--cw-link); font-size: 13px; font-weight: 600; cursor: pointer; }
.cw-flags-about:hover { text-decoration: underline; }
.cw-flaglist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cw-flagrow { display: flex; flex-wrap: wrap; align-items: center; border-radius: var(--id-radius-card); background: var(--cw-card); border: 1px solid var(--cw-line); box-shadow: var(--id-shadow-card); }
.cw-flagrow:hover { border-color: var(--cw-btn-line); background: var(--cw-cell); }
.cw-flag { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 3px; padding: 10px 16px; background: none; border: 0; border-radius: inherit; color: var(--cw-ink); text-align: left; cursor: pointer; }
.cw-flag-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; }
.cw-flag-date { font-size: 12px; color: var(--cw-ink3); white-space: nowrap; }
.cw-flag-title { font-size: 14px; font-weight: 600; color: var(--cw-ink); }
.cw-flag-detail { font-size: 13px; color: var(--cw-ink3); overflow-wrap: anywhere; }
.cw-flag-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cw-chip { padding: 1px 8px; border-radius: 999px; background: var(--cw-cell); border: 1px solid var(--cw-line); font-size: 11px; font-weight: 600; color: var(--cw-ink3); }
.cw-d-value .cw-chip { font-size: 12px; }
.cw-flag-more { display: block; overflow-wrap: anywhere; font-size: 12px; line-height: 1.45; color: var(--cw-mute); }
.cw-flag-src { padding: 0 16px 10px; font-size: 13px; font-weight: 600; }
.cw-flag-src a, .cw-panel a { color: var(--cw-link); }
.cw-flags-empty, .cw-flags-warn { margin: 0; font-size: 13px; color: var(--cw-ink3); }
.cw-flags-warn { font-size: 12px; color: var(--cw-mute); }
.cw-fm { stroke: var(--tone); stroke-width: 2; vector-effect: non-scaling-stroke; }
@media (min-width: 900px) {
  .cw-flag-src { padding: 0 16px 0 0; }
  .cw-flagrow { flex-wrap: nowrap; }
}

/* tiles */
#cw-groups { display: flex; flex-direction: column; gap: 28px; }
.cw-group { display: flex; flex-direction: column; gap: 12px; }
.cw-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 12px; }
.cw-tile { display: flex; flex-direction: column; gap: 6px; padding: 18px 18px 14px; border-radius: var(--id-radius-card); background: var(--cw-card); border: 1px solid var(--cw-line); box-shadow: var(--id-shadow-card); color: var(--cw-ink); text-align: left; cursor: pointer; min-width: 0; }
.cw-tile.is-late { border-color: color-mix(in srgb, var(--id-warn) 45%, var(--cw-line)); }
.cw-tile-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; }
.cw-tile-name { font-size: 14px; font-weight: 600; color: var(--cw-ink3); }
.cw-level { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.cw-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--tone); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone) 20%, transparent); }
.cw-tile-value { font-family: var(--cw-num); font-size: var(--id-fs-number); line-height: 1.1; font-weight: 700; }
.cw-tile-unit { font-size: 12px; color: var(--cw-mute); }
.cw-spark { position: relative; display: block; width: 100%; height: 52px; margin-top: 6px; }
.cw-spark svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.cw-end { position: absolute; left: 100%; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; background: var(--tone); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone) 20%, transparent); }
.cw-nospark { position: absolute; left: 0; bottom: 4px; font-size: 11px; color: var(--cw-mute2); }
.cw-tile-line { display: block; font-size: 12px; line-height: 1.35; color: var(--cw-mute); }
.cw-tile-asof { font-size: 11px; color: var(--cw-mute2); }
.cw-late { color: var(--cw-amber); font-weight: 600; }
.cw-area { fill: var(--cw-blue); fill-opacity: 0.12; }
.cw-track { stroke: var(--cw-line2); }
.cw-arc { stroke: var(--tone); }
.cw-arc.cw-off-seg { stroke: var(--cw-line2); }
.cw-rec { fill: var(--cw-raised); }
.cw-line { fill: none; stroke: var(--cw-blue); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }

/* footer */
.cw-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; padding-top: 16px; border-top: 1px solid var(--cw-line); font-size: 12px; color: var(--cw-mute); }
.cw-btn { min-height: 40px; padding: 0 16px; border-radius: var(--id-radius-control); background: transparent; border: 1px solid var(--cw-btn-line); color: var(--cw-ink); font-size: var(--id-fs-small); font-weight: 600; cursor: pointer; }
.cw-btn:hover { background: var(--cw-raised); }

/* dialogs: the element fills the screen, so a click outside the panel lands on it and closes it */
.cw-dialog { position: fixed; inset: 0; width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: 4vh 16px; border: 0; background: transparent; color: var(--cw-ink); overflow-y: auto; }
.cw-dialog::backdrop { background: var(--id-backdrop); }
.cw-dialog[open] { display: flex; justify-content: center; align-items: flex-start; }
.cw-panel { position: relative; width: 100%; max-width: 720px; padding: var(--id-card-pad); border-radius: var(--id-radius-card); box-shadow: var(--id-shadow-card); background: var(--cw-card); border: 1px solid var(--cw-line2); display: flex; flex-direction: column; gap: 18px; font-size: var(--id-fs-body); line-height: 1.55; color: var(--cw-ink2); }
.cw-panel-wide { max-width: 880px; }
.cw-panel p { margin: 0; }
.cw-d-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.cw-d-titles { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cw-d-name { margin: 0; font-family: var(--cw-num); font-size: var(--id-fs-section); line-height: 1.2; font-weight: 700; color: var(--cw-ink); }
.cw-x { width: 44px; height: 44px; flex: 0 0 auto; border-radius: 12px; background: var(--cw-raised); border: 1px solid var(--cw-line2); color: var(--cw-ink); cursor: pointer; display: flex; align-items: center; justify-content: center; }
#cw-d-body { display: flex; flex-direction: column; gap: 18px; }
.cw-d-value { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 16px; }
.cw-d-num { font-family: var(--cw-num); font-size: calc(var(--id-fs-number) * 1.3); line-height: 1.05; font-weight: 700; color: var(--cw-ink); }
.cw-d-unit { font-size: 14px; color: var(--cw-mute); }
.cw-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: var(--cw-cell); border: 1px solid var(--cw-line); font-size: 13px; font-weight: 600; }
.cw-block { display: flex; flex-direction: column; gap: 6px; }
.cw-block p { font-size: 15px; line-height: 1.55; color: var(--cw-ink2); }
.cw-prose .cw-block p { font-size: 14px; }
.cw-muted, .cw-prose .cw-block p.cw-muted { color: var(--cw-mute); }
.cw-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 16px; }
.cw-cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 8px; }
.cw-cell { padding: 12px; border-radius: 12px; background: var(--cw-cell); display: flex; flex-direction: column; gap: 4px; }
.cw-cell-btn { border: 1px solid var(--cw-line); color: var(--cw-ink); text-align: left; cursor: pointer; }
.cw-cell-name { font-size: 12px; color: var(--cw-ink3); }
.cw-cell-val { font-family: var(--cw-num); font-size: 20px; font-weight: 700; }
.cw-cell-sub { font-size: 11px; color: var(--cw-mute); }
.cw-cell .cw-level { font-size: 11px; }
.cw-cell .cw-late { font-size: 11px; }
.cw-levels { display: flex; flex-wrap: wrap; gap: 8px; }
.cw-lv { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--cw-cell); font-size: 12px; color: var(--cw-ink3); }
.cw-lv b { font-weight: 600; color: var(--cw-ink); }
.cw-source { padding-top: 12px; border-top: 1px solid var(--cw-line); font-size: 12px; color: var(--cw-mute); }

/* the chart */
.cw-chart-box { display: flex; flex-direction: column; gap: 10px; }
.cw-ranges { display: flex; flex-wrap: wrap; gap: 6px; }
.cw-range { min-height: 36px; padding: 0 12px; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer; background: transparent; color: var(--cw-ink3); border: 1px solid var(--cw-btn-line); }
.cw-range[aria-pressed="true"] { background: var(--cw-ink); color: var(--cw-bg); border-color: var(--cw-ink); }
.cw-chart { display: flex; flex-direction: column; gap: 6px; }
.cw-plot { position: relative; height: 240px; margin-left: 46px; margin-right: 4px; }
.cw-plot > svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.cw-yl { position: absolute; left: -46px; top: 0; bottom: 0; width: 40px; }
.cw-yl span { position: absolute; right: 0; font-size: 11px; line-height: 14px; color: var(--cw-mute); white-space: nowrap; }
.cw-grid { stroke: var(--cw-line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.cw-ref { stroke: var(--tone); stroke-width: 1.5; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.cw-mark { stroke: var(--cw-ink); stroke-width: 1.5; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.cw-hov { stroke: var(--cw-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
.cw-ref-label { position: absolute; right: 4px; padding: 0 5px; border-radius: 4px; background: color-mix(in srgb, var(--cw-card) 90%, transparent); color: var(--tone-text); font-size: 11px; line-height: 14px; font-weight: 600; white-space: nowrap; }
.cw-off { position: absolute; left: 6px; top: 4px; padding: 1px 6px; border-radius: 4px; background: color-mix(in srgb, var(--cw-card) 92%, transparent); font-size: 11px; font-weight: 600; color: var(--cw-ink); }
.cw-plot.is-hover .cw-off { visibility: hidden; }
.cw-mark-label { position: absolute; bottom: 4px; padding: 1px 6px; border-radius: 4px; background: var(--cw-ink); color: var(--cw-bg); font-size: 11px; font-weight: 600; white-space: nowrap; transform: translateX(-50%); }
.cw-hdot { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--cw-blue); box-shadow: 0 0 0 2px var(--cw-card); pointer-events: none; }
.cw-tip { position: absolute; top: 6px; padding: 6px 10px; border-radius: 8px; background: var(--id-tooltip-bg); color: var(--id-tooltip-text); border: 1px solid var(--id-tooltip-border); box-shadow: 0 4px 14px var(--id-shadow); font-size: 12px; line-height: 1.35; white-space: nowrap; pointer-events: none; }
.cw-tip b { display: block; font-weight: 700; }
.cw-tip span { color: var(--id-tooltip-muted); }
.cw-touch { position: absolute; inset: 0; cursor: crosshair; touch-action: pan-y; }
.cw-xl { position: relative; height: 16px; margin-left: 46px; margin-right: 4px; }
.cw-xl span { position: absolute; top: 0; font-size: 11px; color: var(--cw-mute); white-space: nowrap; transform: translateX(-50%); }
.cw-note { font-size: 12px; color: var(--cw-mute2); }

@media (max-width: 600px) {
  .cw-wrap { gap: 22px; }
  .cw-scen-box { align-items: stretch; width: 100%; }
  .cw-seg { display: flex; }
  .cw-seg .id-seg-btn { flex: 1; padding: 0 8px; }
  .cw-ring { gap: 16px; padding: var(--id-card-pad); }
  .cw-ring-svg { width: 104px; height: 104px; }
  .cw-ring-word { font-size: var(--id-fs-number); }
  .cw-ring-cap { font-size: 13px; }
  .cw-dialog { padding: 8px; }
  .cw-panel { padding: 18px 16px; }
  .cw-d-num { font-size: var(--id-fs-number); }
  .cw-flags-about { margin-left: 0; }
  .cw-plot { height: 200px; margin-left: 40px; }
  .cw-yl { left: -40px; width: 36px; }
  .cw-xl { margin-left: 40px; }
}
@media (prefers-reduced-motion: no-preference) {
  .cw-ring, .cw-tile, .cw-cell-btn { transition: background-color 0.15s, border-color 0.15s; }
}
