.buying-budget {
  --budget-surface: #fffdf8;
  --budget-estimate: #e9efe5;
  border-bottom: 1px solid var(--line);
}
.budget-heading { margin-bottom: 28px; }
.budget-heading h2 {
  max-width: 18ch;
  margin: 12px 0;
  font-size: clamp(36px, 5vw, 68px);
  line-height: 1.08;
}
.budget-heading > p:last-child { max-width: 54ch; }
.budget-form {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 18px;
  max-width: 1150px;
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.budget-options, .budget-inputs, .budget-output, .budget-details {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--budget-surface);
  padding: clamp(18px, 3vw, 34px);
}
.budget-panel-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 18px;
  margin-bottom: 20px;
}
.budget-form h3 { font-size: clamp(22px, 2.5vw, 32px); line-height: 1.12; }
.budget-link, .budget-note a {
  padding: 0;
  border: 0;
  background: transparent;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.budget-link { min-height: 36px; font-size: 13px; }
.budget-link:disabled { opacity: .55; }
.budget-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.budget-fields label, .budget-scope { display: block; font-size: 14px; font-weight: 600; }
.budget-wide { grid-column: 1 / -1; }
.budget-options { grid-column: 1 / -1; }
.budget-start { max-width: 740px; margin-bottom: 18px; }
.budget-option-table {
  width: 100%;
  margin: 0 0 12px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  text-align: left;
  font-size: 14px;
}
.budget-option-table :is(th, td) {
  padding: 10px clamp(8px, 1.2vw, 16px);
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.budget-option-table th:first-child { width: 20%; padding-left: 0; }
.budget-option-table thead th { border-top: 1px solid var(--line); }
.budget-option-table .budget-scenario-active { background: var(--budget-estimate); }
.budget-option-table th { font-weight: 700; }
.budget-option-table th[scope="row"] { vertical-align: middle; }
.budget-help-heading { position: relative; }
.budget-help-button {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 30px;
  vertical-align: middle;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--deep);
  border-radius: 4px;
  font: 700 12px/1 var(--body);
}
.budget-help-button span {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid currentColor;
  border-radius: 50%;
}
.budget-help-button:is(:hover, [aria-expanded="true"]) span { background: var(--deep); color: var(--paper); }
.budget-help-panel {
  position: absolute;
  z-index: 2;
  top: 100%;
  left: 0;
  width: min(250px, calc(100vw - 86px));
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--budget-surface);
  box-shadow: 0 5px 16px rgb(13 43 30 / 15%);
  font: 400 13px/1.5 var(--body);
}
.budget-option-table input, .budget-option-table select { margin-top: 0; }
.budget-option-table strong { display: block; font-size: clamp(15px, 2vw, 22px); }
.budget-option-table small { margin: 0; }
.budget-option-table td { font-variant-numeric: tabular-nums; }
.budget-scenario-down label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 25px;
  gap: 4px;
  align-items: center;
  margin: 4px 0;
  font-size: 11px;
}
.budget-scenario-down label input:not([type="checkbox"]) { margin: 0; }
.budget-scenario-down small:not(:empty) { margin-top: 6px; }
.budget-scenario-principal td, .budget-scenario-payment { font-weight: 700; }
.budget-scenario-payment td { background: #f0f1e8; }
.budget-scenario-use {
  max-width: 100%;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--deep);
  border-radius: 7px;
  background: var(--budget-surface);
  color: var(--deep);
  font: 700 13px/1.25 var(--body);
}
.budget-scenario-use:hover { background: var(--pale); }
.budget-scenario-use[aria-pressed="true"] { background: var(--deep); color: var(--paper); }
.budget-scenario-picker { display: none; }
.budget-rebates { margin-top: 14px; }
#budget-inputs { scroll-margin-top: 90px; }
.budget-location-costs {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.budget-location-costs h4 { margin: 0; }
.budget-location-costs .budget-fields, .budget-rebate-timing { margin-top: 12px; }
:is(.budget-form, .budget-rate-dialog) :is(input:not([type="checkbox"]), select) {
  width: 100%;
  min-height: 46px;
  margin-top: 5px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--budget-surface);
  color: var(--deep);
  font: 400 16px/1.2 var(--body);
}
:is(.budget-form, .budget-rate-dialog) :is(input, select):focus-visible, .budget-table-wrap:focus-visible {
  outline: 2px solid var(--forest);
  outline-offset: 2px;
}
.budget-rate-dialog { padding: clamp(24px, 5vw, 40px); }
.budget-rate-dialog h2 { margin: 0 0 10px; font-size: clamp(26px, 4vw, 38px); line-height: 1.12; }
.budget-rate-actions { display: flex; justify-content: flex-end; align-items: center; gap: 20px; margin-top: 24px; }
.budget-rate-actions .button { width: auto; }
.budget-form [aria-invalid="true"] { border-color: #9a3d23 !important; }
.budget-form small, .budget-note {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.55;
}
.budget-scope { margin: 20px 0; }
.budget-check { display: flex; align-items: baseline; gap: 8px; margin-top: 12px; font-size: 14px; }
.budget-check input { margin: 0; accent-color: var(--forest); }
.budget-error, .budget-example-note {
  border-radius: 7px;
  padding: 9px 12px;
  margin: 0 0 14px;
  background: var(--pale);
  font-size: 14px;
}
.budget-output {
  align-self: start;
  background: var(--budget-estimate);
}
.budget-output h3 { margin: 12px 0; }
.budget-status {
  display: inline-block;
  background: var(--budget-surface);
  padding: 4px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}
.budget-tax-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 26px;
  margin: 14px 0;
}
.budget-tax-totals dt { font-size: 13px; }
.budget-tax-totals dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.budget-tax-totals div:last-child { font-weight: 700; }
.budget-accordion-total { display: block; font: 700 26px/1.25 var(--display); }
.budget-bank-rates { display: grid; gap: 6px; margin-top: 8px; }
.budget-bank-rate {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--budget-surface);
  text-align: left;
  font-size: 14px;
}
.budget-bank-rate:hover { background: var(--budget-estimate); }
.budget-bank-rate-lowest { border-color: var(--forest); background: var(--budget-estimate); }
.budget-bank-rate strong { white-space: nowrap; font-variant-numeric: tabular-nums; }
.budget-rate-dialog .budget-bank-rate-badge { font-size: 11px; font-weight: 700; }
#budget-bank-rate-empty:empty { display: none; }
.budget-next { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; margin-top: 16px; }
.budget-next .button { max-width: 100%; white-space: normal; }
.budget-details { grid-column: 1 / -1; padding-block: 0; }
.budget-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 16px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.budget-details summary::after {
  content: '';
  width: 8px;
  height: 8px;
  margin-right: 4px;
  flex: none;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}
