:root {
  --obsidian: #070b0a;
  --panel: #0c1412;
  --panel-light: #121e1b;
  --emerald-neon: #00ff9d;
  --emerald-core: #10b981;
  --gold: #f59e0b;
  --cyan: #06b6d4;
  --ink: #f1f5f9;
  --muted: #94a3b8;
  --line: #1e293b;
  --emerald-glow: 0 0 24px rgba(16, 185, 129, 0.28);
  --gold-glow: 0 0 20px rgba(245, 158, 11, 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--obsidian);
  color: var(--ink);
  overflow: hidden;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.hidden { display: none !important; }

#map { width: 100%; height: 100%; z-index: 1; background: var(--obsidian); }
.leaflet-tile-pane.dark-osm-tiles {
  filter: invert(100%) hue-rotate(172deg) brightness(86%) contrast(106%) saturate(135%);
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--obsidian); }
::-webkit-scrollbar-thumb { background: #1e2f2a; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--emerald-core); }

@keyframes emeraldPulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 255, 157, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 12px rgba(0, 255, 157, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 255, 157, 0); }
}

.anchor-beacon { animation: emeraldPulse 2.4s infinite; }

@media (prefers-reduced-motion: reduce) {
  .anchor-beacon, .ping-dot { animation: none !important; }
}

