/* ─────────────────────────── DESIGN TOKENS ─────────────────────────── */
:root {
  /* Tell the browser we're a dark-themed UI. This flips the default rendering
     of native form controls (date/time pickers, scrollbars, autofill…) to
     their dark variants so inputs like <input type="date"> stop showing a
     white background and black text. */
  color-scheme: dark;

  /* Surfaces */
  --bg-0: #06080d;
  --bg-1: rgba(14, 18, 28, 0.78);
  --bg-2: rgba(20, 26, 38, 0.92);
  --bg-3: #1a2030;
  --bg-elev: rgba(10, 14, 22, 0.92);
  --backdrop-blur: blur(14px) saturate(140%);

  /* Borders */
  --border-1: rgba(255, 255, 255, 0.08);
  --border-2: rgba(255, 255, 255, 0.14);
  --border-strong: rgba(255, 255, 255, 0.22);

  /* Text */
  --text-0: #eef1f7;
  --text-1: #b9c0d0;
  --text-2: #7c879f;
  --text-3: #525c75;

  /* Brand / accents */
  --accent: #6b8afd;
  --accent-hot: #8ea6ff;
  --accent-dim: rgba(107, 138, 253, 0.18);
  --good: #4ade80;
  --warn: #f5b14a;
  --bad: #f87171;

  /* Spacing */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;

  /* Radius */
  --r-1: 6px;
  --r-2: 10px;
  --r-3: 14px;

  /* Type */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif;
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-md: 13px;
  --fs-lg: 15px;
  --fs-xl: 18px;
  --fs-xxl: 22px;

  /* Shadows */
  --shadow-1: 0 2px 8px rgba(0, 0, 0, 0.45);
  --shadow-2: 0 8px 32px rgba(0, 0, 0, 0.55);
  --shadow-pop: 0 24px 80px rgba(0, 0, 0, 0.7);

  /* Layout sizes */
  --top-bar-h: 48px;
  --bottom-bar-h: 36px;
  --rail-w: 0px;
  --right-panel-w: 320px;
  --drawer-w: 360px;
}

/* ─────────────────────────── BASE ─────────────────────────── */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--text-0);
  font-family: var(--font);
  font-size: var(--fs-md);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

canvas {
  display: block;
}

/* The HTML `hidden` attribute must beat layout rules like `display: flex`. */
[hidden] {
  display: none !important;
}

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

input,
select,
textarea {
  font-family: inherit;
  color: inherit;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hot);
}

a:visited {
  color: var(--accent);
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  color: var(--text-0);
}

h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); letter-spacing: 0.02em; text-transform: uppercase; color: var(--text-1); }
h4 { font-size: var(--fs-sm); color: var(--text-1); }

.muted {
  color: var(--text-2);
  font-size: var(--fs-sm);
  margin: 0 0 var(--s-3) 0;
}

/* ─────────────────────────── TOP BAR ─────────────────────────── */
#top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--top-bar-h);
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: 0 var(--s-4);
  background: var(--bg-1);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border-bottom: 1px solid var(--border-1);
  /* Above the report popup-panel (z-index 50) so help/login dropdowns aren't
     occluded when expanded over an open Deployment report. */
  z-index: 80;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: 0.02em;
  padding-right: var(--s-3);
  border-right: 1px solid var(--border-1);
}

.brand-mark {
  color: var(--accent);
  font-size: 16px;
}

.mode-tabs {
  display: flex;
  gap: var(--s-1);
  flex: 1;
}

.mode-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 6px 14px;
  font-size: var(--fs-md);
  color: var(--text-1);
  border-radius: var(--r-1);
  transition: background 120ms ease, color 120ms ease;
}

.mode-tab:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-0);
}

.mode-tab.active {
  background: var(--accent-dim);
  color: var(--accent-hot);
}

.tab-icon {
  font-size: 14px;
  opacity: 0.9;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

#followX {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 6px 10px;
  border-radius: var(--r-1);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-1);
  color: var(--text-1);
  font-size: var(--fs-sm);
  transition: background 120ms ease, color 120ms ease;
}

