/* vtrack · "Pipeline Board" look. Plain CSS, no build step. */
/* The two typefaces, served from static/fonts/ (SIL Open Font License 1.1, see its README.txt): no request to Google.
   One variable-font file per subset holds every weight. Instrument Sans: one face for 400 to 700. JetBrains Mono:
   faces at 500 and 700 only, as Google's stylesheet declared them, so a 600 still renders as 700 and a 400 as 500. */
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("../fonts/instrument-sans-latin.fa41c43a3d8e.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("../fonts/instrument-sans-latin-ext.1ff13d113ba4.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
    U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("../fonts/jetbrains-mono-latin.b636a65da4f0.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("../fonts/jetbrains-mono-latin.b636a65da4f0.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("../fonts/jetbrains-mono-latin-ext.bd4781a31b42.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
    U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("../fonts/jetbrains-mono-latin-ext.bd4781a31b42.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
    U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
:root {
  --bg: #F2F4F7; --surface: #FFFFFF; --surface-2: #F9FAFB; --line: #E4E7EC; --line-2: #D0D5DD;
  --ink: #101828; --text-2: #344054; --muted: #475467; --subtle: #667085;
  --accent: #1D4ED8; --accent-ink: #1E3A8A; --accent-bg: #EEF2FF;
  --ok: #067647; --ok-bg: #ECFDF3; --warn: #B93815; --warn-bg: #FFF4ED; --warn-line: #F9DBC6;
  --danger: #B42318; --danger-bg: #FEF3F2;
  --col: #E9ECF1; --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06);
  --font: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: rgba(29,78,216,.12);
  scroll-padding-top: 76px; }  /* focused fields and #anchors stop below the sticky top bar */
[hidden] { display: none !important; }  /* author display rules (.field { display: flex }) must not un-hide */
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 700; }
.mono { font-family: var(--mono); }
.muted { color: var(--subtle); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.brand .ring { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--accent); }
.brand .logo { height: 32px; width: auto; max-width: 160px; object-fit: contain; }
.brand .ring, .brand .logo { flex-shrink: 0; }
.brand .name { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.brand .product { font-weight: 500; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; font-size: 14px; white-space: nowrap; }
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a.active { background: var(--accent-bg); color: var(--accent); }
.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.usermenu summary::-webkit-details-marker { display: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-bg); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.usermenu .menu { position: absolute; right: 0; top: 42px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(16,24,40,.12); min-width: 200px; padding: 6px; display: flex; flex-direction: column; }
.usermenu .menu a, .usermenu .menu button { padding: 9px 12px; border-radius: 6px; color: var(--text-2); font: inherit; font-size: 14px;
  text-align: left; background: none; border: 0; cursor: pointer; }
.usermenu .menu a:hover, .usermenu .menu button:hover { background: var(--surface-2); }
.topbar-id, .me-btn, .back-btn { display: none; }  /* phone top bar only, see "app shell" below */

/* ---------- layout */
.page { padding: 20px 24px 96px; max-width: 1440px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { flex: 1; min-width: 200px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h2 + p { margin: 2px 0 0; color: var(--subtle); font-size: 13px; }
.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi .label { font-size: 12px; font-weight: 600; color: var(--subtle); }
.kpi .value { font: 700 28px/1.1 var(--mono); }
.kpi .value.ok { color: var(--ok); } .kpi .value.warn { color: var(--warn); }

/* ---------- buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text-2);
  font: 600 14px var(--font); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.btn.danger { background: var(--danger-bg); border-color: #FECDCA; color: var(--danger); }
.btn.small { height: 34px; padding: 0 12px; font-size: 13px; }
.btn.big { height: 54px; border-radius: 12px; font-size: 15px; width: 100%; }
.btn[disabled], .btn.htmx-request { opacity: .6; pointer-events: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: 13px;
  background: var(--surface); border: 1px solid var(--line-2); color: var(--text-2); }
.pill.active { background: var(--accent-bg); border-color: #C7D7FE; color: var(--accent); font-weight: 600; }
.pill.warn.active { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
label { font-size: 13px; font-weight: 600; color: var(--text-2); }
input[type=text], input[type=search], input[type=password], input[type=number], input[type=date], input[type=email], input[type=tel],
select, textarea { width: 100%; height: var(--field-h, 40px); border: 1px solid var(--line-2); border-radius: 8px; padding: 0 12px;
  font: 400 var(--field-fs, 15px) var(--font); color: var(--ink); background: var(--surface); }
textarea { height: auto; padding: 10px 12px; }
input[type=file] { width: 100%; min-height: 44px; padding: 5px; border: 1px dashed var(--line-2); border-radius: 8px;
  background: var(--surface-2); font: 400 14px var(--font); color: var(--text-2); }
input[type=file]::file-selector-button { height: 32px; margin-right: 10px; padding: 0 12px; border-radius: 6px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text-2); font: 600 13px var(--font); cursor: pointer; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 3px solid #C7D7FE; outline-offset: 1px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field .help { font-size: 12px; font-weight: 400; color: var(--subtle); }
.field .errors { color: var(--danger); font-size: 13px; font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; }
.check input { width: 18px; height: 18px; }
ul.choices { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
ul.choices li label { display: flex; gap: 8px; align-items: center; font-weight: 500; }

/* ---------- PAGES · forms: busy buttons, sticky save bar (inventory/form.html, settings pages)
   app.js marks the button of a plain POST form .is-busy until the next page loads. --tabbar-h is the phone tab
   bar's height (0 where there is none); sticky bars sit on it and keep their buttons clear of its raised Scan
   button (--bar-clear). */
:root { --bar-clear: min(var(--tabbar-h, 0px), 12px); }
.btn.is-busy { pointer-events: none; opacity: .8; }
.btn.is-busy::after { content: ""; width: 15px; height: 15px; flex-shrink: 0; border: 2px solid currentColor;
  border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.vin-input { text-transform: uppercase; }
.vin-input::placeholder { text-transform: none; }
@media (max-width: 720px) {
  .form-actions { position: sticky; z-index: 5; bottom: calc(var(--tabbar-h, 0px) + env(safe-area-inset-bottom, 0px));
    margin: 4px -18px -18px; padding: 12px 18px calc(12px + var(--bar-clear)); background: var(--surface); border-top: 1px solid var(--line);
    border-radius: 0 0 var(--radius) var(--radius); }
  .kb-open .form-actions { bottom: 0; padding-bottom: 12px; }  /* the tab bar hides while the keyboard is up */
  .form-actions .btn { flex: 1; min-height: 48px; font-size: 15px; }
  /* js/vin-photo.js scrolls its card into view: keep the card's buttons above the sticky bar (about 85 px), not only
     above the tab bar (html's scroll-padding-bottom) */
  .vin-field .photo-card { scroll-margin-bottom: 96px; }
}

/* ---------- badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  color: var(--c, #475467); background: color-mix(in srgb, var(--c, #475467) 11%, white); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, #475467); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.muted { background: var(--surface-2); color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #98A2B3; }
.dot.on { background: #12B76A; }

/* ---------- board */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(190px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--col); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 240px; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px; font-size: 13px; font-weight: 700; }
.col-head .n { margin-left: auto; font: 600 12px var(--mono); color: var(--muted); }
.carcard { background: var(--surface); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 6px;
  box-shadow: var(--shadow); color: var(--ink); }
.carcard:hover { box-shadow: 0 4px 12px rgba(16,24,40,.1); color: var(--ink); }
.carcard .top { display: flex; justify-content: space-between; align-items: center; }
.carcard .stock { font: 700 14px var(--mono); }
.carcard .title { font-size: 14px; font-weight: 600; }
.carcard .meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--subtle); }
.age { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 6px; background: var(--ok-bg); color: var(--ok); }
.age.late { background: var(--warn-bg); color: var(--warn); }

/* ---------- BOARD: drag and drop, Move sheet, phone pages (inventory/board.html + js/board.js)
   Cards drag between columns only (the server sorts each column). .bcard is global, not under .board, because
   SortableJS drags a copy of the card that lives on <body>. */
.board-head .board-filters { display: flex; gap: 12px; align-items: center; }
.board-kpis { margin-bottom: 16px; }
.board-root { position: relative; }
.stage-chips { display: none; }
.board-root .col { position: relative; transition: background-color .15s, box-shadow .15s, opacity .15s; }
.col-head h2 { font: inherit; margin: 0; overflow-wrap: anywhere; }
.col-title { display: flex; flex-direction: column; min-width: 0; }
.col-sub { font-size: 11px; font-weight: 600; color: var(--subtle); line-height: 1.25; }
.col-head .n { flex-shrink: 0; }
.col-move { display: inline-flex; gap: 2px; margin: -4px -6px -4px 0; flex-shrink: 0; }
.col-arrow { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px;
  padding: 0; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.col-arrow::before { content: ""; position: absolute; inset: -9px -3px; }  /* 44 px tall tap area */
.col-arrow:hover { background: var(--surface); color: var(--accent); }
.col-arrow:focus-visible { outline: 3px solid #C7D7FE; outline-offset: 0; }
.col-arrow:disabled { opacity: .3; cursor: default; background: none; color: var(--muted); }
@media (min-width: 901px) {
  .board-root .col-head { cursor: grab; border-radius: 8px; }
  .board-root .col-head:hover { background: rgba(255,255,255,.55); }
}
/* mouse screens: the arrows show over the count while the pointer or the focus is on the head */
@media (min-width: 901px) and (hover: hover) and (pointer: fine) {
  .board-root .col-head { position: relative; }
  .col-move { position: absolute; right: 2px; top: 50%; margin: 0; padding: 2px; border-radius: 8px; background: var(--col);
    translate: 0 -50%; opacity: 0; transition: opacity .15s; }
  .col-head:hover .col-move, .col-head:focus-within .col-move { opacity: 1; }
}
/* narrow columns (seven or more on a laptop): the Move button keeps only its icon */
.board-root .col { container-type: inline-size; }
@container (max-width: 190px) {
  .card-move span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .card-move { padding: 0 6px; }
}
/* a column on the move (the board's own Sortable, js/board.js) */
.col.col-ghost { background: color-mix(in srgb, var(--accent) 6%, transparent); box-shadow: inset 0 0 0 2px #A4BCFD; }
.col.col-ghost > * { visibility: hidden; }
.col.col-dragging { opacity: .96 !important; rotate: 1deg; box-shadow: 0 18px 40px rgba(16,24,40,.25); cursor: grabbing; }
.col-list { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 56px; }
.col .empty { display: none; margin: 0; }
.col-list:not(:has(.bcard)) ~ .empty { display: block; }
.col-note { display: none; }

.bcard { position: relative; }
.bcard .top { justify-content: flex-start; gap: 6px; }
.bcard .card-link { color: inherit; margin-right: auto; }
.bcard .card-link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.bcard .card-link:focus-visible { outline: none; }
.bcard:has(.card-link:focus-visible) { outline: 3px solid #C7D7FE; outline-offset: 1px; }
.bcard.can-move { cursor: grab; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.bcard .grip { color: #98A2B3; flex-shrink: 0; margin-left: -2px; }
.card-move { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px;
  border-radius: 6px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text-2);
  font: 600 12px var(--font); cursor: pointer; }
.card-move::before { content: ""; position: absolute; inset: -10px -6px; }  /* 44 px tall tap area */
.card-move:hover { background: var(--accent-bg); border-color: #C7D7FE; color: var(--accent); }
.card-move:focus-visible { outline: 3px solid #C7D7FE; outline-offset: 1px; }
@media (hover: hover) and (pointer: fine) {
  .card-move { opacity: 0; }
  .bcard:hover .card-move, .bcard:focus-within .card-move { opacity: 1; }
}
.bcard .card-busy { display: none; position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px;
  border: 2.5px solid var(--accent); border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.bcard.is-pending, .bcard.is-waiting { pointer-events: none; }
.bcard.is-pending > :not(.card-busy), .bcard.is-waiting > * { opacity: .45; }
.bcard.is-pending .card-busy { display: block; }
.bcard.just-moved { box-shadow: 0 0 0 2px var(--accent), 0 4px 12px rgba(16,24,40,.12); }

/* while dragging */
.bcard.is-chosen { box-shadow: 0 8px 24px rgba(16,24,40,.18); }
.bcard.is-ghost { background: color-mix(in srgb, var(--accent) 6%, transparent); box-shadow: none; outline: 2px dashed #A4BCFD; outline-offset: -2px; }
.bcard.is-ghost > * { visibility: hidden; }
.bcard.is-dragging-card { opacity: .97 !important; rotate: 1.5deg; box-shadow: 0 18px 40px rgba(16,24,40,.28); cursor: grabbing; }
body.board-dragging, body.board-dragging * { cursor: grabbing !important; }
.board.is-dragging .col.can-drop { background: color-mix(in srgb, var(--accent) 7%, var(--col)); box-shadow: inset 0 0 0 2px #C7D7FE; }
.board.is-dragging .col.drop-over { background: color-mix(in srgb, var(--accent) 14%, var(--col)); box-shadow: inset 0 0 0 2px var(--accent); }
.board.is-dragging .col.no-drop { background: #F4F5F8; }
.board.is-dragging .col.no-drop > .col-list, .board.is-dragging .col.no-drop > .empty { opacity: .35; filter: grayscale(1); }
.board.is-dragging .col.no-drop .col-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0;
  padding: 6px 10px; border-radius: 8px; background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 600; }

/* Move / step sheet: the shell's .sheet (see "app shell" below) with the board's contents. Undo toasts are the
   shell's toasts too: board.html gives #messages the "float" class. */
.sheet-title { flex: 1; min-width: 0; }
.sheet-title h2 { font-size: 18px; }
.sheet-title h2:focus { outline: none; }
.sheet-title p { margin: 4px 0 0; }
.move-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.move-opt { width: 100%; min-height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 14px 0 16px; border: 1px solid var(--line-2);
  border-radius: 12px; background: var(--surface); color: var(--ink); font: 600 16px var(--font); text-align: left; cursor: pointer; }
.move-opt:hover { background: var(--accent-bg); border-color: #C7D7FE; }
.move-opt:focus-visible { outline: 3px solid #C7D7FE; outline-offset: 1px; }
.move-opt .n { margin-left: auto; font: 600 13px var(--mono); color: var(--muted); }
.move-opt > svg { color: var(--subtle); flex-shrink: 0; }
.move-opt.is-busy > svg { display: none; }
.move-opt.is-busy::after, .board-step .btn.is-busy::after { content: ""; width: 16px; height: 16px; border: 2px solid currentColor;
  border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; flex-shrink: 0; }
.move-opt[disabled] { cursor: progress; }
.board-step { display: flex; flex-direction: column; gap: 10px; }
.board-step p { margin: 0 0 4px; }
.board-step .btn.big { white-space: normal; line-height: 1.2; text-align: center; }
.board-sheet-cancel { border-color: transparent; color: var(--muted); }
.board-step input[type=text], .board-step select { height: 44px; font-size: 16px; }  /* 16 px: iOS does not zoom in on focus */
.board-sheet-body > .btn.big { margin-top: 2px; }

/* phones and small tablets: one column per screen with a peek of the next, stage chips to jump or drop on */
@media (max-width: 900px) {
  .stage-chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; position: sticky; top: var(--topbar-h); z-index: 15;
    margin: 0 -24px 10px; padding: 8px 24px; background: var(--bg); scroll-padding-inline: 24px; }
  .stage-chips::-webkit-scrollbar { display: none; }
  .stage-chips .chip { flex: none; display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 14px; border-radius: 999px;
    border: 1px solid var(--line-2); background: var(--surface); color: var(--text-2); font: 600 14px var(--font); white-space: nowrap;
    transition: background-color .15s, border-color .15s, opacity .15s; }
  .stage-chips .chip b { font: 600 12px var(--mono); color: var(--muted); }
  .stage-chips .chip.active { background: var(--accent-bg); border-color: #C7D7FE; color: var(--accent); }
  /* while dragging, every stage is a drop target on screen: a grid that keeps the row's height (so nothing below
     moves) and lets its second row lie over the column heads */
  .stage-chips { height: 56px; }
  /* z-index: above the dragged copy (SortableJS gives it 100000), so the chip under the finger stays in sight */
  .board-root.is-dragging .stage-chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 6px;
    overflow: visible; z-index: 100001; }
  .board-root.is-dragging .chip { justify-content: center; padding: 0 8px; box-shadow: 0 2px 8px rgba(16,24,40,.12); }
  .board-root.is-dragging .chip.can-drop { border: 2px dashed #A4BCFD; }
  .board-root.is-dragging .chip.drop-over { background: var(--accent); border: 2px solid var(--accent); color: #fff; }
  .board-root.is-dragging .chip.drop-over b { color: #fff; }
  .board-root.is-dragging .chip.no-drop { opacity: .4; }
  .board-root .board { grid-auto-columns: min(80vw, 340px); align-items: start; scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain; margin: 0 -24px; padding: 0 24px 8px; scroll-padding-inline: 24px; }
  .board-root .board.is-dragging { scroll-snap-type: none; align-items: stretch; }
  .board-root .col { min-height: 180px; scroll-snap-align: start; }
  .board-kpis.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
  .board-kpis .kpi { flex-direction: column-reverse; justify-content: flex-end; gap: 2px; padding: 8px 10px; border-radius: 10px; }
  .board-kpis .kpi .label { font-size: 12px; line-height: 1.25; }
  .board-kpis .kpi .value { font-size: 20px; }
}
@media (max-width: 640px) {
  .board-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 12px; }
  .board-head h1 { min-width: 0; font-size: 20px; }
  .board-head .board-filters { grid-column: 1 / -1; grid-row: 2; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -14px; padding: 0 14px; }
  .board-head .board-filters::-webkit-scrollbar { display: none; }
  .board-head .pill { flex: none; min-height: 40px; padding: 0 16px; font-size: 14px; }
  .board-head .board-labels { display: none; }  /* label printing is a desk job; Labels stays in the menu */
  .board-head .btn.primary.small { height: 40px; padding: 0 14px; font-size: 14px; }
  .board-head { margin-bottom: 12px; }
  .stage-chips { height: 52px; margin: 0 -14px 8px; padding: 6px 14px; scroll-padding-inline: 14px; }
  .board-root.is-dragging .chip { font-size: 13px; gap: 5px; }
  .board-root .board { margin: 0 -14px; padding: 0 14px 8px; scroll-padding-inline: 14px; gap: 12px; }
}
/* touch screens (phones either way round, tablets): bigger cards and Move buttons */
@media (max-width: 640px), (pointer: coarse) {
  .bcard { padding: 14px; gap: 7px; border-radius: 12px; }
  .bcard .stock { font-size: 16px; }
  .bcard .title { font-size: 16px; }
  .bcard .meta { font-size: 13px; }
  .bcard .age { font-size: 12px; padding: 3px 8px; }
  .card-move { height: 32px; margin: -4px 0; padding: 0 10px; font-size: 13px; }
  .card-move::before { inset: -6px -4px; }
  .col-arrow { width: 36px; height: 36px; background: var(--surface); }
  .col-arrow::before { inset: -4px -1px; }
  .col-move { gap: 6px; margin: -6px -4px -6px 2px; }
}
@media (prefers-reduced-motion: no-preference) {
  .bcard.just-moved { transition: box-shadow .6s; }
}
@media (prefers-reduced-motion: reduce) {
  .board-root .col, .stage-chips .chip, .col-move { transition: none; }
  .bl-row.just-moved { animation: none; }
}

/* ---------- BOARD · Customize board: the button, the sheet and the form (inventory/_board_layout_form.html,
   js/board-layout.js; also its own page, board_layout.html) */
.board-customize svg { flex-shrink: 0; }
@media (min-width: 721px) { .sheet.layout-sheet { width: min(560px, calc(100vw - 32px)); padding-bottom: 0; } }
.bl-form { display: flex; flex-direction: column; gap: 10px; }
.bl-whose { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 0; }
.bl-help { margin: 0; }
.bl-error { margin: 0; padding: 9px 12px; border-radius: 8px; background: var(--danger-bg); color: var(--danger); font-size: 13px; font-weight: 600; }
.bl-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.bl-row { display: flex; align-items: center; gap: 6px; min-height: 60px; padding: 6px 6px 6px 4px; background: var(--surface); }
.bl-row + .bl-row { border-top: 1px solid var(--line); }
.bl-row.off { background: var(--surface-2); }
.bl-row.off .bl-stage { color: var(--subtle); }
.bl-row.off input[type=text] { color: var(--muted); }
.bl-row.just-moved { animation: sd-moved 1s ease-out; }
.bl-handle { display: inline-flex; align-items: center; justify-content: center; width: 28px; align-self: stretch; flex-shrink: 0;
  color: #98A2B3; cursor: grab; touch-action: none; border-radius: 6px; }
.bl-handle:hover { color: var(--muted); background: var(--surface-2); }
.bl-show { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 44px; flex-shrink: 0; cursor: pointer; }
.bl-show input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.bl-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.bl-stage { font-size: 12px; font-weight: 600; line-height: 1.3; color: var(--text-2); }
.bl-stage .dot { width: 7px; height: 7px; margin: 0 6px 1px 0; vertical-align: middle; }
.bl-days { font-weight: 500; color: var(--subtle); white-space: nowrap; }
.bl-name input[type=text] { height: 36px; padding: 0 10px; font-size: 14px; }
.bl-move { display: flex; gap: 4px; flex-shrink: 0; }
.bl-arrow { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0;
  border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text-2); cursor: pointer; }
.bl-arrow:hover { background: var(--accent-bg); border-color: #C7D7FE; color: var(--accent); }
.bl-arrow:focus-visible, .bl-handle:focus-visible { outline: 3px solid #C7D7FE; outline-offset: 1px; }
.bl-arrow:disabled { opacity: .3; cursor: default; background: var(--surface); border-color: var(--line-2); color: var(--text-2); }
.bl-form:not(.bl-live) :is(.bl-handle, .bl-move) { visibility: hidden; }  /* without JavaScript: the rows' order is kept */
.bl-row.bl-chosen { box-shadow: inset 0 0 0 2px #C7D7FE; }
.bl-row.bl-ghost { background: var(--accent-bg); }
.bl-row.bl-ghost > * { visibility: hidden; }
.bl-row.bl-dragging { opacity: .96 !important; box-shadow: 0 12px 32px rgba(16,24,40,.22); border-radius: 10px; cursor: grabbing; }
.bl-recent { gap: 6px; }
.bl-recent-input { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); }
.bl-recent-input input { width: 84px; }
.bl-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
/* in the sheet, Save stays at the bottom of the screen while the list scrolls */
.layout-sheet .bl-actions { position: sticky; z-index: 2; bottom: 0; margin: 0 -20px; padding: 12px 20px 16px;
  background: var(--surface); border-top: 1px solid var(--line); }
.layout-sheet .bl-resets { padding-bottom: 20px; }
.layout-sheet { scroll-padding-block: 12px 96px; }  /* a row the arrows bring into view is not left under Save */
.bl-actions .btn { flex: 1 1 auto; }
.bl-actions .btn.is-busy::after, .bl-resets .btn.is-busy::after { content: ""; width: 14px; height: 14px; border: 2px solid currentColor;
  border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.bl-resets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.bl-resets form { display: contents; }
.bl-resets .btn { color: var(--muted); }
.bl-page { max-width: 620px; }
/* the sheet on phones: Save stays at the bottom of the screen while the list scrolls */
@media (max-width: 720px) {
  .layout-sheet .bl-actions { bottom: calc(-16px - env(safe-area-inset-bottom, 0px)); margin: 0 -16px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .layout-sheet .bl-resets { padding-bottom: 0; }
  .bl-actions .btn { min-height: 48px; font-size: 15px; }
  .bl-resets .btn { min-height: 44px; }
  .bl-name input[type=text] { height: 44px; font-size: 16px; }  /* 16 px: iOS does not zoom in on focus */
  .bl-arrow { width: 44px; height: 44px; }
  .bl-handle { width: 32px; }
  .bl-recent-input input { font-size: 16px; }
}
/* the filters and Customize: part of the head's row on wide screens, a row of their own on phones */
.board-tools { display: contents; }
@media (max-width: 640px) {
  .board-head .board-tools { grid-column: 1 / -1; grid-row: 2; display: flex; align-items: center; gap: 8px; min-width: 0; }
  .board-head .board-tools .board-filters { flex: 1; min-width: 0; margin: 0 0 0 -14px; padding: 0 0 0 14px;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 20px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 20px), transparent); }  /* more pills to scroll to */
  .board-head .board-customize { flex: none; width: 44px; height: 44px; padding: 0; }
  .board-head .board-customize span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ---------- tables */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 11px; font-weight: 700; color: var(--subtle); letter-spacing: .05em; text-transform: uppercase;
  background: var(--surface-2); padding: 10px 14px; white-space: nowrap; }
table.data td { padding: 11px 14px; border-top: 1px solid #F2F4F7; vertical-align: middle; }
table.data tr:hover td { background: #FCFCFD; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 0; }

/* ---------- PAGES · lists on phones: inventory and Tesla fleet cards, wide tables (inventory/list.html,
   tesla/fleet.html, inventory/reports.html, tesla/activity.html, tesla/settings.html)
   The list pages render the rows twice, as a table and as .car-list cards; phones get the cards. Tables that stay
   (.table-scroll) keep their first column in place and show a shadow at the edge that has more columns. */
.list-q { max-width: 320px; }
.list-status { max-width: 220px; }
.list-source { max-width: 180px; }
.list-foot { display: none; }
.car-list { display: none; list-style: none; margin: 0; padding: 0; flex-direction: column; gap: 8px; }
.carrow { display: flex; flex-direction: column; gap: 4px; min-height: 64px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.carrow:hover, .carrow:active { color: var(--ink); border-color: var(--line-2); }
.carrow-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.carrow .stock { font: 700 16px var(--mono); }
.carrow-title { font-size: 15px; font-weight: 600; }
.carrow-meta { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 13px; color: var(--subtle); }
.carrow-action { margin-top: 6px; }
.table-scroll { background: linear-gradient(to right, var(--surface) 30%, rgba(255,255,255,0)) left center / 40px 100% no-repeat local,
  linear-gradient(to left, var(--surface) 30%, rgba(255,255,255,0)) right center / 40px 100% no-repeat local,
  radial-gradient(farthest-side at 0 50%, rgba(16,24,40,.14), transparent) left center / 12px 100% no-repeat scroll,
  radial-gradient(farthest-side at 100% 50%, rgba(16,24,40,.14), transparent) right center / 12px 100% no-repeat scroll,
  var(--surface); }
@media (max-width: 720px) {
  .list-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .list-filters .list-q { grid-column: 1 / -1; max-width: none; height: 48px; }
  .list-filters select { max-width: none; }
  .list-filters .list-tesla { grid-column: 1 / -1; justify-self: start; min-height: 44px; padding: 0 16px 0 12px; border: 1px solid var(--line-2);
    border-radius: 999px; background: var(--surface); }
  .list-filters .list-tesla:has(input:checked) { background: var(--accent-bg); border-color: #C7D7FE; color: var(--accent); }
  .list-filters.autosubmit-on .list-go { display: none; }  /* changes apply by themselves (js/pages.js) */
  .list-head .list-export { display: none; }
  .list-foot { display: flex; justify-content: center; margin: 8px 0 0; }
  .cars-table { display: none; }
  .car-list { display: flex; }
  .fleet-head > span { flex-basis: 100%; }
  .fleet-head form { flex: 1; }
  .fleet-head form .btn { width: 100%; }
  .pager { justify-content: space-between; }
  .pager .btn { flex: 1; max-width: 140px; }
  .table-scroll table.data th:first-child, .table-scroll table.data td:first-child { position: sticky; left: 0; z-index: 1;
    background: var(--surface); box-shadow: 1px 0 0 var(--line); }
  .table-scroll table.data th:first-child { background: var(--surface-2); }
  .table-scroll table.data td:first-child { white-space: nowrap; }
}

/* ---------- vehicle detail */
.vehicle-head { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.vehicle-head .stock { font: 700 34px/1 var(--mono); }
.vehicle-head .title { font-size: 18px; font-weight: 600; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--ink); border-color: var(--accent); }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.fact { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.fact .k { font-size: 11px; font-weight: 600; color: var(--subtle); }
.fact .v { font-size: 14px; font-weight: 600; }
.steps { display: flex; gap: 6px; }
.steps .s { flex: 1; display: flex; flex-direction: column; gap: 5px; font-size: 10px; font-weight: 700; color: var(--muted); }
.steps .bar { height: 6px; border-radius: 3px; background: var(--line); }
.steps .s.done .bar { background: #12B76A; }
.steps .s.now .bar { background: var(--accent); }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.timeline li { display: flex; gap: 12px; }
.timeline .pip { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex-shrink: 0; }
.quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

/* ---------- PAGES · car page (inventory/detail.html)
   Up to 900px the two columns dissolve (.stack gets display: contents) and the sections are re-ordered so the
   signed-in user's actions come first: an open pickup, Update status, Check in, Paperwork, then the facts. */
.quick > .span-all, .quick > :only-child { grid-column: 1 / -1; }
.quick .btn { white-space: normal; line-height: 1.2; text-align: center; padding: 4px 10px; }  /* long labels wrap */
.assign > summary { cursor: pointer; font-size: 13px; font-weight: 600; }
@media (max-width: 900px) {
  .car-tabs { position: sticky; top: var(--topbar-h); z-index: 10; background: var(--bg);
    box-shadow: 0 0 0 100vmax var(--bg); clip-path: inset(-4px -100vmax); }  /* background to the screen edges */
  .car-grid { display: flex; flex-direction: column; gap: 12px; }
  .car-grid > .stack { display: contents; }
  .sec-status { order: 1; } .sec-checkin { order: 2; } .sec-paperwork { order: 3; } .sec-facts { order: 4; }
  .sec-transport { order: 5; } .sec-paperwork.is-done { order: 6; } .sec-sticker { order: 7; }
  .car-grid.transport-open .sec-transport { order: 0; }  /* a pickup still under way: its buttons first */
}
@media (max-width: 720px) {
  .vehicle-head { gap: 10px; }
  .vehicle-head .stock { font-size: 30px; }
  .vehicle-head .title { font-size: 17px; }
  .car-tabs { gap: 0; margin-bottom: 14px; }
  .car-tabs a { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 48px; font-size: 15px; }
  .sec-transport > h2 { order: -2; }
  .sec-transport > .transport-actions { order: -1; }  /* Picked up / Delivered right under the heading */
  .assign > summary { display: list-item; padding: 12px 0; font-size: 15px; }
  .paperwork { flex-direction: column; align-items: stretch; }
  .paperwork .btn { width: 100%; min-height: 48px; font-size: 15px; }
  .stickers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stickers .btn { min-height: 44px; }
  .steps .s { font-size: 11px; }
  .fact .k { font-size: 12px; }
  .fact .v { font-size: 15px; overflow-wrap: anywhere; }
  .timeline .tiny { font-size: 13px; }
}

/* ---------- Tesla panel */
.tesla-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cmd { height: 78px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  font: 600 13px var(--font); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; cursor: pointer; width: 100%; }
.cmd:hover { border-color: var(--line-2); background: var(--surface-2); }
.cmd.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.cmd.primary:hover { background: var(--accent-ink); }
.cmd[disabled] { opacity: .45; cursor: not-allowed; }
.battery { display: flex; align-items: flex-end; gap: 16px; }
.battery .pct { font: 700 38px/1 var(--mono); }
.meter { flex: 1; height: 12px; border-radius: 6px; background: var(--line); overflow: hidden; margin-bottom: 6px; }
.meter span { display: block; height: 12px; background: #12B76A; }
.toast { padding: 10px 14px; border-radius: 10px; font-size: 14px; font-weight: 600; }
.toast.ok { background: var(--ok-bg); color: var(--ok); }
.toast.err { background: var(--danger-bg); color: var(--danger); }
.notice { padding: 14px 16px; border-radius: 12px; background: var(--warn-bg); border: 1px solid var(--warn-line); color: #7A2E0E; font-size: 14px; }
.notice strong { color: var(--warn); display: block; font-size: 15px; margin-bottom: 2px; }
.spinner { display: none; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.htmx-request .spinner, .htmx-request.spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- PAGES · Tesla remote control progress, PIN / confirm sheet (tesla/_panel.html, base.html dialog)
   htmx puts .htmx-request on the command's form while it is out: the tile shows a spinner, not a greyed look.
   Phones: tiles grow, the panel's toast stays in view under the tabs, the confirm dialog is a bottom sheet. */
form.htmx-request .cmd[disabled] { opacity: 1; cursor: progress; }
form.htmx-request .cmd:not(.primary) { border-color: var(--accent); color: var(--accent); }
form.htmx-request .cmd svg { display: none; }
.cmd .spinner { width: 22px; height: 22px; }
.cmd-note.busy { color: var(--accent); font-weight: 600; }
@media (max-width: 720px) {
  .tesla-grid { gap: 10px; }
  .cmd { height: auto; min-height: 84px; padding: 10px 4px; font-size: 14px; }
  #tesla-panel > .toast { position: sticky; z-index: 5; top: calc(var(--topbar-h) + 56px);
    box-shadow: 0 6px 16px rgba(16,24,40,.12); }
  dialog#confirm-dialog { width: 100%; max-width: none; max-height: 100%; margin: auto 0 0; border-radius: 20px 20px 0 0; }
  #confirm-dialog[open] { animation: sheet-up .25s cubic-bezier(.2,.8,.2,1); }
  #confirm-dialog .pin-sheet { gap: 16px; padding: 24px max(20px, env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom, 0px))
    max(20px, env(safe-area-inset-left)); }
  #confirm-dialog .pin-sheet .small { font-size: 15px; }
  #confirm-dialog .btn { min-height: 52px; font-size: 16px; }
}
@keyframes sheet-up { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) {
  #confirm-dialog[open] { animation: none; }
  .spinner, .btn.is-busy::after { animation-duration: 2s; }
}

/* ---------- Tesla demo mode (tesla/demo.py): the DEMO badge on every Tesla screen (tesla/_demo_badge.html), its toast
   and tag, and the switch on tesla/settings.html. Blue like the accent, not warning orange: it is a mode, not a
   problem. The stripes read as "sample" at a glance. */
.tag.demo { background: var(--accent-bg); color: var(--accent); }
.demo-badge { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid #C7D7FE; border-radius: 12px;
  background: repeating-linear-gradient(135deg, var(--accent-bg) 0 14px, #E4EAFE 14px 28px); color: var(--accent-ink);
  font-size: 14px; line-height: 1.35; }
.demo-badge > b { flex-shrink: 0; padding: 3px 8px; border-radius: 6px; background: var(--accent); color: #fff; font-size: 12px;
  letter-spacing: .08em; }
.demo-badge a { font-weight: 600; white-space: nowrap; }
.toast.demo { background: var(--accent-bg); color: var(--accent-ink); border: 1px solid #C7D7FE; }
.checklist .demo-badge { grid-column: 1 / -1; }
.demo-card { display: flex; align-items: center; gap: 16px; }
.demo-card p { margin: 0; color: var(--subtle); font-size: 13px; }
.demo-card.on { border-color: #C7D7FE; background: #F5F8FF; box-shadow: inset 4px 0 0 var(--accent); }
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 4px; border: 0; border-radius: 22px;
  background: none; font: 600 14px var(--font); color: var(--muted); cursor: pointer; }
.switch-track { position: relative; flex-shrink: 0; width: 52px; height: 32px; border-radius: 16px; background: var(--subtle);
  transition: background-color .2s; }
.switch-knob { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(16,24,40,.3); transition: transform .2s cubic-bezier(.2,.8,.2,1); }
.switch-label { min-width: 2em; text-align: left; }
.switch[aria-checked="true"] { color: var(--accent); }
.switch[aria-checked="true"] .switch-track { background: var(--accent); }
.switch[aria-checked="true"] .switch-knob { transform: translateX(20px); }
.switch:focus-visible { outline: 3px solid #C7D7FE; outline-offset: 2px; }
@media (max-width: 720px) {
  .demo-card { align-items: flex-start; }
  .demo-badge { align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) { .switch-track, .switch-knob { transition: none; } }

/* ---------- settings */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; }
.subnav { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.subnav .h { font-size: 12px; font-weight: 700; color: var(--subtle); letter-spacing: .06em; padding: 14px 12px 6px; }
.subnav a { padding: 9px 12px; border-radius: 8px; color: var(--text-2); }
.subnav a.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.checklist { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.checklist .item { display: flex; gap: 10px; align-items: flex-start; }
.checklist .mark { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0; background: var(--surface-2); color: var(--subtle); border: 1px solid var(--line-2); }
.checklist .item.done .mark { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.kv { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 12px; font-size: 14px; padding: 4px 0; }
.kv > :last-child { overflow-wrap: anywhere; }
.copybox { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 12px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 8px; font: 500 12px var(--mono); color: var(--text-2); word-break: break-all; }
.radio-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.radio-cards label { display: flex; gap: 10px; padding: 12px; border: 1px solid var(--line-2); border-radius: 10px; font-weight: 500; cursor: pointer; }
.radio-cards label:has(input:checked) { border: 2px solid var(--accent); background: #F5F8FF; }
.logo-tile { display: flex; align-items: center; justify-content: center; min-height: 112px; padding: 16px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.logo-tile img { max-width: 100%; max-height: 96px; width: auto; height: auto; }
/* Users & roles, Sources, Locations (accounts/team*.html, inventory/settings_*.html). Their lists render twice, like
   the inventory list: a table on wide screens, cards (.setting-list) on phones. */
.setting-form { max-width: 760px; }
.setting-list { display: none; list-style: none; margin: 0; padding: 0; flex-direction: column; gap: 8px; }
.setting-row { display: flex; flex-direction: column; gap: 4px; min-height: 64px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
a.setting-row:hover, a.setting-row:active { color: var(--ink); border-color: var(--line-2); }
.setting-row-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.setting-row-title { font-size: 15px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.setting-row-meta { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 13px; color: var(--subtle); }
.setting-invite { flex-wrap: nowrap; min-height: 48px; margin: 0 -8px; padding: 6px 8px; border-radius: 10px; color: var(--ink); }
.setting-invite:hover { background: var(--surface-2); color: var(--ink); }
.role-field { border: 0; margin: 0; padding: 0; min-width: 0; }
.role-field legend { padding: 0; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.addon-check { align-items: flex-start; }
.addon-check input { margin-top: 2px; flex-shrink: 0; }
.member-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.member-signin { align-self: start; }
@media (max-width: 900px) { .member-signin { order: -1; } }  /* one column: the sign-in actions before the long form */
@media (max-width: 720px) {
  .setting-table { display: none; }
  .setting-list { display: flex; }
  .member-actions { flex-direction: column; }
  .member-actions .btn { width: 100%; min-height: 48px; }
}

/* ---------- PAGES · labels, settings, account pages, errors (labels/home.html, tesla/settings.html, tesla/pair.html,
   branding/settings.html, accounts/*.html, 403.html) */
.labels-template { max-width: 320px; }
.labels-copies { max-width: 110px; }
.labels-note { margin: 0 0 12px; }
.labels-design { font-weight: 600; white-space: nowrap; }
.labels-table tr[data-pick-row] { cursor: pointer; }
.labels-table tr[data-pick-row]:has(.pick:checked) td { background: #F5F8FF; }
.labels-bar, .settings-save { display: none; }
.copy-row { display: flex; gap: 8px; align-items: stretch; }
.copy-row .copybox { flex: 1; min-width: 0; }
.pair-qr > summary { cursor: pointer; font-weight: 600; color: var(--accent); text-align: center; padding: 10px 0; }
.pair-qr .qr { display: flex; justify-content: center; }
.pair-qr .qr svg { max-width: 100%; height: auto; }
.error-card { max-width: 520px; }
.error-card .ico { width: 48px; height: 48px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--warn-bg); color: var(--warn); }
@media (min-width: 721px) {
  .pair-qr > summary { display: none; }  /* wide screens: the QR is what a phone scans, so it is always shown */
}
@media (max-width: 720px) {
  .labels-head { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 8px; }
  .labels-head h1 { grid-column: 1 / -1; min-width: 0; }
  .labels-head select { max-width: none; height: 44px; }
  .labels-head .labels-print { display: none; }
  .labels-table td, .labels-table th { padding-top: 12px; padding-bottom: 12px; }
  .labels-table input[type=checkbox] { width: 22px; height: 22px; }
  .labels-bar { display: block; position: sticky; z-index: 5; bottom: calc(var(--tabbar-h, 0px) + env(safe-area-inset-bottom, 0px));
    margin: 12px -14px 0; padding: 10px 14px calc(10px + var(--bar-clear)); background: var(--bg); border-top: 1px solid var(--line); }
  .kb-open .labels-bar { bottom: 0; padding-bottom: 10px; }
  .radio-cards { grid-template-columns: 1fr; }
  .settings .page-head { gap: 8px; }
  .settings .copybox { font-size: 12px; }
  .settings-save { display: block; grid-column: 1 / -1; position: sticky; z-index: 5; margin: 0 -14px; padding: 10px 14px calc(10px + var(--bar-clear));
    bottom: calc(var(--tabbar-h, 0px) + env(safe-area-inset-bottom, 0px)); background: var(--bg); border-top: 1px solid var(--line); }
  .kb-open .settings-save { bottom: 0; padding-bottom: 10px; }
  .settings-save .btn { width: 100%; min-height: 48px; }
  .save-main { display: none; }  /* the sticky bar carries Save on phones */
  .error-card .btn { min-height: 48px; }
}

/* ---------- PAGES · sticker design, Settings › Stickers (labels/design.html + js/sticker-design.js)
   The form on the left, the real sticker (a PNG of its PDF) on the right; one column below 1100 px, the preview
   under the form. The item rows reorder with their up/down buttons (44 px targets on touch screens). */
.sd-page { gap: 16px; min-width: 0; }
.sd-head { margin: 0; }
.sd-intro { margin: -6px 0 0; max-width: 78ch; }
.sd-sizes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.sd-size { position: relative; display: flex; flex-direction: column; gap: 2px; min-height: 60px; padding: 10px 12px;
  border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); color: var(--text-2); }
.sd-size:hover { border-color: #A4BCFD; color: var(--text-2); }
.sd-size b { font-size: 14px; color: var(--ink); }
.sd-size span { font-size: 12px; color: var(--subtle); }
.sd-size.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: #F5F8FF; }
.sd-custom { align-self: flex-start; margin-top: 4px; padding: 1px 7px; border-radius: 6px; background: var(--ok-bg); color: var(--ok);
  font-size: 11px; font-style: normal; font-weight: 600; }
.sd-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 16px; align-items: start; }
.sd-form { gap: 16px; min-width: 0; }
.sd-preview { position: sticky; top: calc(var(--topbar-h) + 16px); min-width: 0; }
.sd-items { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.sd-item { display: flex; align-items: center; gap: 8px; min-height: 54px; padding: 5px 6px 5px 12px; background: var(--surface); }
.sd-item + .sd-item { border-top: 1px solid var(--line); }
.sd-item.off { background: var(--surface-2); }
.sd-item.off .sd-name { color: var(--muted); font-weight: 500; }
.sd-item.just-moved { animation: sd-moved 1s ease-out; }
@keyframes sd-moved { from { background: var(--accent-bg); } }
.sd-check { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.sd-check input { width: 18px; height: 18px; flex-shrink: 0; margin: 0; accent-color: var(--accent); }
.sd-text { display: flex; flex-direction: column; min-width: 0; }
.sd-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.sd-example { font-size: 12px; font-weight: 400; color: var(--subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sd-example.mono { font-size: 11px; }
select.sd-vin { width: auto; max-width: 168px; height: 36px; padding: 0 8px; font-size: 13px; }
.sd-move { display: flex; gap: 4px; flex-shrink: 0; }
.sd-arrow { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--text-2); cursor: pointer; }
.sd-arrow:hover { background: var(--accent-bg); border-color: #C7D7FE; color: var(--accent); }
.sd-arrow:focus-visible { outline: 3px solid #C7D7FE; outline-offset: 1px; }
.sd-arrow:disabled { opacity: .3; cursor: default; background: var(--surface); border-color: var(--line-2); color: var(--text-2); }
.sd-note { margin: 0; }
.sd-tokens-box { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.sd-tokens-h { font-weight: 600; color: var(--text-2); }
.sd-tokens { display: flex; flex-wrap: wrap; gap: 6px; }
.sd-token { height: 32px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface-2);
  color: var(--text-2); font: 500 12px var(--mono); cursor: pointer; }
.sd-token:hover { background: var(--accent-bg); border-color: #C7D7FE; color: var(--accent); }
.sd-token:focus-visible { outline: 3px solid #C7D7FE; outline-offset: 1px; }
.sd-tokens-box .help { font-size: 12px; color: var(--subtle); }
.sd-preview-head { display: flex; align-items: baseline; gap: 10px; }
.sd-preview-head h2 { flex: 1; }
.sd-state { color: var(--subtle); }
.sd-state.error { color: var(--danger); font-weight: 500; }
/* the label on its backing paper */
.sd-stage { display: flex; align-items: center; justify-content: center; padding: 22px; border-radius: 10px;
  background: var(--col); min-height: 180px; }
.sd-stage img { display: block; width: 100%; height: auto; border-radius: 8px; background: #fff;
  box-shadow: 0 1px 2px rgba(16,24,40,.10), 0 8px 20px rgba(16,24,40,.10); transition: opacity .15s; }
.sd-stage.tag { padding: 36px 22px; }
.sd-stage.tag img { border-radius: 10px; }
.sd-stage.is-busy img { opacity: .55; }
.sd-stage.is-stale img { opacity: .3; }  /* an earlier state of the form: see .sd-state */
.sd-caption { margin: -4px 0 0; }
.sd-warnings { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sd-warnings:empty { display: none; }
.sd-warnings li { padding: 9px 12px; border-radius: 8px; background: var(--warn-bg); border: 1px solid var(--warn-line);
  color: #7A2E0E; font-size: 13px; overflow-wrap: anywhere; }
.sd-fits { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--ok); font-size: 13px; font-weight: 600; }
.sd-bottom, .sd-actions, .sd-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.sd-bottom { gap: 10px 24px; }
.sd-jump { display: none; }
@media (prefers-reduced-motion: reduce) { .sd-item.just-moved { animation: none; } .sd-stage img { transition: none; } }
@media (max-width: 1100px) {
  .sd-editor { grid-template-columns: minmax(0, 1fr); }
  .sd-preview { position: static; scroll-margin-top: calc(var(--topbar-h) + 12px); }
  .sd-jump { display: inline-flex; }  /* one column: the preview is under the form */
}
@media (max-width: 720px) {
  .sd-sizes { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .sd-size { min-height: 64px; }
  .sd-item { flex-wrap: wrap; min-height: 60px; padding: 6px 6px 6px 12px; }
  .sd-check { min-height: 48px; }
  .sd-check input { width: 22px; height: 22px; }
  .sd-name { font-size: 15px; }
  .sd-arrow { width: 44px; height: 44px; }
  .sd-move { order: 2; }
  select.sd-vin { order: 3; flex-basis: 100%; max-width: none; height: 44px; margin: 0 6px 6px 32px; width: calc(100% - 38px); }
  .sd-token { height: 40px; padding: 0 12px; font-size: 13px; }
  .sd-stage { padding: 14px; min-height: 0; }
  .sd-stage.tag { padding: 22px 14px; }
  /* Save stays at the bottom of the screen, like the other settings pages; Reset and "Saved by" do not */
  .sd-bottom { display: contents; }
  .sd-actions { flex-wrap: nowrap; position: sticky; z-index: 5; bottom: calc(var(--tabbar-h, 0px) + env(safe-area-inset-bottom, 0px));
    margin: 0 -14px; padding: 10px 14px calc(10px + var(--bar-clear)); background: var(--bg); border-top: 1px solid var(--line); }
  .kb-open .sd-actions { bottom: 0; padding-bottom: 10px; }
  .sd-actions > .btn.primary { flex: 1; min-height: 48px; }
  .sd-jump { order: -1; }
  .sd-actions .btn, .sd-meta .btn { min-height: 48px; }
}

/* ---------- scanner (inventory/scan.html + js/scan.js)
   A fixed-height box that the camera picture fills (object-fit: cover), whatever shape the phone's stream has: iPhones
   send portrait frames, laptops landscape. The frame is drawn on the box and scan.js reads exactly the part of the
   picture under it. The dim mask is the frame's own shadow, clipped by the box; the corner brackets are its background.
   Wide and short, like a VIN label; a QR sticker is read anywhere in the picture. */
.scanner { position: relative; overflow: hidden; isolation: isolate; border-radius: 16px; background: #1F242B;
  height: clamp(200px, min(62vw, 58vh), 340px); }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-window { --br: #fff; position: absolute; left: 7%; right: 7%; top: 31%; height: 38%; border-radius: 6px;
  outline: 1px solid rgba(255,255,255,.5); box-shadow: 0 0 0 100vmax rgba(16,24,40,.52);
  background: linear-gradient(var(--br), var(--br)) left top / 26px 4px, linear-gradient(var(--br), var(--br)) left top / 4px 26px,
    linear-gradient(var(--br), var(--br)) right top / 26px 4px, linear-gradient(var(--br), var(--br)) right top / 4px 26px,
    linear-gradient(var(--br), var(--br)) left bottom / 26px 4px, linear-gradient(var(--br), var(--br)) left bottom / 4px 26px,
    linear-gradient(var(--br), var(--br)) right bottom / 26px 4px, linear-gradient(var(--br), var(--br)) right bottom / 4px 26px;
  background-repeat: no-repeat; }
.scan-window::after { content: ""; position: absolute; left: 5%; right: 5%; top: calc(50% - 1px); height: 2px; border-radius: 1px;
  background: #F04438; box-shadow: 0 0 6px rgba(240,68,56,.7); }  /* aiming line for the barcode */
.scanner.hit .scan-window { --br: #17B26A; outline: 3px solid #17B26A; }  /* a code was read */
.scan-hint { position: absolute; top: 10px; left: 12px; right: 12px; margin: 0; text-align: center; pointer-events: none;
  color: #fff; font-size: 13px; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.7); }
.scan-sheet { background: var(--surface); border-radius: 16px; padding: 16px; margin-top: 12px; }

/* ---------- PAGES · scan and pickups (inventory/scan.html + js/scan.js, inventory/pickups.html) */
.scan { max-width: 560px; margin: 0 auto; }
.scan-help { margin: 0 0 10px; }
.scan-mode { margin-bottom: 10px; }
.scan-mode-on { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; padding: 8px 8px 8px 12px; border-radius: 12px;
  background: var(--ok-bg); color: var(--ok); font-size: 14px; font-weight: 500; }
.scan-mode-on span { flex: 1; }
.scan-mode-on svg { flex-shrink: 0; }
.checkin-on .scanner { box-shadow: 0 0 0 3px var(--ok); }
.no-camera .scanner { display: none; }
.torch { position: absolute; right: 12px; bottom: 12px; z-index: 5; width: 52px; height: 52px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; border: 0; cursor: pointer;
  background: rgba(16,24,40,.6); color: #fff; }
.torch[aria-pressed="true"] { background: #fff; color: var(--ink); }
.torch:focus-visible { outline: 3px solid #C7D7FE; outline-offset: 2px; }
.scan-manual { display: flex; flex-direction: column; gap: 6px; }
.scan-manual .row { flex-wrap: nowrap; }
.scan-manual input { flex: 1; min-width: 0; height: 48px; font: 600 17px var(--mono); letter-spacing: .04em; text-transform: uppercase; }
.scan-manual input::placeholder { font: 400 15px var(--font); letter-spacing: 0; text-transform: none; }
.scan-manual .btn { height: 48px; min-width: 72px; }
.scan-hit { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--ok-bg);
  border: 1px solid #ABEFC6; color: var(--ink); }
.scan-hit > svg { flex-shrink: 0; color: var(--ok); }
.scan-hit-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.scan-hit .stock { font: 700 18px var(--mono); }
.scan-hit .title { font-size: 14px; font-weight: 600; color: var(--text-2); }
.scan-hit-open { font-weight: 600; color: var(--accent); }
/* photo of the VIN (js/vin-photo.js): the button, then a card to confirm the reading. Also on the intake form. */
.scan-photo { margin-top: 12px; }
/* the file input is opened by the button; out of sight, and too small to widen the page (the global rule is 100%) */
.vin-photo input[type=file] { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; border: 0; opacity: 0;
  overflow: hidden; pointer-events: none; }
.photo-btn { gap: 10px; }
.no-camera .photo-btn { background: var(--accent); border-color: var(--accent); color: #fff; }  /* the way in without a camera */
.photo-card { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; padding: 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.photo-card.warn { border-color: var(--warn-line); }
.photo-title { margin: 0; font-size: 13px; font-weight: 600; color: var(--text-2); }
/* all 17 characters must show to be compared with the car, down to 320 px wide phones; never under 16 px (iOS zooms) */
.photo-card .photo-vin { height: 56px; padding: 0 6px; font: 700 22px var(--mono); font-size: clamp(16px, 5.2vw, 22px);
  letter-spacing: .02em; text-align: center; text-transform: uppercase; }
.photo-note { margin: 0; font-size: 14px; color: var(--text-2); }
.photo-card.warn .photo-note, .photo-card.warn .photo-title { color: var(--warn); font-weight: 600; }
.photo-error { margin: 0; font-size: 14px; font-weight: 600; color: var(--danger); }
.photo-progress { margin: 4px 0 0; font-size: 14px; font-weight: 600; color: var(--accent); }
.photo-tips { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 14px; color: var(--text-2); }
.photo-alts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.photo-alts .btn { letter-spacing: .03em; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-actions .btn { flex: 1; min-height: 44px; }
.photo-actions .btn.primary { flex-basis: 100%; min-height: 50px; font-size: 16px; }
.vin-row { display: flex; gap: 8px; }
.vin-row input { flex: 1; min-width: 0; }
.vin-row .btn { flex-shrink: 0; height: var(--field-h, 40px); }
.vin-field .photo-card { margin-top: 4px; }
.pickups { max-width: 640px; }
.pickup-car { display: flex; flex-direction: column; gap: 2px; color: var(--ink); }
.pickup-car:hover { color: var(--ink); }
.pickup-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pickup-top .stock { font: 700 20px var(--mono); color: var(--accent); }
.pickup-title { font-weight: 600; }
.pickup-from { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.pickup-from > .stack { flex: 1; }
.pickup-from b { overflow-wrap: anywhere; }
.directions { flex-shrink: 0; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 32px 18px; text-align: center; color: var(--subtle); }
.empty-state b { color: var(--ink); }
@media (max-width: 720px) {
  .scan .page-head { margin-bottom: 6px; }
  .scan-mode select { height: 48px; }
  .scan-mode-on .btn { min-height: 40px; }
  .scan-sheet { padding: 14px; }
  .directions { min-height: 44px; }
}

/* ---------- messages / misc */
.messages { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.messages:empty { margin: 0; }  /* not display: none, which would drop the live region from the accessibility tree */
.msg { padding: 10px 14px; border-radius: 10px; font-size: 14px; font-weight: 500; background: var(--accent-bg); color: var(--accent-ink); }
.msg.success { background: var(--ok-bg); color: var(--ok); }
.msg.error { background: var(--danger-bg); color: var(--danger); }
.msg.warning { background: var(--warn-bg); color: var(--warn); }
.empty { color: var(--subtle); font-size: 13px; text-align: center; padding: 18px 8px; }
dialog { border: 0; border-radius: 20px; padding: 0; width: min(390px, 94vw); box-shadow: 0 24px 64px rgba(16,24,40,.3); }
dialog::backdrop { background: rgba(16,24,40,.55); }
.pin-sheet { padding: 22px; display: flex; flex-direction: column; gap: 14px; align-items: center; text-align: center; }
.pin-sheet input { text-align: center; font: 700 28px var(--mono); letter-spacing: .5em; height: 60px; }
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: min(400px, 100%); }
/* The account status page (templates/tenants/status.html): the sign-in card, saying why the app is closed. */
.status-dealer, .status-message, .status-note { margin: 0; }
.status-dealer { margin-top: -6px; font-weight: 600; }
.status-message { font-size: 15px; line-height: 1.5; }
.status-contact { display: flex; flex-direction: column; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2); }
.status-contact a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; overflow-wrap: anywhere; }

/* ---------- app shell: phone top bar, bottom tab bar, sheets, toasts (markup: base.html + partials, JS: nav.js).
   Phones (<= 720px) get a compact top bar (brand, dealer name, page title, account button) and a bottom tab bar in
   place of the top nav and account menu. Wider screens keep the desktop header.
   For page sections: var(--tabbar-h) is the tab bar's height where it shows, else 0 (a sticky bottom bar can use
   bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px))). The sheet markup is documented in nav.js. */
:root { --tabbar-h: 0px; --topbar-h: 60px; }  /* --topbar-h: what sticky bars below the top bar stick under */
/* notched phones in landscape (wider than 720px, so the desktop header): keep clear of the notch */
.topbar { padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); }
.page { padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); }

/* bottom tab bar */
.tabbar { display: none; }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; min-height: 56px;
  padding: 4px 2px 6px; border: 0; background: none; color: var(--muted); font: 600 12px/1.1 var(--font);
  cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tab .ico { display: flex; align-items: center; justify-content: center; width: 52px; height: 30px; border-radius: 999px;
  transition: background-color .15s; }
.tab:active { color: var(--ink); }
.tab:active .ico { background: var(--surface-2); }
@media (hover: hover) { .tab:hover { color: var(--ink); } }  /* touch screens would keep the hover colour after a tap */
.tab[aria-current="page"], .tab.active { color: var(--accent); }
.tab[aria-current="page"] .ico, .tab.active .ico { background: var(--accent-bg); }
.tab:focus-visible { outline: 3px solid #C7D7FE; outline-offset: -3px; border-radius: 12px; }
/* the centre Scan button: a raised accent disc */
.tab-scan { color: var(--text-2); }
.tab-scan .ico, .tab-scan:active .ico, .tab-scan[aria-current="page"] .ico { width: 56px; height: 56px; margin-top: -24px;
  border-radius: 50%; background: var(--accent); color: #fff; box-shadow: 0 0 0 4px var(--surface), 0 6px 16px rgba(29,78,216,.35); }
.tab-scan:active .ico, .tab-scan[aria-current="page"] .ico { background: var(--accent-ink); }

/* sheets: a centred dialog here, a bottom sheet on phones (below) */
.sheet { position: fixed; z-index: 51; left: 50%; top: 50%; width: min(440px, calc(100vw - 32px));
  max-height: min(86vh, 720px); overflow-y: auto; overscroll-behavior: contain; background: var(--surface);
  border-radius: 20px; box-shadow: 0 24px 64px rgba(16,24,40,.3); padding: 18px 20px 20px;
  transform: translate(-50%, -46%); opacity: 0; transition: transform .25s cubic-bezier(.2,.8,.2,1), opacity .2s; }
.sheet.is-open { transform: translate(-50%, -50%); opacity: 1; }
.sheet:focus { outline: none; }
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(16,24,40,.55); opacity: 0; transition: opacity .2s; }
.sheet-backdrop.is-open { opacity: 1; }
.sheet-handle { display: none; }
.sheet-head { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; }
.sheet-head .who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sheet-head .who > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-head .who b { font-size: 16px; }
.sheet-head .avatar { width: 44px; height: 44px; font-size: 15px; }
.sheet-x { width: 44px; height: 44px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; background: var(--surface-2); color: var(--muted); cursor: pointer; }
.sheet-x:hover { color: var(--ink); background: var(--line); }
.sheet-list { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-top: 1px solid var(--line); }
.sheet-list form { display: contents; }
.sheet-list a, .sheet-list button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 6px 8px;
  border: 0; border-radius: 10px; background: none; color: var(--text-2); font: 600 15px var(--font); text-align: left;
  cursor: pointer; -webkit-tap-highlight-color: transparent; }
.sheet-list a:active, .sheet-list button:active { background: var(--surface-2); color: var(--ink); }
@media (hover: hover) { .sheet-list a:hover, .sheet-list button:hover { background: var(--surface-2); color: var(--ink); } }
.sheet-list .ico { width: 36px; height: 36px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; background: var(--bg); color: var(--muted); }
.sheet-list [aria-current="page"] { color: var(--accent); }
.sheet-list [aria-current="page"] .ico { background: var(--accent-bg); color: var(--accent); }
.sheet-list .logout { color: var(--danger); }
.sheet-list .logout .ico { background: var(--danger-bg); color: var(--danger); }
/* toasts (js/nav.js): the dismiss button shows where messages float; vtrack.toast adds a hint line and actions */
.msg-x { display: none; align-items: center; justify-content: center; width: 40px; height: 40px; margin-left: auto;
  flex-shrink: 0; border: 0; border-radius: 8px; background: none; color: inherit; cursor: pointer; opacity: .8; }
.msg-text { flex: 1; min-width: 0; margin: 0; }
.msg-hint { display: block; font-size: 13px; font-weight: 500; opacity: .85; }
.msg-act { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 10px;
  border: 0; border-radius: 8px; background: none; color: var(--accent); font: 700 14px var(--font); cursor: pointer; }
.msg-act:hover { background: rgba(16,24,40,.06); color: var(--accent-ink); }
.msg.error .msg-act { color: var(--danger); }
.messages .msg.leaving { opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }
/* wider screens, on a page that acts in place (the board): the messages float at the bottom, like on phones */
@media (min-width: 721px) {
  .messages.float { position: fixed; z-index: 40; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%); width: min(560px, calc(100vw - 48px)); margin: 0; pointer-events: none; }
  .messages.float .msg { pointer-events: auto; display: flex; align-items: center; gap: 4px; min-height: 48px; padding: 4px 4px 4px 14px;
    border: 1px solid rgba(16,24,40,.08); box-shadow: 0 8px 24px rgba(16,24,40,.16); animation: toast-in .22s ease-out; }
  .messages.float .msg-x { display: inline-flex; }
}

@media (max-width: 720px) {
  :root { --tabbar-h: 64px; --topbar-h: calc(56px + env(safe-area-inset-top, 0px)); }  /* tab bar: above the safe area,
     4px padding + 58px Scan disc row + border */
  html { scroll-padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px); }
  body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }  /* room for the tab bar */
  .page { padding-bottom: 24px; }
  /* compact top bar: [brand mark] dealer name / page title [account] */
  .topbar { height: var(--topbar-h); gap: 10px;
    padding: env(safe-area-inset-top, 0px) max(8px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); }
  .topbar .nav, .topbar .usermenu, .topbar .brand .product { display: none; }
  .topbar .brand .name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; }  /* hidden from sight, not from screen readers: it names the brand link */
  .topbar .brand .logo { height: 28px; max-width: 40vw; }
  .topbar-id { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.2; }
  .topbar-id > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-id .dealer { font-size: 12px; font-weight: 600; color: var(--subtle); }
  .topbar-id .here { font-size: 16px; font-weight: 700; }
  .me-btn, .back-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex-shrink: 0;
    border: 0; border-radius: 50%; background: none; color: var(--text-2); cursor: pointer; padding: 0; }
  .me-btn .avatar { width: 34px; height: 34px; font-size: 13px; }
  .back-btn { margin-left: -8px; }
  .back-btn:not([hidden]) + .brand { display: none; }  /* in the home-screen app, Back replaces the brand mark */

  .tabbar { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: end; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -2px 10px rgba(16,24,40,.04);
    padding: 4px max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom, 0px) max(4px, env(safe-area-inset-left)); }

  .sheet { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 88vh; max-height: 88dvh; border-radius: 20px 20px 0 0;
    box-shadow: 0 -12px 40px rgba(16,24,40,.2); opacity: 1; transform: translateY(100%);
    padding: 0 max(16px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left)); }
  .sheet.is-open { transform: none; }
  .sheet.is-dragging { transition: none; }
  .sheet-handle { display: block; position: sticky; top: 0; z-index: 1; height: 22px; margin: 0 -16px; background: var(--surface); touch-action: none; }
  .sheet-handle::before { content: ""; position: absolute; left: 50%; top: 8px; width: 40px; height: 5px; margin-left: -20px;
    border-radius: 3px; background: var(--line-2); }
  .sheet-head { touch-action: none; }
  html.sheet-open { overflow: hidden; }

  /* toasts: messages float above the tab bar */
  .messages { position: fixed; z-index: 40; margin: 0; pointer-events: none;
    left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right));
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 28px); }  /* clear of the raised Scan disc */
  .kb-open .messages { bottom: 12px; }
  /* a page with a sticky Save / Print bar (form.html, tesla/settings.html, labels/home.html, labels/design.html): above the bar, so an
     error that stays until closed never covers its button (while typing, the rule above still applies) */
  html:not(.kb-open) body:has(.settings-save, .form-actions, .labels-bar, .sd-actions) .messages {
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 96px); }
  .messages .msg { pointer-events: auto; display: flex; align-items: center; gap: 4px; min-height: 48px; padding: 4px 4px 4px 14px;
    border: 1px solid rgba(16,24,40,.08); box-shadow: 0 8px 24px rgba(16,24,40,.16); animation: toast-in .22s ease-out; }
  .msg-x { display: inline-flex; }
  /* a toast with actions (the board's Undo): text and close on the first row, the actions on a row below */
  .messages .msg:has(.msg-act) { flex-wrap: wrap; padding-bottom: 2px; }
  .msg:has(.msg-act) .msg-text { flex-basis: calc(100% - 48px); padding-top: 6px; }
  .msg:has(.msg-act) .msg-x { order: 1; align-self: flex-start; }
  .msg:has(.msg-act) .msg-act { order: 2; }
  .msg-text + .msg-act { margin-left: -10px; }

  /* bigger fields and touch targets */
  :root { --field-h: 44px; --field-fs: 16px; }  /* used by the form field rule; 16px stops iOS zooming in */
  .btn, .pill, .tabs a { min-height: 44px; }
  .tabs a { display: inline-flex; align-items: center; }
  .check { min-height: 44px; }
  .check input { width: 22px; height: 22px; }
}
/* the phone keyboard is open: the tab bar would sit on top of the field being typed in */
@media (max-width: 720px) and (pointer: coarse) { .kb-open .tabbar { display: none; } }
/* tablets and narrow windows: a tighter desktop header, so the whole top nav fits (it scrolled sideways here) */
@media (min-width: 721px) and (max-width: 960px) {
  .topbar { gap: 14px; padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
  .topbar .brand .product, .usermenu summary .small { display: none; }
  .nav a { padding: 8px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-backdrop, .tab .ico, .messages .msg.leaving { transition: none; }
  .messages .msg { animation: none; }
}

/* ---------- two-factor sign-in */
input.code { height: 54px; text-align: center; font: 700 22px var(--mono); letter-spacing: .2em; }
@media (max-width: 640px) { .auth-card input, .auth-card .btn, .twofactor input, .twofactor .btn { min-height: 44px; } }

/* ---------- phone */
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .settings, .form-grid, .checklist { grid-template-columns: 1fr; }
  .brand .name { max-width: 160px; }
  .subnav { flex-direction: row; overflow-x: auto; scrollbar-width: none; gap: 4px; }
  .subnav::-webkit-scrollbar { display: none; }
  .subnav .h { display: none; }
  .subnav a { white-space: nowrap; flex-shrink: 0; }
  .board { grid-auto-columns: 78vw; scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; }
}
@media (max-width: 640px) {
  .settings .btn, .settings .check { min-height: 44px; }
  .subnav a { display: flex; align-items: center; min-height: 44px; }
  .page { padding: 14px max(14px, env(safe-area-inset-right)) 24px max(14px, env(safe-area-inset-left)); }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hide-sm { display: none; }
  table.data th, table.data td { padding: 9px 10px; }
}
@media print { .topbar, .no-print { display: none !important; } body { background: #fff; padding: 0 !important; } }

/* ---------- dealerships: trial banner (base.html), first steps on an empty board, bulk status on the list */
.trial-banner { margin: 0 0 14px; padding: 8px 14px; border-radius: 10px; background: var(--warn-bg); color: var(--warn);
  font-size: 13px; font-weight: 600; }
.first-run { margin-bottom: 16px; }
.first-steps, .first-import { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bulk-bar { margin-bottom: 10px; gap: 8px; align-items: center; }
.bulk-bar select { width: auto; }
.bulk-col { width: 36px; }
.bulk-col input { width: 18px; height: 18px; }
@media (max-width: 720px) {
  .bulk-bar { display: none; }  /* the table it works with is hidden on phones */
  .first-steps .btn { min-height: 44px; }
}

/* ---------- Terms and Privacy links: account menu, the phone "More" sheet, the sign-in card */
.usermenu .menu-legal { display: flex; gap: 2px; margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); }
.usermenu .menu-legal a { flex: 1; font-size: 13px; color: var(--subtle); }
.sheet-legal, .auth-legal { display: flex; justify-content: center; align-items: center; gap: 2px; margin: 0;
  color: var(--subtle); font-size: 13px; }
.sheet-legal { padding-top: 6px; border-top: 1px solid var(--line); }
.sheet-legal a, .auth-legal a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px;
  color: var(--muted); font-weight: 500; }
.auth-legal a { min-height: 36px; }
@media (max-width: 640px) { .auth-legal a { min-height: 44px; } }
