/* ============================================================
   Jesse's Loan Lab — styles.css
   Brand palette derived from NuWave Lending (nuwavelending.com)
   Primary: Indigo hsl(240,49%,40%)
   Secondary: Purple hsl(271,53%,37%)
   Accent: Mint hsl(150,100%,85%)
   ============================================================ */

:root {
  --primary:          hsl(240, 49%, 40%);
  --primary-dark:     hsl(240, 49%, 26%);
  --primary-light:    hsl(240, 49%, 55%);
  --secondary:        hsl(271, 53%, 37%);
  --secondary-light:  hsl(271, 45%, 52%);
  --accent:           hsl(150, 100%, 85%);
  --accent-dark:      hsl(150, 55%, 38%);
  --gradient-hero:    linear-gradient(135deg, hsl(240, 49%, 40%) 0%, hsl(271, 53%, 46%) 100%);
  --background:       #ffffff;
  --foreground:       hsl(240, 10%, 14%);
  --muted:            hsl(220, 18%, 96%);
  --muted-fg:         hsl(220, 10%, 46%);
  --border:           hsl(220, 13%, 89%);
  --card-shadow:      0 4px 24px -4px rgba(28, 28, 80, 0.11);
  --card-shadow-lg:   0 8px 40px -6px rgba(28, 28, 80, 0.18);
  --radius:           12px;
  --radius-sm:        8px;
  --radius-lg:        18px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--foreground);
  background: var(--background);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
em { font-style: normal; }
strong { font-weight: 700; }

/* ─── Layout ─────────────────────────────────────────────── */
.container { max-width: 1220px; margin: 0 auto; padding: 0 24px; }

/* ─── Header / Nav ───────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 200;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 8px rgba(0,0,0,0.04);
}
.nav { display: flex; align-items: center; gap: 28px; height: 68px; }

.logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 1.1rem; color: var(--foreground);
  flex-shrink: 0; letter-spacing: -0.01em;
}
.logo em { color: var(--secondary); }

.nav-links { display: flex; align-items: center; gap: 2px; flex: 1; }

.nav-link {
  padding: 7px 13px; border-radius: var(--radius-sm);
  color: var(--muted-fg); font-size: 0.88rem; font-weight: 500; transition: all 0.15s;
}
.nav-link:hover { background: var(--muted); color: var(--foreground); }

.nav-dropdown { position: relative; }
.nav-btn {
  padding: 7px 13px; border-radius: var(--radius-sm);
  background: none; border: none; color: var(--muted-fg);
  font-size: 0.88rem; font-weight: 500; cursor: pointer; font-family: inherit;
  transition: all 0.15s; display: flex; align-items: center; gap: 4px;
}
.nav-btn:hover { background: var(--muted); color: var(--foreground); }
.chevron { font-size: 0.7em; transition: transform 0.2s; }
.nav-dropdown:hover .chevron { transform: rotate(180deg); }

.dropdown-menu {
  display: none; opacity: 0;
  position: absolute; top: calc(100% + 4px); left: 0;
  background: white; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px 16px; box-shadow: var(--card-shadow-lg);
  min-width: 560px; gap: 0;
  transition: opacity 0.14s ease;
  pointer-events: none;
}
/* Thin accent line at top of menu */
.dropdown-menu::before {
  content: ''; display: block; position: absolute;
  top: 0; left: 16px; right: 16px; height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 2px;
}
/* CSS-only hover fallback (works even without JS) */
.nav-dropdown:hover .dropdown-menu {
  display: flex; opacity: 1; pointer-events: auto;
}
/* JS-controlled open state */
.nav-dropdown.open .dropdown-menu {
  display: flex; opacity: 1; pointer-events: auto;
}
.nav-dropdown.open .nav-btn,
.nav-dropdown.open .nav-btn:hover {
  background: var(--muted); color: var(--foreground);
}
/* Invisible hover bridge between button and menu — fills the 4px gap */
.nav-dropdown.open .dropdown-menu::after {
  content: ''; position: absolute; top: -8px; left: 0; right: 0; height: 8px;
}
.dropdown-cols { display: flex; gap: 8px; width: 100%; padding-top: 10px; }
.dropdown-section { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.dropdown-label {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted-fg);
  margin-bottom: 4px; padding: 0 10px 6px;
  border-bottom: 1px solid var(--border);
}
.dropdown-menu a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  font-size: 0.87rem; font-weight: 500; color: var(--foreground);
  transition: all 0.12s; line-height: 1.2;
}
.dropdown-menu a .dd-icon {
  flex-shrink: 0; width: 26px; display: flex; align-items: center; justify-content: center;
  opacity: 0.75;
}
.dropdown-menu a .dd-icon svg { display: block; color: inherit; }
.dropdown-menu a .dd-label { flex: 1; }
.dropdown-menu a:hover {
  background: hsl(240, 49%, 96%); color: var(--primary);
  transform: translateX(2px);
}
.dropdown-menu a:hover .dd-icon { opacity: 1; }

