:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #102033;
  --ink-soft: #3e5065;
  --muted: #65768a;
  --line: #dce4ed;
  --line-strong: #bac7d6;
  --navy: #173f6b;
  --blue: #2563a6;
  --teal: #0f766e;
  --green: #157347;
  --green-bg: #eaf7ef;
  --green-soft: #dff4e7;
  --green-medium: #bde8cc;
  --green-strong: #0f6a3e;
  --amber: #9a5d05;
  --amber-bg: #fff7df;
  --red: #b42318;
  --red-bg: #fff0ee;
  --slate-bg: #edf2f7;
  --shadow: 0 12px 32px rgba(16, 32, 51, 0.07);
  --radius: 16px;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #08111e;
    --surface: #101c2b;
    --surface-soft: #142235;
    --ink: #eff5fc;
    --ink-soft: #c4d0de;
    --muted: #91a3b8;
    --line: #25374b;
    --line-strong: #40566f;
    --navy: #7db7ef;
    --blue: #74b8ff;
    --teal: #5eead4;
    --green: #5dd39e;
    --green-bg: #103728;
    --green-soft: #123f2e;
    --green-medium: #17543c;
    --green-strong: #80e7b8;
    --amber: #ffd166;
    --amber-bg: #3b2d0e;
    --red: #ff8e86;
    --red-bg: #421c1d;
    --slate-bg: #1a2a3d;
    --shadow: 0 18px 42px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--blue) 7%, transparent), transparent 32rem),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
}

button, input, select { font: inherit; }

button, select, input { color: var(--ink); }

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--blue) 50%, transparent);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  transform: translateY(-150%);
  background: var(--ink);
  color: var(--surface);
  border-radius: 8px;
  padding: 8px 12px;
}

.skip-link:focus { transform: translateY(0); }

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 26px clamp(16px, 3vw, 42px) 70px;
}

.site-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 2px 22px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--teal);
  font: 700 0.72rem/1.2 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 4px;
  font-size: clamp(2rem, 5vw, 3.35rem);
  line-height: 1;
  letter-spacing: -0.045em;
}

h2 {
  margin-bottom: 5px;
  font-size: clamp(1.35rem, 2.3vw, 2rem);
  line-height: 1.18;
  letter-spacing: -0.025em;
}

h3 {
  margin-bottom: 10px;
  font-size: 1rem;
}

.deck { margin: 0; color: var(--ink-soft); max-width: 62ch; }

.header-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font: 0.76rem var(--mono);
  white-space: nowrap;
}

.paper-pill,
.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font: 700 0.7rem var(--mono);
  letter-spacing: 0.04em;
  padding: 5px 9px;
  text-transform: uppercase;
}

.health-banner {
  display: grid;
  grid-template-columns: auto minmax(250px, 1fr) auto;
  align-items: center;
  gap: 18px;
  border: 1px solid var(--line-strong);
  border-left-width: 6px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.health-icon { font-size: 1.35rem; }
.health-copy h2 { margin-bottom: 4px; font-size: 1.12rem; letter-spacing: 0; }
.health-copy p { margin-bottom: 0; }
.health-kicker { color: var(--muted); font: 700 0.67rem var(--mono); letter-spacing: 0.12em; text-transform: uppercase; }

.health-times {
  display: grid;
  grid-template-columns: repeat(4, minmax(105px, 1fr));
  gap: 18px;
  min-width: 550px;
}

.health-times div { border-left: 1px solid var(--line); padding-left: 14px; }
.health-times span { display: block; color: var(--muted); font-size: 0.72rem; }
.health-times strong { display: block; margin-top: 3px; overflow-wrap: anywhere; font: 650 0.78rem/1.35 var(--mono); }

.health-healthy { border-left-color: var(--green); background: linear-gradient(100deg, var(--green-bg), var(--surface) 45%); }
.health-healthy .health-icon { color: var(--green); }
.health-degraded, .health-stale { border-left-color: var(--amber); background: linear-gradient(100deg, var(--amber-bg), var(--surface) 45%); }
.health-degraded .health-icon, .health-stale .health-icon { color: var(--amber); }
.health-failed { border-left-color: var(--red); background: linear-gradient(100deg, var(--red-bg), var(--surface) 45%); }
.health-failed .health-icon { color: var(--red); }
.health-loading { border-left-color: var(--line-strong); }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(125px, 1fr));
  gap: 12px;
  margin: 14px 0 20px;
}

