/* ============================================================
   AntWings — Minimal Data-Focused Stylesheet
   Font: IBM Plex Sans + IBM Plex Mono
   ============================================================ */

:root {
  --bg: #f9f9f8;
  --surface: #ffffff;
  --border: #e4e4e0;
  --border-subtle: #efefec;
  --text: #1a1a18;
  --text-secondary: #6b6b65;
  --text-muted: #9b9b94;
  --accent: #1a6b3c;
  --accent-light: #e8f5ee;
  --accent-mid: #2d9e5f;
  --warn: #c45c1a;
  --warn-light: #fef3ea;
  --danger: #b91c1c;
  --sidebar-bg: #111110;
  --sidebar-text: #c8c8c0;
  --sidebar-active: #ffffff;
  --sidebar-accent: #2d9e5f;
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'IBM Plex Sans', sans-serif;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
}

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

html, body {
  height: 100%;
  font-family: var(--sans);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── App Shell ── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  padding: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.logo-svg {
  width: 34px;
  height: 40px;
  flex-shrink: 0;
  color: var(--sidebar-active);
}

.logo-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--sidebar-active);
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---- Terms of Use Page ---- */
.terms-page {
  max-width: 680px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.terms-block {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 22px;
}

.terms-block-icon {
  font-size: 22px;
  flex-shrink: 0;
  margin-top: 2px;
}

.terms-block-body h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 6px 0;
}

.terms-block-body p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
  margin: 0;
}

.terms-effective {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.nav-item-terms {
  margin-top: auto;
  opacity: 0.7;
}

.beta-badge {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #1e293b;
  background: linear-gradient(135deg, #93c5fd, #60a5fa);
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
  vertical-align: middle;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 400;
  transition: color 0.15s, background 0.15s;
  cursor: pointer;
}

.nav-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.6;
}

.nav-item:hover {
  color: var(--sidebar-active);
  background: rgba(255,255,255,0.04);
}

.nav-item.active {
  color: var(--sidebar-active);
  background: rgba(45,158,95,0.1);
  border-left: 2px solid var(--sidebar-accent);
  padding-left: 16px;
}

.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.btn-calculate {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--sidebar-accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--sans);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-calculate svg { width: 14px; height: 14px; }
.btn-calculate:hover { background: #25845a; }

/* ── Main Content ── */
.main-content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
}

/* ── Panels ── */
.panel {
  display: none;
  padding: 32px 36px 48px;
  max-width: 1200px;
}

.panel.active { display: block; }

.panel-header {
  margin-bottom: 28px;
}

.panel-header h1 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.panel-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ── Summary Tiles ── */
.summary-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

#taxSummary { grid-template-columns: repeat(5, 1fr); }

.summary-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.tile-value {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.02em;
}

.tile-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 4px;
}

.tile-warn { border-color: var(--warn); background: var(--warn-light); }
.tile-warn .tile-value { color: var(--warn); }

.tile-success { border-color: var(--accent); background: var(--accent-light); }
.tile-success .tile-value { color: var(--accent); }

/* ── Input Grid ── */
.input-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.input-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 12px;
}

.field-row label {
  font-size: 13px;
  color: var(--text-secondary);
  flex: 1;
  min-width: 0;
}

.field-row input,
.field-row select {
  width: 120px;
  flex-shrink: 0;
  font-size: 13px;
  font-family: var(--mono);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
  outline: none;
  transition: border-color 0.15s;
}

.field-row input:focus,
.field-row select:focus { border-color: var(--accent-mid); }

.input-prefix-wrap,
.input-suffix-wrap {
  display: flex;
  align-items: center;
  width: 120px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  overflow: hidden;
  transition: border-color 0.15s;
}

.input-prefix-wrap:focus-within,
.input-suffix-wrap:focus-within { border-color: var(--accent-mid); }

.input-prefix-wrap span,
.input-suffix-wrap span {
  font-size: 12px;
  color: var(--text-muted);
  padding: 5px 7px;
  background: var(--border-subtle);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  user-select: none;
}

.input-suffix-wrap span {
  border-right: none;
  border-left: 1px solid var(--border);
}

.input-prefix-wrap input,
.input-suffix-wrap input {
  width: 100%;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 5px 8px;
}

/* ── Cards & Layouts ── */
.col-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}

.col-card h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.card-note {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  line-height: 1.6;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Charts ── */
.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  height: 300px;
}

