/* app.css — NestMint Component Styles */

/* ========== HEADER ========== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in oklch, var(--color-bg) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid oklch(from var(--color-text) l c h / 0.06);
}
.header-inner {
  max-width: var(--content-wide);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  gap: var(--space-4);
}
.logo-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--color-text);
  flex-shrink: 0;
}
.logo-svg { flex-shrink: 0; }
.logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-sm);
  letter-spacing: -0.02em;
}
.logo-tagline {
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--color-text-muted);
  margin-left: var(--space-2);
  padding-left: var(--space-2);
  border-left: 1px solid var(--color-border);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.header-nav {
  display: flex;
  gap: var(--space-1);
}
.nav-link {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  transition: all var(--transition-interactive);
}
.nav-link:hover { color: var(--color-text); background: var(--color-surface-offset); }
.nav-link.active { color: var(--color-primary); background: var(--color-primary-highlight); }
.header-actions { display: flex; align-items: center; gap: var(--space-2); }
.theme-toggle {
  padding: var(--space-2);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  transition: all var(--transition-interactive);
}
.theme-toggle:hover { color: var(--color-text); background: var(--color-surface-offset); }
.mobile-menu-btn { display: none; padding: var(--space-2); color: var(--color-text-muted); }
.mobile-nav {
  display: none;
  flex-direction: column;
  padding: var(--space-2) var(--space-4) var(--space-4);
  gap: var(--space-1);
}
.mobile-nav-link {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  transition: all var(--transition-interactive);
}
.mobile-nav-link:hover { background: var(--color-surface-offset); color: var(--color-text); }
.mobile-nav-link.active { color: var(--color-primary); background: var(--color-primary-highlight); }

@media (max-width: 768px) {
  .header-nav { display: none; }
  .mobile-menu-btn { display: block; }
  .mobile-nav:not([hidden]) { display: flex; }
  .logo-tagline { display: none; }
}

/* ========== VIEWS ========== */
.view { display: none; }
.view.active { display: block; animation: viewFadeIn 300ms cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes viewFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition-interactive);
  white-space: nowrap;
  cursor: pointer;
  border: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-surface-offset); }
.btn-accent {
  background: var(--color-primary-highlight);
  color: var(--color-primary);
  border: 1px solid oklch(from var(--color-primary) l c h / 0.25);
  font-weight: 600;
}
.btn-accent:hover {
  background: oklch(from var(--color-primary) l c h / 0.15);
}
.btn-ghost { color: var(--color-primary); background: transparent; }
.btn-ghost:hover { background: var(--color-primary-highlight); }
.btn-lg { padding: var(--space-3) var(--space-6); font-size: var(--text-sm); }
.btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); }
.btn-block { display: flex; width: 100%; }

/* ========== HERO SECTION ========== */
.hero-section {
  position: relative;
  padding: clamp(var(--space-12), 8vw, var(--space-32)) var(--space-4);
  text-align: center;
  overflow: hidden;
  background: 
    radial-gradient(ellipse at 30% 20%, color-mix(in oklch, var(--color-primary) 8%, transparent) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, color-mix(in oklch, var(--color-secondary) 6%, transparent) 0%, transparent 50%),
    var(--color-bg);
}
.hero-content {
  max-width: var(--content-default);
  margin: 0 auto;
}
.hero-badge {
  display: inline-flex;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-primary);
  background: var(--color-primary-highlight);
  margin-bottom: var(--space-6);
}
.hero-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--color-text);
  margin-bottom: var(--space-6);
}
.hero-accent { color: var(--color-primary); }
.hero-desc {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  max-width: 60ch;
  margin: 0 auto var(--space-8);
  line-height: 1.6;
}
.hero-ctas {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
}
.hero-image-wrapper {
  max-width: var(--content-wide);
  margin: var(--space-10) auto 0;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.hero-image {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

/* ========== SECTIONS ========== */
.section-container {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: clamp(var(--space-8), 6vw, var(--space-16)) var(--space-4);
}
.section-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  text-align: center;
  margin-bottom: var(--space-2);
  letter-spacing: -0.02em;
}
.section-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: var(--space-10);
  max-width: 50ch;
  margin-left: auto;
  margin-right: auto;
}

/* Steps */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: var(--space-6);
}
.step-card {
  background: var(--color-surface);
  border: 1px solid oklch(from var(--color-text) l c h / 0.06);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  text-align: center;
  transition: box-shadow var(--transition-interactive);
}
.step-card:hover { box-shadow: var(--shadow-md); }
.step-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-4);
}
.step-number {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-text-faint);
  margin-bottom: var(--space-2);
}
.step-card h3 {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: var(--space-2);
}
.step-card p { font-size: var(--text-sm); color: var(--color-text-muted); margin: 0 auto; }

/* Product Screenshots */
.screenshots-section {
  border-top: 1px solid var(--color-divider);
}
.screenshot-tabs {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
.screenshot-tab {
  padding: var(--space-2) var(--space-4);
  border: 2px solid oklch(from var(--color-text) l c h / 0.12);
  border-radius: 999px;
  background: transparent;
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-interactive);
}
.screenshot-tab:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: oklch(from var(--color-primary) l c h / 0.06);
}
.screenshot-tab.active {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #fff;
}
.screenshot-gallery {
  position: relative;
}
.screenshot-panel {
  display: none;
  animation: ssReveal 0.4s ease-out;
}
.screenshot-panel.active {
  display: block;
}
@keyframes ssReveal {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.screenshot-frame {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 8px 32px oklch(from var(--color-text) l c h / 0.12), 0 2px 8px oklch(from var(--color-text) l c h / 0.06);
  border: 1px solid oklch(from var(--color-text) l c h / 0.08);
  max-width: 960px;
  margin: 0 auto;
}
.screenshot-frame img {
  display: block;
  width: 100%;
  height: auto;
}
.screenshot-caption {
  text-align: center;
  padding: var(--space-5) var(--space-4) 0;
  max-width: 640px;
  margin: 0 auto;
}
.screenshot-caption h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--color-text);
}
.screenshot-caption p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
}
@media (max-width: 640px) {
  .screenshot-tabs {
    gap: var(--space-1);
  }
  .screenshot-tab {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
  }
}

/* Real App Screenshots */
.real-app-section {
  border-top: 1px solid var(--color-divider);
}
.real-app-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
  max-width: 1200px;
  margin: 0 auto;
}
.real-app-card {
  text-align: center;
}
.real-app-card h3 {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  margin-top: var(--space-3);
  margin-bottom: var(--space-1);
  color: var(--color-text);
}
.real-app-card p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
}
.real-app-frame {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 4px 24px oklch(from var(--color-text) l c h / 0.1), 0 1px 4px oklch(from var(--color-text) l c h / 0.06);
  border: 1px solid oklch(from var(--color-text) l c h / 0.08);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.real-app-frame:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 32px oklch(from var(--color-text) l c h / 0.14), 0 2px 8px oklch(from var(--color-text) l c h / 0.08);
}
.real-app-browser-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--color-surface-raised, #f5f5f5);
  border-bottom: 1px solid oklch(from var(--color-text) l c h / 0.06);
}
.browser-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.browser-url {
  flex: 1;
  text-align: center;
  font-size: 11px;
  color: var(--color-text-muted);
  font-family: var(--font-body);
  letter-spacing: 0.02em;
}
.real-app-frame img {
  display: block;
  width: 100%;
  height: auto;
}
@media (max-width: 900px) {
  .real-app-grid {
    grid-template-columns: 1fr;
    max-width: 640px;
    gap: var(--space-8);
  }
}

/* Features */
.features-section { border-top: 1px solid var(--color-divider); }
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: var(--space-4);
}
.feature-card {
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  border: 1px solid oklch(from var(--color-text) l c h / 0.06);
  background: var(--color-surface);
  transition: box-shadow var(--transition-interactive);
}
.feature-card:hover { box-shadow: var(--shadow-sm); }
.feature-card svg { margin-bottom: var(--space-3); }
.feature-card h4 {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-1);
}
.feature-card p { font-size: var(--text-xs); color: var(--color-text-muted); }

/* Pricing */
.pricing-section {
  border-top: 1px solid var(--color-divider);
}
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
  max-width: 960px;
  margin: 0 auto;
}
.pricing-card {
  background: var(--color-surface);
  border: 1px solid oklch(from var(--color-text) l c h / 0.08);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-6);
  text-align: center;
  position: relative;
  transition: box-shadow var(--transition-interactive), transform var(--transition-interactive);
}
.pricing-card:hover {
  box-shadow: var(--shadow-md);
}
.pricing-card-featured {
  border-color: var(--color-primary);
  border-width: 2px;
  box-shadow: 0 4px 24px oklch(from var(--color-primary) l c h / 0.12);
}
.pricing-card-featured:hover {
  box-shadow: 0 8px 32px oklch(from var(--color-primary) l c h / 0.18);
  transform: translateY(-2px);
}
.pricing-badge {
  position: absolute;
  top: -13px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-primary);
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 16px;
  border-radius: 999px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.pricing-card-header {
  margin-bottom: var(--space-6);
}
.pricing-label {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pricing-amount {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  margin: var(--space-2) 0 var(--space-1);
  line-height: 1;
}
.pricing-dollar {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  margin-top: 6px;
}
.pricing-value {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 2rem + 2.5vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}
.pricing-cents {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  margin-top: 6px;
}
.pricing-period {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.pricing-savings {
  display: block;
  font-size: 0.7rem;
  color: var(--color-primary);
  font-weight: 600;
  margin-top: var(--space-1);
}
.pricing-trial {
  display: block;
  font-size: 0.7rem;
  color: var(--color-text-faint);
  margin-top: var(--space-1);
  font-style: italic;
}
.pricing-features {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-6);
  text-align: left;
}
.pricing-features li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  padding: var(--space-2) 0;
  border-bottom: 1px solid oklch(from var(--color-text) l c h / 0.04);
}
.pricing-features li:last-child { border-bottom: none; }
.pricing-features svg {
  flex-shrink: 0;
  color: var(--color-primary);
}
.pricing-card-featured .pricing-features svg {
  color: var(--color-primary);
}
.btn-block {
  display: block;
  width: 100%;
}
.pricing-disclaimer {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-top: var(--space-6);
  max-width: 50ch;
  margin-left: auto;
  margin-right: auto;
}
@media (max-width: 820px) {
  .pricing-grid {
    grid-template-columns: 1fr;
    max-width: 360px;
  }
}

/* Footer */
.app-footer {
  padding: var(--space-8) var(--space-4);
  text-align: center;
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  border-top: 1px solid var(--color-divider);
  margin-top: var(--space-8);
}
.footer-content {
  max-width: 900px;
  margin: 0 auto;
}
.footer-company {
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}
.footer-disclaimer {
  line-height: 1.6;
  margin-bottom: var(--space-3);
}
.footer-links {
  margin-top: var(--space-2);
}
.footer-links a {
  color: var(--color-primary);
  text-decoration: none;
}
.footer-links a:hover {
  text-decoration: underline;
}
.footer-sep {
  margin: 0 var(--space-2);
  color: var(--color-divider);
}

/* ========== CALCULATOR LAYOUT ========== */
.calc-container {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: var(--space-6) var(--space-4);
}
.calc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
.page-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.page-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}
.calc-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: var(--space-6);
  align-items: start;
}
@media (max-width: 900px) {
  .calc-layout { grid-template-columns: 1fr; }
}

/* ========== FORM ELEMENTS ========== */
.input-card {
  background: var(--color-surface);
  border: 1px solid oklch(from var(--color-text) l c h / 0.06);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.input-card-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-divider);
}
.form-field {
  margin-bottom: var(--space-4);
}
.form-field:last-child { margin-bottom: 0; }
.form-field label {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
}
.form-field input[type="number"],
.form-field input[type="text"],
.form-field select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  transition: border-color var(--transition-interactive), box-shadow var(--transition-interactive);
}
.form-field input:focus,
.form-field select:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-highlight);
}
.input-with-prefix, .input-with-suffix {
  display: flex;
  align-items: center;
}
.input-prefix, .input-suffix {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-faint);
  padding: var(--space-2) var(--space-2);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  white-space: nowrap;
}
.input-prefix {
  border-right: none;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}
