/* ============================================================
   SC CARGO PRO v2 — Refined HUD (New UI Style)
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font-ui:   'Space Grotesk', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --bg:        #e8eef5;
  --surface0:  #f0f4f8;
  --surface1:  #ffffff;
  --surface2:  rgba(255,255,255,0.85);
  --surface3:  rgba(240,246,252,0.65);
  --border:    rgba(8,42,85,0.12);
  --border-dim: rgba(8,42,85,0.07);
  --border-active: rgba(0,168,120,0.55);
  --accent:    #00a878;
  --accent2:   #007f5a;
  --accent-soft: rgba(0,168,120,0.10);
  --green:     #007843;
  --green2:    #005a30;
  --amber:     #c47e00;
  --amber-soft: rgba(196,126,0,0.12);
  --red:       #c0302e;
  --red-soft:  rgba(192,48,46,0.12);
  --purple:    #6030b0;
  --route-color: #c47e00;
  --text:      #3a5268;
  --text-dim:  #6a8aa8;
  --text-hi:   #0d1f2d;
  --text-mute: #8aa0b8;

  --nav-h:     0px;
  --bar-h:     56px;
  --panel-w:   340px;
  --route-w:   420px;
  --rail-w:    56px;
  --pad:       10px;

  --ease:      cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast:  140ms;
  --dur:       260ms;

  --panel-bg:     rgba(255,255,255,0.88);
  --panel-border: rgba(8,42,85,0.10);
  --panel-shadow: 0 1px 0 rgba(255,255,255,0.9) inset, 0 4px 20px rgba(0,0,0,0.07);
  --glow-accent:  0 0 0 1px rgba(0,168,120,0.22), 0 0 16px rgba(0,168,120,0.08);
  --surface-hi:   rgba(240,246,252,0.7);
  --hairline:     rgba(8,42,85,0.08);
  --hairline-2:   rgba(8,42,85,0.12);
  --hairline-hi:  rgba(8,42,85,0.22);
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--hairline-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--hairline-hi); }

/* ── Root Layout ─────────────────────────────────────────── */
html, body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ============================================================
   MAP AREA (fills everything except bottom bar)
   ============================================================ */
#map-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
  background: linear-gradient(160deg, #c2d0de 0%, #ccd8e4 50%, #c5d2dc 100%);
  --map-center-offset-left: 0px;
  --map-center-offset-right: 0px;
}
/* Grid overlay - very faint lines on light bg */
#map-area::before {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(80,120,160,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(80,120,160,0.025) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 40%, transparent 100%);
  z-index: 1;
}
/* Vignette - very subtle */
#map-area::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 120% 100% at 50% 50%, transparent 60%, rgba(150,175,200,0.10) 100%);
  z-index: 2;
}
#map-area:has(#left-panel.open) {
  --map-center-offset-left: calc((var(--panel-w) / 2) + 10px);
}
#map-area:has(#route-panel.open) {
  --map-center-offset-right: calc((var(--route-w) / 2) + 10px);
}
#starmap {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block; cursor: grab;
}
#starmap:active { cursor: grabbing; }

/* ============================================================
   SC STATUS BAR (bottom-left route status line)
   ============================================================ */
#sc-status-bar {
  position: absolute;
  left: 10px; bottom: 10px;
  z-index: 50;
  display: flex; align-items: center; gap: 0;
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  height: 34px;
  width: min(220px, calc(100% - 20px));
  font-family: var(--font-mono);
  font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.06em;
  transition: left 0.22s var(--ease), bottom 0.22s var(--ease);
  overflow: hidden;
}
/* Corner brackets removed */
#sc-status-bar::before,
#sc-status-bar::after { content: none; }

#map-area:has(#left-panel.open) #sc-status-bar {
  left: calc(var(--panel-w) + 20px);
}
.sc-status-icon {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-right: 1px solid var(--panel-border);
  color: var(--amber); font-size: 14px;
  flex-shrink: 0;
}
#sc-status-text {
  position: relative;
  padding: 0 14px;
  color: var(--text-dim);
  flex: 0 0 260px;
  width: 260px;
  height: 100%;
  display: flex;
  align-items: center;
}
#sc-status-text.active { color: var(--accent); }
.sc-status-marquee {
  display: block;
  width: 100%;
  transform: translateX(0);
}
#sc-status-text.is-scrolling .sc-status-marquee {
  min-width: max-content;
}
#sc-status-text.is-scrolling {
  justify-content: flex-start;
}
#sc-status-text:not(.is-scrolling) .sc-status-marquee {
  justify-content: flex-start;
}
#sc-status-text:not(.is-scrolling) .sc-status-marquee-gap,
#sc-status-text:not(.is-scrolling) .sc-status-marquee-text[aria-hidden="true"] {
  display: none;
}
.sc-status-marquee-text,
.sc-status-marquee-gap {
  white-space: normal;
  word-break: break-word;
  line-height: 1.3;
  display: block;
}
.sc-status-marquee-gap {
  color: rgba(123, 163, 194, 0.45);
}
.sc-status-close {
  width: 40px; height: 40px;
  background: none; border: none; border-left: 1px solid var(--panel-border);
  color: var(--text-dim); font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; flex-shrink: 0;
}
.sc-status-close:hover { background: rgba(255,61,87,0.12); color: var(--red); }
.sc-status-close { display: none; }

/* SC map icon buttons — vertical stack in top-right corner */
.sc-map-icons {
  position: absolute;
  top: 10px; right: 10px; left: auto;
  z-index: 50;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transform: none;
}
.sc-map-icon-btn {
  width: 34px; height: 34px;
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  color: var(--text-dim); font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--dur-fast) var(--ease);
}
.sc-map-icon-btn:hover { border-color: var(--hairline-hi); color: var(--accent); }
.sc-map-icon-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* System selector — bottom-right of map */
#system-selector {
  position: absolute; right: 12px; bottom: 12px; left: auto; z-index: 50;
  display: flex; flex-direction: row; align-items: center; justify-content: flex-end; gap: 4px;
  transform: none;
  max-width: calc(100% - 24px);
}
.sys-btn {
  padding: 6px 12px;
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  color: var(--text-dim);
  font-size: 10.5px; font-weight: 600;
  font-family: var(--font-mono); letter-spacing: 0.08em;
  cursor: pointer; transition: all var(--dur-fast) var(--ease);
  text-transform: uppercase; white-space: nowrap;
}
.sys-btn:hover { border-color: var(--hairline-2); color: var(--text); }
.sys-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.sys-btn.placeholder { opacity: 0.4; }

/* ============================================================
   LEFT PANEL (SC info panel)
   ============================================================ */
#left-panel {
  position: absolute;
  top: 10px; bottom: 10px; left: 10px;
  width: var(--panel-w);
  display: flex; flex-direction: column;
  background: var(--panel-bg);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  box-shadow: var(--panel-shadow);
  z-index: 200;
  overflow: hidden;
  transform: translateX(calc(-1 * (var(--panel-w) + 22px)));
  transition: transform var(--dur) var(--ease-out), opacity var(--dur) var(--ease-out);
  opacity: 0;
}
#left-panel.open { transform: translateX(0); opacity: 1; }

/* Corner tick marks — HUD detail */
#left-panel::before,
#left-panel::after {
  content: "";
  position: absolute;
  width: 10px; height: 10px;
  border-color: var(--hairline-hi);
  pointer-events: none;
  z-index: 1;
}
#left-panel::before { top: 0; left: 0; border-top: 1px solid; border-left: 1px solid; }
#left-panel::after  { bottom: 0; right: 0; border-bottom: 1px solid; border-right: 1px solid; }

/* Scanlines removed */
#left-panel .sc-scanlines { display: none; }

/* ── Search bar at top of panel ── */
.sc-panel-search {
  flex-shrink: 0;
  display: flex; align-items: center;
  border-bottom: 1px solid var(--panel-border);
  height: 38px;
  position: relative; z-index: 1;
}
.sc-search-icon {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 14px;
  border-right: 1px solid var(--panel-border);
  flex-shrink: 0;
}
.sc-panel-search input {
  flex: 1; height: 38px; padding: 0 12px;
  background: transparent; border: none; outline: none;
  color: var(--text-hi);
  font-family: var(--font-ui); font-size: 12px; font-weight: 500;
  letter-spacing: 0.04em;
  margin: 0;
}
.sc-panel-search input::placeholder { color: var(--text-mute); }
.sc-panel-search-hidden { display: none; }

/* ── Body: rail + content ── */
.sc-panel-body {
  flex: 1; display: flex; min-height: 0;
  position: relative; z-index: 1;
}

/* Vertical rail (tab icons) */
.sc-panel-rail {
  width: var(--rail-w);
  flex-shrink: 0;
  display: flex; flex-direction: column; align-items: stretch;
  border-right: 1px solid var(--panel-border);
  padding: 8px 0;
  gap: 2px;
}
.sc-rail-tab {
  width: 100%;
  min-height: 48px;
  padding: 6px 4px;
  background: none; border: none; border-left: 2px solid transparent;
  color: var(--text-dim); font-size: 11px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
  font-family: var(--font-ui); font-weight: 600;
  position: relative;
}
.sc-rail-tab:hover { color: var(--text); background: rgba(8,42,85,0.04); }
.sc-rail-tab.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-left-color: var(--accent);
  box-shadow: inset 2px 0 8px rgba(0,168,120,0.08);
}
.sc-rail-tab.active::before {
  content: "";
  position: absolute; left: 0; top: 10px; bottom: 10px;
  width: 2px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
.sc-rail-tab-glyph {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font-size: 15px;
  line-height: 1;
}
.sc-rail-tab-text {
  margin-top: 4px;
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: none;
  line-height: 1;
  opacity: 0.8;
}
.sc-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
}
.sc-nav-icon svg {
  width: 100%;
  height: 100%;
}
.sc-nav-icon-rail {
  width: 26px;
  height: 26px;
}
.sc-nav-icon-bar {
  width: 18px;
  height: 18px;
}
.sc-nav-icon-tab {
  width: 18px;
  height: 18px;
}
/* Scrollable content area */
.sc-panel-content {
  flex: 1; overflow-y: auto; min-width: 0;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(8,42,85,0.01), rgba(255,255,255,0));
}

.setup-options-drawer {
  display: none;
  padding: 14px;
  gap: 12px;
  align-content: start;
}
#left-panel.setup-options-mode {
  bottom: auto;
  height: fit-content;
  max-height: calc(100% - 20px);
  overflow-y: auto;
}
/* Sidebar content/body collapses to the drawer height rather than filling the panel */
#left-panel.setup-options-mode .sc-panel-body,
#left-panel.setup-options-mode .sc-panel-content {
  flex: 0 0 auto;
}
#left-panel.setup-options-mode .sc-panel-footer { display: none; }
#left-panel.setup-options-mode .setup-options-drawer {
  display: grid;
  grid-template-rows: auto auto auto auto auto;
  box-sizing: border-box;
}
#left-panel.setup-options-mode #sc-poi-info,
#left-panel.setup-options-mode .tab-panel {
  display: none !important;
}
#left-panel.setup-options-mode .sc-panel-rail {
  display: none;
}
#left-panel.setup-options-mode .sc-panel-content {
  overflow: visible;
}
/* ============================================================
   Setup Options Drawer (Launcher) — refreshed layout
   ============================================================ */
#setup-options-drawer.setup-options-drawer {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 14px 14px;
}
.setup-options-hero {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0;
  border: none;
  background: transparent;
}
.setup-options-kicker,
.setup-flow-panel-kicker,
.setup-flow-sidebar-kicker {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 1.2px;
  text-transform: uppercase;
}
.setup-options-title,
.setup-flow-panel-title,
.setup-flow-sidebar-title {
  margin-top: 0;
  font-family: var(--font-ui);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-hi);
  line-height: 1.1;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.setup-options-title {
  font-size: clamp(20px, 1.6vw, 24px);
  line-height: 1.08;
}
.setup-flow-selected-copy,
.setup-flow-mission-copy,
.setup-options-description {
  margin-top: 0;
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
}
.setup-options-description {
  color: var(--text-dim);
  max-width: 40ch;
}

