/* ═══════════════════════════════════════════════════════════
   HAB Trajectory Predictor — cool-slate dark theme, one azure accent
   ═══════════════════════════════════════════════════════════ */

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

/* Cool slate neutrals + a single azure accent. Panels = --surface with a
   --surface-raised header strip; accent only for active/selected + primary
   actions; rely on surface-elevation over hard borders. */
:root {
  /* Canonical palette */
  --bg:             #0B0F13;   /* app background, darkest */
  --surface:        #1B2028;   /* panels, cards */
  --surface-raised: #252C37;   /* headers, buttons, hover states */
  --inset:          #101418;   /* input fields, sunken areas */
  --border:         #313A47;   /* dividers, subtle outlines */
  --canvas:         #0F242F;   /* map / main canvas, teal-tinted dark */
  --accent:         #477FEF;   /* active/selected, primary buttons, links */
  --accent-soft:    #A6C1F7;   /* focus rings, accent text */
  --text:           #E7EDF3;   /* primary text (off-white) */
  --text-muted:     #8E98A4;   /* labels, secondary text */

  /* Legacy aliases → mapped onto the new palette so existing rules recolor.
     New code should use the canonical names above. */
  --bg-deep:    var(--bg);
  --bg-panel:   var(--surface);
  --bg-input:   var(--inset);
  --border-hi:  var(--accent-soft);   /* focus ring */
  --field-text: var(--text);          /* inputs use --text now */
  --accent-hi:  #5B8EF0;              /* primary-button hover */

  /* Semantic state colors (kept distinct from the single UI accent) */
  --od-green:   #3FB950;   /* success */
  --yellow:     #D4A017;   /* warning */
  --danger:     #F08891;   /* error text */

  --blue:       var(--accent);
  --sidebar-w:  310px;
  --mono: 'JetBrains Mono', 'Fira Mono', 'Cascadia Code', monospace;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg-deep);
}

/* ─── Layout ────────────────────────────────────────────── */

body {
  display: flex;
}

#sidebar {
  width: var(--sidebar-w);
  min-width: 260px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#map {
  flex: 1;
  height: 100vh;
  background: var(--canvas);   /* teal-tinted dark behind the globe */
}

/* ─── Sidebar header ────────────────────────────────────── */

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 14px 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  background: var(--surface-raised);   /* raised header strip */
  letter-spacing: 0.05em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.header-diamond {
  width: 10px;
  height: 10px;
  background: var(--accent);
  transform: rotate(45deg);
  flex-shrink: 0;
}

/* Wordmark: "Aether" + small muted tagline. The parent .sidebar-header forces
   uppercase/letter-spacing for section-strip consistency; the brand name opts
   out for a cleaner mixed-case wordmark, the tagline keeps the uppercase label look. */
.header-titles {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.header-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--text);
}
.header-sub {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* ─── Form sections ─────────────────────────────────────── */

.form-section {
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.section-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 1px;
}

.input-hint {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ─── Two-column input row ──────────────────────────────── */

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.input-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.input-cell label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Inputs ────────────────────────────────────────────── */

input[type="number"],
input[type="datetime-local"],
input[type="file"],
select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 0;
  color: var(--field-text);
  padding: 5px 8px;
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

input[type="file"] {
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
}

input[type="file"]::-webkit-file-upload-button {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  margin-right: 6px;
}

input[type="number"]:focus,
input[type="datetime-local"]:focus,
select:focus {
  border-color: var(--border-hi);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M0 0l6 8 6-8z' fill='%238E98A4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
  cursor: pointer;
}

/* ─── Toggle (preset / manual / basemap) ───────────────── */

.toggle-row {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}

.toggle-btn {
  flex: 1;
  background: var(--surface-raised);   /* inactive button */
  border: 1px solid var(--border);
  border-radius: 0;
  color: var(--text);
  padding: 5px 0;
  font-size: 11px;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.toggle-btn:hover {
  border-color: var(--accent-soft);
}

.toggle-btn.active {
  background: var(--accent);          /* selected flips to accent fill */
  border-color: var(--accent);
  color: var(--text);
  font-weight: 700;
}

/* ─── Predict button ────────────────────────────────────── */

.predict-btn {
  margin: 12px 14px;
  padding: 9px 0;
  background: var(--accent);          /* primary action */
  border: 1px solid var(--accent);
  border-radius: var(--radius, 4px);
  color: var(--text);
  font-size: 12px;
  font-family: var(--mono);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  width: calc(100% - 28px);
  transition: background 0.15s, opacity 0.15s;
}

.predict-btn:hover:not(:disabled) { background: var(--accent-hi); border-color: var(--accent-hi); }
.predict-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── KML style controls (color + opacity) ──────────────── */

.kml-style-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.kml-style-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.kml-style-grow {
  flex: 1 1 auto;
}

.kml-style-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.kml-style-label span {
  color: var(--field-text);
}

#inp-kml-color {
  width: 38px;
  height: 26px;
  padding: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 0;
  cursor: pointer;
}

#inp-kml-opacity {
  width: 100%;
  accent-color: var(--border-hi);
  cursor: pointer;
}

/* ─── KML button row ────────────────────────────────────── */

.kml-btn-row {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.kml-clear-btn {
  flex: 0 0 auto;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 0;
  color: var(--text);
  padding: 5px 10px;
  font-size: 11px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.kml-clear-btn:hover {
  border-color: var(--border-hi);
  color: var(--text);
}

.kml-error {
  font-size: 11px;
  color: var(--danger);
  font-family: var(--mono);
  margin-top: 3px;
}

/* ─── Feedback panels ───────────────────────────────────── */

.status-panel {
  margin: 0 14px 8px;
  padding: 8px 10px;
  background: rgba(71,127,239,0.10);
  border: 1px solid var(--accent);
  border-radius: 0;
  color: var(--accent-soft);
  font-size: 11px;
  font-family: var(--mono);
  line-height: 1.5;
}

.error-panel {
  margin: 0 14px 8px;
  padding: 8px 10px;
  background: #1f0a0a;
  border: 1px solid #6b1a1a;
  border-radius: 0;
  color: var(--danger);
  font-size: 11px;
  font-family: var(--mono);
  line-height: 1.5;
}

/* ─── Flight summary ────────────────────────────────────── */

#legend-panel {
  margin: 0 14px 14px;
}

.result-summary {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 8px 10px;
}

.sum-row {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-muted);
  line-height: 1.9;
}

.sum-row b { color: var(--text); }

.sum-warn {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--yellow);
  margin-top: 4px;
  line-height: 1.5;
}