.metric-grid.compact { grid-template-columns: repeat(5, minmax(130px, 1fr)); }

.metric-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  padding: 14px 15px;
}

.metric-card span { display: block; color: var(--ink-soft); font-size: 0.77rem; }
.metric-card strong { display: block; margin: 2px 0; font: 700 clamp(1.35rem, 2.4vw, 2rem) var(--mono); letter-spacing: -0.04em; }
.metric-card small { display: block; color: var(--muted); font-size: 0.68rem; }

.tab-list {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px);
  padding: 5px;
  box-shadow: 0 5px 18px rgba(16, 32, 51, 0.05);
}

.tab-list button {
  flex: 0 0 auto;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 650;
  padding: 9px 14px;
}

.tab-list button[aria-selected="true"] { background: var(--navy); color: #fff; }

.tab-panel { padding: 28px 1px 10px; }

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 17px;
}

.section-heading > p { max-width: 60ch; margin-bottom: 2px; color: var(--muted); text-align: right; font-size: 0.83rem; }

.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.span-two { grid-column: span 2; }

.panel-card,
.state-section,
.cohort-definition,
.research-disclosure {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 7px 22px rgba(16, 32, 51, 0.035);
}

.panel-card { min-height: 165px; padding: 18px; }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.status-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font: 700 0.67rem var(--mono);
  padding: 5px 8px;
  text-transform: uppercase;
}

.status-chip.success, .status-chip.win, .status-chip.eligible { color: var(--green); background: var(--green-bg); }
.status-chip.failed, .status-chip.loss, .status-chip.expired { color: var(--red); background: var(--red-bg); }
.status-chip.overdue { color: var(--red); background: var(--red-bg); }
.status-chip.warning, .status-chip.pending, .status-chip.blocked, .status-chip.void { color: var(--amber); background: var(--amber-bg); }
.status-chip.neutral, .status-chip.cancelled, .status-chip.unknown { color: var(--ink-soft); background: var(--slate-bg); }

.run-funnel {
  display: grid;
  grid-template-columns: repeat(6, minmax(80px, 1fr));
  gap: 9px;
  margin-top: 14px;
}

.funnel-step { border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); padding: 11px; }
.funnel-step span { display: block; color: var(--muted); font-size: 0.68rem; }
.funnel-step strong { display: block; font: 700 1.2rem var(--mono); }
.funnel-step small { display: block; margin-top: 4px; color: var(--muted); font-size: 0.62rem; line-height: 1.35; }
.slate-funnel-card { min-height: 0; margin-bottom: 15px; }
.slate-funnel { grid-template-columns: repeat(4, minmax(100px, 1fr)); }
.performance-population-card { min-height: 0; margin: 16px 0; }
.performance-population-map { grid-template-columns: repeat(6, minmax(115px, 1fr)); }
.compact-note { margin: 6px 0 12px; font-size: 0.72rem; line-height: 1.45; }

.definition-list { margin: 0; }
.definition-list div { display: flex; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); padding: 8px 0; }
.definition-list div:last-child { border-bottom: 0; }
.definition-list dt { color: var(--muted); font-size: 0.76rem; }
.definition-list dd { margin: 0; text-align: right; font: 650 0.73rem var(--mono); }

.reason-list { display: grid; gap: 8px; }
.reason-row { display: flex; justify-content: space-between; gap: 12px; color: var(--ink-soft); font-size: 0.76rem; }
.reason-row strong { font-family: var(--mono); }

.state-section { margin-bottom: 15px; padding: 18px; }
.state-heading, .disclosure > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.state-heading > div, .disclosure > summary > span:first-child { display: flex; align-items: center; gap: 9px; }
.state-heading h3 { margin: 0; }
.state-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.state-dot.eligible { background: var(--green); }
.state-dot.blocked { background: var(--amber); }
.state-dot.expired { background: var(--red); }
.section-note { margin: 6px 0 14px; color: var(--muted); font-size: 0.78rem; }
.disclosure > summary { cursor: pointer; font-weight: 700; list-style: none; }
.disclosure > summary::-webkit-details-marker { display: none; }

