/* ---- Calculator layout ---- */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: stretch;
}
.calc-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 22px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.result-card {
  background: linear-gradient(160deg, #fff7f0 0%, #ffffff 100%);
  border: 1px solid #fbd6b6;
  border-radius: 22px;
  padding: 28px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.result-monthly {
  font-size: clamp(40px, 6vw, 72px);
  font-weight: 900;
  color: var(--orange-dark);
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 8px 0 4px;
}
.result-monthly-sub {
  color: var(--gray-700);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 22px;
}
.result-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--gray-200);
  font-size: 15px;
}
.result-row .k { color: var(--gray-700); font-weight: 700; }
.result-row .v { color: var(--gray-900); font-weight: 800; }
.calc-disclaimer {
  margin-top: 18px;
  padding: 14px 16px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  color: var(--gray-700);
  font-size: 13px;
  line-height: 1.5;
}

/* ---- Tabs ---- */
.calc-tabs {
  display: inline-flex;
  gap: 6px;
  padding: 6px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 999px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.calc-tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--gray-800);
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  padding: 10px 24px;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.2s ease;
}
.calc-tab:hover { color: var(--orange-dark); }
.calc-tab.active {
  background: var(--white);
  color: var(--orange-dark);
  border-color: var(--gray-200);
  box-shadow: var(--shadow);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- Form rows / input groups ---- */
.field-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.field-pair .form-field { margin-top: 0; }
.input-group { display: flex; align-items: stretch; width: 100%; }
.input-group .addon {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}
.input-group .addon.prefix { border-right: 0; border-radius: 12px 0 0 12px; }
.input-group .addon.suffix { border-left: 0; border-radius: 0 12px 12px 0; }
.input-group .addon.prefix + input { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group input:has(+ .addon.suffix) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
/* Let the input shrink so it + the addon stay inside the card. */
.input-group input { flex: 1 1 auto; min-width: 0; }

/* iOS Safari zooms the page when a focused input's font-size is < 16px.
   Bump calculator fields to 16px to keep the viewport from zooming in. */
.calc-card input,
.calc-card .addon { font-size: 16px; }

.calc-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}
.calc-actions .btn { flex: 1; min-width: 140px; }

/* ---- Payment streams (APR tab) ---- */
.stream-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 26px 0 14px;
  padding-top: 22px;
  border-top: 1px solid var(--gray-200);
}
.stream-head h3 { margin: 0; font-size: 17px; }
.payment-stream {
  display: grid;
  grid-template-columns: 1fr 1fr 0.9fr auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}
.stream-remove {
  appearance: none;
  cursor: pointer;
  border: 1px solid var(--gray-300);
  background: var(--white);
  color: var(--gray-700);
  border-radius: 10px;
  width: 44px;
  height: 44px;
  font-size: 20px;
  line-height: 1;
  transition: 0.15s ease;
}
.stream-remove:hover:not(:disabled) { border-color: #e0796a; color: #d6442e; }
.stream-remove:disabled { opacity: 0.4; cursor: not-allowed; }
.add-stream {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 0;
  color: var(--success);
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  padding: 0;
}
.add-stream:hover { text-decoration: underline; }

/* ---- Amortization table ---- */
.amort-wrap {
  margin-top: 36px;
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.amort-wrap.hidden { display: none; }
.amort-wrap h2 {
  margin: 0;
  padding: 22px 24px;
  font-size: 20px;
  border-bottom: 1px solid var(--gray-200);
}
.amort-scroll { overflow-x: auto; }
.amort-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.amort-table th,
.amort-table td {
  padding: 12px 18px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--gray-200);
}
.amort-table th:first-child,
.amort-table td:first-child { text-align: left; }
.amort-table th {
  background: var(--gray-100);
  color: var(--gray-800);
  font-weight: 800;
  position: sticky;
  top: 0;
}
.amort-table tbody tr:nth-child(even) { background: var(--gray-100); }
.amort-table tbody tr:last-child td { border-bottom: 0; }

@media (max-width: 1120px) {
  .calc-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .field-pair { grid-template-columns: 1fr; }
  .payment-stream { grid-template-columns: 1fr 1fr; }
  .calc-tabs { display: flex; width: 100%; }
  .calc-tab { flex: 1; padding: 10px 12px; }
}

.form-actions { margin-top: 24px; display: flex; flex-wrap: wrap; gap: 10px; }
