/* ==========================================================================
   style.css — Mortgage Calculator (Premium Fintech Design)
   --------------------------------------------------------------------------
   Palette: #0A1628 (navy) · #F5A623 (gold) · #F8FAFC (bg)
   Font: Inter (Google Fonts) · Icons: Font Awesome 6
   Layout: mobile-first · Dark mode support via data-theme

   Responsive strategy:
     Base styles are mobile-first.
     Breakpoints: 480px (small phones), 768px (tablet), 900px+ (desktop).
   ========================================================================== */

/* ---------- 1. Reset & tokens ---------- */
:root {
  /* Core palette */
  --navy: #0A1628;
  --navy-dark: #060E1C;
  --navy-hover: #132038;
  --gold: #F5A623;
  --gold-dark: #E89A1D;
  --gold-glow: rgba(245,166,35,0.15);
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-alt: #F1F5F9;
  --text: #1E293B;
  --text-secondary: #475569;
  --text-muted: #64748B;
  --border: #E2E8F0;
  --blue: #3B82F6;
  --green: #2f855a;
  --red: #EF4444;
  --focus: #3B82F6;

  /* Card accent backgrounds */
  --accent-red-bg: #FFF0F0;
  --accent-blue-bg: #F0F4FF;
  --accent-green-bg: #F0FFF4;
  --accent-gold-bg: #FFF8F0;

  /* Shadows */
  --shadow-card: 0 8px 32px rgba(10,22,40,0.1);
  --shadow-card-hover: 0 12px 48px rgba(10,22,40,0.16);
  --shadow-btn: 0 4px 16px rgba(10,22,40,0.2);
  --shadow-gold: 0 8px 32px rgba(245,166,35,0.25);

  /* Layout */
  --max-width: 1180px;
  --touch-min: 44px;
  --radius: 20px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --transition: 0.3s cubic-bezier(0.4,0,0.2,1);
}

/* ---------- Dark mode tokens ---------- */
[data-theme="dark"] {
  --bg: #070D19;
  --surface: #0F1A2E;
  --surface-alt: #162236;
  --text: #F1F5F9;
  --text-secondary: #CBD5E1;
  --text-muted: #94A3B8;
  --border: #1E3048;
  --shadow-card: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-card-hover: 0 12px 48px rgba(0,0,0,0.5);
  --shadow-btn: 0 4px 16px rgba(0,0,0,0.3);
  --accent-red-bg: rgba(239,68,68,0.08);
  --accent-blue-bg: rgba(59,130,246,0.08);
  --accent-green-bg: rgba(16,185,129,0.08);
  --accent-gold-bg: rgba(245,166,35,0.08);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  transition: background var(--transition), color var(--transition);
}

img, canvas, svg, video { max-width: 100%; height: auto; }

/* ---------- 2. Accessibility ---------- */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 100;
  background: var(--navy); color: #fff;
  padding: 8px 16px; border-radius: 6px; text-decoration: none;
}
.skip-link:focus { left: 8px; }

/* ---------- 3. Header ---------- */
.site-header {
  background: var(--navy);
  color: #fff;
  box-shadow: 0 2px 24px rgba(0,0,0,0.35);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: var(--touch-min);
}
.brand .logo-mark {
  width: 36px; height: 36px;
  background: url("../assets/img/logo-mark.svg") center / contain no-repeat;
  font-size: 0;
  color: transparent;
  filter: drop-shadow(0 2px 6px rgba(6,43,102,0.45));
}
.main-nav ul {
  list-style: none;
  display: flex;
  gap: 6px;
  margin: 0; padding: 0;
}
.main-nav a {
  color: #94A3B8;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-min);
  transition: color 0.2s, background 0.2s;
}
.main-nav a:hover { color: #fff; background: rgba(255,255,255,0.07); }
.main-nav a.active { color: #fff; background: rgba(255,255,255,0.1); }

/* Hamburger */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 44px; height: 44px;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-xs);
  background: rgba(255,255,255,0.06);
  color: #fff;
  cursor: pointer;
}
.menu-toggle span {
  display: block; width: 20px; height: 2px;
  background: #fff; border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Language selector */
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #94A3B8;
  font-size: 0.85rem;
}
.lang-switch select {
  background: rgba(255,255,255,0.06);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-xs);
  padding: 6px 10px;
  font-size: 16px;
  cursor: pointer;
  font-family: inherit;
}
.lang-switch select option {
  color: #1e293b;
  background: #fff;
}

