:root {
  --charcoal: #0B0F14;
  --panel: #141A20;
  --cream: #F7F4EE;
  --sage: #3D6B5A;
  --sage2: #8FBFA9;
  --muted: #9AA3AD;
  --line: #1e262e;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; min-height: 100%;
  background: var(--charcoal); color: var(--cream);
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}
html.embed, html.embed body { height: 100%; overflow: hidden; }
body { display: flex; flex-direction: column; min-height: 100vh; }
html.embed body { min-height: 100%; height: 100%; }

.open-full { display: none; }
html.embed .open-full {
  display: inline-flex; align-items: center; gap: 0.35rem;
  position: fixed; top: 8px; right: 8px; z-index: 4000;
  pointer-events: auto; background: var(--sage); color: var(--cream);
  text-decoration: none; font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.05em; text-transform: uppercase;
  padding: 0.55rem 0.85rem; border-radius: 999px;
  border: 1px solid rgba(143,191,169,0.35);
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}
html.embed .open-full:hover { background: #4a7d6a; color: #fff; }

.app-bar {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.65rem 1.15rem; border-bottom: 1px solid var(--line);
  flex-shrink: 0; background: rgba(11,15,20,0.96);
}
.app-bar a { color: inherit; text-decoration: none; }
.app-bar .wordmark { height: 32px; width: auto; display: block; }
.app-bar .sub {
  color: var(--muted); font-size: 0.78rem; letter-spacing: 0.06em;
  text-transform: uppercase; font-weight: 500;
}
.app-bar nav {
  margin-left: auto; display: flex; gap: 0.85rem; flex-wrap: wrap;
}
.app-bar nav a {
  color: var(--muted); font-size: 0.78rem; letter-spacing: 0.02em;
}
.app-bar nav a:hover { color: var(--sage2); }

main {
  max-width: 1380px; margin: 0 auto; padding: 1.1rem 1.25rem 1.5rem;
  width: 100%; flex: 1; display: flex; flex-direction: column; min-height: 0;
}
html.embed main {
  max-width: none; margin: 0; padding: 0.35rem 0.4rem 0.4rem;
  overflow: hidden; gap: 0.3rem;
}
html.embed .lede, html.embed .note, html.embed footer.page-foot,
html.embed h1, html.embed .rail .hint, html.embed .rail .pill,
html.embed .cue, html.embed .app-bar nav, html.embed .app-bar .sub { display: none !important; }
html.embed .app-bar { padding: 0.3rem 0.5rem; padding-right: 9.5rem; gap: 0.45rem; }
html.embed .app-bar .wordmark { height: 22px; }
html.embed .kpis { grid-template-columns: repeat(4, minmax(0,1fr)); gap: 0.3rem; margin-bottom: 0; }
html.embed .kpi { padding: 0.28rem 0.4rem; border-radius: 6px; }
html.embed .kpi .v { font-size: 0.88rem; }
html.embed .kpi .l { font-size: 0.52rem; margin-top: 0.1rem; }
html.embed .atlas {
  grid-template-columns: minmax(0,1fr) 200px; gap: 0.4rem;
  margin-bottom: 0; flex: 1; min-height: 0;
}
html.embed .map-wrap { min-height: 0; border-radius: 8px; }
html.embed #map { height: auto !important; min-height: 0; flex: 1; }
html.embed .rail { max-height: none; min-height: 0; overflow: hidden; padding: 0.45rem 0.5rem; border-radius: 8px; }
html.embed .rail h2 { font-size: 0.72rem; margin: 0 0 0.35rem; }
html.embed .controls { padding: 0.35rem 0.5rem; gap: 0.4rem 0.5rem; }
html.embed .controls label { font-size: 0.62rem; }
html.embed .controls select, html.embed .controls input[type="search"] {
  font-size: 0.75rem; padding: 0.28rem 0.4rem; min-width: 5.5rem;
}
html.embed .controls input[type="search"] { min-width: 7.5rem; }
html.embed .controls .tog { font-size: 0.7rem; padding-bottom: 0.1rem; }
html.embed .status { display: none; }
html.embed table { font-size: 0.7rem; }
html.embed th, html.embed td { padding: 0.28rem 0.2rem; }
html.embed .near-label { min-width: 0; }
html.embed .near-row input[type="search"] { min-width: 8rem; }
html.embed .layers-box { top: 10px; right: 10px; max-width: 200px; }
html.embed .map-overlay { max-width: min(260px, calc(100% - 200px)); }
html.embed .detail-panel { max-width: min(260px, calc(100% - 24px)); }

h1 {
  font-family: Syne, "IBM Plex Sans", sans-serif;
  font-weight: 700; font-size: 1.4rem; margin: 0 0 0.3rem; letter-spacing: -0.01em;
}
h2 { font-weight: 500; font-size: 0.95rem; margin: 0 0 0.65rem; color: var(--cream); }
.lede { color: var(--muted); max-width: 48rem; line-height: 1.45; margin: 0 0 0.7rem; font-size: 0.88rem; }
.lede strong { color: var(--cream); font-weight: 500; }

.cue {
  margin: 0 0 0.85rem; max-width: 48rem;
  color: var(--sage2); font-size: 0.86rem; line-height: 1.45;
  padding: 0.55rem 0.75rem;
  border-left: 2px solid var(--sage);
  background: rgba(61,107,90,0.14);
  border-radius: 0 8px 8px 0;
}

.kpis { display: grid; grid-template-columns: repeat(4,1fr); gap: 0.55rem; margin-bottom: 0.85rem; }
@media (max-width: 720px) { .kpis { grid-template-columns: 1fr 1fr; } }
.kpi {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 0.65rem 0.8rem;
}
.kpi .v { font-size: 1.15rem; font-weight: 500; color: var(--sage2); letter-spacing: -0.02em; }
.kpi .l {
  font-size: 0.68rem; color: var(--muted); margin-top: 0.3rem;
  letter-spacing: 0.05em; text-transform: uppercase;
}

.atlas {
  display: grid; grid-template-columns: minmax(0,1fr) 260px;
  gap: 0.75rem; align-items: stretch; margin-bottom: 0.65rem;
  flex: 1; min-height: 0;
}
@media (max-width: 900px) {
  .atlas { grid-template-columns: 1fr; }
  html.embed .atlas { grid-template-columns: 1fr; grid-template-rows: minmax(0,1fr) minmax(120px,28%); }
  html.embed .kpis { grid-template-columns: 1fr 1fr; }
}
@media (max-height: 640px) {
  html.embed .kpis { display: none; }
  html.embed .app-bar { display: none; }
}

.map-wrap {
  position: relative;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden;
  display: flex; flex-direction: column; min-height: 0; flex: 1;
}
.map-wrap.basemap-imagery #map { background: #1a1a1a; }

.controls {
  display: flex; flex-wrap: wrap; gap: 0.65rem 0.75rem; align-items: flex-end;
  padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line); background: #10161c;
  z-index: 600; position: relative;
}
.controls label {
  font-size: 0.7rem; color: var(--muted); letter-spacing: 0.04em;
  text-transform: uppercase; display: flex; flex-direction: column; gap: 0.2rem;
}
.controls select, .controls input[type="search"] {
  background: var(--charcoal); color: var(--cream); border: 1px solid var(--line);
  border-radius: 6px; padding: 0.35rem 0.5rem; font-size: 0.82rem; min-width: 7rem;
}
.controls input[type="search"] { min-width: 11rem; }
.controls .tog {
  flex-direction: row; align-items: flex-end; gap: 0.4rem;
  text-transform: none; letter-spacing: 0; font-size: 0.78rem;
  color: var(--cream); margin: 0; padding-bottom: 0.2rem; height: 100%;
}
.controls .tog input { accent-color: var(--sage); }
.status { margin-left: auto; font-size: 0.72rem; color: var(--muted); white-space: nowrap; }