.match-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 385px), 1fr)); gap: 12px; }

.match-card {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-soft);
  overflow: hidden;
}

.match-card.eligible { border-left: 4px solid var(--green); }
.match-card.blocked { border-left: 4px solid var(--amber); }
.match-card.expired { border-left: 4px solid var(--red); opacity: 0.9; }
.match-card-header { display: flex; justify-content: space-between; gap: 12px; padding: 14px 14px 9px; }
.match-card-header h4 { margin: 0 0 3px; font-size: 0.94rem; }
.match-meta { color: var(--muted); font: 0.68rem/1.5 var(--mono); }
.match-time { text-align: right; white-space: nowrap; font: 650 0.72rem/1.4 var(--mono); }
.match-time small { display: block; color: var(--muted); font-weight: 400; }

.match-probs { display: grid; grid-template-columns: repeat(4, 1fr); border-block: 1px solid var(--line); }
.prob-cell { padding: 9px 10px; border-right: 1px solid var(--line); }
.prob-cell:last-child { border-right: 0; }
.prob-cell span { display: block; color: var(--muted); font-size: 0.63rem; text-transform: uppercase; }
.prob-cell strong { font: 700 0.84rem var(--mono); }

.match-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; }
.match-reasons { margin: 0; padding-left: 16px; color: var(--ink-soft); font-size: 0.73rem; }
.lineage-button, .secondary-button, .pagination button {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 650;
  padding: 6px 9px;
}

.lineage-button:hover, .secondary-button:hover, .pagination button:hover { border-color: var(--blue); color: var(--blue); }
.match-lineage { border-top: 1px solid var(--line); padding: 11px 14px 14px; }
.match-lineage summary { cursor: pointer; color: var(--blue); font-size: 0.73rem; font-weight: 650; }
.lineage-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 16px; margin-top: 10px; }
.lineage-grid div span { display: block; color: var(--muted); font-size: 0.62rem; }
.lineage-grid div code { display: block; overflow-wrap: anywhere; color: var(--ink-soft); font: 0.66rem var(--mono); }

.notice, .callout {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink-soft);
  margin: 0 0 14px;
  padding: 11px 13px;
  font-size: 0.78rem;
}
.notice.warning, .callout { border-color: color-mix(in srgb, var(--amber) 45%, var(--line)); background: var(--amber-bg); }
.notice.failed { border-color: color-mix(in srgb, var(--red) 45%, var(--line)); background: var(--red-bg); }
.notice.success { border-color: color-mix(in srgb, var(--green) 45%, var(--line)); background: var(--green-bg); }
.notice.neutral { background: var(--slate-bg); }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.field-label { display: grid; gap: 5px; color: var(--ink-soft); font-size: 0.72rem; font-weight: 650; }
.field-label select, .field-label input { min-width: 220px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); padding: 8px 10px; }
.performance-controls { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.cohort-definition { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 14px 0; padding: 13px 15px; color: var(--ink-soft); font-size: 0.75rem; }
.cohort-definition strong { color: var(--ink); font-family: var(--mono); }

.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
  gap: 14px;
  margin: 15px 0;
}

.analytics-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 17px;
}