#followX:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-0);
}

.x-logo {
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

/* ─────────────────────────── HELP POPUP ─────────────────────────── */
.help-wrapper {
  position: relative;
  display: inline-block;
}

.help-popup {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 320px;
  max-height: calc(100vh - var(--top-bar-h) - var(--s-5));
  overflow-y: auto;
  padding: var(--s-4);
  background: var(--bg-2);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-pop);
  z-index: 60;
  font-size: var(--fs-sm);
  color: var(--text-1);
  animation: popup-in 160ms ease;
}

.help-popup h3 {
  font-size: var(--fs-lg);
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-0);
  margin: 0 0 var(--s-2) 0;
}

.help-popup h4 {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  margin: var(--s-3) 0 var(--s-2) 0;
}

.help-popup p {
  margin: 0 0 var(--s-2) 0;
  color: var(--text-1);
  line-height: 1.5;
}

.help-popup ul {
  margin: 0;
  padding-left: var(--s-4);
  color: var(--text-1);
  line-height: 1.55;
}

.help-popup li {
  margin-bottom: var(--s-1);
}

.help-popup strong {
  color: var(--text-0);
  font-weight: 600;
}

.help-popup .help-credit {
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid var(--border-1);
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.kbd-list {
  list-style: none;
  padding-left: 0;
}

.kbd-list li {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: var(--fs-xs);
  color: var(--text-0);
  background: var(--bg-elev);
  border: 1px solid var(--border-2);
  border-bottom-width: 2px;
  border-radius: 4px;
}

/* Left rail removed — navigation is in the top bar */

.rail-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--r-1);
  color: var(--text-2);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, color 120ms ease;
}

.rail-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-0);
}

.rail-btn.active {
  background: var(--accent-dim);
  color: var(--accent-hot);
}

/* ─────────────────────────── MODE DRAWER ─────────────────────────── */
#mode-drawer {
  position: fixed;
  top: var(--top-bar-h);
  bottom: var(--bottom-bar-h);
  left: var(--rail-w);
  width: var(--drawer-w);
  background: var(--bg-2);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border-right: 1px solid var(--border-1);
  box-shadow: var(--shadow-2);
  z-index: 22;
  display: flex;
  flex-direction: column;
  animation: drawer-slide-in 180ms ease;
}

@keyframes drawer-slide-in {
  from { transform: translateX(-12px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

.drawer-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border-1);
  flex-shrink: 0;
}

.drawer-header h2 {
  font-size: var(--fs-lg);
  font-weight: 600;
}

.drawer-toolbar {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border-1);
  flex-shrink: 0;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-3) var(--s-4) var(--s-5) var(--s-4);
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}

.drawer-body::-webkit-scrollbar { width: 8px; }
.drawer-body::-webkit-scrollbar-track { background: transparent; }
.drawer-body::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }

/* ─────────────────────────── ICON BUTTON ─────────────────────────── */
.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--r-1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-1);
  font-size: 16px;
  line-height: 1;
  background: transparent;
  border: 1px solid transparent;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-0);
  border-color: var(--border-2);
}

/* ─────────────────────────── SEARCH BOX ─────────────────────────── */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-3);
  font-size: 14px;
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 7px 10px 7px 30px;
  background: var(--bg-elev);
  border: 1px solid var(--border-1);
  border-radius: var(--r-1);
  color: var(--text-0);
  font-size: var(--fs-sm);
  outline: none;
  transition: border-color 120ms ease;
}

.search-box input:focus {
  border-color: var(--accent);
}

.search-box input::placeholder {
  color: var(--text-3);
}

/* ─────────────────────────── PRESETS ─────────────────────────── */
.presets {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.presets select {
  flex: 1;
  padding: 6px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border-1);
  border-radius: var(--r-1);
  color: var(--text-0);
  font-size: var(--fs-sm);
  outline: none;
}

