:root {
  --fg: #1d1f23;
  --bg: #ffffff;
  --muted: #5b6068;
  --accent1: #2e6fdb;
  --accent2: #e07b00;
  --panel: #f5f6f8;
  --border: #d8dade;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e6e8eb;
    --bg: #14161a;
    --muted: #9aa0a8;
    --accent1: #6aa3ff;
    --accent2: #ffa64d;
    --panel: #1c1f24;
    --border: #2a2e36;
  }
}
* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background: var(--bg);
  margin: 0;
  line-height: 1.5;
}
main { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
header h1 { margin: 0 0 .25rem; font-size: 1.8rem; }
header .subtitle { margin: 0 0 1rem; color: var(--accent1); font-size: .95rem; font-weight: 600; }
header .lead { color: var(--muted); margin: 0 0 1.5rem; max-width: 60ch; }
a { color: var(--accent1); }
code { background: var(--panel); padding: 1px 4px; border-radius: 3px; font-size: .9em; }

.controls {
  display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: center;
  background: var(--panel); border: 1px solid var(--border);
  padding: .75rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: .92rem;
}
.controls label { display: flex; gap: .5rem; align-items: center; }
.controls input, .controls button {
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 4px 10px; font: inherit;
}
.controls button { cursor: pointer; }
.controls button:disabled { opacity: .5; cursor: progress; }
.controls .status { color: var(--muted); font-size: .85rem; margin-left: auto; font-family: ui-monospace, monospace; }

.chart-wrap {
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  padding: 1rem; text-align: center; min-height: 300px;
}
.chart-wrap img { max-width: 100%; height: auto; display: block; margin: 0 auto; }

.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .75rem; margin: 1rem 0;
}
.kpi {
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  padding: .8rem 1rem; display: flex; flex-direction: column;
}
.kpi .num { font-size: 1.6rem; font-weight: 600; color: var(--accent1); }
.kpi .lbl { color: var(--muted); font-size: .85rem; }

details { margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 1rem; }
details summary {
  cursor: pointer; font-weight: 600; color: var(--muted); margin-bottom: .5rem;
}
details ol, details ul { color: var(--muted); margin: .5rem 0 0; padding-left: 1.2rem; }
details li { margin: .25rem 0; }
details pre {
  background: var(--panel); border: 1px solid var(--border); border-radius: 4px;
  padding: 1rem; overflow: auto; font-size: .8rem; line-height: 1.4;
  max-height: 500px;
}
