/* ==========================================================================
   LoanPayoff.io — Design system
   ========================================================================== */

:root {
  --navy-900: #0a1f3d;
  --navy-800: #0f2a4a;
  --navy-700: #15375e;
  --navy-600: #1c4a7a;
  --blue-500: #2563eb;
  --blue-400: #3b82f6;
  --teal-600: #0d9488;
  --teal-500: #0ea5a0;
  --green-600: #0e9f6e;
  --green-500: #16b981;
  --amber-500: #f59e0b;
  --red-500: #e11d48;

  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  --white: #ffffff;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

  --container: 1180px;
}

/* ----------------------------- Reset ---------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--gray-800);
  background: var(--white);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p, ul, ol, figure { margin: 0 0 0.75em; }
ul, ol { padding-left: 1.2em; }
button { font-family: inherit; cursor: pointer; }
input, select, button { font-family: inherit; font-size: 1rem; }
table { border-collapse: collapse; width: 100%; }

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 20px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--white);
  color: var(--navy-900);
  padding: 10px 16px;
  z-index: 1000;
  border-radius: 0 0 var(--radius-sm) 0;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ----------------------------- Topbar ---------------------------------- */
.topbar {
  background: var(--navy-900);
  color: var(--gray-200);
  font-size: 0.82rem;
}
.topbar .container {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-top: 6px;
  padding-bottom: 6px;
  flex-wrap: wrap;
}
.topbar span { white-space: nowrap; }

/* ----------------------------- Header ----------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--navy-900);
  flex-shrink: 0;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--teal-500), var(--blue-500));
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
}

.main-nav { display: flex; align-items: center; gap: 4px; flex: 1; justify-content: flex-end; }
.nav-list { display: flex; align-items: center; gap: 4px; list-style: none; margin: 0; padding: 0; }
.nav-list > li { position: relative; }
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--gray-700);
}
.nav-link:hover, .nav-link:focus-visible { background: var(--gray-100); color: var(--navy-900); }
.nav-caret { font-size: 0.65rem; transition: transform 0.15s ease; }
.has-mega:hover .nav-caret, .has-mega:focus-within .nav-caret { transform: rotate(180deg); }

.mega-menu {
  position: absolute;
  top: 100%;
  left: -120px;
  width: 620px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 20px;
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 4px 20px;
  z-index: 200;
}
.has-mega:hover .mega-menu,
.has-mega:focus-within .mega-menu { display: grid; }
.mega-item {
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}
.mega-item:hover { background: var(--gray-100); }
.mega-item .mega-title { font-weight: 700; font-size: 0.9rem; color: var(--navy-900); display: flex; align-items: center; gap: 6px; }
.mega-item .mega-sub { font-size: 0.78rem; color: var(--gray-500); margin-top: 2px; }

.nav-cta {
  background: var(--teal-600);
  color: var(--white);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  margin-left: 6px;
}
.nav-cta:hover { background: var(--teal-500); }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
}
.nav-toggle span, .nav-toggle span::before, .nav-toggle span::after {
  content: "";
  display: block;
  width: 20px;
  height: 2px;
  background: var(--navy-900);
  position: relative;
  transition: all 0.15s ease;
}
.nav-toggle span::before { position: absolute; top: -6px; }
.nav-toggle span::after { position: absolute; top: 6px; }

/* ----------------------------- Hero ------------------------------------- */
.hero {
  background: radial-gradient(ellipse at top right, rgba(14,165,160,0.25), transparent 55%),
              linear-gradient(160deg, var(--navy-900), var(--navy-800));
  color: var(--white);
  padding: 64px 0 56px;
}
.eyebrow {
  display: inline-block;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--gray-100);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 18px;
}
.hero h1 { font-size: clamp(2rem, 4vw, 2.9rem); font-weight: 800; max-width: 760px; line-height: 1.15; }
.hero .lead { font-size: 1.1rem; color: var(--gray-200); max-width: 640px; margin-top: 14px; }
.hero-stats { display: flex; gap: 32px; margin: 28px 0; flex-wrap: wrap; }
.hero-stat .num { font-size: 1.7rem; font-weight: 800; color: var(--teal-500); }
.hero-stat .label { font-size: 0.82rem; color: var(--gray-300); }
.hero-ctas { display: flex; gap: 14px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 24px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.95rem;
  border: 2px solid transparent;
}
.btn-primary { background: var(--teal-600); color: var(--white); }
.btn-primary:hover { background: var(--teal-500); }
.btn-secondary { background: transparent; color: var(--white); border-color: rgba(255,255,255,0.4); }
.btn-secondary:hover { border-color: var(--white); }
.btn-outline { background: var(--white); color: var(--navy-900); border-color: var(--gray-300); }
.btn-outline:hover { border-color: var(--navy-600); }