.near-label { min-width: 15rem; }
.near-row { display: flex; gap: 0.35rem; align-items: stretch; }
.near-row input[type="search"] { flex: 1; min-width: 11rem; }
.near-go {
  appearance: none; cursor: pointer;
  background: var(--sage); color: var(--cream);
  border: 1px solid rgba(143,191,169,0.4);
  border-radius: 6px; padding: 0.35rem 0.7rem;
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; white-space: nowrap;
}
.near-go:hover { background: #4a7d6a; }
.near-go:disabled { opacity: 0.55; cursor: wait; }

#map {
  height: min(68vh, 720px); min-height: 480px; width: 100%;
  background: #0d1218; flex: 1 1 auto;
}
@media (max-width: 720px) { #map { height: 480px; } }

.map-overlay {
  position: absolute; z-index: 500; left: 12px; top: 62px;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(320px, calc(100% - 210px));
  pointer-events: none;
}
html.embed .map-overlay { top: 52px; }

.chip {
  background: rgba(11,15,20,0.88); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; pointer-events: none;
}
.chip h3 {
  margin: 0; font-family: Syne, sans-serif; font-size: 14px; font-weight: 700;
}
.chip span { display: block; margin-top: 3px; color: var(--muted); font-size: 11.5px; }
.chip .overlay-hint {
  margin-top: 6px; color: var(--sage2); font-size: 10.5px; letter-spacing: 0.02em;
}

.satellite-chip {
  align-self: flex-start; pointer-events: auto; appearance: none;
  border: 1px solid rgba(143,191,169,0.55); border-radius: 999px;
  background: rgba(11,15,20,0.9); color: var(--cream); cursor: pointer;
  font-family: "IBM Plex Sans", sans-serif; font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em; padding: 7px 11px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.24);
}
.satellite-chip span { color: var(--sage2); margin-right: 4px; }
.satellite-chip:hover, .satellite-chip.is-active {
  background: var(--sage); border-color: var(--sage2);
}
.satellite-chip:focus-visible { outline: 2px solid var(--sage2); outline-offset: 2px; }