.mobile-menu-btn {
  display: none; background: none; border: none;
  font-size: 1.4rem; cursor: pointer; color: var(--foreground);
  margin-left: auto; padding: 4px 8px; line-height: 1;
}
.mobile-menu {
  display: none; flex-direction: column; padding: 16px 24px 24px;
  gap: 4px; background: white; border-top: 1px solid var(--border);
}
.mobile-menu.open { display: flex; }
.mobile-menu a {
  padding: 11px 12px; border-radius: var(--radius-sm);
  font-weight: 500; color: var(--foreground); font-size: 0.95rem; transition: background 0.12s;
}
.mobile-menu a:hover { background: var(--muted); }

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 22px; border-radius: var(--radius-sm); font-weight: 600;
  font-size: 0.88rem; cursor: pointer; transition: all 0.16s;
  border: 2px solid transparent; white-space: nowrap;
  font-family: inherit; text-decoration: none; letter-spacing: -0.01em;
}
.btn-primary { background: var(--secondary); color: white; border-color: var(--secondary); }
.btn-primary:hover {
  background: var(--secondary-light); border-color: var(--secondary-light);
  transform: translateY(-1px); box-shadow: 0 5px 16px rgba(96, 44, 144, 0.38);
}
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; transform: translateY(-1px); }
.btn-secondary { background: white; color: var(--primary); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); background: hsl(240,49%,98%); }
.btn-sm { padding: 7px 14px; font-size: 0.82rem; }
.btn-full { width: 100%; }

/* ─── Hero Section ────────────────────────────────────────── */
.hero-section {
  background: var(--gradient-hero);
  padding: 52px 0 0; position: relative; overflow: hidden;
}
.hero-section::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Ccircle cx='40' cy='40' r='2'/%3E%3C/g%3E%3C/svg%3E");
}
.hero-content { text-align: center; color: white; padding-bottom: 44px; position: relative; z-index: 1; }

.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.14); color: white;
  border: 1px solid rgba(255,255,255,0.28); border-radius: 100px;
  padding: 7px 18px; font-size: 0.8rem; font-weight: 600;
  margin-bottom: 22px; backdrop-filter: blur(10px); letter-spacing: 0.02em;
}
.badge-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  flex-shrink: 0; animation: dot-pulse 2.2s ease-in-out infinite;
}
@keyframes dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(1.3); }
}

.hero-title {
  font-size: clamp(2.3rem, 5.5vw, 3.8rem); font-weight: 800;
  line-height: 1.08; margin-bottom: 18px; color: white; letter-spacing: -0.02em;
}
.hero-title em { color: var(--accent); }
.hero-subtitle { font-size: 1.05rem; opacity: 0.88; max-width: 520px; margin: 0 auto 24px; line-height: 1.65; }
.trust-badges { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.trust-badge {
  background: rgba(255,255,255,0.13); border: 1px solid rgba(255,255,255,0.22);
  color: rgba(255,255,255,0.92); padding: 6px 15px; border-radius: 100px;
  font-size: 0.8rem; font-weight: 500;
}

/* ─── Calculator Card ─────────────────────────────────────── */
.calculator-card {
  background: white; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -6px 48px rgba(28,28,80,0.18);
  display: grid; grid-template-columns: 1fr 1fr;
  position: relative; z-index: 1; margin-top: 10px; overflow: hidden;
}
.calc-inputs { padding: 36px 36px 40px; border-right: 1px solid var(--border); }
.calc-results { padding: 36px 36px 40px; background: hsl(220, 18%, 97%); }

.calc-section-title {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted-fg);
  margin: 28px 0 16px; padding-bottom: 9px; border-bottom: 1px solid var(--border);
}
.calc-section-title:first-child { margin-top: 0; }

.input-group { margin-bottom: 16px; }
.input-group label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--foreground); margin-bottom: 6px; }
.label-note { font-weight: 400; color: var(--muted-fg); font-size: 0.76rem; }

.input-with-prefix, .input-with-suffix {
  display: flex; align-items: center; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden; background: white; transition: border-color 0.15s, box-shadow 0.15s;
}
.input-with-prefix:focus-within, .input-with-suffix:focus-within {
  border-color: var(--primary); box-shadow: 0 0 0 3px hsl(240, 49%, 93%);
}
.prefix, .suffix {
  padding: 10px 13px; background: var(--muted); color: var(--muted-fg);
  font-size: 0.88rem; font-weight: 500; flex-shrink: 0; user-select: none;
}
.prefix { border-right: 1.5px solid var(--border); }
.suffix { border-left: 1.5px solid var(--border); }
.input-with-prefix input, .input-with-suffix input {
  flex: 1; border: none; outline: none; padding: 10px 12px;
  font-size: 0.93rem; font-family: inherit; color: var(--foreground);
  background: transparent; width: 100%; min-width: 0; font-weight: 500;
}