.chart-wrap canvas {
  max-height: 100%;
}

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table th {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table th:first-child { text-align: left; }

.data-table td {
  padding: 7px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
}

.data-table td:first-child {
  text-align: left;
  font-family: var(--sans);
  color: var(--text-secondary);
}

.data-table tbody tr:hover { background: var(--bg); }
.data-table .highlight-row { background: var(--accent-light); }
.data-table .warn-row { background: var(--warn-light); }

/* ── Sticky columns: Projection table ── */
#projectionTable {
  min-width: 700px; /* triggers horizontal scroll on small screens */
}

/* Col 1: Year */
#projectionTable th:nth-child(1),
#projectionTable td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
}

/* Col 2: Age — right edge marks the sticky boundary */
#projectionTable th:nth-child(2),
#projectionTable td:nth-child(2) {
  position: sticky;
  left: 48px;
  z-index: 2;
  background: var(--surface);
  border-right: 2px solid var(--border);
}

/* Keep sticky cells opaque on hover and phase rows */
#projectionTable tbody tr:hover td:nth-child(1),
#projectionTable tbody tr:hover td:nth-child(2) { background: var(--bg); }

#projectionTable .highlight-row td:nth-child(1),
#projectionTable .highlight-row td:nth-child(2) { background: var(--accent-light); }

#projectionTable .warn-row td:nth-child(1),
#projectionTable .warn-row td:nth-child(2) { background: var(--warn-light); }

/* ── Monte Carlo ── */
.mc-progress-wrap {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.mc-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}

.mc-progress-fill {
  height: 100%;
  background: var(--accent-mid);
  width: 0%;
  transition: width 0.1s;
}

.mc-progress-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--mono);
}

/* ── Profile Bar ── */
.profile-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.profile-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-bar-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  white-space: nowrap;
}

.profile-name-input {
  width: 180px;
  font-size: 13px;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
  outline: none;
  transition: border-color 0.15s;
}

.profile-name-input:focus { border-color: var(--accent-mid); }
.profile-name-input::placeholder { color: var(--text-muted); }

.profile-select {
  width: 200px;
  font-size: 13px;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}

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

.btn-profile {
  font-size: 12px;
  font-family: var(--sans);
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-profile-save {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
}

.btn-profile-save:hover { background: var(--accent-mid); border-color: var(--accent-mid); }

.btn-profile-load {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-profile-load:hover { border-color: var(--accent-mid); color: var(--accent); }

.btn-profile-delete {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-profile-delete:hover { border-color: var(--danger); color: var(--danger); }

/* ── SS Benefit Table ── */
.ss-benefit-section {
  margin-bottom: 4px;
}

.ss-section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.ss-section-title {
  font-size: 13px;
  color: var(--text-secondary);
}

.ss-section-hint {
  font-size: 10px;
  color: var(--text-muted);
}

.ss-table-rows {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 8px;
}

.ss-table-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 7px;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  cursor: pointer;
}

.ss-table-row:hover { background: var(--bg); }

.ss-row-selected {
  background: var(--accent-light);
  border-color: rgba(26,107,60,0.25);
}

.ss-radio { cursor: pointer; accent-color: var(--accent); flex-shrink: 0; }

.ss-age-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  width: 42px;
  flex-shrink: 0;
  cursor: pointer;
}

.ss-row-selected .ss-age-label { color: var(--accent); font-weight: 600; }

.ss-monthly-wrap {
  display: flex;
  align-items: center;
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  overflow: hidden;
  transition: border-color 0.15s;
}

.ss-monthly-wrap:focus-within { border-color: var(--accent-mid); }

.ss-monthly-wrap span {
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 5px;
  background: var(--border-subtle);
  border-right: 1px solid var(--border);
  user-select: none;
  flex-shrink: 0;
}

.ss-monthly-input {
  width: 100%;
  border: none;
  background: transparent;
  padding: 4px 6px;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text);
  outline: none;
}

.ss-per-mo {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.ss-annual-display {
  font-size: 11px;
  color: var(--text-secondary);
  padding: 5px 7px;
  background: var(--bg);
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

.ss-disclaimer {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.5;
}

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

.ss-disclaimer a:hover { text-decoration: underline; }

.ss-annual-value {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--accent);
}

/* ── Toggle Switch ── */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 20px;
  transition: background 0.2s;
}

.toggle-track::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  left: 3px;
  top: 3px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-track { background: var(--accent); }
.toggle-switch input:checked + .toggle-track::before { transform: translateX(16px); }

/* ── Spending Model Card ── */
.spending-model-card { grid-column: 1 / -1; }

.spending-model-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0;
}

.spending-model-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.spending-model-note {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 12px;
  margin-bottom: 14px;
  line-height: 1.5;
}

.spending-phases {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.spending-phase-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--bg);
}

