/* Illumination with zone constraints — map + 3D subsurface */

:root {
  --bg: #0d1526;
  --bg2: #101a2e;
  --panel: rgba(16, 26, 46, 0.94);
  --line: #22314f;
  --fg: #e6ecf5;
  --muted: #94a3b8;
  --accent: #e94560;
  --accent2: #38bdf8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--fg); overflow: hidden;
}

#topbar {
  height: 62px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; background: var(--bg2); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, #2ecc71 0%, #d4a017 50%, #c0392b 100%);
}
#topbar h1 { font-size: 16px; font-weight: 700; letter-spacing: .2px; }
#topbar h1 span { color: var(--muted); font-weight: 500; }
#topbar p { font-size: 11px; color: var(--muted); margin-top: 2px; }

#tabs { display: flex; gap: 4px; background: #0a1220; padding: 4px; border-radius: 10px; }
.tab {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 8px 18px; border-radius: 7px; cursor: pointer;
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--fg); }
.tab.active { background: var(--accent); color: #fff; }

.view { display: none; height: calc(100vh - 62px); }
.view.active { display: block; }
.stage { position: relative; width: 100%; height: 100%; }
#map-main, #plot-main, #map-a, #map-b { position: absolute; inset: 0; }

.split { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto 1fr auto; }
.split-pane { position: relative; overflow: hidden; }
.split-pane.pane-a { border-right: 2px solid var(--line); }
.pane-title {
  position: absolute; top: 0; left: 0; right: 0; z-index: 500;
  padding: 7px 12px; font-size: 11.5px;
  background: linear-gradient(180deg, rgba(13,21,38,.94), rgba(13,21,38,0));
  display: flex; justify-content: space-between; pointer-events: none;
}
.pane-title span { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- per-pane overlay controls -------------------------------------- */
.cmp-controls {
  grid-column: 1 / -1;
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--line); border-bottom: 2px solid var(--line);
}
.cmp-ctrl { background: var(--bg2); padding: 8px 14px 9px; }
.cmp-ctrl-h {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); margin-bottom: 6px;
}
.cmp-ctrl-h b { color: var(--accent2); }
.cmp-ctrl-row { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.chk.sm { font-size: 10.5px; gap: 5px; }
.chk.sm input { width: 13px; height: 13px; }
.opacity-row.compact { margin-top: 6px; font-size: 10.5px; }
.opacity-row.compact > b {
  min-width: 34px; text-align: right; color: var(--fg);
  font-weight: 600; font-variant-numeric: tabular-nums;
}

.cmp-strip {
  grid-column: 1 / -1; display: flex; gap: 1px;
  background: var(--line); border-top: 2px solid var(--line);
}
.cmp-cell {
  flex: 1; background: var(--bg2); padding: 8px 14px;
  display: flex; flex-direction: column; gap: 2px;
}
.cmp-cell .k { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.cmp-cell .v { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cmp-cell .v.bad { color: #fb923c; }
.cmp-cell .v.good { color: #4ade80; }
.cmp-note {
  grid-column: 1 / -1; background: #0a1220; border-top: 2px solid var(--line);
  padding: 9px 16px; font-size: 11.5px; line-height: 1.7; color: var(--muted);
}
.cmp-note b { color: var(--fg); font-weight: 600; }

.compass {
  position: absolute; top: 14px; right: 14px; z-index: 600;
  width: 62px; text-align: center; pointer-events: none;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.5));
}
#view-map .compass { top: auto; bottom: 16px; right: 16px; }
.compass svg { width: 62px; height: 62px; display: block; }
.c-ring { fill: rgba(13,21,38,.82); stroke: var(--muted); stroke-width: 1.5; }
.c-lbl { fill: var(--fg); font-size: 13px; font-weight: 700; text-anchor: middle; }
.c-needle { fill: var(--accent); stroke: #fff; stroke-width: .8; }
.c-hub { fill: #fff; }
.compass-cap {
  display: block; margin-top: 3px; font-size: 9px; font-weight: 700;
  letter-spacing: 1px; color: var(--fg);
  background: rgba(13,21,38,.82); border-radius: 4px; padding: 2px 0;
}
#needle3d { transform-origin: 32px 32px; transition: transform .18s ease-out; }
.compass.mini { top: auto; bottom: 18px; right: 18px; width: 46px; }
.compass.mini svg { width: 46px; height: 46px; }
.compass.mini .c-lbl { font-size: 11px; }

.panel {
  position: absolute; z-index: 600;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px;
  width: 258px; max-height: calc(100% - 28px); overflow-y: auto;
  backdrop-filter: blur(6px);
}
.panel-left { left: 14px; top: 14px; }
.panel-right { right: 90px; top: 14px; width: 244px; }
.panel h3 {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--accent); margin: 14px 0 7px;
}
.panel h3:first-child { margin-top: 0; }
.panel hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }

.btn-row { display: flex; gap: 5px; flex-wrap: wrap; }
.btn-row.col { flex-direction: column; }
.btn {
  flex: 1; border: 1px solid var(--line); background: #0a1220; color: var(--fg);
  font: inherit; font-size: 12px; font-weight: 600;
  padding: 7px 9px; border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--accent2); }
.btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* scenario buttons carry a sentence, so they read left-aligned instead of
   centred like the camera presets */
.btn.scen { justify-content: flex-start; text-align: left; font-weight: 500; }
.btn.scen.active { font-weight: 700; }
/* the difference scenario is a diagnostic, not an acquisition design -- keep it
   visually distinct from the two real-world scenarios */
.btn.scen[data-scen="delta"]:hover { border-color: #f59e0b; }
.btn.scen[data-scen="delta"].active { background: #b45309; border-color: #f59e0b; color: #fff; }

.sel {
  width: 100%; margin-top: 8px; background: #0a1220; color: var(--fg);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 8px; font: inherit; font-size: 12px; cursor: pointer;
}
.sel:focus { outline: 1px solid var(--accent2); }

.chk { display: flex; align-items: center; gap: 7px; font-size: 12px; margin: 6px 0; cursor: pointer; }
.chk input { accent-color: var(--accent2); width: 15px; height: 15px; cursor: pointer; flex: none; }
.chk i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 4px; }
/* <i> inside .chk is already a colour swatch, so italic emphasis uses <em> */
.chk em { font-style: italic; }

.opacity-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 11px; color: var(--muted); }
.opacity-row input { flex: 1; accent-color: var(--accent2); }
/* label on its own line, so a long label never gets squeezed into two */
.opacity-row.stack { flex-wrap: wrap; }
.opacity-row.stack > span { flex: 0 0 100%; margin-bottom: -2px; }
.opacity-row.stack > input { flex: 1 1 120px; }
.opacity-row.stack > b { min-width: 34px; text-align: right; color: var(--fg); font-weight: 600; }

.readout { font-size: 11px; line-height: 1.8; color: var(--muted); font-variant-numeric: tabular-nums; }
.readout b { color: var(--fg); font-weight: 600; }

/* scenario impact table in the 3D right panel */
.dl-row { display: flex; gap: 8px; align-items: baseline; padding: 5px 0;
          border-bottom: 1px solid var(--line); }
.dl-row:last-of-type { border-bottom: 0; }
.dl-row .k { flex: 0 0 30px; color: var(--fg); font-weight: 700; font-size: 11px; }
.dl-row .v { flex: 1; font-size: 10.5px; line-height: 1.6; }
.lg { font-size: 11px; line-height: 1.7; color: var(--muted); }
.lg b { color: var(--fg); font-weight: 600; }
.dim { color: var(--accent2); font-variant-numeric: tabular-nums; }
.sw { width: 15px; height: 10px; display: inline-block; margin-right: 6px; vertical-align: middle; border-radius: 2px; }
.sw.fill { border: 1.5px solid; }

.ramp { margin-top: 10px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.ramp canvas { display: block; width: 100%; height: 14px; }
.ramp-lbl { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }

.note { font-size: 10.5px; line-height: 1.7; color: var(--muted); margin-top: 8px; }
.note b { color: var(--fg); }
.note i { color: #cbd5e1; }

.warn {
  margin-top: 10px; font-size: 10.5px; line-height: 1.7;
  background: rgba(234, 179, 8, .12); border: 1px solid rgba(234, 179, 8, .4);
  border-radius: 7px; padding: 8px 10px; color: #fde68a;
}
.warn b { color: #fef3c7; }

#hover-readout {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
  z-index: 700; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 16px; font-size: 12px;
  font-variant-numeric: tabular-nums; pointer-events: none;
  opacity: 0; transition: opacity .18s;
}
#hover-readout.on { opacity: 1; }

.leaflet-container { background: #0a1220; font-family: inherit; }
.leaflet-bar a { background: var(--panel); color: var(--fg); border-color: var(--line); }
.leaflet-bar a:hover { background: #1b2947; color: #fff; }
.leaflet-control-layers {
  background: var(--panel); color: var(--fg);
  border: 1px solid var(--line) !important; border-radius: 8px !important;
  backdrop-filter: blur(6px);
}
.leaflet-control-layers-expanded { padding: 9px 12px !important; }
.leaflet-control-layers label { font-size: 11.5px; }
.leaflet-control-scale-line {
  background: rgba(13,21,38,.8); color: #fff; border-color: var(--muted);
  font-size: 10px; text-shadow: none;
}
.leaflet-tooltip {
  background: var(--panel); color: var(--fg); border: 1px solid var(--line);
  font-size: 11px; box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.leaflet-tooltip-top:before { border-top-color: var(--line); }

@media (max-width: 980px) {
  .panel-right { display: none; }
  .split { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr auto; }
  .cmp-controls { grid-template-columns: 1fr; }
  .split-pane.pane-a { border-right: 0; border-bottom: 2px solid var(--line); }
}