.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.slider {
  width: 100%; height: 4px; -webkit-appearance: none; appearance: none;
  background: var(--border); border-radius: 2px; outline: none; margin-top: 12px; cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary); cursor: pointer; box-shadow: 0 0 0 4px hsl(240, 49%, 92%);
}
.slider::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%; background: var(--primary); border: none; cursor: pointer;
}

.loan-amount-display {
  padding: 10px 15px; background: hsl(240, 49%, 97%);
  border: 1.5px solid hsl(240, 49%, 87%); border-radius: var(--radius-sm);
  font-size: 0.86rem; color: var(--primary-dark); margin-bottom: 16px;
}
.loan-amount-display strong { color: var(--primary); font-size: 0.95rem; }

.pmi-row { display: flex; align-items: center; gap: 16px; }
.pmi-input { flex: 0 0 120px; }
.pmi-status { display: flex; flex-direction: column; gap: 3px; }
.pmi-badge {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.03em;
  padding: 3px 11px; border-radius: 100px; display: inline-block;
}
.pmi-badge.active  { background: hsl(150, 60%, 88%); color: hsl(150, 60%, 25%); }
.pmi-badge.inactive { background: var(--muted); color: var(--muted-fg); }
.pmi-note { font-size: 0.71rem; color: var(--muted-fg); }

/* ─── Results Panel ───────────────────────────────────────── */
.monthly-payment-card {
  background: var(--gradient-hero); color: white; border-radius: var(--radius);
  padding: 28px 24px 24px; text-align: center; margin-bottom: 18px;
  position: relative; overflow: hidden;
}
.monthly-payment-card::after {
  content: ''; position: absolute; bottom: -30px; right: -30px;
  width: 100px; height: 100px; border-radius: 50%; background: rgba(255,255,255,0.06);
}
.monthly-label {
  font-size: 0.76rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.09em; opacity: 0.82; margin-bottom: 8px;
}
.monthly-amount { font-size: 3rem; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }

.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.result-item { background: white; border-radius: var(--radius-sm); padding: 14px; border: 1.5px solid var(--border); }
.result-label { display: block; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted-fg); margin-bottom: 5px; }
.result-value { font-size: 1.05rem; font-weight: 700; color: var(--foreground); letter-spacing: -0.01em; }

.result-actions { display: flex; gap: 8px; margin-bottom: 20px; }
.action-btn {
  flex: 1; padding: 8px 8px; background: white; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 0.75rem; font-weight: 600; cursor: pointer;
  color: var(--foreground); font-family: inherit; transition: all 0.14s; white-space: nowrap;
}
.action-btn:hover { border-color: var(--primary); color: var(--primary); background: hsl(240, 49%, 98%); }
.action-btn.small { flex: 0 0 auto; padding: 6px 12px; }

/* ─── Amortization ────────────────────────────────────────── */
.amortization-section {
  background: white; border-radius: var(--radius); padding: 20px;
  border: 1.5px solid var(--border); margin-bottom: 18px;
}
.amort-title { font-size: 0.9rem; font-weight: 700; margin-bottom: 14px; color: var(--foreground); }
.amort-tabs {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border);
}
.amort-tab {
  padding: 6px 18px; border-radius: 6px; border: 1.5px solid transparent;
  background: none; font-size: 0.83rem; font-weight: 600; cursor: pointer;
  color: var(--muted-fg); font-family: inherit; transition: all 0.14s;
}
.amort-tab.active { background: var(--primary); color: white; }
.amort-tab:not(.active):hover { background: var(--muted); color: var(--foreground); }