/* Currency selector (mirrors .lang-switch styling) */
.currency-switch { margin-left: 8px; }
@media (max-width: 768px) {
  .currency-switch { margin-left: 0; margin-top: 4px; }
}

/* Theme toggle */
.theme-toggle-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-xs);
  width: 38px; height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--gold);
  transition: all 0.3s;
  min-height: var(--touch-min);
  min-width: var(--touch-min);
}
.theme-toggle-btn:hover {
  background: rgba(245,166,35,0.12);
  border-color: rgba(245,166,35,0.3);
}

/* ---------- 4. Ad containers ---------- */
.ad-container {
  margin: 20px auto;
  text-align: center;
  min-height: 90px;
  background: var(--surface-alt);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.ad-container--tall { min-height: 250px; }

/* ---------- 5. Main layout ---------- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 20px 48px;
  width: 100%;
}
.page-title {
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  color: var(--navy);
  margin: 0 0 8px;
  line-height: 1.25;
  overflow-wrap: break-word;
  font-weight: 900;
  letter-spacing: -0.02em;
}
[data-theme="dark"] .page-title { color: #fff; }
.page-title .hl { color: var(--gold); }
.page-intro {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 760px;
  margin: 0 0 32px;
}

/* ---------- 6. Calculator grid ---------- */
.calculator-wrapper {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}
@media (min-width: 900px) {
  .calculator-wrapper {
    grid-template-columns: 380px 1fr;
    align-items: start;
  }
}

/* ---------- 7. Form (inputs) — glass card ---------- */
.input-section,
.results-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 24px;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.input-section:hover,
.results-section:hover {
  box-shadow: var(--shadow-card-hover);
}
.input-section {
  position: sticky;
  top: 88px;
}

.form-group { margin-bottom: 20px; }
.form-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 8px;
  font-size: 0.85rem;
}
[data-theme="dark"] .form-group label { color: var(--text); }
.form-group label i {
  color: var(--blue);
  font-size: 0.8rem;
  width: 14px;
  text-align: center;
}
[data-theme="dark"] .form-group label i { color: var(--gold); }

.input-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

input[type="number"],
input[type="text"],
input[type="email"],
select,
textarea {
  font-size: 16px;
  padding: 11px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  background: var(--surface);
  font-family: inherit;
  font-weight: 500;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
[data-theme="dark"] input[type="number"]:focus,
[data-theme="dark"] input[type="text"]:focus,
[data-theme="dark"] select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(245,166,35,0.1);
}

/* ---------- Custom range sliders ---------- */
.input-row input[type="range"] {
  flex: 1;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-alt);
  outline: none;
  cursor: pointer;
  position: relative;
}
/* Slider thumb: 18px for sleek look */
.input-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--navy);
  box-shadow: 0 2px 6px rgba(10,22,40,0.2);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.input-row input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 3px 10px rgba(10,22,40,0.3);
}
[data-theme="dark"] .input-row input[type="range"]::-webkit-slider-thumb {
  border-color: var(--gold);
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.input-row input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--surface-alt);
}
.input-row input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--navy);
}
.input-row input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--navy);
  box-shadow: 0 2px 6px rgba(10,22,40,0.2);
  cursor: pointer;
}
[data-theme="dark"] .input-row input[type="range"]::-moz-range-thumb {
  border-color: var(--gold);
}

/* Slider fill bar (JS-driven via animations.js) */
.slider-wrap {
  position: relative;
  height: 6px;
  background: var(--surface-alt);
  border-radius: 3px;
}
.slider-fill {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--navy), #1a3a5c);
  border-radius: 3px;
  pointer-events: none;
  transition: width 0.05s linear;
}
[data-theme="dark"] .slider-fill {
  background: linear-gradient(90deg, var(--gold), #FBBF24);
}

.input-row input[type="number"] { width: 130px; }

.helper {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.helper i { font-size: 0.7rem; }
.helper strong { color: var(--navy); }
[data-theme="dark"] .helper strong { color: var(--gold); }
[data-theme="dark"] .helper i { color: var(--green) !important; }

/* Market rate note */
.market-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--accent-green-bg);
  border-radius: 6px;
  border: 1px solid rgba(16,185,129,0.12);
}
.market-note i { color: var(--green); font-size: 0.7rem; }

