:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --ink: #1d1d1f;
  --ink-2: #6e6e73;
  --ink-3: #86868b;
  --line: #e3e3e6;
  --line-2: #ececee;
  --accent: #e8322f;
  --accent-ink: #ffffff;
  --accent-soft: #fdeceb;
  --green: #1a9e57;
  --amber: #b8860b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04), 0 1px 3px rgba(0, 0, 0, .06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .08), 0 1px 4px rgba(0, 0, 0, .04);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .12);
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2 { letter-spacing: -.02em; }
.hidden { display: none !important; }

/* ───────── Top bar ───────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 22px;
  background: rgba(245, 245, 247, .8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logos { display: inline-flex; align-items: center; }
.brand-logo { height: 24px; width: auto; display: block; }
.brand-logo-mmx { height: 20px; } /* MMX is heavier-weight; slightly smaller reads as matched */
.logo-sep { width: 1px; height: 18px; background: var(--line); margin: 0 12px; }
.brand-divider { width: 1px; height: 20px; background: var(--line); }
.brand-sub { color: var(--ink-2); font-weight: 500; font-size: 15px; }
.userbar { display: flex; align-items: center; gap: 14px; }
.nav { display: flex; gap: 2px; }
.nav-link {
  background: none; border: 0; font: inherit; font-weight: 600; font-size: 14px;
  color: var(--ink-3); cursor: pointer; padding: 6px 12px; border-radius: 8px;
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--ink); }
.nav-link.active { color: var(--ink); background: rgba(0, 0, 0, .05); }
.who { color: var(--ink-2); font-size: 14px; }

/* ───────── Buttons / inputs ───────── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: 980px; padding: 11px 22px;
  font: inherit; font-weight: 600; cursor: pointer;
  transition: transform .12s var(--ease), background .2s var(--ease), opacity .2s;
}
.btn-primary:hover { background: #d12b28; }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-primary.is-busy { pointer-events: none; }
/* Submit-order button in MMX blue */
#submit { background: #4A8AC9; }
#submit:hover { background: #3f79b0; }
.btn-block { width: 100%; }
.order-terms { font-size: 12.5px; line-height: 1.45; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; margin: 0 0 12px; }
.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 980px; padding: 10px 22px;
  font: inherit; font-weight: 600; cursor: pointer; margin-top: 8px;
  transition: background .15s, border-color .15s;
}
.btn-secondary:hover { background: var(--surface-2); }

.btn-ghost {
  background: none; border: 0; color: var(--ink-2);
  font: inherit; font-weight: 500; cursor: pointer; padding: 6px 8px; border-radius: 8px;
  transition: color .15s, background .15s;
}
.btn-ghost:hover { color: var(--ink); background: rgba(0, 0, 0, .04); }

input, textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 11px 13px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }
textarea { resize: vertical; min-height: 44px; }

/* Drop-ship address in the order panel */
.dropship-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; margin: 2px 0 10px; }
.dropship-toggle input { width: auto; margin: 0; cursor: pointer; }
.dropship-fields { display: grid; gap: 6px; margin-bottom: 12px; }
.dropship-fields input { padding: 9px 12px; }

.field { display: block; text-align: left; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 0 0 6px 2px; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ───────── Views ───────── */
.view { animation: fade .35s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ───────── Login ───────── */
.login-view {
  min-height: calc(100vh - 56px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; gap: 20px;
}
.login-card {
  width: 100%; max-width: 400px; text-align: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-md);
  padding: 40px 34px;
}
.login-card h1 { margin: 0 0 8px; font-size: 27px; }
.sub { color: var(--ink-2); margin: 0 0 24px; }
.login-card form { display: flex; flex-direction: column; gap: 16px; }
.form-msg { min-height: 20px; font-size: 13.5px; margin: 14px 0 0; }
.form-msg.ok { color: var(--green); }
.form-msg.err { color: var(--accent); }
.hint { color: var(--ink-3); font-size: 13px; margin: 16px 0 20px; }
.pw-sep { position: relative; text-align: center; margin: 22px 0 16px; }
.pw-sep::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--line); }
.pw-sep span { position: relative; background: var(--surface); padding: 0 12px; color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
#pw-login .field { margin-bottom: 12px; }
.legal { color: var(--ink-3); font-size: 12px; }

.sent-icon {
  width: 64px; height: 64px; margin: 0 auto 20px;
  display: grid; place-items: center; font-size: 28px;
  background: var(--accent-soft); color: var(--accent); border-radius: 50%;
  animation: pop .4s var(--ease);
}
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }

/* ───────── App layout ───────── */
#app { max-width: 1240px; margin: 0 auto; padding: 24px 22px 60px; }
.app-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) 356px; gap: 24px;
  align-items: start;
}
/* View-only logins have no basket panel. Keep the catalogue at its normal
   width (rather than stretching edge-to-edge) and centre it on the page. */
.app-grid.view-only { grid-template-columns: minmax(0, 820px); justify-content: center; }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.search-wrap { position: relative; flex: 1; }
.search-icon {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--ink-3); font-size: 17px; pointer-events: none;
}
.search-wrap input { padding-left: 38px; padding-right: 36px; height: 44px; border-radius: 12px; }
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border: 0; border-radius: 50%;
  background: var(--line); color: var(--ink-2); cursor: pointer; font-size: 11px;
  display: grid; place-items: center;
}
.search-clear:hover { background: #d8d8dc; }
.result-count { color: var(--ink-3); font-size: 13.5px; white-space: nowrap; }
.download-btn {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  text-decoration: none; font-size: 13.5px; font-weight: 600; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  padding: 9px 14px; border-radius: 980px; transition: background .15s, border-color .15s;
}
.download-btn:hover { background: var(--surface-2); border-color: #d8d8dc; }
.download-btn span { color: var(--accent); font-size: 15px; }

/* Brand toggle (catalogue) */
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.brand-bar { display: inline-flex; gap: 2px; background: var(--line-2); border-radius: 980px; padding: 3px; }
.cat-toggles { display: flex; align-items: center; gap: 16px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.cost-toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.cost-toggle input { width: auto; margin: 0; cursor: pointer; }
.brand-link { border: 0; background: none; font: inherit; font-weight: 600; font-size: 13.5px; color: var(--ink-2); padding: 7px 18px; border-radius: 980px; cursor: pointer; transition: background .15s, color .15s; }
.brand-link.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* Brand access segment (admin dealer card) */
.dc-brands { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.dc-order-toggle { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.dc-order-toggle input { width: auto; margin: 0; cursor: pointer; }
.dc-viewonly { font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: #2f6fed; background: rgba(47,111,237,.1); padding: 2px 8px; border-radius: 980px; }
.dc-usa-badge { font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: #1a9e57; background: rgba(26,158,87,.1); padding: 2px 8px; border-radius: 980px; }
.dc-brands-label { color: var(--ink-3); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.brand-seg { display: inline-flex; gap: 2px; background: var(--line-2); border-radius: 980px; padding: 3px; }
.brand-seg button { border: 0; background: none; font: inherit; font-weight: 600; font-size: 12.5px; color: var(--ink-2); padding: 5px 12px; border-radius: 980px; cursor: pointer; }
.brand-seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* Category filter chips */
.category-bar {
  display: flex; gap: 8px; margin-bottom: 14px;
  overflow-x: auto; padding-bottom: 2px; scrollbar-width: none;
  /* Fade the right edge to hint there are more categories to scroll to. */
  -webkit-mask-image: linear-gradient(to right, #000 92%, transparent);
  mask-image: linear-gradient(to right, #000 92%, transparent);
}
.category-bar::-webkit-scrollbar { display: none; }
.category-bar:empty { display: none; }
.catalogue-controls { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.ctrl-spacer { flex: 1 1 auto; }
.ctrl-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.ctrl-toggle input { width: auto; margin: 0; cursor: pointer; }
.ctrl-select { width: auto; padding: 7px 12px; font-size: 13px; font-weight: 600; color: var(--ink-2); border-radius: 10px; background: var(--surface); border: 1px solid var(--line); cursor: pointer; }
.admin-order-filter { display: inline-flex; gap: 2px; background: var(--line-2); border-radius: 980px; padding: 3px; margin-bottom: 14px; }
.ao-filter { border: 0; background: none; font: inherit; font-weight: 600; font-size: 13px; color: var(--ink-2); padding: 6px 16px; border-radius: 980px; cursor: pointer; }
.ao-filter.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.chip {
  flex: none; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600;
  white-space: nowrap; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line);
  padding: 7px 14px; border-radius: 980px;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Stock panel */
.stock-panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--shadow-sm); overflow: hidden;
}
/* Fixed layout so long real-world part codes/names can't blow the table wider
   than its panel (which would clip the Price/Add columns under overflow:hidden). */
table.stock { width: 100%; border-collapse: collapse; table-layout: fixed; }
.stock thead th:nth-child(2) { width: 172px; }  /* Stock (fits "Assembled to order") */
.stock thead th:nth-child(3) { width: 118px; }  /* Price */
.stock thead th:nth-child(4) { width: 78px; }   /* Add */
.stock .stock-cell { white-space: nowrap; }
.stock td.price { white-space: nowrap; }
.stock .name { overflow-wrap: anywhere; }
.item-cell { display: flex; align-items: center; gap: 12px; }
.item-text { min-width: 0; }
.stock-thumb { width: 46px; height: 46px; object-fit: contain; border-radius: 8px; background: #fff; border: 1px solid var(--line-2); flex: none; cursor: zoom-in; padding: 2px; }
.img-lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.72); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 24px; cursor: zoom-out; }
.img-lightbox-inner { background: #fff; border-radius: 14px; padding: 16px; max-width: 90vw; max-height: 90vh; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.img-lightbox-inner img { max-width: min(520px, 80vw); max-height: 70vh; object-fit: contain; }
.img-lightbox-name { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink); text-align: center; }
.submeta { color: var(--ink-3); font-size: 12.5px; margin-top: 3px; }
.stock thead th {
  text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .02em;
  text-transform: uppercase; color: var(--ink-3);
  padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.stock th.num, .stock td.num { text-align: right; }
.stock th.act, .stock td.act { text-align: right; width: 96px; }
.stock tbody td { padding: 13px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.stock tbody tr:last-child td { border-bottom: 0; }
.stock tbody tr { transition: background .12s; }
.stock tbody tr:hover { background: var(--surface-2); }
.code { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 12.5px; white-space: nowrap; }
.name { font-weight: 500; }
.new-tag { display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .04em; color: #fff; background: #2f6fed; padding: 2px 6px; border-radius: 5px; margin-right: 7px; vertical-align: 1px; }
.cat { color: var(--ink-3); font-size: 13px; }
.price { font-variant-numeric: tabular-nums; font-weight: 600; line-height: 1.25; }
.rrp { display: block; font-size: 11px; font-weight: 500; color: var(--ink-3); }
.lbl-na { color: var(--ink-3); font-size: 12px; }

.stock-badge { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; font-weight: 500; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.in { background: var(--green); }
.dot.low { background: var(--amber); }
.dot.out { background: var(--ink-3); }
.dot.assembled { background: #2f6fed; }
.stock-badge.out { color: var(--ink-3); }
.stock-badge.low { color: var(--amber); }
.stock-badge.assembled { color: #2f6fed; }
.lbl-low { color: var(--amber); font-size: 12px; }

.add-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--accent);
  font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer;
  padding: 7px 15px; border-radius: 980px;
  transition: background .15s, border-color .15s, transform .1s;
}
.add-btn:hover { background: var(--accent-soft); border-color: var(--accent-soft); }
.add-btn:active { transform: scale(.95); }
/* MMX products get a blue Add button */
.add-btn.mmx { color: #4A8AC9; border-color: #4A8AC9; }
.add-btn.mmx:hover { background: rgba(74, 138, 201, .1); border-color: rgba(74, 138, 201, .1); }

/* Skeleton */
.skeleton-row { display: flex; gap: 16px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.sk { height: 14px; border-radius: 6px; background: linear-gradient(90deg, #ececee 25%, #f5f5f7 50%, #ececee 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Empty / error states */
.state { text-align: center; padding: 64px 24px; }
.state-emoji { font-size: 34px; margin-bottom: 12px; }
.state h3 { margin: 0 0 6px; font-size: 17px; }
.state p { color: var(--ink-2); margin: 0 0 18px; }

/* ───────── Order / basket ───────── */
.order {
  position: sticky; top: 80px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--shadow-sm); overflow: hidden;
  display: flex; flex-direction: column; max-height: calc(100vh - 104px);
}
.order-head { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 0; }
.order-head h2 { margin: 0; font-size: 18px; }
.pill {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 980px;
  background: var(--accent); color: #fff; font-size: 12.5px; font-weight: 600;
  display: inline-grid; place-items: center;
}
.order-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px 18px; }
.order-empty { text-align: center; color: var(--ink-3); padding: 26px 8px; }
.order-empty .state-emoji { font-size: 28px; margin-bottom: 8px; }

.bline { display: flex; align-items: flex-start; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line-2); animation: fade .25s var(--ease); }
.bline:first-child { padding-top: 2px; }
.bline:last-child { border-bottom: 0; }
.bline-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.bline-thumb { display: none; width: 40px; height: 40px; object-fit: contain; border-radius: 8px; border: 1px solid var(--line-2); background: #fff; flex: none; cursor: zoom-in; padding: 2px; }
.bline-thumb.loaded { display: block; }
.bline-r1 { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.bline-name { font-weight: 500; }
.bline-code { color: var(--ink-3); font-size: 12.5px; }
.bline-total { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bline-ctl { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 980px; overflow: hidden; }
.stepper button { width: 26px; height: 26px; border: 0; background: var(--surface); color: var(--ink); font-size: 15px; cursor: pointer; transition: background .12s; }
.stepper button:hover { background: var(--line-2); }
.stepper input { width: 38px; height: 26px; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); border-radius: 0; text-align: center; padding: 0; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.stepper input:focus { box-shadow: none; }
.bline-x { background: none; border: 0; color: var(--ink-3); cursor: pointer; font-size: 13px; padding: 4px; border-radius: 6px; }
.bline-x:hover { color: var(--accent); }

.order-foot { flex: 0 0 auto; padding: 4px 18px 18px; border-top: 1px solid var(--line-2); }
.total-row { display: flex; align-items: baseline; justify-content: space-between; padding: 14px 0 2px; }
.total-row strong { font-size: 21px; font-variant-numeric: tabular-nums; }
.total-note { color: var(--ink-3); font-size: 12px; margin: 0 0 14px; }
.order-foot textarea { margin-bottom: 12px; }

/* Success state */
.success { text-align: center; padding: 24px 10px 12px; animation: fade .3s var(--ease); }
.success-check { width: 60px; height: 60px; margin: 0 auto 16px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; font-size: 30px; animation: pop .4s var(--ease); }
.success h3 { margin: 0 0 6px; font-size: 19px; }
.success .ref { font-variant-numeric: tabular-nums; font-weight: 600; }
.success p { color: var(--ink-2); margin: 0 0 20px; }

/* ───────── Previous orders ───────── */
.orders-view { max-width: 780px; margin: 0 auto; }
.orders-title { font-size: 22px; margin: 4px 0 20px; }
.order-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--shadow-sm);
  padding: 16px 18px; margin-bottom: 14px;
}
.oc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.oc-ref { font-weight: 700; font-variant-numeric: tabular-nums; }
.oc-date { color: var(--ink-3); font-size: 13px; }
.oc-total { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 17px; }
.oc-meta { color: var(--ink-2); font-size: 13.5px; margin: 6px 0 0; }
.oc-lines { list-style: none; margin: 12px 0 0; padding: 12px 0 0; border-top: 1px solid var(--line-2); }
.oc-lines li { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 14px; }
.oc-lines .q { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.oc-lines .lt { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.oc-actions { margin-top: 14px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.oc-admin-actions { display: flex; gap: 8px; align-items: center; }
.oc-notify { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; white-space: nowrap; margin-right: 2px; }
.oc-notify input { width: auto; margin: 0; cursor: pointer; }
.oc-complete { background: var(--green); color: #fff; border: 0; border-radius: 980px; font: inherit; font-weight: 600; font-size: 13px; padding: 7px 14px; cursor: pointer; }
.oc-complete:hover { filter: brightness(.95); }
.oc-delete { background: none; color: var(--accent); border: 1px solid var(--line); border-radius: 980px; font: inherit; font-weight: 600; font-size: 13px; padding: 7px 14px; cursor: pointer; }
.oc-delete:hover { background: var(--accent-soft); border-color: var(--accent-soft); }
.oc-done { display: inline-block; font-size: 11px; font-weight: 700; color: var(--green); background: rgba(26,158,87,.12); padding: 3px 9px; border-radius: 980px; margin-left: 4px; }
.oc-status { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 980px; margin-left: 6px; vertical-align: 1px; }
.oc-status.done { color: var(--green); background: rgba(26,158,87,.12); }
.oc-status.new { color: #2f6fed; background: rgba(47,111,237,.1); }
.oc-tracking { margin: 8px 0 0; font-size: 13.5px; color: var(--ink); }
.oc-tracking strong { font-variant-numeric: tabular-nums; }
.oc-track { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.oc-track-input { flex: 1; min-width: 180px; padding: 8px 12px; }
.oc-track-save { background: none; color: var(--ink); border: 1px solid var(--line); border-radius: 980px; font: inherit; font-weight: 600; font-size: 13px; padding: 7px 14px; cursor: pointer; white-space: nowrap; }
.oc-track-save:hover { background: var(--surface-2); }
.order-card.done { opacity: .62; }
.order-card.done:hover { opacity: 1; }
.oc-toggle { background: none; border: 0; color: var(--ink-2); font: inherit; font-weight: 500; cursor: pointer; padding: 0; }
.oc-toggle:hover { color: var(--ink); }
.reorder-btn {
  background: #4A8AC9; color: #fff; border: 0; border-radius: 980px;
  font: inherit; font-weight: 600; font-size: 13.5px; padding: 8px 18px; cursor: pointer;
}
.reorder-btn:hover { background: #3f79b0; }
.notes-line { color: var(--ink-3); font-size: 13px; margin-top: 8px; font-style: italic; }

/* ───────── Pricing badge ───────── */
.pricing-badge { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 980px; white-space: nowrap; }
.pricing-badge.dealer { color: var(--green); background: rgba(26, 158, 87, .1); }
.pricing-badge.rrp { color: var(--ink-2); background: var(--line-2); }

/* ───────── Admin ───────── */
.admin-view { max-width: 820px; margin: 0 auto; }
/* Dashboard */
.dash-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.dash-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; box-shadow: var(--shadow-sm); }
.dash-val { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.dash-label { color: var(--ink-3); font-size: 12.5px; font-weight: 600; margin-top: 4px; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dash-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.dash-card h3 { margin: 0 0 10px; font-size: 15px; }
.dash-hint { color: var(--ink-3); font-weight: 500; font-size: 12.5px; }
.dash-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dash-table th { text-align: left; color: var(--ink-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: .02em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.dash-table td { padding: 8px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.dash-table tr:last-child td { border-bottom: 0; }
.dash-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dash-sub { color: var(--ink-3); font-size: 11.5px; margin-top: 2px; }
@media (max-width: 720px) { .dash-tiles { grid-template-columns: repeat(2, 1fr); } .dash-grid { grid-template-columns: 1fr; } }
.admin-sub { color: var(--ink-2); margin: 0 0 20px; font-size: 14px; }
/* Access requests */
.req-head { font-weight: 700; font-size: 15px; margin: 4px 0 12px; display: flex; align-items: center; gap: 8px; }
.req-count { background: #4A8AC9; color: #fff; font-size: 12px; font-weight: 700; padding: 1px 9px; border-radius: 980px; }
.req-card { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; background: rgba(74, 138, 201, .06); border: 1px solid rgba(74, 138, 201, .25); border-radius: var(--r-md); padding: 14px 16px; margin-bottom: 10px; }
.req-company { font-weight: 600; }
.req-meta { color: var(--ink-2); font-size: 13px; margin-top: 3px; }
.req-note { color: var(--ink-2); font-size: 13px; margin-top: 6px; font-style: italic; }
.req-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.req-notify { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.req-notify input { width: auto; margin: 0; }
.req-approve { background: var(--green); color: #fff; border: 0; border-radius: 980px; font: inherit; font-weight: 600; font-size: 13px; padding: 8px 16px; cursor: pointer; }
.req-decline { background: none; color: var(--accent); border: 1px solid var(--line); border-radius: 980px; font: inherit; font-weight: 600; font-size: 13px; padding: 7px 14px; cursor: pointer; }
.field-label .opt { color: var(--ink-3); font-weight: 400; }
.admin-subnav { display: inline-flex; gap: 2px; background: var(--line-2); border-radius: 980px; padding: 3px; margin-bottom: 22px; }
.sub-link { border: 0; background: none; font: inherit; font-weight: 600; font-size: 14px; color: var(--ink-2); padding: 7px 20px; border-radius: 980px; cursor: pointer; transition: background .15s, color .15s; }
.sub-link.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.admin-orders-toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.admin-order-search { flex: 1; max-width: 420px; }
.admin-order-search input { padding-left: 38px; height: 42px; border-radius: 12px; }
.oc-dealer { color: var(--ink-2); font-size: 13.5px; margin-top: 3px; }
.oc-code { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.dealer-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-sm); padding: 14px 16px; margin-bottom: 12px; }
.dc-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.dc-email { font-weight: 600; }
.dc-assign { margin-top: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dc-cust { font-size: 14px; }
.dc-no { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.dc-none { color: var(--ink-3); font-size: 14px; }
.dc-actions { display: flex; gap: 8px; align-items: center; }
.dc-toggle { background: var(--ink); color: #fff; border: 0; border-radius: 980px; font: inherit; font-weight: 600; font-size: 13px; padding: 8px 16px; cursor: pointer; }
.dc-toggle:hover { background: #000; }
.dc-del { background: none; color: var(--accent); border: 1px solid var(--line); border-radius: 980px; font: inherit; font-weight: 600; font-size: 13px; padding: 7px 14px; cursor: pointer; }
.dc-del:hover { background: var(--accent-soft); border-color: var(--accent-soft); }
.dc-suggest { background: var(--accent-soft); color: var(--accent); border: 0; border-radius: 980px; font: inherit; font-weight: 600; font-size: 13px; padding: 8px 14px; cursor: pointer; }

.pl-badge { display: inline-block; font-size: 11px; font-weight: 600; color: var(--ink-2); background: var(--line-2); padding: 3px 9px; border-radius: 980px; white-space: nowrap; }
.pl-badge.sm { font-size: 10px; padding: 2px 7px; }
.pl-none { font-size: 12px; color: var(--ink-3); }

.dc-picker { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.dc-search { margin-bottom: 10px; }
.dc-results { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.cust-result { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; text-align: left; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; cursor: pointer; font: inherit; transition: background .12s, border-color .12s; }
.cust-result:hover { background: var(--accent-soft); border-color: var(--accent-soft); }
.cr-name { font-weight: 600; font-size: 14px; }
.cr-meta { grid-column: 1; color: var(--ink-3); font-size: 12.5px; }
.cr-lists { grid-column: 2; grid-row: 1 / span 2; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; max-width: 240px; }
.dc-remove { margin-top: 10px; background: none; border: 0; color: var(--accent); font: inherit; font-weight: 500; font-size: 13px; cursor: pointer; padding: 0; }

/* ───────── Admin: Team ───────── */
.team-add { display: flex; gap: 10px; margin-bottom: 18px; max-width: 480px; align-items: center; }
.team-add input { flex: 1; }
#admin-dealers .team-add { max-width: 640px; }
.notify-toggle { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.notify-toggle input { flex: none; width: auto; margin: 0; }
.team-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-sm); overflow: hidden; }
.team-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.team-row:last-child { border-bottom: 0; }
.team-email { font-size: 14px; }
.team-you { font-size: 11px; font-weight: 700; color: var(--ink-3); }
.team-right { display: flex; align-items: center; gap: 12px; }
.team-src { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 980px; }
.team-src.config { color: var(--ink-3); background: var(--line-2); }
.team-src.added { color: var(--green); background: rgba(26,158,87,.12); }
.team-remove { background: none; color: var(--accent); border: 1px solid var(--line); border-radius: 980px; font: inherit; font-weight: 600; font-size: 12.5px; padding: 5px 12px; cursor: pointer; }
.team-remove:hover { background: var(--accent-soft); border-color: var(--accent-soft); }

/* ───────── Toasts ───────── */
.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; align-items: center; }
/* Mobile-only floating shortcut to the order. */
.cart-bar { display: none; }
@media (max-width: 860px) {
  /* Toasts to the top so they never cover the order at the page bottom. */
  .toasts { bottom: auto; top: 64px; width: calc(100% - 32px); }
  /* The order lives at the bottom on phones — a floating bar keeps it one tap away. */
  .cart-bar.cart-bar--show { display: flex; }
  .cart-bar {
    position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 40;
    align-items: center; gap: 12px;
    background: #4A8AC9; color: #fff; border: 0; border-radius: 14px;
    padding: 14px 18px; font: inherit; font-weight: 600; font-size: 15px;
    box-shadow: 0 6px 22px rgba(0, 0, 0, .24); cursor: pointer;
  }
  .cart-bar-total { margin-left: auto; font-variant-numeric: tabular-nums; }
  .cart-bar-cta { font-weight: 700; white-space: nowrap; }
}
.toast {
  background: rgba(29, 29, 31, .95); color: #fff; padding: 11px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg);
  animation: toastIn .3s var(--ease);
}
.toast.leaving { animation: toastOut .25s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px); } }

/* ───────── Responsive ───────── */
@media (max-width: 860px) {
  /* minmax(0,1fr) lets the column shrink below content width so long product
     names wrap instead of stretching the whole page (fixes side-scrolling). */
  .app-grid { grid-template-columns: minmax(0, 1fr); }
  .catalogue { min-width: 0; }
  .toolbar .search-wrap { flex-basis: 100%; }
  /* Catalogue first on small screens — browse, then review the order below. */
  .order { position: static; max-height: none; }
  .order-body { overflow: visible; }
  .catalogue { order: 1; }
  .order { order: 2; }
  /* Tidy the cramped header on phones so it fits without side-scrolling. */
  .brand-sub, .who, .brand-divider { display: none; }
  .topbar { padding: 6px 12px; gap: 8px; height: auto; min-height: 52px; flex-wrap: wrap; }
  .brand { gap: 8px; min-width: 0; }
  .brand-logo { height: 17px; }
  .brand-logo-mmx { height: 14px; }
  .userbar { gap: 6px; min-width: 0; }
  .nav { gap: 0; }
  .nav-link { padding: 6px 8px; font-size: 13px; }
  #logout { padding: 6px 8px; font-size: 13px; }
  #app { padding: 16px 14px 48px; overflow-x: hidden; } /* guard against stray content overflow */

  /* Reflow each stock row into a stacked card — a dense table doesn't fit. */
  .stock, .stock tbody, .stock tbody tr, .stock tbody td { display: block; }
  .stock thead { display: none; }
  .stock tbody tr { position: relative; padding: 14px 15px; }
  .stock tbody tr:hover { background: none; }
  .stock tbody td { padding: 0; border: 0; }
  .stock td.item { padding-right: 74px; }
  .stock td.num { display: inline-block; margin-top: 10px; }
  .stock td.price { margin-left: 20px; }
  .stock td.act { position: absolute; top: 14px; right: 15px; width: auto; }

  /* Toolbar buttons wrap below the search on phones. */
  .toolbar { flex-wrap: wrap; }
  /* Stack the catalogue controls so long dropdown options don't overflow. */
  .catalogue-controls { flex-direction: column; align-items: stretch; gap: 10px; }
  .catalogue-controls .ctrl-spacer { display: none; }
  .catalogue-controls .ctrl-select { width: 100%; }
  /* Admin sub-tabs and order toolbar scroll/wrap instead of overflowing. */
  .admin-subnav { max-width: 100%; overflow-x: auto; }
  .admin-orders-toolbar { flex-wrap: wrap; }
  .admin-order-search { max-width: none; }
}
