/* Savings calculator in "The economics" (#cost). Rendered by js/savings.js into #savings-app.
   Light section: white cards on the page background, teal accents. */
.sv { margin-top: 72px; }
.sv [hidden] { display: none !important; }
/* The site-wide focus ring is bright teal, which is faint on white. Use the dark teal here. */
.sv :focus-visible { outline: 2px solid var(--teal-text); outline-offset: 2px; }

.sv-head { display: flex; flex-direction: column; gap: 12px; max-width: 760px; }
.sv-title { font: 700 clamp(28px, 3.2vw, 40px)/1.05 var(--display); letter-spacing: -.025em; margin: 0; text-wrap: balance; }
.sv-lead { font-size: 16px; line-height: 1.6; color: var(--muted); margin: 0; text-wrap: pretty; }

.sv-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 18px; margin-top: 28px; align-items: start; }
@media (max-width: 900px) { .sv-grid { grid-template-columns: minmax(0, 1fr); } }
.sv-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 28px; min-width: 0; }
@media (max-width: 520px) { .sv-card { padding: 20px; } }

/* ---------- Inputs ---------- */
.sv-in { display: flex; flex-direction: column; gap: 24px; margin: 0; }
.sv-in fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.sv-in fieldset + fieldset { border-top: 1px solid var(--border-soft); padding-top: 24px; }
/* float + full width turns the legend into an ordinary flex item, so the gap applies to it too */
.sv-in legend { float: left; width: 100%; padding: 0; margin: 0; font: 500 12px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2); }
.sv-in legend span { color: var(--teal-text); margin-right: 2px; }
.sv-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sv-label { font-size: 15px; font-weight: 600; line-height: 1.4; color: var(--ink); }
.sv-label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.sv-help { margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted-2); }
.sv-tag { display: inline-block; margin-left: 4px; font: 500 10.5px var(--mono); letter-spacing: .05em; text-transform: uppercase; color: var(--warn); background: var(--warn-bg); padding: 3px 7px; border-radius: 5px; vertical-align: 2px; white-space: nowrap; }

.sv-affix { display: flex; align-items: center; margin-top: 4px; background: #fff; border: 1px solid var(--input); border-radius: 8px; transition: border-color .15s; }
.sv-affix:hover { border-color: #b9c6c0; }
.sv-affix:focus-within { border-color: var(--teal-text); outline: 2px solid var(--teal-text); outline-offset: 1px; }
/* Red only alongside a message: savings.js sets aria-invalid when it shows one under the field. */
.sv-affix:has(input[aria-invalid="true"]) { border-color: var(--danger); }
.sv-affix input { flex: 1; min-width: 0; width: 100%; border: 0; border-radius: 8px; background: transparent; padding: 11px 12px; font: 500 16px var(--mono); color: var(--ink); }
.sv-affix input:focus, .sv-affix input:focus-visible { outline: none; } /* the wrapper shows the ring */
.sv-affix input::placeholder { color: var(--muted-2); font: 400 15px var(--sans); opacity: 1; }
.sv-pre, .sv-suf { font: 400 13px var(--mono); color: var(--muted-2); white-space: nowrap; }
.sv-pre { padding-left: 12px; margin-right: -8px; }
.sv-suf { padding-right: 12px; }

.sv-slider { --p: 38.46%; width: 100%; height: 28px; margin: 4px 0 0; background: transparent; cursor: pointer; -webkit-appearance: none; appearance: none; }
.sv-slider::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--teal-text) var(--p), var(--border) var(--p)); }
.sv-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%; background: #fff; border: 2px solid var(--teal-text); box-shadow: 0 1px 4px rgba(12,31,29,.22); }
.sv-slider::-moz-range-track { height: 6px; border-radius: 3px; background: var(--border); }
.sv-slider::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--teal-text); }
.sv-slider::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 2px solid var(--teal-text); box-shadow: 0 1px 4px rgba(12,31,29,.22); }
.sv-slider:focus-visible { outline-offset: 4px; border-radius: 6px; }
.sv-range-val { font: 500 16px var(--mono); color: var(--teal-text); white-space: nowrap; }
.sv-scale { display: flex; justify-content: space-between; font: 400 11px var(--mono); color: var(--muted-2); }