/* ----------------------------- Trust strip ------------------------------ */
.trust-strip { background: var(--navy-800); color: var(--gray-200); padding: 18px 0; }
.trust-strip .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 14px; }
.trust-item { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 600; }

/* ----------------------------- Sections --------------------------------- */
.section { padding: 60px 0; }
.section-head { text-align: center; max-width: 640px; margin: 0 auto 40px; }
.section-head h2 { font-size: clamp(1.6rem, 3vw, 2.1rem); color: var(--navy-900); font-weight: 800; }
.section-head p { color: var(--gray-500); }

/* ----------------------------- Calc grid -------------------------------- */
.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}
.calc-card {
  position: relative;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.calc-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--teal-500); }
.calc-icon { font-size: 1.8rem; margin-bottom: 12px; display: inline-block; }
.calc-card h3 { font-size: 1.05rem; color: var(--navy-900); font-weight: 700; }
.calc-card p { color: var(--gray-500); font-size: 0.9rem; }
.calc-tag {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--amber-500);
  color: var(--navy-900);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 4px 8px;
  border-radius: 999px;
}

/* ----------------------------- Ad slot ---------------------------------- */
.ad-slot {
  border: 1px dashed var(--gray-300);
  border-radius: var(--radius-md);
  background: var(--gray-50);
  color: var(--gray-400);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  min-height: 90px;
  text-align: center;
  padding: 12px;
}
.ad-slot.ad-leaderboard { min-height: 90px; }
.ad-slot.ad-box { min-height: 250px; }
.ad-slot.ad-sticky { min-height: 250px; position: sticky; top: 84px; }

/* ----------------------------- Feature grid ------------------------------ */
.feature-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
.feature-item { text-align: left; }
.feature-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--teal-500), var(--blue-500));
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 14px;
}
.feature-item h3 { font-size: 1rem; color: var(--navy-900); font-weight: 700; }
.feature-item p { color: var(--gray-500); font-size: 0.88rem; }

/* ----------------------------- Article ----------------------------------- */
.article { max-width: 820px; margin: 0 auto; }
.article h2 { font-size: 1.5rem; color: var(--navy-900); font-weight: 800; margin-top: 1.6em; }
.article h3 { font-size: 1.15rem; color: var(--navy-900); font-weight: 700; margin-top: 1.4em; }
.article p, .article li { color: var(--gray-700); }
.article table { margin: 1.2em 0; font-size: 0.92rem; }
.article th, .article td { border: 1px solid var(--gray-200); padding: 10px 12px; text-align: left; }
.article th { background: var(--gray-100); color: var(--navy-900); }

.callout {
  background: #eaf2ff;
  border: 1px solid #c8dcff;
  border-left: 4px solid var(--blue-500);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin: 1.4em 0;
  font-size: 0.92rem;
  color: var(--navy-800);
}
.callout strong { color: var(--navy-900); }

