:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #6b7280;
  --paper: #ffffff;
  --surface: #ffffff;
  --surface-subtle: #f9fafb;
  --surface-hover: #f3f4f6;
  --line: #e5e7eb;
  --line-soft: #f3f4f6;
  --line-strong: #d1d5db;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --focus: #3b82f6;
  --status-loading: #d97706;
  --status-loading-soft: #fef3c7;
  --status-ready: #059669;
  --status-error: #dc2626;
  --status-error-soft: #fee2e2;
  --warning: #a16207;
  --code-ink: #374151;
  --code-surface: #f3f4f6;
  --chart-accent: #2563eb;
  --chart-positive: #059669;
  --chart-negative: #dc2626;
  --chart-neutral: #111827;
  --chart-selected: #f59e0b;
  --chart-fill: #dbeafe;
  --plot-stroke: #ffffff;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e5e7eb;
  --muted: #9ca3af;
  --paper: #0b0f19;
  --surface: #111827;
  --surface-subtle: #0f172a;
  --surface-hover: #1f2937;
  --line: #1f2937;
  --line-soft: #172033;
  --line-strong: #374151;
  --accent: #60a5fa;
  --accent-soft: #172554;
  --focus: #3b82f6;
  --status-loading: #fbbf24;
  --status-loading-soft: #422006;
  --status-ready: #34d399;
  --status-error: #f87171;
  --status-error-soft: #450a0a;
  --warning: #fbbf24;
  --code-ink: #d1d5db;
  --code-surface: #1f2937;
  --chart-accent: #60a5fa;
  --chart-positive: #34d399;
  --chart-negative: #f87171;
  --chart-neutral: #f9fafb;
  --chart-selected: #fbbf24;
  --chart-fill: #1e3a5f;
  --plot-stroke: #0b0f19;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink: #e5e7eb;
    --muted: #9ca3af;
    --paper: #0b0f19;
    --surface: #111827;
    --surface-subtle: #0f172a;
    --surface-hover: #1f2937;
    --line: #1f2937;
    --line-soft: #172033;
    --line-strong: #374151;
    --accent: #60a5fa;
    --accent-soft: #172554;
    --focus: #3b82f6;
    --status-loading: #fbbf24;
    --status-loading-soft: #422006;
    --status-ready: #34d399;
    --status-error: #f87171;
    --status-error-soft: #450a0a;
    --warning: #fbbf24;
    --code-ink: #d1d5db;
    --code-surface: #1f2937;
    --chart-accent: #60a5fa;
    --chart-selected: #fbbf24;
    --chart-fill: #1e3a5f;
    --plot-stroke: #0b0f19;
  }
}

* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-width: 320px;
}
a {
  color: inherit;
  text-underline-offset: 3px;
}

.charts-view {
  padding: 18px 0 36px;
}
#charts-context {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}
.comparison-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  overflow-x: auto;
}
.comparison-tabs button {
  flex: none;
  padding: 7px 10px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.comparison-tabs button[aria-selected="true"] {
  color: var(--ink);
  background: var(--surface-hover);
  border-color: var(--line-strong);
  font-weight: 700;
}
.chart-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}
.chart-controls button {
  min-height: 30px;
  padding: 5px 9px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.chart-controls button:hover,
.chart-controls button.active {
  color: var(--accent);
  border-color: var(--line-strong);
}
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.chart-card {
  min-width: 0;
  padding: 14px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.chart-card-wide {
  grid-column: 1 / -1;
}
.chart-card h2,
.metric-plots h3 {
  margin: 0;
  font-size: 13px;
}
.chart-card > p,
.chart-empty {
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 11px;
}
.plot-host {
  max-width: 100%;
  overflow-x: hidden;
}
.plot-host > svg,
.plot-host > figure {
  display: block;
  max-width: 100%;
}
.plot-host figure,
.metric-plots figure {
  margin: 0;
}
.chart-key {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 7px 16px;
  margin: 10px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--line);
  list-style: none;
}
.chart-key li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 6px;
  align-items: start;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}