.chart-legend {
  display: flex; gap: 18px; flex-wrap: wrap; margin-top: 14px;
  padding-top: 12px; border-top: 1px solid var(--border);
  font-size: 0.77rem; color: var(--muted-fg);
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-dot.principal { background: var(--primary); }
.legend-dot.interest  { background: var(--secondary); }
.legend-dot.balance   { background: var(--accent-dark); }
.legend-item strong { color: var(--foreground); font-weight: 600; }

.table-wrapper { max-height: 300px; overflow-y: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.amort-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.amort-table thead tr { position: sticky; top: 0; z-index: 1; }
.amort-table th {
  background: var(--muted); padding: 8px 12px; text-align: right;
  font-weight: 700; font-size: 0.69rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted-fg);
}
.amort-table th:first-child { text-align: left; }
.amort-table td { padding: 8px 12px; text-align: right; border-bottom: 1px solid hsl(220, 13%, 93%); color: var(--foreground); }
.amort-table td:first-child { text-align: left; font-weight: 600; }
.amort-table tbody tr:hover td { background: hsl(240, 49%, 98%); }
.amort-table tbody tr:last-child td { border-bottom: none; }

.cta-panel {
  background: hsl(240, 49%, 97%); border: 1.5px solid hsl(240, 49%, 87%);
  border-radius: var(--radius); padding: 20px; text-align: center;
}
.cta-panel p { font-size: 0.85rem; color: var(--muted-fg); margin-bottom: 12px; font-weight: 500; }

/* ─── Sections ────────────────────────────────────────────── */
.section { padding: 88px 0; }
.section-header { text-align: center; margin-bottom: 52px; }
.section-tag {
  display: inline-block; background: hsl(240, 49%, 95%); color: var(--primary);
  border: 1px solid hsl(240, 49%, 83%); border-radius: 100px; padding: 5px 15px;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 14px;
}
.section-header h2 {
  font-size: clamp(1.8rem, 3.5vw, 2.6rem); font-weight: 800; line-height: 1.18;
  color: var(--foreground); margin-bottom: 14px; letter-spacing: -0.02em;
}
.section-header h2 em { color: var(--secondary); }
.section-sub { font-size: 1rem; color: var(--muted-fg); max-width: 560px; margin: 0 auto; line-height: 1.65; }

/* ─── How It Works ────────────────────────────────────────── */
.how-it-works { background: var(--muted); }
.steps-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 20px; }
.step {
  background: white; border-radius: var(--radius); padding: 28px 24px;
  border: 1.5px solid var(--border); transition: box-shadow 0.15s, transform 0.15s;
}
.step:hover { box-shadow: var(--card-shadow); transform: translateY(-2px); }
.step-number {
  width: 44px; height: 44px; border-radius: 50%; background: var(--gradient-hero);
  color: white; font-size: 1.1rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center; margin-bottom: 16px;
}
.step h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 9px; color: var(--foreground); line-height: 1.35; }
.step p { font-size: 0.83rem; color: var(--muted-fg); line-height: 1.65; }

/* ─── Rates Section ───────────────────────────────────────── */
.rates-section { background: white; }
.rates-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; max-width: 800px; margin: 0 auto 24px; }
.rate-card {
  background: white; border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 32px 24px 28px; text-align: center; position: relative; transition: all 0.15s;
}
.rate-card:hover { box-shadow: var(--card-shadow); transform: translateY(-2px); }
.rate-card.featured { border-color: var(--primary); background: hsl(240, 49%, 98.5%); }
.rate-badge {
  position: absolute; top: -11px; left: 50%; transform: translateX(-50%);
  background: var(--gradient-hero); color: white; font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em; padding: 4px 14px;
  border-radius: 100px; white-space: nowrap;
}
.rate-type { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-fg); margin-bottom: 12px; }
.rate-value { font-size: 2.6rem; font-weight: 800; color: var(--primary); margin-bottom: 7px; letter-spacing: -0.02em; line-height: 1; }
.rate-change { font-size: 0.8rem; color: var(--muted-fg); }
.rate-change.loading { font-style: italic; }
.rates-disclaimer { text-align: center; font-size: 0.77rem; color: var(--muted-fg); max-width: 600px; margin: 0 auto 24px; line-height: 1.6; }
.rates-cta { text-align: center; }

/* ─── Calculators Grid ────────────────────────────────────── */
.calculators-section { background: var(--muted); }
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.calc-card {
  background: white; border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 24px 22px; display: flex; flex-direction: column; gap: 9px;
  transition: all 0.15s; cursor: pointer; text-decoration: none;
}
.calc-card:hover { border-color: var(--primary); box-shadow: var(--card-shadow); transform: translateY(-2px); }
.calc-card.featured { border-color: var(--secondary); background: linear-gradient(140deg, hsl(240, 49%, 98%) 0%, hsl(271, 53%, 97%) 100%); }
.calc-card h3 { font-size: 0.92rem; font-weight: 700; color: var(--foreground); line-height: 1.3; }
.calc-card p { font-size: 0.8rem; color: var(--muted-fg); line-height: 1.6; flex: 1; }
.calc-arrow { align-self: flex-end; font-size: 1rem; color: var(--primary); font-weight: 700; transition: transform 0.15s; }
.calc-card:hover .calc-arrow { transform: translateX(5px); }