.input-suffix {
  border-left: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.input-with-prefix input { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.input-with-suffix input { border-radius: var(--radius-md) 0 0 var(--radius-md); }

/* Special withdrawal/deposit row alignment — all controls on the same baseline */
.special-withdrawal-row .form-field,
.special-deposit-row .form-field {
  margin-bottom: 0;
}

/* Slider */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--color-surface-offset);
  border-radius: var(--radius-full);
  outline: none;
  margin-top: var(--space-2);
  cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  border: 2px solid var(--color-surface);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-interactive);
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  border: 2px solid var(--color-surface);
  box-shadow: var(--shadow-sm);
}

/* Checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  cursor: pointer;
  color: var(--color-text);
}
.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* Form sections (collapsible) */
.form-section {
  background: var(--color-surface);
  border: 1px solid oklch(from var(--color-text) l c h / 0.06);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-3);
  overflow: hidden;
}
.form-section-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  color: var(--color-text);
  transition: background var(--transition-interactive);
}
.form-section-header::-webkit-details-marker { display: none; }
.form-section-header:hover { background: var(--color-surface-2); }
.form-section-header svg { color: var(--color-primary); flex-shrink: 0; }
.form-section[open] .form-section-header { border-bottom: 1px solid var(--color-divider); }
.form-section .form-grid,
.form-section .form-hint,
.form-section .form-sub-label,
.form-section .spending-tiers,
.form-section .rate-hint,
.form-section .tax-checkbox-group,
.form-section #special-withdrawals-list,
.form-section #special-deposits-list {
  padding: 0 var(--space-5);
}
.form-section .form-grid { padding-top: var(--space-4); padding-bottom: var(--space-4); }
.form-section .form-hint { padding-top: var(--space-3); padding-bottom: var(--space-2); }
.form-section .rate-hint { padding-top: var(--space-3); padding-bottom: var(--space-2); }
.form-section .tax-checkbox-group { padding-bottom: var(--space-4); }
.form-section #special-withdrawals-list,
.form-section #special-deposits-list { padding-top: var(--space-2); padding-bottom: var(--space-4); }
.form-section .form-sub-label { padding-top: var(--space-3); }
.form-section .spending-tiers { padding-bottom: var(--space-4); }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  gap: var(--space-4);
}
.form-sub-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-2);
}
.form-hint {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  padding: var(--space-2) var(--space-3);
  background: var(--color-primary-highlight);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
}

.post-form-layout {
  max-width: 800px;
}

/* ========== KPI CARDS ========== */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.kpi-card {
  background: var(--color-surface);
  border: 1px solid oklch(from var(--color-text) l c h / 0.06);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-sm);
}
.kpi-card.kpi-primary {
  border-color: var(--color-primary);
  border-width: 2px;
}
.kpi-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
  margin-bottom: var(--space-1);
}
.kpi-value {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--color-text);
}
.kpi-delta {
  font-size: var(--text-xs);
  font-weight: 500;
  margin-top: var(--space-1);
}

/* ========== FUN FACT CARD ========== */
.fun-fact-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: linear-gradient(135deg, oklch(0.95 0.04 160), oklch(0.94 0.05 210));
  border: 1px solid oklch(0.85 0.06 180);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-6);
  position: relative;
  overflow: hidden;
  animation: funFactFadeIn 0.4s ease;
}
.fun-fact-card::before {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: oklch(0.90 0.06 180 / 0.35);
  pointer-events: none;
}
@keyframes funFactFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.fun-fact-icon {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.fun-fact-content {
  flex: 1;
  min-width: 0;
}
.fun-fact-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: oklch(0.40 0.10 180);
  margin-bottom: var(--space-1);
}
.fun-fact-text {
  font-size: var(--text-sm);
  font-weight: 600;
  color: oklch(0.25 0.05 200);
  line-height: 1.4;
}
.fun-fact-subtext {
  font-size: var(--text-xs);
  color: oklch(0.40 0.06 200);
  margin-top: 2px;
  line-height: 1.35;
}
.fun-fact-shuffle {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  background: oklch(1 0 0 / 0.6);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: oklch(0.40 0.10 180);
  transition: background 0.2s, transform 0.2s;
}
.fun-fact-shuffle:hover {
  background: oklch(1 0 0 / 0.9);
  transform: rotate(180deg);
}
@media (max-width: 600px) {
  .fun-fact-card { padding: var(--space-3) var(--space-4); gap: var(--space-3); }
  .fun-fact-icon { width: 40px; height: 40px; font-size: 1.5rem; }
  .fun-fact-text { font-size: var(--text-xs); }
}

/* ========== CHART CARDS ========== */
.chart-card {
  background: var(--color-surface);
  border: 1px solid oklch(from var(--color-text) l c h / 0.06);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.chart-card canvas { background: transparent; }
.chart-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-2);
}
.chart-subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}
.chart-wrapper {
  position: relative;
  width: 100%;
  height: 280px;
}
.chart-wrapper.chart-tall { height: 340px; }

.calc-results .chart-card { margin-bottom: var(--space-4); }

/* ========== DASHBOARD ========== */
.dash-container {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: var(--space-6) var(--space-4);
}
.dash-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
.dash-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.dash-charts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.chart-large { grid-column: span 1; }
@media (max-width: 900px) {
  .dash-charts { grid-template-columns: 1fr; }
}

/* What-If Panel */
.whatif-panel {
  background: var(--color-surface);
  border: 1px solid oklch(from var(--color-text) l c h / 0.06);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-md);
}
.whatif-panel:not([hidden]) {
  animation: slideDown 300ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.whatif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.whatif-header h3 {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
}
.whatif-body .form-field { margin-bottom: var(--space-3); }
.whatif-presets {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.whatif-preset {
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
}
.whatif-preset.active {
  background: var(--color-primary-highlight);
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.whatif-preset-wide {
  padding-left: var(--space-5);
  padding-right: var(--space-5);
}
.whatif-mc-btn {
  background: var(--color-success);
  color: #fff;
  border: 1px solid var(--color-success);
  opacity: 0.6;
  transition: opacity var(--transition-interactive), box-shadow var(--transition-interactive);
}
.whatif-mc-btn.active {
  opacity: 1;
  box-shadow: 0 0 0 2px oklch(from var(--color-success) l c h / 0.25);
}
.whatif-mc { margin-top: var(--space-4); }

/* ========== GOAL SIMULATOR PAGE ========== */
.sim-starting-balance {
  max-width: 400px;
  margin-bottom: var(--space-5);
}
.sim-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
}
@media (max-width: 768px) {
  .sim-grid { grid-template-columns: 1fr; }
}
.sim-card {
  background: var(--color-surface);
  border: 1px solid oklch(from var(--color-text) l c h / 0.06);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
}
.sim-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}
.sim-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sim-card-header h3 {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
}
.sim-card-desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
  line-height: 1.5;
}
.sim-card-inputs {
  flex: 1;
  margin-bottom: var(--space-3);
}
.sim-card-inputs .form-grid-2 {
  grid-template-columns: 1fr 1fr;
}
.sim-calc-btn {
  width: 100%;
}
.sim-result {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-primary-highlight);
  border: 1px solid oklch(from var(--color-primary) l c h / 0.2);
}
.sim-answer {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}
.sim-detail {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.6;
}

/* ========== DATA TABLE ========== */
.table-card {
  background: var(--color-surface);
  border: 1px solid oklch(from var(--color-text) l c h / 0.06);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.table-scroll { overflow-x: auto; }
.data-table {
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums lining-nums;
}
.data-table th {
  position: sticky;
  top: 0;
  background: var(--color-surface);
  font-weight: 600;
  text-align: right;
  padding: var(--space-2) var(--space-3);
  border-bottom: 2px solid var(--color-divider);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  color: var(--color-text-muted);
  z-index: 1;
}
.data-table th:first-child { text-align: left; }
.data-table th:hover { color: var(--color-text); }
.data-table td {
  text-align: right;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-divider);
  white-space: nowrap;
}
.data-table td:first-child { text-align: left; font-weight: 500; }
.data-table tr:hover { background: var(--color-surface-2); }
.data-table tr.highlight { background: var(--color-primary-highlight); }
.data-table tr.depleted { background: var(--color-error-highlight); color: var(--color-error); }
.data-table tr.rmd-warning td { color: var(--color-warning); }

.table-details {
  background: var(--color-surface);
  border: 1px solid oklch(from var(--color-text) l c h / 0.06);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.table-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  color: var(--color-text-muted);
  transition: background var(--transition-interactive);
}
.table-toggle::-webkit-details-marker { display: none; }
.table-toggle:hover { background: var(--color-surface-2); }
.table-details[open] .table-toggle { border-bottom: 1px solid var(--color-divider); }
.table-details .table-scroll { padding: 0 var(--space-5) var(--space-5); max-height: 400px; overflow-y: auto; }

/* ========== PRINT ========== */
@media print {
  .app-header, .whatif-panel, .dash-actions, .hero-section,
  .btn, .theme-toggle, .mobile-menu-btn { display: none !important; }
  .view { display: block !important; }
  .chart-card, .kpi-card, .table-card { break-inside: avoid; page-break-inside: avoid; }
  body { font-size: 11pt; }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 600px) {
  .hero-title { font-size: clamp(1.5rem, 1rem + 3vw, 2.5rem); }
  .hero-ctas { flex-direction: column; align-items: center; }
  .hero-ctas .btn { width: 100%; max-width: 320px; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .dash-actions { width: 100%; }
  .dash-actions .btn { flex: 1; }
  .calc-header { flex-direction: column; align-items: flex-start; }
}

/* ========== VIEW TOGGLE ========== */
.view-toggle-bar {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-1);
  background: var(--color-surface-offset);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
  width: fit-content;
}
.view-toggle-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  background: transparent;
  transition: all var(--transition-interactive);
  cursor: pointer;
  border: none;
}
.view-toggle-btn:hover { color: var(--color-text); background: var(--color-surface); }
.view-toggle-btn.active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}
.view-toggle-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Switchable views */
.switchable-view { display: none; }
.switchable-view.active { display: block; animation: viewFadeIn 250ms ease; }

/* ========== SPREADSHEET TABLE ========== */
.spreadsheet-card {
  background: var(--color-surface);
  border: 1px solid oklch(from var(--color-text) l c h / 0.08);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: visible;
  min-width: 320px;
}
.spreadsheet-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
}
.spreadsheet-scroll {
  overflow: auto;
  max-height: 70vh;
  /* Subtle scroll hint shadow on right edge */
  background:
    linear-gradient(to right, var(--color-surface) 30px, transparent),
    linear-gradient(to left, var(--color-surface) 30px, transparent),
    linear-gradient(to right, oklch(from var(--color-text) l c h / 0.12), transparent 30px),
    linear-gradient(to left, oklch(from var(--color-text) l c h / 0.12), transparent 30px);
  background-position: left, right, left, right;
  background-size: 40px 100%, 40px 100%, 20px 100%, 20px 100%;
  background-repeat: no-repeat;
  background-attachment: local, local, scroll, scroll;
}
.spreadsheet-table {
  width: max-content;
  min-width: 100%;
  font-size: 9px;
  font-variant-numeric: tabular-nums lining-nums;
  border-collapse: collapse;
}
#pre-spreadsheet {
  width: 100%;
  min-width: 0;
}
.spreadsheet-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--color-surface-offset);
  padding: 2px 3px;
  text-align: right;
  font-weight: 600;
  font-size: 8px;
  color: var(--color-text);
  border-bottom: 2px solid var(--color-divider);
  white-space: nowrap;
}
.spreadsheet-table th:first-child,
.spreadsheet-table td:first-child { text-align: center; }
.spreadsheet-table th:nth-child(2),
.spreadsheet-table td:nth-child(2) { text-align: center; }
.spreadsheet-table td {
  padding: 1px 3px;
  text-align: right;
  border-bottom: 1px solid oklch(from var(--color-text) l c h / 0.04);
  color: var(--color-text);
  white-space: nowrap;
}
.spreadsheet-table tbody tr:hover {
  background: var(--color-primary-highlight);
}
.spreadsheet-table tbody tr:nth-child(even) {
  background: oklch(from var(--color-text) l c h / 0.02);
}
.spreadsheet-table tbody tr:nth-child(even):hover {
  background: var(--color-primary-highlight);
}
.spreadsheet-table td.negative { color: var(--color-error); }
.spreadsheet-table th.section-start,
.spreadsheet-table td.section-start {
  border-left: 2px solid var(--color-divider);
}
.spreadsheet-table td.positive { color: var(--color-success); }
.spreadsheet-table td.zero { color: var(--color-text-faint); }

