:root {
  --paper: #F6F7FA;
  --surface: #FFFFFF;
  --surface-2: #EDF0F5;
  --ink: #16223E;
  --ink-muted: #5C6B85;
  --line: #DEE3EC;
  --accent: #C41E3A;
  --accent-ink: #FFFFFF;
  --good: #1E8A5F;
  --good-bg: #E3F3EC;
  --warn: #B7791E;
  --warn-bg: #FBF0DC;
  --bad: #C41E3A;
  --bad-bg: #F8E4E8;
  --series-wm: #E0923C;
  --series-mm: #2E6F8E;
  --series-total: #16223E;
  --season-winter: #3B6FA0;
  --season-spring: #4C9A63;
  --season-summer: #D9A02C;
  --season-fall: #A8412E;
  --shadow: 0 1px 2px rgba(22, 34, 62, 0.06), 0 1px 1px rgba(22, 34, 62, 0.04);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0C1220;
    --surface: #151D30;
    --surface-2: #1C2540;
    --ink: #E8ECF6;
    --ink-muted: #94A3C2;
    --line: #2A3454;
    --accent: #FF5470;
    --accent-ink: #1A0810;
    --good: #3FBE8B;
    --good-bg: #163329;
    --warn: #E0A83C;
    --warn-bg: #332711;
    --bad: #FF6B7F;
    --bad-bg: #33141B;
    --series-wm: #F0A75C;
    --series-mm: #5FA8CF;
    --series-total: #E8ECF6;
    --season-winter: #6FA8D9;
    --season-spring: #6FC98A;
    --season-summer: #E8C05C;
    --season-fall: #D9705A;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 1px rgba(0, 0, 0, 0.2);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #0C1220;
  --surface: #151D30;
  --surface-2: #1C2540;
  --ink: #E8ECF6;
  --ink-muted: #94A3C2;
  --line: #2A3454;
  --accent: #FF5470;
  --accent-ink: #1A0810;
  --good: #3FBE8B;
  --good-bg: #163329;
  --warn: #E0A83C;
  --warn-bg: #332711;
  --bad: #FF6B7F;
  --bad-bg: #33141B;
  --series-wm: #F0A75C;
  --series-mm: #5FA8CF;
  --series-total: #E8ECF6;
  --season-winter: #6FA8D9;
  --season-spring: #6FC98A;
  --season-summer: #E8C05C;
  --season-fall: #D9705A;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 1px rgba(0, 0, 0, 0.2);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --paper: #F6F7FA;
  --surface: #FFFFFF;
  --surface-2: #EDF0F5;
  --ink: #16223E;
  --ink-muted: #5C6B85;
  --line: #DEE3EC;
  --accent: #C41E3A;
  --accent-ink: #FFFFFF;
  --good: #1E8A5F;
  --good-bg: #E3F3EC;
  --warn: #B7791E;
  --warn-bg: #FBF0DC;
  --bad: #C41E3A;
  --bad-bg: #F8E4E8;
  --series-wm: #E0923C;
  --series-mm: #2E6F8E;
  --series-total: #16223E;
  --season-winter: #3B6FA0;
  --season-spring: #4C9A63;
  --season-summer: #D9A02C;
  --season-fall: #A8412E;
  --shadow: 0 1px 2px rgba(22, 34, 62, 0.06), 0 1px 1px rgba(22, 34, 62, 0.04);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
button:focus-visible, input:focus-visible, th[role="button"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.num { font-variant-numeric: tabular-nums; font-family: var(--mono); }

/* ---------- Header ---------- */

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
}

.brand .mark {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.freshness {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  font-family: var(--mono);
  color: var(--ink-muted);
  line-height: 1.3;
}

#freshness-date { font-size: 12px; }
#freshness-time { font-size: 10.5px; opacity: 0.75; }

#theme-toggle {
  font-family: var(--sans);
  font-size: 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
}
#theme-toggle:hover { border-color: var(--ink-muted); }

/* ---------- Page ---------- */

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  margin: 4px 0 0;
  text-wrap: balance;
}

.page-sub {
  color: var(--ink-muted);
  font-size: 14px;
  margin: 0;
}

.update-schedule {
  color: var(--ink-muted);
  font-size: 13px;
  margin-top: 8px;
}
.update-schedule p { margin: 0; }
.update-schedule ul {
  margin: 4px 0 0;
  padding-left: 18px;
}
.update-schedule li { margin: 2px 0; }

