/* THE GUIDED SALE, WITH COLOUR THAT GUIDES (owner, 2026-10-28, relaying Ayman and Hany, both dealers: "no colors",
 * "they dont catch his eyes and he gets lost"; "this is basically our customer").
 *
 * The rest of the app keeps its calm chrome. The sale is different: a dealer is working it with a customer in the chair,
 * and every screen has to say at a glance where they are, what is done, what is missing and what to press next. So:
 *   - the step rail is a coloured map: done is green, the page you are on is filled, a page with a problem is red;
 *   - every box is as wide as what goes in it (a state is two letters, a ZIP five digits), so a page reads in rows
 *     instead of a wall of identical full-width boxes;
 *   - a required box that is still empty glows red until it is filled, and its label says "Required" (controls.css);
 *   - each kind of button has its own colour: clearing is red, the trade-in is teal, finance is indigo, and Finance
 *     lights up when the deal is financed; the tools that work the numbers out are blue, working backwards is primary;
 *   - the money groups each carry a coloured edge, so DMV fees, dealer charges, government fees and add-ons are
 *     told apart without reading their titles.
 *
 * Render rules (CLAUDE.md): sizes from the type scale only, weights 400-700, even-pixel spacing, no font shorthand.
 * Loaded just before controls.css (which must stay last, test_controls.mjs); every rule is scoped to
 * :root .sale-wizard, so it outranks controls.css's :root .button rules inside the sale and touches nothing else. */