/* Expanded spreadsheet — full viewport overlay */
.spreadsheet-expanded {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 100;
  border-radius: 0;
  border: none;
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  resize: none;
}
.spreadsheet-expanded .spreadsheet-toolbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
  flex-shrink: 0;
}
.spreadsheet-expanded .spreadsheet-scroll,
.spreadsheet-expanded .budget-annual-scroll-wrapper {
  max-height: none;
  flex: 1;
  overflow: auto;
}
/* Compact rows in expanded view so more fit on screen */
.spreadsheet-expanded .spreadsheet-table {
  font-size: 11px;
}
.spreadsheet-expanded .spreadsheet-table th {
  padding: 3px 5px;
  font-size: 10px;
}
.spreadsheet-expanded .spreadsheet-table td {
  padding: 2px 5px;
}
.spreadsheet-expanded .data-table {
  font-size: 11px;
}
.spreadsheet-expanded .data-table th {
  padding: 3px var(--space-2);
  font-size: 11px;
}
.spreadsheet-expanded .data-table td {
  padding: 2px var(--space-2);
}

.data-table td.negative { color: var(--color-error); }
.data-table td.positive { color: var(--color-success); }

/* Rate toggle */
.rate-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--space-3);
}
.rate-toggle-btn {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 500;
  border: none;
  background: var(--color-surface-raised);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease;
}
.rate-toggle-btn:hover {
  background: var(--color-surface-hover);
}
.rate-toggle-btn.active {
  background: var(--color-primary);
  color: #fff;
}
.rate-panel {
  animation: fadeIn 200ms ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.rate-hint {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin: 0 0 var(--space-3) 0;
}
.rate-tier {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border-faint);
}
.rate-tier:last-child {
  border-bottom: none;
}
.rate-tier label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-secondary);
  white-space: nowrap;
  min-width: 80px;
}
.input-sm {
  max-width: 140px;
  flex: 1;
}
.input-sm input {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  width: 100%;
}

/* ========== TAX CHECKBOX GROUP ========== */
.tax-checkbox-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-3) 0;
}
@media (max-width: 600px) {
  .tax-checkbox-group {
    grid-template-columns: 1fr;
  }
}
.tax-checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  cursor: pointer;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  transition: border-color 0.15s, background 0.15s;
}
.tax-checkbox-label:hover {
  border-color: var(--color-primary);
}
.tax-checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
  cursor: pointer;
  flex-shrink: 0;
}
.tax-checkbox-label input[type="checkbox"]:checked + span {
  font-weight: 500;
}
.tax-pct {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 400;
}

/* Capital Gains Options Sub-panel */
.capgains-options {
  grid-column: 1 / -1;
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-top: var(--space-1);
}
.capgains-option-row {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}
.capgains-option-row > .form-field {
  flex: 1 1 0;
  min-width: 0;
  margin-bottom: 0;
}
.capgains-option-row select,
.capgains-option-row .input-with-suffix {
  box-sizing: border-box;
  height: 38px;
}
.capgains-option-row .input-with-suffix input[type="number"] {
  box-sizing: border-box;
  height: 100%;
}
.capgains-option-row .input-with-suffix .input-suffix {
  box-sizing: border-box;
  height: 100%;
  display: flex;
  align-items: center;
}
@media (max-width: 600px) {
  .capgains-option-row { flex-direction: column; }
}

/* ========== TAX METHOD TOGGLE ========== */
.tax-method-toggle {
  display: inline-flex;
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.tax-method-btn, .ltcg-method-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.tax-method-btn:hover, .ltcg-method-btn:hover {
  color: var(--color-text);
  background: var(--color-surface);
}
.tax-method-btn.active, .ltcg-method-btn.active {
  background: var(--color-accent);
  color: #fff;
  font-weight: 600;
}
.bracket-preview {
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 11px;
  line-height: 1.5;
}
.bracket-preview table {
  width: 100%;
  border-collapse: collapse;
}
.bracket-preview th {
  text-align: left;
  font-weight: 600;
  padding: 2px 8px 2px 0;
  font-size: 10px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.bracket-preview td {
  padding: 1px 8px 1px 0;
  font-variant-numeric: tabular-nums;
}
.bracket-preview tr.active-bracket td {
  color: var(--color-accent);
  font-weight: 600;
}

/* ========== AUTH BUTTON & MODAL ========== */
.auth-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-xs);
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 180ms ease;
}
.auth-btn:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-primary);
}
.auth-btn.logged-in {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.auth-modal {
  position: relative;
  width: 90%;
  max-width: 400px;
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-6);
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  margin: 32px auto;
}
.auth-close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  background: none;
  border: none;
  font-size: 24px;
  color: var(--color-text-muted);
  cursor: pointer;
  line-height: 1;
  padding: var(--space-1);
}
.auth-close:hover { color: var(--color-text); }
.auth-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}
.auth-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}
.auth-field {
  margin-bottom: var(--space-4);
}
.auth-field label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
}
.auth-field input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: 'Inter', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  transition: border-color 180ms ease;
  box-sizing: border-box;
}
.auth-field input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(43, 181, 178, 0.15);
}
.auth-error {
  color: var(--color-error);
  font-size: var(--text-xs);
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: rgba(220, 50, 50, 0.08);
  border-radius: var(--radius-sm);
}
.auth-submit {
  width: 100%;
  margin-top: var(--space-2);
}
.auth-switch {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-4);
}
.auth-switch a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}
.auth-switch a:hover { text-decoration: underline; }

/* Auth: Social Sign-In Buttons */
.auth-social-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.auth-social-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: background 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
  position: relative;
}
.auth-google-btn {
  background: var(--color-bg);
  border: 1px solid var(--color-divider);
  color: var(--color-text);
}
.auth-google-btn:hover {
  background: oklch(from var(--color-text) l c h / 0.04);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.auth-apple-btn {
  background: #000;
  border: 1px solid #000;
  color: #fff;
}
.auth-apple-btn:hover:not(:disabled) {
  background: #222;
}
.auth-apple-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.auth-coming-soon {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(255,255,255,0.2);
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: var(--space-1);
}

/* Auth: Divider */
.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-4) 0;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-divider);
}
.auth-divider span {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* Auth: Select full-width match */
.auth-select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: 'Inter', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  box-sizing: border-box;
  transition: border-color 180ms ease;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.auth-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(43, 181, 178, 0.15);
}

/* Auth: Sign-in method badge */
.auth-signin-method {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-top: calc(-1 * var(--space-2));
  margin-bottom: var(--space-2);
}
.auth-info {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
  line-height: 1.5;
}

/* Password visibility toggle */
.pw-field-wrap {
  position: relative;
}
.pw-field-wrap input {
  padding-right: 38px;
}
.pw-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 150ms ease;
}
.pw-toggle:hover {
  color: var(--color-text);
}

/* Auth: compact for short viewports */
@media (max-height: 800px) {
  .auth-modal {
    padding: var(--space-5) var(--space-5);
    margin: 16px auto;
  }
  .auth-title { font-size: var(--text-base); margin-bottom: 2px; }
  .auth-subtitle { font-size: var(--text-xs); margin-bottom: var(--space-3); }
  .auth-field { margin-bottom: var(--space-2); }
  .auth-field input,
  .auth-select { padding: 6px var(--space-2); font-size: var(--text-xs); }
  .auth-social-btn { padding: 6px var(--space-2); font-size: var(--text-xs); }
  .auth-social-buttons { gap: 4px; margin-bottom: var(--space-2); }
  .auth-divider { margin: var(--space-2) 0; }
  .auth-submit { padding: 8px; font-size: var(--text-sm); }
  .auth-switch { font-size: var(--text-xs); }
}

/* ========== BUDGET TOOL ========== */
.budget-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: var(--space-6);
  align-items: start;
}
@media (max-width: 1024px) {
  .budget-layout { grid-template-columns: 1fr; }
}

.budget-forms {
  min-width: 0;
}

.budget-chart-panel {
  position: sticky;
  top: calc(var(--space-16) + var(--space-4));
}

.budget-donut-wrapper {
  height: 360px !important;
}

/* Budget section rows container */
.budget-section {
  padding: var(--space-2) var(--space-5) 0;
}

/* Each budget row: label + input + optional remove */
.budget-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid oklch(from var(--color-text) l c h / 0.04);
}
.budget-row:last-of-type {
  border-bottom: none;
}
.budget-row-label {
  flex: 1;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  min-width: 0;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  margin: -2px -4px;
  transition: background 0.15s ease;
}
.budget-row-label:hover {
  background: oklch(from var(--color-primary) l c h / 0.08);
}
.budget-row .input-with-prefix {
  width: 160px;
  flex-shrink: 0;
}
.budget-row .input-with-prefix input {
  width: 100%;
  font-variant-numeric: tabular-nums;
}

/* Budget row action buttons (delete) */
.budget-row-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

/* Drag handle */
.budget-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 28px;
  flex-shrink: 0;
  cursor: grab;
  color: var(--color-text-muted);
  opacity: 0.7;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
  user-select: none;
  touch-action: none;
  border-radius: 4px;
  background: oklch(from var(--color-primary) l c h / 0.06);
}
.budget-drag-handle:hover {
  opacity: 1;
  color: var(--color-text-default);
  background: oklch(from var(--color-primary) l c h / 0.12);
}
.budget-drag-handle:active {
  cursor: grabbing;
}
.budget-row-dragging {
  opacity: 0.35;
  background: oklch(from var(--color-primary) l c h / 0.06);
  border-radius: var(--radius-sm);
}
.budget-row-drop-above {
  box-shadow: inset 0 2px 0 0 var(--color-primary);
}
.budget-row-drop-below {
  box-shadow: inset 0 -2px 0 0 var(--color-primary);
}
.budget-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--color-text-faint);
  cursor: pointer;
  transition: all var(--transition-interactive);
  padding: 0;
}
.budget-action-btn:hover {
  background: var(--color-error-highlight);
  color: var(--color-error);
}
.budget-toggle-btn:hover {
  background: oklch(from var(--color-accent) l c h / 0.1);
  color: var(--color-accent);
}
.budget-row-disabled {
  opacity: 0.4;
  position: relative;
}
.budget-row-disabled .budget-input {
  text-decoration: line-through;
  color: var(--color-text-faint);
}
.budget-row-disabled .budget-row-label {
  text-decoration: line-through;
  color: var(--color-text-faint);
}
.budget-row-disabled .budget-toggle-btn {
  opacity: 1 !important;
  color: var(--color-text-muted);
}

/* Inline label editing input */
.budget-edit-input {
  flex: 1;
  min-width: 0;
  font-size: var(--text-sm);
  font-weight: 500;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface-alt);
  border: 1.5px solid var(--color-primary);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  outline: none;
}

/* Legacy remove button (custom rows that still use old pattern) */
.budget-remove-btn {
  display: none;
}

/* Total row at bottom of each section */
.budget-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) 0 var(--space-4);
  border-top: 2px solid var(--color-divider);
  margin-top: var(--space-2);
}
.budget-total-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}
.budget-total-value {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--color-text);
}

/* Add Category bar below form-section */
.budget-add-bar {
  padding: var(--space-3) var(--space-5) var(--space-4);
  border-top: 1px solid var(--color-divider);
}
.budget-add-inline {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}
.budget-add-name-input {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  background: var(--color-surface);
  color: var(--color-text);
  outline: none;
  transition: border-color 0.18s;
}
.budget-add-name-input:focus {
  border-color: var(--color-primary);
  border-style: solid;
}
.budget-add-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-primary);
  background: var(--color-primary-highlight);
  border: 1px dashed var(--color-primary);
  cursor: pointer;
  transition: all var(--transition-interactive);
}
.budget-add-btn:hover {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-style: solid;
}

