/* Forms styles - Input groups, tabs, account cards, buttons */

/* ============================================
   Form Page Layout
   ============================================ */

.split-pane-container {
  display: flex;
  gap: 0;
  height: 100%;
}

.form-page {
  width: 45%;
  margin: 0;
  padding-right: var(--sp-6);
  border-right: 1px solid var(--border-subtle);
}

.chart-pane {
  flex: 1;
  padding-left: var(--sp-6);
  overflow-y: auto;
}

.form-guidance {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  padding-top: var(--sp-2);
}

.guidance-item {
  display: flex;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
}

.guidance-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light, #d1fae5);
  border-radius: 8px;
  color: var(--primary, #00B577);
}

.guidance-icon .material-symbols-outlined {
  font-size: 20px;
}

.guidance-body h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 6px 0;
}

.guidance-body p {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

.form-section {
  margin-bottom: var(--sp-6);
}

.form-section-title {
  font-size: var(--text-lg);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--sp-4);
  color: var(--text-main);
}

.form-section-optional {
  font-size: var(--text-sm);
  font-weight: var(--fw-normal);
  color: var(--text-muted);
  margin-left: 6px;
}

/* Monthly Estimates Grid */
.monthly-estimates-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2) 20px;
}

.monthly-total-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.monthly-total-label {
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
}

.monthly-total-value {
  font-size: var(--text-sm);
  font-weight: var(--fw-bold);
  color: var(--accent);
}

.recalc-link {
  font-size: 11px;
  font-weight: var(--fw-normal);
  margin-left: 8px;
  color: var(--accent);
  text-decoration: none;
  opacity: 0.7;
}

.recalc-link:hover {
  opacity: 1;
  text-decoration: underline;
}

/* Accounts page: net worth card sits to the right of the title text */
.kpi-header-title:has(.networth-card) {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

/* Title text takes 2 parts, card takes 1 part — keeps card ≈ same width as each right KPI */
.kpi-title-text {
  flex: 3 1 0;
  min-width: 0;
}

.stat-card.networth-card {
  flex: 1 0 0;
  min-width: 0;
  border-top: 2px solid var(--primary);
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: 0;
}

.stat-card.networth-card .stat-label {
  font-size: 10px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.07em;
  text-align: right;
  margin-bottom: var(--sp-1);
}

.stat-card.networth-card .stat-value {
  font-size: var(--text-xl);
  font-weight: var(--fw-bold);
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.stat-card.networth-card .stat-desc {
  font-size: 10px;
  text-align: right;
  margin-top: 8px;
  padding-top: 0;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-muted);
  line-height: 1.2;
}

/* Page header with KPI row aligned to chart pane (shared across pages) */
.kpi-page-header {
  justify-content: flex-start;
}
.kpi-header-title {
  width: 45%;
  flex-shrink: 0;
  padding-right: var(--sp-6);
}
.header-kpis {
  flex: 1;
  padding-left: var(--sp-6);
  display: flex;
  gap: var(--sp-3);
}
.header-kpis .stat-card {
  flex: 1;
  min-width: 0;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-xl);
  border-top: 2px solid var(--primary);
  display: flex;
  flex-direction: column;
  gap: 0;
}
.header-kpis .stat-label {
  font-size: 10px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: right;
  margin-bottom: var(--sp-1);
}
.kpi-value {
  font-size: var(--text-sm);
  margin-bottom: 0 !important;
  text-align: right;
  line-height: 1.1;
}
.header-kpis .kpi-value {
  font-size: var(--text-xl);
  font-weight: var(--fw-bold);
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text-main);
}
.header-kpis .stat-desc {
  font-size: 10px;
  text-align: right;
  margin-top: var(--sp-1);
  padding-top: var(--sp-1);
  border-top: 1px solid var(--border-subtle);
  color: var(--text-muted);
  line-height: 1.2;
}

/* Increase gap between value and separator line by ~1mm (except Success) */
.header-kpis .stat-card:not(:first-child) .stat-desc {
  margin-top: 8px;
  padding-top: 0;
}

/* ============================================
   Input Sections
   ============================================ */

.input-section {
  margin-bottom: var(--sp-8);
}

