/* ---------- Page hero ---------- */
.calc-hero { padding: var(--space-7) 0 var(--space-6); background: linear-gradient(180deg, var(--color-bg-alt) 0%, var(--color-bg) 100%); text-align: center; }
.calc-hero .eyebrow { justify-content: center; }
.calc-hero h1 { font-size: clamp(1.9rem, 1.4rem + 2vw, 2.8rem); max-width: 20ch; margin-inline: auto; }
.calc-hero .section-sub { max-width: 640px; margin-inline: auto; }

/* ---------- Disclaimer banner ---------- */
.disclaimer-banner {
  display: flex; gap: var(--space-3); align-items: flex-start;
  background: var(--color-accent-light); border: 1px solid var(--color-accent);
  border-radius: var(--radius-md); padding: var(--space-4); margin-bottom: var(--space-6);
}
.disclaimer-banner svg { flex-shrink: 0; color: var(--color-accent-dark); margin-top: 2px; }
.disclaimer-banner p { margin: 0; font-size: 0.92rem; color: var(--color-text); }
.disclaimer-banner a { color: var(--color-primary); font-weight: 600; text-decoration: underline; }

/* ---------- Tabs ---------- */
.calculators { padding: 0 0 var(--space-8); }
.calc-tabs {
  position: sticky; top: var(--header-h); z-index: 50;
  display: flex; gap: var(--space-2); overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding-top: var(--space-3); padding-bottom: var(--space-2); margin-bottom: var(--space-6);
  background: var(--color-bg); border-bottom: 1px solid var(--color-border);
  scrollbar-width: thin;
}
.calc-tab {
  display: flex; align-items: center; gap: 10px; white-space: nowrap;
  padding: 12px 18px; border: none; background: none; cursor: pointer;
  font-family: inherit; font-weight: 600; font-size: 0.95rem; color: var(--color-text-muted);
  border-bottom: 3px solid transparent; margin-bottom: -1px; min-height: 44px;
  transition: color 180ms var(--ease), border-color 180ms var(--ease);
}
.calc-tab-num {
  width: 22px; height: 22px; border-radius: 50%; background: var(--color-bg-alt); color: var(--color-text-muted);
  font-size: 0.75rem; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background 180ms var(--ease), color 180ms var(--ease);
}
.calc-tab:hover { color: var(--color-primary); }
.calc-tab.active { color: var(--color-primary); border-color: var(--color-primary); }
.calc-tab.active .calc-tab-num { background: var(--color-primary); color: #fff; }

/* ---------- Segmented toggle ---------- */
.calc-toggle {
  display: inline-flex; gap: 4px; background: var(--color-bg-alt); border: 1px solid var(--color-border);
  border-radius: 999px; padding: 4px; margin-bottom: var(--space-5);
}
.toggle-btn {
  border: none; background: none; padding: 10px 20px; border-radius: 999px;
  font-family: inherit; font-weight: 600; font-size: 0.88rem; color: var(--color-text-muted);
  cursor: pointer; min-height: 40px; transition: background 180ms var(--ease), color 180ms var(--ease);
}
.toggle-btn:hover { color: var(--color-primary); }
.toggle-btn.active { background: var(--color-primary); color: #fff; }
.toggle-btn.active:hover { color: #fff; }

/* ---------- Panels ---------- */
.calc-panel:focus { outline: none; }
.calc-intro { max-width: 760px; margin-bottom: var(--space-6); }
.calc-intro h2 { font-size: clamp(1.4rem, 1.2rem + 1vw, 1.9rem); }
.calc-grid { display: grid; grid-template-columns: 0.85fr 1.15fr; gap: var(--space-6); align-items: start; }

.calc-form {
  background: var(--color-bg-alt); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  padding: var(--space-5); position: sticky; top: calc(var(--header-h) + 16px);
}
.calc-form .form-row { margin-bottom: var(--space-4); }
.calc-form .form-row:last-child { margin-bottom: 0; }
.calc-form label { display: block; font-weight: 600; font-size: 0.88rem; margin-bottom: 6px; color: var(--color-text); }
.calc-form input[type="number"], .calc-form input[type="text"] {
  width: 100%; padding: 11px 12px; border: 1.5px solid var(--color-border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.98rem; min-height: 44px; background: var(--color-bg);
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.calc-form input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 4px var(--color-primary-light); }
.helper-text { font-size: 0.82rem; color: var(--color-text-muted); margin: -2px 0 8px; }
.assumption-line { font-size: 0.9rem; margin: 0; padding: 10px 12px; background: var(--color-primary-light); border-radius: var(--radius-sm); color: var(--color-primary-dark); }
.assumption-line strong { color: var(--color-primary-dark); }

.range-row .range-group { display: grid; grid-template-columns: 1fr 84px; gap: var(--space-3); align-items: center; }
.range-group input[type="range"] {
  width: 100%; height: 44px; background: transparent; cursor: pointer; accent-color: var(--color-primary);
}
.range-group input[type="number"] { text-align: center; padding: 11px 6px; }

/* ---------- Results ---------- */
.calc-results { min-width: 0; }
.result-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); margin-bottom: var(--space-4); }
.result-cols.single-card { grid-template-columns: 1fr; }
.result-cols.single-card .result-card { max-width: 480px; }
.result-card {
  background: var(--color-bg); border: 1.5px solid var(--color-border); border-radius: var(--radius-md);
  padding: var(--space-4);
}
.result-card-primary { border-color: var(--color-primary); box-shadow: 0 0 0 1px var(--color-primary); }
.result-card h3 { font-size: 1rem; margin-bottom: var(--space-3); font-family: var(--font-body); font-weight: 700; }
.result-card dl { margin: 0; }
.result-card dl > div { display: flex; justify-content: space-between; gap: var(--space-3); padding: 8px 0; border-bottom: 1px dashed var(--color-border); }
.result-card dl > div:last-child { border-bottom: none; }
.result-card dt { color: var(--color-text-muted); font-size: 0.88rem; }
.result-card dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.result-card .highlight-row dt, .result-card .highlight-row dd { color: var(--color-primary-dark); font-size: 1.05rem; }

.result-banner {
  background: var(--color-primary-dark); color: #fff; border-radius: var(--radius-md);
  padding: var(--space-4); font-size: 0.98rem; line-height: 1.6;
}
.result-banner strong { color: var(--color-accent); font-variant-numeric: tabular-nums; }
.result-note {
  font-size: 0.88rem; color: var(--color-text); background: var(--color-accent-light);
  border-radius: var(--radius-sm); padding: 12px 14px; margin: var(--space-3) 0 0;
}

/* ---------- Longevity table ---------- */
.longevity-section { margin-top: var(--space-5); }
.longevity-section h3 { font-size: 1rem; margin-bottom: 6px; }
.longevity-section .helper-text { margin-bottom: var(--space-3); }
.longevity-table-wrap { max-height: 340px; overflow-y: auto; }
.longevity-table-wrap thead th { position: sticky; top: 0; z-index: 1; }
.calc-table tbody tr.row-current { background: var(--color-primary-light); }
.calc-table tbody tr.row-current td { font-weight: 700; color: var(--color-primary-dark); }

/* ---------- Chart & table ---------- */
.calc-chart-wrap { margin-top: var(--space-5); }
.calc-chart-wrap svg { display: block; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.chart-legend { display: flex; gap: var(--space-4); margin-top: var(--space-2); font-size: 0.85rem; color: var(--color-text-muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend-dot-primary { background: var(--color-primary); }
.legend-dot-muted { background: #A0AEC0; }

.calc-table-wrap { margin-top: var(--space-5); overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.calc-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.calc-table caption { text-align: left; font-weight: 700; padding: 12px 14px; background: var(--color-bg-alt); }
.calc-table th, .calc-table td { padding: 10px 14px; text-align: right; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.calc-table th:first-child, .calc-table td:first-child { text-align: left; }
.calc-table thead th { background: var(--color-bg-alt); font-weight: 700; }
.calc-table tbody tr:last-child td { border-bottom: none; }
.calc-table tbody tr:nth-child(even) { background: var(--color-bg-alt); }

/* ---------- Calculator disclaimer ---------- */
.calc-disclaimer { margin-top: var(--space-6); padding: var(--space-4) var(--space-5); background: var(--color-bg-alt); border-radius: var(--radius-md); border: 1px solid var(--color-border); }
.calc-disclaimer h4 { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); margin-bottom: var(--space-3); font-family: var(--font-body); }
.calc-disclaimer ul { display: flex; flex-direction: column; gap: 8px; }
.calc-disclaimer li { position: relative; padding-left: 18px; font-size: 0.85rem; color: var(--color-text-muted); }
.calc-disclaimer li::before { content: "\2022"; position: absolute; left: 4px; color: var(--color-accent-dark); }

/* ---------- CTA ---------- */
.calc-cta { padding: var(--space-7) 0; background: var(--color-primary-dark); color: #fff; }
.calc-cta-inner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); flex-wrap: wrap; }
.calc-cta h2 { color: #fff; font-size: clamp(1.4rem, 1.2rem + 1vw, 1.9rem); }
.calc-cta p { color: rgba(255,255,255,0.8); max-width: 52ch; margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .calc-grid { grid-template-columns: 1fr; }
  .calc-form { position: static; }
}

@media (max-width: 640px) {
  .result-cols { grid-template-columns: 1fr; }
  .range-row .range-group { grid-template-columns: 1fr 72px; }
  .calc-cta-inner { flex-direction: column; align-items: flex-start; }

  .calc-tabs {
    flex-direction: column; align-items: stretch; overflow-x: visible; gap: 2px;
    padding-top: var(--space-2); border-bottom: none;
  }
  .calc-tab {
    justify-content: flex-start; width: 100%; padding: 12px 14px;
    border-bottom: none; border-left: 3px solid transparent; margin-bottom: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  }
  .calc-tab.active { background: var(--color-primary-light); border-left-color: var(--color-primary); }
}