/* ─── Explanation Section ─────────────────────────────────── */
.explanation-section { background: white; }
.explanation-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; margin-bottom: 44px; }
.explanation-card {
  padding: 28px; border: 1.5px solid var(--border); border-radius: var(--radius); transition: box-shadow 0.15s;
}
.explanation-card:hover { box-shadow: var(--card-shadow); }
.explanation-card h3 {
  font-size: 1rem; font-weight: 700; color: var(--foreground);
  margin-bottom: 14px; padding-bottom: 12px; border-bottom: 2.5px solid var(--accent); line-height: 1.3;
}
.explanation-card p { font-size: 0.86rem; color: var(--muted-fg); line-height: 1.72; margin-bottom: 10px; }
.explanation-card p:last-child { margin-bottom: 0; }
.explanation-callout {
  background: hsl(271, 50%, 96%); border-left: 3px solid var(--secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 13px 16px;
  font-size: 0.83rem; color: hsl(271, 53%, 30%); margin-top: 14px; line-height: 1.6;
}

.formula-box {
  background: hsl(240, 49%, 98%); border: 1.5px solid hsl(240, 49%, 86%);
  border-radius: var(--radius-lg); padding: 40px; text-align: center;
}
.formula-header { margin-bottom: 28px; }
.formula-header h3 { font-size: 1.3rem; font-weight: 700; margin: 10px 0 8px; color: var(--foreground); }
.formula-header p { font-size: 0.9rem; color: var(--muted-fg); }
.formula-display {
  font-size: clamp(1rem, 2.5vw, 1.35rem); font-weight: 700; color: var(--primary);
  background: white; border: 1.5px solid hsl(240, 49%, 83%); border-radius: var(--radius);
  padding: 20px 30px; display: inline-block; margin-bottom: 28px;
  font-family: 'Georgia', serif; letter-spacing: 0.03em;
}
.formula-legend { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; text-align: left; }
.formula-item {
  background: white; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 0.82rem; color: var(--muted-fg); line-height: 1.5;
}
.formula-item strong { display: block; font-size: 1.1rem; color: var(--secondary); margin-bottom: 3px; }

/* ─── FAQ ─────────────────────────────────────────────────── */
.faq-section { background: var(--muted); }
.faq-list { max-width: 740px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.faq-item { background: white; border: 1.5px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: box-shadow 0.15s; }
.faq-item:hover { box-shadow: var(--card-shadow); }
.faq-question {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px; background: none; border: none; text-align: left;
  font-size: 0.93rem; font-weight: 600; color: var(--foreground); cursor: pointer;
  font-family: inherit; transition: background 0.14s; gap: 16px; line-height: 1.4;
}
.faq-question:hover { background: hsl(240, 49%, 99%); }
.faq-icon {
  font-size: 1.4rem; color: var(--primary); flex-shrink: 0;
  transition: transform 0.22s ease; font-weight: 300; line-height: 1; width: 22px; text-align: center;
}
.faq-question.open .faq-icon { transform: rotate(45deg); }
.faq-answer { display: none; padding: 0 24px 20px; font-size: 0.87rem; color: var(--muted-fg); line-height: 1.72; }
.faq-answer.open { display: block; }
.faq-answer a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }

/* ─── Footer ──────────────────────────────────────────────── */
.footer { background: hsl(240, 45%, 11%); color: rgba(255,255,255,0.65); padding: 64px 0 36px; }
.footer-grid { display: grid; grid-template-columns: 2.2fr 1fr 1fr 1fr; gap: 44px; margin-bottom: 52px; }
.footer-brand p { font-size: 0.84rem; line-height: 1.7; margin: 16px 0 22px; color: rgba(255,255,255,0.55); }
.footer-powered { display: flex; align-items: center; gap: 10px; font-size: 0.75rem; color: rgba(255,255,255,0.45); font-weight: 500; }
.nuwave-logo { height: 30px; filter: brightness(0) invert(1) opacity(0.65); transition: filter 0.15s; }
.nuwave-logo:hover { filter: brightness(0) invert(1) opacity(0.9); }
.footer-col h4 { font-size: 0.76rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: white; margin-bottom: 18px; }
.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.footer-col a { font-size: 0.84rem; transition: color 0.14s; color: rgba(255,255,255,0.58); }
.footer-col a:hover { color: var(--accent); }
.footer-bottom { border-top: 1px solid rgba(255,255,255,0.09); padding-top: 30px; font-size: 0.77rem; color: rgba(255,255,255,0.38); display: flex; flex-direction: column; gap: 7px; line-height: 1.65; }
.footer-bottom a { color: rgba(255,255,255,0.55); transition: color 0.14s; }
.footer-bottom a:hover { color: var(--accent); }

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 1100px) {
  .calc-grid { grid-template-columns: repeat(3, 1fr); }
  .steps-grid { grid-template-columns: repeat(3, 1fr); }
  .explanation-grid { grid-template-columns: repeat(2, 1fr); }
  .formula-legend { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .calculator-card { grid-template-columns: 1fr; }
  .calc-inputs { border-right: none; border-bottom: 1px solid var(--border); }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 36px; }
  .rates-grid { grid-template-columns: 1fr; max-width: 340px; margin-left: auto; margin-right: auto; }
  .calc-grid { grid-template-columns: repeat(2, 1fr); }
  .steps-grid { grid-template-columns: repeat(2, 1fr); }
  .dropdown-menu { min-width: 360px; }
}
@media (max-width: 640px) {
  .nav-links, .nav > .btn-primary { display: none; }
  .mobile-menu-btn { display: block; }
  .hero-title { font-size: 2.1rem; }
  .hero-section { padding-top: 40px; }
  .calc-inputs, .calc-results { padding: 24px 20px; }
  .input-row { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr 1fr; }
  .result-actions { flex-wrap: wrap; }
  .action-btn { flex: 1 1 calc(50% - 4px); }
  .footer-grid { grid-template-columns: 1fr; gap: 28px; }
  .steps-grid  { grid-template-columns: 1fr; }
  .calc-grid   { grid-template-columns: 1fr; }
  .explanation-grid { grid-template-columns: 1fr; }
  .formula-legend   { grid-template-columns: 1fr 1fr; }
  .section { padding: 60px 0; }
  .formula-box { padding: 28px 20px; }
}

