/* ═══════════════════════════════════════════════
   MortgageCalc — Premium Financial Design System
   Trust · Clarity · Confidence
   ═══════════════════════════════════════════════ */

/* RESET */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f7f8fa;
  --bg-white: #ffffff;
  --surface: #f1f4f8;
  --surface-alt: #e8ecf2;
  --border: #dfe3ea;
  --border-dark: #c4cad4;
  --text: #1a2332;
  --text-muted: #5a6a7e;
  --text-light: #8a96a8;
  --primary: #0c2340;
  --primary-mid: #163d6b;
  --primary-light: #1a5bb5;
  --accent: #1a73e8;
  --accent-light: #e8f0fe;
  --green: #0d7a3e;
  --green-light: #e6f9ee;
  --green-bg: #effdf4;
  --amber: #a85d00;
  --amber-bg: #fef9eb;
  --red: #c53030;
  --red-bg: #fef2f2;
  --gold: #b8860b;
  --navy: #0c1829;
  --navy-mid: #162a45;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', Courier, monospace;
  --shadow-xs: 0 1px 2px rgba(12,35,64,0.04);
  --shadow-sm: 0 1px 3px rgba(12,35,64,0.06), 0 1px 2px rgba(12,35,64,0.04);
  --shadow: 0 2px 8px rgba(12,35,64,0.08), 0 1px 3px rgba(12,35,64,0.06);
  --shadow-md: 0 4px 16px rgba(12,35,64,0.10), 0 2px 4px rgba(12,35,64,0.05);
  --shadow-lg: 0 8px 32px rgba(12,35,64,0.12), 0 4px 8px rgba(12,35,64,0.06);
  --radius: 8px;
  --radius-lg: 12px;
  --max-width: 1140px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── TYPOGRAPHY ── */
h1, h2, h3 {
  font-family: var(--font-heading);
  color: var(--primary);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
}
h1 { font-size: 1.85rem; margin-bottom: 8px; }
h2 { font-size: 1.35rem; margin-bottom: 6px; border-bottom: 2px solid var(--primary); padding-bottom: 6px; display: inline-block; }
h3 { font-size: 1.1rem; margin-bottom: 4px; }
p { margin-bottom: 12px; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-light); text-decoration: underline; }

/* Financial numbers */
.num { font-family: var(--font-mono); font-weight: 600; letter-spacing: -0.02em; }
.num-lg { font-family: var(--font-mono); font-size: 2rem; font-weight: 700; color: var(--primary); }
.num-green { color: var(--green); }
.num-red { color: var(--red); }
.num-amber { color: var(--amber); }

/* ══════════════════════════════════════
   NAVIGATION — Premium top bar
   ══════════════════════════════════════ */
.nav {
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-mid) 100%);
  color: #fff;
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.nav-logo {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.02em;
}
.nav-logo span {
  background: linear-gradient(135deg, #1a73e8, #0d47a1);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-family: var(--font-body);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.nav-links { display: flex; gap: 2px; }
.nav-links a {
  color: rgba(255,255,255,0.65);
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
}
.nav-links a:hover, .nav-links a.active {
  background: rgba(255,255,255,0.08);
  color: #fff;
  text-decoration: none;
}

/* ══════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════ */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }
.calc-layout { display: grid; grid-template-columns: 380px 1fr; gap: 28px; margin-top: 28px; margin-bottom: 40px; }
@media (max-width: 820px) { .calc-layout { grid-template-columns: 1fr; } }

/* ══════════════════════════════════════
   PAGE HEADER — Clean hero block
   ══════════════════════════════════════ */
.page-header {
  background: linear-gradient(180deg, #f0f3f7 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  padding: 28px 0 24px;
}
.page-header h1 { margin-bottom: 6px; }
.page-header p { color: var(--text-muted); font-size: 0.92rem; margin: 0; max-width: 700px; line-height: 1.5; }
.breadcrumb { font-size: 0.78rem; color: var(--text-light); margin-bottom: 8px; }
.breadcrumb a { color: var(--text-muted); }

/* ══════════════════════════════════════
   INPUT PANEL — Refined calculator inputs
   ══════════════════════════════════════ */
.input-panel {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  scrollbar-width: thin;
}
.input-panel-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-mid) 100%);
  color: #fff;
  padding: 14px 20px;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  letter-spacing: -0.01em;
}
.input-group {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.input-group:hover { background: rgba(26,115,232,0.015); }
.input-group:last-child { border-bottom: none; }
.input-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 7px;
}
.input-label .hint { font-weight: 400; color: var(--text-muted); font-size: 0.75rem; }

/* Tooltip icon */
.info-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.65rem;
  color: var(--text-muted);
  cursor: help;
  position: relative;
  margin-left: 4px;
  transition: all var(--transition);
}
.info-tip:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.info-tip:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 24px; top: -4px;
  background: var(--navy);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  width: 220px;
  z-index: 10;
  font-weight: 400;
  line-height: 1.5;
  box-shadow: var(--shadow-lg);
}