.presets select:focus {
  border-color: var(--accent);
}

/* ─────────────────────────── SLIDER GROUPS ─────────────────────────── */
.slider-section-header {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 8px 10px;
  margin: var(--s-3) 0 var(--s-2) 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-1);
  border-radius: var(--r-1);
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-1);
  font-weight: 600;
  transition: background 120ms ease, border-color 120ms ease;
}

.slider-section-header:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--border-2);
}

.slider-section-header::before {
  content: "▸";
  display: inline-block;
  width: 10px;
  font-size: 10px;
  color: var(--text-2);
  transition: transform 120ms ease;
}

.slider-section-header.expanded::before {
  transform: rotate(90deg);
}

.slider-section-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 220ms ease;
  padding-left: 4px;
  border-left: 2px solid var(--border-1);
  margin-left: 6px;
}

.slider-section-content.active {
  max-height: 4000px;
  padding-top: var(--s-2);
  padding-bottom: var(--s-2);
}

/* ─────────────────────────── SLIDER ROW ─────────────────────────── */
.slider-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--s-2) 6px var(--s-3) 6px;
  border-radius: var(--r-1);
}

.slider-container:hover {
  background: rgba(255, 255, 255, 0.025);
}

.slider-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}

.slider-label {
  font-size: var(--fs-sm);
  color: var(--text-1);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slider-value-input {
  width: 80px;
  padding: 3px 6px;
  background: var(--bg-elev);
  border: 1px solid var(--border-1);
  border-radius: var(--r-1);
  color: var(--text-0);
  font-size: var(--fs-sm);
  text-align: right;
  outline: none;
  font-variant-numeric: tabular-nums;
  transition: border-color 120ms ease;
}

.slider-value-input:focus {
  border-color: var(--accent);
}

.slider-value-input:disabled {
  opacity: 0.6;
}

.slider-unit {
  font-size: var(--fs-xs);
  color: var(--text-3);
  min-width: 24px;
}

/* range input */
input[type="range"].slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border-2);
  border-radius: 2px;
  outline: none;
  margin: 4px 0 0 0;
}

input[type="range"].slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent);
  cursor: pointer;
  border-radius: 50%;
  border: 2px solid var(--bg-0);
  box-shadow: 0 0 0 1px var(--accent);
  transition: transform 120ms ease, background 120ms ease;
}

input[type="range"].slider::-webkit-slider-thumb:hover {
  background: var(--accent-hot);
  transform: scale(1.15);
}

input[type="range"].slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-0);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--accent);
}

input[type="range"].slider::-moz-range-track {
  background: var(--border-2);
  height: 4px;
  border-radius: 2px;
}

/* select / dropdown sliders */
select.slider {
  width: 100%;
  padding: 5px 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border-1);
  border-radius: var(--r-1);
  color: var(--text-0);
  font-size: var(--fs-sm);
  outline: none;
}

/* radio groups */
.radio-container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
  padding: 4px 0;
}

.radio-container input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background-color: var(--bg-elev);
  cursor: pointer;
  outline: none;
  margin: 0 4px 0 0;
  transition: border-color 120ms ease, background 120ms ease;
}

.radio-container input[type="radio"]:hover {
  border-color: var(--accent);
}

.radio-container input[type="radio"]:checked {
  background-color: var(--accent);
  border-color: var(--accent-hot);
  box-shadow: inset 0 0 0 2px var(--bg-0);
}

