.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.loan-tool-page {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(247, 245, 239, 0.96) 420px),
    var(--paper);
}

.loan-tool-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.72fr);
  gap: clamp(26px, 5vw, 64px);
  align-items: end;
  padding: clamp(48px, 8vw, 88px) clamp(18px, 4vw, 56px) clamp(28px, 5vw, 48px);
  border-bottom: 1px solid rgba(13, 27, 42, 0.08);
}

.loan-tool-intro {
  display: grid;
  gap: 16px;
  min-width: 0;
  max-width: 880px;
}

.loan-back-link {
  width: fit-content;
  color: var(--gold-dark);
  font-size: 13px;
  font-weight: 900;
}

.loan-tool-intro h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(38px, 5.8vw, 72px);
  font-weight: 700;
  line-height: 1.04;
  text-wrap: balance;
}

.loan-tool-intro p:not(.eyebrow) {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.74;
}

.loan-tool-visual {
  position: relative;
  overflow: hidden;
  min-width: 0;
  margin: 0;
  border: 1px solid rgba(13, 27, 42, 0.1);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow-soft);
}

.loan-tool-visual img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.loan-tool-visual figcaption {
  position: absolute;
  right: 14px;
  bottom: 14px;
  left: 14px;
  display: grid;
  gap: 5px;
  padding: 14px;
  color: var(--white);
  background: rgba(7, 9, 13, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  backdrop-filter: blur(10px);
}

.loan-tool-visual strong {
  font-size: 14px;
}

.loan-tool-visual span {
  color: rgba(255, 255, 255, 0.76);
  font-size: 13px;
  line-height: 1.5;
}

.loan-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.86fr);
  gap: clamp(20px, 4vw, 42px);
  align-items: start;
  padding: clamp(26px, 5vw, 54px) clamp(18px, 4vw, 56px);
}

.loan-control-panel,
.loan-results-panel,
.loan-schedule-section,
.loan-insight-section,
.loan-faq-section {
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 16px 42px rgba(11, 17, 29, 0.07);
}

.loan-control-panel,
.loan-results-panel {
  padding: clamp(18px, 2.8vw, 28px);
}

.loan-results-panel {
  position: sticky;
  top: 88px;
  display: grid;
  gap: 18px;
}

.loan-panel-head {
  display: grid;
  gap: 9px;
  margin-bottom: 22px;
}

.loan-panel-head h2,
.loan-chart-panel h2,
.loan-section-head h2,
.loan-insight-copy h2 {
  font-size: clamp(25px, 3.1vw, 38px);
  line-height: 1.18;
}

.loan-panel-head p:not(.section-kicker),
.loan-section-head p,
.loan-insight-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.72;
}

.loan-form {
  display: grid;
  gap: 20px;
}

.loan-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.loan-fieldset legend {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.loan-input-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 14px;
  grid-auto-rows: minmax(116px, auto);
}

.loan-form label {
  display: grid;
  grid-template-rows: minmax(34px, auto) minmax(44px, auto) auto;
  align-content: start;
  gap: 8px;
  min-width: 0;
  height: 100%;
  padding: 12px;
  border: 1px solid rgba(13, 27, 42, 0.09);
  border-radius: 8px;
  color: #2d3442;
  background: rgba(255, 255, 255, 0.58);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.loan-form input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(13, 27, 42, 0.16);
  border-radius: 8px;
  color: var(--ink);
  background: #fbfaf6;
  font-size: 15px;
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.loan-form input:focus {
  outline: none;
  border-color: rgba(200, 164, 93, 0.72);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(200, 164, 93, 0.16);
}

.loan-field-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.55;
}

.loan-input-suffix {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  overflow: hidden;
  min-height: 44px;
  border: 1px solid rgba(13, 27, 42, 0.16);
  border-radius: 8px;
  background: #fbfaf6;
}

