/* ATLAS — Compounding Energy Global Geospatial Engine */

* { margin: 0; padding: 0; box-sizing: border-box; }

/* ─── Dark theme (default — matches dark basemaps) ─────────────── */
:root {
  --bg: #06060c;
  --panel: rgba(10, 15, 26, 0.92);
  --glass: rgba(15, 23, 42, 0.65);
  --border: rgba(148, 163, 184, 0.08);
  --border-h: rgba(148, 163, 184, 0.15);
  --text: #e2e8f0;
  --dim: #94a3b8;
  --muted: #64748b;
  --accent: #0891b2;
  --accent-g: rgba(8, 145, 178, 0.12);
  --warn: #fbbf24;
  --danger: #fb7185;
  --sans: 'Inter', -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', 'SF Mono', monospace;
  --input-bg: rgba(148, 163, 184, 0.06);
}

/* ─── Light theme (auto-applied when basemap is light/osm/satellite) ── */
/* basemap-switcher.js toggles .theme-light on <body> whenever the
   user switches basemap. The sidebar, toolbar, settings panel, chat,
   site analysis, unlock modal — everything that reads CSS variables —
   flips to the light palette automatically. The map canvas itself
   is unaffected (MapLibre handles its own tile rendering). */
body.theme-light {
  --bg: #f8fafc;
  --panel: rgba(255, 255, 255, 0.94);
  --glass: rgba(248, 250, 252, 0.85);
  --border: rgba(15, 23, 42, 0.06);
  --border-h: rgba(15, 23, 42, 0.12);
  --text: #0f172a;
  --dim: #334155;
  --muted: #64748b;
  --accent: #0891b2;
  --accent-g: rgba(8, 145, 178, 0.1);
  --warn: #d97706;
  --danger: #e11d48;
  --input-bg: rgba(15, 23, 42, 0.04);
}

/* ── Fade-in animation for first-load polish ── */
@keyframes atlasReveal {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--sans); }
/* Paint the map container with the light basemap's land color BEFORE
   MapLibre's canvas has rendered, so first-load feels seamless instead
   of flashing dark-then-light. The #e8e4da matches the Carto light
   basemap's land tone. */
#map { position: absolute; inset: 0; background: #e8e4da; }

/* ── Panel ── */
.panel {
  position: absolute; top: 12px; left: 12px; z-index: 90; width: 300px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  max-height: calc(100vh - 24px); overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin; scrollbar-color: var(--muted) transparent;
  animation: atlasReveal 0.3s ease-out;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
.panel::-webkit-scrollbar { width: 4px; }
.panel::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 2px; }
/* Light theme: subtle shadow instead of dark glow */
body.theme-light .panel {
  box-shadow: 0 4px 24px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
}

.panel-header {
  padding: 14px 16px 10px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: var(--panel); backdrop-filter: blur(20px); z-index: 1;
}
.panel-logo svg { width: 24px; height: 24px; display: block; }
.panel-title { font-family: var(--mono); font-size: 15px; font-weight: 600; color: var(--accent); letter-spacing: 0.04em; }
.panel-subtitle { font-size: 12px; color: var(--dim); font-family: var(--mono); line-height: 1.4; }

/* ── Sidebar groups ── */
/* Each layer belongs to one of three groups (infrastructure /
   markets / analysis). The group header is sticky-feeling within the
   sidebar and click-to-collapse hides every layer in the group. */
.sb-group {
  border-bottom: 1px solid var(--border);
}
.sb-group:last-child { border-bottom: none; }
.sb-group-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px 10px;
  cursor: pointer; user-select: none;
  background: rgba(0, 229, 255, 0.04);
  transition: background 0.15s;
}
.sb-group-header:hover {
  background: rgba(0, 229, 255, 0.08);
}
.sb-group-chevron {
  font-size: 11px; color: var(--accent);
  transition: transform 0.2s;
  display: inline-block;
  width: 10px;
}
.sb-group.collapsed .sb-group-chevron {
  transform: rotate(-90deg);
}
.sb-group-label {
  flex: 1;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  color: var(--accent); text-transform: uppercase; letter-spacing: 0.1em;
}
.sb-group-count {
  font-family: var(--mono); font-size: 9px; color: var(--muted);
  background: rgba(148, 163, 184, 0.1);
  padding: 1px 6px; border-radius: 3px;
}
.sb-group-body {
  padding-top: 4px;
  max-height: 4000px;
  overflow: hidden;
  transition: max-height 0.25s ease, padding-top 0.2s, opacity 0.2s;
}
.sb-group.collapsed .sb-group-body {
  max-height: 0;
  padding-top: 0;
  opacity: 0;
}

/* ── Section headers ── */
.section { padding: 6px 16px; }
.section.collapsed .category-list { display: none; }
.section.collapsed .bubble-legend-wrap { display: none; }
.section { transition: all 0.15s ease; }

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0; cursor: pointer; user-select: none;
}
.section-title-text {
  font-size: 12.5px; font-weight: 600; color: var(--dim); text-transform: uppercase;
  letter-spacing: 0.06em; flex: 1; cursor: pointer;
}
.section-controls { display: flex; align-items: center; gap: 6px; }
.section-badge {
  font-family: var(--mono); font-size: 9px; color: var(--muted); font-weight: 400;
  background: rgba(148, 163, 184, 0.08); padding: 1px 6px; border-radius: 4px;
}
.section-gear {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 16px; padding: 6px; opacity: 0.6; transition: opacity 0.15s;
}
.section-gear:hover { opacity: 1; color: var(--accent); }

/* Toggle switch */
.section-toggle {
  background: none; border: none; cursor: pointer; padding: 2px;
  display: flex; align-items: center;
}
.toggle-indicator {
  width: 34px; height: 18px; border-radius: 9px;
  background: rgba(148, 163, 184, 0.2); position: relative;
  transition: background 0.2s;
}
.toggle-indicator::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--muted); transition: all 0.2s;
}
.toggle-indicator.on { background: var(--accent-g); }
.toggle-indicator.on::after { left: 18px; background: var(--accent); }

