:root {
  /* Black + orange theme, matched to TyrePro's palette */
  --bg: #141414;
  --panel: #1e1e1e;
  --panel-2: #252525;
  --border: #2e2e2e;
  --text: #f0f0f0;
  --muted: #999999;
  --accent: #ff6b35;
  --accent-dark: #ff8555;
  --good: #2faa57;
  --warn: #d59b2a;
  --bad: #ff4444;
  --row-hover: #232323;
  --cheap: #1c3a26;
  --rc: 8px;            /* control radius — buttons, inputs, toggles, tags */
  --rp: 10px;           /* panel / card radius */
  --focus: 0 0 0 2px rgba(255, 107, 53, 0.35);  /* uniform focus ring */
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: calc(10px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right)) 10px calc(18px + env(safe-area-inset-left));
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 4px;
  font-size: 16px;
  color: var(--text);
}
.brand svg { width: 22px; height: 22px; color: var(--accent); flex-shrink: 0; }
/* The brand is a link to the Apps hub — keep it looking like the logo. */
a.brand, a.brand:hover { text-decoration: none; color: var(--text); }
.login-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  letter-spacing: 6px;
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
}
.login-brand svg { width: 30px; height: 30px; color: var(--accent); flex-shrink: 0; }
.topbar nav { display: flex; gap: 16px; flex: 1; }
.topbar nav a {
  color: var(--muted);
  padding: 6px 12px;
  border-radius: var(--rc);
  transition: background 0.15s ease, color 0.15s ease;
}
.topbar nav a:hover { color: var(--text); text-decoration: none; background: var(--panel-2); }
.topbar nav a.on { color: var(--text); background: var(--panel-2); }
/* Nav icons: hidden on desktop (text-only nav); shown on the mobile tab strip. */
.nav-ico { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: none; flex: 0 0 auto; }

/* Settings dropdown in the nav */
.nav-dropdown { position: relative; display: inline-flex; }
.nav-dropdown-btn {
  color: var(--muted); background: none; border: 0;
  padding: 6px 12px; border-radius: var(--rc);
  gap: 5px; user-select: none; -webkit-user-select: none;
}
.nav-dropdown-btn:hover { color: var(--text); background: var(--panel-2); }
.nav-dropdown-btn.on { color: var(--text); background: var(--panel-2); }
.nav-caret { font-size: 10px; transition: transform 0.15s; }
.nav-dropdown.open .nav-caret { transform: rotate(180deg); }
.nav-dropdown-menu {
  position: absolute; top: calc(100% + 6px); left: 0;
  min-width: 168px; z-index: 20;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 4px; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  display: none; flex-direction: column; gap: 2px;
}
.nav-dropdown.open .nav-dropdown-menu { display: flex; }
.nav-dropdown-menu a {
  color: var(--muted); padding: 8px 12px; border-radius: 6px; white-space: nowrap;
}
.nav-dropdown-menu a:hover { color: var(--text); text-decoration: none; background: var(--panel-2); }
.nav-dropdown-menu a.on { color: var(--text); background: var(--panel-2); }

.shop-switcher {
  font-size: 13px;
  padding: 6px 10px;
  min-width: 120px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.logout-form { margin: 0; }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 6px 10px; }
.link-btn:hover { color: var(--text); }

.page { padding: 16px 18px 80px; max-width: 1400px; margin: 0 auto; }
h1, h2 { margin: 0 0 10px; }
h2 { font-size: 17px; margin-top: 18px; }
.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }
.error { color: var(--bad); }

/* ---------- Uniform controls (inputs, selects, textareas, buttons) ---------- */
input, select, textarea, button {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--rc);
  padding: 8px 12px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }

/* Every button shares one shape; a leading icon/caret aligns the same way. */
button { cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; line-height: 1.25; white-space: nowrap; }
button:focus-visible { outline: none; box-shadow: var(--focus); }
button:not(.primary):not(.danger):not(:disabled):hover { border-color: var(--accent); color: var(--text); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }
button.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
button.danger:hover:not(:disabled) { background: var(--bad); border-color: var(--bad); color: #fff; }
/* "On/active/open" state — one accent look for every toggle in the app. */
button.on, button.open, button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
/* Disabled wins over every variant above (placed last on purpose). */
button:disabled, button.primary:disabled, button.danger:disabled, button.on:disabled {
  background: var(--panel-2); border-color: var(--border); color: var(--muted); cursor: not-allowed; box-shadow: none;
}
label.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }

.search-controls {
  display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap;
}
.search-controls[hidden] { display: none; }
.search-controls #q,
.search-controls #uq,
.search-controls #bq { flex: 1 1 320px; min-width: 200px; font-size: 16px; }
.search-controls select { min-width: 160px; }

/* Square icon-only buttons (hide-cost eye, markup reset) — same height as controls */
.icon-btn { padding: 7px 8px; }
.icon-btn svg { width: 18px; height: 18px; display: block; }
.control-sep { align-self: center; width: 1px; height: 22px; background: var(--border); flex: 0 0 auto; }
#bump-val { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); }
/* Hide the cost (W/GST) column on desktop when the eye is toggled off */
#results.hide-cost thead th:nth-child(7),
#results.hide-cost tbody td:nth-child(7) { display: none; }

#staggered-toggle { color: var(--muted); }  /* active state via universal button.on */

.staggered-controls #front-size, .staggered-controls #rear-size {
  flex: 1 1 200px; min-width: 160px; font-size: 16px;
}
.link-btn-inline {
  background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 6px 4px;
  white-space: nowrap;
}
.link-btn-inline:hover { text-decoration: underline; }

.staggered-results { display: flex; flex-direction: column; gap: 10px; }
.staggered-results[hidden] { display: none; } /* display:flex would override [hidden] */
.pair-card {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--border); border-radius: 8px; background: var(--panel);
  padding: 12px 14px;
}
.pair-card .checkcol { width: auto; padding-top: 2px; }
.pair-card .checkcol input { transform: scale(1.3); }
.pair-card-body { flex: 1; min-width: 0; }
.pair-card-title { font-weight: 600; margin-bottom: 8px; }
.pair-card-row {
  display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap;
  font-size: 14px; padding: 4px 0; border-top: 1px solid var(--border);
}
.pair-card-row:first-of-type { border-top: none; }
.pair-card-row .leg-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; min-width: 42px; }
.pair-card-row .leg-size { font-variant-numeric: tabular-nums; }
.pair-card-row .leg-model { color: var(--muted); font-size: 12.5px; }
.pair-card-row .leg-supplier { color: var(--muted); }
.pair-card-row .leg-price { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Rim design catalog ---------- */
.rim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  /* Vertical drags scroll; horizontal drags are ours to paint selection. */
  touch-action: pan-y;
}
.rim-card img {
  -webkit-user-drag: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.rim-grid .rim-empty { grid-column: 1 / -1; padding: 40px 0; }
.rim-card {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.rim-card:hover { border-color: var(--accent); }
.rim-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.rim-card-imgwrap { position: relative; }
.rim-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--panel-2);
}
/* Selection badge — tap target to start selecting / add-remove a design. */
.rim-check {
  position: absolute; top: 6px; right: 6px;
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid #fff; background: rgba(0, 0, 0, 0.45);
  color: transparent; font-size: 16px; font-weight: 800; line-height: 24px; text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  transition: background 0.12s, color 0.12s;
  cursor: pointer; z-index: 2;
}
/* Invisible enlarged hit area so the tick is easy to tap on the first pick. */
.rim-check::before { content: ''; position: absolute; inset: -14px; }
.rim-card.selected .rim-check { background: var(--accent); border-color: #fff; color: #fff; }
.rim-card figcaption {
  padding: 7px 9px;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--muted);
  word-break: break-word;
}

/* .quote-bar sets display:flex, which would otherwise defeat [hidden]. */
.rim-share-bar[hidden] { display: none; }
.rim-share-bar #rim-share-status { margin-right: auto; }
#rim-lightbox-select { margin: 2px 0; }

/* Mobile: 4 compact designs per row for fast visual browsing; the spec is
   printed on each photo, so the caption is dropped to keep them clean. */
/* "Compact" layout = phones AND touch tablets (iPad): icon tab bar, card rows,
   stacked controls. Desktops/laptops (mouse hover) keep the full table layout.
   Keep in step with COMPACT_MQ in search.js and the query in reservations.ejs. */