/* Progress bar */
.setup-options-progress-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 2px;
}
.setup-options-progress-track {
  height: 4px;
  background: rgba(8,42,85,0.08);
  border-radius: 2px;
  overflow: hidden;
}
.setup-options-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, rgba(0,168,120,0.55), rgba(0,216,130,0.9));
  border-radius: 2px;
  transition: width 0.28s ease;
}
.setup-options-progress-fill.is-complete {
  background: linear-gradient(90deg, rgba(0,216,130,0.9), rgba(80,240,160,0.95));
}
.setup-options-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.setup-options-progress-percent {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* Step cards — one per setup step */
.setup-options-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.setup-options-step-card {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 11px 14px;
  border: 1px solid rgba(8,42,85,0.09);
  background: rgba(8,42,85,0.02);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.setup-options-step-card:hover {
  border-color: rgba(0,168,120,0.3);
  background: rgba(0,168,120,0.04);
  transform: translateX(1px);
}
.setup-options-step-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.setup-options-step-card.is-complete {
  border-color: rgba(0,216,130,0.35);
  background: rgba(0,216,130,0.05);
}
.setup-options-step-index {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(8,42,85,0.13);
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-hi);
  background: rgba(255,255,255,0.02);
  flex-shrink: 0;
}
.setup-options-step-card.is-complete .setup-options-step-index {
  border-color: rgba(0,216,130,0.6);
  background: rgba(0,216,130,0.15);
  color: var(--green);
}
.setup-options-step-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.setup-options-step-title {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-hi);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.setup-options-step-value {
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-dim);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.setup-options-step-card.is-complete .setup-options-step-value {
  color: var(--text);
}
.setup-options-step-chevron {
  font-size: 18px;
  color: var(--text-dim);
  line-height: 1;
  transition: transform 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}
.setup-options-step-card:hover .setup-options-step-chevron {
  transform: translateX(2px);
  color: var(--accent);
}

/* Smart primary CTA */
.setup-options-cta {
  min-height: 46px;
  justify-content: center;
  align-items: center;
  padding: 12px 14px;
  background: rgba(0,168,120,0.2);
  border: 1px solid rgba(0,168,120,0.45);
  color: var(--text-hi);
  font-size: 12px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  margin-top: 2px;
}
.setup-options-cta:hover:not(:disabled) {
  background: rgba(0,168,120,0.3);
  border-color: rgba(0,168,120,0.65);
  transform: translateY(-1px);
}
.setup-options-cta.is-calculate {
  background: linear-gradient(180deg, rgba(0,216,130,0.28), rgba(0,168,120,0.28));
  border-color: rgba(0,216,130,0.55);
  box-shadow: inset 0 -1px 0 rgba(0,216,130,0.2);
}
.setup-options-cta.is-calculate::before {
  content: '▶';
  margin-right: 8px;
  font-size: 9px;
  color: var(--green);
}
.setup-options-cta-label {
  font-family: var(--font-ui);
  font-weight: 700;
}

/* Footer reset button — quiet tertiary action */
.setup-options-footer {
  display: flex;
  justify-content: center;
  padding-top: 6px;
  margin-top: 2px;
  border-top: 1px dashed rgba(8,42,85,0.08);
}
.setup-options-reset-btn {
  width: auto !important;
  background: transparent !important;
  border-color: transparent !important;
  color: var(--text-dim) !important;
  font-size: 10px !important;
  letter-spacing: 0.8px;
  padding: 4px 10px !important;
  height: auto !important;
}
.setup-options-reset-btn:hover:not(:disabled) {
  color: var(--red) !important;
  background: rgba(255,61,87,0.06) !important;
}

/* Hide legacy hints inside setup drawer */
.setup-flow-panel-copy,
.setup-flow-sidebar-copy,
.fp-hint,
.hint-box,
.sc-poi-desc,
.setup-flow-step-meta {
  display: none !important;
}
.setup-flow-selected-title,
.setup-flow-result-title,
.setup-flow-step-title,
.setup-flow-mission-type {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-hi);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.setup-flow-result-meta,
.setup-flow-selected-label,
.setup-flow-mission-reward {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
/* Route panel guide copy — show but subdued */
.route-brief,
.route-focus-copy,
.route-section-copy {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.45;
  margin-top: 3px;
}

/* Hide search bar when in setup-options flow (confusing in that context) */
#left-panel.setup-options-mode .sc-panel-search {
  display: none;
}

/* Legacy rules retained in case other code paths depend on them — harmless if unused */
.setup-options-footer .btn-danger {
  background: transparent;
  border-color: rgba(8,42,85,0.08);
  color: var(--text-dim);
  font-size: 10px;
}
.setup-options-footer .btn-danger:hover:not(:disabled) {
  background: rgba(255,61,87,0.08);
  border-color: rgba(255,61,87,0.3);
  color: var(--red);
}
/* Hide route dock kicker when empty (once fresh JS loads) */
#bottomBarRouteKicker:empty {
  display: none;
}

.modal.setup-flow-modal {
  width: min(1080px, calc(100vw - 48px));
  max-width: min(1080px, calc(100vw - 48px));
  height: min(720px, calc(100vh - 48px));
  max-height: min(720px, calc(100vh - 48px));
}
.modal.setup-flow-modal .modal-header {
  padding: 8px 14px;
}
.modal.setup-flow-modal .modal-header h3 {
  font-size: 13px;
  letter-spacing: 0.08em;
}
.modal.setup-flow-modal .modal-body {
  overflow: hidden;
  min-height: 0;
  padding: 12px 14px;
}
.modal.setup-flow-modal .modal-footer {
  padding: 8px 14px;
}
.setup-flow-start-over-btn {
  margin-left: auto;
  margin-right: 6px;
  margin-bottom: 0;
  min-width: 0;
  width: auto;
  padding-inline: 10px;
  height: 26px;
  font-size: 10px;
  white-space: nowrap;
}
.setup-flow-layout {
  display: grid;
  grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
  height: 100%;
  align-items: stretch;
}
.setup-flow-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-right: 12px;
  border-right: 1px solid rgba(8,42,85,0.07);
  min-height: 0;
  overflow-y: auto;
}
.setup-flow-steps {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-content: start;
}
.setup-flow-step {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 0;
  padding: 8px 10px;
  border: 1px solid rgba(8,42,85,0.09);
  border-radius: var(--r-md, 6px);
  background: rgba(8,42,85,0.02);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.setup-flow-step::after {
  content: '›';
  font-size: 16px;
  color: var(--text-dim);
  line-height: 1;
  transition: color 0.15s ease, transform 0.15s ease;
}
.setup-flow-step:hover {
  background: rgba(0,168,120,0.05);
  border-color: rgba(0,168,120,0.26);
  transform: translateX(1px);
}
.setup-flow-step:hover::after {
  color: var(--accent);
  transform: translateX(2px);
}
.setup-flow-step.active {
  border-color: rgba(0,168,120,0.4);
  background: rgba(0,168,120,0.1);
  box-shadow: inset 3px 0 0 var(--accent2, #21c69b);
}
.setup-flow-step.active::after {
  color: var(--accent);
}
.setup-flow-step.is-complete {
  border-color: rgba(0,216,130,0.3);
  background: rgba(0,216,130,0.05);
}
.setup-flow-step.is-complete .setup-flow-step-index {
  background: rgba(0,216,130,0.85);
  border-color: rgba(0,216,130,0.85);
  color: #02040a;
}
.setup-flow-step.is-complete::after {
  content: '✓';
  font-size: 11px;
  color: var(--green, #4fd389);
}
.setup-flow-step-index {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(8,42,85,0.15);
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-hi);
  background: rgba(255,255,255,0.02);
  flex-shrink: 0;
}
.setup-flow-step-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  justify-content: center;
  min-width: 0;
  flex: 1 1 auto;
}
.setup-flow-step-title {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.5px;
  overflow-wrap: anywhere;
}
.setup-flow-main,
.setup-flow-panel,
.setup-flow-form,
.setup-flow-location-list {
  display: grid;
  gap: 10px;
}
.setup-flow-main {
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  align-content: start;
  padding-right: 6px;
}
.setup-flow-panel {
  min-height: 100%;
  align-content: start;
}
.setup-flow-panel-kicker {
  font-size: 8px !important;
  letter-spacing: 0.14em;
}
.setup-flow-panel-title {
  font-size: 16px !important;
  line-height: 1.15;
  letter-spacing: 0.04em;
}
.setup-flow-panel-missions {
  grid-template-rows: auto auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}
.setup-flow-mission-layout {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(360px, 0.92fr) minmax(420px, 1.08fr);
  gap: 16px;
  align-items: stretch;
}
.setup-flow-mission-column {
  min-width: 0;
  min-height: 0;
  display: grid;
  gap: 16px;
}
.setup-flow-mission-column-intake {
  grid-template-rows: minmax(0, 1fr) auto;
}
.setup-flow-mission-column-active {
  grid-template-rows: minmax(0, 1fr);
}
.setup-flow-mission-box {
  min-width: 0;
  min-height: 0;
  border: 1px solid rgba(8,42,85,0.09);
  background: rgba(8,42,85,0.03);
  overflow: hidden;
  display: grid;
}
.setup-flow-mission-box-intake,
.setup-flow-mission-box-active {
  height: 100%;
}
.setup-flow-mission-box-shortcuts {
  align-self: start;
}
.setup-flow-workspace-host {
  min-height: 0;
  display: grid;
  overflow: hidden;
}
.setup-flow-workspace-intake-host {
  height: 100%;
}
.setup-flow-workspace-shortcut-host {
  height: 100%;
}
.setup-flow-workspace-active-host {
  height: 100%;
}
.setup-flow-search-launcher {
  position: relative;
}
.setup-flow-ship-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 150px);
  gap: 12px;
  align-items: end;
}
.setup-flow-ship-head .setup-flow-panel-title {
  margin-top: 0;
}
.setup-flow-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.setup-flow-form-group-span {
  grid-column: 1 / -1;
}
.setup-flow-form-group label {
  display: block;
  margin-bottom: 6px;
}
.setup-flow-ship-capacity label {
  display: block;
  margin-bottom: 6px;
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}
.setup-flow-ship-capacity input {
  width: 100%;
  padding-left: 10px;
  padding-right: 10px;
}
.setup-flow-selected-card,
.setup-flow-result-card,
.setup-flow-mission-card {
  border: 1px solid rgba(8,42,85,0.09);
  background: rgba(8,42,85,0.03);
}
.setup-flow-selected-card {
  padding: 8px 12px;
}
.setup-flow-selected-title {
  font-size: 13px !important;
}
.setup-flow-selected-copy {
  margin-top: 2px !important;
  font-size: 11px !important;
  line-height: 1.4 !important;
}
.setup-flow-selected-label {
  font-size: 8px !important;
}
.setup-flow-result-card {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.setup-flow-result-card.active {
  border-color: rgba(0,168,120,0.34);
  background: rgba(0,168,120,0.08);
}
.setup-flow-result-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.setup-flow-result-pill {
  padding: 3px 8px;
  border: 1px solid rgba(8,42,85,0.09);
  font-size: 10px;
  color: var(--accent);
  text-transform: uppercase;
  white-space: nowrap;
}
.setup-flow-system-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.setup-flow-location-list {
  position: absolute;
  top: calc(100% - 4px);
  left: 0;
  right: 0;
  display: grid;
  gap: 8px;
  max-height: min(38vh, 260px);
  overflow-y: auto;
  padding: 6px 6px 0;
  border: 1px solid rgba(0,168,120,0.2);
  background: rgba(240,246,252,0.98);
  box-shadow: 0 18px 34px rgba(0,0,0,0.46);
  z-index: 8;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.setup-flow-ship-list {
  top: calc(100% - 2px);
}
.setup-flow-location-list.is-hidden {
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
}

@media (max-width: 760px) {
  .setup-flow-ship-head {
    grid-template-columns: 1fr;
  }
  .setup-flow-mission-shortcuts {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 1050px) {
  .setup-flow-mission-layout {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 1200px) {
  .modal.setup-flow-modal {
    width: calc(100vw - 28px);
    max-width: calc(100vw - 28px);
    height: calc(100vh - 28px);
    max-height: calc(100vh - 28px);
  }
  .setup-flow-layout {
    grid-template-columns: 1fr;
  }
  .setup-flow-sidebar {
    border-right: none;
    border-bottom: 1px solid rgba(8,42,85,0.07);
    padding-right: 0;
    padding-bottom: 12px;
    overflow: visible;
  }
}
.setup-flow-mission-card {
  padding: 10px 12px;
}
.setup-flow-mission-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}
.setup-flow-workspace-panel {
  display: block !important;
  min-height: 0;
  max-height: min(52vh, 640px);
  overflow-y: auto;
  padding-right: 4px;
}
.setup-flow-empty {
  padding: 14px 12px;
  border: 1px dashed rgba(8,42,85,0.12);
  background: rgba(8,42,85,0.02);
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.5;
}
.setup-flow-mission-section {
  padding: 16px 18px;
  border: none;
  border-bottom: none;
  background: transparent;
  min-width: 0;
}
.setup-flow-mission-intake-section,
.setup-flow-mission-shortcuts-section,
.setup-flow-mission-active-section {
  display: grid;
  gap: 14px;
  align-content: start;
}
.setup-flow-mission-intake-section,
.setup-flow-mission-active-section {
  min-height: 0;
  height: 100%;
  overflow-y: auto;
}
.setup-flow-mission-intake-section .fp-hint {
  margin: 0;
  padding: 0;
  background: transparent;
}
.setup-flow-mission-intake-section .mission-intake-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 0;
}
.setup-flow-mission-intake-section .mission-intake-action {
  width: 100%;
  justify-content: center;
}
/* Manual Entry and Load Random were hidden in the intake area in favour
   of duplicates lower in the modal — but on phones those duplicates sit
   below the fold. Showing them up here too keeps all three intake
   actions immediately reachable on every viewport. */
.setup-flow-mission-intake-section .mission-intake-action-manual,
.setup-flow-mission-intake-section .mission-intake-action-random {
  display: inline-flex;
}

/* "Take Photo" surfaces the device camera on touch hardware. Hidden on
   pointer-fine devices because desktop users already have a richer file
   picker via "Add Screenshot". */
.mission-intake-action-camera { display: none; }
@media (pointer: coarse) {
  .mission-intake-action-camera { display: inline-flex; }
}
.setup-flow-mission-intake-section .mission-intake-drop-zone {
  min-height: 170px;
}
.setup-flow-mission-intake-section .mission-intake-scan-row {
  margin-top: 0;
}
.setup-flow-mission-intake-section .mission-intake-scan-row .btn-primary {
  flex: 1 1 auto;
}
.setup-flow-mission-intake-section .scanner-log {
  min-height: 84px;
  max-height: none;
}
.setup-flow-mission-shortcuts-section select,
.setup-flow-mission-shortcuts-section #missionDetails,
.setup-flow-mission-shortcuts-section #addMissionButton {
  display: none !important;
}
.setup-flow-mission-shortcuts-section {
  padding: 8px;
  gap: 8px;
}
.setup-flow-mission-shortcuts-section .fp-label:empty {
  display: none;
}
.setup-flow-mission-shortcuts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.setup-flow-mission-shortcut {
  width: 100%;
  min-height: 0;
  padding: 8px 12px;
  border: 1px solid rgba(8,42,85,0.09);
  background: rgba(8,42,85,0.03);
  color: var(--text-hi);
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.setup-flow-mission-shortcut:hover {
  border-color: rgba(0,168,120,0.28);
  background: rgba(0,168,120,0.08);
  transform: translateY(-1px);
}
.setup-flow-mission-shortcut-title {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  text-align: center;
}
.setup-flow-mission-active-section {
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: stretch;
}
.setup-flow-mission-active-section #missionList {
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  padding-right: 4px;
  margin-top: 0 !important;
}
.setup-flow-mission-active-section .empty-state {
  min-height: 240px;
  display: grid;
  place-items: center;
  text-align: center;
}

/* ── POI Info block (shown on hover) ── */
#sc-poi-info {
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}
.sc-poi-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px 10px;
  background: rgba(0,168,120,0.04);
}
.sc-poi-icon {
  font-size: 22px; color: var(--accent); flex-shrink: 0;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(0,168,120,0.25);
  background: rgba(0,168,120,0.07);
}
.sc-poi-name {
  font-family: var(--font-ui);
  font-size: 16px; font-weight: 700;
  color: var(--text-hi); letter-spacing: 1.5px; text-transform: uppercase;
  line-height: 1.1;
}
.sc-poi-type {
  font-size: 9px; font-weight: 700; letter-spacing: 1px;
  color: var(--text-dim); text-transform: uppercase; margin-top: 2px;
}
.sc-poi-section-label {
  font-size: 9px; font-weight: 700; letter-spacing: 1.2px;
  color: var(--text-dim); text-transform: uppercase;
  padding: 6px 14px 4px;
  border-top: 1px solid var(--border-dim);
}
.sc-poi-jurisdiction {
  margin: 0 14px 8px;
  padding: 5px 10px;
  background: rgba(0,168,120,0.08);
  border: 1px solid rgba(0,168,120,0.2);
  font-family: var(--font-ui); font-size: 12px; font-weight: 700;
  color: var(--accent); letter-spacing: 1px; text-transform: uppercase;
  display: flex; align-items: center; gap: 7px;
}
.sc-poi-jurisdiction::before {
  content: '◈'; font-size: 10px;
}
.sc-poi-desc {
  font-size: 11px; color: var(--text-dim); line-height: 1.6;
  padding: 0 14px 10px;
}