/* Surplus / deficit color coding */
.surplus { color: var(--color-success) !important; }
.deficit { color: var(--color-error) !important; }

/* Outline button variant (hero CTA) */
.btn-outline {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-outline:hover {
  background: var(--color-surface-offset);
  border-color: var(--color-text-muted);
}

/* ========== SAVED SCENARIOS ========== */
.scenario-save-bar {
  padding: var(--space-3) 0 0;
  border-top: 1px solid var(--color-divider);
}
.scenario-save-inline {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}
.scenario-name-input {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  background: var(--color-surface);
  color: var(--color-text);
  outline: none;
  transition: border-color 0.18s;
  min-width: 0;
}
.scenario-name-input:focus {
  border-color: var(--color-primary);
  border-style: solid;
}
.scenario-name-input::placeholder {
  color: var(--color-text-muted);
}
.scenario-count {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  min-height: 1em;
}
.scenario-hint {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-style: italic;
}
.saved-scenarios {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-divider);
}
.saved-scenarios-title {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}
.scenario-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.scenario-card {
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  transition: border-color 0.18s;
}
.scenario-card:hover {
  border-color: var(--color-primary);
}
.scenario-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.scenario-card-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}
.scenario-card-date {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.scenario-card-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.scenario-card-kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.scenario-card-kpi-label {
  font-size: 10px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.2;
}
.scenario-card-kpi-value {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--color-text);
}
.scenario-card-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}
.scenario-delete-btn {
  color: var(--color-text-muted);
}
.scenario-delete-btn:hover {
  color: var(--color-error);
  background: color-mix(in oklch, var(--color-error) 10%, transparent);
}

/* ========== ADVISOR BUTTON ========== */
.advisor-btn {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border: 1.5px solid var(--color-primary);
  border-radius: var(--radius-sm);
  background: color-mix(in oklch, var(--color-primary) 8%, transparent);
  color: var(--color-primary);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  transition: all 180ms ease;
  white-space: nowrap;
}
.advisor-btn:hover {
  background: color-mix(in oklch, var(--color-primary) 16%, transparent);
  transform: translateY(-1px);
}
.advisor-btn svg { flex-shrink: 0; }

/* ========== ADVISOR PANEL ========== */
.advisor-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  background: oklch(from var(--color-text) l c h / 0.15);
  animation: advisorFadeIn 200ms ease;
}
@keyframes advisorFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.advisor-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(440px, 92vw);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  box-shadow: -4px 0 24px oklch(from var(--color-text) l c h / 0.1);
  animation: advisorSlideIn 250ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes advisorSlideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.advisor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid oklch(from var(--color-text) l c h / 0.08);
  flex-shrink: 0;
}
.advisor-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-primary);
}
.advisor-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}
.advisor-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 180ms ease;
}
.advisor-close:hover {
  background: oklch(from var(--color-text) l c h / 0.08);
  color: var(--color-text);
}
.advisor-disclaimer {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: color-mix(in oklch, var(--color-warning) 10%, transparent);
  border-bottom: 1px solid color-mix(in oklch, var(--color-warning) 20%, transparent);
  font-size: 11px;
  line-height: 1.4;
  color: var(--color-text-muted);
  flex-shrink: 0;
}
.advisor-disclaimer svg {
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--color-warning);
}
.advisor-search-wrap {
  position: relative;
  padding: var(--space-3) var(--space-4) var(--space-2);
  flex-shrink: 0;
}
.advisor-search-icon {
  position: absolute;
  left: calc(var(--space-4) + 10px);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
}
.advisor-search {
  width: 100%;
  padding: var(--space-2) var(--space-3) var(--space-2) calc(var(--space-3) + 22px);
  border: 1.5px solid oklch(from var(--color-text) l c h / 0.12);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  transition: border-color 180ms ease;
  outline: none;
}
.advisor-search:focus {
  border-color: var(--color-primary);
}
.advisor-search-clear {
  position: absolute;
  right: calc(var(--space-4) + 8px);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: oklch(from var(--color-text) l c h / 0.08);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 180ms ease;
}
.advisor-search-clear:hover {
  background: oklch(from var(--color-text) l c h / 0.14);
}
.advisor-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) var(--space-4) var(--space-4);
  overscroll-behavior: contain;
}
.advisor-category {
  margin-bottom: var(--space-3);
}
.advisor-category-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: var(--space-2) 0 var(--space-1);
  border-bottom: 1px solid oklch(from var(--color-text) l c h / 0.06);
  margin-bottom: var(--space-1);
}
.advisor-category-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}
.advisor-item {
  border-bottom: 1px solid oklch(from var(--color-text) l c h / 0.04);
}
.advisor-item:last-child {
  border-bottom: none;
}
.advisor-question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-2) var(--space-1);
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  text-align: left;
  transition: all 180ms ease;
  line-height: 1.4;
}
.advisor-question:hover {
  color: var(--color-primary);
  background: color-mix(in oklch, var(--color-primary) 4%, transparent);
  border-radius: var(--radius-sm);
}
.advisor-question svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  color: var(--color-text-muted);
  transition: transform 200ms ease;
}
.advisor-item.open .advisor-question svg {
  transform: rotate(180deg);
}
.advisor-answer {
  display: none;
  padding: var(--space-1) var(--space-1) var(--space-3) var(--space-1);
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--color-text-secondary);
}
.advisor-item.open .advisor-answer {
  display: block;
}
.advisor-answer strong {
  color: var(--color-text);
  font-weight: 600;
}
.advisor-answer ul {
  margin: var(--space-1) 0;
  padding-left: var(--space-4);
}
.advisor-answer li {
  margin-bottom: 4px;
}
.advisor-answer .advisor-tip {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: color-mix(in oklch, var(--color-success) 8%, transparent);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--color-success);
  font-size: 12px;
}
.advisor-answer .advisor-warning {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: color-mix(in oklch, var(--color-warning) 8%, transparent);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--color-warning);
  font-size: 12px;
}
.advisor-no-results {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}
.advisor-no-results svg {
  color: oklch(from var(--color-text) l c h / 0.15);
  margin-bottom: var(--space-2);
}

@media (max-width: 480px) {
  .advisor-btn-text { display: none; }
  .advisor-panel { width: 100vw; }
}

/* ========== BUDGET NET ROW ========== */
.budget-net-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  margin-top: var(--space-3);
  background: var(--color-surface);
  border: 1.5px solid oklch(from var(--color-text) l c h / 0.1);
  border-radius: var(--radius-md);
}
.budget-net-label {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
}
.budget-net-value {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--color-success);
}
.budget-net-value.deficit {
  color: var(--color-error);
}

/* ========== ANNUAL BUDGET SPREADSHEET ========== */
.budget-annual-scroll-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.budget-annual-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-xs);
  line-height: 1.4;
}

.budget-annual-table th,
.budget-annual-table td {
  padding: var(--space-1) var(--space-2);
  white-space: nowrap;
  border-bottom: 1px solid var(--color-divider);
  vertical-align: middle;
}

.budget-annual-table thead th {
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 2px solid var(--color-divider);
}

/* Sticky category column */
.budget-annual-table th.ba-col-category,
.budget-annual-table td.ba-col-category {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--color-surface);
  min-width: 150px;
  max-width: 180px;
  font-weight: 500;
  color: var(--color-text);
  border-right: 2px solid var(--color-divider);
}
.budget-annual-table thead th.ba-col-category {
  z-index: 4;
  background: var(--color-surface-offset);
}

/* Frequency column */
.ba-col-freq { min-width: 110px; }
.ba-freq-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ba-freq-select {
  width: 100px;
  padding: 2px 4px;
  font-size: 11px;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}
.ba-freq-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px oklch(from var(--color-primary) l c h / 0.15);
}

/* Start month picker (Quarterly/Semi/Annual) */
.ba-start-month {
  width: 100px;
  padding: 2px 4px;
  font-size: 10px;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
}
.ba-start-month:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* Custom month picker */
.ba-month-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  max-width: 200px;
}
.ba-month-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  font-weight: 500;
  color: var(--color-text-secondary);
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s ease;
  user-select: none;
}
.ba-month-chip:hover {
  background: oklch(from var(--color-primary) l c h / 0.08);
}
.ba-month-cb {
  width: 12px;
  height: 12px;
  margin: 0;
  accent-color: var(--color-primary);
  cursor: pointer;
}
.ba-month-chip:has(.ba-month-cb:checked) {
  color: var(--color-primary);
  font-weight: 600;
}

/* Month columns */
.ba-col-month { min-width: 76px; text-align: right; }
.ba-month-input {
  width: 70px;
  padding: 3px 6px;
  font-size: 12px;
  font-family: 'Inter', system-ui, sans-serif;
  text-align: right;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  -moz-appearance: textfield;
  transition: border-color 180ms ease;
}
.ba-month-input::-webkit-outer-spin-button,
.ba-month-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.ba-month-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px oklch(from var(--color-primary) l c h / 0.15);
}

/* Total column */
.ba-col-total {
  min-width: 90px;
  text-align: right;
  font-weight: 600;
  color: var(--color-text);
}

/* Section header rows */
.ba-section-header td {
  background: var(--color-surface-offset) !important;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  padding: var(--space-2) var(--space-2);
  border-bottom: 2px solid var(--color-divider);
}
.ba-section-header td.ba-col-category {
  background: var(--color-surface-offset) !important;
}
.ba-section-header.ba-income-header td {
  color: var(--color-success);
  border-bottom-color: oklch(from var(--color-success) l c h / 0.3);
}
.ba-section-header.ba-expense-header td {
  color: var(--color-error);
  border-bottom-color: oklch(from var(--color-error) l c h / 0.3);
}

/* Alternating row colors */
.ba-data-row:nth-child(even) td {
  background: oklch(from var(--color-surface-offset) l c h / 0.5);
}
.ba-data-row:nth-child(even) td.ba-col-category {
  background: oklch(from var(--color-surface-offset) l c h / 0.5);
}
.ba-data-row:hover td {
  background: oklch(from var(--color-primary) l c h / 0.06);
}
.ba-data-row:hover td.ba-col-category {
  background: oklch(from var(--color-primary) l c h / 0.06);
}

/* Totals rows */
.ba-totals-row td {
  background: var(--color-surface-offset) !important;
  font-weight: 600;
  font-size: 12px;
  border-top: 2px solid var(--color-divider);
  color: var(--color-text);
}
.ba-totals-row td.ba-col-category {
  background: var(--color-surface-offset) !important;
}

/* Grand summary row */
.ba-grand-row td {
  background: var(--color-surface-offset) !important;
  font-weight: 700;
  font-size: 12px;
  border-top: 3px double var(--color-divider);
  color: var(--color-text);
}
.ba-grand-row td.ba-col-category {
  background: var(--color-surface-offset) !important;
}
.ba-grand-row .ba-surplus { color: var(--color-success); }
.ba-grand-row .ba-deficit { color: var(--color-error); }

/* Responsive adjustments */
@media (max-width: 768px) {
  .budget-annual-table th.ba-col-category,
  .budget-annual-table td.ba-col-category {
    min-width: 120px;
    max-width: 140px;
    font-size: 11px;
  }
  .ba-month-input { width: 62px; font-size: 11px; }
  .ba-freq-select { width: 88px; font-size: 10px; }
}