.input-section h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--fw-bold);
  margin-bottom: var(--sp-4);
  color: var(--text-main);
}

.input-grid {
  display: grid;
  gap: var(--sp-4);
}

/* ============================================
   Input Groups
   ============================================ */

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.input-group label,
.form-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: var(--fw-medium);
  margin-bottom: 0;
}

.input-group input,
.form-input {
  font-family: var(--font-display);
  font-size: var(--text-base);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  color: var(--text-main);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  min-height: 2.5rem;
}

.input-group input:focus,
.form-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface-card);
  box-shadow: 0 0 0 3px rgba(0, 181, 119, 0.1);
}

.input-group input::placeholder,
.form-input::placeholder {
  color: var(--text-muted);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: var(--sp-2);
  margin-bottom: 0;
}

/* ============================================
   Select Dropdowns
   ============================================ */

select,
.form-select {
  font-family: var(--font-display);
  font-size: var(--text-base);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  color: var(--text-main);
  width: 100%;
  box-sizing: border-box;
  cursor: pointer;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  min-height: 2.5rem;
}

select:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface-card);
  box-shadow: 0 0 0 3px rgba(0, 181, 119, 0.1);
}

/* ============================================
   Strategy Description
   ============================================ */

.conversion-param {
  margin-top: var(--sp-3);
  transition: opacity var(--transition-base);
}

.strategy-description {
  padding: var(--sp-3);
  background: var(--page-bg);
  border-radius: var(--radius-lg);
  border-left: 3px solid var(--primary);
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: 1.5;
  margin-top: var(--sp-3);
}

.strategy-description strong {
  color: var(--text-main);
}

/* ============================================
   Input Rows (Two-Column)
   ============================================ */

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}

/* Windfall row with 3 columns - Amount and Year get more space, Taxable gets less */
.windfall-input-row {
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
}

/* ============================================
   Account Cards
   ============================================ */

.account-card {
  background: var(--page-bg);
  border-radius: var(--radius-xl);
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
  border-left: 3px solid var(--taxable);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: box-shadow var(--transition-base);
}

.account-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}

.account-card.ira { border-left-color: var(--ira); }
.account-card.roth { border-left-color: var(--roth); }
.account-card.ss { border-left-color: var(--primary); }
.account-card.mc { border-left-color: var(--monte-carlo); }
.account-card.spouse { border-left-color: var(--spouse-primary); }

.account-card h4 {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--sp-2);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.account-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--taxable);
}

.account-card.ira .account-dot { background: var(--ira); }
.account-card.roth .account-dot { background: var(--roth); }
.account-card.ss .account-dot { background: var(--primary); }
.account-card.mc .account-dot { background: var(--monte-carlo); }
.account-card.spouse .account-dot { background: var(--spouse-primary); }

/* ============================================
   Filing Status Radio Group
   ============================================ */

.filing-status-group {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
}

.filing-status-option {
  flex: 1;
  position: relative;
}

.filing-status-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.filing-status-option label {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--sp-3);
  background: var(--page-bg);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-base);
  text-transform: none;
  letter-spacing: normal;
}

.filing-status-option input[type="radio"]:checked + label {
  border-color: var(--primary);
  background: var(--surface-card);
  box-shadow: 0 0 0 3px rgba(0, 181, 119, 0.1);
}

.filing-status-option label span.status-title {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-main);
}

.filing-status-option label span.status-desc {
  font-size: var(--text-2xs);
  color: var(--text-muted);
  margin-top: var(--sp-1);
}

/* ============================================
   Spouse Section Toggle
   ============================================ */

.spouse-section {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.4s ease, opacity 0.3s ease, margin 0.3s ease;
  margin-top: 0;
}

.spouse-section.visible {
  max-height: 800px;
  opacity: 1;
  margin-top: var(--sp-6);
}

/* ============================================
   Summary Stats
   ============================================ */

.summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

/* Compact sizing to match header-KPI cards used on all other pages */
.summary-stats .stat-card {
  padding: var(--sp-3) var(--sp-4);
}

.summary-stats .stat-value {
  font-size: var(--text-xl);
  margin-bottom: var(--sp-1);
}