/* ---------- KPI strip ---------- */

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.kpi {
  background: var(--surface);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.kpi-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.kpi-value-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.kpi-value {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.kpi-aside {
  font-size: 11px;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.kpi-detail {
  font-size: 12.5px;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-detail.up { color: var(--good); }
.kpi-detail.down { color: var(--bad); }

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 18px 20px 20px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.card-head h2 {
  font-size: 15px;
  margin: 0 0 3px;
}

.card-head p {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-muted);
}

.card-head p + p { margin-top: 2px; }

.card-body { overflow-x: auto; }

/* ---------- Chart controls (view/metric toggles, detail checkbox) ---------- */

.chart-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.detail-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-muted);
  cursor: pointer;
  user-select: none;
}

.detail-toggle input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* ---------- Segmented control ---------- */

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  flex-shrink: 0;
}

.segmented button {
  font-family: var(--sans);
  font-size: 12.5px;
  padding: 6px 11px;
  border: none;
  background: var(--surface);
  color: var(--ink-muted);
  cursor: pointer;
  border-right: 1px solid var(--line);
}
.segmented button:last-child { border-right: none; }
.segmented button:hover { background: var(--surface-2); }
.segmented button.active {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

/* ---------- Heatmap ---------- */

table.heatmap {
  border-collapse: collapse;
  table-layout: fixed;
  width: 100%;
  min-width: 480px;
}

table.heatmap th, table.heatmap td {
  padding: 5px 8px;
  text-align: center;
  font-size: 12px;
}

table.heatmap thead th {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  text-transform: uppercase;
  font-weight: 600;
}

table.heatmap tbody th {
  font-family: var(--mono);
  text-align: right;
  padding-right: 12px;
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
}

table.heatmap td {
  font-family: var(--mono);
  border-radius: 5px;
  transition: outline-color 0.1s ease;
}

table.heatmap td.cell {
  cursor: default;
}

table.heatmap td.cell:hover {
  outline: 1.5px solid var(--accent);
  outline-offset: -1.5px;
}

/* Any cell with at least one contributing event opens the drill-down
   modal on click - .empty cells (no row at all, the "–" placeholder)
   are deliberately excluded since there's nothing to show. */
table.heatmap td.clickable {
  cursor: pointer;
}

table.heatmap td.clickable:hover {
  outline: 1.5px solid var(--accent);
  outline-offset: -1.5px;
}

table.heatmap td.empty {
  color: var(--ink-muted);
  opacity: 0.4;
}

/* WM/MM detail mode: two-row header (season colspan=2, then WM/MM
   sub-header) with a vertical divider bracketing each season's pair -
   same pattern as the grouped Accepted/Waitlisted/Incomplete headers on
   the events tables. border-collapse merges the group-head's own
   left/right border with the matching grp-start/grp-end border on every
   body cell into one continuous line. */
table.heatmap thead th.group-head {
  text-align: center;
  cursor: default;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

table.heatmap th.grp-start, table.heatmap td.grp-start { border-left: 1px solid var(--line); }
table.heatmap th.grp-end, table.heatmap td.grp-end { border-right: 1px solid var(--line); }

/* ---------- Modal (heatmap cell drill-down) ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 26, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 900px;
  max-height: min(600px, 80vh);
  display: flex;
  flex-direction: column;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 { font-size: 15px; margin: 0 0 3px; }

.modal-subtitle { margin: 0; font-size: 12.5px; color: var(--ink-muted); }

#modal-close {
  font-family: var(--sans);
  font-size: 20px;
  line-height: 1;
  color: var(--ink-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

#modal-close:hover { background: var(--surface-2); color: var(--ink); }

.modal-body { overflow: auto; padding: 4px 20px 16px; }

/* Unlike the main events tables, this table isn't sortable - override
   the inherited pointer cursor/hover color so headers don't look
   clickable when they aren't. */
#modal-table thead th { cursor: default; }
#modal-table thead th:hover { color: var(--ink-muted); }

/* ---------- Column chart (bar-per-season, alternative to the heatmap) ---------- */

.colchart-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.colchart-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  flex-shrink: 0;
  height: 180px;
  margin-bottom: 22px;
  padding-right: 4px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-muted);
}

.colchart-scroll {
  overflow-x: auto;
  flex: 1 1 auto;
  min-width: 0;
}

.colchart {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  min-width: 640px;
  height: 202px;
  padding: 0 4px;
  border-bottom: 1px solid var(--line);
}

.colchart .year-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1 0 auto;
  min-width: 44px;
}

.colchart .bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 180px;
}

.colchart .bar {
  width: 10px;
  border-radius: 2px 2px 0 0;
  position: relative;
  min-height: 1px;
}