/* Top HUD */
.hud-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 30;
  pointer-events: none;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud-row {
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hud-pill {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(12, 20, 18, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(16, 185, 129, 0.38);
  border-radius: 16px;
  padding: 6px 10px;
  box-shadow: var(--emerald-glow);
}

.badge-crown {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.3), rgba(245, 158, 11, 0.2));
  border: 1px solid rgba(0, 255, 157, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fbbf24;
  font-size: 16px;
  flex-shrink: 0;
}

.badge-252 {
  position: absolute;
  bottom: -4px;
  right: -4px;
  padding: 1px 5px;
  background: var(--emerald-core);
  color: var(--obsidian);
  font-weight: 800;
  font-size: 9px;
  border-radius: 6px;
}

.hud-title-row { display: flex; align-items: center; gap: 6px; }
.hud-title { font-size: 13px; font-weight: 800; color: #fff; letter-spacing: -0.01em; }
.hud-tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.16);
  color: var(--emerald-neon);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.energy-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 10px; color: #cbd5e1; }
.energy-track {
  width: 84px; height: 8px;
  background: #1e293b; border: 1px solid #334155;
  border-radius: 999px; overflow: hidden;
}
.energy-fill {
  height: 100%;
  background: linear-gradient(90deg, #34d399, var(--emerald-neon));
  transition: width 0.3s ease;
}

.hud-divider { width: 1px; height: 32px; background: rgba(16, 185, 129, 0.22); }

.xp-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(7, 11, 10, 0.9);
  border: 1px solid rgba(245, 158, 11, 0.42);
  border-radius: 12px;
  padding: 6px 10px;
}

.xp-icon {
  width: 24px; height: 24px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid #fbbf24;
  color: #fbbf24;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.xp-value { font-size: 13px; font-weight: 700; color: #fcd34d; line-height: 1; }
.xp-sub { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }

.hud-actions {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-hud {
  min-height: 48px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  border: 1px solid rgba(16, 185, 129, 0.4);
  background: rgba(12, 20, 18, 0.95);
  color: #6ee7b7;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.btn-hud:hover { border-color: var(--emerald-neon); }
.btn-hud.amber { border-color: rgba(245, 158, 11, 0.55); color: #fcd34d; }
.btn-hud.primary {
  background: linear-gradient(90deg, #059669, #10b981);
  color: var(--obsidian);
  border-color: var(--emerald-neon);
  font-weight: 800;
  box-shadow: var(--emerald-glow);
}

/* Corridor Bar */
.corridor-bar {
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  pointer-events: auto;
}

.corridor-tab, .btn-gis {
  min-height: 48px;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  background: rgba(12, 20, 18, 0.95);
  color: #e2e8f0;
  border: 1px solid rgba(16, 185, 129, 0.35);
}
.corridor-tab.active {
  background: var(--emerald-core);
  color: var(--obsidian);
  font-weight: 800;
}
.btn-gis { border-color: rgba(6, 182, 212, 0.55); color: #67e8f9; }

.gis-banner-wrap { max-width: 1600px; width: 100%; margin: 0 auto; pointer-events: auto; }
.gis-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}
.gis-pill.live { background: rgba(2, 44, 34, 0.95); border-color: rgba(0, 255, 157, 0.6); color: var(--emerald-neon); }
.gis-pill.warn { background: rgba(69, 26, 3, 0.95); border-color: rgba(251, 191, 36, 0.7); color: #fcd34d; }

/* Legend */
.map-legend {
  position: fixed;
  bottom: 64px;
  left: 12px;
  z-index: 20;
  background: rgba(12, 20, 18, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px 12px;
  max-width: 265px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
}
.legend-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 10px; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.legend-list { display: flex; flex-direction: column; gap: 6px; font-size: 11px; }
.legend-item { display: flex; align-items: center; gap: 8px; color: #e2e8f0; }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; border: 1px solid; }
.swatch.anchor { background: rgba(16, 185, 129, 0.4); border-color: var(--emerald-neon); }
.swatch.pilot { background: rgba(6, 182, 212, 0.4); border-color: #22d3ee; }
.swatch.concept { background: rgba(245, 158, 11, 0.4); border-color: #fbbf24; }
.swatch.county { background: rgba(100, 116, 139, 0.3); border-color: #94a3b8; }
.legend-note { margin: 8px 0 0; padding-top: 8px; border-top: 1px solid var(--line); font-size: 10px; color: var(--muted); line-height: 1.35; }

/* Property Inspection Card */
.property-card {
  position: fixed;
  z-index: 30;
  top: 140px;
  right: 16px;
  width: 410px;
  max-height: calc(100vh - 190px);
  background: rgba(12, 20, 18, 0.98);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(16, 185, 129, 0.45);
  border-radius: 22px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.28s ease;
}
.property-card.closed { transform: translateX(120%); }

.card-header { padding: 14px 16px 12px; color: #fff; flex-shrink: 0; }
.card-header.anchor { background: linear-gradient(90deg, #047857, #059669, #0f766e); }
.card-header.pilot { background: linear-gradient(90deg, #0e7490, #0284c7, #0f766e); }
.card-header.concept { background: linear-gradient(90deg, #b45309, #d97706, #c2410c); }
.card-header.readonly { background: linear-gradient(90deg, #334155, #475569, #334155); }

.card-header-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card-address { margin: 0; font-size: 16px; font-weight: 900; text-transform: uppercase; line-height: 1.2; }
.card-sub { margin: 3px 0 0; font-size: 11px; font-weight: 700; color: #d1fae5; letter-spacing: 0.06em; text-transform: uppercase; }

.btn-close-circle {
  width: 48px; height: 48px;
  border-radius: 999px;
  border: 0;
  background: rgba(0, 0, 0, 0.32);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.btn-close-circle:hover { background: rgba(0, 0, 0, 0.55); }

.card-status-strip {
  background: var(--obsidian);
  border-bottom: 1px solid var(--line);
  padding: 6px 14px;
  text-align: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--emerald-neon);
}
.card-status-strip.pilot { color: #67e8f9; }
.card-status-strip.concept { color: #fcd34d; }
.card-status-strip.readonly { color: #cbd5e1; }

.card-scroll { overflow-y: auto; flex: 1; }
.card-section { border-bottom: 1px solid rgba(30, 41, 59, 0.9); }
.steward-box { padding: 10px 16px; text-align: center; background: rgba(18, 30, 27, 0.55); }
.meta-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.steward-val { font-size: 13px; font-weight: 800; color: #6ee7b7; text-transform: uppercase; margin-top: 2px; }

.metrics-grid { display: grid; grid-template-columns: 1fr 1fr; background: var(--panel); }
.metric-cell { padding: 12px; text-align: center; }
.metric-cell + .metric-cell { border-left: 1px solid rgba(30, 41, 59, 0.9); }
.metric-val { font-size: 16px; font-weight: 800; margin-top: 2px; }
.metric-val.amber { color: #fbbf24; }
.metric-val.emerald { color: #6ee7b7; font-size: 13px; }
.metric-note { font-size: 10px; color: var(--muted); margin-top: 2px; }

.action-grid {
  padding: 14px;
  background: rgba(7, 11, 10, 0.65);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  text-align: center;
}

.upland-btn {
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: #e2e8f0;
  transition: transform 0.16s ease;
}
.upland-btn:hover { transform: translateY(-2px); }
.upland-circle {
  width: 48px; height: 48px;
  border-radius: 999px;
  background: var(--panel-light);
  border: 2px solid #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
}
.upland-circle.emerald { border-color: #34d399; color: var(--emerald-neon); box-shadow: var(--emerald-glow); }
.upland-circle.cyan { border-color: #22d3ee; color: #67e8f9; }
.upland-circle.amber { border-color: #fbbf24; color: #fcd34d; box-shadow: var(--gold-glow); }
.upland-label { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; }

.module-box { padding: 16px; background: var(--obsidian); border-top: 1px solid rgba(16, 185, 129, 0.3); font-size: 12px; }
.module-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.module-title { font-size: 12px; font-weight: 800; text-transform: uppercase; color: var(--emerald-neon); }
.module-title.amber { color: #fbbf24; }
.module-title.cyan { color: #67e8f9; }
.module-copy { margin: 0 0 12px; color: #cbd5e1; line-height: 1.5; }

.btn-full {
  min-height: 48px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
}
.btn-full.emerald { background: linear-gradient(90deg, #10b981, var(--emerald-neon)); color: var(--obsidian); box-shadow: var(--emerald-glow); }
.btn-full.amber { background: rgba(245, 158, 11, 0.2); border-color: #fbbf24; color: #fcd34d; }
.btn-full.cyan { background: rgba(6, 182, 212, 0.2); border-color: #22d3ee; color: #67e8f9; }
.btn-full.muted { background: #1e293b; border-color: #475569; color: #cbd5e1; }

.prog-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line);
  margin-bottom: 6px;
}
.prog-btn {
  min-height: 40px; padding: 0 10px; border-radius: 8px; font-size: 10px; font-weight: 700; cursor: pointer;
  border: 1px solid #334155; background: #1e293b; color: #cbd5e1;
}
.prog-btn.on { background: rgba(16, 185, 129, 0.2); border-color: rgba(16, 185, 129, 0.45); color: var(--emerald-neon); }

.reg-box { padding: 10px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); display: grid; gap: 6px; font-size: 11px; color: #cbd5e1; }

/* Bottom Stevie Drawer */
.stevie-footer { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; pointer-events: none; padding: 0 12px; }
.stevie-shell {
  max-width: 1600px; margin: 0 auto; pointer-events: auto;
  background: rgba(12, 20, 18, 0.96); backdrop-filter: blur(12px);
  border: 1px solid rgba(16, 185, 129, 0.4); border-bottom: 0;
  border-radius: 16px 16px 0 0; overflow: hidden;
  box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.6);
}
.stevie-toggle {
  min-height: 48px; width: 100%; border: 0; background: transparent; color: #fff;
  padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; text-align: left;
}
.stevie-toggle:hover { background: rgba(18, 30, 27, 0.7); }
.stevie-left { display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 800; text-transform: uppercase; }
.stevie-badge { padding: 2px 8px; border-radius: 999px; background: rgba(16, 185, 129, 0.2); color: var(--emerald-neon); font-size: 10px; }
.stevie-body { border-top: 1px solid var(--line); padding: 14px 16px; max-height: 260px; overflow-y: auto; background: rgba(7, 11, 10, 0.96); }
.stevie-grid { display: grid; grid-template-columns: 7fr 5fr; gap: 16px; }
.log-row {
  padding: 8px 10px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 8px; font-size: 11px; margin-bottom: 6px;
}
.gis-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 11px; display: grid; gap: 8px; }
.gis-url { background: var(--obsidian); border: 1px solid var(--line); border-radius: 8px; padding: 8px; color: #6ee7b7; word-break: break-all; font-size: 10px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.8); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-box {
  background: var(--panel); border: 1px solid rgba(16, 185, 129, 0.5);
  border-radius: 22px; max-width: 760px; width: 100%; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-head { padding: 12px 18px; background: var(--panel-light); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-title { margin: 0; font-size: 15px; font-weight: 900; text-transform: uppercase; color: #fff; }
.modal-body { padding: 18px; overflow-y: auto; display: grid; gap: 14px; }
.modal-two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-card { background: var(--obsidian); border: 1px solid #334155; border-radius: 14px; padding: 14px; display: grid; gap: 8px; font-size: 12px; color: #cbd5e1; }
.modal-card.emerald { border-color: rgba(0, 255, 157, 0.5); box-shadow: var(--emerald-glow); }

/* Toast */
.toast-wrap {
  position: fixed; top: 150px; left: 50%; transform: translateX(-50%);
  z-index: 50; width: 92%; max-width: 440px; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.toast-msg {
  pointer-events: auto; padding: 10px 16px; border-radius: 14px;
  background: rgba(12, 20, 18, 0.96); border: 1px solid rgba(0, 255, 157, 0.7);
  color: #d1fae5; font-size: 12px; font-weight: 600; text-align: center;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.65); transition: opacity 0.25s ease;
}
.toast-msg.amber { border-color: rgba(251, 191, 36, 0.75); color: #fde68a; }
.toast-msg.cyan { border-color: rgba(34, 211, 238, 0.75); color: #cffafe; }

/* Map Markers & Leaflet Controls */
.map-marker-btn {
  width: 40px; height: 40px; border-radius: 999px; border: 2px solid #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transform: translate(-50%, -50%); font-size: 13px; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.55);
}
.map-marker-btn.anchor { background: var(--emerald-core); color: var(--obsidian); border-color: var(--emerald-neon); }
.map-marker-btn.pilot { background: #22d3ee; color: var(--obsidian); border-color: #fff; }
.map-marker-btn.concept { background: #fbbf24; color: var(--obsidian); border-color: #fef3c7; }

.emerald-tooltip {
  background: rgba(12, 20, 18, 0.94) !important;
  border: 1px solid rgba(16, 185, 129, 0.55) !important;
  color: #f8fafc !important;
  font-size: 11px !important; font-weight: 600 !important;
  padding: 5px 9px !important; border-radius: 8px !important;
}
.leaflet-bottom {
  bottom: 56px !important;
}
.leaflet-control-attribution {
  background: rgba(7, 11, 10, 0.92) !important;
  color: #cbd5e1 !important; font-size: 11px !important;
  border-top-left-radius: 6px; padding: 3px 8px !important;
}
.leaflet-control-attribution a { color: #34d399 !important; text-decoration: underline; }
.leaflet-control-zoom a {
  width: 48px !important; height: 48px !important; line-height: 46px !important;
  font-size: 22px !important; background: var(--panel) !important; color: var(--ink) !important;
  border-color: rgba(16, 185, 129, 0.45) !important;
}
.leaflet-control-zoom a:hover { background: var(--panel-light) !important; color: var(--emerald-neon) !important; }

/* Keep OSM attribution and 48px Leaflet zoom controls visible beside the
   desktop inspection drawer. Closed drawer restores Leaflet's normal placement. */
@media (min-width: 641px) {
  body:has(#property-card:not(.closed)) .leaflet-bottom.leaflet-right {
    right: 442px !important; /* drawer: 410px + right inset: 16px + clearance: 16px */
  }
}

/* Narrow desktop/tablet: allow attribution to wrap within the free map strip,
   and raise the legend so it cannot cover the relocated copyright credit. */
@media (min-width: 641px) and (max-width: 900px) {
  body:has(#property-card:not(.closed)) .leaflet-control-attribution {
    max-width: calc(100vw - 470px);
    overflow-wrap: anywhere;
  }
  body:has(#property-card:not(.closed)) .map-legend { bottom: 248px; }
}

/* Responsive Mobile */
@media (max-width: 640px) {
  .hide-sm { display: none !important; }
  .leaflet-bottom { bottom: 64px !important; }
  .property-card {
    top: auto; bottom: 0; left: 0; right: 0; width: 100%;
    max-height: 82vh; border-radius: 22px 22px 0 0; border-bottom: 0;
  }
  .property-card.closed { transform: translateY(105%); }
  .stevie-grid, .modal-two { grid-template-columns: 1fr; }
  .map-legend { bottom: 96px; max-width: 215px; }
}