.summary-stats .stat-label {
  font-size: 10px;
  margin-bottom: var(--sp-1);
}

.summary-stats .stat-desc {
  font-size: 10px;
  padding-top: var(--sp-1);
  margin-top: var(--sp-1);
  line-height: 1.2;
}

.summary-stats .stat-value-range {
  gap: var(--sp-3);
  margin-bottom: var(--sp-1);
}

.summary-stats .range-label {
  font-size: 10px;
}

.summary-stats .range-value {
  font-size: var(--text-base);
}

.stat-card {
  background: var(--surface-card);
  padding: var(--sp-5) var(--sp-5);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-subtle);
  border-top: 2px solid var(--border-subtle);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 12px rgba(0,0,0,0.04);
  transition: box-shadow var(--transition-base), transform var(--transition-fast), border-top-color var(--transition-base);
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.06);
  transform: translateY(-1px);
  border-top-color: var(--primary);
}

.success-rate-card {
  border-top-color: var(--primary);
}

.stat-value {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--fw-bold);
  color: var(--text-main);
  margin-bottom: var(--sp-2);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.success-rate-card .stat-value {
  color: var(--primary-dark);
}

.stat-label {
  font-size: var(--text-2xs);
  font-weight: var(--fw-bold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: var(--sp-2);
}

.stat-desc {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border-subtle);
  margin-top: var(--sp-1);
  line-height: 1.35;
}

.stat-value-range {
  display: flex;
  gap: var(--sp-4);
  margin-bottom: var(--sp-2);
}

.range-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.range-label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-bottom: var(--sp-1);
}

.range-value {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--fw-bold);
  color: var(--text-main);
}

/* ============================================
   Buttons
   ============================================ */

/* Primary Button */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: var(--text-base);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 6px 20px rgba(0, 181, 119, 0.3);
}

.btn-primary:active {
  transform: scale(0.95);
}

/* Secondary Button */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  background: var(--surface-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  font-size: var(--text-base);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  color: var(--text-main);
  background: var(--page-bg);
  border-color: #9CA3AF;
}

/* AI Pill Button — dark pill, turns green when active */
.btn-ai {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  background: #2D3748;
  color: #fff;
  border: 1px solid #2D3748;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  transition: all var(--transition-base);
  cursor: pointer;
}

.btn-ai:hover {
  background: #4A5568;
  border-color: #4A5568;
  box-shadow: var(--shadow-card-hover);
}

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

.btn-ai.active:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-ai .btn-ai-label {
  color: var(--primary);
}

.btn-ai.active .btn-ai-label {
  color: #fff;
}

.btn-ai .material-symbols-outlined {
  font-size: 18px;
  color: var(--primary);
}

.btn-ai.active .material-symbols-outlined {
  color: #fff;
}

/* Icon Button */
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
}

.btn-icon:hover {
  color: var(--primary);
  background: var(--page-bg);
}

/* Simulate Button */
.simulate-btn,
.btn-simulate {
  width: 100%;
  padding: var(--sp-3) var(--sp-6);
}

.page-header .simulate-btn,
.page-header .btn-simulate,
.page-header .mc-simulate-btn {
  width: auto;
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: var(--fw-bold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-primary);
}

.simulate-btn:hover,
.btn-simulate:hover,
.mc-simulate-btn:hover {
  background: var(--primary-dark);
}

.simulate-btn:active,
.btn-simulate:active,
.mc-simulate-btn:active {
  transform: scale(0.98);
}

/* Windfall Button */
.add-windfall-btn {
  padding: 0.375rem var(--sp-3);
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  transition: background var(--transition-base);
}

.add-windfall-btn:hover {
  background: var(--primary-dark);
}

.windfall-entry {
  position: relative;
  margin-bottom: var(--sp-4);
}

.remove-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: all var(--transition-base);
}

.remove-btn:hover {
  background: rgba(220, 38, 38, 0.1);
  color: var(--danger);
}

#windfallContainer:empty::before {
  content: "No windfalls added. Click + Add Windfall to create one.";
  display: block;
  padding: var(--sp-4);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-base);
  font-style: italic;
}

/* ============================================
   Button States
   ============================================ */

