:root {
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --primary-light: #eff6ff;
  --green: #16a34a;
  --green-light: #f0fdf4;
  --text: #1f2937;
  --text-light: #6b7280;
  --border: #e5e7eb;
  --white: #fff;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f9fafb; color: var(--text); line-height: 1.6; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

header { background: linear-gradient(135deg, #1e3a8a 0%, var(--primary) 100%); color: white; padding: 32px 0 28px; text-align: center; }
header h1 { font-size: clamp(1.5rem, 4vw, 2.2rem); font-weight: 700; margin-bottom: 8px; }
.subtitle { font-size: 0.92rem; opacity: 0.9; }

.calculator-layout { display: grid; grid-template-columns: 1fr 1.1fr; gap: 24px; margin: 32px 0 24px; }
@media (max-width: 768px) { .calculator-layout { grid-template-columns: 1fr; } }

.input-panel, .result-panel { background: var(--white); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.panel-title { font-size: 1.05rem; font-weight: 700; color: var(--primary); margin-bottom: 18px; padding-bottom: 10px; border-bottom: 2px solid var(--primary-light); }

.form-group { margin-bottom: 16px; }
.form-group > label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
.optional { font-weight: 400; font-size: 0.8rem; color: var(--text-light); }

.input-prefix { display: flex; align-items: center; border: 1.5px solid var(--border); border-radius: 8px; overflow: hidden; }
.input-prefix:focus-within { border-color: var(--primary); }
.prefix { padding: 9px 10px; background: #f3f4f6; font-weight: 600; color: var(--text-light); }
.input-prefix input { flex: 1; border: none; outline: none; padding: 9px 12px; font-size: 0.95rem; }

.input-suffix { display: flex; align-items: center; border: 1.5px solid var(--border); border-radius: 8px; overflow: hidden; }
.input-suffix:focus-within { border-color: var(--primary); }
.suffix { padding: 9px 10px; background: #f3f4f6; font-size: 0.85rem; color: var(--text-light); white-space: nowrap; }
.input-suffix input { flex: 1; border: none; outline: none; padding: 9px 12px; font-size: 0.95rem; }

.down-row { display: flex; gap: 8px; }
.down-row .input-prefix { flex: 1; }

select { width: 100%; border: 1.5px solid var(--border); border-radius: 8px; padding: 9px 10px; font-size: 0.9rem; outline: none; background: white; }
select:focus { border-color: var(--primary); }

.extras-details { border: 1.5px solid var(--border); border-radius: 8px; overflow: hidden; }
.extras-details summary { padding: 10px 14px; font-size: 0.88rem; font-weight: 600; cursor: pointer; color: var(--text-light); }
.extras-body { padding: 14px; border-top: 1px solid var(--border); }
.extras-body .form-group:last-child { margin-bottom: 0; }

.empty-state { text-align: center; color: var(--text-light); padding: 40px 20px; font-size: 0.9rem; }

/* Result */
.result-main { background: var(--primary); color: white; border-radius: 12px; padding: 20px; text-align: center; margin-bottom: 16px; }
.main-label { font-size: 0.85rem; opacity: 0.85; margin-bottom: 4px; }
.main-value { font-size: 2.6rem; font-weight: 700; line-height: 1.1; }
.main-sub { font-size: 0.8rem; opacity: 0.8; margin-top: 4px; }

.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.result-card { border-radius: 10px; padding: 12px; text-align: center; }
.result-card.blue-light { background: var(--primary-light); }
.result-card.green-light { background: var(--green-light); }
.rc-label { font-size: 0.74rem; font-weight: 600; color: var(--text-light); margin-bottom: 4px; }
.rc-value { font-size: 1.1rem; font-weight: 700; }
.blue-light .rc-value { color: var(--primary); }
.green-light .rc-value { color: var(--green); }

.extra-savings { background: var(--green-light); border: 1px solid #86efac; border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.extra-savings h3 { font-size: 0.9rem; color: var(--green); margin-bottom: 8px; }
.saving-row { display: flex; justify-content: space-between; font-size: 0.87rem; margin-bottom: 4px; }
.saving-val { font-weight: 700; color: var(--green); }

.pmi-notice { background: #fef9c3; border: 1px solid #fde047; border-radius: 8px; padding: 10px 12px; font-size: 0.82rem; margin-bottom: 12px; }

.total-cost-bar { margin-top: 4px; }
.tcb-labels { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--text-light); margin-bottom: 4px; }
.tcb-track { height: 10px; border-radius: 5px; background: #e5e7eb; overflow: hidden; }
.tcb-fill { height: 100%; border-radius: 5px; background: linear-gradient(to right, var(--primary), #60a5fa); transition: width 0.4s; }

/* Chart */
.chart-section { background: var(--white); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 24px; }
.chart-section h2 { font-size: 1.05rem; margin-bottom: 6px; }
.chart-note { font-size: 0.8rem; color: var(--text-light); margin-bottom: 14px; }
.chart-wrap canvas { max-height: 300px; }

/* Amortization table */
.amort-section { background: var(--white); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 24px; }
.amort-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.amort-header h2 { font-size: 1.05rem; }
.view-toggle { display: flex; gap: 4px; }
.view-btn { border: 1.5px solid var(--border); background: none; padding: 5px 14px; border-radius: 6px; font-size: 0.82rem; cursor: pointer; color: var(--text-light); }
.view-btn.active { border-color: var(--primary); background: var(--primary); color: white; }
.table-wrapper { overflow-x: auto; }
.amort-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.amort-table th { background: var(--primary); color: white; padding: 8px 12px; text-align: right; }
.amort-table th:first-child { text-align: left; }
.amort-table td { padding: 7px 12px; border-bottom: 1px solid var(--border); text-align: right; }
.amort-table td:first-child { text-align: left; font-weight: 600; }
.amort-table tr:last-child td { border-bottom: none; font-weight: 700; background: var(--primary-light); }

/* FAQ */
.faq-section { background: var(--white); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 32px; }
.faq-section h2 { font-size: 1.05rem; margin-bottom: 14px; }
.faq-item { border-bottom: 1px solid var(--border); }
.faq-item:last-child { border-bottom: none; }
.faq-question { width: 100%; background: none; border: none; text-align: left; padding: 14px 0; font-size: 0.92rem; font-weight: 600; cursor: pointer; display: flex; justify-content: space-between; align-items: center; color: var(--text); gap: 12px; }
.faq-icon { color: var(--primary); font-size: 1.1rem; min-width: 20px; text-align: center; transition: transform 0.2s; }
.faq-question.open .faq-icon { transform: rotate(45deg); }
.faq-answer { display: none; padding: 0 0 14px; font-size: 0.88rem; line-height: 1.7; }
.faq-answer p { margin-bottom: 8px; }

footer { background: #1f2937; color: #9ca3af; padding: 24px 0; text-align: center; }
footer a { color: #9ca3af; text-decoration: underline; margin: 0 6px; }
.disclaimer { font-size: 0.78rem; margin-top: 8px; }