/* ── Legend items ── */
.category-list { padding: 2px 0; }
.legend-item {
  display: flex; align-items: center; gap: 10px; padding: 5px 4px;
  cursor: pointer; user-select: none; transition: opacity 0.15s;
  border-radius: 4px; min-height: 28px;
}
.legend-item:hover { background: rgba(148,163,184,0.06); }
.legend-item.off { opacity: 0.4; filter: grayscale(0.4); }
.swatch { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.swatch.line { width: 20px; height: 3px; border-radius: 1.5px; }
.swatch.diamond { width: 10px; height: 10px; transform: rotate(45deg); border-radius: 1px; flex-shrink: 0; }
.legend-label { font-size: 13px; color: var(--text); flex: 1; }
.legend-stat { font-family: var(--mono); font-size: 10px; color: var(--muted); white-space: nowrap; }
.sep { height: 1px; background: var(--border); margin: 4px 16px; }

/* ── Region buttons ── */
.regions { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 16px; }
.region-btn {
  font-size: 12px; padding: 5px 10px; border-radius: 6px; border: 1px solid var(--border);
  background: transparent; color: var(--dim); cursor: pointer; transition: all 0.15s;
  font-family: var(--sans); white-space: nowrap;
}
.region-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-g); }
.region-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-g); box-shadow: 0 0 8px rgba(0,229,255,0.12); }

/* ── Popup ── */
.maplibregl-popup-content {
  background: var(--panel) !important; border: 1px solid var(--border-h) !important;
  border-radius: 12px !important; padding: 14px 16px !important; color: var(--text) !important;
  font-family: var(--sans) !important; font-size: 13px !important;
  backdrop-filter: blur(16px) !important; box-shadow: 0 8px 32px rgba(0,0,0,0.6) !important;
  max-width: 400px !important; min-width: 220px;
}
.maplibregl-popup-tip { border-top-color: var(--panel) !important; }
.maplibregl-popup-close-button { color: var(--dim) !important; font-size: 18px !important; padding: 4px 8px !important; }
.p-name { font-weight: 600; font-size: 14px; margin-bottom: 2px; line-height: 1.3; }
.p-cap { font-family: var(--mono); font-weight: 600; font-size: 15px; margin-bottom: 4px; color: var(--accent); }
.p-row { color: var(--dim); font-size: 12px; line-height: 1.7; }
.p-row span { color: var(--text); }
.p-fuel { display: flex; align-items: center; gap: 5px; font-size: 12px; margin-bottom: 4px; }
.p-fuel-dot { width: 8px; height: 8px; border-radius: 50%; }
.p-badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 10px;
  font-family: var(--mono); font-weight: 500; padding: 2px 8px; border-radius: 4px;
  margin-top: 6px; border: 1px solid; opacity: 0.8;
}
.p-badge-dot { width: 5px; height: 5px; border-radius: 50%; }
.p-mw-bar {
  height: 4px; border-radius: 2px; margin: 6px 0;
  background: rgba(148, 163, 184, 0.15); overflow: hidden;
}
.p-mw-bar-fill { height: 100%; border-radius: 2px; transition: width 0.3s; }

/* ── Hover tooltip (transient, used for raster CF hover-to-sample) ── */
.maplibregl-popup.hover-tooltip { pointer-events: none; }
.maplibregl-popup.hover-tooltip .maplibregl-popup-content {
  padding: 8px 12px !important;
  min-width: 0 !important;
  max-width: 240px !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5) !important;
}
.maplibregl-popup.hover-tooltip .maplibregl-popup-tip { display: none; }
.maplibregl-popup.hover-tooltip .maplibregl-popup-close-button { display: none; }
.hover-tip {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--sans);
  white-space: nowrap;
}
.hover-tip-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dim);
  font-weight: 600;
}
.hover-tip-value {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
}
.hover-tip-sub {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
  margin-left: 2px;
}
.p-name-cap {
  font-family: var(--mono); font-weight: 500; font-size: 12px; color: var(--accent);
  margin-left: 6px;
}
.p-action-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; font-size: 11px; font-family: var(--mono); font-weight: 500;
  background: rgba(0, 229, 255, 0.08); border: 1px solid var(--accent);
  border-radius: 6px; color: var(--accent); cursor: pointer;
  transition: all 0.15s;
}
.p-action-btn:hover {
  background: var(--accent); color: var(--bg);
}
.p-row strong { color: var(--text); display: inline-block; min-width: 80px; font-weight: 500; }

/* ── Search ── */
.search-wrap { padding: 8px 16px; position: relative; }
.search-input {
  width: 100%; padding: 9px 12px 9px 32px; font-size: 13px; font-family: var(--sans);
  background: rgba(148, 163, 184, 0.06); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); outline: none; transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--muted); }
.search-icon {
  position: absolute; left: 26px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.search-results {
  position: absolute; top: 100%; left: 16px; right: 16px;
  background: var(--panel); border: 1px solid var(--border-h);
  border-radius: 8px; max-height: 300px; overflow-y: auto;
  display: none; z-index: 100;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
.search-results.visible { display: block; }
.search-result {
  padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.search-result:hover { background: rgba(0, 229, 255, 0.06); }
.search-result:last-child { border-bottom: none; }
.search-result-layer {
  font-size: 9px; font-family: var(--mono); color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.search-result-text { display: block; font-size: 12px; color: var(--text); margin-top: 2px; }
.search-no-results { padding: 12px; text-align: center; color: var(--muted); font-size: 12px; }

/* ── Toolbar ── */
.toolbar {
  position: absolute; top: 12px; right: 12px; z-index: 90;
  display: flex; gap: 6px;
  animation: atlasReveal 0.3s ease-out 0.1s both;
}
.toolbar-btn {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--glass); color: var(--dim); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(12px); transition: all 0.15s;
}
.toolbar-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-g); box-shadow: 0 0 12px rgba(0,229,255,0.15); }
.toolbar-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-g); }

