:root {
  --bg: #0e1116;
  --surface: #161b22;
  --surface-2: #1f2630;
  --border: #2a323d;
  --text: #e6edf3;
  --text-dim: #9aa6b2;
  --accent: #58a6ff;
  --ok: #57c98a;
  --warn: #d29922;
  --bad: #f85149;
  --code: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font:
    15px/1.55 -apple-system,
    BlinkMacSystemFont,
    "Hiragino Sans",
    "Yu Gothic UI",
    system-ui,
    sans-serif;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

header {
  margin-bottom: 18px;
}

h1 {
  font-size: 28px;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.lede {
  margin: 0;
  color: var(--text-dim);
  max-width: 720px;
}

.lede strong {
  color: var(--text);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  font-family: var(--code);
  font-size: 12.5px;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
}

/* ────────── controls ────────── */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
}

.control-group span {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.06em;
}

select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 5px;
  cursor: pointer;
}

button {
  margin-left: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  font-family: var(--code);
  cursor: pointer;
}

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

/* ────────── map ────────── */

.map-section {
  padding: 0;
  overflow: hidden;
}

#map {
  height: 480px;
  width: 100%;
  background: #0b0e13;
}

.legend {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 11.5px;
  color: var(--text-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.legend-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-title {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 4px;
  color: var(--text-dim);
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  display: inline-block;
  margin: 0 2px 0 6px;
}

.legend-circle {
  display: inline-block;
  border-radius: 50%;
  background: rgba(248, 81, 73, 0.35);
  border: 1px solid #f85149;
  margin: 0 2px 0 6px;
  vertical-align: middle;
}

/* Leaflet overrides for the dark theme. */
.leaflet-container {
  background: #0e1116;
  font-family: inherit;
  font-size: 12px;
}

.leaflet-popup-content-wrapper {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.leaflet-popup-tip {
  background: var(--surface);
  border: 1px solid var(--border);
}

.leaflet-popup-content {
  margin: 10px 14px;
  font-size: 12.5px;
  line-height: 1.55;
}

.leaflet-popup-content b {
  color: var(--text);
}

.leaflet-popup-content a {
  color: var(--accent);
}

.leaflet-control-attribution {
  background: rgba(15, 17, 22, 0.75) !important;
  color: var(--text-dim) !important;
}

.leaflet-control-attribution a {
  color: var(--accent) !important;
}

/* ────────── stats ────────── */

.stats-section {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 12px;
}

@media (min-width: 700px) {
  .stats-section {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
}

.stat-label {
  font-size: 10.5px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.stat-value {
  font-family: var(--code);
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ────────── status ────────── */

.status-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  font-family: var(--code);
  color: var(--text-dim);
}

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

.status.ready {
  color: var(--ok);
}

.status.error {
  color: var(--bad);
}

.next-refresh {
  font-size: 11px;
}

/* ────────── footer ────────── */

footer {
  margin-top: 24px;
  font-size: 12.5px;
  color: var(--text-dim);
}

footer p {
  margin: 4px 0;
}