.analytics-card h3 { margin: 0; font-size: 1.05rem; }
.metric-overview-card { min-height: 0; margin: 15px 0; }
.metric-overview-grid { display: grid; grid-template-columns: repeat(3, minmax(235px, 1fr)); gap: 10px; }
.metric-overview-item { min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); padding: 12px; }
.metric-overview-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.metric-overview-heading strong { font-size: 0.8rem; }
.metric-overview-heading span { color: var(--muted); text-align: right; font: 0.59rem var(--mono); }
.metric-overview-rows { display: grid; gap: 7px; }
.metric-overview-row { display: grid; grid-template-columns: minmax(104px, 1fr) minmax(72px, 1.4fr) 48px; align-items: center; gap: 7px; }
.metric-overview-model { min-width: 0; overflow: hidden; color: var(--ink-soft); font-size: 0.65rem; font-weight: 650; }
.metric-overview-track { position: relative; height: 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.metric-overview-track::before { position: absolute; inset-block: -2px; left: var(--target-position, -100%); width: 1px; content: ""; background: var(--line-strong); }
.metric-overview-dot { position: absolute; top: 50%; width: 9px; height: 9px; border: 2px solid var(--surface); border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 1px var(--line-strong); transform: translate(-50%, -50%); }
.metric-overview-dot.good { background: var(--green); }
.metric-overview-dot.bad { background: var(--red); }
.metric-overview-dot.warning { background: var(--amber); }
.metric-overview-value { text-align: right; font: 700 0.63rem var(--mono); }
.metric-overview-axis { display: flex; justify-content: space-between; margin: 6px 48px 0 111px; color: var(--muted); font: 0.54rem var(--mono); }
.scalar-explorer-card { margin: 15px 0; }
.roc-comparison-card { margin: 15px 0; }
.metric-chart { display: grid; gap: 9px; min-height: 120px; }
.metric-bar-row { display: grid; grid-template-columns: minmax(190px, 1.25fr) minmax(150px, 2fr) 72px; align-items: center; gap: 9px; }
.metric-bar-label { min-width: 0; overflow: hidden; color: var(--ink-soft); font-size: 0.72rem; font-weight: 650; }
.metric-label-primary, .metric-label-version { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.metric-label-version { margin-top: 2px; color: var(--muted); font: 600 0.56rem var(--mono); }
.metric-bar-track { position: relative; height: 17px; overflow: hidden; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-soft); }
.metric-bar-track.diverging::after { position: absolute; inset-block: 0; left: 50%; width: 1px; content: ""; background: var(--line-strong); }
.metric-bar { position: absolute; inset-block: 2px; min-width: 2px; border-radius: 999px; background: var(--blue); }
.metric-bar.good { background: var(--green); }
.metric-bar.bad { background: var(--red); }
.metric-bar.warning { background: var(--amber); }
.metric-bar-value { text-align: right; font: 700 0.72rem var(--mono); }
.roc-chart svg, .calibration-chart svg, .odds-chart svg { display: block; width: 100%; height: auto; }
.chart-axis { stroke: var(--line-strong); stroke-width: 1; }
.chart-grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.chart-perfect { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 6 5; }
.chart-line-p1 { fill: none; stroke: var(--blue); stroke-width: 3; }
.chart-line-p2 { fill: none; stroke: var(--amber); stroke-width: 3; }
.chart-point-p1 { fill: var(--blue); stroke: var(--surface); stroke-width: 2; }
.chart-point-p2 { fill: var(--amber); stroke: var(--surface); stroke-width: 2; }
.chart-calibration-line { fill: none; stroke: var(--teal); stroke-width: 3; }
.chart-calibration-point { fill: var(--teal); stroke: var(--surface); stroke-width: 2; }
.chart-roc-line { fill: none; stroke: var(--blue); stroke-linecap: round; stroke-linejoin: round; stroke-width: 3; }
.chart-roc-point { fill: var(--blue); stroke: var(--surface); stroke-width: 1.5; }
.chart-calibration-line.replay, .chart-roc-line.replay { stroke: var(--amber); stroke-dasharray: 8 6; }
.chart-calibration-point.replay, .chart-roc-point.replay { fill: var(--amber); }
.curve-model-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 7px; margin: 12px 0; }
.curve-model-option { display: grid; grid-template-columns: 16px 10px minmax(0, 1fr); align-items: center; gap: 7px; min-height: 42px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); color: var(--ink-soft); cursor: pointer; }
.curve-model-option:hover { border-color: var(--line-strong); background: var(--surface); }
.curve-model-option:has(input:checked) { border-color: color-mix(in srgb, var(--curve-color, var(--blue)) 65%, var(--line)); box-shadow: inset 3px 0 0 var(--curve-color, var(--blue)); }
.curve-model-option input { margin: 0; accent-color: var(--curve-color, var(--blue)); }
.curve-model-swatch { width: 9px; height: 9px; border-radius: 999px; background: var(--curve-color, var(--blue)); }
.curve-model-copy { min-width: 0; }
.curve-model-copy strong, .curve-model-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.curve-model-copy strong { color: var(--ink); font-size: 0.65rem; }
.curve-model-copy small { margin-top: 2px; color: var(--muted); font: 0.54rem var(--mono); }
.curve-smooth-toggle { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-soft); font-size: 0.64rem; font-weight: 650; }
.curve-smooth-toggle input { accent-color: var(--blue); }
.curve-legend { display: grid; gap: 7px; margin-top: 10px; }
.curve-legend-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 0.64rem; }
.curve-legend-row .curve-model-swatch { width: 11px; height: 3px; border-radius: 999px; }
.curve-legend-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.curve-legend-row span:last-child { color: var(--muted); font: 0.58rem var(--mono); }
.chart-roc-comparison-line { fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 3; }
.chart-roc-comparison-point { stroke: var(--surface); stroke-width: 1.2; }
.curve-loading-note { margin: 8px 0 0; color: var(--muted); font: 0.58rem var(--mono); }
.chart-label { fill: var(--muted); font: 10px var(--mono); }
.chart-empty { display: grid; min-height: 180px; place-items: center; border: 1px dashed var(--line-strong); border-radius: 12px; color: var(--muted); font-size: 0.76rem; text-align: center; padding: 20px; }
.curve-summary { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px; }
.curve-summary strong { color: var(--ink); font: 750 0.82rem var(--mono); }
.curve-summary span { color: var(--muted); font: 0.64rem var(--mono); text-align: right; }