.detail-panel {
  pointer-events: auto;
  background: rgba(11,15,20,0.94); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px 14px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
  max-width: 300px; max-height: min(380px, 48vh); overflow: auto;
}
.detail-panel[hidden] { display: none !important; }
.detail-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; margin-bottom: 8px;
}
.detail-head h3 {
  margin: 0; font-family: Syne, sans-serif; font-size: 15px; font-weight: 700;
}
.detail-geoid {
  display: block; margin-top: 3px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em; color: var(--muted);
}
.detail-close {
  appearance: none; border: 0; width: 28px; height: 28px; border-radius: 8px;
  background: rgba(158,167,177,0.12); color: var(--cream); cursor: pointer;
  font-size: 18px; line-height: 1; flex-shrink: 0;
}
.detail-close:hover { background: rgba(158,167,177,0.22); }
.detail-cue {
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--sage2); margin-bottom: 8px;
}
.detail-rows { margin-top: 2px; }
.detail-row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px;
  padding: 7px 0; border-bottom: 1px solid rgba(30,38,46,0.9); font-size: 12px;
}
.detail-row:last-child { border-bottom: 0; }
.detail-row .lbl { color: var(--muted); }
.detail-row .val {
  font-family: var(--mono); font-weight: 500; color: var(--cream); text-align: right;
}

.layers-box {
  position: absolute; z-index: 500; right: 14px; top: 62px;
  pointer-events: auto;
  background: rgba(11,15,20,0.9); border: 1px solid var(--line);
  border-radius: 10px; min-width: 176px; max-width: 220px;
  overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,0.28);
}
html.embed .layers-box { top: 52px; }
.layers-toggle {
  appearance: none; border: 0; width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: transparent; color: var(--cream); cursor: pointer;
  font-family: "IBM Plex Sans", sans-serif; padding: 8px 11px 7px;
}
.layers-toggle-lbl {
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); font-weight: 500;
}
.layers-toggle-chev { font-size: 10px; color: var(--muted); transition: transform 0.18s ease; }
.layers-box.is-collapsed .layers-toggle-chev { transform: rotate(-90deg); }
.layers-box.is-collapsed .layers-body { display: none; }
.layers-body { padding: 0 10px 9px; border-top: 1px solid rgba(30,38,46,0.85); }
.layers-sec { margin-top: 8px; }
.layers-sec:first-child { margin-top: 7px; }
.layers-sec-lbl {
  font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--sage2); margin-bottom: 4px; font-weight: 500;
}
.layers-opt {
  display: flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: var(--cream); margin: 3px 0;
  cursor: pointer; line-height: 1.25; user-select: none;
}
.layers-opt input {
  accent-color: var(--sage2); width: 13px; height: 13px;
  margin: 0; flex-shrink: 0; cursor: pointer;
}
.layers-opt-hint { color: var(--muted); font-size: 10px; margin-left: 2px; }

