/* ── Reset & base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --bg-card:   #1a1d27;
  --border:    #2a2d3a;
  --text:      #e2e4ed;
  --text-muted:#8b8fa8;
  --accent:    #3b82f6;
  --font:      system-ui, -apple-system, sans-serif;

  /* generation colours */
  --c-lng:           #f97316;
  --c-coal:          #78716c;
  --c-nuclear:       #a855f7;
  --c-hydro:         #3b82f6;
  --c-solar:         #eab308;
  --c-wind:          #06b6d4;
  --c-biomass:       #84cc16;
  --c-geothermal:    #10b981;
  --c-thermal_other: #ef4444;
  --c-oil:           #b91c1c;
  --c-other:         #6b7280;
  --c-battery_storage:#0ea5e9;
  --c-interconnection:#ec4899;
  --c-pumped_storage: #6366f1;
}

html { font-size: 15px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

header h1 { font-size: 1.2rem; font-weight: 600; }

.header-left { display: flex; flex-direction: column; gap: 0.1rem; }

.updated-label { font-size: 0.78rem; color: var(--text-muted); }
#updated-time  { margin-left: 0.3rem; }

.lang-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.3rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: border-color 0.15s, color 0.15s;
}
.lang-toggle:hover { border-color: var(--accent); color: var(--text); }

/* ── Region nav ─────────────────────────────────────────────────────────── */
.region-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.region-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.3rem 0.85rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
}
.region-btn:hover   { border-color: var(--accent); color: var(--text); }
.region-btn.active  { background: var(--accent); border-color: var(--accent); color: #fff; }
.region-btn.system-btn { font-weight: 600; margin-right: 0.5rem; border-color: #4b5563; }

/* ── Main ───────────────────────────────────────────────────────────────── */
main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1.5rem; }

/* ── Metrics ────────────────────────────────────────────────────────────── */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.metric {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}
.metric-value { font-size: 1.8rem; font-weight: 700; letter-spacing: -0.02em; }
.metric-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.15rem; }
.metric-unit  { font-size: 0.72rem; color: var(--text-muted); }

/* ── Breakdown ──────────────────────────────────────────────────────────── */
.breakdown {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.source-row {
  display: grid;
  grid-template-columns: 10px 130px 1fr 70px 55px;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}

.source-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.source-name   { color: var(--text); white-space: nowrap; }
.source-bar-bg { background: var(--border); border-radius: 2px; height: 5px; overflow: hidden; }
.source-bar    { height: 100%; border-radius: 2px; transition: width 0.4s ease; }
.source-mw     { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.source-pct    { text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ── Charts ─────────────────────────────────────────────────────────────── */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.chart-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.chart-title { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; margin-bottom: 0.75rem; }

canvas { display: block; width: 100% !important; }

/* ── Footer ─────────────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .charts  { grid-template-columns: 1fr; }
  .source-row { grid-template-columns: 10px 110px 1fr 60px 45px; }
}