/* ─── Calculator Sub-Pages ────────────────────────────────── */
.calc-page-hero {
  background: var(--gradient-hero);
  padding: 32px 0 0;
  position: relative;
  overflow: hidden;
}
.calc-page-hero::before {
  content:''; position:absolute; inset:0; pointer-events:none;
  background-image:url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Ccircle cx='40' cy='40' r='2'/%3E%3C/g%3E%3C/svg%3E");
}
.breadcrumb { font-size:0.78rem; color:rgba(255,255,255,0.6); margin-bottom:14px; }
.breadcrumb a { color:rgba(255,255,255,0.6); transition:color 0.14s; }
.breadcrumb a:hover { color:white; }
.breadcrumb span { color:rgba(255,255,255,0.85); font-weight:600; }

.calc-page-header { position:relative; z-index:1; padding-bottom:36px; }
.calc-page-tag {
  display:inline-block; background:rgba(255,255,255,0.14); color:white;
  border:1px solid rgba(255,255,255,0.28); border-radius:100px; padding:5px 15px;
  font-size:0.72rem; font-weight:700; text-transform:uppercase; letter-spacing:0.08em;
  margin-bottom:14px;
}
.calc-page-title {
  font-size:clamp(1.9rem,4vw,3rem); font-weight:800; color:white;
  line-height:1.1; margin-bottom:10px; letter-spacing:-0.02em;
}
.calc-page-title em { color:var(--accent); font-style:normal; }
.calc-page-sub { font-size:0.98rem; color:rgba(255,255,255,0.84); max-width:560px; line-height:1.6; }

.calc-page-body { background:var(--muted); padding-bottom:60px; }

/* reuse .calculator-card but in sub-page context */
.calc-page-body .calculator-card {
  border-radius: var(--radius-lg);
  margin-top: 0;
  box-shadow: var(--card-shadow-lg);
}

/* Result callout — large highlighted number */
.result-callout {
  background:var(--gradient-hero); color:white; border-radius:var(--radius);
  padding:24px; text-align:center; margin-bottom:18px;
}
.result-callout-label { font-size:0.76rem; font-weight:700; text-transform:uppercase; letter-spacing:0.09em; opacity:0.82; margin-bottom:6px; }
.result-callout-value { font-size:2.6rem; font-weight:800; line-height:1; letter-spacing:-0.02em; }
.result-callout-sub { font-size:0.82rem; opacity:0.75; margin-top:6px; }

/* Comparison table (rent vs buy, refinance) */
.compare-table { width:100%; border-collapse:collapse; font-size:0.86rem; margin-top:16px; }
.compare-table th {
  background:var(--muted); padding:10px 14px; text-align:left;
  font-size:0.72rem; font-weight:700; text-transform:uppercase; letter-spacing:0.05em; color:var(--muted-fg);
}
.compare-table td { padding:10px 14px; border-bottom:1px solid var(--border); }
.compare-table td:not(:first-child) { text-align:right; font-weight:600; }
.compare-table tr:last-child td { border-bottom:none; }
.compare-table .best-col { color:var(--accent-dark); }

/* Tier cards (affordability) */
.tier-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:14px; margin-top:4px; }
.tier-card { background:white; border:1.5px solid var(--border); border-radius:var(--radius); padding:20px 16px; text-align:center; transition:all 0.15s; }
.tier-card.featured { border-color:var(--primary); background:hsl(240,49%,98%); }
.tier-card:hover { box-shadow:var(--card-shadow); transform:translateY(-2px); }
.tier-label { font-size:0.7rem; font-weight:700; text-transform:uppercase; letter-spacing:0.07em; color:var(--muted-fg); margin-bottom:8px; }
.tier-price { font-size:1.6rem; font-weight:800; color:var(--primary); letter-spacing:-0.02em; line-height:1; margin-bottom:4px; }
.tier-payment { font-size:0.8rem; color:var(--muted-fg); }