.radio-container label {
  color: var(--text-1);
  font-size: var(--fs-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

/* hidden via search filter */
.slider-container.filtered-out,
.slider-section.filtered-out {
  display: none;
}

/* ─────────────────────────── BUTTONS ─────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 8px 14px;
  font-size: var(--fs-md);
  font-weight: 500;
  border-radius: var(--r-1);
  border: 1px solid var(--border-2);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-0);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-strong);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hot);
  border-color: var(--accent-hot);
}

.btn-block {
  width: 100%;
}

/* ─────────────────────────── FORM (Run drawer) ─────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  margin-bottom: var(--s-3);
}

.form-group label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group select,
.drawer-body input[type="text"],
.drawer-body input[type="number"],
.drawer-body input[type="date"],
.drawer-body select {
  padding: 7px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border-1);
  border-radius: var(--r-1);
  color: var(--text-0);
  font-size: var(--fs-sm);
  outline: none;
  transition: border-color 120ms ease;
  color-scheme: dark;
}

.form-group input[type="text"]:focus,
.form-group input[type="number"]:focus,
.form-group input[type="date"]:focus,
.form-group select:focus,
.drawer-body input[type="text"]:focus,
.drawer-body input[type="number"]:focus,
.drawer-body input[type="date"]:focus,
.drawer-body select:focus {
  border-color: var(--accent);
}

.form-hint {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* progress */
#long-term-results {
  margin-top: var(--s-4);
  padding-top: var(--s-3);
  border-top: 1px solid var(--border-1);
}

#long-term-summary-run h3 {
  margin-bottom: var(--s-2);
}

#progress-container-run {
  width: 100%;
  height: 6px;
  background: var(--border-1);
  border-radius: 3px;
  overflow: hidden;
}

#progress-bar-run,
.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hot));
  transition: width 200ms ease;
}

#progress-text-run {
  margin: var(--s-2) 0 0 0;
  font-size: var(--fs-xs);
  color: var(--text-2);
}

#long-term-summary-run-text {
  font-size: var(--fs-xs);
  color: var(--text-2);
  white-space: pre-wrap;
  margin: var(--s-2) 0 0 0;
}

/* ─────────────────────────── RIGHT METRICS PANEL ─────────────────────────── */
#right-panel {
  position: fixed;
  top: var(--top-bar-h);
  right: 0;
  bottom: var(--bottom-bar-h);
  width: var(--right-panel-w);
  background: var(--bg-1);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border-left: 1px solid var(--border-1);
  z-index: 20;
  display: flex;
  flex-direction: column;
  transition: transform 220ms ease;
}

#right-panel.collapsed {
  transform: translateX(100%);
}

#right-panel-toggle {
  position: absolute;
  left: -24px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 56px;
  padding: 0;
  border-radius: var(--r-1) 0 0 var(--r-1);
  border: 1px solid var(--border-1);
  border-right: none;
  background: var(--bg-1);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  color: var(--text-2);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.25);
  z-index: 1;
}

#right-panel-toggle:hover {
  color: var(--text-0);
  background: var(--bg-2);
}

#right-panel-toggle .chev {
  display: inline-block;
  transition: transform 220ms ease;
  line-height: 1;
}

/* When expanded, chevron points right (collapse toward right). */
#right-panel-toggle .chev {
  transform: rotate(0deg);
}

/* When panel is collapsed, chevron points left (to expand back). */
#right-panel.collapsed #right-panel-toggle .chev {
  transform: rotate(180deg);
}

.right-panel-header {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border-1);
  flex-shrink: 0;
}

.right-panel-tabs {
  display: flex;
  gap: var(--s-1);
}

.right-panel-tab {
  font-size: var(--fs-xs);
  padding: 3px 8px;
  border: 1px solid var(--border-1);
  border-radius: var(--r-1);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: all 120ms ease;
}

.right-panel-tab:hover {
  color: var(--text-1);
  border-color: var(--text-3);
}

.right-panel-tab.active {
  color: var(--text-0);
  background: var(--bg-2);
  border-color: var(--text-2);
}

#info-area,
#perf-area {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-3) var(--s-4);
  font-size: var(--fs-sm);
  color: var(--text-1);
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}

#info-area::-webkit-scrollbar, #perf-area::-webkit-scrollbar { width: 8px; }
#info-area::-webkit-scrollbar-track, #perf-area::-webkit-scrollbar-track { background: transparent; }
#info-area::-webkit-scrollbar-thumb, #perf-area::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }

#info-area-costs,
#perf-area-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#info-area-data {
  margin-bottom: var(--s-2);
}

#info-area h3,
#info-area h4 {
  margin: 0 0 var(--s-2) 0;
}

/* Metric cards */
.metric-card {
  background: var(--bg-3);
  border-radius: 6px;
  padding: 8px 10px;
}

.metric-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2);
}

.metric-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  font-weight: 600;
}

.metric-value {
  font-size: var(--fs-lg);
  color: var(--text-0);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.metric-value-sm {
  font-size: var(--fs-md);
  color: var(--text-0);
  font-variant-numeric: tabular-nums;
}

.metric-sub {
  font-size: var(--fs-xs);
  color: var(--text-2);
  margin-top: 2px;
}

.metric-toggle {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-top: 4px;
  user-select: none;
}

.metric-toggle:hover {
  color: var(--text-2);
}

.metric-toggle .arrow {
  font-size: 9px;
  transition: transform 0.15s;
}

.metric-details {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-1);
  font-size: var(--fs-xs);
  color: var(--text-2);
  line-height: 1.6;
}

.metric-card .detail-row,
.metric-details .detail-row {
  display: flex;
  justify-content: space-between;
  gap: var(--s-2);
}

.metric-card .detail-label,
.metric-details .detail-label {
  color: var(--text-3);
}

.metric-card .detail-value,
.metric-details .detail-value {
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.capacity-diagram {
  font-family: monospace;
  font-size: 10px;
  line-height: 1.5;
  white-space: pre;
  margin: 0;
  color: var(--text-1);
}

.metric-badge {
  display: inline-block;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.03em;
  vertical-align: middle;
  margin-left: 6px;
}

.metric-na {
  font-size: var(--fs-sm);
  color: var(--text-3);
  font-style: italic;
}

.chart-wrap {
  width: 100%;
  height: 150px;
  margin-top: 6px;
}

.main-data {
  color: var(--text-0);
}

.detail-data {
  color: var(--text-2);
}

/* ─────────────────────────── BOTTOM BAR ─────────────────────────── */
#bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-bar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: 0 var(--s-4);
  background: var(--bg-1);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border-top: 1px solid var(--border-1);
  font-size: var(--fs-xs);
  color: var(--text-2);
  z-index: 30;
}

.bottom-bar-left {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.sim-time-display {
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
  font-size: var(--fs-sm);
}

.fps-counter {
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  padding: 2px 6px;
  border: 1px solid var(--border-1);
  border-radius: var(--r-1);
  background: rgba(255, 255, 255, 0.02);
}

.worker-status {
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: var(--fs-xs);
  color: var(--text-3);
  padding: 2px 6px;
  border: 1px solid var(--border-1);
  border-radius: var(--r-1);
  background: rgba(255, 255, 255, 0.02);
  letter-spacing: 2px;
  cursor: default;
}

.disclaimer {
  text-align: right;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

/* Bottom-bar inline keyboard-shortcut toggle (L / M). Looks like text by default,
   illuminates when the matching link-label mode is active. */
.kbd-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  font: inherit;
  font-size: var(--fs-xs);
  color: var(--text-3);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-1);
  cursor: pointer;
  transition: color 120ms ease, background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.kbd-toggle:hover {
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-1);
}

.kbd-toggle.active {
  color: var(--accent-hot);
  background: var(--accent-dim);
  border-color: rgba(107, 138, 253, 0.45);
  box-shadow: 0 0 0 1px rgba(107, 138, 253, 0.25), 0 0 12px rgba(107, 138, 253, 0.35);
}

.kbd-toggle.active kbd {
  color: var(--accent-hot);
  border-color: rgba(107, 138, 253, 0.6);
}