.budget-details[open] > summary::after { transform: rotate(225deg); }
.budget-subsection[open] > summary::after { transform: rotate(225deg); }
.budget-detail-content { padding-bottom: 20px; }
.budget-line-items { max-width: 660px; margin: 18px 0; }
.budget-line-items div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 7px 0;
}
.budget-line-items dd { margin: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
.budget-subsection { border-top: 1px solid var(--line); }
.budget-subsection[open] { padding-bottom: 16px; }
.budget-subsection .budget-note { margin: 8px 0; }
.budget-compare { border-top: 1px solid var(--line); padding: 18px 0; }
.budget-table-wrap { overflow-x: auto; margin-top: 10px; }
.budget-table-wrap table { width: 100%; border-collapse: collapse; font-size: 14px; }
.budget-table-wrap :is(th, td) { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.budget-table-wrap td { white-space: nowrap; font-variant-numeric: tabular-nums; }
.budget-history { max-width: 720px; margin-top: 20px; }
.budget-history img { width: 100%; height: auto; }
.budget-scenario-select { display: block; max-width: 320px; margin-bottom: 12px; font-weight: 600; }

@media (max-width: 900px) {
  .budget-form { grid-template-columns: minmax(0, 1fr); }
  .budget-next { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 760px) {
  .budget-scenario-picker { display: block; margin-bottom: 12px; font-size: 14px; font-weight: 600; }
  .budget-option-table :is(td, th[scope="col"]:not(:first-child)):not(.budget-scenario-active) { display: none; }
  .budget-option-table th:first-child { width: 45%; }
  .budget-option-table :is(th, td) { padding-inline: 8px; }
  .budget-scenario-action { display: none; }
}
@media (max-width: 500px) {
  .budget-fields { grid-template-columns: minmax(0, 1fr); }
  .budget-option-table, .budget-option-table th small { font-size: 12px; }
  .budget-start { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .budget-option-table select { padding-inline: 5px; }
  .budget-inputs > .button { justify-content: space-between; width: 100%; }
  #budget-renewal-table table { font-size: 12px; }
  #budget-renewal-table :is(th, td) { padding: 8px 5px; }
}
@media (max-width: 360px) {
  .budget-start { grid-template-columns: minmax(0, 1fr); }
}