/* ===== Active Scenario Indicator & Card Highlight ===== */
.active-scenario-indicator {
  font-size: 13px;
  font-weight: 600;
  color: #2e7d32;
  margin: 4px 0 0;
  padding: 4px 10px;
  background: #e8f5e9;
  border-radius: 6px;
  display: inline-block;
}
.scenario-card-active {
  border: 2px solid #43a047;
  box-shadow: 0 0 0 3px rgba(67, 160, 71, 0.15);
  position: relative;
}
.scenario-card-active::after {
  content: 'Active';
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: #43a047;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* ===== PLANNING TOOLS SECTION ===== */
.planning-tools-section {
  margin-top: var(--space-6, 24px);
  padding-top: var(--space-4, 16px);
  border-top: 3px solid #2bb5b2;
}
.planning-tools-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-secondary, #666);
  margin: 0 0 12px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.planning-tools-heading svg { opacity: 0.6; }

/* Tool Card Accordion */
.planning-tool-card {
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 10px;
  margin-bottom: 8px;
  background: var(--color-bg, #fff);
  transition: box-shadow 0.18s ease;
}
.planning-tool-card[open] {
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.planning-tool-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text, #1e1e1e);
}
.planning-tool-toggle::-webkit-details-marker { display: none; }
.planning-tool-toggle::marker { content: ''; }
.planning-tool-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
}
.planning-tool-label { flex: 1; }
.planning-tool-badge {
  font-size: 11px;
  font-weight: 700;
  color: #2bb5b2;
  background: rgba(43,181,178,0.1);
  padding: 2px 8px;
  border-radius: 10px;
  display: none;
}
.planning-tool-badge:not(:empty) { display: inline-block; }
.planning-tool-chevron {
  transition: transform 0.2s ease;
  opacity: 0.4;
  flex-shrink: 0;
}
.planning-tool-card[open] .planning-tool-chevron {
  transform: rotate(180deg);
}
.planning-tool-body {
  padding: 0 14px 14px;
}
.planning-tool-desc {
  font-size: 13px;
  color: var(--color-text-secondary, #777);
  margin: 0 0 12px 0;
  line-height: 1.5;
}

/* Milestone list */
.milestone-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.milestone-empty {
  font-size: 13px;
  color: #aaa;
  text-align: center;
  padding: 16px 0;
}
.milestone-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(0,0,0,0.02);
}
.milestone-row.milestone-reached {
  background: rgba(43,181,178,0.06);
}
.milestone-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 11px;
}
.milestone-check.done {
  background: #2bb5b2;
  color: #fff;
}
.milestone-check.pending {
  background: rgba(0,0,0,0.06);
  color: #bbb;
}
.milestone-info { flex: 1; }
.milestone-target {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text, #1e1e1e);
}
.milestone-year {
  font-size: 12px;
  color: var(--color-text-secondary, #888);
}
.milestone-value {
  font-size: 13px;
  font-weight: 600;
  color: #2bb5b2;
  text-align: right;
}

/* Match Optimizer Results */
.match-inputs { margin-bottom: 14px; }
.match-results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.match-result-card {
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(0,0,0,0.02);
}
.match-result-card.highlight {
  background: rgba(43,181,178,0.06);
  border: 1px solid rgba(43,181,178,0.15);
}
.match-result-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-secondary, #888);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}
.match-result-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text, #1e1e1e);
}
.match-result-value.accent { color: #2bb5b2; }
.match-result-value.warning { color: #e65100; }
.match-tip {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(43,181,178,0.06);
  font-size: 13px;
  color: var(--color-text, #333);
  line-height: 1.5;
}
.match-tip strong { color: #2bb5b2; }

/* Start Now vs Wait Results */
.start-vs-wait-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.start-vs-wait-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-secondary, #888);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.start-vs-wait-table td {
  padding: 8px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}
.start-vs-wait-table tr:first-child td {
  font-weight: 600;
  background: rgba(43,181,178,0.04);
}
.start-vs-wait-table .cost-cell {
  color: #c62828;
  font-weight: 600;
}
.start-vs-wait-table .now-label {
  color: #2bb5b2;
  font-weight: 600;
}
.cost-summary {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(198,40,40,0.05);
  font-size: 13px;
  color: #c62828;
  line-height: 1.5;
}

/* Carry-over toggle checkbox */
.carry-over-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-top: 8px;
  background: linear-gradient(135deg, #e0f7f5 0%, #e8f5e9 100%);
  border: 1px solid #b2dfdb;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: #2e7d6f;
  font-weight: 500;
  transition: background 0.2s, border-color 0.2s;
  user-select: none;
}
.carry-over-toggle:hover {
  background: linear-gradient(135deg, #d0f0ed 0%, #dcedc8 100%);
  border-color: #80cbc4;
}
.carry-over-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #2bb5b2;
  cursor: pointer;
  flex-shrink: 0;
}
.carry-over-toggle span {
  line-height: 1.3;
}

/* Catch-Up Contribution Planner */
.catchup-limits-table {
  background: rgba(43, 181, 178, 0.06);
  border: 1px solid rgba(43, 181, 178, 0.15);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
}
.catchup-limits-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #2bb5b2;
  margin-bottom: 6px;
}
.catchup-limits-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 13px;
  gap: 8px;
}
.catchup-limits-label {
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
}
.catchup-limits-detail {
  color: #6b7280;
  text-align: right;
}
.catchup-super-note {
  font-size: 12px;
  color: #d97706;
  font-weight: 500;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(43, 181, 178, 0.12);
}
.catchup-note {
  background: rgba(249, 196, 42, 0.1);
  border: 1px solid rgba(249, 196, 42, 0.25);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: #92400e;
  margin-bottom: 12px;
}
.catchup-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin: 10px 0;
}
.catchup-kpi {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
}
.catchup-kpi-value {
  font-size: 16px;
  font-weight: 700;
  color: #1f2937;
}
.catchup-kpi-label {
  font-size: 11px;
  color: #6b7280;
  margin-top: 2px;
}
.catchup-kpi-highlight {
  background: rgba(43, 181, 178, 0.08);
  border-color: rgba(43, 181, 178, 0.25);
}
.catchup-kpi-highlight .catchup-kpi-value {
  color: #2bb5b2;
}
.catchup-detail summary {
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  padding: 6px 0;
}
.catchup-detail summary:hover {
  color: #2bb5b2;
}
.catchup-table {
  width: 100%;
  font-size: 12px;
  border-collapse: collapse;
  margin-top: 6px;
}
.catchup-table th {
  background: #f3f4f6;
  padding: 6px 8px;
  text-align: left;
  font-weight: 600;
  color: #374151;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 2px solid #e5e7eb;
}
.catchup-table td {
  padding: 5px 8px;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
}
.catchup-super-row {
  background: rgba(249, 196, 42, 0.06);
}
.rmd-table-scroll {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}
.rmd-table-scroll .catchup-table th {
  position: sticky;
  top: 0;
  z-index: 1;
}