.table-shell { overflow: auto; max-width: 100%; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
caption { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
th, td { border-bottom: 1px solid var(--line); padding: 10px 12px; text-align: right; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 1; background: var(--surface-soft); color: var(--muted); font: 700 0.65rem var(--mono); letter-spacing: 0.05em; text-transform: uppercase; }
th[data-sort-field] { padding: 0; }
.sort-button {
  display: inline-flex;
  width: 100%;
  min-height: 38px;
  box-sizing: border-box;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  letter-spacing: inherit;
  padding: 10px 12px;
  text-align: inherit;
  text-transform: inherit;
}
th:nth-child(1) .sort-button, th:nth-child(2) .sort-button, th:nth-child(3) .sort-button { justify-content: flex-start; }
.sort-button:hover { color: var(--ink); background: color-mix(in srgb, var(--blue) 7%, transparent); }
.sort-button:focus-visible { position: relative; z-index: 2; outline: 2px solid var(--blue); outline-offset: -3px; }
.sort-mark { min-width: 1em; color: var(--muted); font-size: 0.7rem; text-align: center; }
th.sorted .sort-button, th.sorted .sort-mark { color: var(--blue); }
td { font: 0.73rem var(--mono); }
th:nth-child(1), td:nth-child(1), th:nth-child(2), td:nth-child(2), th:nth-child(3), td:nth-child(3) { text-align: left; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--blue) 4%, var(--surface)); }
.cell-primary { color: var(--ink); font-family: var(--sans); font-weight: 650; }
.cell-secondary { display: block; color: var(--muted); font: 0.66rem var(--mono); }
.numeric-good { color: var(--green); }
.numeric-bad { color: var(--red); }
.numeric-warning { color: var(--amber); }
.version-context-note { margin: 15px 0 8px; }
.sort-note { margin: 8px 2px; }
.signal-good { color: var(--green); background: color-mix(in srgb, var(--green-bg) 72%, transparent); font-weight: 750; }
.signal-bad { color: var(--red); background: color-mix(in srgb, var(--red-bg) 72%, transparent); font-weight: 750; }
.signal-warning { color: var(--amber); background: color-mix(in srgb, var(--amber-bg) 72%, transparent); font-weight: 750; }
.model-name { display: flex; align-items: center; gap: 7px; min-width: 190px; }
.model-name strong { font-family: var(--sans); font-size: 0.76rem; }
.role-badge { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font: 700 0.58rem var(--mono); padding: 2px 6px; text-transform: uppercase; }
.role-badge.shadow { border-color: color-mix(in srgb, var(--teal) 45%, var(--line)); color: var(--teal); }
.role-badge.benchmark { border-color: color-mix(in srgb, var(--blue) 45%, var(--line)); color: var(--blue); }
.role-badge.promoted { border-color: color-mix(in srgb, var(--green) 45%, var(--line)); color: var(--green); }
.role-badge.candidate, .role-badge.shadow_candidate, .role-badge.forward { border-color: color-mix(in srgb, var(--teal) 45%, var(--line)); color: var(--teal); }
.role-badge.archived { color: var(--muted); }
.role-badge.replay { border-color: color-mix(in srgb, var(--amber) 55%, var(--line)); background: color-mix(in srgb, var(--amber-bg) 70%, transparent); color: var(--amber); }
.version-cell { color: var(--ink); font-weight: 750; }
.candidate-evidence-section { margin-top: 26px; border-top: 1px solid var(--line-strong); padding-top: 22px; }
.compact-heading { margin-bottom: 11px; }
.candidate-cohort-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; margin: 10px 0; }
.candidate-cohort-card { border: 1px solid var(--line); border-radius: 12px; padding: 13px; background: var(--surface); }
.candidate-cohort-card.forward { border-color: color-mix(in srgb, var(--teal) 45%, var(--line)); background: color-mix(in srgb, var(--teal) 5%, var(--surface)); }
.candidate-cohort-card.replay { border-color: color-mix(in srgb, var(--amber) 45%, var(--line)); background: color-mix(in srgb, var(--amber-bg) 58%, var(--surface)); }
.candidate-cohort-card span { display: block; color: var(--muted); font: 750 0.64rem var(--mono); text-transform: uppercase; }
.candidate-cohort-card strong { display: block; margin: 5px 0 3px; font-size: 1.06rem; }
.candidate-cohort-card small { color: var(--ink-soft); font-size: 0.68rem; }
.candidate-status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; margin: 10px 0 14px; }
.candidate-status-card { border: 1px solid color-mix(in srgb, var(--teal) 35%, var(--line)); border-radius: 12px; background: color-mix(in srgb, var(--teal) 4%, var(--surface)); padding: 13px; }
.candidate-status-card span { display: block; color: var(--muted); font: 700 0.64rem var(--mono); text-transform: uppercase; }
.candidate-status-card strong { display: block; margin: 5px 0 3px; font-size: 1rem; }
.candidate-status-card small { color: var(--ink-soft); font-size: 0.66rem; }
.candidate-diagnostics { grid-template-columns: minmax(0, 1fr); margin-top: 14px; }
.replay-row td { background-color: color-mix(in srgb, var(--amber-bg) 74%, var(--surface)); background-image: repeating-linear-gradient(135deg, transparent 0, transparent 9px, color-mix(in srgb, var(--amber) 5%, transparent) 9px, color-mix(in srgb, var(--amber) 5%, transparent) 12px); }
.candidate-row td { background: color-mix(in srgb, var(--teal) 3%, var(--surface)); }
.catalog-notes { min-width: 330px; max-width: 520px; white-space: normal; line-height: 1.35; }
.research-disclosure { margin-top: 15px; padding: 13px 15px; }
.research-disclosure summary { cursor: pointer; font-weight: 700; }
.research-disclosure p { margin: 9px 0 0; color: var(--muted); font-size: 0.78rem; }
.pagination { display: flex; justify-content: center; margin-top: 14px; }