/* ── Tab panels ── */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Panel Footer (SC nav buttons) ── */
.sc-panel-footer {
  flex-shrink: 0;
  display: flex; align-items: center;
  border-top: 1px solid var(--panel-border);
  height: 38px;
  position: relative; z-index: 1;
  background: rgba(0,0,0,0.25);
}
.sc-foot-btn {
  width: 38px; height: 38px;
  background: none; border: none; border-right: 1px solid var(--panel-border);
  color: var(--text-dim); font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; flex-shrink: 0;
  font-family: var(--font-ui);
}
.sc-foot-btn:hover { color: var(--accent); background: rgba(0,168,120,0.07); }

.sc-route-btn {
  flex: 1; height: 38px;
  background: var(--surface2);
  border: none;
  color: var(--text-mute);
  font-family: var(--font-ui); font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  cursor: pointer; transition: all var(--dur-fast) var(--ease);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 12px;
  position: relative; overflow: hidden;
}
.sc-route-btn:not(:disabled) {
  color: #0b0e13;
  background: var(--accent);
  border-top: 1px solid var(--accent2);
}
.sc-route-btn:not(:disabled):hover {
  background: var(--accent2);
  box-shadow: 0 0 18px rgba(0,168,120,0.3);
}
.sc-route-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.sc-route-icon { font-size: 12px; }
.sc-route-btn.calculating {
  color: var(--text);
  background: var(--surface2);
}
.sc-route-btn.calculating::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--accent-soft), transparent);
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer {
  0%  { transform: translateX(-100%); }
  100%{ transform: translateX(100%); }
}

/* ============================================================
   RIGHT PANEL (Route Summary)
   ============================================================ */
#route-panel {
  position: absolute;
  top: 10px; bottom: 10px; right: 10px;
  width: var(--route-w);
  display: flex; flex-direction: column;
  background: var(--panel-bg);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  box-shadow: var(--panel-shadow);
  z-index: 200;
  overflow: hidden;
  transform: translateX(calc(var(--route-w) + 22px));
  transition: transform var(--dur) var(--ease-out), opacity var(--dur) var(--ease-out);
  opacity: 0;
}
#route-panel.open { transform: translateX(0); opacity: 1; }

/* Corner tick marks */
#route-panel::before,
#route-panel::after {
  content: "";
  position: absolute;
  width: 10px; height: 10px;
  border-color: var(--hairline-hi);
  pointer-events: none;
  z-index: 1;
}
#route-panel::before { top: 0; left: 0; border-top: 1px solid; border-left: 1px solid; }
#route-panel::after  { bottom: 0; right: 0; border-bottom: 1px solid; border-right: 1px solid; }

/* Panel header */
.fp-header {
  height: 38px; flex-shrink: 0;
  display: flex; align-items: center;
  border-bottom: 1px solid var(--panel-border);
  gap: 0;
}
.fp-title {
  font-family: var(--font-ui);
  font-size: 11px; font-weight: 700;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: 1.2px;
  padding: 0 14px; flex: 1;
}
.fp-close {
  width: 38px; height: 38px;
  background: none; border: none; border-left: 1px solid var(--panel-border);
  color: var(--text-dim); font-size: 11px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.fp-close:hover { background: rgba(255,61,87,0.12); color: var(--red); }
#route-panel .fp-close { display: none; }

/* Right panel tabs */
.rpanel-tabs { display: flex; flex: 1; height: 38px; }
.right-tab-btn {
  flex: 1; height: 38px;
  background: none; border: none; border-right: 1px solid var(--panel-border);
  color: var(--text-dim);
  font-family: var(--font-ui); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px; cursor: pointer;
  transition: all 0.15s;
  border-bottom: 2px solid transparent;
}
.right-tab-btn:last-child { border-right: none; }
.right-tab-btn:hover { color: var(--text); background: rgba(8,42,85,0.03); }
.right-tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(0,168,120,0.05);
}

/* Right panel content */
.right-panel { display: none; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.right-panel.active { display: flex; }

/* Scrollable body */
.fp-body { flex: 1; overflow-y: auto; min-height: 0; }

.route-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(140px, 0.8fr);
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(0,168,120,0.04);
  flex-shrink: 0;
}
.route-hero-copy {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.route-kicker,
.route-focus-label,
.route-section-kicker {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.route-headline {
  font-family: var(--font-ui);
  font-size: clamp(18px, 1.9vw, 22px);
  font-weight: 700;
  color: var(--text-hi);
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  overflow-wrap: anywhere;
}
.route-brief {
  font-size: 11px;
  color: var(--text);
  line-height: 1.45;
  text-transform: none;
  max-width: 32ch;
}
.route-profit-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid rgba(8,42,85,0.08);
  background: rgba(8,42,85,0.02);
}
/* Amber styling only once a route is calculated */
#route-panel.has-route .route-profit-card {
  border-color: rgba(232,160,0,0.2);
  background: rgba(232,160,0,0.06);
}
.route-profit-value {
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1;
}

.route-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  padding: 0;
  border-bottom: 1px solid var(--panel-border);
  background: var(--panel-border);
  flex-shrink: 0;
}
.metric-box {
  background: var(--panel-bg);
  padding: 9px 12px;
}
.metric-wide { grid-column: 1 / -1; }
.metric-label {
  font-size: 9px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 3px;
}
.metric-value {
  font-family: var(--font-mono); font-size: 18px; font-weight: 600;
  color: var(--text-hi); line-height: 1; letter-spacing: -0.02em;
}
.metric-value.green { color: var(--green); }
.metric-value.amber { color: var(--amber); }
.metric-value.blue  { color: var(--accent); }
.metric-value.red   { color: var(--red); }

.route-actions {
  padding: 10px 14px;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  flex-shrink: 0;
}
.route-actions .btn {
  margin-bottom: 0;
  flex: 0 0 auto;
}
.route-run-btn {
  flex: 0 0 auto;
  width: 100%;
  height: 40px;
  min-height: 40px;
  font-size: 12px;
}
.route-full-btn,
.route-overview-btn {
  flex: 0 0 auto;
  height: 34px;
  min-height: 34px;
}

#route-details-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.route-tools-menu {
  position: relative;
}
.route-tools-menu summary {
  list-style: none;
  margin-bottom: 0;
}
.route-tools-menu summary::-webkit-details-marker {
  display: none;
}
.route-tools-menu[open] summary {
  border-color: rgba(0,168,120,0.34);
  background: rgba(0,168,120,0.08);
  color: var(--text-hi);
}
.route-tools-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 5;
  width: 170px;
  padding: 8px;
  display: grid;
  gap: 6px;
  border: 1px solid var(--panel-border);
  background: rgba(240,246,252,0.98);
  box-shadow: 0 18px 36px rgba(0,0,0,0.45);
}

.route-focus-grid {
  display: grid;
  gap: 10px;
}
.route-focus-card {
  padding: 12px;
  border: 1px solid rgba(0,168,120,0.14);
  background: rgba(0,168,120,0.04);
}
.route-focus-title {
  margin-top: 4px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-hi);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.route-focus-copy,