.chart-key strong {
  color: var(--ink);
  font-family: var(--mono);
}
.chart-key span {
  overflow-wrap: anywhere;
}
.metric-plots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.metric-plots section {
  min-width: 0;
}
.metric-plots h3 {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

main,
footer {
  width: min(1600px, 100%);
  margin-inline: auto;
  padding-inline: 20px;
}
.data-strip {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 24px;
  align-items: center;
  min-height: 66px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.live-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
}
.status-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--status-loading);
  box-shadow: 0 0 0 3px var(--status-loading-soft);
}
.live-status:has([data-kind="ready"]) .status-dot {
  background: var(--status-ready);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.live-status:has([data-kind="error"]) .status-dot {
  background: var(--status-error);
  box-shadow: 0 0 0 3px var(--status-error-soft);
}
dl {
  display: flex;
  gap: 28px;
  margin: 0;
}
dl div {
  min-width: 90px;
}
dt {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
}
.error-help {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--status-error);
  font-size: 12px;
}

.entity-view {
  padding: 18px 0 8px;
}
.entity-path {
  justify-content: flex-start;
  min-height: auto;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
}
.entity-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}
.entity-heading > a {
  color: var(--accent);
  font-size: 12px;
}
.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.entity-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 14px 0;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.entity-summary div {
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  background: var(--surface);
}
.entity-summary span {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.entity-summary strong {
  font-family: var(--mono);
  font-size: 18px;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.detail-card {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.detail-card h2 {
  margin: 0 0 10px;
  font-size: 13px;
}
.detail-card p {
  margin: 6px 0;
  color: var(--muted);
  font-size: 12px;
}
.provenance-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 12px;
}
.provenance-list dt,
.provenance-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 10px;
}
.detail-card p strong {
  color: var(--ink);
}
.comparison-card {
  grid-column: 1 / -1;
}
.comparison-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.comparison-grid h3 {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.comparison-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  padding: 6px 0;
  overflow: hidden;
  border-top: 1px solid var(--line-soft);
  font-size: 11px;
  text-decoration: none;
}
.comparison-row strong,
.comparison-row span {
  font-family: var(--mono);
}
.comparison-row span {
  color: var(--muted);
}
.breakdown-row,
.run-link {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-top: 1px solid var(--line-soft);
  font-size: 11px;
  text-decoration: none;
}
.breakdown-row:first-child,
.run-link:first-child {
  border-top: 0;
}
.breakdown-row:hover,
.run-link:hover,
.entity-link:hover {
  color: var(--accent);
}
.run-link {
  display: block;
  overflow: hidden;
  font-family: var(--mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.entity-link {
  text-decoration: none;
}
.leaderboard {
  padding: 18px 0 36px;
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 12px;
}
h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.025em;
}
#result-count {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.table-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}
#reset-filters {
  min-height: 30px;
  padding: 0 10px;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
#reset-filters:hover {
  background: var(--surface);
}
label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
button:focus-visible,
a:focus-visible,
.table-shell:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.table-shell {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
table {
  width: 100%;
  min-width: 820px;
  table-layout: auto;
  border-collapse: collapse;
  font-size: 13px;
}
.column-heading {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.sort-button,
.filter-button {
  min-height: 24px;
  padding: 2px 3px;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 4px;
  font: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}
.sort-button:hover,
.filter-button:hover,
.filter-button.active {
  color: var(--accent);
  background: var(--surface-hover);
}
.sort-button.active::after {
  margin-left: 5px;
  content: "↓";
}
.sort-button.active[data-direction="asc"]::after {
  content: "↑";
}
.filter-button {
  font-size: 13px;
}
.filter-popover {
  width: min(320px, calc(100vw - 24px));
  max-height: min(520px, calc(100vh - 40px));
  margin: 0;
  padding: 12px;
  overflow: auto;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 14px 40px rgb(18 45 34 / 18%);
}
.filter-popover:popover-open {
  position: fixed;
  inset: auto;
  margin: 0;
}
.filter-popover fieldset {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0 0 10px;
  border: 0;
}
.filter-popover fieldset + fieldset {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.filter-popover fieldset + fieldset label {
  padding-left: 18px;
}
.filter-popover fieldset:last-child {
  padding-bottom: 0;
}
.filter-popover legend {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.filter-popover label {
  display: flex;
  gap: 9px;
  align-items: center;
  min-height: 32px;
  padding: 3px 6px;
  border-radius: 5px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}
.tree-heading {
  display: block;
  margin: 0 6px 10px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.filter-popover .tree-depth-1 {
  margin-left: 16px;
  border-left: 1px solid var(--line);
}
.filter-popover .tree-depth-2 {
  margin-left: 32px;
  border-left: 1px solid var(--line);
}
.filter-popover .tree-depth-3 {
  margin-left: 48px;
  border-left: 1px solid var(--line);
}
.filter-popover label:hover {
  background: var(--surface-hover);
}
.filter-popover input {
  accent-color: var(--accent);
}
th {
  position: sticky;
  top: 0;
  padding: 11px 14px;
  color: var(--muted);
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
tbody tr:last-child td {
  border-bottom: 0;
}
tbody tr:hover {
  background: var(--surface-subtle);
}
tbody tr.selected-row {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}
tbody tr.selected-row:hover {
  background: var(--accent-soft);
}
td strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.cell-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.number {
  font-family: var(--mono);
  white-space: nowrap;
}
.score {
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
}
.score-cell,
th:first-child {
  min-width: 260px;
}
.score-cell .score {
  font-size: 20px;
}
.comparison-positive {
  color: var(--chart-positive);
}
.comparison-negative {
  color: var(--chart-negative);
}
.comparison-neutral {
  color: var(--chart-neutral);
}
.score-section {
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px solid var(--line-soft);
}
.nested-title {
  margin-top: 8px;
}
.score-details {
  max-width: none;
}
.evidence-complete {
  color: var(--accent);
}
.evidence-partial {
  color: var(--warning);
}
.muted {
  color: var(--muted);
}
code {
  padding: 4px 6px;
  color: var(--code-ink);
  background: var(--code-surface);
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 11px;
}
.empty {
  margin: 0;
  padding: 48px 24px;
  color: var(--muted);
  text-align: center;
}
.table-note {
  max-width: 900px;
  margin: 15px 4px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

footer {
  display: flex;
  justify-content: space-between;
  padding-block: 28px 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}
footer p {
  margin: 0;
}

@media (max-width: 1000px) {
  .data-strip {
    grid-template-columns: 1fr;
    gap: 18px;
  }
  dl {
    justify-content: space-between;
  }
}

@media (max-width: 640px) {
  .entity-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .detail-grid {
    grid-template-columns: 1fr;
  }
  .metric-plots {
    grid-template-columns: 1fr;
  }
  .comparison-grid {
    grid-template-columns: 1fr;
  }
  main,
  footer {
    padding-inline: 12px;
  }
  .data-strip {
    gap: 10px;
    padding: 10px 0;
  }
  dl {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  dl div {
    min-width: 0;
  }
  .leaderboard {
    padding-top: 14px;
  }
  .section-heading {
    gap: 12px;
  }
  h1 {
    font-size: 20px;
  }
  footer {
    display: grid;
    gap: 12px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  tbody tr {
    transition: background-color 120ms ease;
  }
}

.slice-table {
  margin-top: 0.75rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
}

.slice-table table {
  width: 100%;
  border-collapse: collapse;
}

.slice-table th,
.slice-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}

.slice-table th {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.slice-table tr:last-child td {
  border-bottom: 0;
}