.colchart .bar-stack {
  display: flex;
  flex-direction: column-reverse;
  width: 10px;
  border-radius: 2px 2px 0 0;
  overflow: hidden;
}

.colchart .bar-seg { width: 100%; }

.colchart .year-label {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-muted);
  white-space: nowrap;
  height: 16px;
  line-height: 16px;
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 11.5px;
  color: var(--ink-muted);
}

.heatmap-legend .swatch-scale {
  display: flex;
  gap: 2px;
}

.heatmap-legend .swatch-scale span {
  width: 14px;
  height: 10px;
  border-radius: 2px;
}

/* ---------- Bar charts (category / demographics) ---------- */

.barchart { display: flex; flex-direction: column; gap: 10px; }

.barchart .row {
  display: grid;
  grid-template-columns: 130px 1fr 64px;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
}

.barchart .row .label { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* The identity cards are narrower (half of .two-col) than other bar
   charts, and their "value" cell can show two numbers ("146 / 225") -
   the default 64px value column wraps that onto two lines, so widen it
   here and shrink the label column (a bare 4-digit year) plus the gap
   before the track, since 130px/12px left more empty space than a
   4-character year needs. */
#demographics-unique .barchart .row, #demographics-total .barchart .row {
  grid-template-columns: 36px 1fr 100px;
  gap: 6px;
}
#demographics-unique .barchart .value, #demographics-total .barchart .value {
  white-space: nowrap;
}

/* Event names here can run much longer than any other bar chart's labels
   ("Ultimate Study Hall - Fall Day Camp Series") - a fixed label column
   either truncates them or forces a wrap, so this card sizes the label
   column to `max-content` instead: always exactly as wide as the
   longest visible name, on one line, never truncated (the base
   .barchart .row .label's nowrap/ellipsis above become a no-op safety
   net, not something that actually triggers).

   Unlike every other bar chart on this dashboard, .barchart itself (not
   just each .row) is a grid here, with every .row subgridding its three
   columns from it via `grid-template-columns: subgrid`. That's what
   makes the label column's max-content width - and therefore the track
   and value columns next to it - identical across every row: each .row
   below is otherwise its own independent grid, so without subgrid, a
   row with a short name would size its own label column narrower and
   its bar wider than a row with a long name, making bar widths
   incomparable at a glance. Subgridding means every row shares one set
   of column tracks (sized once, from the single longest label among
   them all), so the track column - and therefore every bar's rendered
   width for a given percentage - lines up identically row to row. */
#pathways-result .barchart {
  display: grid;
  grid-template-columns: max-content 1fr 130px;
  row-gap: 10px;
}
#pathways-result .barchart .row {
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
}
#pathways-result .barchart .value {
  white-space: nowrap;
}

.barchart .track {
  position: relative;
  height: 20px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
}

.barchart .segment {
  height: 100%;
}

.barchart .value {
  font-family: var(--mono);
  text-align: right;
  color: var(--ink-muted);
}

/* ---------- Fill-rate strip ---------- */

.fillrate { display: flex; flex-direction: column; gap: 12px; }

.fillrate .row {
  display: grid;
  grid-template-columns: 1fr 120px 56px;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
}

.fillrate .ev-name { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fillrate .ev-year { color: var(--ink-muted); font-family: var(--mono); font-size: 11px; margin-left: 6px; }
.fillrate .ev-detail {
  font-size: 10.5px;
  color: var(--ink-muted);
  opacity: 0.8;
  margin-left: 8px;
}

.fillrate .track {
  position: relative;
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
}

.fillrate .fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  border-radius: 4px;
}

.fillrate .pct {
  font-family: var(--mono);
  text-align: right;
  color: var(--ink-muted);
}
.fillrate .pct.hot { color: var(--bad); font-weight: 700; }
.fillrate .pct.warm { color: var(--warn); font-weight: 700; }

/* ---------- Legend chips ---------- */

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink-muted);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* ---------- Table ---------- */

.table-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.table-controls input[type="search"] {
  font-family: var(--sans);
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  min-width: 220px;
}

.table-controls select {
  font-family: var(--sans);
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}

/* ---------- Multi-select filter dropdown ----------
   initMultiSelect() (app.js / admin.js) hides the real <select> and
   inserts this button+panel pair in its place - the button mimics the
   plain-select styling above so the filter row's layout doesn't shift. */

.multiselect { position: relative; display: inline-block; }

.multiselect-button {
  display: inline-flex;
  align-items: center;
  font-family: var(--sans);
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  min-width: 110px;
  white-space: nowrap;
}