/* ── Toolbar dropdowns ── */
.tb-dropdown {
  position: fixed; z-index: 200;
  background: var(--panel); border: 1px solid var(--border-h); border-radius: 12px;
  padding: 8px; min-width: 260px; max-width: 320px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.7); backdrop-filter: blur(20px);
  opacity: 0; transform: translateY(-4px); transition: all 0.15s;
}
.tb-dropdown.visible { opacity: 1; transform: translateY(0); }
.tb-dropdown-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text);
  transition: background 0.1s;
}
.tb-dropdown-item:hover { background: rgba(0,229,255,0.06); }
.tb-dropdown-item.active { background: rgba(0,229,255,0.1); border: 1px solid var(--accent); }
.tb-dropdown-item strong { display: block; font-size: 13px; }
.tb-dd-desc { font-size: 11px; color: var(--muted); display: block; margin-top: 2px; }
.tb-dd-on { font-family: var(--mono); font-size: 10px; color: var(--accent); margin-left: auto; }
.tb-dd-link {
  padding: 10px 12px; color: var(--accent); font-size: 12px; cursor: pointer;
  border-top: 1px solid var(--border); margin-top: 4px;
}
.tb-region { gap: 8px; }
.tb-dd-section {
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em;
  padding: 8px 12px 4px;
}
.tb-dd-divider {
  height: 1px; background: var(--border); margin: 6px 4px;
}

/* ── Stats bar ── */
.stats-bar {
  position: absolute; top: 12px; right: 160px; z-index: 80;
  display: flex; gap: 8px;
}
.stat-chip {
  font-family: var(--mono); font-size: 11px; color: var(--dim);
  background: var(--glass); padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--border); backdrop-filter: blur(12px); white-space: nowrap;
}
.stat-chip strong { color: var(--accent); font-weight: 600; }
.stat-chip { transition: all 0.3s ease; }

/* ── Basemap switcher with thumbnail grid ── */
.basemap-switcher {
  position: absolute; bottom: 80px; left: 320px; z-index: 90;
}
.basemap-trigger {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px;
  background: var(--glass); border: 1px solid var(--border); border-radius: 8px;
  color: var(--dim); cursor: pointer; font-family: var(--sans); font-size: 11px;
  backdrop-filter: blur(12px); transition: all 0.15s;
}
.basemap-trigger:hover { border-color: var(--accent); color: var(--accent); }
.basemap-grid {
  position: absolute; bottom: 100%; left: 0; margin-bottom: 8px;
  background: var(--panel); border: 1px solid var(--border-h); border-radius: 12px;
  padding: 10px; display: none; gap: 8px;
  grid-template-columns: repeat(4, 1fr);
  box-shadow: 0 12px 40px rgba(0,0,0,0.7);
  backdrop-filter: blur(20px);
  min-width: 340px;
}
.basemap-grid.visible { display: grid; }
.basemap-thumb {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: rgba(148,163,184,0.05); border: 2px solid transparent;
  border-radius: 8px; padding: 4px; cursor: pointer; transition: all 0.15s;
}
.basemap-thumb:hover { border-color: var(--border-h); background: rgba(148,163,184,0.1); }
.basemap-thumb.active { border-color: var(--accent); background: var(--accent-g); }
.basemap-thumb img { border-radius: 4px; display: block; }
.basemap-thumb-color { width: 72px; height: 50px; border-radius: 4px; }
.basemap-thumb-label {
  font-size: 9px; font-family: var(--mono); color: var(--muted);
  text-align: center; white-space: nowrap;
}
.basemap-thumb.active .basemap-thumb-label { color: var(--accent); }

/* ── Bubble legend ── */
.bubble-legend-wrap { padding: 8px 0 4px; }
.section-subtitle {
  font-size: 9px; font-weight: 600; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.06em; margin-bottom: 4px;
}

/* ── Settings panel (slide-out) ── */
.sp-panel {
  position: fixed; top: 0; right: -360px; z-index: 200;
  width: 340px; height: 100vh;
  background: var(--panel); border-left: 1px solid var(--border-h);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  overflow-y: auto; overflow-x: hidden;
  transition: right 0.25s ease;
  scrollbar-width: thin; scrollbar-color: var(--muted) transparent;
}
.sp-panel.visible { right: 0; }
.sp-panel::-webkit-scrollbar { width: 4px; }
.sp-panel::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 2px; }
.sp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 12px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--panel); z-index: 1;
}
.sp-title { font-size: 16px; font-weight: 600; color: var(--text); }
.sp-close {
  background: none; border: none; color: var(--dim); font-size: 22px;
  cursor: pointer; padding: 4px 8px; transition: color 0.15s;
}
.sp-close:hover { color: var(--text); }
.sp-body { padding: 14px 18px; }
.sp-section { margin-bottom: 4px; }
.sp-section-title {
  font-size: 10px; font-weight: 600; color: var(--dim); text-transform: uppercase;
  letter-spacing: 0.06em; margin-bottom: 8px;
}
.sp-sep { height: 1px; background: var(--border); margin: 14px 0; }
.sp-radio, .sp-check {
  display: flex; align-items: center; gap: 8px; padding: 5px 0;
  font-size: 12.5px; color: var(--text); cursor: pointer;
}
.sp-radio input, .sp-check input { accent-color: var(--accent); width: 15px; height: 15px; }

/* Status toggle buttons */
.sp-status-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.sp-status-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px; border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--dim); cursor: pointer;
  font-size: 10px; font-family: var(--sans); transition: all 0.15s;
}
.sp-status-btn:hover { border-color: var(--border-h); }
.sp-status-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-g); }
.sp-status-icon { font-size: 16px; }

/* Select dropdowns */
.sp-field { margin-bottom: 8px; }
.sp-field-label { font-size: 11px; font-weight: 600; color: var(--dim); display: block; margin-bottom: 4px; }
.sp-select {
  width: 100%; padding: 8px 10px; font-size: 12px; font-family: var(--sans);
  background: rgba(148,163,184,0.06); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.sp-select:focus { border-color: var(--accent); outline: none; }

/* Sliders */
.sp-slider-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.sp-slider-label { font-size: 12px; color: var(--text); }
.sp-slider-value { font-family: var(--mono); font-size: 11px; color: var(--accent); }
.sp-slider-wrap { display: flex; gap: 8px; align-items: center; }
.sp-slider {
  flex: 1; height: 6px; -webkit-appearance: none; appearance: none;
  background: rgba(148,163,184,0.2); border-radius: 3px; outline: none;
}
.sp-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 2px solid var(--bg);
}
.sp-slider-num {
  width: 52px; padding: 4px 6px; font-size: 11px; font-family: var(--mono);
  background: rgba(148,163,184,0.06); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); text-align: center;
}

