/* Series colors: categorical slots 1-2 of the validated reference palette
   (checked against #ffffff light / #1d201f dark surfaces: CVD ΔE ≥ 24, contrast ≥ 3:1). */
:root { --s-dl: #2a78d6; --s-ul: #eb6834; --grid: #ececea; --axis: #8a8a86; --tip-bg: #1d1d1f; --tip-fg: #ffffff; }
@media (prefers-color-scheme: dark) {
  :root { --s-dl: #3987e5; --s-ul: #d95926; --grid: #2a2e2c; --axis: #8f938f; --tip-bg: #e8e8e4; --tip-fg: #151716; }
}

.st-card { margin-bottom: 16px; }
.st-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.st-head h2 { font-size: 17px; margin: 0; }
.st-go { min-width: 120px; padding: 10px 18px; font-size: 15px; }
.small-btn { padding: 4px 10px; font-size: 13px; }

/* progress steps: state is carried by icon + text, not color alone */
.steps { list-style: none; display: flex; gap: 8px; padding: 0; margin: 14px 0 6px; flex-wrap: wrap; }
.steps li { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px 4px 8px; }
.steps .ico { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--line); display: inline-grid; place-items: center; font-size: 11px; }
.steps li[data-state="active"] { color: var(--text); border-color: var(--text); }
.steps li[data-state="active"] .ico { border-color: var(--text); border-top-color: transparent; animation: spin .9s linear infinite; }
.steps li[data-state="done"] { color: var(--text); }
.steps li[data-state="done"] .ico { border-color: var(--ok); background: var(--ok); color: var(--panel); }
.steps li[data-state="done"] .ico::after { content: "✓"; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .steps li[data-state="active"] .ico { animation: none; border-top-color: var(--text); } }

/* hero figure: same sans, proportional digits */
.hero { margin: 18px 0 8px; }
.hero-label { display: block; color: var(--muted); font-size: 13px; }
.hero-row { display: flex; align-items: baseline; gap: 8px; }
.hero-value { font-size: 64px; line-height: 1.05; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: proportional-nums; }
.hero-unit { color: var(--muted); font-size: 16px; }
.hero-meter[hidden] { display: none; }
.hero-meter { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; max-width: 420px; margin-top: 8px; }
.hero-meter i { display: block; height: 100%; width: 0; background: var(--text); border-radius: 2px; transition: width .2s; }

/* chart */
.chart { margin: 18px 0 0; }
.chart figcaption { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.chart-title { font-size: 13px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--text); }
.key { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 12px; height: 3px; border-radius: 2px; }
.sw.dl { background: var(--s-dl); }
.sw.ul { background: var(--s-ul); }
.plot { position: relative; }
#svg { display: block; width: 100%; height: 240px; overflow: visible; }
#svg .grid line { stroke: var(--grid); stroke-width: 1; }
#svg .tick { fill: var(--axis); font-size: 11px; font-variant-numeric: tabular-nums; }
#svg .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
#svg .line.dl { stroke: var(--s-dl); }
#svg .line.ul { stroke: var(--s-ul); }
#svg .area.dl { fill: var(--s-dl); opacity: .08; }
#svg .area.ul { fill: var(--s-ul); opacity: .08; }
#svg .end { stroke: var(--panel); stroke-width: 2; }
#svg .end.dl { fill: var(--s-dl); }
#svg .end.ul { fill: var(--s-ul); }
#svg .lbl { fill: var(--text); font-size: 12px; font-weight: 600; }
#svg .xh { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; }
#svg .empty { fill: var(--muted); font-size: 13px; }
.tip { position: absolute; top: 0; pointer-events: none; background: var(--tip-bg); color: var(--tip-fg);
  border-radius: 8px; padding: 6px 9px; font-size: 12px; line-height: 1.5; white-space: nowrap; transform: translateX(-50%); }
.tip .row { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }

/* KPI row */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.kpi { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg); }
.kpi-label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.kpi-val { color: var(--muted); font-size: 13px; }
.kpi-val b { color: var(--text); font-size: 24px; font-weight: 650; font-variant-numeric: proportional-nums; margin-right: 2px; }

/* tables */
.data { margin-top: 14px; }
.data summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.tbl { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
.tbl th { text-align: right; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl .muted { color: var(--muted); text-align: left; }
#samples { max-height: 240px; }
.hist .hint { margin-top: 2px; }
.credit { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.credit a { color: var(--muted); }

@media (max-width: 640px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .hero-value { font-size: 52px; }
  .st-head { flex-direction: column; }
  .st-go { width: 100%; }
  #svg { height: 200px; }
}
