:root {
  --bg: #071321;
  --bg-soft: #0f2238;
  --card: rgba(10, 24, 40, 0.9);
  --card-border: rgba(115, 142, 176, 0.2);
  --text: #edf4fb;
  --muted: #9bb0c6;
  --accent: #ffb106;
  --accent-2: #38c8ff;
  --success: #78d86d;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Bahnschrift, "Aptos", "Trebuchet MS", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(56, 200, 255, 0.14), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 177, 6, 0.12), transparent 24%),
    linear-gradient(180deg, #081521 0%, #04101c 100%);
}

.shell {
  width: min(1500px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.masthead {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  margin-bottom: 18px;
}

.masthead h1 {
  margin: 0;
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1;
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.updated-stamp {
  margin-bottom: 0.24rem;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.masthead-meta {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.scope-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255, 177, 6, 0.16);
  border: 1px solid rgba(255, 177, 6, 0.35);
  color: #ffd580;
  font-weight: 700;
}

.meta-note {
  color: var(--muted);
  font-size: 0.92rem;
}

@media (max-width: 840px) {
  .masthead h1 {
    align-items: flex-start;
    gap: 8px;
  }

  .updated-stamp {
    margin-bottom: 0;
    white-space: normal;
  }
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(280px, 1fr);
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.toolbar-label,
.panel-title {
  margin: 0 0 12px;
  color: #d4e6f6;
  font-size: 0.94rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toolbar-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.toolbar-grid label {
  display: block;
  width: 80%;
}

label span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

select,
button,
input[type="range"] {
  font: inherit;
}

select {
  width: 100%;
  appearance: none;
  padding: 12px 42px 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(132, 156, 181, 0.24);
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01)),
    #0b1c2f;
}

select:disabled {
  color: #607287;
  background: #0a1726;
}

.tab-row {
  display: flex;
  width: 100%;
  padding: 3px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(132, 156, 181, 0.18);
  gap: 3px;
}

.tab {
  flex: 1 1 0;
  border: 0;
  border-radius: 12px;
  padding: 8px 20px;
  color: #d6e3f0;
  background: transparent;
  cursor: pointer;
  min-width: 0;
  font-weight: 700;
}

.tab.active {
  background: linear-gradient(180deg, #ffbf2f, #f59e0b);
  color: #102031;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
  gap: 18px;
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 18px;
}

.side-panel .card {
  padding: 18px;
}

.filter-card {
  padding: 10px 12px;
}

.filter-card .filter-stack {
  gap: 8px;
}

.filter-card select {
  padding: 10px 38px 10px 14px;
}

.filter-stack {
  display: grid;
  gap: 14px;
}

.filter-stack .is-hidden {
  display: none;
}

.legend-card {
  min-height: 360px;
}

.legend-head {
  display: flex;
  justify-content: flex-start;
  align-items: baseline;
}

.legend-list {
  display: grid;
  gap: 10px;
}

.legend-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) 92px;
  gap: 8px;
  align-items: center;
  justify-content: start;
}

.legend-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.legend-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-value {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
  justify-self: end;
  width: 92px;
}

.note-copy {
  margin: 0;
  line-height: 1.55;
  color: #c4d7e9;
}

.map-panel {
  position: relative;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.map-stage {
  position: relative;
  min-height: 720px;
  border-radius: 22px;
  overflow: hidden;
  border: 0;
  background: transparent;
}

.map-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.backdrop-none {
  background: #e4e7e2;
}

.backdrop-none::before {
  display: none;
}

.backdrop-osm,
.backdrop-street {
  background:
    linear-gradient(90deg, rgba(244, 224, 181, 0.14) 0 1px, transparent 1px) 0 0 / 86px 86px,
    linear-gradient(rgba(244, 224, 181, 0.12) 0 1px, transparent 1px) 0 0 / 86px 86px,
    linear-gradient(34deg, rgba(239, 68, 68, 0.08), transparent 30%),
    linear-gradient(180deg, #efe7d9 0%, #d9d7d0 100%);
}

.backdrop-satellite {
  background:
    radial-gradient(circle at 25% 20%, rgba(34, 197, 94, 0.18), transparent 26%),
    radial-gradient(circle at 70% 35%, rgba(22, 163, 74, 0.16), transparent 24%),
    radial-gradient(circle at 52% 68%, rgba(59, 130, 246, 0.14), transparent 22%),
    linear-gradient(180deg, #1e2d23 0%, #151d1a 100%);
}

.backdrop-google,
.backdrop-drone {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px) 0 0 / 36px 36px,
    linear-gradient(rgba(255, 255, 255, 0.06) 0 1px, transparent 1px) 0 0 / 36px 36px,
    radial-gradient(circle at 25% 22%, rgba(148, 163, 184, 0.18), transparent 20%),
    radial-gradient(circle at 74% 58%, rgba(56, 189, 248, 0.1), transparent 22%),
    linear-gradient(180deg, #5b6672 0%, #34414f 100%);
}

.map-backdrop::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(180deg, rgba(255, 255, 255, 0.25), transparent 85%);
}

.map-canvas,
.map-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.map-feature {
  stroke: rgba(7, 19, 33, 0.9);
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: filter 140ms ease, transform 140ms ease;
}

.map-feature:hover,
.map-feature.active {
  filter: brightness(1.08);
}

.map-feature.active {
  stroke: #ffe2a0;
  stroke-width: 2.2;
}

.map-control {
  position: absolute;
  left: 18px;
  bottom: 18px;
  width: min(248px, calc(100% - 48px));
  margin-top: 0;
  padding: 16px;
  z-index: 20;
  pointer-events: auto;
}

.map-control.map-control-basemap {
  width: auto;
  min-width: 0;
  max-width: calc(100% - 48px);
  padding: 14px 14px 12px;
  background: rgba(8, 14, 22, 0.18);
  border: 1px solid rgba(0, 0, 0, 0.82);
  box-shadow: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  --basemap-slider-width: 170px;
}

.map-control,
.map-control * {
  pointer-events: auto;
}

.basemap-option {
  width: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #d9e8f7;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.basemap-option small {
  color: #7f92a8;
  font-size: 0.8em;
}

.basemap-dot {
  width: 15px;
  height: 15px;
  border-radius: 999px;
  border: 2px solid #718096;
  background: transparent;
  flex: 0 0 auto;
}

.basemap-option.is-active .basemap-dot {
  border-color: var(--accent);
  background:
    radial-gradient(circle at center, var(--accent) 0 45%, transparent 46% 100%);
}

.basemap-option.is-disabled {
  color: #7588a0;
  cursor: not-allowed;
}

.basemap-option.is-disabled .basemap-dot {
  border-color: #5f7289;
}

.basemap-option.is-disabled span {
  color: #7588a0;
}

.slider-wrap {
  width: var(--basemap-slider-width);
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid rgba(132, 156, 181, 0.2);
  display: block;
}

input[type="range"] {
  accent-color: var(--accent);
}

.map-control-basemap input[type="range"] {
  width: var(--basemap-slider-width);
  display: block;
}

.map-stage .maplibregl-map {
  font: inherit;
}

.map-stage .maplibregl-canvas {
  outline: none;
}

.map-stage .maplibregl-control-container {
  z-index: 2;
}

.map-stage .maplibregl-ctrl-group,
.map-stage .maplibregl-ctrl.maplibregl-ctrl-attrib {
  background: rgba(8, 19, 31, 0.9);
  border: 1px solid rgba(132, 156, 181, 0.18);
  box-shadow: var(--shadow);
}

.map-stage .maplibregl-ctrl button {
  background-color: transparent;
}

.map-stage .maplibregl-ctrl button .maplibregl-ctrl-icon {
  filter: invert(1) brightness(1.2);
}

.map-stage .maplibregl-ctrl-attrib {
  color: #c8d8e8;
}

.map-stage .maplibregl-ctrl-attrib a {
  color: #d7e7f8;
}

.hover-card {
  position: absolute;
  right: 18px;
  top: 18px;
  width: 290px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(8, 19, 31, 0.94);
  border: 1px solid rgba(132, 156, 181, 0.18);
  box-shadow: var(--shadow);
  z-index: 3;
}

.hover-card.hidden {
  display: none;
}

.status-note {
  position: absolute;
  left: 18px;
  top: 18px;
  max-width: 380px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 177, 6, 0.18);
  border: 1px solid rgba(255, 177, 6, 0.38);
  color: #ffe3a5;
  box-shadow: var(--shadow);
  z-index: 3;
}

.status-note.hidden {
  display: none;
}

.hover-title {
  margin: 0;
  font-size: 1.34rem;
}

.hover-subtitle {
  margin: 6px 0 14px;
  color: var(--accent-2);
}

.hover-metric {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.hover-metric span:last-child {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.status-row {
  display: none;
}

.status-label {
  color: var(--muted);
  margin-right: 8px;
}

@media (max-width: 1200px) {
  .toolbar,
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .shell {
    width: min(100vw - 20px, 1500px);
    padding-top: 16px;
  }

  .masthead {
    flex-direction: column;
    align-items: flex-start;
  }

  .toolbar-grid {
    grid-template-columns: 1fr;
  }

  .tab-row {
    display: grid;
  }

  .tab {
    min-width: 0;
  }

  .map-stage {
    min-height: 560px;
  }

  .hover-card {
    position: static;
    width: auto;
    margin: 14px;
  }

  .map-control {
    width: min(248px, calc(100% - 36px));
  }
}