.route-section-copy {
  margin-top: 5px;
  font-size: 12px;
  color: var(--text);
  line-height: 1.55;
  text-transform: none;
}
.route-advanced-details {
  margin: 10px 14px 0;
  border: 1px solid var(--border-dim);
  background: rgba(8,42,85,0.02);
  flex-shrink: 0;
}
.route-advanced-details summary {
  padding: 12px 14px;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-hi);
  text-transform: uppercase;
  letter-spacing: 1px;
  list-style: none;
}
.route-advanced-details summary::-webkit-details-marker {
  display: none;
}
.route-advanced-details summary::after {
  content: '+';
  float: right;
  color: var(--accent);
}
.route-advanced-details[open] summary::after {
  content: '−';
}
.route-advanced-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--panel-border);
  border-top: 1px solid var(--panel-border);
}
.route-section-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.route-section-title {
  font-family: var(--font-ui);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-hi);
  text-transform: uppercase;
  letter-spacing: 0.7px;
}

#right-panel-route.route-panel-overview-compact .route-focus-grid {
  grid-template-columns: 1fr;
  align-items: start;
}
#right-panel-route.route-panel-overview-compact .route-section-head,
#right-panel-route.route-panel-overview-compact #routeDetails {
  display: none;
}

/* Base pull-tab box (detailed positioning / labels live in ui.css) */
.panel-pull-tab {
  position: absolute;
  z-index: 230;
  padding: 8px 6px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(6, 10, 20, 0.97);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.panel-pull-tab:hover {
  color: var(--accent);
  border-color: rgba(0,168,120,0.35);
  background: rgba(0,168,120,0.06);
}
.panel-pull-tab.is-open {
  color: var(--accent);
  border-color: rgba(0,168,120,0.3);
  background: rgba(0,168,120,0.05);
}
.panel-pull-tab-label {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

#route-panel.route-panel-guided .route-hero {
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 14px 16px 10px;
  background:
    linear-gradient(180deg, rgba(0,168,120,0.06), rgba(0,168,120,0.015)),
    radial-gradient(circle at top left, rgba(0,168,120,0.08), transparent 58%);
}
#route-panel.route-panel-guided .route-headline {
  font-size: clamp(15px, 1.35vw, 18px);
  line-height: 1.08;
  letter-spacing: 0.4px;
}
#route-panel.route-panel-guided .route-brief,
#route-panel.route-panel-guided .route-profit-card,
#route-panel.route-panel-guided .route-metrics,
#route-panel.route-panel-guided .route-advanced-details,
#route-panel.route-panel-guided .route-focus-grid,
#route-panel.route-panel-guided .route-section-head {
  display: none;
}
#route-panel.route-panel-guided .route-actions {
  padding: 10px 16px;
  justify-content: space-between;
  flex-wrap: nowrap;
}
#route-panel.route-panel-guided .route-overview-btn {
  flex: 1 1 auto;
}
#route-panel.route-panel-guided .route-tools-menu {
  margin-left: auto;
}
#route-panel.route-panel-guided #route-details-container {
  padding: 12px 16px 16px;
  gap: 12px;
}
#route-panel.route-panel-guided .route-nav-progress {
  display: none;
}
#route-panel.route-panel-guided .route-nav-card,
#route-panel.route-panel-guided .route-nav-footer {
  padding: 12px;
}
#route-panel.route-panel-guided .route-nav-card-title {
  font-size: 18px;
}
#route-panel.route-panel-guided .route-nav-card-copy,
#route-panel.route-panel-guided .route-nav-step-text,
#route-panel.route-panel-guided .route-nav-footer-copy,
#route-panel.route-panel-guided .route-task-detail {
  font-size: 11px;
}
#route-panel.route-panel-guided .ai-analysis-box {
  display: none !important;
}


/* ============================================================
   BOTTOM BAR — Flat single-row layout
   Layout is entirely delegated to ui.css. This file keeps only the
   top-level scaffolding so legacy rules don't reappear.
   ============================================================ */

/* (All bottom-bar visual rules live in ui.css.) */


/* Graph container — lives inside route panel */
.algo-overview {
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(0,168,120,0.18);
  background: rgba(0,168,120,0.04);
}

.algo-overview-title {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-hi);
  margin-bottom: 5px;
}

.algo-overview p {
  margin: 0;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.55;
}

.graph-modal {
  width: min(960px, 92vw);
  max-width: min(960px, 92vw);
  height: min(72vh, 560px);
}

.graph-modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.graph-modal-copy {
  margin: 0;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.5;
}

.graph-frame {
  flex: 1;
  min-height: 320px;
  border: 1px solid var(--panel-border);
  background: rgba(3,8,18,0.92);
  padding: 10px;
}

#graph-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.entity-tree-modal {
  width: min(1120px, 94vw);
  max-width: min(1120px, 94vw);
  height: min(78vh, 720px);
}

.entity-tree-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1.15fr) minmax(300px, 0.85fr);
  gap: 14px;
  height: 100%;
  min-height: 0;
}

.entity-tree-panel,
.entity-tree-details {
  min-height: 0;
  border: 1px solid var(--border-dim);
  background: var(--surface0);
}

.entity-tree-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.entity-tree-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(0,168,120, 0.04);
}

.entity-tree-toolbar-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entity-tree-toolbar-copy {
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.5;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.entity-tree-search {
  margin: 0;
  background: rgba(0, 0, 0, 0.24);
}

.entity-tree-toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.entity-tree-root {
  flex: 1;
  overflow: auto;
  padding: 10px 12px 14px;
}

.entity-tree-empty {
  padding: 22px 14px;
  text-align: center;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.6;
}

.entity-tree-node {
  display: block;
}

.entity-tree-node-children {
  margin-left: 14px;
  padding-left: 10px;
  border-left: 1px solid rgba(8,42,85,0.09);
}

.entity-tree-row-wrap {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.entity-tree-toggle,
.entity-tree-spacer {
  width: 20px;
  flex: 0 0 20px;
}

.entity-tree-toggle {
  border: 1px solid rgba(8,42,85,0.09);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  transition: all 0.15s;
}

.entity-tree-toggle:hover {
  border-color: rgba(0,168,120, 0.28);
  color: var(--accent);
}

.entity-tree-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.entity-tree-row:hover {
  border-color: rgba(8,42,85,0.09);
  background: rgba(255, 255, 255, 0.03);
}

.entity-tree-row.active {
  border-color: rgba(0,168,120, 0.34);
  background: rgba(0,168,120, 0.08);
}

.entity-tree-row.placeholder {
  opacity: 0.7;
}

.entity-tree-icon {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}

.entity-tree-copy {
  flex: 1;
  min-width: 0;
}

.entity-tree-name {
  display: block;
  color: var(--text-hi);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entity-tree-meta {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.entity-tree-badge {
  flex-shrink: 0;
  padding: 2px 7px;
  border: 1px solid rgba(8,42,85,0.09);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.entity-tree-details {
  padding: 14px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.entity-tree-card {
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.02);
  padding: 12px;
}

.entity-tree-detail-label {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.entity-tree-detail-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-hi);
  letter-spacing: 1px;
  text-transform: uppercase;
  line-height: 1.1;
}

.entity-tree-detail-subtitle {
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.entity-tree-path {
  font-size: 11px;
  color: var(--text);
  line-height: 1.6;
}

.entity-tree-path strong {
  color: var(--text-hi);
}

.entity-tree-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.entity-tree-stat {
  border: 1px solid rgba(8,42,85,0.09);
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 10px;
}

.entity-tree-stat-name {
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 0.9px;
  text-transform: uppercase;
}

.entity-tree-stat-value {
  margin-top: 3px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-hi);
}

.entity-tree-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.entity-tree-actions .btn {
  margin-bottom: 0;
}

.entity-tree-children {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.entity-tree-child-btn {
  padding: 6px 9px;
  border: 1px solid rgba(8,42,85,0.09);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: all 0.15s;
}

.entity-tree-child-btn:hover {
  border-color: rgba(0,168,120, 0.26);
  color: var(--accent);
  background: rgba(0,168,120, 0.08);
}

.entity-tree-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entity-tree-list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(8,42,85,0.07);
  font-size: 11px;
}

.entity-tree-list-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.entity-tree-list-term {
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.7px;
}

.entity-tree-list-value {
  color: var(--text);
  text-align: right;
}

/* Keyboard shortcuts (right side) */
.sc-bar-shortcuts {
  display: flex; flex-direction: row; align-items: center; gap: 10px;
  padding: 0 10px;
  flex-shrink: 0;
}
.sc-shortcut {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 9px; font-weight: 700; letter-spacing: 0.8px;
  color: var(--text-dim); text-transform: uppercase; white-space: nowrap;
}
.sc-shortcut-hidden { display: none; }
kbd {
  background: var(--surface2); border: 1px solid var(--hairline-2);
  border-bottom-width: 2px; border-radius: 2px;
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 600;
  padding: 1px 5px; color: var(--text-hi);
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px;
}

/* ============================================================
   MAP OVERLAYS
   ============================================================ */

/* Map controls: top-left (SC-style vertical strip) */
.map-controls {
  position: absolute; top: 10px; left: 10px;
  display: flex; flex-direction: column; gap: 4px; z-index: 10;
  transition: left 0.22s var(--ease);
}
#map-area:has(#left-panel.open) .map-controls {
  left: calc(var(--panel-w) + 20px);
}
.map-ctrl-btn {
  width: 32px; height: 32px;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  color: var(--text-dim); font-size: 12px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  font-family: var(--font-ui); letter-spacing: 0;
}
.map-ctrl-btn:hover { border-color: var(--accent2); color: var(--accent); background: rgba(0,168,120,0.08); }
.map-ctrl-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(0,168,120,0.14); }

/* Map legend: bottom-left of map (ui.css handles positioning) */
.map-legend {
  transition: background var(--dur-fast) var(--ease);
}
.legend-title {
  font-family: var(--font-ui); font-size: 9px; font-weight: 700;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px;
}
.legend-item { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; color: var(--text-dim); }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* Map tooltip */
#map-tooltip {
  position: absolute; pointer-events: none; z-index: 20;
  background: var(--surface0);
  backdrop-filter: blur(14px);
  border: 1px solid var(--hairline-2);
  border-radius: 3px;
  padding: 8px 12px;
  box-shadow: 0 8px 24px -8px rgba(0,0,0,0.5);
  font-family: var(--font-ui); font-size: 12px; font-weight: 600;
  color: var(--text-hi); letter-spacing: 0.02em;
  display: none; white-space: nowrap;
}
#map-tooltip .tt-type {
  font-family: var(--font-mono); font-size: 10px; font-weight: 400; color: var(--text-dim);
  letter-spacing: 0.05em; margin-top: 2px; text-transform: uppercase;
}

/* Map search overlay */
#map-search-overlay {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 15; display: none; flex-direction: column; gap: 0;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-active);
  border-radius: 3px;
  padding: 0; width: 300px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7);
}
#map-search-overlay input {
  margin-bottom: 0; border: none; background: transparent;
  border-bottom: 1px solid var(--panel-border);
  font-family: var(--font-ui); font-size: 12px; font-weight: 500;
  letter-spacing: 0.02em; color: var(--text-hi);
  height: 38px; padding: 0 14px;
}
#map-search-overlay input:focus { box-shadow: none; }
.search-result-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 14px;
  cursor: pointer; font-family: var(--font-ui);
  font-size: 12px; font-weight: 500; color: var(--text);
  letter-spacing: 0.01em; border-bottom: 1px solid var(--panel-border);
  transition: background var(--dur-fast) var(--ease);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--accent-soft); color: var(--accent); }
.search-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.search-type { margin-left: auto; font-family: var(--font-mono); font-size: 9px; color: var(--text-dim); letter-spacing: 0.05em; text-transform: uppercase; }

/* ============================================================
   PANEL SECTION STYLES (fp-section, fp-label etc.)
   ============================================================ */