/* ─────────────────────────── REPORT POPUP PANEL ─────────────────────────── */
.popup-panel {
  position: fixed;
  top: calc(var(--top-bar-h) + var(--s-4));
  bottom: calc(var(--bottom-bar-h) + var(--s-4));
  left: calc(var(--rail-w) + var(--s-4));
  right: calc(var(--right-panel-w) + var(--s-4));
  background: var(--bg-2);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border: 1px solid var(--border-2);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-pop);
  z-index: 50;
  display: flex;
  flex-direction: column;
  animation: popup-in 200ms ease;
  max-width: 1280px;
  margin: 0 auto;
  /* Match the right-panel collapse transition so the report reflows in sync. */
  transition: right 220ms ease;
}

/* When the right metrics panel is collapsed, reclaim its width for the
   report popup. #right-panel and #report-panel are sibling children of
   <body>, with #right-panel appearing first, so the general-sibling
   combinator works here. */
#right-panel.collapsed ~ #report-panel.popup-panel {
  right: var(--s-4);
}

@keyframes popup-in {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border-1);
  flex-shrink: 0;
}

.panel-header h2 {
  font-size: var(--fs-lg);
}

.panel-actions {
  display: flex;
  gap: var(--s-1);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-5);
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}

.panel-body::-webkit-scrollbar { width: 10px; }
.panel-body::-webkit-scrollbar-track { background: transparent; }
.panel-body::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 5px; }

.empty-state {
  color: var(--text-2);
  text-align: center;
  padding: var(--s-6);
}

/* ─────────────────────────── REPORT CONTENT (formerly deploymentreport.css) ─────────────────────────── */
.report h1 {
  font-size: var(--fs-xxl);
  margin-bottom: var(--s-4);
}

.report h2 {
  font-size: var(--fs-xl);
  margin-top: var(--s-5);
  margin-bottom: var(--s-3);
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--border-1);
}

.report > *:first-child,
.totals-section > *:first-child,
.orbit-section > *:first-child {
  margin-top: 0;
}

.report h3 {
  font-size: var(--fs-md);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-1);
  margin-top: var(--s-4);
  margin-bottom: var(--s-2);
}

.report h4 {
  font-size: var(--fs-sm);
  color: var(--text-2);
  margin-top: var(--s-3);
  margin-bottom: var(--s-2);
}

.totals-section,
.orbit-section {
  margin: var(--s-3) 0;
  padding: var(--s-4);
  background: var(--bg-3);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
}

details.orbit-section {
  padding: 0;
  overflow: hidden;
}

details.orbit-section > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  list-style: none;
  cursor: pointer;
  padding: var(--s-3) var(--s-4);
  user-select: none;
  transition: background 120ms ease;
}

details.orbit-section > summary::-webkit-details-marker {
  display: none;
}

details.orbit-section > summary::before {
  content: "▸";
  display: inline-block;
  width: 12px;
  font-size: 12px;
  color: var(--text-2);
  transition: transform 150ms ease;
  flex-shrink: 0;
}

details.orbit-section[open] > summary::before {
  transform: rotate(90deg);
}

details.orbit-section > summary:hover {
  background: rgba(255, 255, 255, 0.04);
}

details.orbit-section > summary > h2 {
  margin: 0;
  padding: 0;
  border: none;
  flex: 1;
  font-size: var(--fs-lg);
}

.orbit-summary-meta {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

details.orbit-section[open] > summary {
  border-bottom: 1px solid var(--border-1);
}

details.orbit-section > *:not(summary) {
  margin-left: var(--s-4);
  margin-right: var(--s-4);
}

details.orbit-section > *:not(summary):first-of-type {
  margin-top: var(--s-3);
}

details.orbit-section > *:not(summary):last-child {
  margin-bottom: var(--s-4);
}

.table-caption {
  font-size: var(--fs-xs);
  color: var(--text-2);
  margin: var(--s-2) 0;
  font-style: italic;
}

.orbit-chart {
  margin: var(--s-3) 0;
  padding: var(--s-3);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-1);
  border-radius: var(--r-1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
}

.orbit-charts-row {
  display: flex;
  gap: var(--s-3);
  flex-wrap: wrap;
}

.orbit-chart-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-1);
}