/* RMD Planner on results page */
.rmd-planner-card {
  cursor: default;
  border: 1px solid var(--color-border, #e5e7eb);
}
.rmd-planner-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.rmd-planner-summary::-webkit-details-marker { display: none; }
.rmd-planner-summary-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.rmd-planner-summary-left svg:first-child {
  color: var(--color-accent, #2bb5b2);
  flex-shrink: 0;
}
.rmd-planner-chevron {
  transition: transform 0.2s ease;
  color: var(--color-text-muted);
}
.rmd-planner-card[open] .rmd-planner-chevron {
  transform: rotate(180deg);
}
.rmd-planner-body {
  padding: 0 var(--space-5) var(--space-5);
  border-top: 1px solid var(--color-border, #e5e7eb);
  padding-top: var(--space-4);
}

/* Roth Conversion Explorer */
.roth-strategy-btns {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.roth-strategy-btn {
  background: var(--color-surface);
  border: 1px solid var(--color-border, #e5e7eb);
  color: var(--color-text);
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.roth-strategy-btn:hover {
  border-color: var(--color-accent);
  background: oklch(from var(--color-accent) l c h / 0.06);
}
.roth-strategy-btn.active {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}
.roth-ex-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.roth-ex-kpi {
  background: var(--color-surface);
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 10px;
  padding: 14px 12px;
  text-align: center;
}
.roth-ex-kpi-label {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
  font-weight: 500;
}
.roth-ex-kpi-value {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-display);
}
.roth-ex-kpi-sub {
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: 3px;
}
.roth-ex-kpi:nth-child(1) .roth-ex-kpi-value { color: var(--color-success, #22c55e); }
.roth-ex-kpi:nth-child(2) .roth-ex-kpi-value { color: var(--color-accent, #2bb5b2); }
.roth-ex-kpi:nth-child(3) .roth-ex-kpi-value { color: var(--color-primary, #3b82f6); }
.roth-ex-kpi:nth-child(4) .roth-ex-kpi-value { color: var(--color-text); }
.roth-ex-table { font-size: 12px; }
.roth-ex-table th { font-size: 11px; white-space: nowrap; }
.roth-ex-table td { padding: 5px 8px; white-space: nowrap; }
.roth-ex-irmaa-flag {
  display: inline-block;
  background: oklch(from var(--color-warning, #f59e0b) l c h / 0.15);
  color: var(--color-warning, #f59e0b);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}
.roth-ex-irmaa-alert {
  background: oklch(from var(--color-warning, #f59e0b) l c h / 0.08);
  border: 1px solid oklch(from var(--color-warning, #f59e0b) l c h / 0.2);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--color-text);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.roth-ex-irmaa-alert svg {
  color: var(--color-warning, #f59e0b);
  flex-shrink: 0;
  margin-top: 1px;
}
@media (max-width: 640px) {
  .roth-ex-kpis { grid-template-columns: repeat(2, 1fr); }
  .roth-ex-kpi-value { font-size: 16px; }
  .roth-strategy-btns { flex-direction: column; }
}

/* Goal Simulator Quick Adjust Sliders */
.sim-slider-panel {
  background: linear-gradient(135deg, oklch(0.97 0.01 180), oklch(0.97 0.01 220));
  border: 1px solid oklch(0.90 0.03 180);
  border-radius: 12px;
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-4);
}
.sim-slider-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-text);
  margin-bottom: var(--space-4);
}
.sim-slider-header svg {
  color: #2bb5b2;
}
.sim-slider-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3) var(--space-6);
}
.sim-slider-field label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}
.sim-sl-val {
  font-weight: 700;
  color: var(--color-text);
  font-size: var(--text-sm);
}
.sim-slider-field input[type="range"] {
  width: 100%;
  margin: 0;
}
@media (max-width: 640px) {
  .sim-slider-grid {
    grid-template-columns: 1fr;
  }
}

/* Spending & Withdrawal Layout */
.spending-section {
  padding: var(--space-4) var(--space-5);
  padding-bottom: 0;
}
.withdrawal-row {
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 600px) {
  .withdrawal-row { grid-template-columns: 1fr; }
}

/* Dynamic Spending Phases */
.spend-phase-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.spend-phase-range {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
  flex: 0 0 165px; /* fixed width so all rows align regardless of end-year input */
}
.spend-phase-end {
  width: 52px;
  padding: 4px 6px;
  font-size: var(--text-xs);
  border: 1px solid var(--color-border, #d1d5db);
  border-radius: 6px;
  text-align: center;
  background: #fff;
}
.spend-phase-row .input-with-prefix {
  flex: 1;
  min-width: 0;
  max-width: none;
}
.spend-phase-row .input-sm {
  flex: 1;
  min-width: 0;
  max-width: none;
}
.spend-phase-row .input-with-prefix input {
  min-width: 50px;
  width: 100%;
}
.spend-phase-remainder {
  font-style: italic;
}
.spend-phase-remove {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--color-text-muted);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
}
.spend-phase-remove:hover {
  color: var(--color-error, #ef4444);
  background: oklch(from var(--color-error, #ef4444) l c h / 0.08);
}

/* ========== FIELD HELP TOOLTIPS ========== */
.field-help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--color-border, #d0d5dd);
  background: transparent;
  color: var(--color-text-muted, #6b7280);
  cursor: pointer;
  padding: 0;
  margin-left: 5px;
  vertical-align: middle;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-body, sans-serif);
  line-height: 1;
  transition: all 0.15s ease;
  position: relative;
  flex-shrink: 0;
}
.field-help-btn:hover {
  border-color: var(--color-accent, #2a9d8f);
  color: var(--color-accent, #2a9d8f);
  background: oklch(from var(--color-accent, #2a9d8f) l c h / 0.08);
}
.field-help-btn.active {
  border-color: var(--color-accent, #2a9d8f);
  color: #fff;
  background: var(--color-accent, #2a9d8f);
}
.field-help-popover {
  display: none;
  position: fixed;
  z-index: 1000;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #d0d5dd);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--color-text, #1a1a1a);
  max-width: 340px;
  min-width: 220px;
  width: max-content;
  word-wrap: break-word;
  animation: fieldHelpFadeIn 0.15s ease;
}
.field-help-popover.show { display: block; }
@keyframes fieldHelpFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.field-help-popover strong {
  color: var(--color-text, #1a1a1a);
  font-weight: 600;
}
.field-help-popover .fh-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--color-accent, #2a9d8f);
}
.field-help-popover .fh-body {
  font-size: 12.5px;
  color: var(--color-text-muted, #6b7280);
}
.field-help-popover .fh-advisor-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--color-accent, #2a9d8f);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ========== HEALTHCARE SUMMARY CARD ========== */
.healthcare-summary-card {
  background: color-mix(in oklch, #00897b 8%, var(--color-surface));
  border: 1px solid color-mix(in oklch, #00897b 25%, transparent);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.healthcare-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.healthcare-summary-label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.healthcare-summary-value {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums lining-nums;
  color: #00897b;
}
.healthcare-irmaa-warning {
  font-size: var(--text-xs);
  color: #e65100;
  background: color-mix(in oklch, #ff9800 12%, transparent);
  border: 1px solid color-mix(in oklch, #ff9800 30%, transparent);
  border-radius: var(--radius-md);
  padding: var(--space-1) var(--space-2);
  margin-top: var(--space-1);
}

/* ========== SCENARIO COMPARISON OVERLAY ========== */
#scenario-compare-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  overflow-y: auto;
}
.scenario-compare-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  max-width: 960px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
}
.scenario-compare-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-divider);
  position: sticky;
  top: 0;
  background: var(--color-surface);
  z-index: 1;
}
.scenario-compare-header h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}
.scenario-compare-body {
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}
.scenario-compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.scenario-compare-table thead tr {
  background: var(--color-surface-offset);
}
.scenario-compare-table th {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  border-bottom: 2px solid var(--color-divider);
}
.scenario-compare-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-divider);
  font-variant-numeric: tabular-nums lining-nums;
}
.scenario-compare-table td.scenario-compare-kpi-label {
  font-weight: 500;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}
.scenario-compare-table tbody tr:nth-child(even) {
  background: var(--color-surface-offset);
}
.scenario-compare-best {
  background: #e8f5e9 !important;
  color: #1b5e20;
  font-weight: 600;
}
.scenario-compare-worst {
  background: #fff8e1 !important;
  color: #e65100;
}
.scenario-compare-chart-wrap {
  height: 260px;
  position: relative;
}
.scenario-compare-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-divider);
}
.scenario-compare-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.scenario-compare-label {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  cursor: pointer;
  white-space: nowrap;
}
.scenario-compare-label input[type="checkbox"] {
  cursor: pointer;
}

/* Dark mode adjustments for comparison */
@media (prefers-color-scheme: dark) {
  .scenario-compare-best {
    background: color-mix(in oklch, #4caf50 18%, var(--color-surface)) !important;
    color: #a5d6a7;
  }
  .scenario-compare-worst {
    background: color-mix(in oklch, #ff9800 15%, var(--color-surface)) !important;
    color: #ffcc80;
  }
  .healthcare-summary-value {
    color: #4db6ac;
  }
  .healthcare-summary-card {
    border-color: color-mix(in oklch, #4db6ac 30%, transparent);
  }
}

/* Mobile: horizontal scroll for comparison table */
@media (max-width: 600px) {
  .scenario-compare-body {
    overflow-x: auto;
    padding: var(--space-3);
  }
  .scenario-compare-table {
    min-width: 480px;
  }
}

/* ========== STRATEGY COMPARISON STEPS ========== */
.strat-compare-step {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  transition: opacity 0.3s;
}
.strat-compare-step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.strat-compare-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: oklch(0.55 0.15 250);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}
.strat-compare-step-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text);
}
.strat-compare-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--color-text-muted);
  font-weight: 500;
}
.strat-compare-pick-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.strat-compare-pick-empty {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  background: var(--color-bg);
  border-radius: 8px;
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.5;
}
.strat-compare-pick-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--color-bg);
  border: 2px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.strat-compare-pick-item:hover {
  background: var(--color-surface-offset, var(--color-bg));
}
.strat-compare-pick-item.selected {
  border-color: oklch(0.55 0.15 250);
  background: oklch(0.55 0.15 250 / 0.06);
}
.strat-compare-pick-item .pick-checkbox {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid var(--color-divider);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.strat-compare-pick-item.selected .pick-checkbox {
  background: oklch(0.55 0.15 250);
  border-color: oklch(0.55 0.15 250);
}
.strat-compare-pick-item .pick-checkbox svg {
  opacity: 0;
  transition: opacity 0.15s;
}
.strat-compare-pick-item.selected .pick-checkbox svg {
  opacity: 1;
}
.strat-compare-pick-info {
  flex: 1;
  min-width: 0;
}
.strat-compare-pick-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--color-text);
}
.strat-compare-pick-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 3px;
}
.strat-compare-pick-tag {
  font-size: 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--color-text-muted);
}
.strat-compare-pick-badge {
  font-size: 10px;
  background: oklch(0.55 0.15 250 / 0.12);
  color: oklch(0.45 0.15 250);
  border-radius: 4px;
  padding: 1px 6px;
  font-weight: 600;
}
.strat-compare-snapshot-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-top: 4px;
  border-top: 1px solid var(--color-divider);
}
[data-theme="dark"] .strat-compare-pick-item.selected {
  background: oklch(0.55 0.15 250 / 0.12);
}
[data-theme="dark"] .strat-compare-pick-badge {
  background: oklch(0.55 0.15 250 / 0.2);
  color: oklch(0.70 0.15 250);
}

/* ========== TOAST NOTIFICATIONS ========== */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 24px oklch(from var(--color-text) l c h / 0.15);
  background: var(--color-surface);
  border: 1px solid oklch(from var(--color-text) l c h / 0.1);
  max-width: 380px;
  font-size: var(--text-sm);
  line-height: 1.5;
  animation: toastIn 0.3s ease-out;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.toast-exiting {
  opacity: 0;
  transform: translateX(20px);
}
.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}
.toast-success .toast-icon { color: var(--color-success); }
.toast-error .toast-icon { color: var(--color-error); }
.toast-warning .toast-icon { color: #e8a735; }
.toast-info .toast-icon { color: var(--color-primary); }
.toast-body {
  flex: 1;
  color: var(--color-text);
}
.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 0;
  line-height: 1;
}
.toast-close:hover { color: var(--color-text); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@media (max-width: 640px) {
  .toast-container {
    top: auto;
    bottom: var(--space-4);
    right: var(--space-3);
    left: var(--space-3);
  }
  .toast { max-width: 100%; }
}

/* ========== SUBSCRIPTION BANNER ========== */
.sub-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9000;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  text-align: center;
  animation: bannerSlide 0.3s ease-out;
}
.sub-banner.sub-banner-grace {
  background: linear-gradient(135deg, #fff3e0, #ffe0b2);
  color: #7a4a00;
  border-bottom: 1px solid #e8a735;
}
.sub-banner.sub-banner-expired {
  background: linear-gradient(135deg, #ffebee, #ffcdd2);
  color: #8b1a1a;
  border-bottom: 1px solid #ef5350;
}
.sub-banner-content {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.sub-banner-close {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
}
.sub-banner-close:hover { opacity: 1; }
@keyframes bannerSlide {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

/* Body offset when banner is visible */
body.has-sub-banner .nav-header {
  top: 36px;
}
body.has-sub-banner .main-content {
  padding-top: 36px;
}

/* ========== ACCOUNT SETTINGS ========== */
.account-section {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid oklch(from var(--color-text) l c h / 0.08);
}
.account-section-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-3);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.account-sub-card {
  background: oklch(from var(--color-primary) l c h / 0.06);
  border: 1px solid oklch(from var(--color-primary) l c h / 0.12);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}
.account-sub-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-1) 0;
}
.account-sub-row + .account-sub-row {
  border-top: 1px solid oklch(from var(--color-text) l c h / 0.06);
}
.account-sub-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.account-sub-value {
  font-size: var(--text-sm);
  font-weight: 600;
}
.account-divider {
  margin: var(--space-5) 0;
  border-top: 1px solid oklch(from var(--color-text) l c h / 0.08);
}
.auth-success {
  color: var(--color-success);
  font-size: var(--text-xs);
  margin: var(--space-2) 0;
}

/* Plan selection cards in account panel */
.acct-plans {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}
@media (max-width: 600px) {
  .acct-plans {
    grid-template-columns: 1fr;
  }
}
.acct-plan-card {
  position: relative;
  border: 2px solid oklch(from var(--color-text) l c h / 0.1);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  text-align: center;
  transition: border-color var(--transition-interactive), box-shadow var(--transition-interactive);
}
.acct-plan-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 2px 12px oklch(from var(--color-primary) l c h / 0.12);
}
.acct-plan-featured {
  border-color: var(--color-primary);
  background: oklch(from var(--color-primary) l c h / 0.04);
}
.acct-plan-badge {
  position: absolute;
  top: -10px;
  right: var(--space-3);
  background: var(--color-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.03em;
}
.acct-plan-top {
  margin-bottom: var(--space-2);
}
.acct-plan-name {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-1);
}
.acct-plan-price {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
}
.acct-plan-period {
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--color-text-muted);
}
.acct-plan-btn {
  width: 100%;
  margin-top: var(--space-2);
}
.acct-plan-note {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: oklch(from var(--color-primary) l c h / 0.06);
  border-radius: var(--radius-sm);
}
.acct-plan-active {
  border-color: var(--color-success);
  background: oklch(from var(--color-success) l c h / 0.05);
}
.acct-plan-active .acct-plan-btn {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
  pointer-events: none;
}

/* ========== FEEDBACK WIDGET ========== */
.feedback-fab {
  position: fixed;
  bottom: var(--space-4);
  left: var(--space-4);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  transition: background 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}
.feedback-fab:hover {
  background: var(--color-primary-hover);
  transform: scale(1.08);
  box-shadow: var(--shadow-lg);
}
.feedback-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 10001;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: var(--space-4);
}
.feedback-panel {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  border: 1px solid var(--color-divider);
}
.feedback-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-divider);
}
.feedback-header h3 {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
}
.feedback-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  cursor: pointer;
  border: none;
  transition: background 150ms ease;
}
.feedback-close:hover {
  background: var(--color-surface-offset);
}
.feedback-body {
  padding: var(--space-5);
}
.feedback-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
  line-height: 1.6;
}
.feedback-field {
  margin-bottom: var(--space-4);
}
.feedback-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: var(--space-1);
  color: var(--color-text);
}
.feedback-field select,
.feedback-field textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  background: var(--color-surface);
  color: var(--color-text);
  resize: vertical;
  transition: border-color 150ms ease;
}
.feedback-field select:focus,
.feedback-field textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-highlight);
}
.feedback-field textarea {
  min-height: 100px;
}
.feedback-error {
  font-size: 13px;
  color: var(--color-error);
  margin-bottom: var(--space-3);
}
.feedback-success {
  font-size: 13px;
  color: var(--color-success);
  margin-bottom: var(--space-3);
}

@media (max-width: 480px) {
  .feedback-overlay {
    align-items: flex-end;
    justify-content: center;
    padding: 0;
  }
  .feedback-panel {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-width: 100%;
  }
}

/* ===================== PROFILE PAGE ===================== */
.profile-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}
.profile-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5ba3d9 0%, #4ecdc4 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
}
.profile-card-meta h3 {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 2px 0;
}
.profile-member-since {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0;
}
.profile-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.profile-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}
.profile-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}
.profile-field input,
.profile-field select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 150ms ease;
  box-sizing: border-box;
}
.profile-field input:focus,
.profile-field select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-highlight);
}
.profile-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
}
.profile-save-status {
  font-size: var(--text-sm);
  color: var(--color-success);
  transition: opacity 200ms ease;
}

