:root {
  color-scheme: dark;
  --bg: #070b10;
  --panel: rgba(10, 17, 25, 0.9);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f2f7fb;
  --muted: #95a4b7;
  --accent: #ffd447;
  --blue: #3da7ff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
}

.map-shell {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  z-index: 600;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(7, 11, 16, 0.98), rgba(12, 21, 30, 0.96));
  border-right: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
}

.brand strong {
  display: block;
  font-size: 1rem;
}

.brand small,
.panel p,
footer {
  color: var(--muted);
}

.bolt {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #162536;
  color: var(--accent);
  font-size: 1.35rem;
}

.panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 1.45rem;
  line-height: 1.1;
}

h2 {
  margin-bottom: 10px;
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stats span,
.nav-list a {
  min-height: 44px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.stats span {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 10px;
  color: var(--muted);
}

.stats strong {
  color: var(--text);
  font-size: 1.25rem;
}

.nav-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.nav-list.single {
  grid-template-columns: 1fr;
}

.nav-list a {
  display: grid;
  place-items: center;
  padding: 10px;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid transparent;
}

.nav-list a.active {
  color: var(--text);
  border-color: rgba(255, 212, 71, 0.75);
  background: rgba(255, 212, 71, 0.12);
}

.controls {
  display: grid;
  gap: 12px;
}

.controls label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

input,
select {
  accent-color: var(--accent);
}

select {
  max-width: 138px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101925;
  color: var(--text);
}

.legend ol {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.legend span {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 16px var(--swatch);
}

footer {
  margin-top: auto;
  font-size: 0.85rem;
}

.map-stage {
  position: relative;
  min-height: 100vh;
}

#map {
  position: absolute;
  inset: 0;
  background: #101922;
}

/* Critical Leaflet layout fallback.
   If the CDN stylesheet is blocked, these rules still keep tiles stitched
   together instead of appearing as scattered images across the page. */
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-container {
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
  -webkit-user-drag: none;
}

.leaflet-tile {
  filter: saturate(0.72) contrast(1.04) brightness(0.84);
}

.leaflet-control-container .leaflet-top,
.leaflet-control-container .leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-control-container .leaflet-top {
  top: 0;
}

.leaflet-control-container .leaflet-bottom {
  bottom: 0;
}

.leaflet-control-container .leaflet-left {
  left: 0;
}

.leaflet-control-container .leaflet-right {
  right: 0;
}

.leaflet-control {
  position: relative;
  z-index: 1000;
  pointer-events: auto;
}

.leaflet-bottom .leaflet-control {
  margin-bottom: 12px;
}

.leaflet-right .leaflet-control {
  margin-right: 12px;
}

.topbar {
  position: absolute;
  top: 16px;
  left: 50%;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 11, 16, 0.82);
  color: var(--text);
  transform: translateX(-50%);
  backdrop-filter: blur(12px);
}

#status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #29d37d;
  box-shadow: 0 0 14px #29d37d;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #0b121a;
  color: var(--text);
}

.about-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.about-page article {
  max-width: 680px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

@media (max-width: 820px) {
  .map-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .map-stage {
    min-height: 68vh;
  }

  .topbar {
    top: 10px;
    width: calc(100% - 20px);
    justify-content: center;
  }
}