button:disabled,
.btn-primary:disabled,
.btn-secondary:disabled,
.btn-ai:disabled,
.simulate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

button:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-ai:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ============================================
   Checkbox Styling
   ============================================ */

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  font-weight: var(--fw-medium);
  color: var(--text-main);
  height: 2.5rem;
  padding: 0 var(--sp-2);
  margin: 0;
}

input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 1.125rem;
  height: 1.125rem;
  border: 1.5px solid var(--border-subtle);
  border-radius: 3px;
  background: var(--surface-card);
  cursor: pointer;
  position: relative;
  transition: all var(--transition-base);
  flex-shrink: 0;
  margin: 0;
}

input[type="checkbox"]:hover {
  border-color: var(--text-secondary);
}

input[type="checkbox"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0, 181, 119, 0.15);
}

input[type="checkbox"]:checked {
  background: #1f2937;
  border-color: #1f2937;
}

input[type="checkbox"]:checked::after {
  content: "✓";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 0.75rem;
  font-weight: var(--fw-bold);
  line-height: 1;
}

/* ============================================
   Account Card Header (label + action button row)
   ============================================ */

.account-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}

.account-card-header h4 {
  margin: 0;
}

/* Optimize trigger button — compact, right-aligned inside card headers */
.btn-optimize {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius-lg);
  font-size: 0.75rem;
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-optimize .material-symbols-outlined {
  font-size: 14px;
}

.btn-optimize:hover {
  background: var(--primary);
  color: white;
}

.btn-optimize:active {
  transform: scale(0.96);
}

/* ============================================
   Optimization Results Modal
   ============================================ */

/* form-section-header: flex row pairing a section title with an action button */
.form-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}

.form-section-header .form-section-title {
  margin-bottom: 0;
}

.form-section-header .btn-optimize {
  margin-top: 10px;
}

.modal-content.optimize-modal-content {
  max-width: 1100px;
  width: 98vw;
  max-height: 92vh;
}

/* ============================================
   Spend Analyzer Modal
   ============================================ */

.modal-content.spend-analyzer-modal-content {
  max-width: 680px;
  width: 95vw;
}

.spend-analyzer-disclaimer {
  background: var(--surface-elevated, var(--surface-card));
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: var(--sp-3) var(--sp-4);
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: var(--sp-5);
}

.spend-analyzer-portfolio {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
}

.spend-analyzer-portfolio-label {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.spend-analyzer-portfolio-value {
  font-size: 1.15rem;
  font-weight: var(--fw-bold);
  color: var(--text-main);
}

.spend-analyzer-portfolio-age {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.spend-analyzer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-4);
}

@media (max-width: 520px) {
  .spend-analyzer-grid {
    grid-template-columns: 1fr;
  }
}

.spend-analyzer-card {
  background: var(--surface-elevated, var(--surface-card));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.spend-analyzer-card-name {
  font-size: 0.78rem;
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--sp-1);
}

.spend-analyzer-amount {
  font-size: 1.55rem;
  font-weight: var(--fw-bold);
  color: var(--primary);
  line-height: 1.1;
}

.spend-analyzer-pct {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.spend-analyzer-desc {
  font-size: 0.77rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-top: var(--sp-2);
  flex: 1;
}

.optimize-legend {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.optimize-table-wrap {
  overflow-x: auto;
}

.optimize-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.optimize-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-size: 0.75rem;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border-subtle);
  white-space: nowrap;
}

.optimize-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.optimize-table tbody tr:last-child td {
  border-bottom: none;
}

.optimize-table tbody tr:hover td {
  background: var(--page-bg);
}

.optimize-row-optimal td {
  background: color-mix(in srgb, var(--primary) 6%, transparent);
}

.optimize-row-optimal:hover td {
  background: color-mix(in srgb, var(--primary) 10%, transparent) !important;
}

.optimize-label {
  font-weight: var(--fw-medium);
}

.optimize-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.optimize-pareto-cell {
  text-align: center;
}

.optimize-pareto-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: var(--fw-bold);
}

.optimize-success.yes {
  color: var(--primary);
  font-weight: var(--fw-semibold);
}