/* Input fields */
.input-row { display: flex; gap: 8px; align-items: center; }
.input-field {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg-white);
  transition: all var(--transition);
}
.input-field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,115,232,0.12);
}
.input-field-sm { width: 80px; text-align: right; }
.input-prefix, .input-suffix {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-light);
  white-space: nowrap;
}

/* Slider */
.slider-container { margin-top: 6px; }
.slider {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 5px;
  background: linear-gradient(90deg, var(--border) 0%, var(--surface-alt) 100%);
  border-radius: 3px;
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid #fff;
  box-shadow: var(--shadow);
  transition: transform var(--transition);
}
.slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: var(--shadow-md);
}

/* Radio/Toggle buttons */
.term-options { display: flex; gap: 0; }
.term-btn {
  flex: 1;
  padding: 8px 0;
  text-align: center;
  border: 1.5px solid var(--border);
  background: var(--bg-white);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-mono);
}
.term-btn:first-child { border-radius: 6px 0 0 6px; }
.term-btn:last-child { border-radius: 0 6px 6px 0; }
.term-btn:hover { background: var(--surface); }
.term-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
}

/* Collapse toggle */
.collapse-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  transition: background var(--transition);
}
.collapse-toggle:hover { background: var(--surface-alt); }
.collapse-content { display: none; }
.collapse-content.open { display: block; }

/* ══════════════════════════════════════
   RESULT CARDS — Clean elevated cards
   ══════════════════════════════════════ */
.results-panel { min-width: 0; }

.result-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
  transition: box-shadow var(--transition);
}
.result-card:hover {
  box-shadow: var(--shadow);
}
.result-card-header {
  background: linear-gradient(180deg, #f5f7fa, #eef1f5);
  padding: 12px 20px;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-heading);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.result-card-body { padding: 20px; }

/* Monthly payment hero */
.monthly-payment {
  text-align: center;
  padding: 28px 20px;
  background: linear-gradient(135deg, var(--primary) 0%, #194d80 50%, #1a5bb5 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.monthly-payment::before {
  content: '';
  position: absolute;
  top: -50%; right: -20%;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(255,255,255,0.04) 0%, transparent 70%);
  border-radius: 50%;
}
.monthly-payment .label { font-size: 0.88rem; opacity: 0.85; margin-bottom: 6px; font-weight: 500; }
.monthly-payment .amount {
  font-family: var(--font-mono);
  font-size: 2.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.monthly-payment .sub { font-size: 0.82rem; opacity: 0.7; margin-top: 6px; }

/* Breakdown table */
.breakdown-table { width: 100%; border-collapse: collapse; }
.breakdown-table td {
  padding: 10px 14px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.breakdown-table tr:hover td { background: rgba(26,115,232,0.02); }
.breakdown-table tr:last-child td { border-bottom: none; }
.breakdown-table td:first-child { color: var(--text-muted); }
.breakdown-table td:last-child { text-align: right; font-family: var(--font-mono); font-weight: 600; }
.breakdown-table .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 10px; }
.breakdown-table tr.total { background: var(--surface); font-weight: 700; }
.breakdown-table tr.total td { border-top: 2px solid var(--border-dark); color: var(--text); padding: 12px 14px; }

/* Savings highlight */
.savings-box {
  background: linear-gradient(135deg, var(--green-bg) 0%, #e0f7ea 100%);
  border: 1px solid #a7e8c0;
  border-left: 4px solid var(--green);
  padding: 14px 18px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 14px 0;
}
.savings-box .label { font-size: 0.82rem; color: var(--green); font-weight: 600; }
.savings-box .value { font-family: var(--font-mono); font-size: 1.25rem; font-weight: 700; color: var(--green); }

/* Warning box */
.warning-box {
  background: linear-gradient(135deg, var(--amber-bg) 0%, #fef3c7 100%);
  border: 1px solid #fcd34d;
  border-left: 4px solid var(--amber);
  padding: 14px 18px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 14px 0;
  font-size: 0.84rem;
  color: var(--amber);
  line-height: 1.55;
}

/* Chart container */
.chart-container { position: relative; width: 100%; }
.chart-container canvas { width: 100% !important; }

/* ══════════════════════════════════════
   AMORTIZATION TABLE — Professional data grid
   ══════════════════════════════════════ */
.amort-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.amort-table thead th {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-mid) 100%);
  color: #fff;
  padding: 10px 14px;
  text-align: right;
  font-weight: 600;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
}
.amort-table thead th:first-child { text-align: left; border-radius: 6px 0 0 0; }
.amort-table thead th:last-child { border-radius: 0 6px 0 0; }
.amort-table tbody td {
  padding: 8px 14px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.amort-table tbody td:first-child { text-align: left; font-family: var(--font-body); font-weight: 600; }
.amort-table tbody tr:nth-child(even) { background: rgba(241,244,248,0.5); }
.amort-table tbody tr:hover { background: var(--accent-light); }
.amort-table tfoot td {
  font-weight: 700;
  background: var(--surface);
  border-top: 2px solid var(--border-dark);
  padding: 12px 14px;
}

/* ══════════════════════════════════════
   COMPARE SECTION — Side-by-side cards
   ══════════════════════════════════════ */
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .compare-grid { grid-template-columns: 1fr; } }
.compare-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition);
}
.compare-card:hover { box-shadow: var(--shadow); }
.compare-card.highlighted {
  border-color: var(--green);
  border-width: 2px;
  box-shadow: 0 0 0 3px rgba(13,122,62,0.08);
}
.compare-card-header {
  padding: 12px 16px;
  font-weight: 700;
  font-size: 0.85rem;
  background: linear-gradient(180deg, #f5f7fa, #eef1f5);
  border-bottom: 1px solid var(--border);
}

/* ══════════════════════════════════════
   TRUE COST SECTION
   ══════════════════════════════════════ */
.true-cost {
  background: linear-gradient(135deg, var(--surface) 0%, #e8ecf2 100%);
  border: 2px solid var(--border-dark);
  border-radius: var(--radius);
  padding: 22px;
  margin: 20px 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
.true-cost-header {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--primary);
  margin-bottom: 14px;
  text-align: center;
  border-bottom: 2px double var(--border-dark);
  padding-bottom: 10px;
  letter-spacing: -0.02em;
}
.true-cost-row { display: flex; justify-content: space-between; padding: 5px 0; }
.true-cost-row.subtotal { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 6px; font-weight: 700; }
.true-cost-row.grand-total { border-top: 2px double var(--border-dark); padding-top: 12px; margin-top: 8px; font-weight: 700; font-size: 1rem; color: var(--primary); }
.true-cost-divider { border-top: 1px dashed var(--border); margin: 12px 0; }

/* ══════════════════════════════════════
   BUTTONS — Refined interactive elements
   ══════════════════════════════════════ */
.btn {
  padding: 9px 18px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--bg-white);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-body);
  color: var(--text);
}
.btn:hover {
  background: var(--surface);
  border-color: var(--border-dark);
  box-shadow: var(--shadow-xs);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-mid) 100%);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-mid) 0%, var(--primary) 100%); }