/* Rate bands (rate estimator tier rows) */
.rate-band { border-radius:var(--radius-sm); padding:10px 14px; display:flex; justify-content:space-between; align-items:center; margin-bottom:6px; color:var(--foreground); }
.rate-band-label { font-size:0.84rem; font-weight:600; }
.rate-band-val { font-size:1rem; font-weight:700; }
.rate-band-note { font-size:0.8rem; opacity:0.72; margin-top:8px; }

/* Savings highlight */
.savings-highlight { display:flex; align-items:center; gap:10px; background:hsl(150,60%,94%); border:1.5px solid hsl(150,60%,75%); border-radius:var(--radius-sm); padding:12px 16px; margin-bottom:14px; }
.savings-highlight .sav-icon { font-size:1.4rem; flex-shrink:0; }
.savings-highlight .sav-text { font-size:0.84rem; color:hsl(150,60%,25%); font-weight:600; line-height:1.4; }

/* Timeline bars (down payment) */
.timeline-scenario { display:flex; align-items:center; gap:14px; margin-bottom:12px; }
.timeline-label { font-size:0.8rem; font-weight:700; width:60px; flex-shrink:0; color:var(--foreground); }
.timeline-bar-wrap { flex:1; background:var(--border); border-radius:4px; height:10px; overflow:hidden; }
.timeline-bar { height:100%; border-radius:4px; background:var(--gradient-hero); transition:width 0.4s ease; }
.timeline-months { font-size:0.78rem; color:var(--muted-fg); width:80px; text-align:right; flex-shrink:0; }

@media (max-width:640px) {
  .tier-grid { grid-template-columns:1fr; }
  .calc-page-title { font-size:1.9rem; }
}

@media print {
  .header, .hero-content, .how-it-works, .rates-section,
  .calculators-section, .explanation-section, .faq-section, .footer,
  .result-actions, .amort-tabs .action-btn, .cta-panel { display: none !important; }
  .hero-section { background: white !important; padding: 0; }
  .calculator-card { box-shadow: none; }
  body { font-size: 12px; }
}

/* ─── Save Scenario Bar ───────────────────────────────────── */
.save-scenario-bar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 10px;
}

.btn-save-scenario {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  background: var(--gradient-hero); color: white;
  border: none; font-size: 0.84rem; font-weight: 700;
  cursor: pointer; font-family: inherit; transition: all 0.15s;
  letter-spacing: -0.01em;
}
.btn-save-scenario:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(96,44,144,0.35); }
.btn-save-scenario:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.scenario-count-label {
  font-size: 0.78rem; color: var(--muted-fg); font-weight: 500;
}

.scenario-name-prompt {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; background: hsl(240,49%,97%);
  border: 1.5px solid hsl(240,49%,85%); border-radius: var(--radius-sm);
  margin-bottom: 10px;
}
.scenario-name-prompt input {
  flex: 1; border: 1.5px solid var(--border); border-radius: 6px;
  padding: 7px 12px; font-size: 0.88rem; font-family: inherit;
  color: var(--foreground); outline: none;
  transition: border-color 0.15s;
}
.scenario-name-prompt input:focus { border-color: var(--primary); }
.prompt-save-btn {
  padding: 7px 16px; background: var(--secondary); color: white;
  border: none; border-radius: 6px; font-size: 0.84rem; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: background 0.14s;
}
.prompt-save-btn:hover { background: var(--secondary-light); }
.prompt-cancel-btn {
  padding: 7px 12px; background: none; color: var(--muted-fg);
  border: 1.5px solid var(--border); border-radius: 6px; font-size: 0.84rem;
  cursor: pointer; font-family: inherit; transition: all 0.14s;
}
.prompt-cancel-btn:hover { background: var(--muted); color: var(--foreground); }

/* ─── Scenario Comparison Section ────────────────────────── */
.scenario-section {
  background: hsl(240, 49%, 98%);
  border-top: 1px solid hsl(240, 49%, 88%);
  border-bottom: 1px solid hsl(240, 49%, 88%);
  padding: 52px 0;
}

.scenario-section-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 36px; gap: 20px;
}
.scenario-section-title {
  font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 800;
  color: var(--foreground); letter-spacing: -0.02em; margin: 8px 0 6px;
}
.scenario-section-title em { color: var(--secondary); }
.scenario-section-sub { font-size: 0.88rem; color: var(--muted-fg); }

.clear-all-btn { font-size: 0.82rem; flex-shrink: 0; padding: 8px 16px; margin-top: 10px; }

.scenario-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

/* Individual Scenario Card */
.scenario-card {
  background: white; border: 1.5px solid var(--border); border-radius: var(--radius);
  overflow: hidden; transition: box-shadow 0.15s;
}
.scenario-card:hover { box-shadow: var(--card-shadow-lg); }

