@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ================================================
   DESIGN TOKENS
   ================================================ */
:root {
  --navy:    #1a3c5e;
  --navy-dk: #0f2440;
  --blue:    #2563eb;
  --blue-lt: #dbeafe;
  --green:   #059669;
  --green-lt:#d1fae5;
  --yellow:  #d97706;
  --yellow-lt:#fef3c7;
  --red:     #dc2626;
  --red-lt:  #fee2e2;
  --gray-50: #f8fafc;
  --gray-100:#f1f5f9;
  --gray-200:#e2e8f0;
  --gray-300:#cbd5e1;
  --gray-400:#94a3b8;
  --gray-500:#64748b;
  --gray-700:#334155;
  --gray-900:#0f172a;
  --white:   #ffffff;
  --radius:  6px;
  --radius-lg:10px;
  --shadow:  0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --nav-width:240px;
  --transition: .18s ease;
}

/* ================================================
   RESET & BASE
   ================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--gray-50);
  color: var(--gray-700);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ================================================
   HEADER
   ================================================ */
.site-header {
  background: var(--navy);
  color: var(--white);
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.site-header .brand {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--white);
}
.site-header .brand span { color: #60a5fa; }
.site-header nav a {
  color: rgba(255,255,255,.8);
  font-size: .875rem;
  font-weight: 500;
  margin-left: 1.5rem;
  transition: color var(--transition);
}
.site-header nav a:hover { color: var(--white); text-decoration: none; }

/* ================================================
   LAYOUT
   ================================================ */
.layout {
  display: flex;
  min-height: calc(100vh - 56px);
}

/* ================================================
   SIDEBAR NAV
   ================================================ */
.sidebar {
  width: var(--nav-width);
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  flex-shrink: 0;
  scrollbar-width: thin;
}
.sidebar-section {
  padding: .625rem .75rem .25rem;
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-400);
  margin-top: .5rem;
}
.sidebar a {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .75rem;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--gray-700);
  border-radius: var(--radius);
  margin: 1px .375rem;
  transition: background var(--transition), color var(--transition);
}
.sidebar a:hover { background: var(--gray-100); color: var(--navy); text-decoration: none; }
.sidebar a.active { background: var(--blue-lt); color: var(--blue); font-weight: 600; }
.sidebar a .icon { font-size: 1rem; width: 1.25rem; text-align: center; }

/* ================================================
   MAIN CONTENT
   ================================================ */
.main-content {
  flex: 1;
  padding: 2rem 2.5rem 4rem;
  max-width: 900px;
}

/* ================================================
   CALCULATOR SECTIONS
   ================================================ */
.calc-section { display: none; }
.calc-section.active { display: block; }

.calc-title {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -.025em;
  margin-bottom: .25rem;
}
.calc-subtitle {
  font-size: .9375rem;
  color: var(--gray-500);
  margin-bottom: 1.5rem;
}

/* ================================================
   CALC CARD
   ================================================ */
.calc-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.calc-body {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0;
}
.calc-inputs {
  padding: 1.5rem;
  border-right: 1px solid var(--gray-200);
}
.calc-results {
  padding: 1.5rem;
  width: 280px;
  background: var(--gray-50);
}

/* ================================================
   FORM CONTROLS
   ================================================ */
.field { margin-bottom: 1rem; }
.field label {
  display: block;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: .375rem;
}
.field label .hint {
  font-weight: 400;
  color: var(--gray-400);
  font-size: .75rem;
  margin-left: .25rem;
}
.input-wrap {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  overflow: hidden;
}
.input-wrap:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.input-wrap .prefix, .input-wrap .suffix {
  padding: 0 .625rem;
  font-size: .875rem;
  font-weight: 500;
  color: var(--gray-500);
  background: var(--gray-100);
  border-right: 1px solid var(--gray-200);
  height: 38px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.input-wrap .suffix {
  border-right: none;
  border-left: 1px solid var(--gray-200);
}
.input-wrap input[type="number"],
.input-wrap input[type="text"] {
  flex: 1;
  border: none;
  outline: none;
  padding: 0 .625rem;
  font-size: .9375rem;
  font-family: inherit;
  color: var(--gray-900);
  height: 38px;
  background: transparent;
  width: 100%;
}
/* Remove spin buttons */
.input-wrap input[type="number"]::-webkit-inner-spin-button,
.input-wrap input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
.input-wrap input[type="number"] { -moz-appearance: textfield; }

.field select {
  width: 100%;
  height: 38px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 0 .625rem;
  font-size: .9375rem;
  font-family: inherit;
  color: var(--gray-900);
  background: var(--white);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* ================================================
   SLIDERS  (Zillow-style)
   ================================================ */
.slider-field { margin-bottom: 1rem; }
.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: .375rem;
}
.slider-header label {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--gray-700);
}
.slider-value {
  font-size: .9375rem;
  font-weight: 700;
  color: var(--blue);
}
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: var(--gray-200);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .1s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: .6875rem;
  color: var(--gray-400);
  margin-top: .25rem;
}

/* ================================================
   CALC BUTTON
   ================================================ */
