:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

header {
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  padding: 14px 20px;
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  font-size: 16px;
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

nav { display: flex; gap: 4px; }

button, input, select {
  font: inherit;
  color: inherit;
}

.tab {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  color: var(--text-secondary);
}
.tab[aria-selected="true"] {
  background: var(--page);
  border-color: var(--border);
  color: var(--text-primary);
  font-weight: 600;
}

.search {
  margin-left: auto;
  display: flex;
  gap: 8px;
  position: relative;
}
.search input {
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  width: 230px;
}
.search button {
  background: var(--series-1);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
  font-weight: 600;
}

.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 280px;
  overflow-y: auto;
  z-index: 20;
  display: none;
}
.suggestions.open { display: block; }
.suggestions div {
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.suggestions div:hover { background: var(--page); }
.suggestions b { font-variant-numeric: tabular-nums; }

main { padding: 20px; max-width: 1280px; margin: 0 auto; }

section[hidden] { display: none; }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.card h2 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 650;
}
.card .sub {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 0 0 14px;
}

.headline {
  display: flex;
  gap: 28px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.hero-score { min-width: 150px; }
.hero-score .value {
  font-size: 52px;
  font-weight: 680;
  line-height: 1;
  letter-spacing: -0.03em;
}
.hero-score .label {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 6px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px 22px;
  flex: 1;
  min-width: 300px;
}
.tile .k {
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tile .v {
  font-size: 22px;
  font-weight: 620;
  letter-spacing: -0.02em;
}
.tile .n {
  color: var(--text-muted);
  font-size: 12px;
}
.tile .v.none { color: var(--text-muted); font-size: 15px; font-weight: 500; }

.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 16px;
}

.legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

figure { margin: 0; position: relative; }
svg { display: block; width: 100%; height: auto; overflow: visible; }
.grid-line { stroke: var(--grid); stroke-width: 1; }
.axis-line { stroke: var(--axis); stroke-width: 1; }
.tick { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.crosshair { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 90ms;
  z-index: 5;
}
.tooltip.on { opacity: 1; }
.tooltip .t-date { color: var(--text-secondary); margin-bottom: 3px; }
.tooltip .t-row { display: flex; gap: 8px; align-items: center; }
.tooltip .t-val { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }

.components { width: 100%; border-collapse: collapse; font-size: 13px; }
.components th {
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
}
.components td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--grid);
  vertical-align: top;
}
.components td.num { text-align: right; font-variant-numeric: tabular-nums; }
.components .explain { color: var(--text-secondary); font-size: 12px; }
.bar-cell { width: 130px; }
.bar-track { background: var(--grid); border-radius: 3px; height: 8px; }
.bar-fill { background: var(--series-1); border-radius: 3px; height: 8px; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 14px;
}
.filters label { font-size: 12px; color: var(--text-secondary); display: block; }
.filters input, .filters select {
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  width: 120px;
}
.filters button {
  background: var(--series-1);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 7px 16px;
  cursor: pointer;
  font-weight: 600;
}
.filters button.ghost {
  background: none;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.table-wrap { overflow-x: auto; }
table.results { width: 100%; border-collapse: collapse; font-size: 13px; }
table.results th {
  text-align: right;
  padding: 7px 10px;
  border-bottom: 1px solid var(--axis);
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  position: sticky;
  top: 0;
  background: var(--surface-1);
}
table.results th:first-child, table.results th:nth-child(2) { text-align: left; }
table.results th[aria-sort]::after { content: " ▾"; color: var(--text-muted); }
table.results td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--grid);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
table.results td:first-child, table.results td:nth-child(2) { text-align: left; }
table.results td:nth-child(2) {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: normal;
}
table.results tbody tr:hover { background: var(--page); }
table.results a { color: var(--series-1); text-decoration: none; font-weight: 600; }
table.results a:hover { text-decoration: underline; }
td.na { color: var(--text-muted); }

.score-pill {
  display: inline-block;
  min-width: 42px;
  padding: 1px 7px;
  border-radius: 4px;
  font-weight: 650;
  color: #fff;
}

.status { color: var(--text-secondary); font-size: 13px; }
.error {
  border-left: 3px solid var(--critical);
  padding: 10px 14px;
  background: var(--surface-1);
  border-radius: 6px;
  color: var(--text-primary);
}
.note { color: var(--text-secondary); font-size: 12px; margin-top: 10px; }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 12px; font-size: 13px; }
.pager button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 12px;
  cursor: pointer;
}
.pager button:disabled { opacity: 0.4; cursor: default; }
