:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f0efec;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.22);
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #b4b2a9;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111110;
    --surface: #1a1a19;
    --surface-2: #232321;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #898781;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.24);
    --grid: #2c2c2a;
    --axis: #4a4a47;
    --accent: #3987e5;
    --danger: #f97066;
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #5f5e5a;
  }
}
:root[data-theme="dark"] {
  --bg: #111110; --surface: #1a1a19; --surface-2: #232321; --text: #f0efec; --text-2: #c3c2b7;
  --border: rgba(255, 255, 255, 0.10); --border-strong: rgba(255, 255, 255, 0.24);
  --grid: #2c2c2a; --axis: #4a4a47; --accent: #3987e5; --danger: #f97066;
  --s1: #3987e5; --s2: #d95926; --s3: #5f5e5a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
main { max-width: 900px; margin: 0 auto; padding: 40px 16px 64px; }
h1 { font-size: 28px; font-weight: 600; margin: 0 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 17px; font-weight: 600; margin: 40px 0 8px; }
.lede { color: var(--text-2); margin: 0 0 24px; max-width: 62ch; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
code { font-size: 13px; }

.drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 36px 16px; border: 1.5px dashed var(--border-strong); border-radius: 12px;
  background: var(--surface); cursor: pointer; text-align: center;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); }
.drop.over { background: var(--surface-2); }
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.drop-title { font-weight: 600; }
.drop-sub { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 14px; }
.note {
  margin: 12px 0 0; padding: 10px 14px; font-size: 14px; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.demo-line { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
button.link {
  font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px;
}
button.link:hover { text-decoration-thickness: 2px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; }
tr:last-child td { border-bottom: 0; }
td.name { white-space: normal; min-width: 180px; }
td.name small { display: block; color: var(--muted); }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); }
.offset { display: flex; align-items: center; gap: 6px; }
.offset input { width: 64px; }
.offset small { color: var(--muted); }
button.icon { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 2px 6px; border-radius: 6px; }
button.icon:hover { color: var(--text); background: var(--surface-2); }

input[type="number"], input[type="text"], select {
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 6px 8px;
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="radio"], input[type="checkbox"] { accent-color: var(--accent); }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 12px; }
.source { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.source label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.source select { width: 100%; }
.source small { display: block; color: var(--muted); font-size: 12px; margin-top: 6px; }
.options { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; margin: 16px 0 8px; font-size: 14px; }
.options label { display: flex; align-items: center; gap: 8px; }
.options .grow { flex: 1 1 260px; }
.options .grow input { flex: 1; min-width: 0; }
.options input[type="number"] { width: 64px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 12px; margin-bottom: 8px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.kpi span { display: block; font-size: 12px; color: var(--muted); }
.kpi b { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }

.chart-block { margin-top: 28px; }
.chart-title { font-size: 14px; font-weight: 600; margin: 0 0 2px; }
.chart-sub { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.legend i { display: inline-block; width: 16px; height: 0; border-top: 2px solid; margin-right: 6px; vertical-align: middle; }
.chart { position: relative; height: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 4px; }
.chart.short { height: 150px; }
.chart canvas { display: block; touch-action: pan-y; }
.tip {
  position: absolute; display: none; pointer-events: none; z-index: 2;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 6px 9px; font-size: 12px; color: var(--text-2); white-space: nowrap;
  font-variant-numeric: tabular-nums; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.tip-h { color: var(--muted); margin-bottom: 2px; }
.tip b { color: var(--text); font-weight: 600; }
.sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

details { margin-top: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; font-size: 13px; }
summary { cursor: pointer; font-weight: 600; font-size: 14px; }
details ul { margin: 10px 0 0; padding-left: 18px; color: var(--text-2); font-variant-numeric: tabular-nums; columns: 2 220px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 28px; }
.actions .hint { margin: 0; }
button.primary {
  font: inherit; font-weight: 600; color: var(--accent-ink); background: var(--accent);
  border: 0; border-radius: 10px; padding: 10px 18px; cursor: pointer;
}
button.primary:hover { filter: brightness(1.08); }
button.secondary {
  font: inherit; font-weight: 600; color: var(--accent); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 10px; padding: 9px 17px; cursor: pointer;
}
button.secondary:hover { border-color: var(--accent); }
footer { margin-top: 56px; color: var(--muted); font-size: 12px; }
footer a { color: inherit; }