.formula-box {
  background: var(--navy-900);
  color: #d7e8ff;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.88rem;
  border-radius: var(--radius-md);
  padding: 18px 20px;
  overflow-x: auto;
  margin: 1.2em 0;
  line-height: 1.7;
}
.formula-box .muted { color: #93a9c9; }

/* ----------------------------- FAQ ---------------------------------------- */
.faq-list { margin-top: 12px; }
.faq-item { border-bottom: 1px solid var(--gray-200); }
.faq-q {
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  padding: 18px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--navy-900);
}
.faq-q::after { content: "+"; font-size: 1.3rem; color: var(--teal-600); transition: transform 0.15s ease; }
.faq-item.open .faq-q::after { transform: rotate(45deg); }
.faq-a {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease;
  color: var(--gray-600);
  font-size: 0.92rem;
  padding: 0 4px;
}
.faq-a > div { padding-bottom: 18px; }
.faq-item.open .faq-a { max-height: 600px; }

/* ----------------------------- Breadcrumbs -------------------------------- */
.breadcrumbs { font-size: 0.82rem; color: var(--gray-500); margin-bottom: 14px; }
.breadcrumbs a { color: var(--gray-500); }
.breadcrumbs a:hover { color: var(--teal-600); }
.breadcrumbs .sep { margin: 0 6px; color: var(--gray-300); }

/* ----------------------------- Calc page layout ---------------------------- */
.calc-hero { background: var(--navy-900); color: var(--white); padding: 36px 0 40px; }
.calc-hero h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 800; }
.calc-hero p { color: var(--gray-300); max-width: 700px; margin-top: 10px; }

.calc-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 32px;
  padding: 40px 0 60px;
  align-items: start;
}

.calc-panel {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  margin-top: -70px;
  position: relative;
  z-index: 2;
}
.calc-panel h2 { margin-top: 0; font-size: 1.2rem; color: var(--navy-900); font-weight: 800; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 6px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 0.85rem; font-weight: 600; color: var(--gray-700); }
.field-input { position: relative; display: flex; align-items: center; }
.field-input .prefix, .field-input .suffix {
  position: absolute;
  color: var(--gray-400);
  font-weight: 600;
  pointer-events: none;
}
.field-input .prefix { left: 12px; }
.field-input .suffix { right: 12px; }
.field-input input, .field-input select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--gray-800);
}
.field-input.has-prefix input { padding-left: 26px; }
.field-input.has-suffix input { padding-right: 30px; }
.field-input input:focus, .field-input select:focus {
  outline: none;
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(14,165,160,0.15);
}
.field-hint { font-size: 0.76rem; color: var(--gray-400); }

.debt-rows { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.debt-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 12px;
}
.debt-row .field label { font-size: 0.72rem; }
.row-remove {
  background: var(--white);
  border: 1px solid var(--gray-300);
  color: var(--red-500);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-size: 1rem;
}
.row-remove:hover { background: #fee2e2; }
.add-row-btn {
  align-self: flex-start;
  background: var(--white);
  border: 1px dashed var(--gray-300);
  color: var(--teal-600);
  font-weight: 700;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
}
.add-row-btn:hover { border-color: var(--teal-500); background: #f0fdfa; }

.calc-actions { display: flex; gap: 12px; margin-top: 18px; }
.btn-calc { background: var(--teal-600); color: var(--white); border: none; padding: 13px 26px; border-radius: var(--radius-sm); font-weight: 700; }
.btn-calc:hover { background: var(--teal-500); }
.btn-reset { background: var(--white); color: var(--gray-600); border: 1px solid var(--gray-300); padding: 13px 22px; border-radius: var(--radius-sm); font-weight: 700; }
.btn-reset:hover { border-color: var(--gray-400); }

.results {
  background: var(--navy-900);
  color: var(--white);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-top: 26px;
}
.results.is-hidden { display: none; }
.results h2 { color: var(--white); font-size: 1.1rem; font-weight: 700; margin-bottom: 18px; }
.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 18px; }
.result-item .value { font-size: 1.6rem; font-weight: 800; }
.result-item .label { font-size: 0.8rem; color: var(--gray-300); margin-top: 2px; }
.result-item.good .value { color: var(--green-500); }
.result-item.warn .value { color: var(--amber-500); }

.chart-wrap { margin-top: 22px; background: rgba(255,255,255,0.04); border-radius: var(--radius-md); padding: 16px; }
.chart-wrap canvas { width: 100%; height: 260px; }
.chart-legend { display: flex; gap: 18px; margin-top: 10px; flex-wrap: wrap; font-size: 0.78rem; color: var(--gray-300); }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }

.table-scroll { overflow-x: auto; margin-top: 18px; border: 1px solid var(--gray-200); border-radius: var(--radius-md); max-height: 420px; }
.table-scroll table { min-width: 560px; font-size: 0.88rem; }
.table-scroll thead th {
  position: sticky;
  top: 0;
  background: var(--navy-800);
  color: var(--white);
  padding: 10px 12px;
  text-align: left;
  z-index: 1;
}
.table-scroll td { padding: 8px 12px; border-bottom: 1px solid var(--gray-100); }
.table-scroll tbody tr:nth-child(even) { background: var(--gray-50); }

.calc-article { margin-top: 56px; }

.sidebar { display: flex; flex-direction: column; gap: 20px; position: sticky; top: 84px; }
.sidebar-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.sidebar-card h3 { font-size: 0.92rem; color: var(--navy-900); font-weight: 800; margin-bottom: 10px; }
.related-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.related-list a { font-size: 0.86rem; font-weight: 600; color: var(--gray-700); display: block; }
.related-list a:hover { color: var(--teal-600); }

/* ----------------------------- Footer -------------------------------------- */
.site-footer { background: var(--navy-900); color: var(--gray-300); padding-top: 48px; }
.disclaimer-box {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  font-size: 0.8rem;
  color: var(--gray-400);
  margin-bottom: 40px;
}
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 28px; padding-bottom: 36px; }
.footer-brand .brand { color: var(--white); }
.footer-brand p { color: var(--gray-400); font-size: 0.86rem; margin-top: 12px; }
.footer-col h4 { color: var(--white); font-size: 0.86rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 14px; }
.footer-col ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.footer-col a { font-size: 0.86rem; color: var(--gray-400); }
.footer-col a:hover { color: var(--teal-500); }
.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding: 20px 0;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--gray-500);
}

/* ----------------------------- Static/simple pages -------------------------- */
.page-hero { background: var(--navy-900); color: var(--white); padding: 48px 0; }
.page-hero h1 { font-size: clamp(1.8rem, 3.5vw, 2.4rem); font-weight: 800; }
.page-hero p { color: var(--gray-300); max-width: 680px; margin-top: 10px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-status { margin-top: 14px; font-size: 0.9rem; font-weight: 600; }
.form-status.success { color: var(--green-600); }
.form-status.error { color: var(--red-500); }
.honeypot { position: absolute; left: -9999px; opacity: 0; height: 0; }

.mini-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 30px; }

/* ----------------------------- Responsive ----------------------------------- */
@media (max-width: 980px) {
  .main-nav { position: fixed; inset: 68px 0 0 0; background: var(--white); flex-direction: column; align-items: stretch; padding: 20px; overflow-y: auto; transform: translateX(100%); transition: transform 0.2s ease; }
  .main-nav.open { transform: translateX(0); }
  .nav-list { flex-direction: column; align-items: stretch; gap: 0; }
  .nav-list > li { width: 100%; }
  .nav-link { width: 100%; justify-content: space-between; }
  .mega-menu { position: static; width: 100%; display: none; grid-template-columns: 1fr; box-shadow: none; border: none; padding: 6px 0 6px 10px; }
  .has-mega.open .mega-menu { display: grid; }
  .nav-cta { margin: 14px 0 0; text-align: center; justify-content: center; }
  .nav-toggle { display: flex; }

  .feature-grid { grid-template-columns: 1fr 1fr; }
  .calc-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; flex-direction: row; flex-wrap: wrap; }
  .sidebar-card { flex: 1 1 260px; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .debt-row { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .mini-grid { grid-template-columns: 1fr; }
  .calc-panel { margin-top: -40px; }
}

@media (max-width: 600px) {
  .field-grid { grid-template-columns: 1fr; }
  .hero-stats { gap: 20px; }
  .feature-grid { grid-template-columns: 1fr; }
}