.tournament-stack { display: grid; gap: 14px; }
.tournament-group { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.tournament-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); background: linear-gradient(100deg, color-mix(in srgb, var(--blue) 7%, var(--surface)), var(--surface)); padding: 13px 15px; }
.tournament-heading h4 { margin: 0; font-size: 1rem; }
.tournament-heading p { margin: 2px 0 0; color: var(--muted); font: 0.68rem var(--mono); }
.tournament-summary { color: var(--ink-soft); text-align: right; font: 700 0.67rem var(--mono); }
.tournament-matches { display: grid; }

.match-card { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: var(--surface); }
.match-card:last-child { border-bottom: 0; }
.match-card.eligible, .match-card.blocked, .match-card.expired { border-left-width: 4px; }
.match-card-header { background: var(--surface-soft); padding: 11px 14px 8px; }
.match-board-shell { overflow-x: auto; }
.match-board { min-width: 760px; table-layout: fixed; }
.match-board th, .match-board td { padding: 8px 10px; }
.match-board th { position: static; font-size: 0.58rem; }
.match-board th:first-child, .match-board td:first-child { width: 29%; text-align: left; }
.match-board th:not(:first-child), .match-board td:not(:first-child) { text-align: right; }
.match-board tbody tr:last-child td { border-bottom: 0; }
.player-cell { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.player-identity { min-width: 0; }
.player-identity strong { display: block; font-family: var(--sans); font-size: 0.82rem; line-height: 1.25; }
.player-identity span { display: block; color: var(--muted); font: 0.61rem var(--mono); }
.player-row.edge-positive-low td { background: color-mix(in srgb, var(--green-soft) 45%, var(--surface)); }
.player-row.edge-positive-medium td { background: color-mix(in srgb, var(--green-medium) 55%, var(--surface)); }
.player-row.edge-positive-strong td { background: color-mix(in srgb, var(--green-medium) 82%, var(--surface)); }
.player-row.edge-positive-strong .edge-value { color: var(--green-strong); font-weight: 850; }
.player-row.edge-negative .edge-value { color: var(--red); }
.player-row.edge-watch .edge-value { color: var(--amber); }
.edge-value { display: block; font-weight: 750; }
.edge-label { display: block; color: var(--muted); font: 0.56rem var(--mono); }
.price-cell strong { display: block; }
.price-cell span { display: block; color: var(--muted); font-size: 0.59rem; }
.match-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.market-path-button { border: 1px solid color-mix(in srgb, var(--blue) 40%, var(--line)); border-radius: 8px; background: color-mix(in srgb, var(--blue) 7%, var(--surface)); color: var(--blue); cursor: pointer; font-size: 0.7rem; font-weight: 700; padding: 6px 9px; }
.market-path-button:hover { background: color-mix(in srgb, var(--blue) 13%, var(--surface)); }

.odds-dialog-body { padding: 18px 20px 24px; }
.odds-summary-grid { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 9px; margin-bottom: 14px; }
.odds-summary-card { border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); padding: 10px; }
.odds-summary-card span { display: block; color: var(--muted); font-size: 0.63rem; }
.odds-summary-card strong { display: block; margin-top: 2px; font: 750 0.82rem var(--mono); }
.chart-legend { display: flex; gap: 15px; margin: 8px 0; color: var(--ink-soft); font-size: 0.7rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--blue); }
.legend-dot.p2 { background: var(--amber); }
.odds-chart { border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); padding: 10px; }
.odds-observations { margin-top: 13px; }