.fp-section {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-dim);
}
.fp-section:last-child { border-bottom: none; }
.fp-section-fill { flex: 1; display: flex; flex-direction: column; }
.fp-section-hidden { display: none; }
.fp-section-collapsible {
  padding: 0;
  background: linear-gradient(180deg, rgba(8,42,85,0.02), rgba(8,42,85,0.01));
}
.fp-section-toggle {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid rgba(8,42,85,0.04);
  background: transparent;
  color: var(--text-hi);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.fp-section-toggle:hover {
  background: rgba(0,168,120,0.05);
}
.fp-section-toggle-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.fp-section-toggle-kicker {
  font-size: 8px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.fp-section-toggle-title {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-hi);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.fp-section-toggle-summary {
  justify-self: end;
  min-width: 0;
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fp-section-toggle-icon {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  transition: transform 0.15s ease, color 0.15s ease;
}
.fp-section.collapsed .fp-section-toggle-icon {
  transform: rotate(-90deg);
}
.fp-section-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 12px 12px;
}
.fp-section.collapsed .fp-section-content {
  display: none;
}
.fp-label-sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.fp-label {
  font-family: var(--font-ui);
  font-size: 10px; font-weight: 700;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px;
  margin-bottom: 8px;
}
.fp-label-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.fp-hint {
  font-size: 11px; color: var(--text-dim); line-height: 1.55;
  background: none; border: none; padding: 0;
  font-family: var(--font-ui);
}
.fp-hint strong { color: var(--text); }

/* ============================================================
   FORM CONTROLS
   ============================================================ */
label {
  display: block; font-size: 11px; font-weight: 700;
  color: var(--text-dim); margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: 0.8px;
  font-family: var(--font-ui);
}

input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%; padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--hairline);
  color: var(--text-hi);
  font-size: 12.5px; font-family: var(--font-ui); font-weight: 400;
  letter-spacing: 0.01em;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
  outline: none; margin-bottom: 8px;
  border-radius: 3px;
}
input[type="text"]:hover,
input[type="number"]:hover,
input[type="password"]:hover,
select:hover { border-color: var(--hairline-2); }
input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  background: var(--surface-hi);
  box-shadow: none;
}
input::placeholder, textarea::placeholder { color: var(--text-mute); }
input:disabled { opacity: 0.4; cursor: not-allowed; }
select option { background: var(--surface0); }
textarea { resize: vertical; min-height: 60px; font-size: 11px; }

.form-group { margin-bottom: 8px; }
.form-row { display: flex; gap: 8px; }
.form-row > * { flex: 1; }

/* Ship info bar */
.ship-info {
  display: none; gap: 8px; padding: 6px 10px;
  flex-wrap: wrap;
  background: rgba(0,150,200,0.07);
  border: 1px solid rgba(0,150,200,0.2);
  font-size: 11px; color: var(--accent);
  margin-bottom: 0; font-weight: 700;
  font-family: var(--font-ui); letter-spacing: 0.5px;
}

.ship-search-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ship-search-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ship-search-helper {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.9px;
  text-transform: uppercase;
}

#shipSearchInput {
  margin-bottom: 0;
}

.ship-search-results {
  display: grid;
  gap: 6px;
}

.ship-search-result {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid rgba(8,42,85,0.09);
  background: rgba(8,42,85,0.02);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.ship-search-result:hover {
  border-color: rgba(0,168,120,0.28);
  background: rgba(0,168,120,0.06);
}

.ship-search-result.active {
  border-color: rgba(0,168,120,0.34);
  background: rgba(0,168,120,0.12);
  box-shadow: inset 2px 0 0 var(--accent2);
}

.ship-search-result-manual {
  border-style: dashed;
}

.ship-search-result-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ship-search-result-name {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-hi);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.ship-search-result-meta {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.6px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.ship-search-result-cargo {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.7px;
  text-transform: uppercase;
  white-space: nowrap;
}

.ship-search-empty {
  padding: 10px 12px;
  border: 1px dashed rgba(8,42,85,0.11);
  background: rgba(8,42,85,0.02);
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.45;
}

.location-search-picker {
  display: grid;
  gap: 10px;
}

.location-search-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.location-search-picker-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.9px;
  text-transform: uppercase;
}

.location-search-input {
  margin-bottom: 0;
}

.location-search-selected {
  padding: 10px 12px;
  border: 1px solid rgba(0,168,120,0.18);
  background: rgba(0,168,120,0.05);
}

.location-search-selected.empty {
  border-style: dashed;
  background: rgba(8,42,85,0.02);
}

.location-search-results {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}

.location-workspace-modal {
  width: min(94vw, 920px);
  max-width: min(94vw, 920px);
}

.location-workspace-panel {
  display: grid;
  gap: 12px;
}

.location-workspace-panel .location-search-results {
  max-height: min(50vh, 360px);
}

.start-location-picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#startLocationSearch {
  margin-bottom: 0;
}

.start-location-system-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.start-location-system-tab {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid rgba(8,42,85,0.09);
  background: rgba(8,42,85,0.03);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}

.start-location-system-tab:hover {
  border-color: rgba(0,168,120,0.26);
  background: rgba(0,168,120,0.06);
}

.start-location-system-tab.active {
  border-color: rgba(0,168,120,0.34);
  background: rgba(0,168,120,0.12);
  box-shadow: inset 2px 0 0 var(--accent2);
}

.start-location-system-tab.placeholder {
  opacity: 0.72;
}

.start-location-system-tab-name,
.start-location-system-tab-count {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.start-location-system-tab-name {
  color: var(--text-hi);
}

.start-location-system-tab-count {
  color: var(--text-dim);
}

.start-location-selected {
  padding: 10px 12px;
  border: 1px solid rgba(0,168,120,0.18);
  background: rgba(0,168,120,0.05);
}

.start-location-selected.empty {
  border-style: dashed;
  background: rgba(8,42,85,0.02);
}

.start-location-selected-label {
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.start-location-selected-name {
  font-family: var(--font-ui);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-hi);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.start-location-selected-meta,
.start-location-selected-empty {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-top: 4px;
  font-family: var(--font-ui);
}

.start-location-list {
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid var(--border-dim);
  background: rgba(0,0,0,0.18);
  padding: 10px;
}

.start-location-browser {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.start-location-section {
  border: 1px solid rgba(8,42,85,0.07);
  background: rgba(8,42,85,0.02);
}

.start-location-section > .start-location-subgroup {
  padding: 10px 12px 12px;
}

.start-location-section > .start-location-subgroup + .start-location-subgroup {
  border-top: 1px solid rgba(8,42,85,0.04);
  padding-top: 10px;
}

.start-location-section-header {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(8,42,85,0.04);
  background: rgba(0,168,120,0.04);
}

.start-location-section-title {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-hi);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.start-location-section-copy {
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.5;
}

.start-location-body-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 12px;
}

.start-location-body-card {
  border: 1px solid rgba(8,42,85,0.09);
  background: rgba(8,42,85,0.02);
}

.start-location-body-card.nested {
  margin-top: 8px;
}

.start-location-body-summary {
  list-style: none;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
}

.start-location-body-summary::-webkit-details-marker {
  display: none;
}

.start-location-body-card[open] > .start-location-body-summary {
  border-bottom: 1px solid rgba(8,42,85,0.04);
  background: rgba(8,42,85,0.02);
}

.start-location-body-dot,
.start-location-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(8,42,85,0.11);
  flex-shrink: 0;
}

.start-location-body-copy,
.start-location-action-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.start-location-body-name,
.start-location-action-name {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-hi);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.start-location-body-meta,
.start-location-action-meta {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.start-location-body-count {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  text-align: right;
}

.start-location-body-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px 12px;
}

.start-location-body-children {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.start-location-subgroup {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.start-location-subgroup-label {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.9px;
}

.start-location-action-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.start-location-action {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid rgba(8,42,85,0.09);
  background: rgba(8,42,85,0.02);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.start-location-action:hover {
  border-color: rgba(0,168,120,0.28);
  background: rgba(0,168,120,0.06);
}

.start-location-action.active {
  border-color: rgba(0,168,120,0.34);
  background: rgba(0,168,120,0.12);
  box-shadow: inset 2px 0 0 var(--accent2);
}

.start-location-action-type {
  padding: 2px 6px;
  border: 1px solid rgba(8,42,85,0.09);
  background: rgba(8,42,85,0.03);
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  white-space: nowrap;
}

.start-location-empty {
  padding: 14px 12px;
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-ui);
}

.route-mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.route-mode-grid-modal {
  margin-bottom: 0;
}

.route-mode-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px 10px 34px;
  border: 1px solid var(--border-dim);
  background: rgba(8,42,85,0.03);
  cursor: pointer;
  margin-bottom: 0;
  min-height: 108px;
  text-transform: none;
  transition: border-color 0.15s, background 0.15s;
}

.route-mode-card:hover {
  border-color: rgba(0,168,120,0.24);
  background: rgba(0,168,120,0.05);
}

.route-mode-card input {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
}

.route-mode-title {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-hi);
  letter-spacing: 0.3px;
  text-transform: none;
  line-height: 1.1;
}

.route-mode-copy {
  flex: 1;
  font-size: 10.5px;
  color: var(--text-dim);
  line-height: 1.4;
  text-transform: none;
}

.route-mode-card:has(input:checked) {
  border-color: rgba(0,168,120,0.45);
  background: rgba(0,168,120,0.07);
  box-shadow: inset 3px 0 0 var(--accent2);
}

.route-priority-modal {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.route-priority-copy {
  margin: 0;
  font-size: 12px;
  color: var(--text);
  line-height: 1.6;
}
.route-mode-card-modal {
  min-height: 0;
  padding: 8px 10px 8px 28px;
  gap: 3px;
}
.route-mode-card-modal .route-mode-title {
  font-size: 11px;
}
.route-mode-card-modal .route-mode-copy {
  font-size: 10px;
  line-height: 1.35;
}
.route-mode-card-modal input {
  top: 9px;
  left: 9px;
  width: 12px;
  height: 12px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 12px; border: 1px solid var(--hairline-2);
  font-size: 12px; font-weight: 500;
  font-family: var(--font-ui); letter-spacing: 0.02em;
  cursor: pointer; transition: all var(--dur-fast) var(--ease);
  border-radius: 3px;
  background: var(--surface2); color: var(--text);
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--hairline-hi); background: var(--surface-hi); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  background: var(--accent); color: #0b0e13;
  border-color: var(--accent); font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: var(--accent2); border-color: var(--accent2); }
.btn-primary:disabled { background: var(--surface2); color: var(--text-mute); border-color: var(--hairline); }
.btn-success { background: rgba(0,216,130,0.15); color: var(--green); border-color: rgba(0,216,130,0.3); }
.btn-success:hover:not(:disabled) { background: rgba(0,216,130,0.25); border-color: var(--green); }
.btn-danger { color: var(--red); border-color: var(--red-soft); background: transparent; }
.btn-danger:hover:not(:disabled) { background: var(--red-soft); border-color: var(--red); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--surface2); border-color: var(--hairline); }
.btn-ai { background: rgba(100,60,200,0.2); color: var(--purple); border-color: rgba(100,60,200,0.35); }
.btn-ai:hover:not(:disabled) { background: rgba(130,80,230,0.3); border-color: var(--purple); }
.btn-sm { padding: 4px 10px; font-size: 10px; }
.btn-full { width: 100%; }
.btn-icon { padding: 4px 8px; }
.btn-row { display: flex; gap: 5px; flex-wrap: wrap; }

/* Calculate main button (hidden legacy — now uses sc-route-btn) */
.calc-main-btn { display: none; }

/* Prices status */
.prices-status-row { display: flex; align-items: center; gap: 7px; }
.price-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.price-dot.live    { background: var(--green); }
.price-dot.offline { background: var(--text-dim); opacity: 0.5; }

/* ============================================================
   MISSION LIST
   ============================================================ */
.mission-list { display: flex; flex-direction: column; gap: 6px; }

.mission-item {
  background: rgba(8,42,85,0.02);
  border: 1px solid var(--border-dim);
  border-left: 2px solid var(--green2);
  padding: 10px 12px;
  transition: border-color 0.15s;
}
.mission-item:hover { border-color: rgba(0,168,120,0.2); }