/* MW filter */
.sp-mw-filter {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  font-size: 12px; color: var(--text);
}
.sp-mw-input {
  width: 70px; padding: 5px 8px; font-size: 12px; font-family: var(--mono);
  background: rgba(148,163,184,0.06); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); text-align: center;
}

/* Color palettes */
.sp-palettes { display: flex; flex-direction: column; gap: 4px; }
.sp-palette {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 5px 8px; border-radius: 6px;
  background: none; border: 1px solid transparent; cursor: pointer;
  transition: all 0.15s;
}
.sp-palette:hover { border-color: var(--border-h); background: rgba(148,163,184,0.04); }
.sp-palette.active { border-color: var(--accent); background: var(--accent-g); }
.sp-palette-ramp {
  display: flex; flex: 1; border-radius: 3px; overflow: hidden; height: 16px;
}
.sp-palette-ramp span { flex: 1; }
.sp-palette-label {
  font-size: 11px; color: var(--text); min-width: 70px; text-align: right;
}
.sp-palette.active .sp-palette-label { color: var(--accent); }

/* Color swatches */
.sp-color-swatches { display: flex; gap: 6px; margin-bottom: 8px; }
.sp-swatch {
  width: 32px; height: 32px; border-radius: 6px; cursor: pointer;
  border: 2px solid transparent; transition: all 0.15s;
}
.sp-swatch:hover { border-color: var(--border-h); }
.sp-swatch.active { border-color: var(--accent); box-shadow: 0 0 8px rgba(0,229,255,0.3); }

/* Hint text */
.sp-hint {
  font-size: 10px; color: var(--muted); margin-top: 4px; line-height: 1.4;
}

/* ── Layers quick-toggle panel ── */
.layers-panel { position: absolute; bottom: 80px; left: 430px; z-index: 90; }
.layers-trigger {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px;
  background: var(--glass); border: 1px solid var(--border); border-radius: 8px;
  color: var(--dim); cursor: pointer; font-family: var(--sans); font-size: 11px;
  backdrop-filter: blur(12px); transition: all 0.15s;
}
.layers-trigger:hover { border-color: var(--accent); color: var(--accent); }
.layers-grid-popup {
  position: absolute; bottom: 100%; left: 0; margin-bottom: 8px;
  background: var(--panel); border: 1px solid var(--border-h); border-radius: 14px;
  padding: 16px 20px; display: none; min-width: 360px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.7); backdrop-filter: blur(20px);
}
.layers-grid-popup.visible { display: block; }
.lg-group-label {
  font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.08em; margin-bottom: 8px; margin-top: 12px;
}
.lg-group-label:first-child { margin-top: 0; }
.lg-group-items { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 6px; }
.lg-item {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 6px; border-radius: 10px; border: 1px solid var(--border);
  background: transparent; color: var(--dim); cursor: pointer;
  font-size: 10px; font-family: var(--sans); transition: all 0.15s;
}
.lg-item:hover { border-color: var(--border-h); }
.lg-item.active { border-color: var(--accent); color: var(--accent); background: var(--accent-g); }
.lg-item.locked {
  border-color: rgba(251, 191, 36, 0.28);
  color: var(--muted);
  background: rgba(251, 191, 36, 0.04);
}
.lg-item.locked .lg-icon { opacity: 0.55; }
.lg-item.locked:hover {
  border-color: var(--warn);
  color: var(--warn);
  background: rgba(251, 191, 36, 0.1);
}
.lg-item.locked .lg-icon,
.lg-item.locked .lg-label { filter: grayscale(0.3); }
.lg-lock {
  position: absolute;
  top: 5px; right: 5px;
  width: 14px; height: 14px;
  background: var(--warn);
  color: #0a0f1e;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px var(--panel);
  pointer-events: none;
}
.lg-icon { font-size: 20px; line-height: 1; }
.lg-label { white-space: nowrap; }

/* ── Color radio (Fiber) ── */
.sp-color-radio {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px;
  cursor: pointer; font-size: 13px; color: var(--text); border-radius: 6px;
  transition: background 0.1s;
}
.sp-color-radio:hover { background: rgba(148,163,184,0.06); }
.sp-color-radio input { display: none; }
.sp-color-radio.active, .sp-color-radio:has(input:checked) { background: rgba(148,163,184,0.1); }
.sp-color-dot {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid transparent;
}
.sp-color-radio.active .sp-color-dot,
.sp-color-radio:has(input:checked) .sp-color-dot { border-color: var(--accent); }

/* ── Chat panel ── */
.chat-panel {
  position: fixed; bottom: 60px; right: 12px; z-index: 200;
  width: 380px; height: 500px;
  background: var(--panel); border: 1px solid var(--border-h); border-radius: 14px;
  backdrop-filter: blur(24px); box-shadow: 0 16px 48px rgba(0,0,0,0.7);
  display: none; flex-direction: column; overflow: hidden;
}
.chat-panel.visible { display: flex; }
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.chat-title { font-size: 14px; font-weight: 600; color: var(--accent); font-family: var(--mono); }
.chat-close {
  background: none; border: none; color: var(--dim); font-size: 20px;
  cursor: pointer; padding: 4px 8px;
}
.chat-close:hover { color: var(--text); }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 12px 16px;
  scrollbar-width: thin; scrollbar-color: var(--muted) transparent;
}
.chat-msg { margin-bottom: 12px; }
.chat-msg-text {
  font-size: 13px; line-height: 1.5; color: var(--text);
  white-space: pre-wrap; word-wrap: break-word;
}
.chat-user .chat-msg-text {
  background: var(--accent-g); border: 1px solid rgba(0,229,255,0.2);
  padding: 8px 12px; border-radius: 10px 10px 2px 10px;
  color: var(--accent); display: inline-block; max-width: 90%;
  float: right;
}
.chat-bot .chat-msg-text {
  background: rgba(148,163,184,0.06); border: 1px solid var(--border);
  padding: 8px 12px; border-radius: 10px 10px 10px 2px;
  display: inline-block; max-width: 95%;
}
.chat-msg::after { content: ''; display: table; clear: both; }
.chat-typing .chat-msg-text { opacity: 0.5; font-style: italic; }
.chat-examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chat-example {
  font-size: 11px; padding: 4px 10px; border-radius: 12px;
  border: 1px solid var(--border); background: none;
  color: var(--accent); cursor: pointer; font-family: var(--sans);
  transition: all 0.15s;
}
.chat-example:hover { background: var(--accent-g); border-color: var(--accent); }
.chat-enhanced {
  margin-top: 8px; padding: 8px 12px; border-radius: 8px;
  background: rgba(0,229,255,0.04); border: 1px solid rgba(0,229,255,0.12);
  font-size: 12px; color: var(--dim);
}
.chat-enhanced-label {
  font-size: 9px; font-weight: 600; color: var(--accent); text-transform: uppercase;
  letter-spacing: 0.06em; margin-bottom: 4px;
}
.chat-input-wrap {
  display: flex; gap: 8px; padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.chat-input {
  flex: 1; padding: 10px 14px; font-size: 13px; font-family: var(--sans);
  background: rgba(148,163,184,0.06); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); outline: none;
}
.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: var(--muted); }
.chat-send {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent-g); border: 1px solid var(--accent);
  color: var(--accent); cursor: pointer; display: flex;
  align-items: center; justify-content: center; transition: all 0.15s;
}
.chat-send:hover { background: var(--accent); color: var(--bg); }

