:root {
  --bg: #0c1016;
  --bg-elev: #141b25;
  --bg-elev-2: #1b2533;
  --line: #243044;
  --text: #e8edf4;
  --muted: #8a99ad;
  --accent: #4dabf7;
  --green: #37b24d;
  --amber: #f59f00;
  --orange: #f76707;
  --red: #e03131;
  --darkred: #a61e4d;
  --radius: 16px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #16202d 0%, var(--bg) 60%);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 40px);
  max-width: 1100px;
  margin: 0 auto;
}

.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  font-size: 28px;
  filter: drop-shadow(0 0 10px rgba(247, 103, 7, 0.5));
}
.topbar h1 { font-size: clamp(18px, 2.6vw, 24px); margin: 0; letter-spacing: -0.01em; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.sub span { color: var(--text); font-variant-numeric: tabular-nums; }

.status {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 rgba(55, 178, 77, 0.6);
}
.dot.live { background: var(--green); animation: pulse 2s infinite; }
.dot.stale { background: var(--amber); }
.dot.error { background: var(--red); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(55, 178, 77, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(55, 178, 77, 0); }
  100% { box-shadow: 0 0 0 0 rgba(55, 178, 77, 0); }
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 4px clamp(16px, 4vw, 40px) 40px;
  display: grid;
  gap: 22px;
}

.card {
  background: linear-gradient(180deg, var(--bg-elev) 0%, var(--bg) 140%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.gauge-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 16px 22px;
}
.gauge {
  width: 100%;
  max-width: 640px;
  height: clamp(320px, 40vw, 460px);
}
.gauge.stale { filter: grayscale(0.85) opacity(0.75); transition: filter 0.4s; }

.readout { text-align: center; margin-top: -18px; }
.band-label {
  font-size: clamp(16px, 2.4vw, 20px);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.cpm {
  margin-top: 4px;
  color: var(--muted);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.cpm .unit { font-size: 12px; }
.meta-line {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12.5px;
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
}
.meta-line .sep { opacity: 0.5; }

.card-head { padding: 18px 20px 0; }
.card-head h2 { margin: 0; font-size: 17px; }
.hint { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.chart { width: 100%; height: 340px; padding: 6px; }

.series-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.series-nav {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0; font-variant-numeric: tabular-nums;
}
.series-nav button {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-elev-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px;
  font-size: 14px; cursor: pointer; line-height: 1;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.series-nav button:hover:not(:disabled) { background: var(--line); border-color: var(--accent); }
.series-nav button:disabled { opacity: 0.35; cursor: default; }
.series-range {
  min-width: 168px; text-align: center;
  color: var(--muted); font-size: 12.5px;
}

.charts-row { display: grid; gap: 22px; }

.dose-note {
  margin: 2px 0 0;
  padding: 0 20px 18px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}
.dose-note b { color: var(--text); }

.map-card { overflow: hidden; }
.map {
  width: 100%;
  height: 380px;
  margin-top: 14px;
  background: var(--bg);
  border-radius: 0 0 var(--radius) var(--radius);
}
.map .leaflet-container { background: var(--bg); font: inherit; }
.map .leaflet-popup-content { font-size: 13px; }

.legend {
  display: flex; flex-wrap: wrap; gap: 14px;
  padding: 0 20px 18px;
  color: var(--muted);
  font-size: 12.5px;
}
.legend .chip { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 12px; height: 12px; border-radius: 3px; }

.foot {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 40px) 40px;
  color: var(--muted);
  font-size: 12px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.foot a { color: var(--accent); text-decoration: none; }
.foot .sep { opacity: 0.4; }
.foot .muted { opacity: 0.7; }

@media (min-width: 860px) {
  .charts-row { grid-template-columns: 1fr 1fr; }
}
