:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #444444;
  --border: #cccccc;
  --accent: #3366cc;
  --accent2: #cc6633;
  --accent3: #339966;
  --error: #b00020;
  --input-bg: #ffffff;
  --tile-bg: #f5f6f8;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #14161a;
  --fg: #e8e8e8;
  --muted: #a8adb4;
  --border: #3a3d42;
  --accent: #7fa6f0;
  --accent2: #e0985f;
  --accent3: #63c795;
  --error: #ff6b6b;
  --input-bg: #1f2226;
  --tile-bg: #1c1f24;
  color-scheme: dark;
}
body {
  font-family: system-ui, sans-serif;
  max-width: 1350px;
  margin: 2rem auto;
  padding: 0 1rem;
  background: var(--bg);
  color: var(--fg);
}
h1 { font-size: 1.4rem; margin: 0; }
header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; gap: 1rem; flex-wrap: wrap; }
header .header-left { display: flex; align-items: baseline; gap: 1rem; }
nav a { color: var(--accent); text-decoration: none; margin-right: 1rem; font-size: 0.95rem; }
nav a:hover { text-decoration: underline; }
nav a.active { color: var(--fg); font-weight: 600; text-decoration: none; }
fieldset { border: 1px solid var(--border); border-radius: 6px; margin-bottom: 1rem; padding: 1rem; }
label { display: inline-block; margin-right: 1rem; }
input, select, button {
  background: var(--input-bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.4rem;
}
button { cursor: pointer; }
.row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.75rem; }
.row:last-child { margin-bottom: 0; }
#rangeControls { display: none; }
#rangeControls.visible { display: flex; }
#stats { font-size: 0.9rem; color: var(--muted); margin-bottom: 0.5rem; min-height: 1.2em; }
#error { color: var(--error); font-weight: 600; min-height: 1.2em; margin-bottom: 0.5rem; }
canvas { max-width: 100%; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat-tile { background: var(--tile-bg); border: 1px solid var(--border); border-radius: 6px; padding: 0.75rem 1rem; }
.stat-tile .label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.stat-tile .value { font-size: 1.3rem; font-weight: 600; margin-top: 0.15rem; }
.stat-tile .sub { font-size: 0.8rem; color: var(--muted); margin-top: 0.1rem; }

.chart-actions { display: flex; justify-content: flex-end; margin-bottom: 0.5rem; }
.caption { font-size: 0.8rem; color: var(--muted); margin-top: 0.5rem; }
