:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --soft: #f8fafc;
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --s-a: #2563eb;
  --s-b: #0f172a;
  --s-c: #f59e0b;
  --grid: #e2e8f0;
  --logo-filter: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220; --card: #111a2e; --text: #e2e8f0; --text-2: #cbd5e1; --muted: #94a3b8;
    --line: #1e293b; --line-2: #334155; --soft: #0f172a; --primary: #60a5fa; --primary-soft: #172554;
    --s-a: #60a5fa; --s-b: #e2e8f0; --s-c: #fbbf24; --grid: #1e293b; --logo-filter: invert(1);
  }
}
:root[data-theme="dark"] {
  --bg: #0b1220; --card: #111a2e; --text: #e2e8f0; --text-2: #cbd5e1; --muted: #94a3b8;
  --line: #1e293b; --line-2: #334155; --soft: #0f172a; --primary: #60a5fa; --primary-soft: #172554;
  --s-a: #60a5fa; --s-b: #e2e8f0; --s-c: #fbbf24; --grid: #1e293b; --logo-filter: invert(1);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/20px Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { margin: 0; color: var(--text); }
h1 { font-size: 28px; line-height: 36px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 18px; line-height: 26px; font-weight: 600; }
h3 { font-size: 15px; line-height: 22px; font-weight: 600; }
.hint { margin: 2px 0 0; color: var(--muted); font-size: 13px; line-height: 18px; }

.top { background: var(--card); border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; justify-content: space-between; height: 56px; gap: 12px; }
.logo { filter: var(--logo-filter); display: block; }
.updated { color: var(--muted); font-size: 13px; text-align: right; }

.hero { padding: 28px 0 8px; }
.lead { max-width: 760px; margin: 8px 0 0; color: var(--text-2); font-size: 15px; line-height: 23px; }

.controls { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: flex-end; padding: 16px 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { color: var(--muted); font-size: 12px; line-height: 16px; }
select {
  height: 32px; min-width: 220px; padding: 0 32px 0 10px; border: 1px solid var(--line-2); border-radius: 6px;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 11px center;
  color: var(--text); font: inherit; appearance: none; cursor: pointer;
}
select:hover { border-color: #94a3b8; }
select:focus-visible, .seg button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; background: var(--card); }
.seg button {
  height: 30px; padding: 0 12px; border: 0; border-right: 1px solid var(--line-2); background: transparent;
  color: var(--text-2); font: inherit; cursor: pointer; white-space: nowrap;
}
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.kpi-name { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.kpi-val { font-size: 32px; line-height: 40px; font-weight: 700; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi-val small { font-size: 16px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.kpi-sub { color: var(--muted); font-size: 13px; line-height: 18px; margin-top: 2px; }
.kpi-sub b { color: var(--text-2); font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 16px 12px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--text-2); font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 16px; height: 3px; border-radius: 2px; display: inline-block; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid .card { margin-bottom: 0; }
.grid + .card { margin-top: 16px; }

.chart { position: relative; margin-top: 12px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .ax { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .gl { stroke: var(--grid); stroke-width: 1; }
.chart .vl { stroke: var(--line-2); stroke-width: 1; }
.chart .empty { fill: var(--muted); font-size: 13px; }

.tip {
  position: fixed; z-index: 10; pointer-events: none; min-width: 150px;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, .12); font-size: 13px; line-height: 19px;
}
.tip b { display: block; margin-bottom: 2px; }
.tip div { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.tip div span:last-child { margin-left: auto; padding-left: 12px; font-weight: 600; }

.table-wrap { overflow-x: auto; margin-top: 8px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
th span { display: inline-flex; align-items: center; gap: 6px; }
tr:last-child td { border-bottom: 0; }
td.best { font-weight: 600; }
td .x { color: var(--muted); font-size: 12px; margin-left: 6px; }

.method ul { margin: 8px 0 8px; padding-left: 18px; color: var(--text-2); }
.method li { margin: 4px 0; }
.foot { color: var(--muted); font-size: 12px; padding: 8px 16px 32px; }

@media (max-width: 760px) {
  h1 { font-size: 24px; line-height: 30px; }
  .kpis { grid-template-columns: 1fr; gap: 8px; }
  .kpi { display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 12px 14px; }
  .kpi-val { margin: 0; font-size: 26px; line-height: 32px; grid-row: span 2; }
  .grid { grid-template-columns: 1fr; }
  select { min-width: 0; width: 100%; }
  .controls .field:first-child { flex: 1 1 100%; }
}