.btn-calc {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  background: var(--blue);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  padding: .5625rem 1.25rem;
  font-size: .9375rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition), transform .1s;
  margin-top: .25rem;
}
.btn-calc:hover { background: #1d4ed8; }
.btn-calc:active { transform: scale(.98); }
.btn-secondary {
  background: var(--white);
  color: var(--blue);
  border: 1.5px solid var(--blue);
}
.btn-secondary:hover { background: var(--blue-lt); }

/* ================================================
   RESULTS PANEL
   ================================================ */
.result-primary {
  text-align: center;
  margin-bottom: 1.25rem;
}
.result-primary .label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-500);
  margin-bottom: .25rem;
}
.result-primary .value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--green);
  letter-spacing: -.03em;
  line-height: 1.1;
}
.result-primary .sub {
  font-size: .8125rem;
  color: var(--gray-500);
  margin-top: .125rem;
}

.result-list { list-style: none; }
.result-list li {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: .5rem 0;
  border-bottom: 1px solid var(--gray-200);
  font-size: .8125rem;
  gap: .5rem;
}
.result-list li:last-child { border-bottom: none; }
.result-list li .rl-label { color: var(--gray-500); }
.result-list li .rl-value { font-weight: 600; color: var(--gray-900); text-align: right; }
.result-list li .rl-value.green { color: var(--green); }
.result-list li .rl-value.yellow { color: var(--yellow); }
.result-list li .rl-value.red { color: var(--red); }

/* ================================================
   BADGE / PILLS
   ================================================ */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.badge-green { background: var(--green-lt); color: var(--green); }
.badge-yellow { background: var(--yellow-lt); color: var(--yellow); }
.badge-red { background: var(--red-lt); color: var(--red); }
.badge-blue { background: var(--blue-lt); color: var(--blue); }

/* ================================================
   COMPARISON TABLE (Down Payment Explorer, etc.)
   ================================================ */
.compare-table-wrap { overflow-x: auto; margin-bottom: 1.5rem; }
.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8125rem;
}
.compare-table th {
  background: var(--navy);
  color: var(--white);
  padding: .625rem .875rem;
  text-align: right;
  font-weight: 600;
  font-size: .75rem;
  letter-spacing: .03em;
}
.compare-table th:first-child { text-align: left; border-radius: var(--radius) 0 0 0; }
.compare-table th:last-child { border-radius: 0 var(--radius) 0 0; }
.compare-table td {
  padding: .5625rem .875rem;
  text-align: right;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: middle;
}
.compare-table td:first-child { text-align: left; font-weight: 600; }
.compare-table tr:last-child td { border-bottom: none; }
.compare-table tr:nth-child(even) td { background: var(--gray-50); }
.compare-table .highlight-row td { background: var(--green-lt) !important; font-weight: 700; }
.compare-table .caution-row td { background: var(--yellow-lt) !important; }
.compare-table .risk-row td { background: var(--red-lt) !important; }

/* ================================================
   INFO BOX / EXPLAINER TEXT
   ================================================ */
.info-box {
  border-left: 3px solid var(--blue);
  background: var(--blue-lt);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: .875rem 1rem;
  margin-bottom: 1rem;
  font-size: .875rem;
}
.info-box strong { color: var(--navy); }
.warn-box {
  border-left: 3px solid var(--yellow);
  background: var(--yellow-lt);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: .875rem 1rem;
  margin-bottom: 1rem;
  font-size: .875rem;
}

/* ================================================
   EXPLAINER / BELOW CALCULATOR COPY
   ================================================ */
.explainer {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-top: 1.5rem;
}
.explainer h2 {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: .75rem;
}
.explainer h3 {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--gray-700);
  margin: 1rem 0 .375rem;
}
.explainer p { font-size: .9rem; color: var(--gray-700); margin-bottom: .625rem; line-height: 1.65; }
.explainer ul { padding-left: 1.25rem; margin-bottom: .625rem; }
.explainer ul li { font-size: .9rem; color: var(--gray-700); margin-bottom: .25rem; line-height: 1.6; }

/* ================================================
   FAQ SECTION (SEO/LLM structured content)
   ================================================ */
.faq { margin-top: 1.25rem; border-top: 1px solid var(--gray-200); padding-top: 1rem; }
.faq-item { margin-bottom: .875rem; }
.faq-item dt {
  font-size: .9rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: .25rem;
}
.faq-item dd { font-size: .875rem; color: var(--gray-700); line-height: 1.65; }

/* ================================================
   AMORTIZATION TABLE
   ================================================ */
.amort-table-wrap {
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-top: 1rem;
  scrollbar-width: thin;
}
.amort-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8125rem;
}
.amort-table thead th {
  background: var(--gray-100);
  position: sticky;
  top: 0;
  padding: .5rem .75rem;
  text-align: right;
  font-weight: 600;
  font-size: .75rem;
  border-bottom: 1px solid var(--gray-200);
  color: var(--gray-700);
}
.amort-table thead th:first-child { text-align: left; }
.amort-table td {
  padding: .4375rem .75rem;
  text-align: right;
  border-bottom: 1px solid var(--gray-100);
  font-size: .8rem;
}
.amort-table td:first-child { text-align: left; font-weight: 500; }
.amort-table tr:last-child td { border-bottom: none; }