.multiselect-button::after {
  content: "▾";
  margin-left: auto;
  padding-left: 10px;
  color: var(--ink-muted);
  font-size: 10px;
}

.multiselect-button.active { border-color: var(--accent); color: var(--accent); }
.multiselect-button.active::after { color: var(--accent); }

.multiselect-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  min-width: 100%;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 6px;
}

.multiselect-panel.hidden { display: none; }

.multiselect-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 5px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

.multiselect-option:hover { background: var(--surface-2); }

.multiselect-option input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }

/* ---------- Searchable single-select dropdown ----------
   initSearchableSelect() (app.js) hides the real <select> and inserts
   this text-input+panel pair in its place - for selects with far too
   many options to scan by eye (every event), so typing narrows the list
   instead of scrolling it. Panel styling mirrors .multiselect-panel
   above for visual consistency between the two dropdown patterns. */

/* min-width so the wrapper (a flex item in .table-controls, sized by
   its content otherwise) gets a sensible default size instead of
   shrinking to fit an empty/placeholder input - similar in spirit to
   .table-controls input[type="search"]'s own min-width above. */
.searchable-select { position: relative; min-width: 260px; }

.searchable-select-input {
  width: 100%;
  font-family: var(--sans);
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}

.searchable-select-input:disabled {
  color: var(--ink-muted);
  cursor: not-allowed;
}

.searchable-select-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 6px;
}

.searchable-select-panel.hidden { display: none; }

.searchable-select-option {
  padding: 6px 8px;
  border-radius: 5px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.searchable-select-option:hover { background: var(--surface-2); }

.searchable-select-empty {
  padding: 6px 8px;
  font-size: 13px;
  color: var(--ink-muted);
}

.table-scroll {
  max-height: 460px;
  overflow-y: auto;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table.events {
  border-collapse: collapse;
  width: 100%;
  font-size: 12.5px;
}

table.events thead th {
  position: sticky;
  top: 0;
  height: 32px;
  background: var(--surface-2);
  text-align: left;
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-muted);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  border-bottom: 1px solid var(--line);
}
table.events thead tr:nth-child(2) th { top: 32px; }
table.events thead th:hover { color: var(--ink); }
table.events thead th.sorted { color: var(--accent); }
table.events thead th.group-head {
  text-align: center;
  cursor: default;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}
table.events thead th.group-head:hover { color: var(--ink-muted); }

/* Vertical bars bracketing each status group (Accepted/Waitlisted/
   Incomplete) - .group-head (row 1) already brackets the whole colspan;
   .grp-start/.grp-end mark the first/last sub-column (row 2 + body td)
   so the same bar runs the full height of the table, not just the
   header. border-collapse merges these with the .group-head borders
   above into a single line rather than doubling it. */
table.events th.grp-start,
table.events td.grp-start { border-left: 1px solid var(--line); }
table.events th.grp-end,
table.events td.grp-end { border-right: 1px solid var(--line); }

table.events td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.events td.num { text-align: right; }
table.events th.num-center, table.events td.num-center { text-align: center; }
table.events tbody tr:last-child td { border-bottom: none; }
table.events tbody tr:hover { background: var(--surface-2); }

.category-pill {
  display: inline-block;
  font-family: var(--sans);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--ink-muted);
}

.results-count {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 8px;
}

/* ---------- Footer ---------- */

footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px 40px;
  font-size: 12px;
  color: var(--ink-muted);
  font-family: var(--mono);
}

/* ---------- Loading / empty ---------- */

.loading, .error {
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-muted);
  font-size: 13px;
}
.error { color: var(--bad); }

.two-col {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 24px;
}

.three-col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

/* ---------- Event participation ---------- */

.participation-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.participation-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 12px;
}

.participation-header i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* Per-year rows, same narrow-label/wide-value override as the identity
   cards - a bare 4-digit year doesn't need .barchart's default 130px
   label column, and the value here ("24.3% · 1.42x") is wider than a
   single number. */
.participation-col .barchart .row {
  grid-template-columns: 34px 1fr 104px;
  gap: 6px;
}
.participation-col .barchart .value { white-space: nowrap; }

@media (max-width: 760px) {
  .kpi-strip { grid-template-columns: 1fr; }
  .barchart .row, .fillrate .row { grid-template-columns: 100px 1fr 50px; }
  .two-col, .three-col { grid-template-columns: 1fr; }
  header.topbar { padding: 10px 16px; }
  .brand span:last-child { display: none; }
  #freshness-date { font-size: 11px; }
  #freshness-time { font-size: 9.5px; }
  main { padding: 20px 16px 60px; }
}