/* ─── Utility ───────────────────────────────────────────── */

.hidden { display: none !important; }

/* ─── Floating path tooltip ─────────────────────────────── */

.map-tooltip {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  background: rgba(37, 44, 55, 0.95);   /* --surface-raised */
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 6px 11px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
}

/* ─── Toast ─────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  pointer-events: none;
  background: var(--surface-raised);
  border: 1px solid var(--accent);
  border-radius: 0;
  padding: 7px 20px;
  font-size: 11px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-soft);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  white-space: nowrap;
}

/* ─── Tank rows (fill calculator) ───────────────────────── */

.tanks-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
}

.tank-row {
  display: grid;
  grid-template-columns: 52px 1fr 1fr 22px;
  gap: 4px;
  align-items: end;
}

.tank-preset-toggle {
  display: flex;
  gap: 2px;
}

.tank-preset-btn {
  flex: 1;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 0;
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.tank-preset-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text);
}

.tank-input-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tank-input-cell label {
  font-size: 9.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tank-remove-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  height: 27px;
  transition: border-color 0.1s, color 0.1s;
}

.tank-remove-btn:hover { border-color: #6b1a1a; color: var(--danger); }

.add-tank-btn {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-style: dashed;
  color: var(--text);
  padding: 5px 0;
  font-size: 11px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  width: 100%;
  transition: border-color 0.15s, color 0.15s;
}

.add-tank-btn:hover { border-color: var(--border-hi); color: var(--text); }

/* ─── Fill results panel ─────────────────────────────────── */

.fill-results {
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.fill-stat {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-muted);
  line-height: 1.8;
}

.fill-stat b { color: var(--text); }

.fill-stat.fill-warn {
  color: var(--yellow);
  margin-top: 2px;
}

.fill-stat.fill-err {
  color: var(--danger);
}

/* ─── Cutdown summary rows ───────────────────────────────── */

.sum-row.cutdown-label {
  color: var(--text-muted);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 5px;
}

/* ─── Missions workspace (WS-U1/U2) ─────────────────────────── */
.missions-empty { display: flex; flex-direction: column; gap: 8px; padding: 4px 0 2px; }
.missions-empty-text { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
#missions-list { display: flex; flex-direction: column; gap: 5px; margin: 2px 0 6px; }
.mission-card {
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--inset); overflow: hidden;
  transition: border-color .12s;
}
.mission-card.active { border-color: var(--accent); }
.mission-card.hidden-mission { opacity: 0.55; }
.mission-head {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 7px; cursor: pointer; font-size: 13px; color: var(--text);
}
.mission-card.active .mission-head { background: var(--surface-raised); }
.mission-dot { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.mission-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 96px; }
.mission-chip {
  flex: 1; font-size: 10.5px; color: var(--text-muted);
  font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mc-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 13px; line-height: 1; padding: 0 2px; flex-shrink: 0;
}
.mc-btn:hover { color: var(--text); }
.mission-del { font-size: 16px; }
.mission-del:hover { color: var(--danger); }
.mission-body {
  padding: 6px 9px 8px; border-top: 1px solid var(--border);
  font-size: 11.5px; display: flex; flex-direction: column; gap: 3px;
}
.mc-row { display: flex; justify-content: space-between; gap: 10px; color: var(--text-muted); }
.mc-row b { color: var(--text); font-weight: 600; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-unsolved { color: var(--text-muted); font-style: italic; }

/* ─── Dispersion foldout (WS-U3) ────────────────────────────── */
.disp-foldout {
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
}
.disp-foldout > summary.disp-summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 0;
}
.disp-foldout > summary.disp-summary::-webkit-details-marker { display: none; }
.disp-foldout > summary.disp-summary::before {
  content: "\25B8";                 /* ▸ */
  color: var(--text-muted);
  font-size: 10px;
  transition: transform .12s;
}
.disp-foldout[open] > summary.disp-summary::before { transform: rotate(90deg); }
.disp-foldout[open] > summary.disp-summary { margin-bottom: 8px; }
.disp-optional {
  font-size: 9px; font-weight: 600; letter-spacing: .06em;
  color: var(--text-muted); text-transform: uppercase;
  border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px;
}
/* Secondary action — subordinate to the primary Predict Flight button */
.disp-run-btn {
  width: 100%;
  padding: 8px 0;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent-soft);
  border-radius: var(--radius, 4px);
  font-family: var(--mono);
  font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.disp-run-btn:hover { background: var(--surface-raised); color: var(--text); }

/* ─── Stale-result indicators (amber, distinct from the azure accent) ───────── */
.mission-stale {
  font-size: 8.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--yellow); border: 1px solid var(--yellow); border-radius: 3px;
  padding: 0 4px; flex-shrink: 0;
}
.stale-banner {
  font-size: 11px; color: var(--yellow); line-height: 1.35;
  background: rgba(212, 160, 23, 0.12); border: 1px solid var(--yellow);
  border-radius: 4px; padding: 6px 8px;
}