.sv-select { width: 100%; margin-top: 4px; padding: 11px 40px 11px 12px; font-size: 16px; color: var(--ink); border: 1px solid var(--input); border-radius: 8px; cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%230c1f1d' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 14px center / 12px 8px;
  -webkit-appearance: none; appearance: none; }
.sv-select:hover { border-color: #b9c6c0; }
.sv-select:focus-visible { border-color: var(--teal-text); outline-offset: 1px; }

.sv-check { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 8px; background: var(--teal-tint); font-size: 14px; font-weight: 500; line-height: 1.4; cursor: pointer; }
.sv-check input { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--ink); cursor: pointer; }

/* A value that was capped, rounded or ignored: the note sits under its own field. */
.sv-err { margin: 2px 0 0; padding: 8px 10px; border-radius: 6px; background: var(--warn-bg); color: var(--warn); font-size: 13px; line-height: 1.5; }
.sv-err.is-invalid { background: var(--danger-bg); color: var(--danger-ink); }

/* ---------- Results ---------- */
.sv-out { display: flex; flex-direction: column; gap: 18px; border-top: 3px solid var(--teal); }
@media (min-width: 901px) and (min-height: 760px) { .sv-out { position: sticky; top: calc(var(--header-h) + 20px); } }
.sv-out-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.sv-out-title { margin: 0; }
.sv-per { font: 400 12px var(--mono); color: var(--muted-2); }
.sv-rows { margin: 0; display: flex; flex-direction: column; }
.sv-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; align-items: baseline; padding: 14px 0; border-top: 1px solid var(--border-soft); }
.sv-row dt { font-size: 15px; font-weight: 600; line-height: 1.35; }
.sv-row dd { margin: 0; }
.sv-val { font: 700 22px/1.1 var(--display); letter-spacing: -.01em; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sv-val.is-off { font: 500 13px var(--mono); letter-spacing: 0; color: var(--muted-2); }
.sv-math { grid-column: 1 / -1; margin: 0; font: 400 12.5px/1.55 var(--mono); color: var(--muted-2); overflow-wrap: anywhere; }
.sv-math span { display: block; }

.sv-net { display: flex; flex-direction: column; gap: 8px; padding: 18px 20px; border-radius: 12px; background: var(--page); border: 1px solid var(--border); }
.sv-out[data-verdict="incomplete"] .sv-net { border-style: dashed; }
.sv-out[data-verdict="saves"] .sv-net { background: var(--teal-wash); border-color: #bfe9dd; }
.sv-out[data-verdict="costs"] .sv-net { background: var(--warn-bg); border-color: #f0dcb2; }
html:not(.calm) .sv-net { transition: background-color .25s ease, border-color .25s ease; }
.sv-net-label { font: 500 12px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2); }
.sv-net-figs { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; }
.sv-net-val { font: 700 clamp(32px, 4vw, 44px)/1 var(--display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sv-net-val small { font: 400 14px var(--sans); letter-spacing: 0; color: var(--muted-2); }
.sv-out[data-verdict="saves"] .sv-net-val { color: var(--teal-text); }
.sv-out[data-verdict="costs"] .sv-net-val { color: var(--warn); }
.sv-net-year { font: 500 14px var(--mono); color: var(--muted); }
.sv-verdict { margin: 0; font-size: 14.5px; line-height: 1.55; color: var(--ink); text-wrap: pretty; }

.sv-foot { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.sv-note { margin: 0; font-size: 13px; line-height: 1.55; color: var(--muted-2); }
.sv-note b { color: var(--ink); font-weight: 600; }
.sv-cta { padding: 12px 18px; font-size: 15px; }
.sv-cta:focus-visible { outline-offset: 3px; }

/* Windows high contrast: hand the custom controls back to the system so they stay visible. */
@media (forced-colors: active) {
  .sv-slider, .sv-slider::-webkit-slider-thumb, .sv-select { -webkit-appearance: auto; appearance: auto; background-image: none; }
}
@media print { .sv-cta { display: none; } }