/* Rate refresh button (inline with interest-rate input) */
.rate-refresh-btn {
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0 10px;
  height: 40px;
  min-width: 40px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: background 0.2s, transform 0.2s;
  flex-shrink: 0;
}
.rate-refresh-btn:hover { background: var(--gold); color: var(--navy); }
.rate-refresh-btn:active { transform: scale(0.95); }
.rate-refresh-btn.spin i { animation: spin 0.8s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
[data-theme="dark"] .rate-refresh-btn { background: var(--navy); }
[data-theme="dark"] .rate-refresh-btn:hover { background: var(--gold); color: var(--navy); }

/* Rate cache note (below interest-rate input) */
.rate-cache-note {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.rate-cache-note i { font-size: 0.65rem; color: var(--green); }

/* ---------- Buttons ---------- */
.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 24px;
}
.btn {
  padding: 13px 22px;
  border: none;
  border-radius: var(--radius-xs);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch-min);
  font-family: inherit;
  transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--navy);
  color: #fff;
  flex: 1;
  box-shadow: var(--shadow-btn);
}
.btn-primary:hover {
  background: var(--navy-hover);
  box-shadow: 0 6px 24px rgba(10,22,40,0.25);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--border);
  color: var(--text);
}

/* ---------- 8. Results ---------- */
.results-section h2 {
  font-size: 1.15rem;
  color: var(--navy);
  margin: 0 0 16px;
  font-weight: 700;
}
[data-theme="dark"] .results-section h2 { color: #fff; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

/* Main payment card — gold accent */
.result-card {
  border-radius: var(--radius-sm);
  padding: 16px;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  overflow: visible;
}
.result-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card-hover);
}
.result-card--main {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
  border: 1px solid rgba(245,166,35,0.2);
  border-left: 5px solid var(--gold);
  padding: 24px;
}
[data-theme="dark"] .result-card--main {
  background: linear-gradient(135deg, rgba(245,166,35,0.06), rgba(245,166,35,0.02));
  border-color: rgba(245,166,35,0.15);
}
.result-card--main .result-label { color: var(--text-muted); }
.result-card--main .result-value {
  color: var(--gold-dark);
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.1;
  min-height: 3.6rem;
  display: flex;
  align-items: baseline;
  word-break: break-word;
  overflow-wrap: anywhere;
}
[data-theme="dark"] .result-card--main .result-value { color: var(--gold); }

.result-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.result-value {
  display: block;
  font-size: clamp(1.1rem, 2.5vw, 1.35rem);
  font-weight: 800;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
  min-height: 1.8rem;
  word-break: break-word;
  overflow-wrap: anywhere;
}
[data-theme="dark"] .result-value { color: var(--text); }
.result-value small {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Colored result cards */
.result-card:nth-child(2) {
  background: var(--accent-red-bg);
  border: 1px solid rgba(239,68,68,0.1);
}
.result-card:nth-child(2) .result-value { color: var(--red); }
.result-card:nth-child(3) {
  background: var(--accent-blue-bg);
  border: 1px solid rgba(59,130,246,0.1);
}
.result-card:nth-child(4) {
  background: var(--accent-green-bg);
  border: 1px solid rgba(16,185,129,0.1);
}
.result-card:nth-child(4) .result-value { color: var(--green); }
.result-card:nth-child(5) {
  background: var(--accent-gold-bg);
  border: 1px solid rgba(245,166,35,0.1);
}
.result-card:nth-child(5) .result-value { color: var(--green); }

/* Breakdown in main card */
.breakdown {
  margin: 12px 0 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.breakdown span { white-space: nowrap; }
.breakdown .tax { color: var(--gold-dark); font-weight: 600; }
.breakdown .ins { color: var(--green); font-weight: 600; }

/* Calculator hub page cards */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin: 24px 0;
}
.calc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-card);
}
.calc-card h2 { font-size: 1.25rem; margin: 0; color: var(--navy); }
[data-theme="dark"] .calc-card h2 { color: var(--text); }
.calc-card p { margin: 0; font-size: 0.95rem; color: var(--text-muted); flex: 1; }
.calc-card .btn { align-self: flex-start; }

