/* Dark engineering UI — chrome tokens from the reference palette */
:root {
  --bg: #0d0d0d;
  --panel: #1a1a19;
  --panel2: #232322;
  --ink: #ffffff;
  --ink2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --accent: #3987e5;
  --accent-deep: #1c5cab;
  --good: #0ca30c;
  --critical: #d03b3b;
  --border: rgba(255, 255, 255, 0.10);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 13px;
  overflow: hidden;
}
body { display: flex; }

/* ---------- sidebar ---------- */
#sidebar {
  width: 302px; flex: 0 0 302px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px 14px 10px;
}
#sidebar h1 { font-size: 16px; margin: 0 0 2px; font-weight: 650; }
#sidebar .sub { color: var(--muted); font-size: 11.5px; margin-bottom: 10px; }
#sidebar section {
  border-top: 1px solid var(--border);
  padding: 10px 0;
}
#sidebar h2 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); margin: 0 0 8px; font-weight: 600;
}
.row.btns { display: flex; gap: 6px; margin-bottom: 6px; }
.row.btns button { flex: 1; }

button {
  background: var(--panel2); color: var(--ink2);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 8px; font-size: 12.5px; cursor: pointer;
  font-family: inherit;
}
button:hover { background: #2c2c2a; color: var(--ink); }
button.primary {
  background: var(--accent); border-color: var(--accent);
  color: #fff; font-weight: 600; width: 100%; padding: 9px;
}
button.primary:hover { background: #4a92e8; }
button.primary-outline.active {
  background: var(--accent-deep); color: #fff; border-color: var(--accent);
}
button:disabled { opacity: 0.45; cursor: default; }

.hint { color: var(--muted); font-size: 11.5px; line-height: 1.45; margin-top: 4px; }
.hint b { color: var(--ink2); }

.prow {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin: 6px 0; color: var(--ink2);
}
.prow > span:first-child { flex: 1; }
.prow .val { display: flex; align-items: center; gap: 5px; }
.prow .val u { text-decoration: none; color: var(--muted); font-size: 11.5px; width: 18px; }
.prow .val.wide { flex: 0 0 118px; }
.prow b { color: var(--ink); font-weight: 600; }
input[type="number"], select {
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--axis); border-radius: 5px;
  padding: 4px 6px; width: 74px; font-size: 12.5px; text-align: right;
  font-variant-numeric: tabular-nums; font-family: inherit;
}
select { width: auto; text-align: left; max-width: 150px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }
input:focus, select:focus { outline: 1px solid var(--accent); }

.computeSec { padding-top: 12px; }
#progressWrap {
  height: 4px; background: var(--grid); border-radius: 2px;
  margin: 8px 0 6px; overflow: hidden; opacity: 0;
}
#progressWrap.on { opacity: 1; }
#progressBar { height: 100%; width: 0%; background: var(--accent); transition: width 0.15s; }
#statusText { color: var(--muted); font-size: 11.5px; min-height: 15px; line-height: 1.4; }
#statusText.err { color: var(--critical); }
#staleNote { color: #c98500; font-size: 11.5px; margin-top: 3px; }

.stats { color: var(--ink2); font-size: 12px; line-height: 1.65; }
.stats b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.stats .warn { color: var(--critical); }

.credits { color: var(--muted); font-size: 10.5px; line-height: 1.5; padding: 10px 0 4px; border-top: 1px solid var(--border); }

/* ---------- map + overlays ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#mapWrap { flex: 1; display: flex; min-height: 0; }
#pane3d { flex: 1; position: relative; min-width: 0; }
#cesiumContainer { position: absolute; inset: 0; }
#cesiumContainer.drawing canvas { cursor: crosshair !important; }

#pane2d {
  width: 42%; min-width: 260px; position: relative;
  border-left: 1px solid var(--border);
}
#pane2d.hidden { display: none; }
#map2d { position: absolute; inset: 0; background: #e9e7e1; }
#map2d.drawing { cursor: crosshair !important; }
#map2dBar {
  position: absolute; top: 10px; right: 10px; z-index: 1000;
  background: rgba(26, 26, 25, 0.92); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 9px;
  color: var(--ink2); font-size: 11.5px;
}
#map2dBar label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.leaflet-container { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.leaflet-control-attribution { font-size: 9.5px; }

/* mode-dependent UI rows */
body[data-mode="drone"] .mode-static { display: none !important; }
body[data-mode="static"] .mode-drone { display: none !important; }

