:root {
  --bg: #0e0f12;
  --fg: #e8e8ea;
  --muted: #8a8d94;
  --accent: #f5c518;
  --card: #16181d;
  --border: #262932;
  --neso: #5b8def;
  --actual: #e8e8ea;
  --our: #f5c518;
  --our-band: rgba(245, 197, 24, 0.18);

  --wind: #5bbdef;
  --solar: #f5c518;
  --nuclear: #7d6dff;
  --gas: #ef6b5b;
  --coal: #444851;
  --biomass: #6dc36b;
  --hydro: #36a4d0;
  --imports: #c97ad6;
  --other: #8a8d94;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding: 24px 16px 40px;
}

main {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
}

header {
  margin-bottom: 28px;
}
h1 {
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 4px;
}
h1 span { color: var(--accent); }
.tagline {
  color: var(--muted);
  margin: 0;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}
.card-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
  letter-spacing: 0.02em;
}

/* "Now" stats — three cards in a grid */
.now-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat .label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}
.stat .value {
  font-size: 34px;
  font-weight: 600;
  line-height: 1.1;
}
.stat .unit {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.stat .when {
  font-size: 11px;
  margin-top: 6px;
}
.stat.accent {
  border-color: var(--accent);
}
.stat.accent .value { color: var(--accent); }

.genmix-card { margin-bottom: 18px; }
#genmix-bar svg { display: block; width: 100%; height: 36px; border-radius: 6px; overflow: hidden; }
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
  font-size: 12px;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  display: inline-block;
}

/* Chart cards */
.chart-card { margin-bottom: 18px; }
#line-chart svg, #resid-chart svg { display: block; }

/* Phone tweaks */
@media (max-width: 480px) {
  body { padding: 16px 12px 32px; }
  h1 { font-size: 22px; }
  .tagline { font-size: 13px; }
  .card { padding: 14px 14px; }
  .stat .value { font-size: 28px; }
  .card-label { font-size: 12px; margin-bottom: 10px; }
  .now-grid { gap: 10px; }
  .chart-legend, .legend { gap: 10px; font-size: 11px; }
}

/* d3 chart styles */
.chart-axis line, .chart-axis path { stroke: var(--border); }
.chart-axis text { fill: var(--muted); font-size: 11px; }
.chart-gridline { stroke: var(--border); stroke-dasharray: 2 3; }
.chart-now { stroke: var(--accent); stroke-dasharray: 4 3; stroke-width: 1.5px; opacity: 0.6; }
.chart-now-label { fill: var(--accent); font-size: 10px; font-weight: 600; opacity: 0.7; }

.line-actual { fill: none; stroke: var(--actual); stroke-width: 1.7px; }
.line-neso { fill: none; stroke: var(--neso); stroke-width: 1.4px; stroke-dasharray: 4 3; }
.line-our { fill: none; stroke: var(--our); stroke-width: 1.8px; }
.band-our { fill: var(--our-band); stroke: none; }

.resid-bar-pos { fill: #6dc36b; opacity: 0.6; }
.resid-bar-neg { fill: #ef6b5b; opacity: 0.6; }
.resid-marker { stroke: var(--our); stroke-width: 2px; fill: none; }
.resid-baseline { stroke: var(--border); stroke-width: 1px; }

.chart-tooltip {
  position: absolute;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.08s;
  z-index: 10;
}
.chart-tooltip .tt-time {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 4px;
}
.chart-tooltip .tt-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 1px 0;
}
.chart-tooltip .tt-swatch {
  width: 8px; height: 8px; border-radius: 2px;
  display: inline-block; margin-right: 6px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 8px;
  font-size: 12px;
}
.chart-legend .swatch {
  width: 18px; height: 2px; display: inline-block;
  margin-right: 6px; vertical-align: middle;
}
.chart-legend .swatch-dash {
  background: repeating-linear-gradient(to right, currentColor 0, currentColor 4px, transparent 4px, transparent 7px);
  height: 2px;
}
.chart-legend .swatch-band {
  width: 18px; height: 10px; display: inline-block; margin-right: 6px;
  vertical-align: middle; border-radius: 2px;
}

footer {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}
.footer-row { display: flex; gap: 12px; flex-wrap: wrap; }