.orbit-chart-title {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  font-weight: 600;
}

.orbit-chart-svg,
.orbit-chart-lambert,
.orbit-chart-refined {
  width: 320px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lambert-debug {
  width: 100%;
  margin-top: 6px;
  font-size: var(--fs-sm);
  color: var(--text-2);
}

.lambert-debug > summary {
  cursor: pointer;
  padding: 4px 6px;
  background: rgba(136, 221, 255, 0.08);
  border: 1px solid rgba(136, 221, 255, 0.25);
  border-radius: var(--r-1);
  color: #88ddff;
  user-select: none;
  list-style: none;
}

.lambert-debug > summary:hover {
  background: rgba(136, 221, 255, 0.15);
}

.lambert-debug[open] > summary {
  margin-bottom: 4px;
}

.lambert-debug-section-label {
  margin-top: 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
}

.lambert-debug-json {
  max-height: 200px;
  overflow: auto;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: var(--r-1);
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: 10px;
  line-height: 1.35;
  color: #cfd8e3;
  white-space: pre;
  word-break: normal;
}

.lambert-debug-error {
  padding: 4px 6px;
  margin-bottom: 4px;
  background: rgba(255, 107, 107, 0.1);
  border-left: 2px solid #ff6b6b;
  color: #ff9a9a;
  font-size: 11px;
}

/* Hohmann variant: recolor the summary + banner in orange to match the
   Hohmann transfer arc (#ffa94d) so the debug blocks are visually
   distinguishable at a glance. */
.lambert-debug.lambert-debug-hohmann > summary {
  background: rgba(255, 169, 77, 0.08);
  border-color: rgba(255, 169, 77, 0.25);
  color: #ffa94d;
}
.lambert-debug.lambert-debug-hohmann > summary:hover {
  background: rgba(255, 169, 77, 0.15);
}

/* Refined Hohmann variant: green accent (matches the #8fe39b ΔV labels in
   the middle chart). */
.lambert-debug.lambert-debug-hohmann-refined > summary {
  background: rgba(143, 227, 155, 0.08);
  border-color: rgba(143, 227, 155, 0.3);
  color: #8fe39b;
}
.lambert-debug.lambert-debug-hohmann-refined > summary:hover {
  background: rgba(143, 227, 155, 0.15);
}

.orbit-debug-banner {
  margin-bottom: 6px;
  padding: 4px 6px;
  border-radius: var(--r-1);
  font-size: 10px;
  line-height: 1.4;
}
.orbit-debug-banner code {
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Consolas, monospace;
  padding: 0 3px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.35);
}
.orbit-debug-banner-api {
  background: rgba(136, 221, 255, 0.08);
  border-left: 2px solid #88ddff;
  color: #a8e4ff;
}
.orbit-debug-banner-local {
  background: rgba(255, 169, 77, 0.08);
  border-left: 2px solid #ffa94d;
  color: #ffc98a;
}
.orbit-debug-banner-refined {
  background: rgba(143, 227, 155, 0.08);
  border-left: 2px solid #8fe39b;
  color: #b6ebbf;
}

.orbit-chart-svg svg,
.orbit-chart-lambert svg,
.orbit-chart-refined svg {
  display: block;
  background: rgba(0, 0, 0, 0.45);
  border-radius: var(--r-1);
}

.lambert-placeholder {
  width: 320px;
  height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--r-1);
  color: var(--text-3);
  font-size: var(--fs-sm);
  font-style: italic;
}

.orbit-chart-legend {
  font-size: 10px;
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Consolas, monospace;
}

.orbit-chart-note {
  font-size: 11px;
  fill: var(--text-2);
}

.orbit-chart-controls {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  align-items: stretch;
  font-size: var(--fs-xs);
  color: var(--text-2);
}

.orbit-chart-controls input.flight-slider {
  width: 100%;
}