.inventory-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 15px 0; }
.inventory-card { border: 1px solid var(--line); border-radius: 11px; background: var(--surface); padding: 12px; }
.inventory-card span { display: block; color: var(--muted); font-size: 0.69rem; }
.inventory-card strong { display: block; margin-top: 2px; font: 700 1.12rem var(--mono); }
.inventory-card small { color: var(--muted); font-size: 0.64rem; }

dialog {
  width: min(920px, calc(100vw - 28px));
  max-height: min(82vh, 900px);
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.32);
  padding: 0;
}

dialog::backdrop { background: rgba(5, 15, 28, 0.62); backdrop-filter: blur(4px); }
.dialog-header { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); background: var(--surface); padding: 17px 20px; }
.dialog-header h2 { margin: 0; font-size: 1.25rem; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface-soft); cursor: pointer; font-size: 1.35rem; line-height: 1; }
#feature-dialog-body { padding: 18px 20px 24px; }
.feature-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 9px; margin-bottom: 16px; }
.feature-meta div { border: 1px solid var(--line); border-radius: 9px; padding: 9px; }
.feature-meta span { display: block; color: var(--muted); font-size: 0.64rem; }
.feature-meta code { overflow-wrap: anywhere; font: 0.69rem var(--mono); }
.feature-groups { columns: 2; column-gap: 14px; }
.feature-group { break-inside: avoid; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; padding: 10px; }
.feature-group h3 { font-size: 0.8rem; }
.feature-row { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding: 5px 0; font-size: 0.69rem; }
.feature-row code { overflow-wrap: anywhere; }