/* 2D waypoint editing handles */
.wp2d {
  width: 13px; height: 13px; border-radius: 50%;
  background: #fff; border: 2px solid #000; box-sizing: border-box;
  cursor: grab;
}
.wp2d.start { background: #0ca30c; }
.wp2d.radar { background: #ff3b30; }
.azHandle {
  width: 15px; height: 15px; border-radius: 50%;
  background: rgba(255, 59, 48, 0.35); border: 2px solid #ff3b30;
  box-sizing: border-box; cursor: grab;
}
.wp2d-mid {
  width: 9px; height: 9px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.6); border: 1.5px solid rgba(0, 0, 0, 0.6);
  box-sizing: border-box; cursor: copy;
}

/* place search (3D pane, top left) */
#searchBox { position: absolute; top: 10px; left: 10px; z-index: 6; width: 270px; }
#searchBox input {
  width: 100%; text-align: left;
  background: rgba(26, 26, 25, 0.92); color: var(--ink);
  border: 1px solid var(--border); border-radius: 7px;
  padding: 7px 10px; font-size: 12.5px;
}
#searchBox input::placeholder { color: var(--muted); }
#searchResults {
  margin-top: 4px; background: rgba(26, 26, 25, 0.96);
  border: 1px solid var(--border); border-radius: 7px;
  max-height: 260px; overflow-y: auto;
}
#searchResults.hidden { display: none; }
.searchItem {
  padding: 6px 10px; cursor: pointer; color: var(--ink2);
  font-size: 12px; line-height: 1.35;
  border-bottom: 1px solid var(--grid);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.searchItem:last-child { border-bottom: none; }
.searchItem:hover { background: #2c2c2a; color: var(--ink); }
.searchItem .src { color: var(--muted); font-size: 10.5px; margin-left: 4px; }
.searchEmpty { padding: 7px 10px; color: var(--muted); font-size: 12px; }

#legend {
  position: absolute; left: 12px; bottom: 34px;
  background: rgba(26, 26, 25, 0.92);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; z-index: 5; width: 202px;
}
#legend.hidden { display: none; }
#legendTitle { color: var(--ink2); font-size: 11.5px; margin-bottom: 5px; }
#legendBar { display: block; border-radius: 2px; width: 180px; height: 10px; }
#legendLabels {
  display: flex; justify-content: space-between;
  color: var(--muted); font-size: 10.5px; margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

/* ---------- profile panel ---------- */
#profilePanel {
  flex: 0 0 232px; background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
#profilePanel.collapsed { flex-basis: 30px; }
#profilePanel.collapsed #profileBody { display: none; }
#profileHeader {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 12px; flex: 0 0 30px;
}
#profileTitle { font-size: 12px; font-weight: 600; color: var(--ink2); }
#profileInfo { flex: 1; color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
#profileInfo .warn { color: var(--critical); font-weight: 600; }
#btnProfileToggle { padding: 1px 8px; font-size: 11px; }
#profileBody { flex: 1; position: relative; min-height: 0; }
#profileCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#profileTip {
  position: absolute; pointer-events: none; z-index: 6;
  background: rgba(35, 35, 34, 0.96); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 8px;
  color: var(--ink2); font-size: 11.5px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
#profileTip b { color: var(--ink); }
#profileTip.hidden { display: none; }

/* Cesium chrome adjustments */
.cesium-viewer-bottom { font-size: 10px; opacity: 0.75; }
.cesium-widget-credits a { color: var(--muted) !important; }