.orbit-chart-slider-label {
  color: var(--text-1);
  font-weight: 600;
}

.flight-meta {
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}

/* ── Per-flight schedule list ── */
.flight-schedule-list {
  margin: var(--s-3) 0;
}

.flight-header-row,
.flight-summary-row {
  display: flex;
  gap: var(--s-2);
  align-items: center;
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  padding: 4px var(--s-2);
}

.flight-header-row {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-1);
  background: rgba(107, 138, 253, 0.12);
  border-radius: var(--r-1) var(--r-1) 0 0;
}

details.flight-row {
  border-bottom: 1px solid var(--border-1);
}

details.flight-row > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  transition: background 80ms ease;
}

details.flight-row > summary::-webkit-details-marker {
  display: none;
}

details.flight-row > summary:hover {
  background: rgba(255, 255, 255, 0.04);
}

details.flight-row[open] > summary {
  background: rgba(255, 255, 255, 0.03);
}

.flight-tree {
  margin: var(--s-2) var(--s-3) var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-left: 2px solid var(--border-1);
}

/* Column widths for the flight grid */
.fh-num    { flex: 0 0 28px; text-align: right; }
.fh-launch { flex: 0 0 60px; text-align: right; }
.fh-date   { flex: 0 0 82px; }
.fh-small  { flex: 0 0 36px; text-align: right; }
.fh-dv     { flex: 0 0 50px; text-align: right; }
.fh-pct    { flex: 0 0 46px; text-align: right; }

.report table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--s-3) 0;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--r-1);
  overflow: hidden;
  font-size: var(--fs-sm);
}

.report th,
.report td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-1);
}

.report th {
  background: rgba(107, 138, 253, 0.12);
  color: var(--text-0);
  font-weight: 600;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.report tr:last-child td {
  border-bottom: none;
}

.report .non-maneuver-note td:nth-child(2) {
  background-color: rgba(255, 255, 255, 0.04);
  text-align: center;
  font-style: italic;
  color: var(--text-2);
}

.report .console {
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: var(--fs-xs);
  color: var(--text-2);
  background: rgba(0, 0, 0, 0.35);
  padding: var(--s-3);
  border-radius: var(--r-1);
  margin-top: var(--s-3);
  overflow-x: auto;
}

.report .hardware-icon {
  width: 12px;
  height: auto;
  vertical-align: middle;
  margin-right: 4px;
}

.report .starship-svg {
  text-align: center;
  padding: var(--s-3) 0;
}

.report .assumptions {
  margin-top: var(--s-4);
}

/* ─────────────── Login (top bar) ─────────────── */
.auth-btn {
  height: 28px;
  padding: 0 var(--s-3);
  background: var(--bg-2);
  color: var(--text-1);
  border: 1px solid var(--border-2);
  border-radius: var(--r-1);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.auth-btn:hover {
  background: var(--bg-3, var(--bg-2));
  color: var(--text-0);
  border-color: var(--border-3, var(--border-2));
}

.auth-popup {
  width: 280px;
}
.auth-form {
  display: flex;
  gap: var(--s-2);
  margin-top: var(--s-2);
}
.auth-form input[type="password"] {
  flex: 1;
  height: 30px;
  padding: 0 var(--s-2);
  background: var(--bg-1);
  color: var(--text-0);
  border: 1px solid var(--border-2);
  border-radius: var(--r-1);
  font-size: var(--fs-sm);
}
.auth-form input[type="password"]:focus {
  outline: none;
  border-color: var(--accent, #4a9eff);
}
.auth-form .btn {
  height: 30px;
  padding: 0 var(--s-3);
}
.auth-status {
  min-height: 1.2em;
  margin-top: var(--s-2);
  font-size: var(--fs-xs);
}

.lambert-placeholder-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
}
.lambert-placeholder-auth .btn {
  height: 26px;
  padding: 0 var(--s-3);
  font-size: var(--fs-xs);
}