footer { border-top: 1px solid var(--line); margin-top: 32px; padding-top: 17px; color: var(--muted); font-size: 0.74rem; }
.noscript { margin: 20px; border: 1px solid var(--red); border-radius: 10px; background: var(--red-bg); padding: 14px; }
.empty-state { border: 1px dashed var(--line-strong); border-radius: 11px; color: var(--muted); padding: 22px; text-align: center; font-size: 0.78rem; }
.skeleton { min-height: 72px; background: linear-gradient(90deg, var(--surface-soft), var(--slate-bg), var(--surface-soft)); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 1050px) {
  .health-banner { grid-template-columns: auto 1fr; }
  .health-times { grid-column: 1 / -1; min-width: 0; }
  .metric-grid, .metric-grid.compact { grid-template-columns: repeat(3, minmax(130px, 1fr)); }
  .overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-overview-grid { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
  .analytics-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .app-shell { padding-inline: 12px; padding-top: 12px; }
  .site-header, .section-heading { align-items: flex-start; flex-direction: column; gap: 10px; }
  .header-meta { width: 100%; justify-content: space-between; white-space: normal; }
  .health-banner { grid-template-columns: 1fr; padding: 15px; }
  .health-icon { display: none; }
  .health-times { grid-template-columns: 1fr; gap: 7px; }
  .health-times div { border-left: 0; border-top: 1px solid var(--line); padding: 7px 0 0; }
  .metric-grid, .metric-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tab-list { top: 0; border-radius: 10px; }
  .tab-list button { padding: 8px 11px; }
  .section-heading > p { text-align: left; }
  .overview-grid { grid-template-columns: 1fr; }
  .span-two { grid-column: auto; }
  .run-funnel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .match-grid { grid-template-columns: 1fr; }
  .match-card-header { align-items: flex-start; flex-direction: column; }
  .match-time { text-align: left; }
  .match-probs { grid-template-columns: repeat(2, 1fr); }
  .prob-cell:nth-child(2) { border-right: 0; }
  .prob-cell:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .lineage-grid { grid-template-columns: 1fr; }
  .field-label, .field-label select, .field-label input { width: 100%; min-width: 0; }
  .performance-controls { width: 100%; }
  .metric-overview-grid { grid-template-columns: 1fr; }
  .metric-overview-row { grid-template-columns: minmax(96px, 1fr) minmax(72px, 1.4fr) 48px; }
  .metric-overview-axis { margin-left: 103px; }
  .metric-bar-row { grid-template-columns: minmax(142px, 1.1fr) minmax(100px, 1.5fr) 62px; }
  .tournament-heading { align-items: flex-start; }
  .tournament-summary { max-width: 42%; }
  .match-board { min-width: 0; }
  .match-board th, .match-board td { padding: 7px 6px; }
  .match-board th:nth-child(3), .match-board td:nth-child(3),
  .match-board th:nth-child(5), .match-board td:nth-child(5),
  .match-board th:nth-child(6), .match-board td:nth-child(6) { display: none; }
  .match-board th:first-child, .match-board td:first-child { width: 39%; }
  .match-board th:nth-child(2), .match-board td:nth-child(2) { width: 23%; }
  .match-board th:nth-child(4), .match-board td:nth-child(4) { width: 15%; }
  .match-board th:nth-child(7), .match-board td:nth-child(7) { width: 23%; }
  .odds-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .feature-groups { columns: 1; }
}

@media (max-width: 430px) {
  .metric-grid, .metric-grid.compact { grid-template-columns: 1fr 1fr; }
  .metric-card:last-child { grid-column: 1 / -1; }
  .performance-population-map { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