.btn-sm { padding: 5px 12px; font-size: 0.75rem; }
.btn-group { display: flex; gap: 10px; margin-top: 14px; }

/* ══════════════════════════════════════
   AD SLOTS
   ══════════════════════════════════════ */
.ad-slot {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-alt) 100%);
  border: 1px dashed var(--border-dark);
  text-align: center;
  padding: 24px;
  color: var(--text-light);
  font-size: 0.72rem;
  margin: 24px 0;
  border-radius: var(--radius);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ══════════════════════════════════════
   RELATED CALCULATORS — Link cards
   ══════════════════════════════════════ */
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin: 16px 0; }
.related-card {
  display: block;
  padding: 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition);
  background: var(--bg-white);
}
.related-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  text-decoration: none;
  transform: translateY(-2px);
}
.related-card h4 { font-size: 0.88rem; font-family: var(--font-body); margin-bottom: 4px; color: var(--primary); }
.related-card p { font-size: 0.76rem; color: var(--text-muted); margin: 0; line-height: 1.4; }

/* ══════════════════════════════════════
   FOOTER — Clean brand footer
   ══════════════════════════════════════ */
.footer {
  background: linear-gradient(180deg, var(--navy) 0%, #060d17 100%);
  color: #8a96a8;
  padding: 36px 24px;
  margin-top: 48px;
  font-size: 0.82rem;
  text-align: center;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.footer strong { color: #cbd5e1; letter-spacing: -0.01em; }
.footer a { color: #a0b0c0; transition: color var(--transition); }
.footer a:hover { color: #fff; text-decoration: none; }
.footer-links { margin-top: 10px; }
.footer-links a { margin: 0 10px; }

/* ══════════════════════════════════════
   PRINT STYLES
   ══════════════════════════════════════ */
@media print {
  .nav, .ad-slot, .btn-group, .related-grid, .footer, .slider-container, .collapse-toggle { display: none !important; }
  .input-panel { position: static; }
  .calc-layout { display: block; }
  .amort-table { font-size: 0.7rem; }
  .amort-table thead th { background: #333 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { font-size: 12px; background: #fff; }
  .result-card { box-shadow: none; border: 1px solid #ccc; }
}

/* ══════════════════════════════════════
   MOBILE RESPONSIVE
   ══════════════════════════════════════ */
@media (max-width: 820px) {
  .nav-links { display: none; }
  .nav { padding: 0 16px; height: 52px; }
  h1 { font-size: 1.45rem; }
  .monthly-payment .amount { font-size: 2.2rem; }
  .input-panel { position: static; max-height: none; }
  .container { padding: 0 14px; }
  .calc-layout { gap: 16px; margin-top: 16px; }
  .result-card-body { padding: 14px; }
  .page-header { padding: 20px 0 16px; }
}

/* ══════════════════════════════════════
   MICRO-ANIMATIONS
   ══════════════════════════════════════ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.result-card { animation: fadeInUp 0.3s ease-out; }
