:root {
  --ink-primary: #0b0b0b;
  --ink-secondary: #52514e;
  --ink-muted: #898781;
  --surface: #fcfcfb;
  --page-bg: #f6f5f3;
  --panel: #ffffff;
  --hairline: #e6e4e0;
  --hairline-strong: #d4d2cd;
  --accent: #1c5cab;
  --highlight: #eef4fd;
  --radius: 10px;
  --font: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink-primary: #f3f2ef;
    --ink-secondary: #b5b3ad;
    --ink-muted: #8a8881;
    --surface: #1a1a19;
    --page-bg: #121211;
    --panel: #1a1a19;
    --hairline: #2e2e2c;
    --hairline-strong: #3d3d3a;
    --accent: #6da7ec;
    --highlight: #16233a;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--ink-primary);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.page-head h1 {
  font-size: 28px;
  line-height: 1.2;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}

.lede {
  margin: 0 0 28px;
  color: var(--ink-secondary);
  max-width: 68ch;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.panel h2 {
  font-size: 16px;
  margin: 0 0 4px;
  letter-spacing: -0.005em;
}

.section-note {
  margin: 0 0 16px;
  color: var(--ink-secondary);
  max-width: 72ch;
  font-size: 13.5px;
}

/* --- inputs ------------------------------------------------------------ */

.input-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-secondary);
  margin-bottom: 6px;
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: 8px;
  padding: 0 10px;
  transition: border-color 0.12s ease;
}

.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.input-wrap[data-prefix]::before {
  content: attr(data-prefix);
  color: var(--ink-muted);
  font-size: 14px;
}

.input-wrap[data-suffix]::after {
  content: attr(data-suffix);
  color: var(--ink-muted);
  font-size: 13px;
  white-space: nowrap;
}

.input-wrap input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink-primary);
  font: inherit;
  font-variant-numeric: tabular-nums;
  padding: 9px 0;
  outline: none;
}

.field-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--ink-muted);
}

.field-error {
  margin: 6px 0 0;
  font-size: 12px;
  color: #b3261e;
  min-height: 0;
}

@media (prefers-color-scheme: dark) {
  .field-error {
    color: #f2b8b5;
  }
}

.field-error:empty {
  display: none;
}

.input-wrap.invalid {
  border-color: #b3261e;
}

.panel-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-secondary);
  max-width: 52ch;
  cursor: pointer;
}

.checkbox input {
  margin-top: 3px;
  accent-color: var(--accent);
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ghost-button {
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-secondary);
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: 7px;
  padding: 6px 11px;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
}

.ghost-button:hover {
  color: var(--ink-primary);
  border-color: var(--ink-muted);
}

.status {
  margin: 12px 0 0;
  font-size: 12.5px;
  color: var(--ink-muted);
  min-height: 1em;
}

/* --- filter pills ------------------------------------------------------ */

.filter-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 18px;
}

.filter-label {
  font-size: 13px;
  color: var(--ink-secondary);
}

.pills {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  padding: 3px;
}

.pill {
  font: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-secondary);
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 5px 13px;
  cursor: pointer;
}

.pill:hover {
  color: var(--ink-primary);
}

.pill[aria-checked='true'] {
  background: var(--accent);
  color: #fff;
}

@media (prefers-color-scheme: dark) {
  .pill[aria-checked='true'] {
    color: #10233d;
  }
}

/* --- summary tiles ----------------------------------------------------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(152px, 1fr));
  gap: 10px;
  margin: 0 0 20px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 11px 13px 12px;
}

.tile-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  margin-bottom: 5px;
}

.tile-value {
  font-size: 19px;
  line-height: 1.2;
  color: var(--ink-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.015em;
}

.tile-note {
  font-size: 12px;
  color: var(--ink-secondary);
  margin-top: 4px;
  line-height: 1.35;
}

/* --- tables ------------------------------------------------------------ */