.mission-item-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 5px; }
.mission-badge {
  font-family: var(--font-ui); font-size: 9px; font-weight: 700;
  padding: 2px 7px; text-transform: uppercase; letter-spacing: 0.8px; border-radius: 0;
}
.badge-direct   { background: rgba(0,168,120,0.1);  color: var(--accent);  border: 1px solid rgba(0,168,120,0.2); }
.badge-multi-do { background: rgba(232,160,0,0.1);  color: var(--amber);   border: 1px solid rgba(232,160,0,0.2); }
.badge-multi-pu { background: rgba(0,216,130,0.1);  color: var(--green);   border: 1px solid rgba(0,216,130,0.2); }
.badge-count    { background: var(--accent2); color: #fff; font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 0; margin-left: 4px; }
.mission-intake-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.mission-intake-scan-row {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.mission-intake-drop-zone {
  min-height: 112px;
}

.mission-cargo  { font-size: 11px; color: var(--text-dim); line-height: 1.6; font-family: var(--font-ui); }
.mission-reward { font-family: var(--font-ui); font-size: 13px; font-weight: 700; color: var(--amber); margin-top: 4px; }
.mission-meta   { font-size: 9px; color: var(--text-dim); margin-top: 2px; letter-spacing: 0.5px; }

/* Cargo / location entry rows */
.location-entry {
  background: rgba(8,42,85,0.02);
  border: 1px solid var(--border-dim); padding: 8px; margin-bottom: 8px;
}
.location-entry-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.location-entry-title {
  font-family: var(--font-ui); font-size: 10px; font-weight: 700;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.8px;
}
.cargo-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.cargo-row input[type="text"]   { flex: 2; margin-bottom: 0; }
.cargo-row input[type="number"] { flex: 1; margin-bottom: 0; }

/* ============================================================
   GA PARAMS
   ============================================================ */
.ga-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 8px;
  margin: 10px 0 8px;
}
.ga-field label { font-size: 9px; margin-bottom: 2px; }
.ga-field input  { font-size: 11px; padding: 5px 8px; margin-bottom: 0; }

.algo-parameter-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.algo-note-chip {
  border: 1px solid rgba(0,168,120, 0.18);
  background: rgba(0,168,120, 0.05);
  color: var(--text-dim);
  padding: 4px 7px;
  font-size: 10px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.algo-inline-graph-card {
  margin: 10px 0 0;
  border: 1px solid rgba(0,168,120, 0.14);
  background: rgba(4, 11, 22, 0.92);
  padding: 10px;
  width: 100%;
  max-width: none;
}

.algo-inline-graph-card-prominent {
  margin-top: 8px;
}

.algo-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.algo-inline-graph-head {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}

.algo-inline-graph-title {
  color: var(--text-hi);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.graph-frame-inline {
  height: 128px;
  min-height: 128px;
  max-height: 128px;
  padding: 0;
  overflow: hidden;
}

#graph-inline-canvas {
  width: 100%;
  height: 128px;
  display: block;
}

.algo-hidden-inputs,
.algo-stats-hidden {
  display: none;
}

.search-launcher-modal {
  width: min(96vw, 960px);
  max-width: min(96vw, 960px);
  height: min(78vh, 540px);
  max-height: min(78vh, 540px);
}

.search-launcher-modal .modal-body {
  padding: 0;
  overflow: hidden;
  min-height: 0;
}

.search-launcher {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(380px, 1.1fr);
}

.search-launcher-column {
  min-height: 0;
  overflow: hidden;
}

.search-launcher-column-controls {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-right: 1px solid var(--border-dim);
  background: transparent;
  min-height: 0;
}

.search-launcher-column-graph {
  padding: 14px;
  display: flex;
  min-height: 0;
  overflow: hidden;
  background: transparent;
}

.search-launcher-card {
  border: 1px solid var(--border-dim);
  background: transparent;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.search-launcher-card-recalculate {
  margin-top: auto;
  flex: 0 0 auto;
}

.search-launcher-card-graph {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.search-launcher-kicker {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.search-launcher-copy {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.45;
  margin: 0;
}

.search-launcher-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 2px;
}

.search-launcher-form .form-group {
  margin-bottom: 0;
}

.search-launcher-form label {
  font-size: 9px;
  letter-spacing: 0.08em;
}

.search-launcher-form input {
  padding: 6px 8px;
  font-size: 12px;
}

.search-launcher-graph-frame {
  min-height: 0;
  height: 100%;
  overflow: hidden;
  align-self: stretch;
  padding: 6px;
  background: var(--surface0);
  border: 1px solid var(--border-dim);
}

.search-launcher-graph-frame canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.algo-hidden-store {
  display: none !important;
}

/* ============================================================
   ROUTE STOP CARDS
   ============================================================ */
.route-stop-card {
  border: 1px solid var(--border-dim);
  background: rgba(8,42,85,0.02);
}
.route-stop-card + .route-stop-card {
  margin-top: 12px;
}
.route-stop-card[open] {
  border-color: rgba(0,168,120,0.22);
  background: rgba(255,255,255,0.025);
}
.route-stop-card summary {
  list-style: none;
}
.route-stop-card summary::-webkit-details-marker {
  display: none;
}
.route-stop-summary-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  cursor: pointer;
}
.route-stop-summary-copy {
  min-width: 0;
}
.route-stop-title {
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-hi);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.route-stop-summary-text {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text);
  line-height: 1.5;
  text-transform: none;
}
.route-stop-index {
  min-width: 58px;
  padding: 5px 8px;
  text-align: center;
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #fff;
  background: var(--accent2);
}
.route-stop-index-start { background: var(--green2); }
.route-stop-index-transit { background: var(--purple); }
.route-stop-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.route-stop-badge {
  padding: 3px 7px;
  border: 1px solid rgba(8,42,85,0.09);
  background: rgba(8,42,85,0.03);
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  white-space: nowrap;
}
.route-stop-badge.pickup {
  border-color: rgba(0,216,130,0.28);
  color: var(--green);
  background: rgba(0,216,130,0.10);
}
.route-stop-badge.dropoff {
  border-color: rgba(255,61,87,0.28);
  color: var(--red);
  background: rgba(255,61,87,0.10);
}
.route-stop-badge.transit {
  border-color: rgba(156,109,255,0.3);
  color: var(--purple);
  background: rgba(156,109,255,0.10);
}
.route-stop-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 14px 14px;
  border-top: 1px solid rgba(8,42,85,0.04);
}
.route-stop-note {
  padding-top: 12px;
  font-size: 11px;
  color: var(--text);
  line-height: 1.55;
}
.route-stop-section {
  padding-top: 12px;
}
.route-stop-section-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 8px;
}
.route-stop-section-title {
  font-size: 9px;
  color: var(--text-dim);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.route-stop-section-meta {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.route-stop-group {
  border: 1px solid rgba(8,42,85,0.07);
  background: rgba(8,42,85,0.02);
  padding: 9px 10px;
}
.route-stop-group + .route-stop-group,
.route-stop-group + .route-stop-line-item {
  margin-top: 7px;
}
.route-stop-group-title {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-hi);
  letter-spacing: 0.5px;
}
.route-stop-line-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text);
}
.route-stop-line-item-fallback {
  padding: 9px 10px;
  border: 1px solid rgba(8,42,85,0.04);
  background: rgba(8,42,85,0.02);
}
.route-stop-line-main {
  color: var(--text);
}
.route-stop-line-meta {
  color: var(--text-dim);
  text-align: right;
}
.route-stop-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(8,42,85,0.04);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.route-stop-card-start {
  border-left: 2px solid var(--green2);
}
.route-stop-card-service {
  border-left: 2px solid var(--accent2);
}
.route-stop-card-transit {
  border-left: 2px solid var(--purple);
  background: rgba(156,109,255,0.05);
}

.route-nav-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.route-nav-progress,
.route-nav-card {
  border: 1px solid rgba(0,168,120,0.14);
  background: rgba(0,168,120,0.04);
  padding: 14px;
}
.route-nav-progress-complete {
  border-color: rgba(0,216,130,0.2);
  background: rgba(0,216,130,0.05);
}
.route-nav-kicker,
.route-nav-card-label,
.route-nav-step-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.route-nav-title,
.route-nav-card-title {
  margin-top: 6px;
  font-family: var(--font-ui);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-hi);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.route-nav-copy,
.route-nav-card-copy,
.route-nav-step-text,
.route-nav-footer-copy,
.route-task-detail {
  margin-top: 5px;
  font-size: 12px;
  color: var(--text);
  line-height: 1.55;
  text-transform: none;
}
.route-nav-progress-bar {
  margin-top: 12px;
  height: 6px;
  background: rgba(8,42,85,0.07);
  overflow: hidden;
}
.route-nav-progress-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}
.route-nav-steps {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.route-nav-step {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid rgba(8,42,85,0.04);
}
.route-nav-step:first-child {
  padding-top: 0;
  border-top: none;
}
.route-nav-step-index {
  min-width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-hi);
  background: rgba(8,42,85,0.09);
}
.route-nav-step-arrival .route-nav-step-index {
  background: rgba(0,216,130,0.18);
  color: var(--green);
}
.route-nav-step-transit .route-nav-step-index {
  background: rgba(156,109,255,0.18);
  color: var(--purple);
}
.route-nav-step-title {
  margin-top: 4px;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-hi);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.route-nav-task-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.route-task-btn {
  width: 100%;
  border: 1px solid rgba(8,42,85,0.09);
  background: rgba(8,42,85,0.03);
  color: var(--text-hi);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 11px 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.route-task-btn:hover {
  transform: translateY(-1px);
}
.route-task-btn-pickup:hover {
  border-color: rgba(0,216,130,0.3);
  background: rgba(0,216,130,0.08);
}
.route-task-btn-dropoff:hover {
  border-color: rgba(255,61,87,0.3);
  background: rgba(255,61,87,0.08);
}
.route-task-btn.is-complete {
  border-color: rgba(0,216,130,0.3);
  background: rgba(0,216,130,0.10);
}
.route-task-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.route-task-title {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-hi);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.route-task-state {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.route-task-btn.is-complete .route-task-state {
  color: var(--green);
}
.route-nav-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(8,42,85,0.07);
  background: rgba(8,42,85,0.02);
}
.route-nav-shell-complete {
  min-height: 180px;
}

.route-full-modal {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.route-full-modal-summary {
  padding: 10px 12px;
  border: 1px solid rgba(0,168,120,0.16);
  background: rgba(0,168,120,0.05);
}
.route-full-modal-kicker {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.route-full-modal-copy {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text);
  line-height: 1.45;
}

/* AI analysis box */
.ai-analysis-box {
  background: rgba(156,109,255,0.06);
  border: 1px solid rgba(156,109,255,0.2);
  padding: 12px 14px;
  display: none;
}
.ai-analysis-box .analysis-title {
  font-family: var(--font-ui); font-size: 10px; font-weight: 700;
  color: var(--purple); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px;
}
.ai-analysis-box .analysis-text { font-size: 11px; color: var(--text); line-height: 1.7; white-space: pre-wrap; }

/* ============================================================
   SCANNER & AI CHAT
   ============================================================ */
.drop-zone {
  border: 1px dashed rgba(8,42,85,0.13); padding: 24px 18px;
  text-align: center; cursor: pointer; transition: all 0.15s;
  background: rgba(8,42,85,0.02);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--purple); background: rgba(156,109,255,0.05);
}
.dz-icon { font-size: 28px; margin-bottom: 7px; }
.dz-text { font-size: 11px; font-weight: 700; color: var(--text-dim); font-family: var(--font-ui); letter-spacing: 0.5px; }
.dz-sub  { font-size: 9px; color: var(--text-dim); margin-top: 3px; opacity: 0.6; letter-spacing: 0.8px; }

.preview-image {
  width: 100%; max-height: 140px; object-fit: contain;
  border: 1px solid var(--border-dim);
  background: #000; display: none; margin-top: 8px;
}

.scanner-log, .ai-log {
  background: rgba(0,0,0,0.4); border: 1px solid var(--border-dim);
  padding: 8px; font-size: 10px; color: var(--text-dim);
  line-height: 1.7; min-height: 60px; max-height: 160px; overflow-y: auto;
  font-family: 'Courier New', monospace; white-space: pre-wrap;
}

.chat-messages {
  background: rgba(0,0,0,0.25); border: 1px solid var(--border-dim);
  padding: 10px; min-height: 80px; max-height: 180px; overflow-y: auto;
  font-size: 11px; line-height: 1.7; flex: 1;
  font-family: var(--font-ui);
}
.chat-msg { margin-bottom: 8px; }
.chat-msg.user .msg-label { color: var(--accent); font-weight: 700; font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; }
.chat-msg.ai   .msg-label { color: var(--purple); font-weight: 700; font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; }
.chat-msg .msg-body { color: var(--text); margin-top: 2px; }
.chat-input-row { display: flex; gap: 5px; margin-top: 6px; }
.chat-input-row input { flex: 1; margin-bottom: 0; }
.ai-key-row { display: flex; gap: 5px; }
.ai-key-row input { flex: 1; margin-bottom: 0; }

/* ============================================================
   ROUTE HISTORY
   ============================================================ */
.history-card {
  background: rgba(8,42,85,0.02); border: 1px solid var(--border-dim);
  padding: 8px 10px; margin-bottom: 7px; transition: border-color 0.15s;
}
.history-card:hover { border-color: rgba(0,168,120,0.2); }
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.history-date { font-size: 9px; color: var(--text-dim); letter-spacing: 0.5px; text-transform: uppercase; font-family: var(--font-ui); }
.history-actions { display: flex; gap: 4px; }
.history-stats { display: flex; gap: 10px; font-size: 11px; color: var(--text); flex-wrap: wrap; font-family: var(--font-ui); }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.8); display: none;
  align-items: center; justify-content: center;
}
.modal-overlay.visible { display: flex; }
.modal {
  background: var(--surface0); border: 1px solid var(--panel-border);
  width: min(94vw, 760px); max-width: min(94vw, 760px); max-height: 84vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.9);
  border-radius: 0;
}
/* Corner brackets removed */
.modal::before, .modal::after { content: none; }
.modal { position: relative; } /* for pseudo-element positioning */