/* ── Mini globe overview map ── */
.atlas-minimap {
  position: absolute; bottom: 60px; right: 16px; z-index: 85;
  width: 140px; height: 140px;
  border-radius: 50%;
  overflow: hidden;
  /* Light basemap → light background behind the canvas so tiles read
     crisply; a solid dark ring frames the globe against the main map. */
  background: #e8e4da;
  border: 3px solid #0a0f1e;
  box-shadow: 0 0 20px rgba(0,0,0,0.6), 0 0 40px rgba(0,229,255,0.05);
  cursor: grab;
  transition: all 0.2s;
}
.atlas-minimap:hover {
  border-color: var(--accent);
  box-shadow: 0 0 24px rgba(0,229,255,0.3), 0 0 48px rgba(0,229,255,0.12);
}
.atlas-minimap:active { cursor: grabbing; }
.atlas-minimap .maplibregl-canvas-container { border-radius: 50%; }
.atlas-minimap canvas { border-radius: 50%; cursor: inherit; }
.atlas-minimap .maplibregl-canvas-container.maplibregl-interactive { cursor: inherit !important; }
.atlas-minimap .maplibregl-canvas-container.maplibregl-interactive:active { cursor: inherit !important; }
.atlas-minimap .maplibregl-control-container { display: none; }

@media (max-width: 640px) {
  .atlas-minimap { width: 90px; height: 90px; bottom: 70px; right: 8px; }
}

/* ── Brand ── */
.brand {
  position: absolute; bottom: 8px; left: 12px; z-index: 80;
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  background: var(--glass); padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--border); backdrop-filter: blur(12px);
}
.brand strong { color: var(--accent); font-weight: 600; }

/* ── Site Analysis panel ── */
.sa-panel {
  position: absolute; top: 12px; right: 12px; z-index: 95;
  width: 360px; max-height: calc(100vh - 24px);
  background: var(--panel); border: 1px solid var(--border-h); border-radius: 14px;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 12px 48px rgba(0,0,0,0.7);
  overflow-y: auto; overflow-x: hidden;
  font-family: var(--sans); font-size: 13px;
  opacity: 0; transform: translateX(8px); transition: all 0.2s;
}
.sa-panel.visible { opacity: 1; transform: translateX(0); }
.sa-panel::-webkit-scrollbar { width: 4px; }
.sa-panel::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 2px; }

.sa-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--panel); backdrop-filter: blur(20px); z-index: 1;
}
.sa-anchor-name {
  font-size: 14px; font-weight: 600; color: var(--text);
  line-height: 1.3; margin-bottom: 3px;
}
.sa-anchor-sub {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
}
.sa-close {
  background: none; border: none; color: var(--dim);
  font-size: 22px; line-height: 1; padding: 0 4px;
  cursor: pointer; transition: color 0.15s;
}
.sa-close:hover { color: var(--accent); }

/* Radius slider */
.sa-radius {
  padding: 14px 16px 16px;
  border-bottom: 1px solid var(--border);
}
.sa-radius-row {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 8px;
}
.sa-radius-label {
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em;
}
.sa-radius-value {
  font-family: var(--mono); font-size: 13px; font-weight: 600;
  color: var(--accent);
}
.sa-radius-slider {
  width: 100%; height: 4px; background: rgba(148,163,184,0.18);
  border-radius: 2px; outline: none; -webkit-appearance: none; appearance: none;
  cursor: pointer;
}
.sa-radius-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 0 8px rgba(0,229,255,0.4);
}
.sa-radius-slider::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
  border: 2px solid var(--bg);
}

/* Section title above the summary cards */
.sa-section-title {
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  color: var(--accent); text-transform: uppercase; letter-spacing: 0.1em;
  padding: 14px 16px 8px;
}

/* Summary cards (Generation / DCs / Substations) */
.sa-summary-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 6px; padding: 0 16px 14px;
  border-bottom: 1px solid var(--border);
}
.sa-summary-card {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 8px;
  text-align: center;
}
.sa-summary-value {
  font-family: var(--mono); font-size: 18px; font-weight: 700;
  color: var(--accent); line-height: 1.1;
}
.sa-summary-label {
  font-size: 9.5px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.05em; margin-top: 4px; line-height: 1.2;
}