.scenario-card-header {
  background: var(--gradient-hero); padding: 18px 20px 16px; color: white;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.scenario-name-wrap { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.scenario-name-input {
  background: transparent; border: none; border-bottom: 1.5px solid rgba(255,255,255,0.35);
  color: white; font-size: 1rem; font-weight: 700; font-family: inherit;
  outline: none; padding: 2px 0; width: 100%;
  transition: border-color 0.14s;
}
.scenario-name-input:focus { border-bottom-color: rgba(255,255,255,0.85); }
.scenario-name-input::placeholder { color: rgba(255,255,255,0.55); }
.scenario-name-hint { font-size: 0.68rem; opacity: 0.6; margin-top: 1px; }

.scenario-delete-btn {
  background: rgba(255,255,255,0.18); border: none; color: white;
  width: 26px; height: 26px; border-radius: 50%; font-size: 1rem; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.14s; flex-shrink: 0; padding: 0;
}
.scenario-delete-btn:hover { background: rgba(255,255,255,0.32); }

.scenario-inputs-summary {
  padding: 14px 20px 12px; background: hsl(240,49%,97%);
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem; color: var(--muted-fg); line-height: 1.6;
}
.scenario-inputs-summary span { display: inline-block; margin-right: 10px; }

.scenario-monthly {
  padding: 16px 20px 14px; text-align: center;
  border-bottom: 1px solid var(--border);
}
.scenario-monthly-label {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted-fg); margin-bottom: 4px;
}
.scenario-monthly-value {
  font-size: 2.1rem; font-weight: 800; color: var(--foreground);
  letter-spacing: -0.02em; line-height: 1;
}
.scenario-monthly-value.best { color: var(--accent-dark); }

.scenario-metrics {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--border); border-bottom: 1px solid var(--border);
}
.scenario-metric {
  background: white; padding: 12px 14px;
}
.scenario-metric-label {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted-fg); margin-bottom: 3px;
}
.scenario-metric-value {
  font-size: 0.95rem; font-weight: 700; color: var(--foreground);
}
.scenario-metric-value.best { color: var(--accent-dark); }

.scenario-card-footer {
  padding: 14px 20px; display: flex; gap: 8px;
}
.scenario-load-btn {
  flex: 1; padding: 9px 0; background: hsl(240,49%,97%);
  border: 1.5px solid hsl(240,49%,85%); border-radius: var(--radius-sm);
  font-size: 0.82rem; font-weight: 600; color: var(--primary);
  cursor: pointer; font-family: inherit; transition: all 0.14s;
}
.scenario-load-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }

/* ─── FRED API Bar ────────────────────────────────────────── */
.fred-api-bar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: white; border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 14px 20px; margin-bottom: 28px;
}

.fred-api-status { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.fred-dot {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
  background: var(--muted-fg); transition: background 0.3s;
}
.fred-dot.live { background: hsl(150, 65%, 42%); animation: dot-pulse 2.2s ease-in-out infinite; }
.fred-dot.error { background: hsl(0, 72%, 55%); }

#fredStatusText { font-size: 0.83rem; font-weight: 600; color: var(--foreground); white-space: nowrap; }

.fred-api-form { display: flex; gap: 8px; flex: 1; min-width: 260px; }
.fred-api-form input {
  flex: 1; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 13px; font-size: 0.84rem; font-family: inherit;
  color: var(--foreground); outline: none; transition: border-color 0.15s;
  min-width: 0;
}
.fred-api-form input:focus { border-color: var(--primary); }
.fred-connect-btn {
  padding: 8px 18px; background: var(--primary); color: white;
  border: none; border-radius: var(--radius-sm); font-size: 0.84rem; font-weight: 700;
  cursor: pointer; font-family: inherit; transition: background 0.14s; white-space: nowrap;
}
.fred-connect-btn:hover { background: var(--primary-light); }

.fred-register-link {
  font-size: 0.8rem; color: var(--primary); font-weight: 600;
  text-decoration: underline; text-underline-offset: 2px; white-space: nowrap;
  transition: color 0.14s;
}
.fred-register-link:hover { color: var(--secondary); }

.fred-disconnect-btn {
  padding: 7px 14px; background: none; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 0.8rem; color: var(--muted-fg);
  cursor: pointer; font-family: inherit; transition: all 0.14s; white-space: nowrap;
}
.fred-disconnect-btn:hover { border-color: hsl(0,72%,55%); color: hsl(0,72%,50%); }

@media (max-width: 640px) {
  .scenario-grid { grid-template-columns: 1fr; }
  .scenario-section-header { flex-direction: column; }
  .fred-api-bar { flex-direction: column; align-items: flex-start; gap: 10px; }
  .fred-api-form { width: 100%; }
  .save-scenario-bar { flex-wrap: wrap; }
}