@media (max-width: 720px), (hover: none) and (pointer: coarse) and (max-width: 1366px) {
  .rim-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .rim-card figcaption { display: none; }
  /* …but a no-photo card's spec lives in the caption — keep it visible. */
  .rim-card.rim-noimg figcaption { display: block; }
  /* Used rims: photos don't carry the spec, so show the description (2 per row). */
  .rim-grid.rim-grid-used { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .rim-grid-used .rim-card figcaption { display: block; }
  .rim-check { width: 26px; height: 26px; top: 5px; right: 5px; line-height: 22px; font-size: 14px; }
  /* Controls: the New/Used switch gets its own full-width row (bigger tap
     targets), the diameter + bolt-pattern selects pair up beneath it. */
  .rim-controls .rim-type { display: flex; flex: 1 1 100%; }
  .rim-controls .rim-type button { padding-top: 9px; padding-bottom: 9px; font-size: 14px; }
  .rim-controls select { flex: 1 1 calc(50% - 5px); min-width: 0; }
}
@media (max-width: 400px) {
  .rim-check { width: 24px; height: 24px; border-width: 1.5px; line-height: 20px; }
}

.rim-lightbox {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.88);
}
.rim-lightbox[hidden] { display: none; }
.rim-lightbox img {
  max-width: min(92vw, 720px);
  max-height: 72vh;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
}
.rim-lightbox-close {
  position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 16px;
  background: none; border: 0; color: #fff; font-size: 30px; line-height: 1; padding: 0;
  width: 44px; height: 44px; border-radius: var(--rc);
}
.rim-lightbox-close:hover { background: rgba(255, 255, 255, 0.15); color: #fff; border-color: transparent; }
.rim-lightbox-cap {
  display: flex; flex-direction: column; gap: 4px; text-align: center;
  max-width: min(92vw, 720px); color: var(--text); font-size: 13px;
}
.rim-lightbox-cap .muted { font-size: 12px; }

.table-wrap { overflow: visible; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  background: var(--panel);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 56px; z-index: 1;
}
tbody td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: var(--row-hover); }
tbody tr.cheapest td:nth-child(8) { color: var(--good); font-weight: 600; } /* Selling col (col 8 after Qty added) */
tbody tr.cheapest { background: rgba(47, 170, 87, 0.06); }

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
.sort-arrow { display: inline-block; min-width: 12px; margin-left: 4px; color: var(--accent); font-size: 11px; }

.tag {
  display: inline-block;
  padding: 1px 6px;
  margin-left: 4px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  vertical-align: 1px;
}
.tag-old { background: rgba(214, 80, 74, 0.15);  color: var(--bad);  border: 1px solid rgba(214, 80, 74, 0.35); }
.tag-instock { background: rgba(47, 170, 87, 0.18); color: var(--good); border: 1px solid rgba(47, 170, 87, 0.4); }
.tag-reserved { background: rgba(224, 145, 47, 0.20); color: #e0912f; border: 1px solid rgba(224, 145, 47, 0.45); }
.tag-b3f1 { background: rgba(168, 85, 247, 0.22); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.5); }
/* Price-history source badges: AI (accent) vs paste-in (muted) */
.tag-ai    { margin-left: 0; background: rgba(90, 140, 255, 0.18); color: var(--accent); border: 1px solid rgba(90, 140, 255, 0.4); }
.tag-paste { margin-left: 0; background: rgba(153, 153, 153, 0.15); color: var(--muted); border: 1px solid var(--border); }