.phase-gogo  { border-top: 3px solid #2563eb; }
.phase-slowgo { border-top: 3px solid var(--warn); }
.phase-nogo  { border-top: 3px solid #475569; }

.phase-icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.phase-icon-wrap svg { width: 16px; height: 16px; }

.phase-gogo  .phase-icon-wrap { background: rgba(37,99,235,0.1);  color: #2563eb; }
.phase-slowgo .phase-icon-wrap { background: rgba(196,92,26,0.1); color: var(--warn); }
.phase-nogo  .phase-icon-wrap { background: rgba(71,85,105,0.1);  color: #475569; }

.phase-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}

.phase-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.5;
}

.phase-range {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.phase-age-input {
  width: 44px;
  font-size: 11px;
  font-family: var(--mono);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 2px 4px;
  outline: none;
  text-align: center;
  transition: border-color 0.15s;
}

.phase-age-input:focus { border-color: var(--accent-mid); }

.phase-pct-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.phase-pct-input {
  width: 54px;
  font-size: 12px;
  font-weight: 400;
  font-family: var(--mono);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 4px 6px;
  outline: none;
  text-align: center;
  transition: border-color 0.15s;
}

.phase-pct-input:focus { border-color: var(--accent-mid); }

.phase-pct-label {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ── Segmented Control ── */
.seg-control {
  display: flex;
  width: 120px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.seg-btn {
  flex: 1;
  padding: 5px 0;
  font-size: 11px;
  font-family: var(--sans);
  font-weight: 500;
  background: var(--bg);
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn.active { background: var(--accent); color: #fff; }
.seg-btn:hover:not(.active) { background: var(--border-subtle); color: var(--text); }

/* ── Help Icon Tooltips ── */
.help-icon-wrap {
  position: relative;
  display: inline-block;
  margin-left: 4px;
  vertical-align: middle;
}

.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 600;
  font-style: normal;
  font-family: var(--sans);
  line-height: 1;
  cursor: help;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}

.help-icon-wrap:hover .help-icon {
  background: var(--accent-light);
  color: var(--accent);
}

.tooltip-bubble {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 12px 14px;
  font-size: 12px;
  font-family: var(--sans);
  color: var(--text-secondary);
  line-height: 1.65;
  z-index: 200;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.15s, visibility 0.15s;
  pointer-events: none;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.tooltip-bubble::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: var(--border);
}

.tooltip-bubble::before {
  content: '';
  position: absolute;
  bottom: calc(100% - 1px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: var(--surface);
  z-index: 1;
}

.help-icon-wrap:hover .tooltip-bubble {
  visibility: visible;
  opacity: 1;
}

.mc-alert {
  background: #fff8f5;
  border: 1px solid #f0c4a8;
  border-left: 3px solid var(--warn);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.mc-alert-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--warn);
  margin-bottom: 10px;
}

.mc-alert-list {
  list-style: disc;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.mc-alert-list li {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.mc-alert-list li strong { color: var(--text); }

/* ── Scenarios ── */
.scenario-builder { margin-bottom: 8px; }
.scenario-builder h3 { font-size: 14px; font-weight: 600; margin-bottom: 14px; }

.scenario-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }

.scenario-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.scenario-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.scenario-name {
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.scenario-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.scenario-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.scenario-field label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 3px;
}

.scenario-field input {
  width: 100%;
  font-size: 12px;
  font-family: var(--mono);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 7px;
  outline: none;
}

.scenario-field input:focus { border-color: var(--accent-mid); }

.btn-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  padding: 0;
}

.btn-remove:hover { color: var(--danger); }

.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 13px;
  font-family: var(--sans);
  cursor: pointer;
  color: var(--text-secondary);
  transition: border-color 0.15s, color 0.15s;
}

.btn-secondary:hover { border-color: var(--accent-mid); color: var(--accent); }

/* ── Roth Scenarios ── */
.roth-scenarios { display: flex; flex-direction: column; gap: 10px; }

.roth-scenario-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.roth-scenario-name { font-size: 13px; color: var(--text-secondary); }
.roth-scenario-value { font-family: var(--mono); font-size: 14px; font-weight: 500; color: var(--text); }
.roth-scenario-savings { font-size: 11px; color: var(--accent); margin-top: 2px; }
.roth-scenario-warn { font-size: 11px; color: var(--warn); margin-top: 2px; }

/* ── SS Threshold Display ── */
.ss-threshold-display {
  margin-bottom: 12px;
}

.ss-tier {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
}

.ss-tier-pct {
  font-family: var(--mono);
  font-weight: 500;
  width: 40px;
  flex-shrink: 0;
}

.ss-tier-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.ss-tier-fill { height: 100%; border-radius: 3px; }

.ss-tier-label { font-size: 11px; color: var(--text-secondary); flex-shrink: 0; }

/* ── Highlight Classes ── */
.text-success { color: var(--accent); }
.text-warn { color: var(--warn); }
.text-danger { color: var(--danger); }
.text-mono { font-family: var(--mono); }

/* ── Cell Tooltip ─────────────────────────────────────────── */
.cell-tip {
  position: relative;
  cursor: default;
  white-space: nowrap;
}

.tip-icon {
  width: 11px;
  height: 11px;
  margin-left: 4px;
  vertical-align: middle;
  color: var(--text-muted);
  opacity: 0.6;
  flex-shrink: 0;
}

.cell-tip:hover .tip-icon {
  color: var(--accent);
  opacity: 1;
}

.cell-tip-bubble {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 8px 12px;
  font-size: 11px;
  font-family: var(--sans);
  color: var(--text-secondary);
  line-height: 1.7;
  white-space: nowrap;
  z-index: 200;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.15s, visibility 0.15s;
  pointer-events: none;
  text-align: left;
  font-weight: 400;
}

.cell-tip:hover .cell-tip-bubble {
  visibility: visible;
  opacity: 1;
}

/* ── Live Preview Bar ─────────────────────────────────────── */
.live-sidebar {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1.25rem;
  margin-bottom: 1.25rem;
}

.live-sidebar-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  flex-shrink: 0;
  padding-right: 1rem;
  border-right: 1px solid var(--border);
}

.live-metric {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex-shrink: 0;
}

.live-metric-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.live-metric-value {
  font-size: 1.1rem;
  font-weight: 600;
  font-family: var(--mono);
  color: var(--text-primary);
}

.live-chart-wrap {
  flex: 1;
  height: 52px;
  min-width: 0;
}

/* ── Responsive: Tablet (≤ 900px) ── */
@media (max-width: 900px) {
  .sidebar { width: 60px; }
  .logo-text, .nav-item span, .sidebar-footer .btn-calculate span { display: none; }
  .logo-svg { margin: 0 auto; }
  .sidebar-logo { justify-content: center; }
  .nav-item { justify-content: center; padding: 12px; }
  .nav-item svg { margin: 0; }
  .inputs-layout { flex-direction: column; }
  .live-sidebar { width: 100%; position: static; }
  .input-grid { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .summary-row { grid-template-columns: repeat(2, 1fr); }
  .panel { padding: 20px; }
}

/* ── Responsive: Mobile (≤ 600px) ── */
@media (max-width: 600px) {
  /* Stack layout: content on top, nav bar pinned to bottom */
  .app-shell { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    flex-shrink: 0;
    order: 2;
    border-top: 1px solid rgba(255,255,255,0.08);
  }

  .sidebar-logo,
  .sidebar-footer { display: none; }

  .sidebar-nav {
    display: flex;
    flex-direction: row;
    flex: 1;
    padding: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-item {
    flex: 1;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 10px 6px;
    min-width: 60px;
  }

  .nav-item svg { width: 16px; height: 16px; margin: 0; flex-shrink: 0; }

  /* Icons only on mobile — hide labels */
  .nav-item span, .sidebar-nav .nav-item span { display: none !important; }

  /* Main content fills remaining height */
  .main-content { order: 1; flex: 1; min-height: 0; }

  /* Panel */
  .panel { padding: 14px 12px 24px; }

  /* Input grid: single column */
  .input-grid { grid-template-columns: 1fr; }

  /* Summary tiles: 2 columns */
  .summary-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }

  /* Tile values: scale down slightly */
  .tile-value { font-size: 1.25rem; }

  /* Live preview: wrap metrics, full-width chart */
  .live-sidebar { flex-wrap: wrap; gap: 0.75rem 1.5rem; padding: 0.75rem 1rem; }
  .live-sidebar-title {
    width: 100%;
    padding-right: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.4rem;
  }
  .live-chart-wrap { width: 100%; flex: none; height: 50px; }

  /* Profile bar: stack groups */
  .profile-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .profile-group { flex-wrap: wrap; }
  .profile-name-input,
  .profile-select { flex: 1; min-width: 100px; }

  /* Tables: scroll horizontally */
  .col-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Spending phases: stack */
  .spending-phases { grid-template-columns: 1fr; }

  /* Segmented controls: full width, stack label above */
  .seg-control { width: 100%; }
  .seg-btn { flex: 1; }
  .field-row:has(.seg-control) {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  /* Chart heights: more compact */
  .chart-wrap { height: 220px !important; }
}