.table-scroll {
  overflow-x: auto;
  margin-bottom: 24px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

th,
td {
  text-align: right;
  padding: 9px 12px;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}

thead th {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody th,
th:first-child,
td:first-child {
  text-align: left;
}

tbody th {
  font-weight: 500;
  color: var(--ink-primary);
}

tbody tr.best {
  background: var(--highlight);
}

/* Grouped header: a quiet band naming each cluster of measures. */
.group-row th {
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  text-align: left;
  padding-bottom: 2px;
  border-bottom: 0;
}

.stats-table .group-start {
  border-left: 1px solid var(--hairline);
  padding-left: 12px;
}

/* Ten columns of figures: trade padding for fitting on one screen. */
.stats-table th,
.stats-table td {
  padding: 8px 9px;
  font-size: 13px;
}

.stats-table tbody th {
  padding-right: 14px;
}

/* Second value inside a cell — the delta or share that gives it context. */
.cell-note {
  display: block;
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-top: 2px;
}

.table-note {
  margin: 10px 0 24px;
  font-size: 12px;
  color: var(--ink-muted);
  max-width: 92ch;
}

.row-swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: baseline;
}

.best-tag {
  font-size: 11px;
  color: var(--ink-muted);
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* --- charts ------------------------------------------------------------ */

.chart-stack {
  display: grid;
  gap: 24px;
}

.chart {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 14px 16px 10px;
}

.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.chart-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-primary);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: var(--ink-secondary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

.chart-body {
  position: relative;
}

.chart-svg {
  display: block;
  width: 100%;
  touch-action: none;
}

.gridline {
  stroke: var(--hairline);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.axis-text {
  fill: var(--ink-muted);
  font-family: var(--font);
  font-size: 11px;
}

.series-label {
  fill: var(--ink-secondary);
  font-family: var(--font);
  font-size: 11.5px;
}

.end-marker {
  stroke: var(--surface);
}

.hover-dot {
  stroke: var(--surface);
}

.crosshair {
  stroke: var(--hairline-strong);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--panel);
  border: 1px solid var(--hairline-strong);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  min-width: 148px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  z-index: 2;
}

.tooltip-head {
  color: var(--ink-secondary);
  font-weight: 500;
  margin-bottom: 5px;
}

.tooltip-rows {
  display: grid;
  gap: 3px;
}

.tooltip-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 7px;
}

.tooltip-label {
  color: var(--ink-muted);
}

.tooltip-value {
  color: var(--ink-primary);
  font-variant-numeric: tabular-nums;
}

.chart-table {
  max-height: 340px;
  overflow: auto;
  border: 1px solid var(--hairline);
  border-radius: 8px;
}

.chart-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
}

/* --- callout and footer ------------------------------------------------ */

.callout {
  margin-top: 16px;
  border-left: 2px solid var(--accent);
  padding: 2px 0 2px 14px;
  color: var(--ink-secondary);
  font-size: 13.5px;
}

.callout p {
  margin: 0 0 8px;
}

.callout p:last-child {
  margin-bottom: 0;
}

.callout strong {
  color: var(--ink-primary);
  font-weight: 500;
}

.assumptions {
  border-top: 1px solid var(--hairline);
  padding-top: 20px;
  color: var(--ink-secondary);
  font-size: 13px;
}

.assumptions h2 {
  font-size: 13px;
  color: var(--ink-primary);
  margin: 0 0 10px;
}

.assumptions ul {
  margin: 0;
  padding-left: 18px;
  max-width: 82ch;
}

.assumptions li {
  margin-bottom: 6px;
}

.assumptions strong {
  color: var(--ink-primary);
  font-weight: 500;
}

.disclaimer {
  color: var(--ink-muted);
  font-size: 12.5px;
  margin-top: 14px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 640px) {
  .page {
    padding: 20px 14px 48px;
  }
  .page-head h1 {
    font-size: 22px;
  }
  .panel-foot {
    flex-direction: column;
    align-items: flex-start;
  }
}