/* Sections (Operating Plants / Data Centers / Substations) */
.sa-section {
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.sa-section:last-child { border-bottom: none; }
.sa-section-header {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.sa-empty {
  font-size: 11px; color: var(--muted); font-style: italic;
}

.sa-item {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 10px; padding: 8px 0;
  border-top: 1px solid rgba(148,163,184,0.08);
}
.sa-item:first-of-type { border-top: none; }
.sa-item-main { flex: 1; min-width: 0; }
.sa-item-title {
  font-size: 13px; color: var(--text); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sa-item-sub {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--dim); margin-top: 2px;
}
.sa-dot {
  width: 7px; height: 7px; border-radius: 50%;
  flex-shrink: 0;
}
.sa-item-right {
  text-align: right; font-family: var(--mono); flex-shrink: 0;
}
.sa-item-value {
  font-size: 12px; font-weight: 600; color: var(--text);
}
.sa-item-distance {
  font-size: 10px; color: var(--accent); margin-top: 2px;
  background: rgba(0,229,255,0.08); padding: 1px 6px; border-radius: 3px;
  display: inline-block;
}
.sa-more {
  display: block;
  width: 100%;
  text-align: center; padding: 7px 0;
  font-size: 11px; color: var(--accent); cursor: pointer;
  font-family: var(--mono);
  background: rgba(0,229,255,0.06);
  border: 1px solid rgba(0,229,255,0.2);
  border-radius: 4px;
  margin-top: 6px;
  transition: all 0.15s;
}
.sa-more:hover {
  background: rgba(0,229,255,0.12);
  border-color: rgba(0,229,255,0.5);
}

/* "Site analysis" trigger button (lives inside popup HTML) */
.sa-trigger-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; margin-top: 8px;
  background: rgba(0, 229, 255, 0.1);
  border: 1px solid rgba(0, 229, 255, 0.4);
  border-radius: 6px;
  color: var(--accent); cursor: pointer;
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  transition: all 0.15s;
}
.sa-trigger-btn:hover {
  background: rgba(0, 229, 255, 0.2);
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.2);
}

@media (max-width: 1100px) {
  .sa-panel { width: 320px; }
}

/* ── Site Analysis v2: Asset Score Block ─────────────────────────── */
.sa-asset-block {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(0,229,255,0.04) 0%, transparent 100%);
}
.sa-asset-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
}
.sa-asset-icon {
  font-size: 18px;
}
.sa-asset-label {
  font-size: 14px; font-weight: 600; color: var(--text);
  font-family: var(--sans);
}
.sa-verdict {
  padding: 12px;
  border-radius: 8px;
  border-left: 3px solid transparent;
  margin-bottom: 12px;
}
.sa-verdict-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px;
}
.sa-verdict-badge {
  font-family: var(--mono); font-size: 9px; font-weight: 700;
  padding: 4px 8px; border-radius: 4px;
  letter-spacing: 0.05em;
}
.sa-verdict-score {
  font-family: var(--mono); font-size: 22px; font-weight: 700;
}
.sa-verdict-label {
  font-size: 11px; color: var(--dim); font-weight: 500;
}
.sa-required {
  margin-bottom: 10px;
  padding: 8px 10px;
  background: rgba(148,163,184,0.06);
  border-radius: 6px;
}
.sa-required-label {
  font-family: var(--mono); font-size: 9px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 3px;
}
.sa-required-value {
  font-size: 12px; color: var(--text); font-weight: 500;
}
.sa-best-match {
  margin-bottom: 10px;
  padding: 8px 10px;
  background: rgba(0,229,255,0.05);
  border-left: 2px solid var(--accent);
  border-radius: 4px;
}
.sa-best-match-label {
  font-family: var(--mono); font-size: 9px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 2px;
}
.sa-best-match-value {
  font-size: 11px; color: var(--text);
}
.sa-reasons-label {
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  color: var(--accent); text-transform: uppercase; letter-spacing: 0.1em;
  margin: 12px 0 6px;
}
.sa-reasons-list {
  list-style: none; padding: 0; margin: 0;
}
.sa-reason {
  position: relative;
  padding-left: 14px;
  margin-bottom: 5px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--dim);
}
.sa-reason::before {
  content: '•';
  position: absolute; left: 4px;
  color: var(--accent);
  font-weight: 700;
}
.sa-asset-hint {
  margin-top: 10px;
  padding: 6px 8px;
  background: rgba(251,191,36,0.06);
  border-left: 2px solid var(--warn);
  font-size: 10px;
  color: var(--warn);
  line-height: 1.4;
  border-radius: 3px;
}

/* Mini-card style for the four Site Analysis v2.1 score blocks
   (Connection, Power Availability, Local Price, Suitability) */
.sa-mini-card {
  margin-top: 10px;
  padding: 10px 12px;
  border-left: 3px solid transparent;
  border-radius: 6px;
}
.sa-mini-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.sa-mini-title {
  font-family: var(--mono); font-size: 9px; font-weight: 700;
  color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em;
}
.sa-mini-badge {
  font-family: var(--mono); font-size: 9px; font-weight: 700;
  padding: 3px 7px; border-radius: 3px;
  letter-spacing: 0.04em;
}
.sa-mini-row {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 8px;
  font-size: 11px;
  margin-bottom: 4px;
  line-height: 1.4;
}
.sa-mini-row:last-child { margin-bottom: 0; }
.sa-mini-label {
  color: var(--muted);
  flex-shrink: 0;
}
.sa-mini-value {
  color: var(--text);
  text-align: right;
  font-size: 11px;
}
.sa-mini-value strong {
  font-weight: 600;
}
.sa-mini-sub {
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
}
.sa-mini-hint {
  margin-top: 6px;
  font-size: 10px;
  color: var(--dim);
  font-style: italic;
  line-height: 1.4;
}
.sa-power-bar {
  margin-top: 8px;
  height: 5px;
  background: rgba(148,163,184,0.15);
  border-radius: 2px;
  overflow: hidden;
}
.sa-power-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #84cc16);
  border-radius: 2px;
  transition: width 0.3s;
}

