:root {
  --bg: #0b0d12;
  --panel: rgba(14, 17, 24, 0.84);
  --panel-border: rgba(255, 255, 255, 0.10);
  --text: #eef1f6;
  --muted: #9aa4b5;
  --accent: #42e88a;
  --accent-2: #f97316;
  --radius: 14px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden; background: var(--bg); color: var(--text);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#map { position: fixed; inset: 0; width: 100vw; height: 100vh; }

.hud {
  position: fixed; z-index: 20;
  background: var(--panel);
  backdrop-filter: blur(18px) saturate(1.25);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.brand-hud {
  top: 16px; left: 16px; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand-badge {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, #5b2c98 0%, #2478d4 52%, #42e88a 100%);
  display: grid; place-items: center; font-weight: 800; font-size: 12px;
  letter-spacing: 0.04em; color: #fff; flex-shrink: 0;
}
.brand-hud h1 {
  margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -0.02em;
}
.brand-hud .subtitle {
  margin: 2px 0 0; font-size: 11px; color: var(--muted);
}

.status-pill {
  top: 16px; left: 50%; transform: translateX(-50%);
  padding: 7px 14px; display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text); border-radius: 999px;
}
.led {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 10px var(--accent); animation: pulse 2.2s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.38; } }

.top-actions {
  top: 16px; right: 16px; padding: 6px;
  display: flex; align-items: center; gap: 6px;
}
.pill-btn, .pill-select {
  appearance: none; border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.05); color: var(--text);
  padding: 7px 12px; border-radius: 9px; font-size: 12px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: all 0.15s ease;
  font-family: inherit;
}
.pill-btn:hover { background: rgba(255,255,255,0.12); }
.pill-btn.active { background: rgba(66, 232, 138, 0.18); border-color: rgba(66, 232, 138, 0.55); color: #8dffbe; }
.pill-btn.accent {
  background: linear-gradient(135deg, #5b2c98 0%, #1e70d6 55%, #16b877 100%);
  border-color: rgba(255,255,255,0.22); color: #fff;
}
.pill-btn.accent:hover { filter: brightness(1.12); transform: translateY(-1px); }
.pill-btn.ghost { color: var(--muted); }

.panel-left {
  top: 86px; left: 16px; bottom: 16px; width: 326px;
  padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px;
}
.panel-right {
  top: 86px; right: 16px; width: 320px; max-height: calc(100vh - 102px);
  padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
}
.panel-left::-webkit-scrollbar, .panel-right::-webkit-scrollbar { width: 5px; }
.panel-left::-webkit-scrollbar-thumb, .panel-right::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.14); border-radius: 4px;
}

.panel-sec {
  padding-bottom: 11px; border-bottom: 1px solid rgba(255,255,255,0.07);
}
.panel-sec:last-child { border-bottom: none; padding-bottom: 0; }

.sec-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); font-weight: 600; margin-bottom: 6px; display: block;
}
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mono-val { font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--muted); }

.zone-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.zone-btn {
  text-align: left; padding: 9px 10px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.10); background: rgba(255,255,255,0.04);
  color: var(--text); cursor: pointer; transition: all 0.15s;
}
.zone-btn:hover { background: rgba(255,255,255,0.09); }
.zone-btn.active {
  background: rgba(66, 232, 138, 0.13); border-color: rgba(66, 232, 138, 0.55);
}
.zone-btn strong { display: block; font-size: 12.5px; }
.zone-btn span { font-size: 10.5px; color: var(--muted); }
.zone-summary {
  margin-top: 8px; font-size: 11.5px; line-height: 1.45; color: #c7d0df;
}

.layer-groups { display: flex; flex-direction: column; gap: 8px; }
.layer-grp-title { font-size: 10px; color: #7b8698; margin: 2px 0 4px; font-weight: 600; }
.layer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.layer-btn {
  padding: 7px 8px; border-radius: 8px; text-align: left;
  border: 1px solid rgba(255,255,255,0.08); background: rgba(255,255,255,0.03);
  color: #d6dde9; font-size: 11.5px; cursor: pointer; transition: all 0.12s;
}
.layer-btn:hover { background: rgba(255,255,255,0.09); }
.layer-btn.active {
  background: rgba(56, 152, 245, 0.22); border-color: rgba(92, 184, 255, 0.65); color: #fff; font-weight: 600;
}
.layer-btn small { display: block; font-size: 9.5px; color: var(--muted); font-weight: 400; }

input[type="range"] { width: 100%; accent-color: var(--accent); cursor: pointer; }

.legend-bar { height: 11px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.14); margin: 4px 0; }
.legend-ticks { display: flex; justify-content: space-between; font-family: "JetBrains Mono", monospace; font-size: 10.5px; color: var(--muted); }