/* Price-history controls: filter tabs + bulk-delete */
.ph-controls { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.ph-filter { display: inline-flex; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--rc); padding: 3px; gap: 2px; }
.ph-tab { background: none; border: 0; color: var(--muted); padding: 6px 14px; border-radius: 6px; }
.ph-tab:not(.on):hover { color: var(--text); background: var(--row-hover); }  /* active state via universal button.on */
.ph-controls #ph-delete { margin-left: auto; }
/* Own-stock rows pinned at the top of results */
tbody tr.own-stock-row { background: rgba(47, 170, 87, 0.07); }
tbody tr.own-stock-row:hover { background: rgba(47, 170, 87, 0.12); }
tbody tr.own-stock-row td:first-child { box-shadow: inset 3px 0 0 var(--good); }
/* Reserved rows (held for a customer) — amber, overrides the own-stock tint/bar */
tbody tr.reserved-row { background: rgba(224, 145, 47, 0.11); }
tbody tr.reserved-row:hover { background: rgba(224, 145, 47, 0.17); }
tbody tr.reserved-row td:first-child { box-shadow: inset 3px 0 0 #e0912f; }
.size-c  { color: var(--warn); font-weight: 700; margin-left: 1px; }

.quoted-cell { white-space: nowrap; }

/* AL per-outlet stock expander */
.al-toggle {  /* small inline variant of the standard button; hover/open handled universally */
  font-size: 11.5px; color: var(--accent);
  border-radius: var(--rc); padding: 3px 8px; margin-left: 4px;
}
tr.al-outlets-row > td { background: var(--panel-2); padding: 10px 14px; }
.al-outlets { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.al-outlets .alo-title { font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.alo-table { width: auto; border-collapse: collapse; font-variant-numeric: tabular-nums; }  /* compact, not full-width */
/* Every cell centred so each quantity sits directly under its outlet code. */
.alo-table th, .alo-table td {
  border: 1px solid var(--border); padding: 4px 12px; text-align: center; font-size: 12.5px; min-width: 44px;
}
/* The results table restyles thead/tbody/tr for its own mobile card layout
   (thead:none, tbody/tr:block) and desktop sticky header. Those must NOT reach
   this NESTED breakdown table, or its columns stop lining up — restore real
   table display for it. #results prefix beats those mobile/base rules. */
#results .alo-table { display: table; }
#results .alo-table thead { display: table-header-group; }
#results .alo-table tbody { display: table-row-group; }
#results .alo-table tr { display: table-row; }
#results .alo-table th, #results .alo-table td { display: table-cell; }
.alo-table thead th {
  position: static; top: auto; z-index: auto;
  background: var(--panel-2); text-transform: none;
  color: var(--muted); font-weight: 600;
}
.alo-table tbody td { font-weight: 700; }
.alo-table .alo-total { color: var(--accent); }
.alo-years { margin-top: 6px; font-size: 12px; }
.dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.2) inset;
}
.dot.fresh { background: var(--good); }
.dot.warm  { background: var(--warn); }
.dot.cold  { background: var(--bad); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.checkcol { width: 36px; text-align: center; }
.checkcol input { transform: scale(1.2); }

.quote-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 12px calc(18px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) calc(18px + env(safe-area-inset-left));
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
  z-index: 5;
}
/* Flash quote — outlined accent, between Clear and the filled Generate. */
#flash-quote { border-color: var(--accent); color: var(--accent); background: transparent; font-weight: 600; white-space: nowrap; }
#flash-quote:hover:not(:disabled) { background: rgba(255, 107, 53, 0.12); }
#flash-quote:disabled { border-color: var(--border); color: var(--muted); opacity: 0.6; }
/* Phones: three buttons can't share one row — Clear + Flash split the top
   row, Generate (the primary action) takes the full row beneath. */
@media (max-width: 720px) {
  .quote-bar { flex-wrap: wrap; }
  .quote-bar #clear-selection, .quote-bar #flash-quote { flex: 1 1 0; min-width: 0; }
  .quote-bar #generate { flex: 1 1 100%; }
}

dialog#quote-dialog, dialog.q-dialog {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 0;
  width: min(680px, 92vw);
}
dialog#quote-dialog::backdrop, dialog.q-dialog::backdrop { background: rgba(0,0,0,0.6); }
.dialog-head { display: flex; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { margin: 0; flex: 1; }
.close-btn { background: none; border: 0; color: var(--muted); font-size: 22px; line-height: 1; width: 32px; height: 32px; padding: 0; border-radius: var(--rc); }
.close-btn:hover { background: var(--panel-2); color: var(--text); border-color: transparent; }
#quote-text, #used-text, #batt-text { display: block; width: calc(100% - 32px); margin: 14px 16px; resize: vertical; font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- Used tyres list ---------- */
.used-list { border: 1px solid var(--border); border-radius: 8px; background: var(--panel); overflow: hidden; }
.used-list .used-empty { padding: 40px 0; }
.used-card { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.used-card:last-child { border-bottom: none; }
.used-card:hover { background: var(--row-hover); }
.used-card.reserved-row { background: rgba(224, 145, 47, 0.11); box-shadow: inset 3px 0 0 #e0912f; }
.used-card.reserved-row:hover { background: rgba(224, 145, 47, 0.17); }
.used-check { flex: 0 0 auto; transform: scale(1.25); }
.uc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.uc-line1 { display: flex; align-items: baseline; gap: 10px; }
.uc-name { flex: 1; min-width: 0; font-size: 14px; line-height: 1.35; }
.uc-size { color: var(--muted); font-variant-numeric: tabular-nums; margin: 0 3px; }
.uc-qty { flex: 0 0 auto; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.uc-years { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.uc-years .uy-qty { opacity: 0.65; }
/* Small "T" beside a year that came in as a trade-in */
.uc-years .ut {
  display: inline-block; font-size: 9px; font-weight: 800; line-height: 1;
  color: var(--warn); border: 1px solid rgba(213,155,42,0.5); border-radius: 3px;
  padding: 1px 3px; margin-left: 2px; vertical-align: 1px;
}
.tag-four    { background: rgba(47,170,87,0.18);   color: var(--good); border: 1px solid rgba(47,170,87,0.4); }
.dialog-foot { display: flex; align-items: center; gap: 10px; padding: 0 16px 16px; }

.entry-step { margin-bottom: 22px; }
/* Short review table doesn't need a sticky header — kill it so the
   overflow-x:auto wrap doesn't trap position:sticky and leave a ghost band. */
#parsed-table thead th { position: static; top: auto; }
.entry-step textarea { width: 100%; resize: vertical; font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.entry-step > div { margin-top: 10px; display: flex; gap: 10px; align-items: center; }
.row-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.row-form input, .row-form select { min-width: 140px; }

.login-body { display: grid; place-items: center; min-height: 100vh; background: var(--bg); }
.login-card { background: var(--panel); padding: 28px 28px 22px; border-radius: 12px; border: 1px solid var(--border); width: 320px; display: flex; flex-direction: column; gap: 10px; }
.login-card h1 { font-size: 20px; }
.login-card input, .login-card button { font-size: 15px; padding: 10px 12px; }

@media (max-width: 720px), (hover: none) and (pointer: coarse) and (max-width: 1366px) {
  /* Mobile app feel: row 1 = brand + shop switcher + logout; row 2 = an even
     icon+label tab strip. */
  .topbar {
    flex-wrap: wrap;
    row-gap: 10px;
    gap: 10px;
    padding: calc(10px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) 10px calc(14px + env(safe-area-inset-left));
  }
  .topbar .brand { order: 1; flex: 1 1 auto; letter-spacing: 2.5px; font-size: 15px; }
  .topbar .brand svg { width: 20px; height: 20px; }
  .shop-switcher { order: 2; flex: 0 1 auto; font-size: 12px; padding: 7px 10px; min-width: 0; border-radius: 8px; }
  .logout-form { order: 3; }
  .logout-form .link-btn { padding: 7px 6px; font-size: 13px; }
  .topbar nav {
    order: 4;
    flex: 1 1 100%;
    gap: 2px;
    flex-wrap: nowrap;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 4px;
  }
  /* Each tab: icon stacked over a small label, evenly sized. */
  .topbar nav a,
  .nav-dropdown-btn {
    flex: 1 1 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px;
    padding: 7px 2px 6px;
    border-radius: 9px;
    white-space: nowrap;
    color: var(--muted);
  }
  .topbar nav .nav-ico { display: block; width: 22px; height: 22px; }
  .topbar nav .nav-lbl { font-size: 10px; letter-spacing: 0.2px; line-height: 1; }
  .topbar nav .nav-caret { display: none; }           /* icon implies the menu */
  .topbar nav a.on,
  .nav-dropdown-btn.on {
    background: var(--accent); color: #fff;
    box-shadow: 0 2px 8px rgba(224, 108, 47, 0.35);
  }
  .topbar nav a.on .nav-ico { stroke-width: 2; }
  .topbar nav .nav-dropdown { flex: 1 1 0; }
  .nav-dropdown-menu { left: auto; right: 0; top: calc(100% + 8px); min-width: 180px; }
  .page { padding: 14px calc(12px + env(safe-area-inset-right)) calc(90px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left)); }
  /* Used tyres / batteries: search bar spans the row; the count is noise on mobile. */
  .search-controls #uq,
  .search-controls #bq { flex: 1 1 100%; }
  #ucount, #bcount { display: none; }
  /* Results: too many columns for a phone table, so render each row as a
     compact two-line card (see rowHtml() in search.js) — no sideways scroll. */
  .table-wrap { overflow: hidden; }
  #results thead { display: none; }
  #results, #results tbody, #results tr { display: block; }
  #results tr { border-bottom: 1px solid var(--border); }
  #results tr:last-child { border-bottom: none; }
  #results td.rc-cell { display: block; padding: 0; border: none; }
  .row-card { display: flex; align-items: center; gap: 11px; padding: 11px 12px; cursor: pointer; }
  .row-card .row-check { flex: 0 0 auto; transform: scale(1.25); margin: 0; }
  .rc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
  .rc-line1 { display: flex; align-items: baseline; gap: 10px; }
  .rc-name { flex: 1; min-width: 0; font-size: 14px; line-height: 1.3; }
  .rc-price { flex: 0 0 auto; font-weight: 700; font-size: 15.5px; font-variant-numeric: tabular-nums; }
  /* Meta on the left, the outlets chip on the right of the SAME line (sitting
     under the price) — so an AL row is the same height as a non-AL row. Meta
     stays one line (ellipsis) so the chip can't push it into a second line. */
  .rc-line2 { display: flex; align-items: center; gap: 10px; }
  .rc-line2 .rc-meta { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .rc-line2 .al-toggle { flex: 0 0 auto; margin-left: 0; }
  .rc-price.rc-cheap { color: var(--good); }
  .rc-meta { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
  .rc-meta .dot { width: 7px; height: 7px; margin-right: 5px; }
  /* Own-stock accent on the card */
  #results tr.own-stock-row { background: rgba(47, 170, 87, 0.07); }
  #results tr.own-stock-row .row-card { box-shadow: inset 3px 0 0 var(--good); }
  #results tr.reserved-row { background: rgba(224, 145, 47, 0.11); }
  #results tr.reserved-row .row-card { box-shadow: inset 3px 0 0 #e0912f; }
  /* Tags sit inline in the name; keep them from stretching the line height */
  .rc-name .tag { vertical-align: 1px; }
  /* AL outlet detail: block cell, indented so its title + table line up under
     the card's model name (past the checkbox), and a tight table that still
     fits the phone width (overflow-x scrolls if it ever doesn't). */
  #results tr.al-outlets-row { display: block; }
  #results tr.al-outlets-row > td { display: block; padding: 4px 12px 12px 36px; }
  .alo-table th, .alo-table td { padding: 3px 6px; min-width: 32px; }
}

@media (max-width: 380px) {
  .topbar nav .nav-lbl { font-size: 9px; }
  .topbar nav .nav-ico { width: 20px; height: 20px; }
  .topbar nav a, .nav-dropdown-btn { padding: 6px 1px 5px; }
}

/* ---------- Stock Insights ---------- */
.ins-h { margin: 22px 0 2px; font-size: 16px; }
.ins-sub { margin: 0 0 8px; }
.ins-table td a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
#ins-msg { margin: 8px 0 12px; }
/* Short tables — no sticky header (it ghosts over rows inside .table-wrap on mobile). */
.ins-table thead th { position: static; top: auto; }
.ins-table td, .ins-table th { padding: 10px 8px; }

/* ---------- Other shop's shelf strip ("At Pitstop: …") ---------- */
.other-shop { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin: 0 0 10px; padding: 8px 10px;
  border: 1px solid rgba(56, 132, 230, 0.35); background: rgba(56, 132, 230, 0.08); border-radius: 8px; font-size: 13px; }
.other-shop .os-label { color: #6aa8f0; font-weight: 700; margin-right: 2px; }
.os-list { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.os-chip { display: block; padding: 4px 8px; border-radius: 6px; background: var(--panel); border: 1px solid var(--border); }
.os-more { background: none; border: 1px solid rgba(56, 132, 230, 0.45); color: #6aa8f0; border-radius: 6px; padding: 4px 12px; font-size: 12px; font-weight: 600; cursor: pointer; }
.tag-othershop { background: rgba(56, 132, 230, 0.16); color: #6aa8f0; border: 1px solid rgba(56, 132, 230, 0.45); }

/* ---------- Used tyres: alternative sizes ---------- */
.used-alts { border-top: 2px solid rgba(56, 132, 230, 0.45); background: rgba(56, 132, 230, 0.05); }
.ua-title { padding: 10px 14px 6px; font-weight: 700; color: #6aa8f0; font-size: 14px; }
.ua-title .muted { font-weight: 400; font-size: 12px; }
.ua-note { margin: 0 14px 8px; padding: 6px 10px; border-radius: 6px; font-size: 12px; font-weight: 600;
  color: #e0912f; background: rgba(224, 145, 47, 0.12); border: 1px solid rgba(224, 145, 47, 0.4); }
.ua-head { display: flex; align-items: baseline; gap: 10px; padding: 8px 14px 6px; border-top: 1px solid var(--border); }
.ua-size { font-weight: 700; font-variant-numeric: tabular-nums; }
.ua-diff { color: var(--muted); font-size: 12px; }
.used-alts .used-card:last-child { border-bottom: none; }

/* ---------- Tyre spec filter (dropdown beside the supplier filter) ---------- */
#spec-filter.on { border-color: var(--accent); color: var(--accent); }
@media (max-width: 720px), (hover: none) and (pointer: coarse) and (max-width: 1366px) {
  /* Supplier + spec dropdowns share one row on phones. */
  .search-controls #supplier-filter,
  .search-controls #spec-filter { flex: 1 1 calc(50% - 5px); min-width: 0; }
}
/* display:flex above would otherwise override the [hidden] attribute */
.other-shop[hidden] { display: none; }
/* batchList "Show more" marker inside the rims grid spans the full row */
.rim-grid > .more-row { grid-column: 1 / -1; padding: 12px 0; }
.used-list > .more-row { padding: 12px 0; }

/* Touch tablets (iPad) in the compact layout: keep the content a comfortable
   reading width, centred, instead of stretching cards edge to edge. */
@media (hover: none) and (pointer: coarse) and (min-width: 721px) and (max-width: 1366px) {
  /* Search box on its own row (as on phones); dropdowns share the next row. */
  .search-controls #q { flex: 1 1 100%; }
  /* Slightly larger tab icons/labels for the bigger screen. */
  .topbar nav .nav-ico { width: 24px; height: 24px; }
  .topbar nav .nav-lbl { font-size: 12px; }
  .topbar, .page, .quote-bar {
    padding-left: max(calc(16px + env(safe-area-inset-left)), calc((100vw - 880px) / 2));
    padding-right: max(calc(16px + env(safe-area-inset-right)), calc((100vw - 880px) / 2));
  }
}

/* ---------- Ex-stock discount ---------- */
.tag-exstock { background: rgba(214, 80, 74, 0.18); color: #ff7a6e; border: 1px solid rgba(214, 80, 74, 0.5); }
.tag-consign { background: rgba(38, 178, 196, 0.16); color: #4fd6e6; border: 1px solid rgba(38, 178, 196, 0.5); }
.was-price { color: var(--muted); font-weight: 400; font-size: 0.8em; margin-right: 2px; }
.xs-msg { margin: 0 0 12px; padding: 8px 12px; border-radius: 8px; font-size: 13px;
  color: #e0912f; background: rgba(224, 145, 47, 0.12); border: 1px solid rgba(224, 145, 47, 0.4); }
.xs-list { max-width: 640px; }
.xs-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.xs-row:last-child { border-bottom: none; }
.xs-field { display: inline-flex; align-items: center; gap: 8px; }
.xs-field input { width: 72px; text-align: right; font-size: 16px; }
.xs-made { flex: 1 1 auto; }
.xs-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; }

/* ---------- Used staggered: recommendations ---------- */
.rec-wrap { display: flex; flex-direction: column; gap: 10px; }
.rec-intro { margin: 4px 0 0; }
.rec-h { font-weight: 700; font-size: 14px; color: #6aa8f0; margin: 6px 0 0; }
.rec-h .muted { font-weight: 400; font-size: 12px; }
.rec-h-top { margin-top: 10px; }
.rec-side { display: flex; flex-direction: column; gap: 6px; }
.rec-alt { color: #e0912f; }
.rec-none { margin: 2px 0 6px; }

/* ---------- Supplier sync warning ---------- */
.sync-warn { margin: 0 0 12px; padding: 10px 14px; border-radius: 8px; font-size: 13px;
  color: #f0b45e; background: rgba(224, 145, 47, 0.12); border: 1px solid rgba(224, 145, 47, 0.45); }
.sync-warn[hidden] { display: none; }
.sync-warn .sw-head { font-weight: 700; margin-bottom: 4px; }
.sync-warn ul { margin: 0 0 2px; padding-left: 18px; color: var(--text); }
.sync-warn li { margin: 2px 0; }
.sync-warn .sw-hide { padding: 2px 0; font-size: 12px; color: #f0b45e; }

/* ---------- Promotions (Settings → Promotions) ---------- */
.pr-list { max-width: 760px; display: flex; flex-direction: column; gap: 12px; }
.pr-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: var(--panel, transparent); }
.pr-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }
.pr-name { font-size: 16px; }
.pr-head .tag { margin-left: 0; }
.pr-status { margin-left: auto; font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor; }
.pr-live { color: #3ecf6e; }
.pr-sched { color: #e0b341; }
.pr-ended, .pr-off { color: var(--muted, #888); }
.pr-line { margin: 3px 0; font-size: 14px; line-height: 1.4; }
.pr-btns { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; }
.pr-err { color: var(--bad); font-size: 13px; }
.pr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 14px; margin-bottom: 10px; }
.pr-f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.pr-f input, .pr-f select { font-size: 16px; width: 100%; box-sizing: border-box; }
.pr-wide { grid-column: 1 / -1; }
.pr-chk-f { justify-content: flex-end; }
.pr-set { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px 10px; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.pr-set[hidden] { display: none; }
.pr-set legend { font-size: 13px; padding: 0 4px; }
.pr-chk { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; cursor: pointer; }
.pr-chk input { width: 18px; height: 18px; }
.pr-tiers-h { font-size: 13px; margin: 4px 0 6px; }
.pr-tiers { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.pr-tier { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; }
.pr-tier input { width: 58px; text-align: right; font-size: 16px; }
.pr-unit { color: var(--muted, #888); }
.pr-tier-del { padding: 6px 10px; margin-left: 2px; }

/* In-stock WebMax rim tag (Rims catalog) */
.rim-stock { position: absolute; left: 6px; bottom: 6px; max-width: calc(100% - 12px); box-sizing: border-box;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 10px; line-height: 1.25; font-weight: 700; letter-spacing: .02em;
  padding: 2px 6px; border-radius: 6px; background: rgba(20, 120, 60, 0.92); color: #fff; pointer-events: none; }

/* New Tyres: Qty sort button (ready stock by shelf quantity). Outlined, not
   filled, when on — it's a view setting, so it shouldn't shout like a toggle. */
.qty-sort { gap: 4px; }
.qty-sort .sort-arrow { font-size: 14px; }
button.qty-sort[aria-pressed="true"] { background: transparent; border-color: var(--accent); color: var(--accent); }

/* Rims: New / Used segmented switch — recessed pill track with a gliding
   orange thumb (iOS-style). The thumb is the track's ::before, sized to one
   half and slid by data-active on the container (set in rims.js). */
.rim-type {
  position: relative; display: inline-flex; padding: 4px; flex: 0 0 auto;
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.45);
}
.rim-type::before {
  content: ''; position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px);
  border-radius: 999px; background: linear-gradient(180deg, var(--accent-dark), var(--accent));
  box-shadow: 0 1px 6px rgba(255, 107, 53, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transition: transform 0.22s cubic-bezier(0.33, 1, 0.5, 1);
}
.rim-type[data-active="used"]::before { transform: translateX(100%); }
.rim-type button {
  position: relative; z-index: 1; flex: 1 1 0; min-width: 108px;
  border: 0; background: none; padding: 7px 18px; border-radius: 999px;
  color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: 0.02em;
  white-space: nowrap; transition: color 0.18s ease;
}
.rim-type button:not([aria-pressed="true"]):hover { color: var(--text); background: none; }
.rim-type button[aria-pressed="true"] { color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }
.rim-type button:focus-visible { outline: none; box-shadow: var(--focus); }
.rim-used { position: absolute; left: 6px; top: 6px; max-width: calc(100% - 44px); box-sizing: border-box; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; font-size: 10px; line-height: 1.25; font-weight: 700; letter-spacing: .02em;
  padding: 2px 6px; border-radius: 6px; color: #fff; pointer-events: none; background: rgba(120, 90, 30, 0.92); }
.rim-used-tr { background: rgba(140, 95, 20, 0.92); }
.rim-used-cr { background: rgba(40, 90, 160, 0.92); }
.rim-used-csr { background: rgba(30, 130, 145, 0.92); }
.rim-noimg { cursor: default; opacity: .85; }
.rim-noimg:hover { border-color: var(--border); }
.rim-noimg-box { aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; color: var(--muted, #888);
  font-size: 12px; background: var(--panel-2, #252525); }