.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--panel-border);
  background: transparent;
}
.modal-header h3 {
  font-family: var(--font-ui); font-size: 14px; font-weight: 700;
  color: var(--text-hi); letter-spacing: 0.4px; text-transform: uppercase;
}
.modal-body { padding: 14px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 10px 14px; border-top: 1px solid var(--panel-border); display: flex; gap: 7px; justify-content: flex-end; }

.mission-workspace-modal {
  width: min(96vw, 1080px);
  max-width: min(96vw, 1080px);
  max-height: 88vh;
}

.mission-workspace-modal .modal-body {
  padding: 0;
  overflow: hidden;
}

.workspace-modal-host {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.workspace-modal-panel {
  display: block !important;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
}

.compare-table { width: 100%; border-collapse: collapse; font-size: 12px; font-family: var(--font-ui); }
.compare-table th, .compare-table td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--border-dim); }
.compare-table th { font-size: 9px; color: var(--text-dim); font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; }
.compare-table td { color: var(--text); }
.highlight-better { color: var(--green) !important; font-weight: 700; }

/* ============================================================
   MISC UTILITIES
   ============================================================ */
.spinner {
  width: 12px; height: 12px;
  border: 2px solid rgba(8,42,85,0.13); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 20px 14px; color: var(--text-dim); font-size: 11px; line-height: 1.6; font-family: var(--font-ui); }
.empty-state .empty-icon { font-size: 20px; margin-bottom: 6px; opacity: 0.5; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1440px) {
  :root { --panel-w: 348px; --route-w: 392px; }
}

@media (max-width: 1100px) {
  :root { --panel-w: 290px; --route-w: 338px; }
  #bottom-mid { flex: 0 0 140px; }
  .sc-bar-shortcuts { display: none; }
}

@media (max-width: 860px) {
  :root { --panel-w: 280px; --route-w: 312px; }
  #bottom-mid { display: none; }
  .sc-bar-ship {
    flex-basis: 240px;
    max-width: 320px;
  }
  .sc-bar-tab span:last-child { display: none; }
  .sc-bar-tab-icon { font-size: 16px; }
  .route-mode-grid { grid-template-columns: 1fr; }
  .entity-tree-layout { grid-template-columns: 1fr; }
  .entity-tree-modal { height: min(86vh, 840px); }
  .route-hero { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  :root { --panel-w: calc(100vw - 20px); --route-w: calc(100vw - 20px); }
  .map-legend { display: none; }
  .sc-map-icons {
    top: 8px;
    max-width: calc(100% - 16px);
  }
  #system-selector {
    right: 8px;
    bottom: 8px;
    max-width: calc(100% - 16px);
  }
  #bottom-bar {
    height: auto;
    flex-wrap: wrap;
  }
  #bottom-bar.route-dock-guided {
    min-height: 0;
  }
  .sc-bar-ship {
    flex-basis: 100%;
    border-right: none;
    border-bottom: 1px solid var(--panel-border);
  }
  .sc-bar-route-summary {
    padding: 10px 12px;
  }
  .sc-bar-route-title {
    font-size: 15px;
  }
  .sc-bar-route-meta {
    right: 12px;
    bottom: 10px;
  }
  .entity-tree-toolbar { flex-direction: column; }
  .entity-tree-toolbar-actions { justify-content: flex-start; }
  .entity-tree-stat-grid { grid-template-columns: 1fr; }
  .route-metrics,
  .route-advanced-grid { grid-template-columns: 1fr; }
  .route-stop-summary-row { grid-template-columns: 1fr; }
  .route-stop-badges { justify-content: flex-start; }
  .route-stop-line-item,
  .route-stop-footer { flex-direction: column; align-items: flex-start; }
  .ship-search-result {
    grid-template-columns: 1fr;
  }
  .ship-search-result-cargo {
    white-space: normal;
  }
  .route-task-btn {
    flex-direction: column;
    align-items: flex-start;
  }
  .route-task-state {
    margin-top: 4px;
  }
  #route-panel.route-panel-guided .route-actions {
    flex-wrap: wrap;
  }
  #route-panel.route-panel-guided .route-tools-menu {
    margin-left: 0;
  }
  .bottom-route-dock {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px 12px;
  }
  .bottom-route-dock.is-guided {
    padding: 10px 12px;
    grid-template-columns: 1fr;
  }
  .bottom-route-dock.is-guided .bottom-route-dock-actions {
    grid-template-columns: 1fr;
  }
  .bottom-route-task,
  .bottom-route-advance {
    min-width: 0;
  }
  .fp-section-toggle {
    grid-template-columns: 1fr auto;
  }
  .fp-section-toggle-summary {
    grid-column: 1 / -1;
    justify-self: start;
    white-space: normal;
  }
}

@media (max-width: 900px) {
  .search-launcher-modal {
    height: min(82vh, 760px);
    max-height: min(82vh, 760px);
  }
  .search-launcher {
    grid-template-columns: 1fr;
  }
  .search-launcher-column-controls {
    border-right: none;
    border-bottom: 1px solid var(--panel-border);
  }
  .search-launcher-form {
    grid-template-columns: 1fr;
  }
  .search-launcher-card-graph {
    min-height: 320px;
  }
}

/* ============================================================
   DARK MODE
   ============================================================ */

/* Smooth theme colour transitions on every element */
*,
*::before,
*::after {
  transition:
    background-color 0.22s var(--ease),
    border-color     0.22s var(--ease),
    color            0.22s var(--ease),
    box-shadow       0.22s var(--ease);
}
/* But keep geometry transitions from the original rules intact */
#left-panel, #route-panel {
  transition:
    background-color 0.22s var(--ease),
    border-color     0.22s var(--ease),
    color            0.22s var(--ease),
    box-shadow       0.22s var(--ease),
    transform        var(--dur) var(--ease-out),
    opacity          var(--dur) var(--ease-out);
}

[data-theme="dark"] {
  /* Backgrounds */
  --bg:        #06090f;
  --surface0:  #0b1120;
  --surface1:  #101828;
  --surface2:  rgba(16,24,40,0.90);
  --surface3:  rgba(14,22,36,0.65);

  /* Borders */
  --border:         rgba(90,145,210,0.13);
  --border-dim:     rgba(90,145,210,0.07);
  --border-active:  rgba(0,184,130,0.60);

  /* Accent */
  --accent:      #00cc98;
  --accent2:     #00a87a;
  --accent-soft: rgba(0,204,152,0.11);

  /* Status */
  --green:      #00c86a;
  --green2:     #009450;
  --amber:      #e09600;
  --amber-soft: rgba(224,150,0,0.13);
  --red:        #ff4848;
  --red-soft:   rgba(255,72,72,0.12);
  --purple:     #9060d8;
  --route-color: #e09600;

  /* Text */
  --text:      #7aa4c0;
  --text-dim:  #3a5c74;
  --text-hi:   #cce4f8;
  --text-mute: #1e3a52;

  /* Panel chrome */
  --panel-bg:     rgba(9,15,28,0.95);
  --panel-border: rgba(90,145,210,0.10);
  --panel-shadow:
    0 1px 0 rgba(255,255,255,0.03) inset,
    0 6px 24px rgba(0,0,0,0.40);
  --glow-accent:
    0 0 0 1px rgba(0,168,120,0.28),
    0 0 20px rgba(0,168,120,0.12);

  /* Surfaces */
  --surface-hi:  rgba(14,24,40,0.70);
  --hairline:    rgba(90,145,210,0.08);
  --hairline-2:  rgba(90,145,210,0.12);
  --hairline-hi: rgba(90,145,210,0.26);
}

/* Map area */
[data-theme="dark"] #map-area {
  background: linear-gradient(160deg, #04060c 0%, #060a12 50%, #04070b 100%);
}
[data-theme="dark"] #map-area::before {
  background-image:
    linear-gradient(rgba(60,110,170,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(60,110,170,0.025) 1px, transparent 1px);
}
[data-theme="dark"] #map-area::after {
  /* Softer dark tint so orbital traces and markers read clearly */
  background: rgba(3,5,12,0.18);
}

/* Panel footer */
[data-theme="dark"] .sc-panel-footer {
  background: rgba(0,0,0,0.50);
}

/* Location list / dropdowns */
[data-theme="dark"] .start-location-list {
  background: rgba(6,10,20,0.96);
}
[data-theme="dark"] .setup-flow-location-list {
  background: rgba(6,10,20,0.99);
  box-shadow: 0 18px 34px rgba(0,0,0,0.80);
}
[data-theme="dark"] .route-tools-popover {
  background: rgba(6,10,20,0.99);
}

/* Logs / chat */
[data-theme="dark"] .scanner-log,
[data-theme="dark"] .ai-log {
  background: rgba(0,0,0,0.60);
}
[data-theme="dark"] .chat-messages {
  background: rgba(0,0,0,0.45);
}

/* Graph / algo cards */
[data-theme="dark"] .graph-frame {
  background: rgba(3,6,16,0.97);
}
[data-theme="dark"] .algo-inline-graph-card {
  background: rgba(4,7,14,0.98);
}
[data-theme="dark"] .search-launcher-graph-frame {
  background: rgba(4,7,14,0.98);
}
[data-theme="dark"] .entity-tree-panel,
[data-theme="dark"] .entity-tree-details {
  background: rgba(6,10,20,0.88);
}

/* Bottom bar */
[data-theme="dark"] #bottom-bar {
  background: var(--surface0);
}

/* Keyboard shortcut chips */
[data-theme="dark"] kbd {
  background: rgba(16,26,44,0.90);
  color: var(--text-hi);
  border-color: rgba(90,145,210,0.20);
}

/* Select option bg */
[data-theme="dark"] select option {
  background: #0b1120;
  color: var(--text-hi);
}

/* Modal */
[data-theme="dark"] .modal {
  background: var(--surface0);
  box-shadow: 0 24px 64px rgba(0,0,0,0.70);
}

/* Preview image */
[data-theme="dark"] .preview-image {
  border-color: var(--border-dim);
}

/* ============================================================
   THEME TOGGLE BUTTON
   ============================================================ */
#theme-toggle {
  position: absolute;
  top: 12px;
  right: 10px;
  z-index: 50;
  width: 34px;
  height: 34px;
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  color: var(--text-dim);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    right      0.22s var(--ease),
    background 0.22s var(--ease),
    border-color 0.22s var(--ease),
    color        var(--dur-fast) var(--ease),
    transform    var(--dur-fast) var(--ease);
}
#theme-toggle:hover {
  border-color: var(--hairline-hi);
  color: var(--amber);
}
#theme-toggle:active { transform: scale(0.90); }