/* ---------- Charts ---------- */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin: 20px 0;
}
@media (min-width: 700px) {
  .chart-grid { grid-template-columns: 1fr 1fr; }
  .calc-grid { grid-template-columns: repeat(2, 1fr); }
}
.chart-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition), box-shadow var(--transition);
}
.chart-box:hover { transform: translateY(-2px); box-shadow: var(--shadow-card-hover); }
.chart-box h3 {
  font-size: 0.88rem;
  color: var(--navy);
  margin: 0 0 10px;
  text-align: center;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
[data-theme="dark"] .chart-box h3 { color: #fff; }
.chart-box h3 i { color: var(--blue); font-size: 0.85rem; }
[data-theme="dark"] .chart-box h3 i { color: var(--gold); }
.chart-canvas {
  position: relative;
  width: 100%;
  height: 240px;
}

/* ---------- Amortization table ---------- */
.schedule {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-card);
}
.schedule h2 {
  font-size: 1.1rem;
  color: var(--navy);
  margin: 0 0 6px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
[data-theme="dark"] .schedule h2 { color: #fff; }
.schedule h2 i { color: var(--blue); font-size: 0.9rem; }
[data-theme="dark"] .schedule h2 i { color: var(--gold); }
.schedule-note {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0 0 12px;
}
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  max-height: 380px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
}
.table-scroll::-webkit-scrollbar { width: 5px; }
.table-scroll::-webkit-scrollbar-track { background: transparent; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

table.amortization {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  min-width: 520px;
}
table.amortization thead th {
  position: sticky;
  top: 0;
  background: var(--navy);
  color: #fff;
  text-align: right;
  padding: 11px 14px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  z-index: 1;
}
table.amortization thead th:first-child { text-align: left; }
table.amortization tbody td {
  padding: 9px 14px;
  text-align: right;
  border-top: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
table.amortization tbody td:first-child { text-align: left; color: var(--text-muted); font-weight: 600; }
table.amortization tbody tr:nth-child(even) { background: var(--surface-alt); }
table.amortization tbody tr:nth-child(odd) { background: var(--surface); }
table.amortization tbody tr:hover { background: rgba(59,130,246,0.04); }
[data-theme="dark"] table.amortization tbody tr:hover { background: rgba(59,130,246,0.06); }

.schedule-footer {
  margin: 12px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.schedule-footer #export-pdf:disabled { opacity: 0.6; cursor: wait; }

/* ---------- CTA box ---------- */
.cta-box {
  margin-top: 20px;
  background: var(--accent-blue-bg);
  border: 1px solid rgba(59,130,246,0.15);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
}
.cta-box h3 { margin: 0 0 4px; color: var(--navy); font-size: 1rem; font-weight: 700; }
[data-theme="dark"] .cta-box h3 { color: #fff; }
.cta-box p { margin: 0 0 12px; font-size: 0.9rem; color: var(--text-muted); }

.cta-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.cta-links .btn { flex: 1 1 200px; }
.btn-affiliate {
  background: var(--green);
  color: #fff;
}
.btn-affiliate:hover { background: #276749; }
.btn-outline {
  background: var(--surface);
  color: var(--blue);
  border: 2px solid var(--blue);
}
.btn-outline:hover { background: var(--accent-blue-bg); }

/* Share row */
.share-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0 0;
}
.share-row span { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.share-btn {
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--navy);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  text-decoration: none;
  transition: all 0.2s;
}
.share-btn:hover { background: var(--accent-blue-bg); border-color: var(--blue); color: var(--blue); }
[data-theme="dark"] .share-btn { color: var(--text); }

/* ---------- 9. SEO content sections ---------- */
.seo-section {
  margin-top: 36px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.seo-section h2 {
  font-size: clamp(1.25rem, 2.5vw, 1.6rem);
  color: var(--navy);
  margin: 0 0 12px;
  line-height: 1.35;
  font-weight: 800;
}
[data-theme="dark"] .seo-section h2 { color: #fff; }
.seo-section h3 {
  font-size: 1.1rem;
  color: var(--blue);
  margin: 20px 0 8px;
  font-weight: 700;
}
[data-theme="dark"] .seo-section h3 { color: var(--gold); }
.seo-section p { margin: 0 0 14px; color: var(--text); }
.seo-section ul { padding-left: 22px; }

/* ---------- 9b. Explore More card grid ---------- */
.explore-more {
  max-width: 56rem;
  margin: 36px auto 0;
  padding: 28px 0 0;
  border-top: 1px solid var(--border);
}
.explore-more__title {
  font-size: clamp(1.25rem, 2.5vw, 1.6rem);
  font-weight: 800;
  line-height: 1.35;
  margin: 0 0 12px;
  color: var(--navy);
}
[data-theme="dark"] .explore-more__title { color: #fff; }
.explore-more__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
@media (min-width: 640px) {
  .explore-more__grid { grid-template-columns: 1fr 1fr; }
}
.explore-more__card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}
[data-theme="dark"] .explore-more__card {
  border-color: #334155;
  background: rgba(30, 41, 59, 0.5);
  color: #e2e8f0;
}
.explore-more__card:hover {
  border-color: var(--blue);
  background: var(--navy-hover);
}
[data-theme="dark"] .explore-more__card:hover {
  border-color: #2dd4bf;
  background: #1e293b;
}
.explore-more__text {
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
}
.explore-more__arrow {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.2s ease, color 0.2s ease;
}
[data-theme="dark"] .explore-more__arrow { color: #64748b; }
.explore-more__card:hover .explore-more__arrow {
  transform: translateX(2px);
  color: var(--blue);
}
[data-theme="dark"] .explore-more__card:hover .explore-more__arrow {
  color: #2dd4bf;
}

/* FAQ */
.faq-list { margin-top: 16px; }
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(10,22,40,0.04);
}
.faq-item summary {
  padding: 16px;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
  list-style-position: inside;
  background: var(--surface-alt);
  min-height: var(--touch-min);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: background 0.2s;
}
[data-theme="dark"] .faq-item summary { color: var(--text); }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+";
  flex: 0 0 auto;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 28px;
  text-align: center;
  transition: background 0.2s;
}
.faq-item[open] summary::after { content: "−"; background: var(--gold); color: var(--navy); }
.faq-item summary:hover { background: var(--border); }
.faq-item p { padding: 0 16px 16px; margin: 0; color: var(--text-secondary); }

/* ---------- 10. Footer ---------- */
.site-footer {
  background: var(--navy);
  margin-top: 48px;
  color: #94A3B8;
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 36px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  text-align: center;
}
.footer-nav {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}
.footer-nav a {
  color: #94A3B8;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  min-height: var(--touch-min);
  display: inline-flex;
  align-items: center;
  transition: color 0.2s;
}
.footer-nav a:hover { color: var(--gold); }
.results-disclaimer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #7C5A00;
  background: #FFF8E6;
  border: 1px solid #F5DFA0;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin: 0.75rem 0 1.25rem;
}
.results-disclaimer i {
  color: #B8860B;
  flex-shrink: 0;
}
.results-disclaimer a {
  color: var(--blue, #1a365d);
  text-decoration: underline;
  white-space: nowrap;
}
[data-theme="dark"] .results-disclaimer {
  background: #2A2410;
  border-color: #4A3F1A;
  color: #E8D8A0;
}
.footer-disclaimer {
  font-size: 0.75rem;
  color: #64748B;
  max-width: 720px;
  margin: 0;
  line-height: 1.7;
}
.footer-copy {
  font-size: 0.8rem;
  margin: 0;
  color: #64748B;
}

/* ---------- 11. Content pages ---------- */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}
.blog-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
}
.blog-card time { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 10px; }
.blog-card h2 { font-size: 1.05rem; line-height: 1.4; color: var(--navy); margin: 0 0 10px; }
[data-theme="dark"] .blog-card h2 { color: var(--text); }
.blog-card p { margin: 0; font-size: 0.92rem; color: var(--text); }

.feature-list { list-style: none; padding: 0; margin: 0 0 16px; }
.feature-list li { position: relative; padding: 8px 0 8px 28px; color: var(--text); }
.feature-list li::before {
  content: "✓"; position: absolute; left: 4px;
  color: var(--green); font-weight: 700;
}

.contact-grid { display: grid; grid-template-columns: 1fr; gap: 24px; }
.notice {
  display: none; margin-top: 16px; padding: 12px 16px;
  background: var(--accent-green-bg); border: 1px solid rgba(16,185,129,0.3);
  border-radius: var(--radius-sm); color: #22543d;
}
.notice--visible { display: block; }
.notice--error { background: var(--accent-red-bg); border-color: rgba(239,68,68,0.3); color: #742a2a; }
[data-theme="dark"] .notice { color: #68d391; }
[data-theme="dark"] .notice--error { color: #fc8181; }

.contact-section { max-width: 700px; margin: 0 auto; }
.contact-form {
  background: var(--surface-alt);
  padding: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}
.contact-form .form-group { margin-bottom: 20px; }
.contact-form input[type="text"],
.contact-form input[type="email"],
.contact-form textarea { width: 100%; box-sizing: border-box; }
.contact-form input:focus,
.contact-form textarea:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.btn-submit {
  display: block; width: 100%;
  padding: 14px 30px;
  background: var(--navy); color: #fff;
  border: none; border-radius: var(--radius-xs);
  font-size: 1rem; font-weight: 700;
  cursor: pointer; font-family: inherit;
  min-height: var(--touch-min);
  transition: background 0.2s;
}
.btn-submit:hover { background: var(--navy-hover); }
.btn-submit:disabled { opacity: 0.6; cursor: wait; }
.contact-info {
  text-align: center; margin-top: 30px;
  background: var(--surface-alt);
  padding: 20px; border-radius: var(--radius-xs);
  color: var(--text);
}
.contact-info a { color: var(--navy); }
[data-theme="dark"] .contact-info a { color: var(--blue-light); }

.formula {
  margin: 12px 0; padding: 12px 16px;
  background: var(--surface-alt);
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 0.95rem;
  overflow-x: auto;
}
.related-guides {
  margin-top: 24px; padding: 16px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.related-guides h3 { margin: 0 0 10px; color: var(--navy); font-size: 1rem; }
[data-theme="dark"] .related-guides h3 { color: var(--text); }
.related-guides ul { list-style: none; margin: 0 0 14px; padding: 0; }
.related-guides li { margin: 0 0 6px; }
.related-guides li::before { content: '→ '; color: var(--blue); }
.related-guides li a { color: var(--blue); text-decoration: none; }
.related-guides li a:hover { text-decoration: underline; }
.related-guides .btn { display: inline-block; }

/* ---------- 12. Responsive: tablet (max 768px) ---------- */
@media (max-width: 768px) {
  .container { padding: 16px 15px 40px; }
  .result-grid { grid-template-columns: 1fr; }
  .result-card { width: 100%; margin-bottom: 12px; }
  .result-card--main .result-value { min-height: 2.7rem; }
  .input-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .input-row input[type="range"] { flex: 1 1 auto; }
  .input-row input[type="number"] { width: 100%; }
  .input-section { position: static; }
  .menu-toggle { display: inline-flex; }
  .main-nav {
    display: none;
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: var(--navy-dark);
    box-shadow: 0 8px 16px rgba(0,0,0,0.3);
    z-index: 99;
  }
  .main-nav.active { display: block; }
  .main-nav ul { flex-direction: column; gap: 0; padding: 8px 0; }
  .main-nav a {
    display: block; padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,0.06);
    font-size: 1rem;
  }
  .main-nav a.active { border-bottom: none; border-left: 4px solid var(--gold); }
  .input-group--loan-term { padding-bottom: 20px; }
}

/* ---------- 13. Responsive: small phones (max 480px) ---------- */
@media (max-width: 480px) {
  .header-inner { padding: 10px 14px; gap: 10px; }
  .page-title { font-size: 1.8rem; }
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.4rem; }
  h3 { font-size: 1.2rem; }
  .input-section, .results-section { padding: 16px; }
  .page-intro { font-size: 1rem; }
  .seo-section { margin-top: 28px; padding-top: 22px; }
  table.amortization { font-size: 12px; min-width: 0; }
  table.amortization thead th { padding: 8px 6px; font-size: 12px; }
  table.amortization tbody td { padding: 6px 6px; }
  #amortization-table thead th:nth-child(2),
  #amortization-table tbody td:nth-child(2),
  #amortization-table thead th:nth-child(5),
  #amortization-table tbody td:nth-child(5) { display: none; }
  .contact-form { padding: 20px; }
  .btn-row .btn { flex: 1 1 100%; }
  .chart-canvas { height: 220px; }
  .result-card--main .result-value { min-height: 2.5rem; }
}

@media (min-width: 760px) {
  .contact-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- 14. Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
