:root {
  --ink: #0b1d2c;
  --muted: #4a5b6f;
  --navy: #0b4f8a;
  --sky: #1ea7c6;
  --bg: #eef2f7;
  --shadow: 0 18px 40px rgba(11, 31, 52, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
}

body {
  font-family: "Manrope", "Segoe UI", sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: radial-gradient(circle at 20% 20%, rgba(0, 161, 199, 0.08), transparent 35%),
    radial-gradient(circle at 80% 10%, rgba(11, 79, 138, 0.08), transparent 40%), var(--bg);
}

.page {
  min-height: 100vh;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1002;
  background: linear-gradient(120deg, #002a52 0%, #00498c 60%, #00a1c7 100%);
  color: #ffffff;
  box-shadow: var(--shadow);
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 13px 20px;
  flex-wrap: wrap;
}

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

.brand-logo {
  height: 46px;
  width: auto;
  display: inline-block;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.2));
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.82);
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.brand-subtitle {
  color: rgba(255, 255, 255, 0.75);
  font-size: 13px;
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.top-pill {
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 700;
  display: inline-flex;
  gap: 7px;
  align-items: center;
  font-size: 13px;
}

.top-pill-btn {
  font-family: inherit;
  cursor: pointer;
}

.top-pill-btn[aria-pressed='false'] {
  background: rgba(18, 22, 31, 0.45);
  border-color: rgba(255, 255, 255, 0.5);
}

.basemap-switch {
  gap: 8px;
  padding-right: 8px;
}

.basemap-buttons {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.base-btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  padding: 4px 9px;
  cursor: pointer;
}

.base-btn.is-active {
  background: rgba(255, 255, 255, 0.94);
  color: #003965;
  border-color: rgba(255, 255, 255, 0.95);
}

.map-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #dfe7f1;
}

#map,
#network-canvas {
  position: absolute;
  inset: 0;
}

#map {
  z-index: 1;
}

#network-canvas {
  z-index: 500;
  pointer-events: none;
}

.map-legend {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 650;
  width: min(320px, calc(100vw - 32px));
  background: rgba(255, 255, 255, 0.93);
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
  padding: 10px 12px;
  color: #121a24;
  font-size: 12px;
  line-height: 1.28;
}

.map-legend-title {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 6px;
}

.legend-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-chip {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  flex: 0 0 12px;
}

.legend-chip.c0 {
  background: #b7cf2e;
}

.legend-chip.c1 {
  background: #1b9e9a;
}

.legend-chip.c2 {
  background: #2bad7f;
}

.legend-chip.c3 {
  background: #38bb63;
}

.legend-chip.c4 {
  background: #6bc94f;
}

.legend-chip.c5 {
  background: #a5d53f;
}

.legend-chip.c6 {
  background: #d6dd36;
}

.legend-chip.c7 {
  background: #f1d32a;
}

.legend-chip.c8 {
  background: #f7b71f;
}

.legend-chip.c9 {
  background: #f7921e;
}

.legend-chip.c10 {
  background: #f36c1d;
}

.legend-chip.c11 {
  background: #ef4a1a;
}

.legend-chip.c12 {
  background: #e60012;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 18, 30, 0.28);
  backdrop-filter: blur(1.2px);
}

.loading-overlay.hidden {
  display: none;
}

.loading-card {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #d6dde6;
  border-radius: 999px;
  padding: 10px 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
  color: #0b1d2c;
  font-size: 13px;
  font-weight: 700;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(11, 79, 138, 0.25);
  border-top-color: #0b4f8a;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 720px) {
  .topbar-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .topbar-actions {
    width: 100%;
  }

  .map-legend {
    right: 10px;
    bottom: 10px;
    max-height: min(58vh, 420px);
    overflow-y: auto;
  }
}