:root .sale-wizard {
  --sw-trade: #0f766e;
  --sw-trade-soft: color-mix(in srgb, #0f766e 12%, var(--surface, #fff));
  --sw-finance: #4f46e5;
  --sw-finance-soft: color-mix(in srgb, #4f46e5 12%, var(--surface, #fff));
  --sw-tool: #1d4ed8;
  --sw-tool-soft: color-mix(in srgb, #1d4ed8 10%, var(--surface, #fff));
  --sw-risk: var(--pui-risk, #b4341f);
  --sw-ok: var(--pui-ok, #1c7a4a);
  --sw-warn: var(--pui-warn, #9a6700);
}
:root[data-theme="dark"] .sale-wizard {
  --sw-trade: #2dd4bf;
  --sw-trade-soft: color-mix(in srgb, #2dd4bf 16%, var(--surface, #111));
  --sw-finance: #a5b4fc;
  --sw-finance-soft: color-mix(in srgb, #818cf8 20%, var(--surface, #111));
  --sw-tool: #93c5fd;
  --sw-tool-soft: color-mix(in srgb, #60a5fa 16%, var(--surface, #111));
  --sw-risk: #f87171;
  --sw-ok: #4ade80;
  --sw-warn: #fbbf24;
}

/* ---- The step rail: a coloured map of the sale ---- */
:root .sale-wizard .sw-rail { gap: 8px; margin: 0 0 20px; }
:root .sale-wizard .sw-rail-step button {
  min-height: 48px; padding: 8px 12px; gap: 10px;
  border-width: 2px; font-size: var(--fs-body); line-height: var(--lh-body); font-weight: 600;
}
:root .sale-wizard .sw-rail-num { flex: 0 0 28px; width: 28px; height: 28px; font-size: var(--fs-small); line-height: var(--lh-small); }
:root .sale-wizard .sw-rail-step.sw-done button { border-color: var(--sw-ok); background: color-mix(in srgb, var(--sw-ok) 10%, var(--surface, #fff)); color: var(--ink); }
:root .sale-wizard .sw-rail-step.sw-done .sw-rail-num { background: var(--sw-ok); color: #fff; }
:root .sale-wizard .sw-rail-step.sw-blocked button { border-color: var(--sw-risk); background: color-mix(in srgb, var(--sw-risk) 9%, var(--surface, #fff)); color: var(--ink); }
:root .sale-wizard .sw-rail-step.sw-current button {
  border-color: var(--accent); background: var(--accent); color: var(--accent-ink, #fff);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}
/* The number on the current step is the accent and its own ink swapped: readable in every design, light and dark (white
   with the accent measured 2.14:1 on dark mode's sky blue). */
:root .sale-wizard .sw-rail-step.sw-current .sw-rail-num { background: var(--accent-ink, #fff); color: var(--accent); }
:root .sale-wizard .sw-rail-step button:disabled { opacity: .55; }

/* The page title carries the accent too, so the step you are on is said twice: in the rail and over the page. */
:root .sale-wizard .sw-head h2 { border-left: 6px solid var(--accent); padding-left: 12px; }

/* ---- Boxes as wide as what goes in them ---- */
:root .sale-wizard .sw-grid { display: flex; flex-wrap: wrap; gap: 14px 16px; align-items: flex-start; }
:root .sale-wizard .sw-grid > * { flex: 0 1 auto; }
:root .sale-wizard .sw-field { width: 15em; max-width: 100%; }
:root .sale-wizard .sw-field.sw-size-xs { width: 6.5em; }
:root .sale-wizard .sw-field.sw-size-sm { width: 9.5em; }
:root .sale-wizard .sw-field.sw-size-md { width: 13em; }
:root .sale-wizard .sw-field.sw-size-lg { width: 20em; }
:root .sale-wizard .sw-field.sw-size-xl { width: 28em; }
:root .sale-wizard .sw-grid > .sw-wide, :root .sale-wizard .sw-field.sw-wide { flex-basis: 100%; width: 100%; }
:root .sale-wizard .sw-field input, :root .sale-wizard .sw-field select { width: 100%; }
/* A row break: the next box starts a new line (the address block reads street / city-state-ZIP). */
:root .sale-wizard .sw-break { flex-basis: 100%; height: 0; margin: -14px 0 0; }

/* ---- Required and missing: impossible to overlook ---- */
:root .sale-wizard .sw-field input.sw-missing, :root .sale-wizard .sw-field select.sw-missing {
  border: 2px solid var(--sw-risk) !important;
  background: color-mix(in srgb, var(--sw-risk) 6%, var(--surface, #fff));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--sw-risk) 28%, transparent), 0 0 14px color-mix(in srgb, var(--sw-risk) 30%, transparent);
}
:root .sale-wizard .sw-field:has(.sw-missing) > span { color: var(--sw-risk); }

/* ---- Buttons, each in its own colour ---- */
:root .sale-wizard .button.warning-action {
  border: 2px solid var(--sw-risk); color: var(--sw-risk);
  background: color-mix(in srgb, var(--sw-risk) 7%, var(--surface, #fff)); font-weight: 600;
}
:root .sale-wizard .button.warning-action:hover { background: color-mix(in srgb, var(--sw-risk) 14%, var(--surface, #fff)); }
:root .sale-wizard .sw-detail-button { border-width: 2px; font-weight: 600; min-height: 40px; padding: 6px 12px; }
:root .sale-wizard #editTradeData { border-color: var(--sw-trade); color: var(--sw-trade); background: var(--sw-trade-soft); }
:root .sale-wizard #editTradeData b { background: var(--surface, #fff); color: var(--sw-trade); border: 1px solid var(--sw-trade); }
:root .sale-wizard #editTradeData.has-data { background: var(--sw-trade); color: #fff; }
:root .sale-wizard #editTradeData.has-data b { background: color-mix(in srgb, #000 20%, transparent); color: #fff; border-color: transparent; }
:root[data-theme="dark"] .sale-wizard #editTradeData.has-data, :root[data-theme="dark"] .sale-wizard #editFinanceData.sw-finance-ready { color: #0b1020; }
:root .sale-wizard #editFinanceData { border-color: var(--sw-finance); color: var(--sw-finance); background: var(--sw-finance-soft); }
:root .sale-wizard #editFinanceData b { background: var(--surface, #fff); color: var(--sw-finance); border: 1px solid var(--sw-finance); }
/* Cash, or pricing not ready: still visibly the finance button, not a greyed-out ghost; it says why it waits. */
:root .sale-wizard #editFinanceData:disabled { opacity: .7; }
/* FINANCE LIGHTS UP when the deal is financed (owner, 2026-10-28). */
:root .sale-wizard #editFinanceData.sw-finance-ready, :root .sale-wizard #editFinanceData[aria-pressed="true"]:not(:disabled) {
  background: var(--sw-finance); border-color: var(--sw-finance); color: #fff;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--sw-finance) 30%, transparent), 0 0 18px color-mix(in srgb, var(--sw-finance) 45%, transparent);
}
:root .sale-wizard #editFinanceData.sw-finance-ready b, :root .sale-wizard #editFinanceData[aria-pressed="true"]:not(:disabled) b { background: color-mix(in srgb, #000 22%, transparent); color: #fff; border-color: transparent; }
:root .sale-wizard #editFinanceData.sw-finance-complete { background: var(--sw-ok); border-color: var(--sw-ok); color: #fff; box-shadow: 0 0 0 4px color-mix(in srgb, var(--sw-ok) 30%, transparent); }
:root .sale-wizard #editFinanceData.sw-finance-stale { background: color-mix(in srgb, var(--sw-warn) 18%, var(--surface, #fff)); border-color: var(--sw-warn); color: var(--ink); }

/* The number tools are blue; working the deal backwards is the main action, as on Ayman's page. */
:root .sale-wizard .sw-tools .button { border-width: 2px; font-weight: 600; }
:root .sale-wizard .sw-tools #swDmvFees, :root .sale-wizard .sw-tools #swPullTaxRate { background: var(--sw-tool); border-color: var(--sw-tool); color: #fff; }
:root[data-theme="dark"] .sale-wizard .sw-tools #swDmvFees, :root[data-theme="dark"] .sale-wizard .sw-tools #swPullTaxRate { color: #0b1020; }
:root .sale-wizard .sw-tools #openOfficialDmvFeeCalculator, :root .sale-wizard .sw-tools #openOfficialTaxLookup { border-color: var(--sw-tool); color: var(--sw-tool); background: var(--sw-tool-soft); }
:root .sale-wizard .sw-tools #openAdjustPricing, :root .sale-wizard .sw-tools #openReverseDesking { background: var(--accent); border-color: var(--accent); color: var(--accent-ink, #fff); }

/* ---- Money groups: a coloured edge for each kind ---- */
:root .sale-wizard .sw-fee-group { border-left: 6px solid var(--line); }
:root .sale-wizard .sw-fee-group:nth-of-type(1) { border-left-color: var(--sw-tool); }
:root .sale-wizard .sw-fee-group:nth-of-type(2) { border-left-color: var(--sw-warn); }
:root .sale-wizard .sw-fee-group:nth-of-type(3) { border-left-color: #64748b; }
:root .sale-wizard .sw-fee-group:nth-of-type(4) { border-left-color: var(--sw-trade); }
:root .sale-wizard .sw-fee-group .sw-grid { gap: 12px 14px; }

/* The figures a customer asks about, at the top of the page as on Ayman's: one strong band. */
:root .sale-wizard .sw-pricing-summary {
  display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: baseline; margin: 12px 0 16px; padding: 12px 16px;
  border: 2px solid var(--accent); border-radius: var(--r-control, 8px);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface, #fff));
  font-size: var(--fs-body); line-height: var(--lh-body);
}
:root .sale-wizard .sw-pricing-summary strong { font-weight: 700; }
:root .sale-wizard .sw-pricing-summary .sw-otd-strong { margin-left: auto; font-size: var(--fs-h3); line-height: var(--lh-h3); }

:root .sale-wizard .sw-paying { border-left: 6px solid var(--sw-ok); padding-left: 14px; }

@media (max-width: 640px) {
  :root .sale-wizard .sw-field, :root .sale-wizard .sw-field.sw-size-lg, :root .sale-wizard .sw-field.sw-size-xl, :root .sale-wizard .sw-field.sw-size-md { width: 100%; }
  :root .sale-wizard .sw-field.sw-size-xs, :root .sale-wizard .sw-field.sw-size-sm { width: calc(50% - 8px); }
  :root .sale-wizard .sw-pricing-summary .sw-otd-strong { margin-left: 0; }
}

/* ---- Forms / compliance: two cards, boxes in even rows (owner, 2026-11-01: "organize and make it look streamlined") ---- */
:root .sale-wizard .sw-comp-card { margin: 0 0 16px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--r-surface); background: var(--surface); }
:root .sale-wizard .sw-comp-title { display: flex; flex-direction: column; gap: 4px; margin: 0 0 14px; color: var(--ink); font-size: var(--fs-lead); line-height: var(--lh-lead); font-weight: 600; }
:root .sale-wizard .sw-comp-title small { color: var(--muted); font-size: var(--fs-small); line-height: var(--lh-small); font-weight: 400; }
:root .sale-wizard .sw-comp-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 16px; align-items: start; margin: 0 0 12px; }
:root .sale-wizard .sw-comp-row:last-child { margin-bottom: 0; }
:root .sale-wizard .sw-comp-row > .sw-field { width: 100%; min-width: 0; max-width: none; }
:root .sale-wizard .sw-comp-row > .sw-wide { grid-column: 1 / -1; }
:root .sale-wizard .sw-comp-row .sw-field-hint { display: block; margin-top: 4px; color: var(--muted); font-size: var(--fs-small); line-height: var(--lh-small); }
:root .sale-wizard .sw-comp-action { display: flex; align-items: flex-start; padding-top: 24px; }
:root .sale-wizard .sw-comp-card .sw-return-rules { margin: 14px 0 0; }
:root .sale-wizard .sw-comp-row-actions { margin-top: 4px; }
:root .sale-wizard .sw-comp-row-cancel { grid-template-columns: minmax(240px, 1.6fr) repeat(3, minmax(150px, 1fr)); }
@media (max-width: 900px) { :root .sale-wizard .sw-comp-row-cancel { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); } }

/* ---- Pricing: two even rows of five (owner, 2026-11-01: "organize these fields in a more uniform organized manner") ----
   Each row is a grid and each field spans four of its rows as a subgrid (label, box, error, note), so a two-line label
   lifts every label in its row, never its own box: the boxes in a row always start on one line. */
:root .sale-wizard .sw-grid.sw-price-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); grid-auto-rows: auto; column-gap: 16px; row-gap: 0; align-items: start; margin: 0 0 14px; }
:root .sale-wizard .sw-grid.sw-price-row > .sw-field { display: grid; grid-row: span 4; grid-template-rows: subgrid; row-gap: 0; width: auto; max-width: none; min-width: 0; align-self: stretch; }
:root .sale-wizard .sw-grid.sw-price-row > .sw-field > span { display: flex; flex-flow: row wrap; justify-content: flex-start; align-items: baseline; align-content: flex-end; column-gap: 8px; min-height: 0; margin: 0 0 6px; text-align: left; }
/* "Required" goes under the box here rather than lengthening the label, so no label in a row takes an extra line. */
:root .sale-wizard .sw-grid.sw-price-row > .sw-field > span::after { content: none; }
:root .sale-wizard .sw-grid.sw-price-row > .sw-field:is(:has(> [data-sw-required].sw-missing), :has(> .sw-tender-row > [data-sw-required].sw-missing))::after { content: "Required"; margin-top: 4px; color: var(--pui-risk, #b4341f); font-size: var(--fs-small); line-height: var(--lh-small); font-weight: 600; }
:root .sale-wizard .sw-grid.sw-price-row > .sw-field > small { margin-top: 4px; }
@media (max-width: 1100px) { :root .sale-wizard .sw-grid.sw-price-row { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 12px; } }
@media (max-width: 640px) { :root .sale-wizard .sw-grid.sw-price-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
:root .sale-wizard .sw-main-fees{margin-top:2px}
/* Seven boxes wrap to a second line, so the row needs the gap the separate rows get from their margin. */
:root .sale-wizard .sw-grid.sw-price-row.sw-main-fees{row-gap:14px}

/* How they pay: one compact dropdown on Pricing with the chosen logo, and the code to pay folded on Paperwork (owner, 2026-11-01). */
:root .sale-wizard .sw-tender-row{display:flex;align-items:center;gap:8px;min-width:0}
:root .sale-wizard .sw-tender-row select{flex:1 1 auto;min-width:0}
:root .sale-wizard .sw-tender-row .sw-tender-mark{flex:none}
:root .sale-wizard .sw-tender-select{min-width:0}
/* The logo row is a span inside the label, so the label-text rule (row wrap, baseline) would catch it: keep it one line. Two columns wide, so "Choose how they are paying" is never clipped. */
:root .sale-wizard .sw-grid.sw-price-row > .sw-field.sw-tender-select{grid-column:span 2}
:root .sale-wizard .sw-grid.sw-price-row > .sw-field > span.sw-tender-row{flex-flow:row nowrap;align-items:center;align-content:normal;column-gap:8px;margin:0}
:root .sale-wizard .sw-pay-section{display:grid;gap:8px}
:root .sale-wizard .sw-pay-drop{border:1px solid var(--line);border-radius:var(--r-control);background:var(--surface)}
:root .sale-wizard .sw-pay-drop[data-missing="1"]{border-color:var(--pui-risk,#b4341f)}
:root .sale-wizard .sw-pay-drop-head{display:flex;align-items:center;gap:10px;min-height:44px;padding:6px 12px;cursor:pointer;list-style:none;font-weight:600}
:root .sale-wizard .sw-pay-drop-head::-webkit-details-marker{display:none}
:root .sale-wizard .sw-pay-drop-name{flex:1 1 auto;min-width:0}
:root .sale-wizard .sw-pay-drop-open{color:var(--accent);font-size:var(--fs-small);line-height:var(--lh-small)}
:root .sale-wizard .sw-pay-drop[open] .sw-pay-drop-open{display:none}
:root .sale-wizard .sw-pay-drop-body{display:grid;gap:10px;padding:0 12px 12px}

/* THE DEAL SO FAR (owner, 7 Nov 2026: "i also like this receipt on the side add to sale and dont mess anything up in it").
 * A read-only receipt (web/sale-receipt.js). Nothing inside a sale page changes size because of it:
 *   - when the sale's column has room (measured on the page itself, not the window, so an open sidebar counts), the sale
 *     grows from 940px to 1240px on EVERY step and the receipt takes the extra 300px. Each page's body keeps its 894px,
 *     so the five-box rows on Pricing keep their widths and one-line labels, and the step bar is the same width on
 *     every step (a bar of steps never moves between them);
 *   - without room, the sale stays 940px and the receipt shows under the Pricing page only.
 * Measured by tools/dev/walk/car-page-receipt-probe.mjs: box widths and label heights with and without the receipt. */
:root .guided-sale-shell{container-type:inline-size;container-name:gsale}
:root .sale-wizard .sw-with-receipt{display:block}
:root .sale-wizard .sw-with-receipt:not(.sw-on-price) > .sw-receipt{display:none}
:root .sale-wizard .sw-receipt{margin:16px 0 0;padding:16px 18px;border:1px solid var(--line);border-radius:var(--r-control);background:var(--surface);color:var(--ink)}
:root .sale-wizard .sw-receipt-title{margin:0 0 10px;color:var(--muted);font-size:var(--fs-small);line-height:var(--lh-small);font-weight:600;letter-spacing:.04em;text-transform:uppercase}
:root .sale-wizard .sw-receipt-lines{display:grid;gap:4px;margin:0}
:root .sale-wizard .sw-receipt-row{display:flex;align-items:baseline;justify-content:space-between;gap:12px}
:root .sale-wizard .sw-receipt-row dt{min-width:0;color:var(--muted);font-size:var(--fs-small);line-height:var(--lh-small)}
:root .sale-wizard .sw-receipt-row dd{margin:0;color:var(--ink);font-size:var(--fs-small);line-height:var(--lh-small);font-variant-numeric:tabular-nums;white-space:nowrap}
:root .sale-wizard .sw-receipt-totals{margin-top:10px;padding-top:10px;border-top:2px solid var(--ink)}
:root .sale-wizard .sw-receipt-row.sw-receipt-total :is(dt,dd){color:var(--ink);font-size:var(--fs-body);line-height:var(--lh-body);font-weight:700}
:root .sale-wizard .sw-receipt-due{display:grid;gap:2px;margin-top:12px;padding-top:12px;border-top:1px dashed var(--line)}
:root .sale-wizard .sw-receipt-due span{color:var(--muted);font-size:var(--fs-micro);line-height:var(--lh-micro);font-weight:600;letter-spacing:.04em;text-transform:uppercase}
:root .sale-wizard .sw-receipt-due strong{color:var(--accent);font-size:var(--fs-h2);line-height:var(--lh-h2);font-weight:700;font-variant-numeric:tabular-nums}
@container gsale (min-width: 1248px) {
  :root .guided-sale-shell:has(.sw-with-receipt) :is(.sw-page-heading,.sale-wizard){max-width:1240px}
  :root .sale-wizard .sw-with-receipt{display:grid;grid-template-columns:minmax(0,1fr) 280px;column-gap:20px;align-items:start}
  :root .sale-wizard .sw-with-receipt > .sw-receipt{display:block;margin:0}
}

/* The sale is always as wide as its column allows, whatever the page holds. It was sized by its content, so a tab with
 * longer lines made it 12px wider and the Paperwork tab bar moved sideways between tabs (Print and sign 1240px, Payment
 * 1228px; tools/dev/walk/paperwork-tabs-probe.mjs). A bar of tabs never moves (owner, 2026-11-03). */
:root .guided-sale-shell :is(.sw-page-heading,.sale-wizard){width:100%}