/* Saved Data Dashboard */
.profile-dashboard {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}
.profile-dash-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 var(--space-2) 0;
}
.profile-dash-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-5) 0;
}
.profile-slot-group {
  margin-bottom: var(--space-5);
}
.profile-slot-group:last-child {
  margin-bottom: 0;
}
.profile-slot-group-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 var(--space-2) 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.profile-slot-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.profile-slot-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.profile-slot-empty {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-style: italic;
  margin: 0;
  padding: var(--space-2) 0;
}
.profile-slot-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease, opacity 200ms ease, transform 200ms ease;
}
.profile-slot-item:hover {
  border-color: var(--color-primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.profile-slot-item-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}
.profile-slot-item-meta {
  font-size: 12px;
  color: var(--color-text-muted);
}
.profile-slot-item-arrow {
  font-size: 14px;
  color: var(--color-text-muted);
  transition: transform 150ms ease;
}
.profile-slot-item-info {
  flex: 1;
  min-width: 0;
}
.profile-slot-item-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
.profile-slot-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
  padding: 0;
}
.profile-slot-delete:hover {
  background: #fde8e8;
  color: #c53030;
}
.dark-mode .profile-slot-delete:hover {
  background: rgba(197, 48, 48, 0.2);
  color: #fc8181;
}
.profile-slot-item:hover .profile-slot-item-arrow {
  transform: translateX(2px);
  color: var(--color-primary);
}
.profile-slot-confirm {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) 0 0 0;
  margin-top: var(--space-2);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.profile-slot-confirm span {
  flex: 1;
}
.profile-slot-confirm-yes {
  padding: 4px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: #c53030;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease;
}
.profile-slot-confirm-yes:hover {
  background: #9b2c2c;
}
.profile-slot-confirm-no {
  padding: 4px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease;
}
.profile-slot-confirm-no:hover {
  background: var(--color-surface);
}

/* Quick Links */
.profile-quick-links {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* Mobile responsive */
@media (max-width: 600px) {
  .profile-row {
    grid-template-columns: 1fr;
  }
  .profile-card {
    padding: var(--space-4);
  }
  .profile-dashboard {
    padding: var(--space-4);
  }
  .profile-avatar {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }
}

/* ========== SCENARIO ACTIVE BAR (Save / Save As / New) ========== */
.scenario-active-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-alt);
  border-radius: 8px;
  border: 1px solid var(--color-border);
  flex-wrap: wrap;
}
.scenario-active-name {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  min-width: 0;
}
.scenario-active-name svg {
  flex-shrink: 0;
  color: var(--color-primary);
}
.scenario-active-name span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scenario-active-actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}
@media (max-width: 480px) {
  .scenario-active-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .scenario-active-actions {
    justify-content: flex-end;
  }
}

/* ========== INVESTMENT STRATEGY PLANNER ========== */
.strat-waterfall {
  margin-top: var(--space-4);
}
.strat-waterfall-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: var(--space-3);
  color: var(--color-text);
}
.strat-bucket {
  margin-bottom: var(--space-4);
}
.strat-bucket-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.strat-bucket-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.strat-bucket-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text);
}
.strat-bucket-amount {
  margin-left: auto;
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text);
  white-space: nowrap;
}
.strat-bucket-bar {
  height: 8px;
  background: var(--color-surface-alt);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}
.strat-bucket-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 400ms ease;
}
.strat-bucket-note {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* Asset Allocation Bar */
.strat-alloc {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}
.strat-alloc-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: var(--space-3);
  color: var(--color-text);
}
.strat-alloc-bar {
  display: flex;
  height: 28px;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: var(--space-2);
}
.strat-alloc-seg {
  transition: width 400ms ease;
  min-width: 2%;
}
.strat-alloc-legend {
  display: flex;
  gap: var(--space-4);
  font-size: 13px;
  color: var(--color-text-muted);
  flex-wrap: wrap;
}
.strat-leg-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}
.strat-alloc-hint {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-alt);
  border-radius: 6px;
  line-height: 1.5;
}

/* ========== SCRATCHPAD ========== */
.scratchpad-fab {
  position: fixed;
  bottom: calc(var(--space-4) + 56px);
  left: var(--space-4);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: oklch(0.50 0.12 250);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  transition: background 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}
.scratchpad-fab:hover {
  background: oklch(0.45 0.14 250);
  transform: scale(1.08);
  box-shadow: var(--shadow-lg);
}
.scratchpad-fab.active {
  background: oklch(0.42 0.14 250);
  box-shadow: 0 0 0 3px oklch(0.50 0.12 250 / 0.3);
}
.scratchpad-panel {
  position: fixed;
  right: -380px;
  top: 50%;
  transform: translateY(-50%);
  width: 340px;
  max-height: 70vh;
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 16px;
  box-shadow: var(--shadow-xl);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  transition: right 280ms cubic-bezier(0.4, 0, 0.2, 1);
}
.scratchpad-panel.open {
  right: var(--space-4);
}
.scratchpad-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-divider);
  font-size: var(--text-sm);
}
.scratchpad-textarea {
  flex: 1;
  min-height: 260px;
  padding: 14px 16px;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.7;
  color: var(--color-text);
  background: transparent;
}
.scratchpad-textarea::placeholder {
  color: var(--color-text-muted);
  font-style: italic;
}
.scratchpad-footer {
  padding: 8px 16px;
  border-top: 1px solid var(--color-divider);
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

@media (max-width: 600px) {
  .scratchpad-panel {
    width: calc(100vw - 32px);
    right: -100vw;
    max-height: 55vh;
  }
  .scratchpad-panel.open {
    right: 16px;
  }
}

/* ========== INSIGHTS ENGINE ========== */
.insights-panel {
  margin: var(--space-4) 0;
}
.insights-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}
.insights-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-text);
}
.insights-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--color-primary);
  color: white;
  font-size: 11px;
  font-weight: 600;
}
.insights-dismiss-all {
  background: none;
  border: none;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.insights-dismiss-all:hover {
  background: var(--color-surface-raised);
  color: var(--color-text);
}
.insights-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.insight-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: 1.5;
  transition: opacity 0.25s, transform 0.25s;
  position: relative;
}
.insight-card.insight-info {
  background: rgba(59, 130, 246, 0.08);
  border-left: 3px solid rgba(59, 130, 246, 0.5);
  color: var(--color-text);
}
.insight-card.insight-attention {
  background: rgba(245, 158, 11, 0.08);
  border-left: 3px solid rgba(245, 158, 11, 0.6);
  color: var(--color-text);
}
.insight-card.insight-positive {
  background: rgba(34, 197, 94, 0.08);
  border-left: 3px solid rgba(34, 197, 94, 0.5);
  color: var(--color-text);
}
.insight-icon {
  flex-shrink: 0;
  margin-top: 1px;
}
.insight-card.insight-info .insight-icon { color: #3b82f6; }
.insight-card.insight-attention .insight-icon { color: #f59e0b; }
.insight-card.insight-positive .insight-icon { color: #22c55e; }
.insight-content {
  flex: 1;
}
.insight-dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0 var(--space-1);
  opacity: 0.5;
  transition: opacity 0.15s;
}
.insight-dismiss:hover {
  opacity: 1;
}

/* Dark mode adjustments */
[data-theme="dark"] .insight-card.insight-info {
  background: rgba(59, 130, 246, 0.12);
}
[data-theme="dark"] .insight-card.insight-attention {
  background: rgba(245, 158, 11, 0.12);
}
[data-theme="dark"] .insight-card.insight-positive {
  background: rgba(34, 197, 94, 0.12);
}

@media (max-width: 640px) {
  .insight-card {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
    gap: var(--space-2);
  }
}

/* ========== EMPLOYER MATCH COLLAPSIBLE ========== */
.match-details {
  margin-top: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.match-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  background: var(--color-surface-raised);
  user-select: none;
  list-style: none;
}
.match-summary::-webkit-details-marker { display: none; }
.match-summary::before {
  content: '▸';
  margin-right: var(--space-2);
  font-size: 12px;
  transition: transform 0.15s;
}
details.match-details[open] > .match-summary::before {
  transform: rotate(90deg);
}
.match-status {
  font-weight: 400;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-left: auto;
}
.match-fields {
  padding: var(--space-3);
  border-top: 1px solid var(--color-border);
}
.match-fields .form-field {
  margin-bottom: var(--space-3);
}
.match-fields .form-field:last-of-type {
  margin-bottom: 0;
}

/* ===== SPREADSHEET GRID VIEWER ===== */
.xlsx-grid-wrap {
  overflow: auto;
  max-height: 100%;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md, 6px);
  background: #fff;
}
.xlsx-grid {
  border-collapse: collapse;
  font-size: 12px;
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
  min-width: 100%;
  white-space: nowrap;
}
.xlsx-grid thead {
  position: sticky;
  top: 0;
  z-index: 2;
}
.xlsx-col-header-row {
  background: #f0f2f5;
}
.xlsx-col-header-row th {
  padding: 3px 6px;
  text-align: center;
  font-weight: 600;
  font-size: 10px;
  color: #6b7280;
  border-bottom: 2px solid #d1d5db;
  border-right: 1px solid #e5e7eb;
  letter-spacing: 0.5px;
}
.xlsx-col-letter {
  min-width: 64px;
}
.xlsx-row-num {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #f0f2f5;
  text-align: center;
  font-weight: 600;
  font-size: 10px;
  color: #6b7280;
  padding: 2px 6px;
  min-width: 38px;
  border-right: 2px solid #d1d5db;
  user-select: none;
}
.xlsx-cell {
  padding: 3px 8px;
  border-right: 1px solid #edf0f3;
  border-bottom: 1px solid #edf0f3;
  color: #1e293b;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.xlsx-hdr-cell {
  font-weight: 700;
  color: #0f172a;
}
.xlsx-label-cell {
  font-weight: 600;
  color: #334155;
}
/* Column header rows (month names, year headers) */
.xlsx-colhdr-row {
  background: #e8f4f8;
}
.xlsx-colhdr-row td.xlsx-row-num {
  background: #dbeef5;
}
.xlsx-colhdr-row .xlsx-cell {
  font-weight: 700;
  color: #0c4a6e;
  border-bottom: 2px solid #7dd3fc;
  padding-top: 5px;
  padding-bottom: 5px;
}
/* Section title rows (like "Cash In", "Total Income") */
.xlsx-section-row {
  background: #f8fafc;
}
.xlsx-section-row td.xlsx-row-num {
  background: #f0f2f5;
}
.xlsx-section-row .xlsx-cell {
  font-weight: 700;
  color: #1e40af;
  padding-top: 6px;
  padding-bottom: 6px;
  font-size: 12.5px;
  border-bottom: 1px solid #cbd5e1;
}
/* Empty separator rows */
.xlsx-empty-row {
  height: 8px;
}
.xlsx-empty-row td {
  border-bottom: none;
}
.xlsx-empty-row td.xlsx-row-num {
  background: #f0f2f5;
}
/* Alternating data rows */
.xlsx-alt-row {
  background: #f9fafb;
}
.xlsx-data-row:hover,
.xlsx-alt-row:hover {
  background: #eff6ff;
}
.xlsx-data-row:hover td.xlsx-row-num,
.xlsx-alt-row:hover td.xlsx-row-num {
  background: #dbeafe;
}
/* Truncation notice */
.xlsx-truncated {
  font-size: 11px;
  color: var(--color-text-muted);
  text-align: center;
  margin-top: 6px;
  padding: 4px;
}
/* Sheet tabs area - scrollable */
.xlsx-tabs-wrap {
  max-height: 120px;
  overflow-y: auto;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--color-divider);
  padding-bottom: 6px;
  flex-shrink: 0;
}
.xlsx-tabs-compact {
  max-height: 80px;
}
.xlsx-tabs-inner {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
/* Expanded floating panel transition */
#floating-file-panel {
  transition: all 0.25s ease;
}
.floating-panel-expanded .xlsx-tabs-wrap {
  max-height: 140px;
}
.floating-panel-expanded .xlsx-tabs-compact {
  max-height: 140px;
}