/* ── Asset Placer Modal ──────────────────────────────────────────── */
.asset-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  opacity: 0; transition: opacity 0.2s;
}
.asset-modal.visible { opacity: 1; }
.asset-modal-inner {
  background: var(--panel);
  border: 1px solid var(--border-h);
  border-radius: 14px;
  width: 480px; max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  box-shadow: 0 24px 72px rgba(0,0,0,0.7);
  font-family: var(--sans);
}
.asset-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.asset-modal-title {
  font-size: 15px; font-weight: 600; color: var(--text);
}
.asset-modal-close {
  background: none; border: none; color: var(--dim);
  font-size: 24px; line-height: 1; cursor: pointer; padding: 0 4px;
  transition: color 0.15s;
}
.asset-modal-close:hover { color: var(--accent); }
.asset-modal-body {
  padding: 16px 20px 20px;
}
.asset-modal-hint {
  font-size: 12px; color: var(--dim); line-height: 1.5;
  margin-bottom: 16px;
}
.asset-type-label,
.asset-mw-label {
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  color: var(--accent); text-transform: uppercase; letter-spacing: 0.1em;
  margin: 12px 0 8px;
}
.asset-type-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.asset-type-btn {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  background: rgba(148,163,184,0.06);
  border: 1px solid var(--border-h);
  border-radius: 8px;
  color: var(--text); cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  font-family: var(--sans);
}
.asset-type-btn:hover {
  background: rgba(148,163,184,0.12);
  border-color: var(--muted);
}
.asset-type-btn.active {
  background: rgba(0,229,255,0.1);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(0,229,255,0.3);
}
.asset-type-icon { font-size: 18px; margin-bottom: 2px; }
.asset-type-label-name {
  font-size: 12px; font-weight: 600;
}
.asset-type-default {
  font-family: var(--mono); font-size: 9px; color: var(--muted);
}
.asset-mw-wrap {
  display: flex; align-items: center; gap: 8px;
  background: rgba(148,163,184,0.06);
  border: 1px solid var(--border-h);
  border-radius: 8px;
  padding: 0 12px;
}
.asset-mw-input {
  flex: 1;
  background: none; border: none; outline: none;
  color: var(--text);
  font-family: var(--mono); font-size: 15px; font-weight: 500;
  padding: 10px 0;
}
.asset-mw-unit {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  text-transform: uppercase;
}
.asset-place-btn {
  width: 100%;
  padding: 12px;
  margin-top: 16px;
  background: var(--accent);
  color: var(--bg);
  border: none; border-radius: 8px;
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.15s;
}
.asset-place-btn:hover {
  background: var(--accent);
  box-shadow: 0 0 24px rgba(0,229,255,0.3);
}
/* Place-asset toolbar button active state */
#btn-place-asset.active {
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 0 16px rgba(0,229,255,0.4);
}

/* ── Forecast Panel (bottom slide-up) ── */
.forecast-panel {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 280px;
  z-index: 100;
  background: var(--panel);
  border-top: 1px solid var(--border-h);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 -8px 32px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.25s ease;
}
.forecast-panel.visible {
  transform: translateY(0);
}
.fp-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.fp-title-wrap {
  flex: 1;
  min-width: 0;
}
.fp-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.fp-subtitle {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  display: block;
  margin-top: 2px;
}
.fp-stats {
  display: flex;
  gap: 16px;
  flex-shrink: 0;
}
.fp-stat {
  text-align: center;
}
.fp-stat-value {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: block;
}
.fp-stat-label {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.fp-close {
  background: none;
  border: none;
  color: var(--dim);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  transition: color 0.15s;
}
.fp-close:hover { color: var(--accent); }
.fp-chart-wrap {
  flex: 1;
  min-height: 0;
  padding: 0 8px;
}
.fp-footer {
  padding: 6px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.fp-source {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted);
}
.fp-source strong {
  color: var(--accent);
}

/* Forecast button in popups — inherits .sa-trigger-btn base */
.forecast-btn:hover {
  box-shadow: 0 0 12px rgba(8,145,178,0.2);
}

@media (max-width: 640px) {
  .forecast-panel { height: 220px; }
  .fp-stats { gap: 10px; }
  .fp-stat-value { font-size: 12px; }
}

/* ── Toast ── */
.atlas-toast {
  position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--accent);
  color: var(--accent); font-family: var(--mono); font-size: 12px;
  padding: 8px 20px; border-radius: 8px; z-index: 999;
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
.atlas-toast.visible { opacity: 1; }

/* ── Attribution override ── */
.maplibregl-ctrl-attrib { background: rgba(6,6,12,0.7) !important; font-size: 10px !important; }
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }
.maplibregl-ctrl-group { background: var(--glass) !important; border: 1px solid var(--border) !important; border-radius: 8px !important; }
.maplibregl-ctrl-group button { width: 32px !important; height: 32px !important; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--border) !important; }
.maplibregl-ctrl button .maplibregl-ctrl-icon { filter: invert(1) brightness(0.7); }

/* ── Responsive: Tablet ── */
@media (max-width: 900px) {
  .panel { width: 280px; }
  .basemap-switcher { left: 300px; }
  .layers-panel { left: 410px; }
  .basemap-grid { min-width: 280px; grid-template-columns: repeat(3, 1fr); }
  .chat-panel { width: 320px; }
  .sp-panel { width: 300px; }
}

/* ── Light theme: element-specific overrides ────────────────────── */
/* These cover elements that use hardcoded dark-theme colours (black
   shadows, dark borders, opaque backgrounds) and need to flip when
   the sidebar is in light mode. Everything that reads CSS variables
   flips automatically; these are the stragglers. */