.optimize-success.no {
  color: var(--danger, #ef4444);
}

/* ── Retire Age: earliest-age hero card ── */
.retire-age-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 1.5rem 1.25rem 1.25rem;
  margin-bottom: 1.25rem;
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  border-radius: var(--radius-lg);
  text-align: center;
}

.retire-age-hero--none {
  background: color-mix(in srgb, var(--danger, #ef4444) 6%, transparent);
  border-color: color-mix(in srgb, var(--danger, #ef4444) 25%, transparent);
}

.retire-age-hero-label {
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
}

.retire-age-hero-age {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text-main);
  line-height: 1;
}

.retire-age-hero-stats {
  display: flex;
  gap: 1.5rem;
  margin-top: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.retire-age-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.retire-age-stat-label {
  font-size: 0.68rem;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.retire-age-stat-value {
  font-size: var(--text-base);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
}

.retire-age-earliest-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  background: var(--primary);
  color: white;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
}

.optimize-row-fail td {
  color: var(--text-secondary);
  opacity: 0.7;
}

.optimize-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem;
  color: var(--text-secondary);
}

.optimize-spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.optimize-error {
  color: var(--danger, #ef4444);
  padding: 1rem 0;
}

.optimize-empty {
  color: var(--text-secondary);
  padding: 1rem 0;
}

/* ─── Onboarding Checklist ─────────────────────────────────────────────────── */

.onboarding-checklist {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--sp-5);
  margin-bottom: var(--sp-4);
}

.onboarding-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.onboarding-header-icon {
  font-size: 1.5rem;
  color: var(--primary);
  flex-shrink: 0;
}

.onboarding-header-text {
  flex: 1;
  min-width: 0;
}

.onboarding-header-text h3 {
  font-size: var(--text-base);
  font-weight: var(--fw-semibold);
  color: var(--text-main);
  margin: 0 0 2px;
}

.onboarding-header-text p {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0;
}

.onboarding-skip-btn {
  background: none;
  border: none;
  font-size: var(--text-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius);
  white-space: nowrap;
  flex-shrink: 0;
  transition: color var(--transition-base);
}

.onboarding-skip-btn:hover {
  color: var(--text-main);
}

.onboarding-steps {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin-bottom: var(--sp-4);
}

.onboarding-step {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-2);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background var(--transition-base);
}

.onboarding-step:not(.complete):hover {
  background: var(--surface-hover, rgba(0,0,0,0.04));
}

.onboarding-step.complete {
  cursor: default;
  opacity: 0.65;
}

.onboarding-step .step-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color var(--transition-base);
}

.onboarding-step.complete .step-icon {
  color: var(--primary);
}

.onboarding-step .step-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.onboarding-step .step-title {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text-main);
  line-height: 1.3;
}

.onboarding-step.complete .step-title {
  color: var(--text-muted);
}

.onboarding-step .step-desc {
  font-size: var(--text-xs, 0.75rem);
  color: var(--text-muted);
  line-height: 1.3;
  margin-top: 1px;
}

.onboarding-step .step-arrow {
  font-size: 1.1rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.onboarding-run-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: background var(--transition-base), opacity var(--transition-base);
}

.onboarding-run-btn:hover:not(:disabled) {
  background: var(--primary-dark, #059669);
}

.onboarding-run-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.onboarding-run-btn .material-symbols-outlined {
  font-size: 1.1rem;
}

/* Resume mini-card */
.onboarding-resume {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-card);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-xl);
  margin-bottom: var(--sp-4);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.onboarding-resume .material-symbols-outlined {
  font-size: 1.2rem;
  color: var(--primary);
  flex-shrink: 0;
}

.onboarding-resume-btn {
  margin-left: auto;
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  font-size: var(--text-xs, 0.75rem);
  font-weight: var(--fw-medium);
  color: var(--primary);
  padding: var(--sp-1) var(--sp-3);
  cursor: pointer;
  transition: background var(--transition-base), border-color var(--transition-base);
  white-space: nowrap;
}

/* ── Tax Consequences Table ─────────────────────────────── */
.form-section-subtitle {
  font-size: var(--text-2xs);
  color: var(--text-muted);
  margin: -8px 0 var(--sp-3) 0;
  line-height: 1.5;
}

