:root {
  color-scheme: light;
  --bg: #f6f8f3;
  --surface: #ffffff;
  --ink: #162018;
  --muted: #607063;
  --line: #dce4d7;
  --accent: #117a4f;
  --accent-dark: #0d5f3e;
  --accent-soft: #e2f4e9;
  --accent-pale: #f0f8f3;
  --warn: #c27a19;
  --shadow: 0 18px 50px rgba(30, 47, 28, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

select,
input[type="text"],
input[type="number"] {
  font: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(246, 248, 243, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 14px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

.brand-logo {
  display: block;
  width: clamp(178px, 22vw, 238px);
  height: auto;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 650;
}

nav a:hover {
  color: var(--accent-dark);
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 32px;
  align-items: center;
  min-height: 560px;
  padding: 64px 0 42px;
}

.hero h1 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(2.5rem, 7vw, 5.6rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.lead {
  max-width: 700px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 1.18rem;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 18px;
  font-weight: 800;
  cursor: pointer;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button.secondary {
  background: transparent;
}

.button.small {
  min-height: 38px;
  padding: 0 14px;
  font-size: 0.9rem;
}

.hero-panel,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-panel {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.hero-panel div,
.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.hero-panel span,
.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.hero-panel strong,
.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 1.35rem;
}

.calculator-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(340px, 0.95fr);
  gap: 24px;
  align-items: start;
  padding: 20px 0;
}

.panel {
  padding: 22px;
}

.results-panel {
  position: sticky;
  top: 84px;
}

.section-title h2,
.inline-title h2,
.inline-title h3 {
  margin: 0;
}

.grid {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label span,
legend {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.input-affix {
  display: flex;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.input-affix input {
  width: 100%;
  min-width: 0;
  border: 0;
  padding: 12px;
  color: var(--ink);
  outline: 0;
}

.input-affix:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input-affix span {
  display: grid;
  min-width: 68px;
  margin: 0;
  place-items: center;
  border-left: 1px solid var(--line);
  background: #f8faf6;
  color: var(--muted);
}

fieldset {
  min-width: 0;
  margin: 18px 0 0;
  padding: 0;
  border: 0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf6;
}

.segmented label {
  margin: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: grid;
  min-height: 40px;
  margin: 0;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
}

.segmented input:checked + span {
  background: var(--accent);
  color: #fff;
}

.rate-market,
.rate-fixed-fields,
.rate-mixed-fields {
  display: none;
}

.rate-mode-fixed .rate-fixed-fields {
  display: grid;
}

.rate-mode-variable .rate-market {
  display: grid;
}

.rate-mode-mixed .rate-market,
.rate-mode-mixed .rate-mixed-fields {
  display: grid;
}

.rate-mode-variable details.rate-market,
.rate-mode-mixed details.rate-market {
  display: block;
}

.advanced {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.advanced summary {
  color: var(--ink);
  font-weight: 850;
  cursor: pointer;
}

.inline-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.amortizations {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.amortization-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.amortization-row {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1.15fr auto;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfa;
}

.amortization-row select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 10px;
  color: var(--ink);
  font: inherit;
}

.remove-row {
  width: 42px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #9b2f22;
  font-weight: 900;
  cursor: pointer;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.primary-metric {
  margin-top: 18px;
  border-color: var(--accent);
  background: var(--accent-soft);
}

.primary-metric strong {
  font-size: 2rem;
}

.chart-wrap {
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
}

.note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.assumptions-box {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 16px;
}

.assumptions-box h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.assumptions-box ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.content-section {
  padding: 42px 0 18px;
}

.section-heading {
  max-width: 760px;
}

.section-heading p:not(.eyebrow) {
  margin: 12px 0 0;
  color: var(--muted);
}

.article-grid {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.article-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.article-card {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
}

.article-card span {
  display: inline-flex;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 850;
}

.article-card h3,
.method-box h3 {
  margin: 14px 0 8px;
}

.article-card p,
.method-box p {
  margin: 0;
  color: var(--muted);
}

.article-card:hover {
  border-color: #bddbc8;
  box-shadow: 0 10px 28px rgba(30, 47, 28, 0.08);
  transform: translateY(-1px);
}

.ranking-shell {
  margin-top: 20px;
}

.ranking-table {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ranking-table table {
  min-width: 900px;
}

.ranking-table td,
.ranking-table th {
  text-align: left;
  white-space: normal;
  vertical-align: top;
}

.ranking-table td strong,
.ranking-table td span,
.ranking-table td small {
  display: block;
}

.ranking-table td span,
.ranking-table td small,
.ranking-note {
  color: var(--muted);
}

.ranking-table td small {
  margin-top: 4px;
  font-size: 0.82rem;
}

.ranking-table a {
  color: var(--accent-dark);
  font-weight: 850;
}

.ranking-table .button {
  min-height: 34px;
  width: 100%;
}

.method-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent-pale);
  padding: 18px;
}

.method-box ol,
.method-box ul {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
  padding-left: 20px;
  color: var(--muted);
}

.ranking-help {
  margin-top: 16px;
}

.ranking-help ul {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding-left: 0;
  list-style: none;
}

.ranking-help li {
  border: 1px solid #bddbc8;
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.ranking-note {
  margin: 12px 0 0;
  font-size: 0.9rem;
}

.article-page {
  width: min(880px, calc(100% - 32px));
  margin: 0 auto;
  padding: 54px 0 64px;
}

.article-hero {
  margin-bottom: 28px;
}

.article-hero h1 {
  margin: 0;
  font-size: clamp(2.2rem, 6vw, 4.5rem);
  line-height: 0.98;
}

.article-hero .lead {
  max-width: 760px;
}

.article-body {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.article-body h2 {
  margin: 34px 0 10px;
  font-size: 1.55rem;
}

.article-body p,
.article-body li {
  color: #334237;
  font-size: 1.04rem;
}

.article-body ul,
.article-body ol {
  display: grid;
  gap: 8px;
  padding-left: 22px;
}

.callout {
  margin: 26px 0;
  border: 1px solid #bddbc8;
  border-radius: 8px;
  background: var(--accent-pale);
  padding: 18px;
}

.article-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.compare-hero {
  width: min(980px, 100%);
  margin: 0;
  padding: 54px 0 24px;
}

.compare-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 24px;
  align-items: start;
  padding: 20px 0 42px;
}

.compare-title {
  margin-top: 28px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.compare-offers {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.compare-offer-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.offer-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--accent-pale);
  padding: 14px;
}

.offer-card-head strong,
.offer-card-head span {
  display: block;
}

.offer-card-head strong {
  font-size: 1.08rem;
}

.offer-card-head span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.offer-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
}

.offer-summary-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 12px;
}

.offer-summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.offer-summary-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 1.05rem;
}

.compare-row-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 12px;
  align-items: end;
  padding: 0 14px 14px;
}

.compare-row-head input,
.compare-row-head select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

.field-fixed,
.field-mixed,
.field-variable,
.field-market {
  display: none;
}

.offer-fixed .field-fixed,
.offer-mixed .field-mixed,
.offer-mixed .field-market,
.offer-variable .field-variable,
.offer-variable .field-market {
  display: block;
}

.offer-details {
  border-top: 1px solid var(--line);
  padding: 0 14px;
}

.offer-details summary {
  color: var(--ink);
  cursor: pointer;
  font-weight: 850;
  padding: 14px 0;
}

.offer-details .grid,
.offer-details .bonus-grid {
  margin: 0 0 14px;
}

.bonus-hint {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.bonus-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.bonus-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.bonus-item > span {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.bonus-costs {
  display: grid;
  grid-template-columns: minmax(0, 0.75fr) minmax(0, 1.25fr);
  gap: 8px;
  margin-top: 10px;
}

.compare-results {
  top: 84px;
}

.compare-scroll table {
  min-width: 980px;
}

.compare-result-cards {
  display: none;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 14px;
}

.result-card + .result-card {
  margin-top: 10px;
}

.result-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.result-card-head span {
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 4px 9px;
  font-size: 0.78rem;
  font-weight: 850;
}

.result-card dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.result-card dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.result-card dt {
  color: var(--muted);
  font-weight: 800;
}

.result-card dd {
  margin: 0;
  text-align: right;
  font-weight: 850;
}

.export-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.table-panel {
  margin: 24px 0 42px;
}

.table-scroll {
  margin-top: 16px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  background: #eef5ec;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 24px 16px;
  text-align: center;
}

@media (max-width: 920px) {
  .hero,
  .calculator-shell,
  .compare-shell {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
    padding-top: 44px;
  }

  .results-panel {
    position: static;
  }
}

@media (max-width: 680px) {
  main {
    width: min(100% - 20px, 1180px);
  }

  .header-inner {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    width: min(100% - 20px, 1180px);
    padding: 10px 0;
  }

  nav {
    width: 100%;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    white-space: nowrap;
    font-size: 0.86rem;
  }

  .brand-logo {
    width: 170px;
  }

  .compare-hero {
    padding: 28px 0 14px;
  }

  .compare-hero h1,
  .article-hero h1 {
    font-size: 2.25rem;
    line-height: 1;
  }

  .lead {
    font-size: 1rem;
  }

  .grid.two,
  .grid.three,
  .metrics-grid,
  .amortization-row,
  .article-grid,
  .ranking-help ul,
  .compare-row-head,
  .offer-summary-grid,
  .bonus-grid,
  .bonus-costs {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    font-size: 2.55rem;
  }

  .panel {
    padding: 14px;
  }

  .compare-shell {
    gap: 14px;
    padding-top: 10px;
  }

  .compare-title {
    gap: 12px;
    margin-top: 22px;
  }

  .offer-card-head,
  .offer-summary-grid,
  .compare-row-head {
    padding-left: 12px;
    padding-right: 12px;
  }

  .offer-card-head {
    align-items: flex-start;
  }

  .offer-summary-grid {
    gap: 8px;
  }

  .offer-summary-grid div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px;
  }

  .offer-summary-grid strong {
    margin-top: 0;
    text-align: right;
  }

  .offer-details {
    padding: 0 12px;
  }

  .input-affix span {
    min-width: 56px;
    padding: 0 8px;
    font-size: 0.82rem;
  }

  .bonus-costs .input-affix span {
    min-width: 78px;
  }

  .compare-scroll {
    display: none;
  }

  .compare-result-cards {
    display: block;
    margin-top: 14px;
  }

  .export-actions {
    grid-template-columns: 1fr;
  }

  .inline-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .button {
    width: 100%;
  }

  .remove-row {
    width: 100%;
  }
}