body.theme-light .toolbar-btn {
  background: rgba(255,255,255,0.85);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
body.theme-light .toolbar-btn:hover {
  box-shadow: 0 0 12px rgba(8,145,178,0.15);
}
body.theme-light .tb-dropdown {
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
body.theme-light .atlas-minimap {
  background: #e8e4da;
  border-color: #334155;
}
body.theme-light .sa-panel {
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}
body.theme-light .sp-panel {
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}
body.theme-light .sb-group-header {
  background: rgba(8, 145, 178, 0.04);
}
body.theme-light .sb-group-header:hover {
  background: rgba(8, 145, 178, 0.08);
}
body.theme-light .section-lock {
  border-color: rgba(217, 119, 6, 0.35);
  color: var(--warn);
}
/* Light popups */
body.theme-light .maplibregl-popup-content {
  background: rgba(255,255,255,0.96) !important;
  color: #0f172a !important;
  box-shadow: 0 6px 24px rgba(0,0,0,0.12) !important;
  border: 1px solid rgba(0,0,0,0.06) !important;
}
body.theme-light .maplibregl-popup-tip {
  border-top-color: rgba(255,255,255,0.96) !important;
}
/* Light toast */
body.theme-light .atlas-toast {
  background: rgba(255,255,255,0.92);
  border-color: var(--accent);
  color: var(--accent);
}

/* Site Analysis panel mobile responsiveness */
@media (max-width: 640px) {
  .sa-panel {
    width: 100% !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    max-height: 55vh !important;
    border-radius: 14px 14px 0 0 !important;
  }
}

/* ── Responsive: Mobile ── */
@media (max-width: 640px) {
  .panel {
    width: 100%; left: 0; top: auto; bottom: 0;
    max-height: 45vh; border-radius: 14px 14px 0 0;
    border-bottom: none;
  }
  .panel-header { padding: 10px 14px 8px; }
  .regions { padding: 6px 14px; }
  .region-btn { font-size: 11px; padding: 4px 8px; }
  .search-wrap { padding: 6px 14px; }
  .stats-bar { display: none; }
  .toolbar { right: 8px; top: 8px; gap: 4px; }
  .toolbar-btn { width: 32px; height: 32px; }
  .brand { display: none; }
  .basemap-switcher { left: 8px; bottom: auto; top: 8px; }
  .layers-panel { left: 120px; bottom: auto; top: 8px; }
  .basemap-grid { min-width: 240px; grid-template-columns: repeat(3, 1fr); }
  .chat-panel { width: 100%; right: 0; bottom: 0; height: 60vh; border-radius: 14px 14px 0 0; }
  .sp-panel { width: 100%; right: 0; }
  .search-input { font-size: 16px; } /* prevents iOS zoom */
  .chat-input { font-size: 16px; }
  .legend-item { min-height: 44px; } /* touch target */
  .section-gear { padding: 10px; font-size: 18px; }
  .section-toggle { padding: 6px; }
  .lg-group-items { grid-template-columns: repeat(3, 1fr); }
}

/* ── Beta lock / padlock UI ──────────────────────────────────── */
/* Locked sidebar sections show a small padlock where the gear+
   toggle normally sit. The title text becomes amber-tinted and
   the click handler opens the unlock modal. */
.section.locked .section-title-text {
  color: var(--warn);
  opacity: 0.85;
}
.section.locked .section-title-text::before {
  content: '';
  display: inline-block;
  width: 0; height: 0;
}
.section-lock {
  background: none;
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: var(--warn);
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.section-lock:hover {
  background: rgba(251, 191, 36, 0.12);
  border-color: var(--warn);
}

/* Coming Soon badge — grey-toned, shows the integration brand
   (CompoundVision / Gridsight) alongside a "Coming Soon" label. */
.section-coming-soon {
  display: flex;
  align-items: center;
  gap: 6px;
}
.coming-soon-brand {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.coming-soon-badge {
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: var(--input-bg);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
}
.section.locked-by-coming_soon .section-title-text {
  color: var(--muted);
  opacity: 0.7;
}

/* Lock indicator on the place-asset toolbar button */
.toolbar-btn-lock {
  display: none;
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background: var(--warn);
  color: #0a0f1e;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--bg);
}
.toolbar-btn.locked { position: relative; }
.toolbar-btn.locked .toolbar-btn-lock { display: flex; }
.toolbar-btn.locked { color: var(--muted); }
.toolbar-btn.locked:hover { color: var(--warn); }

/* ── Unlock modal ─────────────────────────────────────────────── */
.unlock-modal {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
  opacity: 0; transition: opacity 0.18s;
}
.unlock-modal.visible { opacity: 1; }
.unlock-modal-inner {
  background: var(--panel);
  border: 1px solid var(--border-h);
  border-radius: 14px;
  width: 460px; max-width: calc(100vw - 32px);
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.7);
  font-family: var(--sans);
}
.unlock-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.unlock-modal-title {
  font-size: 15px; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.unlock-modal-title::before {
  content: '\1F512';   /* 🔒 */
  font-size: 15px;
  filter: hue-rotate(20deg);
}
.unlock-modal-close {
  background: none; border: none; color: var(--dim);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px;
  transition: color 0.15s;
}
.unlock-modal-close:hover { color: var(--accent); }
.unlock-modal-body {
  padding: 16px 20px 20px;
}
.unlock-modal-reason {
  margin-bottom: 12px;
  padding: 8px 12px;
  background: rgba(251, 191, 36, 0.08);
  border-left: 2px solid var(--warn);
  font-size: 11px;
  color: var(--warn);
  border-radius: 3px;
  line-height: 1.5;
}
.unlock-modal-hint {
  font-size: 12px;
  color: var(--dim);
  line-height: 1.5;
  margin-bottom: 14px;
}
.unlock-key-label {
  display: block;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}
.unlock-key-input {
  width: 100%;
  padding: 10px 12px;
  background: rgba(148, 163, 184, 0.06);
  border: 1px solid var(--border-h);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}
.unlock-key-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.15);
}
.unlock-error {
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(251, 113, 133, 0.08);
  border-left: 2px solid var(--danger);
  color: var(--danger);
  font-size: 11px;
  border-radius: 3px;
}
.unlock-modal-primary {
  width: 100%;
  padding: 12px;
  margin-top: 14px;
  background: var(--accent);
  color: var(--bg);
  border: none; border-radius: 8px;
  font-family: var(--mono);
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
}
.unlock-modal-primary:hover:not(:disabled) {
  background: var(--accent);
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.3);
}
.unlock-modal-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}
.unlock-modal-secondary, .unlock-modal-danger {
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  background: transparent;
  border: 1px solid var(--border-h);
  border-radius: 8px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.unlock-modal-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.unlock-modal-danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}
.unlock-modal-footer {
  margin-top: 14px;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}
.unlock-modal-footer a {
  color: var(--accent);
  text-decoration: none;
}
.unlock-modal-footer a:hover {
  text-decoration: underline;
}

.unlock-user-card {
  background: rgba(0, 229, 255, 0.05);
  border: 1px solid rgba(0, 229, 255, 0.2);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}
.unlock-user-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  margin-bottom: 5px;
}
.unlock-user-row:last-child { margin-bottom: 0; }
.unlock-user-label {
  font-family: var(--mono);
  color: var(--muted);
  text-transform: uppercase;
  font-size: 9px;
  letter-spacing: 0.06em;
}
.unlock-user-value {
  color: var(--text);
  text-align: right;
  font-family: var(--mono);
  font-size: 11px;
}