.rail {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 0.75rem 0.8rem 0.7rem;
  display: flex; flex-direction: column; min-height: 0; height: 100%;
}
.rail .hint { font-size: 0.72rem; color: var(--muted); margin: 0 0 0.65rem; line-height: 1.4; }
.rail-scroll { overflow: auto; flex: 1; margin: 0 -0.25rem; padding: 0 0.25rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
th, td { text-align: left; padding: 0.4rem 0.3rem; border-bottom: 1px solid var(--line); }
th {
  color: var(--muted); font-weight: 500; font-size: 0.65rem;
  letter-spacing: 0.04em; text-transform: uppercase;
  position: sticky; top: 0; background: var(--panel);
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; transition: background 0.12s; }
tbody tr:hover, tbody tr.active { background: rgba(61,107,90,0.22); }
.pill {
  display: inline-block; margin-top: 0.75rem; padding: 0.22rem 0.6rem;
  border-radius: 999px; background: rgba(61,107,90,0.25);
  color: var(--sage2); font-size: 0.72rem;
}
.note {
  font-size: 0.7rem; color: var(--muted); margin-top: 0.55rem;
  line-height: 1.4; max-width: 52rem;
}
a { color: var(--sage2); }

footer.page-foot {
  border-top: 1px solid var(--line); padding: 0.85rem 1.25rem;
  color: var(--muted); font-size: 0.7rem; line-height: 1.45;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: auto; flex-shrink: 0;
}
footer.page-foot b { color: var(--cream); font-weight: 500; }
footer.page-foot a { color: var(--sage2); }
footer.page-foot a:hover { color: var(--cream); }

.leaflet-container { background: #0d1218; font: inherit; }
.leaflet-popup-content-wrapper {
  background: var(--panel); color: var(--cream); border-radius: 8px;
  border: 1px solid var(--line); box-shadow: 0 8px 28px rgba(0,0,0,0.45);
}
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-content { margin: 0.7rem 0.85rem; font-size: 0.82rem; line-height: 1.4; min-width: 160px; }
.leaflet-popup-content .cu { font-weight: 500; color: var(--cream); margin-bottom: 0.15rem; }
.leaflet-popup-content .site { color: var(--sage2); font-size: 0.78rem; }
.leaflet-popup-content .meta { color: var(--muted); font-size: 0.75rem; margin-top: 0.35rem; }
.leaflet-popup-content .stats { margin-top: 0.45rem; font-variant-numeric: tabular-nums; font-size: 0.78rem; }
.leaflet-popup-content .stats span { color: var(--sage2); }
.leaflet-control-zoom a {
  background: var(--panel) !important; color: var(--cream) !important;
  border-color: var(--line) !important;
}
.leaflet-control-attribution {
  background: rgba(11,15,20,0.75) !important; color: var(--muted) !important; font-size: 0.65rem !important;
}
.leaflet-control-attribution a { color: var(--sage2) !important; }
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large {
  background: rgba(61,107,90,0.35) !important;
}
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div {
  background: rgba(61,107,90,0.85) !important; color: var(--cream) !important;
  font-weight: 500; font-size: 0.75rem;
}
.branch-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--sage2); border: 1.5px solid rgba(247,244,238,0.55);
  box-shadow: 0 0 0 2px rgba(61,107,90,0.35);
}
.branch-dot.main { background: #c8e0d2; width: 11px; height: 11px; }
.branch-dot.pinned {
  background: #f0e6c8; width: 14px; height: 14px;
  border-color: #fff; box-shadow: 0 0 0 3px rgba(61,107,90,0.55);
}

.leaflet-control-fullscreen a {
  background: var(--panel) !important; color: var(--cream) !important;
  border-color: var(--line) !important; width: 34px !important; height: 34px !important;
  line-height: 34px !important; font-size: 16px !important; text-align: center;
  text-decoration: none !important;
}
.leaflet-control-fullscreen a:hover { background: #1a222a !important; }
.map-wrap:fullscreen, .map-wrap:-webkit-full-screen {
  width: 100vw; height: 100vh; border-radius: 0; background: #0d1218;
}
.map-wrap:fullscreen #map, .map-wrap:-webkit-full-screen #map { height: 100% !important; flex: 1; }
.map-wrap:fullscreen .map-overlay, .map-wrap:-webkit-full-screen .map-overlay { top: 12px; }
.map-wrap:fullscreen .layers-box, .map-wrap:-webkit-full-screen .layers-box { top: 12px; }

@media (max-width: 900px) {
  .layers-box { top: auto; bottom: 52px; right: 10px; min-width: 152px; }
  .map-overlay { max-width: min(280px, calc(100% - 24px)); top: 58px; }
  .detail-panel { max-width: min(280px, 90%); max-height: 42vh; }
  .satellite-chip { font-size: 10.5px; padding: 6px 10px; }
  .app-bar nav { display: none; }
}
