:root {
  --bg: #0f1014;
  --panel: #181c24;
  --panel-2: #1f2530;
  --border: #2a3140;
  --fg: #e6ecf2;
  --muted: #8b95a3;
  --accent: #7cc4ff;
  --accent-dim: #4a7aa8;
  --warn: #ffce67;
  --ok: #7cffa1;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

header {
  max-width: 880px;
  margin: 32px auto 18px;
  padding: 0 20px;
}

h1 {
  margin: 0 0 6px;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 72ch;
}

.subtitle code {
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: 0.85em;
  background: var(--panel);
  padding: 1px 5px;
  border-radius: 3px;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 200px auto;
  gap: 10px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field .label,
.presets-row .label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

#input, #period {
  width: 100%;
  background: #0c0e13;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
}

#input:focus, #period:focus {
  border-color: var(--accent);
}

.primary {
  background: var(--accent);
  color: #061018;
  border: none;
  border-radius: 6px;
  padding: 9px 22px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  font-family: inherit;
  align-self: end;
}

.primary:hover {
  filter: brightness(1.08);
}

.presets-row {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
}

.preset {
  background: var(--panel-2);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
}

.preset:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.status {
  grid-column: 1 / -1;
  font-size: 0.82rem;
  color: var(--muted);
  padding: 4px 0;
  min-height: 1.4em;
}

.status.loading { color: var(--accent); }
.status.warn    { color: var(--warn); }
.status.ok      { color: var(--ok); }

.chart-panel {
  padding: 10px;
}

.chart {
  width: 100%;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.totals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.total-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.total-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: 0.85rem;
  color: var(--fg);
  margin-bottom: 4px;
}

.total-name .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.total-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}

.total-label {
  font-size: 0.72rem;
  color: var(--muted);
}

footer {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
  line-height: 1.6;
}

footer code {
  background: var(--panel-2);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: 0.8rem;
}

@media (max-width: 600px) {
  .controls { grid-template-columns: 1fr; }
  .primary { width: 100%; }
}
