:root {
  --ink: #0F2240;
  --ink-light: #1e3a5f;
  --purple: #2563EB;
  --purple-light: #60a5fa;
  --accent: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f8fafc;
  --white: #ffffff;
  --text: #0F2240;
  --text-muted: #64748b;
  --border: #e2e8f0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }

/* === NAV === */
.nav { background: var(--ink); color: white; padding: 16px 32px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100; }
.nav-logo { font-weight: 800; font-size: 1.3rem; letter-spacing: -0.5px; color: white; text-decoration: none; }
.nav-links { display: flex; gap: 32px; }
.nav-links a { color: white; text-decoration: none; font-size: 0.9rem; font-weight: 500; opacity: 0.9; }
.nav-links a:hover { opacity: 1; }
.nav-links a.active { color: var(--purple-light); font-weight: 600; }
.nav-cta { background: var(--purple); color: white; padding: 10px 20px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; text-decoration: none; }

/* === HERO === */
.hero { background: linear-gradient(135deg, var(--ink) 0%, var(--ink-light) 100%); color: white; padding: 48px 32px 120px; text-align: center; position: relative; }
.hero::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 80px; background: var(--bg); clip-path: polygon(0 100%, 100% 100%, 100% 20%, 0 80%); }
.hero-eyebrow { color: var(--purple-light); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 16px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.5rem); font-weight: 800; line-height: 1.1; margin-bottom: 16px; letter-spacing: -1px; }
.hero p { font-size: 1.15rem; color: #cbd5e1; max-width: 640px; margin: 0 auto; }

/* === CALC CARD === */
.calc-wrapper { max-width: 1100px; margin: -60px auto 60px; padding: 0 24px; position: relative; z-index: 10; }
.calc-card { background: white; border-radius: 24px; box-shadow: 0 25px 60px -15px rgba(15, 34, 64, 0.25), 0 10px 20px -5px rgba(15, 34, 64, 0.1); overflow: hidden; border: 1px solid var(--border); }

/* === TABS === */
.tabs { display: flex; background: #f1f5f9; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { flex: 1; min-width: 140px; padding: 16px 20px; background: none; border: none; font-family: inherit; font-size: 0.9rem; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 3px solid transparent; transition: all 0.2s; white-space: nowrap; }
.tab:hover { color: var(--ink); background: #e2e8f0; }
.tab.active { color: var(--purple); background: white; border-bottom-color: var(--purple); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* === CALC BODY === */
.calc-body { display: grid; grid-template-columns: 1fr 1.2fr; min-height: 600px; }

.calc-inputs { padding: 40px; background: white; border-right: 1px solid var(--border); }
.calc-inputs h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }
.calc-inputs .subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 28px; }

.section-heading { font-size: 0.75rem; font-weight: 700; color: var(--purple); text-transform: uppercase; letter-spacing: 1.5px; margin: 24px 0 12px; padding-top: 16px; border-top: 1px dashed var(--border); }
.section-heading:first-of-type { margin-top: 8px; padding-top: 0; border-top: none; }

.input-group { margin-bottom: 20px; }
.input-group label { display: flex; justify-content: space-between; gap: 8px; font-size: 0.8rem; font-weight: 600; color: var(--ink); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; overflow: hidden; }
.input-group label .helper { text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1 1 auto; }
.input-group .field-hint { margin-top: 6px; font-size: 0.75rem; color: var(--text-muted); font-weight: 500; line-height: 1.4; }
.input-group .helper { color: var(--text-muted); font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 0.75rem; }

.input-wrap { position: relative; }
.input-wrap .prefix, .input-wrap .suffix { position: absolute; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-weight: 600; font-size: 1rem; }
.input-wrap .prefix { left: 16px; }
.input-wrap .suffix { right: 16px; }

input[type="text"], input[type="number"], select { width: 100%; padding: 14px 16px 14px 32px; border: 1.5px solid var(--border); border-radius: 10px; font-family: inherit; font-size: 1.05rem; font-weight: 600; color: var(--ink); background: white; transition: border 0.2s, box-shadow 0.2s; }
input.no-prefix, select.no-prefix { padding-left: 16px; }
input.has-suffix { padding-right: 40px; }
input:focus, select:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }

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

/* Down payment $/% toggle row */
.down-payment-row { display: flex; gap: 8px; align-items: stretch; }
.down-payment-row .dp-input { flex: 1; }
.dp-toggle {
  display: inline-flex; background: #f1f5f9; border: 1.5px solid var(--border);
  border-radius: 10px; padding: 3px; gap: 2px;
}
.dp-toggle-btn {
  padding: 8px 14px; background: transparent; border: none; cursor: pointer;
  font-family: inherit; font-size: 0.95rem; font-weight: 700;
  color: var(--text-muted); border-radius: 7px; min-width: 38px;
  transition: all 0.15s ease;
}
.dp-toggle-btn.active {
  background: white; color: var(--purple); box-shadow: 0 1px 3px rgba(15,34,64,0.08);
}
.dp-toggle-btn:not(.active):hover { color: var(--ink); }

/* === LOAN TYPE PILLS === */
.loan-type-info { margin-top: 10px; }
.loan-type-info a { color: var(--purple); text-decoration: none; font-size: 0.85rem; font-weight: 600; }
.loan-type-info a:hover { text-decoration: underline; }
.field-help { font-size: 0.8rem; color: var(--text-muted); margin-top: 6px; line-height: 1.5; }
.field-help strong { color: var(--ink); }

.va-fields, .fha-note { background: #f1f5f9; border-radius: 12px; padding: 16px 20px; margin-bottom: 20px; border-left: 3px solid var(--purple); }
.va-fields .input-group:last-child { margin-bottom: 0; }
.fha-note p { margin: 0; }

/* === DEBT CONSOLIDATION ROWS === */
.debt-row { background: #f8fafc; border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px; margin-bottom: 12px; position: relative; }
.debt-row-header { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.debt-label { flex: 1; padding: 8px 12px !important; border: 1px dashed var(--border) !important; border-radius: 8px; font-weight: 700; font-size: 0.95rem; background: transparent !important; }
.debt-label:focus { border-style: solid !important; }
.debt-remove { background: transparent; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; padding: 0 8px; line-height: 1; transition: color 0.2s; }
.debt-remove:hover { color: var(--danger); }
.debt-row .input-group { margin-bottom: 12px; }
.debt-row .input-group:last-child { margin-bottom: 0; }

.add-debt-btn { width: 100%; padding: 14px; background: transparent; border: 1.5px dashed var(--purple); color: var(--purple); border-radius: 12px; font-family: inherit; font-size: 0.9rem; font-weight: 700; cursor: pointer; margin-top: 4px; transition: all 0.2s; }
.add-debt-btn:hover { background: rgba(37, 99, 235, 0.05); }

.loan-type-group { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-pill { cursor: pointer; }
.radio-pill input { position: absolute; opacity: 0; pointer-events: none; }
.radio-pill span { display: inline-block; padding: 10px 18px; border: 1.5px solid var(--border); border-radius: 999px; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); transition: all 0.2s; }
.radio-pill input:checked + span { background: var(--purple); color: white; border-color: var(--purple); }
.radio-pill:hover span { border-color: var(--purple); color: var(--purple); }
.radio-pill input:checked ~ span { background: var(--purple); color: white; border-color: var(--purple); }

/* Checkbox */
.checkbox-row { display: flex; align-items: center; gap: 10px; cursor: pointer; text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 0.9rem; color: var(--text); }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--purple); padding: 0; }

/* === RESULTS === */
.calc-results { padding: 40px; background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%); position: relative; }

.result-hero { text-align: center; padding-bottom: 28px; border-bottom: 1px solid var(--border); margin-bottom: 28px; }
.result-label { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 8px; }
.result-amount { font-size: 3.5rem; font-weight: 800; color: var(--ink); letter-spacing: -2px; line-height: 1; }
.result-amount .currency { font-size: 2rem; color: var(--text-muted); vertical-align: super; margin-right: 4px; }
.result-amount .period { font-size: 1.1rem; color: var(--text-muted); font-weight: 500; margin-left: 4px; }
.result-amount-alt { font-size: 3.5rem; font-weight: 800; color: var(--purple); letter-spacing: -2px; line-height: 1; }
.result-amount-alt .period { font-size: 1.5rem; color: var(--text-muted); margin-left: 2px; }

.rate-badge { margin-top: 12px; font-size: 0.85rem; color: var(--text-muted); }
.rate-badge strong { color: var(--purple); font-weight: 700; }
.rate-badge .helper { color: var(--text-muted); font-weight: 500; }

.breakdown { }
.breakdown-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--border); font-size: 0.95rem; }
.breakdown-row:last-child { border-bottom: none; }
.breakdown-row:has(.dot) { grid-template-columns: auto 1fr auto; }
.breakdown-row:not(:has(.dot)) { grid-template-columns: 1fr auto; }
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.pi { background: var(--purple); }
.dot.tax { background: var(--accent); }
.dot.ins { background: var(--warning); }
.dot.pmi { background: var(--danger); }
.dot.hoa { background: #8b5cf6; }
.breakdown-label { color: var(--text); font-weight: 500; }
.breakdown-value { font-weight: 700; color: var(--ink); }

.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--border); }
.summary-label { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.summary-value { font-size: 1.25rem; font-weight: 700; color: var(--ink); }
.summary-value.warning { color: var(--warning); }

.mi-disclaimer { margin-top: 20px; padding: 14px 16px; background: #fef9c3; border-left: 4px solid var(--warning); border-radius: 8px; font-size: 0.82rem; color: #78350f; line-height: 1.6; }
.mi-disclaimer strong { color: #78350f; font-weight: 700; }
.jumbo-disclaimer { margin-top: 12px; padding: 14px 16px; background: rgba(239, 68, 68, 0.08); border-left: 4px solid var(--danger); border-radius: 8px; font-size: 0.82rem; color: #7f1d1d; line-height: 1.6; }
.jumbo-disclaimer strong { color: #7f1d1d; font-weight: 700; }

/* === RECOMMENDATIONS === */
.recommendations-section { padding: 32px 40px 40px; background: var(--bg); border-top: 1px solid var(--border); }
.recommendations-section:empty { display: none; }
.rec-title-main { font-size: 1.1rem; font-weight: 800; color: var(--ink); margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.rec-title-main::before { content: '💡'; font-size: 1.2rem; }

.rec-card { background: white; border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 12px; padding: 18px 20px; margin-bottom: 12px; display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; }
.rec-card.info { border-left-color: var(--purple); }
.rec-card.high { border-left-color: var(--accent); }
.rec-card.medium { border-left-color: var(--warning); }
.rec-card h4 { font-size: 1rem; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.rec-card p { font-size: 0.88rem; color: var(--text-muted); line-height: 1.5; }
.rec-savings { text-align: right; min-width: 120px; }
.rec-savings-val { font-size: 1.25rem; font-weight: 800; color: var(--accent); }
.rec-savings-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 2px; }

.recommendation-inline { margin-top: 24px; padding: 16px 20px; background: rgba(37, 99, 235, 0.06); border-radius: 12px; border: 1px solid rgba(37, 99, 235, 0.15); }
.rec-title { font-size: 0.75rem; font-weight: 700; color: var(--purple); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.rec-body { color: var(--ink); font-size: 0.92rem; line-height: 1.6; }

/* === AMORT + GATE === */
.amort-section { max-width: 1100px; margin: 60px auto; padding: 0 24px; }
.amort-preview { background: white; border-radius: 24px; overflow: hidden; box-shadow: 0 10px 30px -10px rgba(15, 34, 64, 0.15); border: 1px solid var(--border); }
.amort-header { padding: 32px 40px 24px; border-bottom: 1px solid var(--border); }
.amort-header h3 { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }
.amort-header p { color: var(--text-muted); }

.amort-table-wrapper { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.amort-table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 0.9rem; }
.amort-table th { text-align: left; padding: 14px 16px; background: #f8fafc; font-size: 0.75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); }
.amort-table td { padding: 14px 16px; border-bottom: 1px solid #f1f5f9; color: var(--ink); }
.amort-table tr:nth-child(even) td { background: #fafbfd; }

.amort-gate { position: relative; padding: 48px 40px 40px; text-align: center; background: linear-gradient(180deg, transparent 0%, white 60px); margin-top: -60px; }
.gate-badge { display: inline-block; background: rgba(37, 99, 235, 0.1); color: var(--purple); padding: 6px 14px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 16px; }
.gate-headline { font-size: 1.6rem; font-weight: 700; color: var(--ink); margin-bottom: 12px; max-width: 600px; margin-left: auto; margin-right: auto; line-height: 1.3; }
.gate-sub { color: var(--text-muted); max-width: 540px; margin: 0 auto 28px; line-height: 1.6; }
.gate-form { max-width: 440px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.gate-form input { padding: 16px 20px !important; font-size: 1rem; border: 1.5px solid var(--border); border-radius: 12px; text-align: center; padding-left: 20px !important; }
.gate-btn { background: var(--purple); color: white; border: none; padding: 16px 32px; border-radius: 12px; font-size: 1rem; font-weight: 700; cursor: pointer; transition: all 0.2s; font-family: inherit; }
.gate-btn:hover { background: #1d4ed8; transform: translateY(-1px); box-shadow: 0 10px 20px -5px rgba(37, 99, 235, 0.4); }
.gate-footnote { margin-top: 16px; font-size: 0.8rem; color: var(--text-muted); }
.gate-footnote strong { color: var(--ink); }
.gate-success { max-width: 440px; margin: 0 auto; padding: 20px; background: rgba(16, 185, 129, 0.1); color: var(--accent); border-radius: 12px; font-weight: 600; }

/* === JEFF CTA === */
.jeff-cta { max-width: 1100px; margin: 60px auto; padding: 32px 40px; display: grid; grid-template-columns: auto 1fr auto; gap: 24px; align-items: center; background: var(--ink); border-radius: 24px; color: white; }
.jeff-photo-img { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; }
.jeff-photo { width: 80px; height: 80px; border-radius: 50%; background: #94a3b8; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.5rem; color: var(--ink); }
.jeff-text h4 { font-size: 1.2rem; font-weight: 700; margin-bottom: 4px; }
.jeff-text p { color: #cbd5e1; font-size: 0.95rem; }
.jeff-btn { background: var(--purple); color: white; padding: 14px 28px; border-radius: 999px; text-decoration: none; font-weight: 700; white-space: nowrap; }
.jeff-btn:hover { background: #1d4ed8; }

/* === FAQ === */
.faq-section { max-width: 900px; margin: 80px auto; padding: 0 24px; }
.faq-section h2 { font-size: 2rem; font-weight: 800; margin-bottom: 8px; text-align: center; }
.faq-section .subtitle { color: var(--text-muted); text-align: center; margin-bottom: 40px; }
.faq-item { background: white; border-radius: 16px; padding: 24px 28px; margin-bottom: 12px; border: 1px solid var(--border); }
.faq-item h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; color: var(--ink); }
.faq-item p { color: var(--text-muted); line-height: 1.7; }
.faq-item a { color: var(--purple); text-decoration: none; font-weight: 600; }

/* === FOOTER === */
.calc-footer { max-width: 1100px; margin: 40px auto 40px; padding: 0 24px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }
.calc-footer p { margin-bottom: 8px; }
.calc-footer .small { font-size: 0.75rem; line-height: 1.6; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .nav { padding: 14px 16px; }
  .nav-links { display: none; }
  .hero { padding: 36px 20px 100px; }
  .calc-wrapper { padding: 0 16px; margin-top: -50px; }
  .calc-body { grid-template-columns: 1fr; }
  .calc-inputs, .calc-results { padding: 24px 20px; }
  .calc-inputs { border-right: none; border-bottom: 1px solid var(--border); }
  .input-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  /* Keep down-payment $/% toggle inline but tighten spacing */
  .down-payment-row { gap: 6px; }
  .dp-toggle-btn { padding: 8px 10px; min-width: 34px; font-size: 0.85rem; }
  /* Results hero */
  .result-amount { font-size: 2.5rem; }
  .result-amount .currency { font-size: 1.5rem; }
  .result-hero { padding-bottom: 20px; margin-bottom: 20px; }
  /* Rate detail badge wraps cleanly */
  .rate-badge { line-height: 1.5; }
  /* Summary grid stays 2-col but tighter */
  .summary-grid { gap: 14px; margin-top: 20px; padding-top: 18px; }
  .summary-value { font-size: 1.1rem; }
  /* Recommendations section */
  .recommendations-section { padding: 24px 20px 28px; }
  .rec-card { grid-template-columns: 1fr; text-align: left; padding: 16px 18px; }
  .rec-savings { text-align: left; }
  .rec-savings-val { font-size: 1.1rem; }
  /* Amortization section */
  .amort-section { margin: 40px auto; padding: 0 16px; }
  .amort-header { padding: 24px 20px 18px; }
  .amort-header h3 { font-size: 1.25rem; }
  .amort-table th, .amort-table td { padding: 12px 14px; font-size: 0.85rem; }
  /* Gate form */
  .amort-gate { padding: 36px 20px 28px; }
  .gate-headline { font-size: 1.3rem; }
  /* Jeff CTA */
  .jeff-cta { grid-template-columns: 1fr; text-align: center; padding: 24px 20px; gap: 16px; margin: 40px 16px; }
  .jeff-photo-img, .jeff-photo { margin: 0 auto; }
  /* FAQ */
  .faq-section { margin: 48px auto; padding: 0 16px; }
  .faq-section h2 { font-size: 1.6rem; }
  .faq-item { padding: 18px 20px; }
  .faq-item h3 { font-size: 1rem; }
  /* Footer */
  .calc-footer { padding: 0 16px; }
  /* VA/FHA conditional cards */
  .va-fields, .fha-note { padding: 14px 16px; }
  /* Mi disclaimer tighter */
  .mi-disclaimer, .jumbo-disclaimer { padding: 12px 14px; font-size: 0.78rem; }
}

/* Extra tight for small phones (iPhone SE / 360px Android) */
@media (max-width: 400px) {
  .calc-inputs h2 { font-size: 1.25rem; }
  .tab { min-width: 110px; padding: 14px 14px; font-size: 0.82rem; }
  .result-amount { font-size: 2.2rem; }
  .input-grid { gap: 10px; }
}