/* ========== READ-ONLY LOCK OVERLAY ========== */
body.read-only-mode .btn-primary:not(.acct-plan-btn):not(.auth-submit):not([id="auth-logout-btn"]),
body.read-only-mode .btn-secondary:not(.acct-plan-btn):not(.auth-submit):not([id="auth-logout-btn"]) {
  position: relative;
  pointer-events: none;
  opacity: 0.5;
}
body.read-only-mode .btn-primary:not(.acct-plan-btn):not(.auth-submit)::after,
body.read-only-mode .btn-secondary:not(.acct-plan-btn):not(.auth-submit)::after {
  content: "🔒";
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
}
body.read-only-mode #run-simulation-btn { pointer-events: none; opacity: 0.45; }
body.read-only-mode .spreadsheet-table tbody { opacity: 0.7; }
body.read-only-mode input:not([id^="auth-"]):not([id^="acct-"]):not([id="login-"]),
body.read-only-mode select:not([id^="auth-"]):not([id^="acct-"]) {
  pointer-events: none;
  opacity: 0.6;
}
body.read-only-mode textarea:not(#scratchpad-textarea) { pointer-events: none; opacity: 0.6; }

/* Resubscribe CTA in sub-banner */
.sub-banner-cta {
  display: inline-block;
  margin-left: 12px;
  padding: 3px 14px;
  background: white;
  color: var(--color-error);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: background 0.15s, transform 0.1s;
}
.sub-banner-cta:hover { background: #f0f0f0; transform: translateY(-1px); }

/* ========== SESSION TIMEOUT MODAL ========== */
.session-timeout-overlay {
  position: fixed;
  inset: 0;
  background: oklch(0.15 0 0 / 0.65);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
.session-timeout-modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-8) var(--space-6);
  max-width: 400px;
  width: 90vw;
  box-shadow: 0 16px 48px rgba(0,0,0,0.25);
  text-align: center;
}
.session-timeout-icon {
  width: 56px;
  height: 56px;
  background: oklch(0.92 0.03 80);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-4);
}
.session-timeout-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  margin-bottom: var(--space-2);
}
.session-timeout-text {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
  line-height: 1.5;
}
.session-timeout-countdown {
  font-size: var(--text-2xl);
  font-weight: 800;
  font-family: var(--font-display);
  color: var(--color-error);
  margin: var(--space-3) 0;
  font-variant-numeric: tabular-nums;
}
.session-timeout-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-4);
}
.session-timeout-actions .btn { flex: 1; }

/* ========== ACCOUNT SETTINGS ENHANCEMENTS ========== */
.acct-session-pref {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.acct-session-pref label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  min-width: 120px;
}
.acct-session-pref select {
  flex: 1;
  max-width: 200px;
}
.acct-danger-zone {
  margin-top: var(--space-6);
  padding: var(--space-4);
  border: 1px solid oklch(from var(--color-error) l c h / 0.25);
  border-radius: var(--radius-lg);
  background: oklch(from var(--color-error) l c h / 0.03);
}
.acct-danger-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-error);
  margin-bottom: var(--space-2);
}
.acct-danger-text {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
  line-height: 1.5;
}
.acct-delete-btn {
  background: none;
  border: 1px solid var(--color-error);
  color: var(--color-error);
  padding: var(--space-1) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all 0.15s;
}
.acct-delete-btn:hover { background: var(--color-error); color: white; }
/* ========== PROMO CODE ========== */
.acct-promo-wrap {
  margin-top: var(--space-4);
  text-align: center;
}
.acct-promo-toggle {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: var(--text-sm);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
}
.acct-promo-toggle:hover { opacity: 0.8; }
.acct-promo-form {
  margin-top: var(--space-3);
}
.acct-promo-input-row {
  display: flex;
  gap: var(--space-2);
  max-width: 320px;
  margin: 0 auto;
}
.acct-promo-input-row input {
  flex: 1;
  font-family: var(--font-mono, monospace);
  font-size: var(--text-sm);
  letter-spacing: 1px;
  text-align: center;
}
.acct-promo-error {
  color: var(--color-error);
  font-size: var(--text-xs);
  margin-top: var(--space-2);
}
.acct-promo-success {
  color: var(--color-success);
  font-size: var(--text-xs);
  margin-top: var(--space-2);
  font-weight: 600;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ========== SHOW YOUR WORK — Clickable Cells & Popover ========== */
.syw-cell {
  cursor: pointer;
  transition: background 0.15s ease;
}
.syw-cell:hover {
  background: color-mix(in oklch, var(--color-accent) 12%, transparent) !important;
}
.syw-cell-active {
  background: color-mix(in oklch, var(--color-accent) 22%, transparent) !important;
  outline: 2px solid var(--color-accent);
  outline-offset: -1px;
}

.syw-popover {
  position: fixed;
  z-index: 9999;
  width: 340px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.syw-popover.syw-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.syw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-divider);
  background: color-mix(in oklch, var(--color-accent) 8%, var(--color-surface));
  border-radius: 10px 10px 0 0;
}
.syw-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--color-text);
}
.syw-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 0 2px;
  line-height: 1;
}
.syw-close:hover {
  color: var(--color-text);
}
.syw-body {
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--color-text);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  white-space: pre-wrap;
  word-break: break-word;
}
.syw-footer {
  padding: 8px 14px;
  font-size: 11px;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-divider);
  text-align: center;
}

/* ========== STRESS TEST ========== */
.stresstest-panel {
  background: linear-gradient(135deg, oklch(0.97 0.02 70), oklch(0.97 0.01 40));
  border: 1px solid oklch(0.88 0.04 70);
  border-radius: 14px;
  padding: 0;
  margin-bottom: 20px;
  overflow: hidden;
}
[data-theme="dark"] .stresstest-panel {
  background: linear-gradient(135deg, oklch(0.22 0.02 70), oklch(0.20 0.01 40));
  border-color: oklch(0.35 0.04 70);
}
.stresstest-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid oklch(0.88 0.04 70);
}
[data-theme="dark"] .stresstest-header {
  border-color: oklch(0.35 0.04 70);
}
.stresstest-header h3 {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-warning, #b58a1b);
  margin: 0;
}
.stresstest-body {
  padding: 18px;
}
.stresstest-intro {
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.6;
  margin: 0 0 16px 0;
}

/* Scenario cards */
.st-scenarios {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (max-width: 700px) {
  .st-scenarios { grid-template-columns: 1fr; }
}
.st-scenario-card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
}
.st-scenario-card:hover {
  border-color: var(--color-warning, #b58a1b);
  box-shadow: 0 2px 12px oklch(0.6 0.1 70 / 0.15);
  transform: translateY(-1px);
}
.st-scenario-card.st-selected {
  border-color: var(--color-warning, #b58a1b);
  background: oklch(from var(--color-warning, #b58a1b) l c h / 0.07);
  box-shadow: 0 2px 12px oklch(0.6 0.1 70 / 0.2);
}
.st-card-icon {
  font-size: 24px;
  line-height: 1;
}
.st-card-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--color-text);
}
.st-card-desc {
  font-size: 11px;
  color: var(--color-text-muted);
  line-height: 1.4;
}
.st-card-pattern {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}
.st-card-actual {
  font-size: 10px;
  color: var(--color-text-muted);
  opacity: 0.7;
  margin-top: 5px;
  font-style: italic;
  line-height: 1.3;
}
.st-yr-down {
  font-size: 11px;
  font-weight: 700;
  color: #d32f2f;
  background: rgba(211, 47, 47, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
}
.st-yr-up {
  font-size: 11px;
  font-weight: 700;
  color: #2e7d32;
  background: rgba(46, 125, 50, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Stress test results */
.st-results-header {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--color-text);
}
.st-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
@media (max-width: 600px) {
  .st-kpi-row { grid-template-columns: 1fr; }
}
.st-kpi {
  background: var(--color-surface);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  border: 1px solid var(--color-border);
}
.st-kpi-crash {
  border-color: #d32f2f;
  background: rgba(211, 47, 47, 0.04);
}
.st-kpi-label {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}
.st-kpi-value {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-display);
}
.st-survival {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 14px;
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 14px;
}
.st-return-strip {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  margin-bottom: 4px;
  align-items: center;
}
.st-return-strip .st-strip-yr {
  font-size: 10px;
  padding: 3px 6px;
  border-radius: 4px;
  font-weight: 600;
  text-align: center;
  min-width: 42px;
}
.st-return-strip .st-strip-yr.st-strip-down {
  background: rgba(211, 47, 47, 0.1);
  color: #d32f2f;
}
.st-return-strip .st-strip-yr.st-strip-up {
  background: rgba(46, 125, 50, 0.1);
  color: #2e7d32;
}
.st-return-strip .st-strip-yr.st-strip-normal {
  background: var(--color-surface);
  color: var(--color-text-muted);
}
.st-return-strip .st-strip-label {
  font-size: 9px;
  color: var(--color-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 4px;
}

/* Stress test comparison table */
.st-table-wrap {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--color-border);
}
.st-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.st-table-wrap th {
  background: var(--color-surface);
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 8px 10px;
  text-align: right;
  border-bottom: 2px solid var(--color-border);
  position: sticky;
  top: 0;
}
.st-table-wrap th:first-child,
.st-table-wrap td:first-child {
  text-align: left;
}
.st-table-wrap td {
  padding: 6px 10px;
  text-align: right;
  border-bottom: 1px solid var(--color-divider, var(--color-border));
}
.st-table-wrap tr.st-crash-row {
  background: rgba(211, 47, 47, 0.04);
}
.st-table-wrap tr.st-rally-row {
  background: rgba(46, 125, 50, 0.04);
}

/* Deduction type toggle */
button.deduction-toggle { transition: background 0.2s, color 0.2s; border: 1px solid var(--color-divider); }
button.deduction-toggle:not(.active) { background: var(--color-surface) !important; color: var(--color-text-muted) !important; }
button.deduction-toggle:not(.active):hover { background: var(--color-surface-alt) !important; }
button.deduction-toggle.active { background: oklch(0.45 0.15 230) !important; color: #fff !important; border-color: oklch(0.45 0.15 230) !important; }
#post-std-deduction[readonly] { background: var(--color-surface-alt); opacity: 0.7; cursor: not-allowed; }

/* Deduction range table */
.deduction-range-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs);
  margin-bottom: 6px;
}
.deduction-range-table th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  color: var(--color-text-muted);
  padding: 4px 6px;
  border-bottom: 1px solid var(--color-divider);
}
.deduction-range-table td {
  padding: 3px 4px;
  border-bottom: 1px solid oklch(from var(--color-text) l c h / 0.06);
}
.deduction-range-table input[type="number"] {
  width: 100%;
  min-width: 60px;
  padding: 4px 6px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}
.deduction-range-table input[type="number"]:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 2px var(--color-primary-highlight);
}
.deduction-range-remove {
  background: none;
  border: none;
  color: var(--color-text-faint);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}
.deduction-range-remove:hover {
  color: var(--color-error, #d32f2f);
  background: oklch(from var(--color-error, #d32f2f) l c h / 0.08);
}
.deduction-add-range-btn {
  display: inline-block;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-primary);
  background: var(--color-primary-highlight);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s;
}
.deduction-add-range-btn:hover {
  background: var(--color-primary);
  color: #fff;
}


/* ========== METRIC HELP TOOLTIPS ========== */
.metric-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid var(--color-text-muted);
  color: var(--color-text-muted);
  font-size: 8px;
  font-weight: 700;
  font-style: normal;
  line-height: 1;
  cursor: help;
  position: relative;
  margin-left: 3px;
  vertical-align: middle;
  flex-shrink: 0;
  opacity: 0.65;
  transition: opacity 0.15s;
}
.metric-help:hover {
  opacity: 1;
  border-color: var(--color-text-secondary);
  color: var(--color-text-secondary);
}
.metric-help .metric-help-tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-surface-alt, var(--color-surface));
  color: var(--color-text);
  border: 1px solid var(--color-divider);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.45;
  white-space: normal;
  width: 210px;
  text-transform: none;
  letter-spacing: normal;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 100;
  pointer-events: none;
}
.metric-help .metric-help-tip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--color-divider);
}
.metric-help:hover .metric-help-tip {
  display: block;
}