.tax-cell-main {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-weight: var(--fw-medium);
  color: var(--text-main);
  margin-bottom: 6px;
  font-size: 0.8125rem;
  line-height: 1.45;
}

.tax-cell-main .tax-dot {
  margin-top: 5px;
}

.tax-cell-detail {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.65;
}

.tax-cell-detail em {
  font-style: italic;
  color: var(--text-secondary);
}

.tax-table {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
  font-size: var(--text-2xs);
}

.tax-table-header {
  display: grid;
  grid-template-columns: 130px 1fr 1fr;
  background: rgba(0, 0, 0, 0.07);
  border-bottom: 1px solid var(--border-subtle);
  padding: var(--sp-2) var(--sp-3);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tax-table-row {
  display: grid;
  grid-template-columns: 130px 1fr 1fr;
  border-bottom: 1px solid var(--border-subtle);
  border-left: 3px solid var(--row-accent);
  background: var(--surface-card);
  transition: background var(--transition-base);
}

.tax-table-row:last-child {
  border-bottom: none;
}

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

.tax-table-account-col {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-3);
  border-right: 1px solid var(--border-subtle);
}

.tax-table-col {
  padding: var(--sp-4) var(--sp-3);
  color: var(--text-secondary);
  line-height: 1.5;
  border-right: 1px solid var(--border-subtle);
}

.tax-table-col:last-child {
  border-right: none;
}

.tax-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 4px;
}

.tax-account-name {
  font-weight: var(--fw-semibold);
  color: var(--text-main);
  font-size: 0.8125rem;
  margin-bottom: 4px;
}

.tax-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

.tax-badge-mixed {
  background: rgba(156, 186, 81, 0.15);
  color: #6a7f28;
}

[data-theme="dark"] .tax-badge-mixed {
  background: rgba(156, 186, 81, 0.2);
  color: #c3d96c;
}

.tax-badge-worst {
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
}

[data-theme="dark"] .tax-badge-worst {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.tax-badge-best {
  background: rgba(0, 181, 119, 0.12);
  color: var(--primary-dark, #008f5d);
}

[data-theme="dark"] .tax-badge-best {
  background: rgba(0, 181, 119, 0.18);
  color: #6ee7b7;
}

.onboarding-resume-btn:hover {
  background: var(--primary-light, #d1fae5);
  border-color: var(--primary);
}

/* ============================================================
   Demo Mode — Read-Only Form State
   body.demo-mode is set when a demo plan is loaded.
   .form-page inputs are disabled via pointer-events; .chart-pane
   controls remain fully interactive so users can navigate charts.
   ============================================================ */

body.demo-mode .form-page input,
body.demo-mode .form-page select,
body.demo-mode .form-page textarea,
body.demo-mode .form-page button,
body.demo-mode .form-page label {
  pointer-events: none;
  opacity: 0.55;
  cursor: not-allowed;
}

/* Filing status uses hidden radio inputs (opacity:0) with a styled label overlay.
   Restore opacity:0 so the native radio circle doesn't bleed through. */
body.demo-mode .form-page .filing-status-option input[type="radio"] {
  opacity: 0;
}

/* Chart and visualization controls stay fully interactive */
body.demo-mode .chart-pane input,
body.demo-mode .chart-pane select,
body.demo-mode .chart-pane button {
  pointer-events: auto !important;
  opacity: 1 !important;
  cursor: pointer !important;
}

/* Run Analyzer / Run Optimization buttons are read-only actions — re-enable in demo mode */
body.demo-mode .form-page .btn-optimize {
  pointer-events: auto !important;
  opacity: 1 !important;
  cursor: pointer !important;
}

/* Plan name header shows default cursor (no rename) and wider to fit "(Demo, Read-Only)" */
body.demo-mode #currentPlanName {
  cursor: default !important;
  max-width: 420px;
}


/* Dark theme adjustments */
[data-theme="dark"] body.demo-mode .form-page input,
[data-theme="dark"] body.demo-mode .form-page select,
[data-theme="dark"] body.demo-mode .form-page textarea,
[data-theme="dark"] body.demo-mode .form-page button {
  opacity: 0.35;
}