/* ================================================
   LTV METER (visual)
   ================================================ */
.ltv-meter-wrap { margin: 1rem 0; }
.ltv-meter-label {
  display: flex;
  justify-content: space-between;
  font-size: .75rem;
  color: var(--gray-500);
  margin-bottom: .375rem;
  font-weight: 500;
}
.ltv-meter-bar {
  height: 12px;
  border-radius: 999px;
  background: var(--gray-200);
  overflow: hidden;
}
.ltv-meter-fill {
  height: 100%;
  border-radius: 999px;
  transition: width .4s ease, background .4s ease;
}

/* ================================================
   TABS (ARM vs Fixed, etc.)
   ================================================ */
.tab-bar {
  display: flex;
  gap: .25rem;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 1.25rem;
}
.tab-btn {
  padding: .5rem 1rem;
  font-size: .875rem;
  font-weight: 600;
  color: var(--gray-500);
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-family: inherit;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-btn:hover:not(.active) { color: var(--gray-700); }

/* ================================================
   BALLOON TERM CHIPS
   ================================================ */
.term-chips { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip {
  display: inline-block;
  padding: .3125rem .875rem;
  border-radius: 999px;
  font-size: .8125rem;
  font-weight: 600;
  border: 1.5px solid var(--gray-300);
  color: var(--gray-700);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  background: var(--white);
}
.chip.active { background: var(--navy); border-color: var(--navy); color: var(--white); }
.chip:hover:not(.active) { border-color: var(--blue); color: var(--blue); }

/* ================================================
   RENT VS OWN VISUAL
   ================================================ */
.rvo-bars { display: flex; gap: 1.5rem; align-items: flex-end; margin: 1rem 0; height: 120px; }
.rvo-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .375rem; }
.rvo-bar {
  width: 100%;
  border-radius: var(--radius) var(--radius) 0 0;
  transition: height .5s cubic-bezier(.4,0,.2,1);
  min-height: 4px;
}
.rvo-bar-rent { background: linear-gradient(180deg, #f87171 0%, #ef4444 100%); }
.rvo-bar-own  { background: linear-gradient(180deg, #34d399 0%, #059669 100%); }
.rvo-bar-label { font-size: .75rem; font-weight: 700; color: var(--gray-500); }
.rvo-bar-amt   { font-size: .75rem; font-weight: 700; }

/* ================================================
   FOOTER
   ================================================ */
.site-footer {
  background: var(--navy-dk);
  color: rgba(255,255,255,.55);
  font-size: .8125rem;
  padding: 2rem 2.5rem;
  margin-top: auto;
}
.site-footer a { color: rgba(255,255,255,.7); }
.site-footer .footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 2rem; margin-bottom: 1.5rem; }
.site-footer h4 { color: var(--white); font-size: .875rem; font-weight: 600; margin-bottom: .75rem; }
.site-footer ul { list-style: none; }
.site-footer ul li { margin-bottom: .375rem; }
.site-footer .footer-copy { border-top: 1px solid rgba(255,255,255,.1); padding-top: 1rem; }

/* ================================================
   RESPONSIVE
   ================================================ */
@media (max-width: 768px) {
  :root { --nav-width: 0px; }
  .sidebar { display: none; }
  .main-content { padding: 1.25rem 1rem 3rem; }
  .calc-body { grid-template-columns: 1fr; }
  .calc-inputs { border-right: none; border-bottom: 1px solid var(--gray-200); }
  .calc-results { width: 100%; }
  .calc-title { font-size: 1.25rem; }
  .site-footer .footer-grid { grid-template-columns: 1fr; gap: 1rem; }

  /* Mobile hamburger menu */
  .mobile-nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1.5px solid rgba(255,255,255,.4);
    border-radius: var(--radius);
    width: 36px;
    height: 36px;
    color: var(--white);
    font-size: 1.1rem;
    cursor: pointer;
  }
  .mobile-nav-open .sidebar {
    display: block;
    position: fixed;
    top: 56px;
    left: 0;
    z-index: 200;
    width: 260px;
    height: calc(100vh - 56px);
    box-shadow: var(--shadow-md);
  }
}
@media (min-width: 769px) {
  .mobile-nav-toggle { display: none; }
}

/* ================================================
   UTILITY
   ================================================ */
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.text-yellow{ color: var(--yellow); }
.text-navy  { color: var(--navy); }
.text-sm    { font-size: .875rem; }
.text-xs    { font-size: .75rem; }
.fw-700     { font-weight: 700; }
.mt-1       { margin-top: .5rem; }
.mt-2       { margin-top: 1rem; }
.mt-3       { margin-top: 1.5rem; }
.mb-1       { margin-bottom: .5rem; }
.mb-2       { margin-bottom: 1rem; }
.flex       { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1      { gap: .5rem; }
.hidden     { display: none !important; }