/* Shift left when route panel is open */
#map-area:has(#route-panel.open) #theme-toggle {
  right: calc(var(--route-w) + 18px);
}

/* Sun icon for dark mode, moon for light */
#theme-toggle .icon-sun  { display: none; }
#theme-toggle .icon-moon { display: block; }
[data-theme="dark"] #theme-toggle .icon-sun  { display: block; }
[data-theme="dark"] #theme-toggle .icon-moon { display: none; }

/* ============================================================
   TOAST SYSTEM  (styles — logic in ui.js)
   ============================================================ */
#toast-container {
  position: fixed;
  right: 16px;
  bottom: calc(var(--bar-h) + 14px);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
  max-width: min(380px, calc(100vw - 32px));
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(22px) scale(0.96); }
  to   { opacity: 1; transform: translateX(0)   scale(1); }
}
@keyframes fadeOut {
  from { opacity: 1; transform: translateX(0); max-height: 90px; margin-bottom: 0; }
  to   { opacity: 0; transform: translateX(16px); max-height: 0;  margin-bottom: -8px; }
}

.toast {
  pointer-events: auto;
  width: 100%;
  padding: 11px 14px;
  background: var(--surface0);
  border: 1px solid var(--panel-border);
  border-left: 3px solid var(--accent);
  border-radius: 3px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.28), 0 1px 0 rgba(255,255,255,0.04) inset;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text);
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  animation: toastIn 0.28s var(--ease-out) both;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.toast.success { border-left-color: var(--green); }
.toast.error   { border-left-color: var(--red); }
.toast.warn    { border-left-color: var(--amber); }
.toast.info    { border-left-color: var(--accent); }

.toast-icon {
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 1px;
  line-height: 1;
}
.toast.success .toast-icon { color: var(--green); }
.toast.error   .toast-icon { color: var(--red); }
.toast.warn    .toast-icon { color: var(--amber); }
.toast.info    .toast-icon { color: var(--accent); }

.toast-body { flex: 1; min-width: 0; }
.toast-title {
  font-weight: 700;
  font-size: 11px;
  color: var(--text-hi);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.toast-msg {
  font-size: 11px;
  color: var(--text);
  line-height: 1.5;
}

/* ============================================================
   ENHANCED ANIMATIONS & MICRO-INTERACTIONS
   ============================================================ */

/* Button press feedback */
.btn:active:not(:disabled)         { transform: scale(0.97); }
.sc-map-icon-btn:active            { transform: scale(0.90); }
.sc-route-btn:active:not(:disabled){ transform: scale(0.98); }
.sc-bar-tab:active                 { transform: scale(0.95); }
.sys-btn:active                    { transform: scale(0.95); }

/* Entrance animations */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

/* Pulse / breathe */
@keyframes breathe {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0   var(--accent-soft); }
  60%  { box-shadow: 0 0 0 5px transparent; }
  100% { box-shadow: 0 0 0 0   transparent; }
}
@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Tab panel fade-in */
.tab-panel.active      { animation: fadeIn 0.15s var(--ease-out) both; }

/* Mission & history items */
.mission-item          { animation: fadeSlideUp 0.20s var(--ease-out) both; }
.history-card          { animation: fadeSlideUp 0.20s var(--ease-out) both; }

/* Route stop cards — stagger via nth-child */
.route-stop-card       { animation: fadeSlideUp 0.22s var(--ease-out) both; }
.route-stop-card:nth-child(2) { animation-delay: 0.04s; }
.route-stop-card:nth-child(3) { animation-delay: 0.08s; }
.route-stop-card:nth-child(4) { animation-delay: 0.12s; }
.route-stop-card:nth-child(5) { animation-delay: 0.16s; }
.route-stop-card:nth-child(n+6) { animation-delay: 0.20s; }

/* Modal appear */
.modal-overlay.visible .modal { animation: scaleIn 0.22s var(--ease-out) both; }

/* Active price dot breathes */
.price-dot.live { animation: breathe 2.8s ease-in-out infinite; }

/* Calculate button pulses when ready */
.sc-route-btn:not(:disabled):not(.calculating) {
  animation: pulse-ring 2.6s ease-out infinite;
}

/* Progress bar smooth fill */
.progress-bar-fill { transition: width 0.35s var(--ease-out); }

/* Metric value flash on update */
@keyframes metricFlash {
  0%   { color: var(--accent); opacity: 0.6; }
  100% { color: inherit;       opacity: 1; }
}
.metric-value.updated { animation: metricFlash 0.45s var(--ease-out); }

/* Panel focus-ring enhancement */
input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  box-shadow:
    0 0 0 2px var(--accent-soft),
    0 0 0 1px rgba(0,168,120,0.28);
}

/* Card hover lift */
.mission-item:hover,
.history-card:hover,
.ship-search-result:hover,
.setup-flow-result-card:hover,
.start-location-action:hover {
  transform: translateY(-1px);
  transition:
    border-color 0.15s,
    background   0.15s,
    box-shadow   0.15s,
    transform    0.15s;
}

/* Route mode card selection flash */
.route-mode-card:has(input:checked) {
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

/* ============================================================
   READABILITY IMPROVEMENTS
   ============================================================ */

/* Slightly larger base body text */
html, body { font-size: 13.5px; }

/* Better contrast for fp-hint */
.fp-hint {
  display: block !important;   /* show hints */
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.6;
  margin-top: 6px;
}

/* Tighter metric grid with more breathing room */
.metric-box { padding: 11px 14px; }
.metric-value { font-size: 20px; }
.metric-label { font-size: 9.5px; letter-spacing: 0.7px; }

/* Route hero headline sizing */
.route-headline { font-size: clamp(17px, 1.8vw, 22px); }

/* Better section label contrast */
.fp-label { color: var(--text); font-size: 10.5px; letter-spacing: 0.7px; }

/* Scanner log readability */
.scanner-log, .ai-log {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.8;
}

/* Chat messages */
.chat-messages { font-size: 12px; line-height: 1.75; }
.chat-msg .msg-body { font-size: 12px; }

/* Route stop title */
.route-stop-title { font-size: 17px; }

/* Route section title */
.route-section-title { font-size: 16px; }

/* Empty state */
.empty-state { padding: 28px 16px; }
.empty-state .empty-icon { font-size: 24px; margin-bottom: 8px; }

/* Better legend text (legacy fallback — new toggles styled in ui.css) */
.legend-item { font-size: 10px; gap: 9px; margin-bottom: 4px; }

/* Map tooltip */
#map-tooltip { font-size: 13px; padding: 9px 13px; }

/* Keyboard shortcut chips */
kbd { font-size: 10px; padding: 2px 6px; height: 19px; min-width: 20px; }

/* ============================================================
   MOBILE IMPROVEMENTS
   ============================================================ */

/* Touch-friendly minimum tap targets */
@media (hover: none) and (pointer: coarse) {
  .btn          { min-height: 42px; padding: 10px 14px; }
  .btn-sm       { min-height: 36px; padding: 7px 12px; font-size: 11px; }
  .btn-icon     { min-height: 36px; padding: 7px 10px; }
  .sc-map-icon-btn { width: 40px; height: 40px; font-size: 15px; }
  .sys-btn      { padding: 8px 14px; font-size: 11px; }
  .sc-bar-tab   { height: 42px; padding: 0 12px; }
  .sc-rail-tab  { min-height: 54px; }
  .right-tab-btn { height: 44px; }
  input[type="text"],
  input[type="number"],
  input[type="password"],
  select { padding: 10px 12px; font-size: 14px; }
}

/* Small phones (≤ 480px) */
@media (max-width: 480px) {
  :root {
    --bar-h: 54px;
  }

  .sc-bar-tabs {
    gap: 0;
    padding: 0 4px;
    justify-content: space-around;
  }

  .sc-bar-tab {
    padding: 0 7px;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    height: 54px;
    gap: 3px;
    font-size: 9.5px;
  }

  .sc-bar-tab-icon { font-size: 15px; }

  .sc-bar-ship {
    display: none; /* hide on very small screens, info is in route panel */
  }

  .sc-bar-shortcuts { display: none; }

  #bottom-mid { display: none; }

  /* Full-width panels on small screens */
  :root { --panel-w: calc(100vw - 16px); --route-w: calc(100vw - 16px); }

  #left-panel  { left: 8px; top: 8px; bottom: 70px; }
  #route-panel { right: 8px; top: 8px; bottom: 70px; }

  /* Map icons compact */
  .sc-map-icons { gap: 4px; }
  .sc-map-icon-btn { width: 36px; height: 36px; }

  /* System selector compact */
  #system-selector { right: 8px; bottom: 8px; gap: 3px; }
  .sys-btn { padding: 6px 10px; font-size: 9.5px; }

  /* Toast right-aligned */
  #toast-container { right: 8px; bottom: calc(var(--bar-h) + 10px); }

  /* Legend hidden (too cluttered) */
  .map-legend { display: none; }

  /* Modal as bottom sheet */
  .modal-overlay { align-items: flex-end; }
  .modal {
    width: 100vw;
    max-width: 100vw;
    border-radius: 8px 8px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    max-height: 88vh;
  }
  .modal-overlay.visible .modal {
    animation: slideUpModal 0.28s var(--ease-out) both;
  }
  @keyframes slideUpModal {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
  }
}

/* Very small (≤ 360px) — icon-only bottom bar */
@media (max-width: 360px) {
  .sc-bar-tab span:not(.sc-bar-tab-icon):not(.badge-count) { display: none; }
  .sc-bar-tab { padding: 0 6px; min-width: 38px; }
}

/* Landscape mobile fix */
@media (max-height: 500px) and (orientation: landscape) {
  :root { --bar-h: 42px; }
  .sc-bar-tab { height: 42px; }
  #left-panel, #route-panel {
    top: 6px;
    bottom: calc(var(--bar-h) + 8px);
  }
}

/* ============================================================
   SCROLLBAR POLISH (Firefox + Chromium)
   ============================================================ */
@supports (scrollbar-width: thin) {
  .sc-panel-content,
  #route-details-container,
  .start-location-list,
  .location-search-results,
  .entity-tree-root,
  .setup-flow-main,
  .chat-messages {
    scrollbar-width: thin;
    scrollbar-color: var(--hairline-2) transparent;
  }
}

/* ============================================================
   SKELETON LOADING STATES
   ============================================================ */
@keyframes skeletonShimmer {
  0%   { background-position: -200% center; }
  100% { background-position:  200% center; }
}
.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface2) 25%,
    var(--surface-hi) 50%,
    var(--surface2) 75%
  );
  background-size: 200% 100%;
  animation: skeletonShimmer 1.6s ease-in-out infinite;
  border-radius: 2px;
  min-height: 12px;
}

/* ============================================================
   MISC POLISH
   ============================================================ */

/* Smoother details/summary expand */
details summary { cursor: pointer; user-select: none; }

/* Better disabled state */
.btn:disabled, input:disabled, select:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

/* Route panel open transition helper */
#route-panel.open  { box-shadow: var(--panel-shadow), -4px 0 40px rgba(0,0,0,0.12); }
#left-panel.open   { box-shadow: var(--panel-shadow),  4px 0 40px rgba(0,0,0,0.12); }

/* System selector active button glow */
.sys-btn.active {
  box-shadow: 0 0 0 1px var(--accent), 0 0 12px var(--accent-soft);
}

/* Map icon active glow */
.sc-map-icon-btn.active {
  box-shadow: 0 0 0 1px var(--accent), 0 0 10px var(--accent-soft);
}

/* Rail tab active indicator animation */
.sc-rail-tab.active::before {
  animation: breathe 2.5s ease-in-out infinite;
}

/* AI analysis box */
.ai-analysis-box[style*="block"],
.ai-analysis-box.visible {
  animation: fadeSlideUp 0.2s var(--ease-out) both;
}

/* Progress bar glow pulse during calculation */
#progressFill {
  box-shadow: 0 0 8px var(--accent), 0 0 2px var(--accent);
  animation: shimmer 1.4s linear infinite;
  background: linear-gradient(90deg, var(--accent2), var(--accent), var(--accent2));
  background-size: 200% 100%;
}
