:root {
  --bg: #0e1014;
  --bg2: #161a21;
  --panel: #1b202a;
  --line: #2a313d;
  --fg: #e7ebf0;
  --muted: #9aa3b0;
  --accent: #b24fd0;
  --accent2: #36c2a8;
  --radius: 12px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg2), var(--bg));
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--fg);
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.brand:hover { text-decoration: none; }
.spark {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(178, 79, 208, 0.55);
  animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(178,79,208,0.55); }
  70% { box-shadow: 0 0 0 9px rgba(178,79,208,0); }
  100% { box-shadow: 0 0 0 0 rgba(178,79,208,0); }
}
nav { display: flex; gap: 18px; }
nav a { color: var(--muted); font-size: 0.95rem; }
nav a.active { color: var(--fg); }
nav a:hover { color: var(--fg); text-decoration: none; }

main { max-width: 1040px; margin: 0 auto; padding: 26px 22px 60px; }

.hero h1 { font-size: clamp(1.6rem, 4vw, 2.5rem); margin: 6px 0 4px; letter-spacing: -0.02em; }
.hero .now { color: var(--accent); }
.sub { color: var(--muted); margin: 0 0 18px; max-width: 60ch; }

.controls { display: flex; align-items: center; gap: 12px; margin: 8px 0 22px; flex-wrap: wrap; }
.controls label { color: var(--muted); font-size: 0.9rem; }
select {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.95rem;
}
.pill {
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: 999px;
}
.pill.live { color: #7ed957; border-color: #2f5b2f; }
.pill.stale { color: #f4c531; border-color: #5b5320; }

.dashboard {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 28px;
  align-items: center;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}
@media (max-width: 720px) { .dashboard { grid-template-columns: 1fr; } }

.chartwrap { position: relative; width: 240px; height: 240px; margin: 0 auto; }
#donut { width: 240px; height: 240px; }
.donut-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; pointer-events: none;
}
.donut-center .big { font-size: 1.7rem; font-weight: 700; }
.donut-center .lbl { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

.legend { display: flex; flex-direction: column; gap: 2px; }
.legend .row {
  display: grid;
  grid-template-columns: 14px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 7px 4px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.legend .row:last-child { border-bottom: none; }
.legend .sw { width: 14px; height: 14px; border-radius: 3px; }
.legend .nm { color: var(--fg); }
.legend .pct { color: var(--fg); font-weight: 600; }
.legend .mw { color: var(--muted); font-size: 0.85rem; min-width: 78px; text-align: right; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-top: 22px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat .v { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .k { color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; }

.prose { max-width: 70ch; }
.prose h1 { letter-spacing: -0.02em; }
.prose h2 { margin-top: 1.6em; }
.prose .muted { color: var(--muted); font-size: 0.9rem; }

.maphead h1 { letter-spacing: -0.02em; margin-bottom: 4px; }
.maphead .src { color: var(--muted); font-size: 0.8rem; margin: 0 0 12px; }
.maphead .src a { color: var(--muted); }
.map {
  width: 100%;
  height: 70vh;
  min-height: 460px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 14px;
  background: #0a0c10;
}
.maplegend { display: flex; flex-wrap: wrap; gap: 12px; margin: 10px 0; }
.maplegend .item { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.maplegend .dot { width: 11px; height: 11px; border-radius: 50%; }

.mapviews { display: flex; align-items: center; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.mapviews button {
  background: var(--panel); color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 14px; font-size: 0.88rem; cursor: pointer;
}
.mapviews button:hover { color: var(--fg); }
.mapviews button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.mapstatus { font-size: 0.82rem; color: var(--muted); margin-left: 4px; }
.maplibregl-popup-content .muted { color: var(--muted); font-size: 0.8rem; }

.maplibregl-popup-content {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.85rem;
}
.maplibregl-popup-content strong { color: var(--fg); }
.maplibregl-popup-tip { border-top-color: var(--panel) !important; border-bottom-color: var(--panel) !important; }

.foot {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  padding: 20px 22px;
  max-width: 1040px;
  margin: 0 auto;
}
.foot a { color: var(--muted); text-decoration: underline; }