.link-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.link-row a {
  font-size: 11px; color: #8fd3ff; text-decoration: none;
  padding: 4px 8px; border-radius: 6px; background: rgba(56,152,245,0.12);
  border: 1px solid rgba(56,152,245,0.28);
}
.link-row a:hover { background: rgba(56,152,245,0.25); }
.credit-note { margin: 0; font-size: 10px; line-height: 1.4; color: #7c8799; }

/* Right Inspector */
.toggle-mini { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); cursor: pointer; }
.inspect-hint { margin: 0; font-size: 12px; line-height: 1.45; color: var(--muted); }
.hidden { display: none !important; }
.inspect-body { display: flex; flex-direction: column; gap: 10px; }
.coord-line { padding: 4px 8px; border-radius: 6px; background: rgba(255,255,255,0.04); }
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.kpi {
  padding: 8px 10px; border-radius: 9px;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06);
}
.k-lbl { display: block; font-size: 10px; color: var(--muted); }
.kpi strong { font-size: 14px; font-family: "JetBrains Mono", monospace; color: #fff; }
.sub-block { padding-top: 6px; border-top: 1px solid rgba(255,255,255,0.07); }
.profile-svg { width: 100%; height: 124px; background: rgba(0,0,0,0.26); border-radius: 8px; display: block; }

.strata-bars { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.s-row { display: grid; grid-template-columns: 96px 1fr 44px; align-items: center; gap: 6px; font-size: 11px; }
.s-track { height: 8px; border-radius: 999px; background: rgba(255,255,255,0.08); overflow: hidden; }
.s-fill { height: 100%; border-radius: 999px; transition: width 0.15s ease; }
.s-fill.cover { background: linear-gradient(90deg, #1a8a6c, #42e88a); }
.s-fill.mid { background: linear-gradient(90deg, #d97706, #fbbf24); }
.s-fill.ladder { background: linear-gradient(90deg, #dc2626, #fb923c); }

.fuel-badge {
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.fuel-low { background: rgba(34,197,94,0.18); color: #86efac; }
.fuel-mod { background: rgba(245,158,11,0.22); color: #fcd34d; }
.fuel-high { background: rgba(239,68,68,0.26); color: #fca5a5; }
.meta-footer { font-size: 10.5px; color: #8995a8; border-top: 1px solid rgba(255,255,255,0.07); padding-top: 6px; }

/* 3D WUI Marker on Map */
.wui-marker {
  background: linear-gradient(135deg, #6d28d9, #1d4ed8, #10b981);
  color: #fff; font-size: 11px; font-weight: 700; padding: 5px 10px;
  border-radius: 999px; border: 1.5px solid #fff; cursor: pointer;
  box-shadow: 0 6px 22px rgba(0,0,0,0.65); white-space: nowrap;
}
.wui-marker:hover { transform: scale(1.06); }

/* 3D Point Cloud Modal */
.modal-3d {
  position: fixed; inset: 0; z-index: 100; background: #030407;
}
#canvas-3d-host { position: absolute; inset: 0; width: 100%; height: 100%; }

.v3d-topbar {
  top: 16px; left: 16px; right: 16px; padding: 12px 18px;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
}
.v3d-kicker { font-size: 10px; letter-spacing: 0.1em; color: #7ef7b4; font-weight: 700; }
.v3d-topbar h2 { margin: 2px 0; font-size: 17px; }
.v3d-topbar p { margin: 0; }
.v3d-top-actions { display: flex; align-items: center; gap: 8px; }
.pill-select { background: #141923; }

.v3d-controls {
  left: 16px; bottom: 16px; width: 340px; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.palette-btns { display: grid; grid-template-columns: 1fr; gap: 5px; }
.pal-btn {
  text-align: left; padding: 7px 10px; border-radius: 8px; font-size: 11.5px;
  border: 1px solid rgba(255,255,255,0.09); background: rgba(255,255,255,0.04);
  color: var(--text); cursor: pointer;
}
.pal-btn.active { background: rgba(66,232,138,0.18); border-color: rgba(66,232,138,0.6); font-weight: 600; }
.v3d-sliders { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: 11px; color: var(--muted); }
.v3d-sliders b { color: #fff; font-family: "JetBrains Mono", monospace; }
.v3d-cameras { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.cam-btn {
  padding: 6px 6px; font-size: 11px; border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.10); background: rgba(255,255,255,0.05);
  color: var(--text); cursor: pointer;
}
.cam-btn:hover { background: rgba(255,255,255,0.12); }
.v3d-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  font-size: 10.5px; color: #c7d0df; padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.v3d-loading {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  background: rgba(3,4,7,0.75); z-index: 30; font-size: 13px;
}
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.15); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 960px) {
  .status-pill { display: none; }
  .panel-right { display: none; }
  .panel-left { width: calc(100vw - 32px); top: auto; max-height: 44vh; }
}