.loan-input-suffix input {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.loan-input-suffix small {
  padding: 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

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

.rate-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
}

.loan-small-button {
  min-height: 38px;
  padding: 0 12px;
  font-size: 13px;
}

.rate-editor-wrap,
.stress-table-wrap,
.loan-table-wrap {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.rate-editor,
.stress-table,
.loan-schedule-table {
  width: 100%;
  border-collapse: collapse;
}

.rate-editor {
  min-width: 560px;
}

.rate-editor th,
.rate-editor td,
.stress-table th,
.stress-table td,
.loan-schedule-table th,
.loan-schedule-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.rate-editor th,
.stress-table th,
.loan-schedule-table th {
  color: var(--ink);
  background: #f4f0e6;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.rate-editor tr:last-child td,
.stress-table tr:last-child td,
.loan-schedule-table tr:last-child td {
  border-bottom: 0;
}

.rate-editor input {
  min-height: 38px;
  padding: 0 10px;
  font-size: 14px;
}

.rate-remove {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(217, 97, 76, 0.3);
  border-radius: 8px;
  color: #9f2d1f;
  background: rgba(217, 97, 76, 0.08);
  font-weight: 900;
  cursor: pointer;
}

.rate-remove:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.loan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.loan-export-note {
  max-width: 680px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

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

.loan-metric {
  display: grid;
  gap: 6px;
  min-height: 128px;
  padding: 16px;
  border: 1px solid rgba(13, 27, 42, 0.1);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #fbfaf6);
}

.loan-metric span,
.loan-metric small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.4;
}

.loan-metric strong {
  align-self: center;
  color: var(--ink);
  font-size: clamp(20px, 2.4vw, 28px);
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.loan-alert {
  padding: 14px 16px;
  border: 1px solid rgba(13, 27, 42, 0.12);
  border-radius: 8px;
  color: #263140;
  background: #f6f3ea;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.55;
}

.loan-alert.is-ok {
  border-color: rgba(38, 133, 86, 0.28);
  background: rgba(38, 133, 86, 0.09);
}

.loan-alert.is-review {
  border-color: rgba(200, 164, 93, 0.44);
  background: rgba(200, 164, 93, 0.13);
}

.loan-alert.is-danger {
  border-color: rgba(217, 97, 76, 0.36);
  background: rgba(217, 97, 76, 0.1);
}

.loan-chart-panel,
.stress-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.loan-chart-panel canvas {
  width: 100%;
  height: 280px;
  border: 1px solid rgba(13, 27, 42, 0.1);
  border-radius: 8px;
  background: #fbfaf6;
}

.stress-table {
  min-width: 820px;
  font-size: 14px;
}

.stress-table td {
  color: #2d3442;
  font-weight: 700;
}

.loan-schedule-section,
.loan-insight-section,
.loan-faq-section {
  margin: clamp(22px, 4vw, 42px) clamp(18px, 4vw, 56px);
  padding: clamp(20px, 3.6vw, 34px);
}

.loan-section-head {
  display: flex;
  gap: 22px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 18px;
}

.loan-section-head p {
  max-width: 460px;
}

.loan-table-wrap {
  max-height: 660px;
  overflow: auto;
}

.loan-schedule-table {
  min-width: 1120px;
  font-size: 14px;
}

.loan-schedule-table th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.loan-schedule-table td {
  color: #2d3442;
}

.loan-schedule-table td:nth-child(1),
.loan-schedule-table td:nth-child(3),
.loan-schedule-table td:nth-child(7) {
  font-weight: 800;
}

.loan-insight-section {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(280px, 0.72fr);
  gap: clamp(22px, 5vw, 54px);
  align-items: start;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(247, 245, 239, 0.92)),
    linear-gradient(90deg, rgba(200, 164, 93, 0.14), rgba(13, 27, 42, 0.04));
}

.loan-insight-copy {
  display: grid;
  gap: 14px;
}

.loan-insight-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.loan-related-links {
  display: grid;
  gap: 12px;
}

.loan-related-links a {
  display: grid;
  gap: 7px;
  padding: 16px;
  border: 1px solid rgba(13, 27, 42, 0.1);
  border-radius: 8px;
  background: var(--white);
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.loan-related-links a:hover {
  border-color: rgba(200, 164, 93, 0.48);
  box-shadow: var(--shadow-soft);
  transform: translateY(-2px);
}

.loan-related-links span {
  color: var(--gold-dark);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.loan-related-links strong {
  color: var(--ink);
  line-height: 1.4;
}

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

.loan-faq-grid details {
  padding: 18px;
  border: 1px solid rgba(13, 27, 42, 0.1);
  border-radius: 8px;
  background: var(--white);
}

.loan-faq-grid summary {
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
}

.loan-faq-grid p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.loan-disclaimer {
  max-width: 1120px;
  margin: 0 clamp(18px, 4vw, 56px) clamp(34px, 5vw, 58px);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.65;
}

@media (max-width: 1100px) {
  .loan-workspace,
  .loan-tool-hero,
  .loan-insight-section {
    grid-template-columns: 1fr;
  }

  .loan-results-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .loan-tool-hero {
    padding-top: 34px;
    padding-bottom: 20px;
  }

  .loan-tool-intro h1 {
    font-size: clamp(32px, 9vw, 42px);
  }

  .loan-tool-intro p:not(.eyebrow) {
    font-size: 16px;
    line-height: 1.66;
  }

  .loan-tool-visual {
    display: none;
  }

  .loan-input-grid,
  .loan-summary-grid,
  .loan-faq-grid {
    grid-template-columns: 1fr;
  }

  .loan-input-grid {
    grid-auto-rows: auto;
    gap: 10px;
  }

  .loan-form label {
    grid-template-rows: auto;
    min-height: 0;
    padding: 11px;
  }

  .rate-head,
  .loan-section-head {
    display: grid;
    align-items: start;
  }

  .loan-actions,
  .loan-insight-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .loan-actions .button,
  .loan-insight-actions .button {
    width: 100%;
  }

  .loan-chart-panel canvas {
    height: 230px;
  }

  .rate-editor {
    min-width: 100%;
    table-layout: fixed;
  }

  .rate-editor th,
  .rate-editor td {
    padding: 8px;
    font-size: 12px;
  }

  .rate-editor th:nth-child(1),
  .rate-editor td:nth-child(1) {
    width: 74px;
  }

  .rate-editor th:nth-child(2),
  .rate-editor td:nth-child(2) {
    width: 70px;
  }

  .rate-editor th:nth-child(4),
  .rate-editor td:nth-child(4) {
    width: 42px;
  }

  .rate-editor input {
    min-height: 34px;
    padding: 0 7px;
    font-size: 13px;
  }

  .rate-remove {
    width: 30px;
    height: 30px;
  }

  .loan-schedule-table {
    display: block;
    min-width: 0;
    font-size: 13px;
  }

  .loan-schedule-table thead {
    display: none;
  }

  .loan-schedule-table tbody {
    display: grid;
    gap: 10px;
    padding: 10px;
  }

  .loan-schedule-table tr {
    display: grid;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
  }

  .loan-schedule-table td {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 10px;
    padding: 9px 10px;
    border-bottom: 1px solid var(--line);
    text-align: right;
    overflow-wrap: anywhere;
  }

  .loan-schedule-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    text-align: left;
    text-transform: uppercase;
  }

  .loan-schedule-table td:last-child {
    border-bottom: 0;
  }
}
