/* BCW Inventory — components.
   Load after tokens.css. Plain CSS, classes only (no inline styles needed),
   keeps bcw-admin's existing class names: .topbar .page .flash .form .button
   .filters .table .num .status .muted .notice .warn .is-sold-out. */

/* ---------- Base ---------- */
html { font-size: 18px; }
:root { font-family: var(--font-sans); line-height: var(--leading); color: var(--text); background: var(--bg); }
* { box-sizing: border-box; }
body { margin: 0; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
/* Links are denim, not the royal blue of buttons. In sentences a faint underline
   marks them; names in tables, Buy and Sell lines and Home's tools have none until
   hover, so rows of names stay calm (Nov 14, option B of the link styles). */
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 0.18em;
    text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); }
a:hover { color: var(--link-hover); text-decoration-color: currentColor; }
:is(.table, .line-card__name, .screen) a:not(.button) { text-decoration: none; }
:is(.table, .line-card__name, .screen) a:not(.button):hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 1.11rem; height: 1.11rem; flex: none; vertical-align: -0.2em; }
.muted { color: var(--muted); }
.notice { color: var(--muted); }
.warn { color: var(--error); font-weight: 700; }
.num, .money { font-variant-numeric: tabular-nums lining-nums; }
.kbd {
  display: inline-block; min-width: 1.5em; padding: 0 0.35em;
  font: 700 var(--text-xs)/1.5 var(--font-sans); text-align: center;
  color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-bottom-width: 2px; border-radius: var(--radius-sm);
}

/* ---------- App shell ---------- */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-5);
  padding: 0 var(--space-5); min-height: 4rem;
  background: var(--brand-navy); color: var(--on-navy);
}
/* Turbo's page-loading bar (shown when a page takes over 0.5 s), across the top of the navy bar: a thin, faint slate, only a little lighter than the navy, so it's there if you look for it but doesn't call attention. */
.turbo-progress-bar { height: 2px; background: color-mix(in srgb, var(--on-navy-muted) 30%, transparent); }
.topbar__brand { display: flex; align-items: center; padding: var(--space-2) 0; }
.topbar__brand img { display: block; height: 2.44rem; width: auto; }
.topbar__nav { display: flex; flex-wrap: wrap; align-self: stretch; gap: var(--space-1); margin-right: auto; }
.topbar__link {
  display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-3);
  color: var(--on-navy-muted); font-weight: 700; text-decoration: none;
  border-bottom: 4px solid transparent; border-top: 4px solid transparent;
}
.topbar__link:hover { color: var(--on-navy); }
.topbar__link[aria-current="page"] { color: var(--on-navy); border-bottom-color: var(--brand-red); }
.topbar__link:focus-visible { outline-color: var(--on-navy); outline-offset: -3px; }
.topbar__count { min-width: 1.4em; padding: 0 0.4em; border-radius: var(--radius-pill); background: var(--highlight); color: var(--text); font-size: var(--text-xs); font-weight: 900; text-align: center; }
.topbar__pc { color: var(--on-navy-muted); font-size: var(--text-sm); }
/* Keyboard shortcuts: one quiet button in the header (and the ? key) opens the list */
.topbar__help {
  display: grid; place-items: center; width: 2.22rem; height: 2.22rem; padding: 0;
  font: 900 var(--text-md) var(--font-sans); color: var(--on-navy-muted); background: transparent;
  border: 1.5px solid rgba(255, 255, 255, 0.32); border-radius: 50%; cursor: pointer;
}
.topbar__help:hover { color: var(--on-navy); border-color: var(--on-navy); }
.topbar__help:focus-visible { outline-color: var(--on-navy); }
.topbar__user { color: var(--on-navy-muted); font-size: var(--text-sm); }

/* Two identities, kept visibly apart:
   .who            the person: the staff member who entered their PIN on a counter PC,
                   or an admin signed in with their own account.
   .topbar__device the counter PC's own long-lived sign-in (shared device account). Quiet. */
.who {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-3);
  border: 1px solid rgba(255, 255, 255, 0.24); border-radius: var(--radius-pill);
}
.who__name { font-weight: 700; }
.who__avatar { display: grid; place-items: center; width: 1.78rem; height: 1.78rem; margin-left: calc(var(--space-2) * -1); border-radius: 50%; background: var(--on-navy-muted); color: var(--brand-navy); font-size: var(--text-xs); font-weight: 900; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5); }
button.who__avatar { padding: 0; border: 0; font-family: inherit; cursor: pointer; }
button.who__avatar:hover { box-shadow: 0 0 0 2px var(--on-navy); }
button.who__avatar:focus-visible { outline: 3px solid var(--on-navy); outline-offset: 2px; }
.who__role { font-size: var(--text-xs); font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; color: var(--brand-navy); background: var(--highlight); border-radius: var(--radius-sm); padding: 0 var(--space-1); }
.who__action {
  margin-left: var(--space-1); font: 700 var(--text-sm) var(--font-sans); color: var(--brand-navy); background: var(--on-navy);
  border: 0; border-radius: var(--radius-pill); padding: var(--space-1) var(--space-3); cursor: pointer;
}
.who__action { text-decoration: none; }
.who__action:hover { color: var(--brand-navy); background: var(--accent-tint); }
.who__action:focus-visible { outline-color: var(--on-navy); }
/* A nav item that opens a menu (the admin screens) */
button.topbar__link { font: inherit; font-weight: 700; background: none; border-left: 0; border-right: 0; cursor: pointer; }
.topbar__link svg { width: 1rem; height: 1rem; }
.topbar__device {
  display: flex; align-items: center; gap: var(--space-2); padding-left: var(--space-4);
  color: var(--on-navy-muted); font-size: var(--text-sm); border-left: 1px solid rgba(255, 255, 255, 0.24);
}

/* ---------- Counter PIN screen and sign-in (full page, before the app) ---------- */
.lock { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; background: var(--brand-navy); color: var(--on-navy); }
.lock--frame { min-height: 40rem; border-radius: var(--radius-lg); overflow: hidden; }
.lock__top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5); }
.lock__top img { display: block; height: 2.67rem; width: auto; }
.lock__body { display: grid; place-items: center; align-content: center; gap: var(--space-4); padding: var(--space-5); }
.lock__note { max-width: 30rem; text-align: center; font-size: var(--text-sm); color: var(--on-navy-muted); }
.lock__note a { color: var(--on-navy); }
.lock .dialog { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 16px 40px rgba(0, 0, 0, 0.35); }
.lock .flash { width: min(34rem, 100%); }

.page { max-width: 1400px; margin: 0 auto; padding: var(--space-5) var(--space-5) var(--space-7); display: grid; gap: var(--space-5); } /* more room at the bottom, so the last table doesn't crowd the window's edge */
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--space-4); }
.page-head__title { display: grid; gap: var(--space-1); }
.page-title { font: 900 var(--text-2xl)/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.01em; }
.page-kicker { font-size: var(--text-sm); color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.section-title { font: 800 var(--text-xl)/1.1 var(--font-display); text-transform: uppercase; letter-spacing: 0.02em; }

/* Two-column work area: content plus a side panel that stacks on narrow screens */
.work { display: flex; flex-wrap: wrap; gap: var(--space-5); align-items: flex-start; }
.work__main { flex: 999 1 640px; min-width: 0; display: grid; gap: var(--space-4); }
.work__side { flex: 1 1 360px; min-width: 0; display: grid; gap: var(--space-4); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4); display: grid; gap: var(--space-4); }
.panel__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }

/* ---------- Flash messages ---------- */
.flash {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius);
  background: var(--accent-tint); color: var(--text); border: 1px solid var(--accent);
}
.flash svg { flex: none; width: 1.33rem; height: 1.33rem; }
.flash--notice { background: var(--ok-tint); border-color: var(--ok); }
.flash--notice svg { color: var(--ok); }
.flash--alert { background: var(--error-tint); border-color: var(--error); }
.flash--alert svg { color: var(--error); }
.flash--warn { background: var(--warn-tint); border-color: var(--warn); }
.flash--warn svg { color: var(--warn-line); }
.flash__action { margin-left: auto; }

/* ---------- Buttons ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--control-h); padding: 0 var(--space-5);
  font: 700 var(--text-md)/1.2 var(--font-sans); text-decoration: none; white-space: nowrap;
  color: var(--accent-text); background: var(--accent);
  border: 2px solid var(--accent); border-radius: var(--radius); cursor: pointer;
}
.button:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
.button svg { width: 1.11rem; height: 1.11rem; flex: none; }
.button--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.button--secondary:hover { background: var(--surface); color: var(--text); border-color: var(--text); }
.button--quiet { background: transparent; color: var(--accent); border-color: transparent; padding: 0 var(--space-3); }
.button--quiet:hover { background: var(--accent-tint); color: var(--accent); border-color: transparent; }
.button--danger { background: var(--surface); color: var(--error); border-color: var(--error); }
.button--danger:hover { background: var(--error-tint); color: var(--error); border-color: var(--error); }
.button--lg { min-height: 3.56rem; font-size: var(--text-lg); padding: var(--space-2) var(--space-5); white-space: normal; text-align: center; }
.button--sm { min-height: var(--control-h-sm); padding: 0 var(--space-3); font-size: var(--text-sm); }
.button--icon { padding: 0; width: var(--control-h-sm); min-height: var(--control-h-sm); }
.button[disabled], .button[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }

/* ---------- Fields ---------- */
.field { display: grid; gap: var(--space-1); }
.field__label, .form label { font-weight: 700; font-size: var(--text-sm); }
.field__help { font-size: var(--text-sm); color: var(--muted); }
.field--error .input { border-color: var(--error); }
.field--error .field__help { color: var(--error); font-weight: 700; }
.input, .select,
.form input[type="email"], .form input[type="password"], .form input[type="text"] {
  width: 100%; min-height: var(--control-h); padding: 0 var(--space-3);
  font: 400 var(--text-md) var(--font-sans); color: var(--text);
  background: var(--surface); border: 1.5px solid var(--border-strong); border-radius: var(--radius);
}
.input::placeholder { color: var(--muted); }
.input:focus, .select:focus { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
.input--money { text-align: right; font-variant-numeric: tabular-nums; }
.input--sm { min-height: var(--control-h-sm); }
.form { display: grid; gap: var(--space-2); max-width: 24rem; }

/* Segmented choice (condition, finish, offer type): radio inputs styled as buttons */
.seg { display: inline-flex; flex-wrap: wrap; gap: var(--space-1); padding: var(--space-1); background: var(--surface-sunken); border-radius: var(--radius); border: 0; margin: 0; }
/* The legend sits above the grey track, like a field label, not inside it. */
.seg:has(> legend) { position: relative; margin-top: calc(var(--text-sm) * var(--leading) + var(--space-1)); }
.seg legend { position: absolute; bottom: 100%; left: 0; padding: 0; margin-bottom: var(--space-1); font-weight: 700; font-size: var(--text-sm); line-height: var(--leading); white-space: nowrap; }
.seg__option { position: relative; }
.seg__option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg__option span {
  display: flex; align-items: center; justify-content: center; gap: var(--space-1);
  min-width: 3.2rem; min-height: var(--control-h-sm); padding: 0 var(--space-3);
  font-weight: 700; border-radius: var(--radius-sm); color: var(--text); border: 1.5px solid transparent;
}
.seg__option input:checked + span { background: var(--surface); border-color: var(--accent); color: var(--accent); box-shadow: 0 1px 2px rgba(2, 20, 66, 0.12); }
.seg__option input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }
.seg__option input:disabled + span { color: var(--muted); text-decoration: line-through; opacity: 0.6; }

/* Quantity: a number input flanked by − and + (arrow keys also step) */
.qty { display: inline-flex; align-items: stretch; height: var(--control-h-sm); border: 1.5px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.qty button { width: 2.2rem; border: 0; background: transparent; font: 900 var(--text-lg)/1 var(--font-sans); color: var(--text); cursor: pointer; }
.qty button:hover { background: var(--surface-sunken); }
.qty button:focus-visible { outline-offset: -3px; }
.qty input { width: 3rem; border: 0; border-left: 1px solid var(--border); border-right: 1px solid var(--border); text-align: center; font: 700 var(--text-md) var(--font-sans); font-variant-numeric: tabular-nums; color: var(--text); background: transparent; }
.qty input:focus { outline: 3px solid var(--focus); outline-offset: -3px; }
.qty--warn { border-color: var(--warn); border-width: 2px; }

/* ---------- Scan field and results ---------- */
.scan { display: grid; gap: var(--space-2); }
.scan__label { font-weight: 700; }
.scan__box { position: relative; }
.scan__box svg { position: absolute; left: var(--space-4); top: 50%; width: 1.78rem; height: 1.78rem; margin-top: -0.89rem; color: var(--muted); pointer-events: none; }
.scan__input {
  width: 100%; height: var(--scan-h); padding: 0 var(--space-4) 0 3.6rem;
  font: 700 var(--text-xl) var(--font-sans); letter-spacing: 0.02em; color: var(--text);
  background: var(--surface); border: 2px solid var(--border-strong); border-radius: var(--radius-lg);
}
.scan__input:focus { outline: none; border-color: var(--focus); box-shadow: var(--focus-ring); }
.scan__hint { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); font-size: var(--text-sm); color: var(--muted); }
.scan__ready { display: inline-flex; align-items: center; gap: var(--space-1); color: var(--ok); font-weight: 700; }
.scan__ready::before { content: ""; width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--ok); }

/* The result of the last scan: big enough to read from a step back */
.scan-result {
  display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: var(--space-4);
  padding: var(--space-4) var(--space-5); border-radius: var(--radius-lg);
  border: 2px solid var(--border); background: var(--surface);
}
.scan-result__icon { display: grid; place-items: center; width: 3.56rem; height: 3.56rem; border-radius: 50%; color: var(--surface); }
.scan-result__icon svg { width: 2rem; height: 2rem; }
.scan-result__thumb { width: 3.11rem; height: 4.33rem; }
.scan-result__text { display: grid; gap: var(--space-1); min-width: 0; }
.scan-result__headline { font: 900 var(--text-2xl)/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.01em; }
.scan-result__detail { font-size: var(--text-lg); font-weight: 700; overflow-wrap: anywhere; }
.scan-result__meta { color: var(--muted); }
.scan-result__price { font: 900 var(--text-2xl)/1 var(--font-display); font-variant-numeric: tabular-nums; }
.scan-result--added { border-color: var(--ok); background: var(--ok-tint); }
.scan-result--added .scan-result__icon { background: var(--ok); }
.scan-result--added .scan-result__headline { color: var(--ok); }
.scan-result--not-found { border-color: var(--error); background: var(--error-tint); grid-template-columns: auto 1fr auto; }
.scan-result--not-found .scan-result__icon { background: var(--error); }
.scan-result--not-found .scan-result__headline { color: var(--error); }
.scan-result--choose { border-color: var(--accent); background: var(--accent-tint); grid-template-columns: auto 1fr auto; }
.scan-result--choose .scan-result__icon { background: var(--accent); }
.scan-result--choose .scan-result__headline { color: var(--accent); }
.scan-result--limit { border-color: var(--warn); background: var(--warn-tint); }
.scan-result--limit .scan-result__icon { background: var(--warn); color: var(--warn-line); }
.scan-result--limit .scan-result__headline { color: var(--warn-text); }

/* "Which one?": candidates for an old label, picked with 1–9 or arrows + Enter */
.chooser { display: grid; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.chooser__option {
  display: grid; grid-template-columns: auto auto 1fr auto auto; align-items: center; gap: var(--space-4);
  width: 100%; padding: var(--space-3) var(--space-4); text-align: left;
  font: inherit; color: var(--text); background: var(--surface);
  border: 2px solid var(--border); border-radius: var(--radius); cursor: pointer;
}
.chooser__option:hover, .chooser__option[aria-selected="true"] { border-color: var(--accent); background: var(--accent-tint); }

/* ---------- Card bits ---------- */
/* A card image (Scryfall "small" is 146×204). Without an image it shows a placeholder at the same ratio. */
.thumb { display: block; width: 2.22rem; aspect-ratio: 146 / 204; border-radius: var(--radius-sm); background: var(--surface-sunken); object-fit: cover; }
.thumb--md { width: 3.11rem; }
.thumb--lg { width: 8.11rem; border-radius: var(--radius); }
.card-cell { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: var(--space-3); min-width: 0; }
.card-cell__name { font-weight: 700; overflow-wrap: anywhere; }
.card-cell__meta { font-size: var(--text-sm); color: var(--muted); }
.card-cell__tags { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: var(--space-1); }

/* Small tags: finish, condition, language, version */
.tag { display: inline-flex; align-items: center; min-height: 1.4rem; padding: 0 var(--space-2); border-radius: var(--radius-sm); font-size: var(--text-xs); font-weight: 900; letter-spacing: 0.04em; background: var(--surface-sunken); color: var(--text); white-space: nowrap; }
.tag--foil { background: var(--foil-sheen); }

/* The warning icon (class icon--warn): a yellow triangle with a dark outline and "!",
   like a road sign. The dark parts carry the contrast, so the yellow can be bright. */
.icon--warn path:first-child { fill: var(--warn); }
.tag--outline { background: transparent; box-shadow: inset 0 0 0 1.5px var(--border-strong); }

/* Status pills: Shopify sync and price-change states. Always a word, never color alone. */
.status { display: inline-flex; align-items: center; gap: 0.35em; font-size: var(--text-xs); font-weight: 700; padding: 0.1rem 0.55rem; border-radius: var(--radius-pill); border: 1.5px solid currentColor; white-space: nowrap; }
.status--ok, .status--listed, .status--applied, .status--approved { color: var(--ok); }
.status--pending, .status--sending { color: var(--accent); }
.status--muted, .status--not-listed, .status--reverted, .status--rejected, .status--superseded { color: var(--muted); }
.status--held { color: var(--warn-text); }
.status--failed, .status--stopped { color: var(--error); }

/* ---------- Card search (autocomplete) ---------- */
.search { position: relative; }
.search__list {
  position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + var(--space-1));
  margin: 0; padding: var(--space-1); list-style: none; max-height: 26rem; overflow: auto;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-pop);
}
.search__list--static { position: static; }
.search__option { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); cursor: pointer; }
.search__option[aria-selected="true"] { background: var(--accent-tint); }
.search__option mark { background: transparent; color: inherit; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 2px; }
.search__count { font-size: var(--text-sm); color: var(--muted); white-space: nowrap; }

/* ---------- Printing picker ---------- */
.printings { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.9rem, 1fr)); gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
.printing {
  display: grid; gap: var(--space-1); width: 100%; padding: var(--space-2); text-align: left;
  font: inherit; color: var(--text); background: var(--surface);
  border: 2px solid var(--border); border-radius: var(--radius); cursor: pointer;
}
.printing:hover { border-color: var(--border-strong); }
.printing[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.printing .thumb { width: 100%; }
.printing__set { font-weight: 700; font-size: var(--text-sm); }
.printing__meta { font-size: var(--text-xs); color: var(--muted); }

/* ---------- Card entry (Buy): the chosen printing plus its details, compact ----------
   The printing switch beside the name, the fields on one row (wrapping when narrow),
   the offer strip and the actions sharing the last row. */
.entry { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.entry .thumb--lg { width: 5.5rem; }
.entry__body { display: grid; gap: var(--space-3); min-width: 0; }
.entry__top { display: flex; align-items: start; justify-content: space-between; gap: var(--space-3); }
.entry__head { display: grid; gap: var(--space-1); }
.entry__name { font-size: var(--text-lg); font-weight: 900; overflow-wrap: anywhere; }
.entry__other { flex: none; }
.entry__fields { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-3); }
.entry__fields .field--price { width: 7.5rem; }
.entry__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
.entry__foot > :first-child { flex: 1 1 26rem; min-width: 0; }
.entry__offer { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-5); padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--surface-sunken); }
.entry__offer strong { font-variant-numeric: tabular-nums; }
.entry__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
@media (max-width: 700px) { .entry { grid-template-columns: 1fr; } }

/* ---------- Data table ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.table-wrap--tall { max-height: 34rem; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); font-size: var(--text-md); }
.table-wrap .table { border: 0; }
.table th, .table td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-sunken); font-size: var(--text-sm); font-weight: 700; color: var(--muted); white-space: nowrap; }
.table tbody tr:hover td { background: var(--bg); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { font-weight: 700; border-top: 2px solid var(--border); border-bottom: 0; background: var(--surface); }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .money-cell { font-weight: 700; }
.table .details { white-space: nowrap; }
.table .actions { width: 1%; white-space: nowrap; text-align: right; }
.table .input--money { display: block; width: 8rem; margin-left: auto; }
.row-actions { display: flex; flex-wrap: nowrap; justify-content: flex-end; gap: var(--space-2); }
.table code { font-size: var(--text-sm); }
.table tr.is-sold-out td { color: var(--muted); }
.table tr.is-sold-out .thumb { opacity: 0.5; }
.table tr.is-sold-out a:not(.button) { color: var(--muted); } /* links only: a link styled as a button keeps its colours */
.table tr.is-selected td { background: var(--accent-tint); }
.table tr.is-new td { background: var(--ok-tint); }
.table tr.is-warn td { background: var(--warn-tint); }
/* Quantity stepped, not yet sent (quantity_step_controller.js): the money is for the old quantity. */
.table tr.is-pending td.num { opacity: 0.4; }
.table--compact th, .table--compact td { padding: var(--space-1) var(--space-3); }
.line-warning { display: flex; align-items: center; gap: var(--space-1); margin-top: var(--space-1); font-size: var(--text-sm); font-weight: 700; color: var(--warn-text); }
.line-warning svg { color: var(--warn-line); }
.line-warning svg { width: 1rem; height: 1rem; flex: none; }

/* ---------- Filters (existing) ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-3) var(--space-4); }
.filters__field { display: grid; gap: var(--space-1); }
.filters__field label { font-weight: 700; font-size: var(--text-sm); }
.filters select, .filters input[type="search"] { font: inherit; min-height: var(--control-h); padding: 0 var(--space-3); border: 1.5px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.filters__check { display: flex; align-items: center; gap: var(--space-2); min-height: var(--control-h); }
.filters__check input { width: 1.2rem; height: 1.2rem; accent-color: var(--accent); }
.filters__reset { align-self: center; font-weight: 700; }
/* Selects draw their own caret, inset from the edge (the native one sits against it). A data: image is allowed by the app's CSP (img-src 'self' data:). */
.select, .filters select {
  -webkit-appearance: none; appearance: none; padding-right: 2.6rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230e1733' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--space-3) center; background-size: 1.1rem;
}
.select::-ms-expand { display: none; }

/* ---------- Money and totals ---------- */
.money { font-family: var(--font-display); font-weight: 900; line-height: 1; }
.totals { background: var(--surface); border: 2px solid var(--brand-navy); border-radius: var(--radius-lg); overflow: hidden; }
.totals__body { padding: var(--space-4) var(--space-5); display: grid; gap: var(--space-3); }
.totals__row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.totals__label { font-size: var(--text-sm); font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.totals__grand { font-size: var(--text-money); }
.totals__sub { font-size: var(--text-xl); }
.totals__foot { padding: var(--space-4) var(--space-5); background: var(--surface-sunken); display: grid; gap: var(--space-3); }
.totals__foot .button { width: 100%; }

/* Buy offer panel. First what the shop will sell these for (context, not a choice: plain, muted,
   no box), then the decision: "Customer takes" is one radio group whose options ARE the offers. */
.sell-value { display: grid; gap: var(--space-1); padding-bottom: var(--space-4); border-bottom: 1px solid var(--border); }
.sell-value__row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.sell-value__label { font-size: var(--text-sm); font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.sell-value__amount { font: 900 var(--text-xl)/1 var(--font-display); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.offer-choice { display: grid; gap: var(--space-2); margin: 0; padding: 0; border: 0; min-width: 0; }
.offer-choice legend { float: left; width: 100%; margin-bottom: var(--space-2); padding: 0; font-size: var(--text-sm); font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text); }
.offer-opt { position: relative; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-width: 0; padding: var(--space-3) var(--space-4); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); cursor: pointer; }
.offer-opt input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.offer-opt__name { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-lg); font-weight: 900; }
.offer-opt__check { width: 1.2rem; height: 1.2rem; flex: none; color: var(--accent); visibility: hidden; }
.offer-opt__value { font: 900 var(--text-2xl)/1 var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.offer-opt:hover { border-color: var(--accent); }
.offer-opt:has(input:checked) { background: var(--accent-tint); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.offer-opt:has(input:checked) .offer-opt__name { color: var(--accent); }
.offer-opt:has(input:checked) .offer-opt__check { visibility: visible; }
.offer-opt:has(input:focus-visible) { box-shadow: var(--focus-ring); }

/* Small stat (e.g. stock removed today) */
.stat { display: grid; gap: 0; padding: var(--space-1) var(--space-4); border-left: 1px solid var(--border); }
.stats .stat:first-child { border-left: 0; padding-left: 0; }
a.stat { color: inherit; text-decoration: none; border-radius: var(--radius-sm); }
a.stat:hover .stat__value { color: var(--link-hover); }
a.stat .stat__label { text-decoration: underline; text-underline-offset: 2px; }
.stat__label { font-size: var(--text-sm); color: var(--muted); }
.stat__value { font: 900 var(--text-xl)/1.1 var(--font-display); font-variant-numeric: tabular-nums; }

/* ---------- Dialogs (in-page, never alert/confirm) ---------- */
.dialog-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: var(--space-5); background: rgba(2, 20, 66, 0.55); }
.dialog-backdrop--inline { position: relative; inset: auto; min-height: 30rem; border-radius: var(--radius-lg); }
.dialog {
  width: min(34rem, 100%); padding: var(--space-6); display: grid; gap: var(--space-4);
  background: var(--surface); color: var(--text); border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-pop);
}
.dialog__title { font: 900 var(--text-2xl)/1 var(--font-display); text-transform: uppercase; }
.dialog__body { display: grid; gap: var(--space-3); }
.dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-3); padding-top: var(--space-2); }
.dialog--wide { width: min(46rem, 100%); }

/* ---------- PIN prompt ---------- */
.pin { text-align: center; justify-items: center; }
.pin__icon { display: grid; place-items: center; width: 4rem; height: 4rem; border-radius: 50%; background: var(--accent-tint); color: var(--accent); }
.pin__icon svg { width: 2rem; height: 2rem; }
.pin__for { color: var(--muted); }
.pin__input {
  width: 100%; max-width: 18rem; height: 4rem; text-align: center;
  font: 900 var(--text-2xl) var(--font-sans); letter-spacing: 0.5em;
  border: 2px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); color: var(--text);
}
.pin__input:focus { outline: none; border-color: var(--focus); box-shadow: var(--focus-ring); }
.pin--error .pin__input { border-color: var(--error); }
.pin__message { font-weight: 700; min-height: 1.4em; }
.pin--error .pin__message { color: var(--error); }
.pin--locked .pin__icon { background: var(--error-tint); color: var(--error); }
.pin .button--lg { width: 100%; max-width: 18rem; }

/* PIN boxes: one real input (numeric, paste and autofill work, one label for screen readers)
   laid over one box per digit. A small Stimulus controller mirrors the input into the boxes
   and submits the form by itself when the last digit is typed. Change the box count to change
   the PIN length. */
.pin-boxes { position: relative; display: flex; justify-content: center; gap: var(--space-2); }
.pin-boxes__input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; font-size: 1rem; caret-color: transparent; cursor: text; }
.pin-box { display: grid; place-items: center; width: 3.33rem; height: 4rem; border: 2px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.pin-box--filled { border-color: var(--text); }
.pin-box--filled::after { content: ""; width: 0.9rem; height: 0.9rem; border-radius: 50%; background: var(--text); }
.pin-box--current { border-color: var(--focus); box-shadow: var(--focus-ring); }
.pin--checking .pin-box { border-color: var(--accent); }
.pin--checking .pin-box::after { background: var(--accent); }
.pin--error .pin-box { border-color: var(--error); }
.pin--error .pin-box--current { box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--error); }
.pin__message { color: var(--muted); }
.pin--checking .pin__message { color: var(--accent); }

/* Staff picker: "Who's working?" One click on your name and you're in. The PIN isn't security,
   only who-did-what for the history, so the fastest way to say who you are wins.
   Buttons in a grid; arrow keys move, typing a name's first letters jumps to it, Enter picks. */
.staff-picker { width: min(46rem, 100%); text-align: center; justify-items: center; }
.staff-list { width: 100%; margin: 0; padding: var(--space-2) 0 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: var(--space-3); }
.staff {
  position: relative; display: grid; justify-items: center; gap: var(--space-2); width: 100%; padding: var(--space-4) var(--space-3);
  font: inherit; color: var(--text); background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius-lg); cursor: pointer;
}
.staff:hover { border-color: var(--accent); background: var(--accent-tint); }
.staff:focus-visible { outline: none; border-color: var(--focus); box-shadow: var(--focus-ring); }
.staff__avatar { display: grid; place-items: center; width: 3.56rem; height: 3.56rem; border-radius: 50%; background: var(--brand-navy); color: var(--on-navy); font: 900 var(--text-lg) var(--font-sans); letter-spacing: 0.02em; }
.staff__name { font-weight: 900; font-size: var(--text-lg); }
/* "Last here" never changes the grid: names stay in a fixed order, and the tag sits on the
   button's top edge, outside its content, so no button changes size. */
.staff__tag { position: absolute; top: 0; left: 50%; transform: translate(-50%, -50%); white-space: nowrap; background: var(--accent); color: var(--accent-text); }
.staff--last { border-color: var(--accent); }
/* Each person keeps one color (set when they're added, or id mod 12) */
.staff-color-1 { background: var(--staff-1); color: var(--staff-1-ink); }
.staff-color-2 { background: var(--staff-2); color: var(--staff-2-ink); }
.staff-color-3 { background: var(--staff-3); color: var(--staff-3-ink); }
.staff-color-4 { background: var(--staff-4); color: var(--staff-4-ink); }
.staff-color-5 { background: var(--staff-5); color: var(--staff-5-ink); }
.staff-color-6 { background: var(--staff-6); color: var(--staff-6-ink); }
.staff-color-7 { background: var(--staff-7); color: var(--staff-7-ink); }
.staff-color-8 { background: var(--staff-8); color: var(--staff-8-ink); }
.staff-color-9 { background: var(--staff-9); color: var(--staff-9-ink); }
.staff-color-10 { background: var(--staff-10); color: var(--staff-10-ink); }
.staff-color-11 { background: var(--staff-11); color: var(--staff-11-ink); }
.staff-color-12 { background: var(--staff-12); color: var(--staff-12-ink); }

/* Signed-out PC: says plainly what's wrong and who can fix it, then the admin form */
.signin { width: min(36rem, 100%); padding: 0; gap: 0; overflow: hidden; }
.signin__status { display: grid; justify-items: center; gap: var(--space-3); padding: var(--space-6) var(--space-6) var(--space-5); text-align: center; }
.signin__icon { display: grid; place-items: center; width: 4rem; height: 4rem; border-radius: 50%; background: var(--warn-tint); color: var(--warn-line); }
.signin__icon svg { width: 2rem; height: 2rem; }
.signin__lead { margin: 0; font-size: var(--text-lg); }
.signin__steps { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--space-2); text-align: left; counter-reset: step; }
.signin__steps li { display: flex; align-items: baseline; gap: var(--space-3); counter-increment: step; }
.signin__steps li::before { content: counter(step); flex: none; display: grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--brand-navy); color: var(--on-navy); font-weight: 900; font-size: var(--text-sm); }
.signin__form { display: grid; gap: var(--space-3); padding: var(--space-5) var(--space-6) var(--space-6); background: var(--surface-sunken); border-top: 1px solid var(--border); }
.signin__form-title { font-size: var(--text-sm); font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

/* ---------- Summary after a sale or buy ---------- */
.done { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--space-4); padding: var(--space-5); background: var(--ok-tint); border: 1px solid var(--ok); border-radius: var(--radius-lg); }
.done__icon { display: grid; place-items: center; width: 3.56rem; height: 3.56rem; border-radius: 50%; background: var(--ok); color: var(--surface); }
.done__icon svg { width: 2rem; height: 2rem; }
.done__title { font: 900 var(--text-2xl)/1 var(--font-display); text-transform: uppercase; color: var(--ok); }
.done__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
/* Where a label print reports back ("Sent 3 labels…", or why they didn't print). Empty, it takes no space in the stack. */
.print-result:empty { display: none; }

/* ---------- Warnings that don't block: fix now, or it goes on Needs Attention ---------- */
.line-warning .button { margin-left: var(--space-2); }
.warn-list { list-style: none; margin: 0; padding: var(--space-3) var(--space-4); display: grid; gap: var(--space-3); background: var(--warn-tint); border: 1px solid var(--warn); border-radius: var(--radius); }
.warn-list li { display: grid; grid-template-columns: auto 1fr; gap: var(--space-2); align-items: start; }
.warn-list svg { width: 1.33rem; height: 1.33rem; color: var(--warn-line); margin-top: 0.1em; }
.warn-list strong { display: block; }
.warn-list--error { background: var(--error-tint); border-color: var(--error); }
.warn-list--error svg { color: var(--error); }
.attention-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.attention { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--space-4); padding: var(--space-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
/* The item's status is the icon in a soft circle, not an edge */
.attention > svg { box-sizing: content-box; width: 1.33rem; height: 1.33rem; padding: 0.5rem; border-radius: 50%; color: var(--warn-line); background: var(--warn-tint); }
.attention__title { font-weight: 900; }
.attention__meta { font-size: var(--text-sm); color: var(--muted); }
.attention__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; }
.count { display: inline-grid; place-items: center; min-width: 1.4rem; height: 1.4rem; padding: 0 var(--space-1); margin-left: var(--space-1); border-radius: var(--radius-pill); background: var(--highlight); color: var(--brand-navy); font-size: var(--text-xs); font-weight: 900; line-height: 1; }

/* ---------- Someone else's work is open on this device ---------- */
.open-work { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: var(--space-4); padding: var(--space-4); background: var(--surface-sunken); border-radius: var(--radius); text-align: left; }
.open-work__title { font-weight: 900; font-size: var(--text-lg); }
.open-work__lines { font-size: var(--text-sm); color: var(--muted); }
.staff__avatar--sm { width: 2.67rem; height: 2.67rem; font-size: var(--text-md); }
.choices { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.choice {
  display: grid; gap: var(--space-1); width: 100%; padding: var(--space-4) var(--space-5); text-align: left;
  font: inherit; color: var(--text); background: var(--surface); border: 2px solid var(--border-strong); border-radius: var(--radius-lg); cursor: pointer;
}
.choice:hover { border-color: var(--accent); background: var(--accent-tint); }
.choice:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.choice__title { font-weight: 900; font-size: var(--text-lg); }
.choice__detail { font-size: var(--text-sm); color: var(--muted); }
.choice--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.choice--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.choice--primary .choice__detail { color: var(--accent-text); }
.choice--danger .choice__title { color: var(--error); }
.choice--danger:hover { border-color: var(--error); background: var(--error-tint); }

/* ---------- Round 2: Receive, Look Up, Current Inventory ---------- */
/* Steps: Receive is pick a set → enter quantities → review */
.steps { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-1) var(--space-3) var(--space-1) var(--space-1); border-radius: var(--radius-pill); background: var(--surface-sunken); color: var(--muted); font-weight: 700; font-size: var(--text-sm); counter-increment: step; }
.steps li::before { content: counter(step); display: grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--surface); color: var(--muted); font-weight: 900; }
.steps li[aria-current="step"] { background: var(--accent-tint); color: var(--accent); }
.steps li[aria-current="step"]::before { background: var(--accent); color: var(--accent-text); }
.steps li.is-done { color: var(--text); }
.steps li.is-done::before { content: "✓"; background: var(--ok); color: var(--surface); }

/* Toolbar above a grid: filters on the left, a count or toggle on the right */
.toolbar { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--space-3) var(--space-4); }
.toolbar__group { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-3) var(--space-4); }
.toggle { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--control-h); font-weight: 700; }
.toggle input { width: 1.2rem; height: 1.2rem; accent-color: var(--accent); }

/* Rarity: the word, tinted */
.rarity { display: inline-flex; align-items: center; min-height: 1.4rem; padding: 0 var(--space-2); border-radius: var(--radius-sm); font-size: var(--text-xs); font-weight: 900; background: var(--surface-sunken); color: var(--text); white-space: nowrap; }
.rarity--mythic { background: var(--rarity-mythic); color: var(--rarity-mythic-ink); }
.rarity--rare { background: var(--rarity-rare); color: var(--rarity-rare-ink); }
.rarity--uncommon { background: var(--rarity-uncommon); color: var(--rarity-uncommon-ink); }

/* Spreadsheet-style quantity grid: a borderless number input fills each cell. Type, Tab, type. */
.grid-table td.cell { padding: 0; width: 6rem; border-left: 1px solid var(--border); }
.grid-table th.group { text-align: center; border-left: 1px solid var(--border); }
.grid-table th.cell-head { border-left: 1px solid var(--border); }
.cell-input {
  display: block; width: 100%; height: 2.67rem; padding: 0 var(--space-3); text-align: right;
  font: 700 var(--text-md) var(--font-sans); font-variant-numeric: tabular-nums; color: var(--text);
  background: transparent; border: 0; border-radius: 0;
}
.cell-input::placeholder { color: var(--border-strong); font-weight: 400; }
.cell-input:not(:placeholder-shown) { background: var(--ok-tint); }
.cell-input:focus { outline: 3px solid var(--focus); outline-offset: -3px; background: var(--surface); }
.cell-input--check, .cell-input--check:not(:placeholder-shown) { background: var(--warn-tint); box-shadow: inset 0 0 0 3px var(--warn); }
.cell-none { display: block; text-align: center; color: var(--muted); font-size: var(--text-sm); }
.cell-price { font-size: var(--text-sm); color: var(--muted); }

/* Card preview: the focused row's card, beside the grid */
.preview { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.preview__name { font-size: var(--text-lg); font-weight: 900; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-1) var(--space-3); margin: 0; font-size: var(--text-sm); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

/* A row of small stats */
.stats { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-4); }
.stat--warn .stat__value { color: var(--warn-text); }

/* Progress: a real <progress> element (no inline widths, so it works under the CSP) */
.progress { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 0.89rem; border: 0; border-radius: var(--radius-pill); background: var(--surface-sunken); overflow: hidden; }
.progress::-webkit-progress-bar { background: var(--surface-sunken); border-radius: var(--radius-pill); }
.progress::-webkit-progress-value { background: var(--accent); border-radius: var(--radius-pill); }
.progress::-moz-progress-bar { background: var(--accent); border-radius: var(--radius-pill); }
.progress--ok::-webkit-progress-value { background: var(--ok); }
.progress--ok::-moz-progress-bar { background: var(--ok); }
.job { display: grid; gap: var(--space-3); padding: var(--space-5); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.job__title { font: 900 var(--text-xl)/1.1 var(--font-display); text-transform: uppercase; }
.job__row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-2) var(--space-4); }
.job--failed { background: var(--error-tint); border-color: var(--error); }
.job--failed .job__title { color: var(--error); }

/* Look Up: the card at the top */
.card-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-5); align-items: start; padding: var(--space-5); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.card-head__body { display: grid; gap: var(--space-2); align-content: start; justify-items: start; }
.card-head__name { font: 900 var(--text-2xl)/1.05 var(--font-sans); overflow-wrap: anywhere; }
.card-head__meta { color: var(--muted); }
.card-head__tags { display: flex; flex-wrap: wrap; gap: var(--space-2); }
/* The card's figures: one row of labelled stats under the name, so every rule lines up */
.card-head__stats { margin: var(--space-2) 0; }
/* Item details: read-only facts in a few labelled groups */
.details-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: var(--space-4) var(--space-5); }
.details-grid__title { margin: 0 0 var(--space-2); font-size: var(--text-sm); font-weight: 900; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.details-grid .facts dd { font-weight: 400; overflow-wrap: anywhere; }

/* A person in a table or list: small avatar in their staff color + name */
.person { display: inline-flex; align-items: center; gap: var(--space-2); white-space: nowrap; }
.person__avatar { display: grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; font-size: 0.67rem; font-weight: 900; }
.person__avatar--system { background: var(--surface-sunken); color: var(--muted); }
.person__avatar svg { width: 1rem; height: 1rem; }

/* Stock changes: always a sign, not color alone */
.delta { font-weight: 900; font-variant-numeric: tabular-nums; }
.delta--up { color: var(--ok); }
.delta--down { color: var(--error); }
/* A pinned price: the nightly run leaves it alone */
.pinned { display: inline-flex; vertical-align: -0.15em; margin-right: var(--space-1); color: var(--muted); }
.pinned svg { width: 0.95rem; height: 0.95rem; }

/* Long tables (Current Inventory): the page scrolls and the header row sticks to the top of the window */
.table-wrap--page { overflow: clip; }
@media (max-width: 1100px) { .table-wrap--page { overflow: auto; } }
.table .group-start { border-left: 1px solid var(--border); }
.set-code { font-weight: 900; letter-spacing: 0.04em; }

/* Number inputs for counts in dialogs */
.count-input { width: 7rem; text-align: right; font-weight: 900; font-size: var(--text-xl); font-variant-numeric: tabular-nums; }
.from-to { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-3) var(--space-4); }
.from-to__arrow { padding-bottom: var(--space-3); color: var(--muted); font-weight: 900; }

/* Drop a file: a real file input covering the whole box, so click, keyboard and drag all work */
.dropzone { position: relative; display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-6) var(--space-5); text-align: center; color: var(--muted); background: var(--surface); border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); cursor: pointer; }
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-tint); }
.dropzone:focus-within { border-color: var(--focus); box-shadow: var(--focus-ring); }
.dropzone input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone svg { width: 2.67rem; height: 2.67rem; color: var(--accent); }
.dropzone__title { font-size: var(--text-lg); font-weight: 900; color: var(--text); }

/* ---------- Admin: a shell that grows ----------
   The admin area has its own left navigation in labelled groups (To do, People, Settings…).
   New areas (catalog and product types, reports, more settings) are new groups or new links;
   no page needs to change. Counter screens stay in the top bar. */
/* The menu's white strip and its edge run the full height of the page, even
   when the page is short; the menu itself stays sticky as long pages scroll. */
.admin {
  display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); align-items: start;
  min-height: calc(100vh - 4rem);
  background: linear-gradient(to right, var(--surface) calc(15.5rem - 1px), var(--border) calc(15.5rem - 1px) 15.5rem, transparent 15.5rem);
}
/* A column at least as tall as the window below the top bar, so System Status (the foot) sits at the bottom. */
.side-nav { position: sticky; top: 0; max-height: 100vh; min-height: calc(100vh - 4rem); overflow: auto; display: flex; flex-direction: column; gap: var(--space-5); padding: var(--space-5) var(--space-3); background: var(--surface); border-right: 1px solid var(--border); }
.side-nav__group { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.side-nav__title { padding: 0 var(--space-3) var(--space-1); font-size: var(--text-xs); font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.side-nav__link { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-height: 2.44rem; padding: 0 var(--space-3); border-radius: var(--radius); color: var(--text); font-weight: 700; text-decoration: none; }
.side-nav__link:hover { background: var(--bg); color: var(--text); }
.side-nav__link[aria-current="page"] { background: var(--accent-tint); color: var(--accent); }
.side-nav__link .count { margin-left: auto; }
/* A link BCW rarely needs (System Status): smaller and grey, below a rule; a count still shows in its warning colour. */
.side-nav__foot { margin-top: auto; padding-top: var(--space-3); border-top: 1px solid var(--border); }
.side-nav__link--quiet { min-height: 2rem; font-size: var(--text-sm); font-weight: 600; color: var(--muted); }
.admin__main { min-width: 0; width: 100%; } /* .page centres itself with auto margins, which in this grid would shrink it to its content */
@media (max-width: 900px) {
  .admin { grid-template-columns: 1fr; min-height: 0; background: none; }
  .side-nav { position: static; max-height: none; min-height: 0; display: grid; border-right: 0; border-bottom: 1px solid var(--border); grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); }
}
/* Mockup only: where future areas go */
.side-nav__later { padding: var(--space-3); border: 1.5px dashed var(--border-strong); border-radius: var(--radius); font-size: var(--text-sm); color: var(--muted); }
.side-nav__later strong { color: var(--text); }

/* Overview tiles: one per thing to watch; a tile can link to its page */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: var(--space-4); }
.tile { display: grid; gap: var(--space-2); align-content: start; padding: var(--space-4) var(--space-5); color: var(--text); text-decoration: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
a.tile:hover { border-color: var(--accent); color: var(--text); }
.tile__label { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.tile__value { font: 900 var(--text-2xl)/1 var(--font-display); font-variant-numeric: tabular-nums; }
.tile__detail { font-size: var(--text-sm); color: var(--muted); }
.tile--warn .tile__value { color: var(--warn-text); }
.tile--ok .tile__value { color: var(--ok); }

/* Settings pages: sections with the explanation on the left and the fields on the right */
.settings-section { display: grid; grid-template-columns: minmax(13rem, 21rem) minmax(0, 1fr); gap: var(--space-4) var(--space-6); padding: var(--space-5) 0; border-top: 1px solid var(--border); }
.settings-section__intro { display: grid; gap: var(--space-2); align-content: start; }
.settings-section__intro p { margin: 0; color: var(--muted); font-size: var(--text-sm); }
.settings-section__body { display: grid; gap: var(--space-3); align-content: start; min-width: 0; }
.settings-section__body > .table-wrap { max-width: 40rem; }
@media (max-width: 1000px) { .settings-section { grid-template-columns: 1fr; } }
.input--pct { width: 6rem; text-align: right; font-variant-numeric: tabular-nums; }
/* A rule written as a sentence with the numbers in it: "Stop if the price data is older than [36] hours." */
.rule-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: 0; }
.rule-line .input { width: 6.5rem; min-height: var(--control-h-sm); text-align: right; font-variant-numeric: tabular-nums; }
.rule-list { display: grid; gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
.table .input--pct { display: inline-block; margin-left: auto; }
/* Unsaved changes: a bar that stays at the bottom of the window */
.save-bar { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3) var(--space-4); padding: var(--space-3) var(--space-5); background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); }
.save-bar__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }

/* Color choice for a person: 12 swatches as radio buttons */
.swatches { display: flex; flex-wrap: wrap; gap: var(--space-2); border: 0; margin: 0; padding: 0; }
.swatches legend { padding: 0; margin-bottom: var(--space-1); font-weight: 700; font-size: var(--text-sm); }
.swatch { position: relative; }
.swatch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.swatch span { display: grid; place-items: center; width: 2.44rem; height: 2.44rem; border-radius: 50%; font-size: var(--text-xs); font-weight: 900; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px transparent; }
.swatch input:checked + span { box-shadow: 0 0 0 2px var(--surface), 0 0 0 5px var(--text); }
.swatch input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 4px; }
/* Your color: who else has each one, under it */
.swatches--named { gap: var(--space-3) var(--space-2); }
.swatches--named .swatch { display: grid; justify-items: center; gap: var(--space-1); width: 3rem; }
.swatch__taken { min-height: 1lh; font-size: var(--text-xs); color: var(--muted); text-align: center; overflow-wrap: anywhere; }

/* ---------- Highlights: one visual language ----------
   1. Status on a card or list item: an icon in a soft tinted circle (.icon-badge), plus a word. The card stays white.
   2. A message that needs action now (flash, scan result, done, failed job): tinted background + thin full border.
   3. Selected or current: accent tint + thin accent border.
   Never a thick colored edge. */
.icon-badge { display: inline-grid; place-items: center; flex: none; width: 2.22rem; height: 2.22rem; border-radius: 50%; color: var(--muted); background: var(--surface-sunken); }
.icon-badge svg { width: 1.2rem; height: 1.2rem; }
.icon-badge--sm { width: 1.56rem; height: 1.56rem; }
.icon-badge--sm svg { width: 0.95rem; height: 0.95rem; }
.icon-badge--warn { color: var(--warn-line); background: var(--warn-tint); }
.icon-badge--ok { color: var(--ok); background: var(--ok-tint); }
.icon-badge--error { color: var(--error); background: var(--error-tint); }
.icon-badge--accent { color: var(--accent); background: var(--accent-tint); }

/* ---------- Labels: DYMO 30336, 1 in × 2-1/8 in, black only (thermal) ----------
   Sized in real inches so the preview prints and measures true. Pure black on white:
   the printer has no grey, so nothing relies on tone. The padding keeps clear of
   the edges the DYMO driver can't print: about 0.06 in on the long edges and
   0.1 in at the ends (its printable area for this label, macOS driver). */
.label {
  box-sizing: border-box; width: 2.125in; height: 1in; padding: 0.07in 0.1in 0.09in;
  display: grid; grid-template-rows: auto auto 1fr auto; row-gap: 0.015in;
  background: #fff; color: #000; font-family: var(--font-sans); overflow: hidden;
  border-radius: 0.06in; box-shadow: 0 0 0 1px var(--border-strong), 0 2px 6px rgba(2, 20, 66, 0.15);
}
.label__name { font-size: 8.5pt; font-weight: 900; line-height: 1.1; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.label__name--long { font-size: 7pt; }
.label__meta { display: flex; align-items: center; gap: 0.04in; font-size: 6.5pt; font-weight: 700; line-height: 1.1; white-space: nowrap; overflow: hidden; }
.label__foil { padding: 0 0.03in; background: #000; color: #fff; font-weight: 900; letter-spacing: 0.04em; }
/* Quiet zone: Code 39 needs about 10 bar-widths of white each side */
.label__bars { display: block; width: calc(100% - 0.08in); height: 100%; min-height: 0.26in; margin: 0 0.04in; }
.label__foot { display: flex; justify-content: space-between; align-items: baseline; font-size: 6pt; line-height: 1; }
.label__code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-weight: 700; letter-spacing: 0.08em; }
.label__shop { font-weight: 900; letter-spacing: 0.04em; }
/* With a QR code for customers: QR on the left, the staff barcode (Code 128, narrower than Code 39) on the right */
.label--qr { grid-template-columns: 0.66in minmax(0, 1fr); grid-template-rows: 1fr; column-gap: 0.05in; padding: 0.07in 0.1in 0.09in; }
.label__qrcol { display: grid; align-content: center; justify-items: center; row-gap: 0.01in; }
.label__qr { display: block; width: 0.66in; height: 0.66in; }
.label__qrcap { font-size: 5pt; font-weight: 900; line-height: 1.05; text-align: center; letter-spacing: 0.02em; }
.label__main { display: grid; grid-template-rows: auto auto 1fr auto; row-gap: 0.015in; min-width: 0; }
.label--qr .label__name { font-size: 7.5pt; }
.label--qr .label__name--long { font-size: 6.5pt; }
.label--qr .label__shop { font-size: 5pt; }
/* Enlarged copy for checking detail on screen; the 1:1 copy is the true size */
.label-zoom { zoom: 2.6; }
.work__side .label-zoom { zoom: 1.55; }
.label-pair { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-5); }
.label-pair__cap { font-size: var(--text-xs); color: var(--muted); }
.label-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: var(--space-5) var(--space-4); }
.label-gallery figure { margin: 0; display: grid; gap: var(--space-2); justify-items: start; }
.label-gallery figcaption { font-size: var(--text-sm); color: var(--muted); }

/* Printer status chip */
.printer { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); font-weight: 700; }
.printer svg { width: 1.11rem; height: 1.11rem; }
.printer--ok { color: var(--ok); }
.printer--error { color: var(--error); }
.steps-list { margin: 0; padding-left: 1.4em; display: grid; gap: var(--space-2); }
/* A list of radio choices as rows (which stock item to label) */
.choice-rows { display: grid; gap: var(--space-2); margin: 0; padding: 0; border: 0; }
.choice-rows ul { display: grid; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.choice-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; }
.choice-row input { width: 1.2rem; height: 1.2rem; margin: 0; accent-color: var(--accent); }
.choice-row .muted { margin-left: auto; }
.choice-row:hover { border-color: var(--border-strong); }
.choice-row:has(input:checked) { background: var(--accent-tint); border-color: var(--accent); }

/* ---------- Home: the tools, grouped by job ----------
   Driven by a list (name, path, description, group, icon, who can see it), so a new tool
   is one more entry. Sell and Buy are the big ones; everything is a link. */
.home-greeting { display: grid; gap: var(--space-1); }
.tool-group { display: grid; gap: var(--space-3); }
.tool-group__title { font-size: var(--text-sm); font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: var(--space-4); margin: 0; padding: 0; list-style: none; }
.tools--primary { grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); }
.tool {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--space-2) var(--space-4); height: 100%;
  padding: var(--space-4) var(--space-5); color: var(--text); text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.tool:hover { border-color: var(--accent); color: var(--text); }
.tool:hover .tool__name { color: var(--accent); }
.tool:focus-visible { outline: none; box-shadow: var(--focus-ring); border-color: var(--focus); }
.tool__text { display: grid; gap: var(--space-1); min-width: 0; }
.tool__name { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-lg); font-weight: 900; }
.tool__desc { font-size: var(--text-sm); color: var(--muted); }
.tool .icon-badge { width: 3.11rem; height: 3.11rem; }
.tool .icon-badge svg { width: 1.56rem; height: 1.56rem; }
.tool--primary { padding: var(--space-5) var(--space-6); }
.tool--primary .tool__name { font: 900 var(--text-2xl)/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.01em; }
.tool--primary .tool__desc { font-size: var(--text-md); }
.tool--primary .icon-badge { width: 4rem; height: 4rem; }
.tool--primary .icon-badge svg { width: 2rem; height: 2rem; }
/* Unfinished work on this device: one line, one button */
.resume { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3) var(--space-4); padding: var(--space-4) var(--space-5); background: var(--accent-tint); border: 1px solid var(--accent); border-radius: var(--radius-lg); }
.resume__text { display: flex; align-items: center; gap: var(--space-3); }
/* A quiet line of system status at the foot of Home */
.status-line { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); font-size: var(--text-sm); color: var(--muted); }
.status-line span { display: inline-flex; align-items: center; gap: var(--space-2); }
.status-line svg { width: 1rem; height: 1rem; }

/* ---------- Line lists (Buy, Sell): dense but calm ----------
   Two text lines per row at most: the card name, then set · number · condition with any flags
   (FOIL, a non-English language, "needs a price") on the same line. No stacked warnings, no
   separate Details column, a compact stepper. The header row and the totals row stay in view. */
.table--lines td { padding: var(--space-1) var(--space-3); }
.table--lines thead th { top: 0; }
.table--lines tfoot td { position: sticky; bottom: 0; z-index: 1; background: var(--surface); box-shadow: 0 -1px 0 var(--border); }
.line-card { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: var(--space-3); min-width: 0; }
.line-card .thumb { width: 1.39rem; }
.line-card__name { font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.line-card__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--space-2); font-size: var(--text-sm); line-height: 1.3; color: var(--muted); }
.line-card__meta .tag { min-height: 1.1rem; font-size: 0.72rem; }
.line-card__flag { display: inline-flex; align-items: center; gap: 0.25em; color: var(--warn-text); font-weight: 700; }
.line-card__flag svg { width: 0.9rem; height: 0.9rem; color: var(--warn-line); }
/* The [− n +] stepper, sized to the row; the Qty header, steppers and footer count share one centered column */
.table--lines .qty { height: 2rem; }
.table--lines .qty button { width: 1.75rem; font-size: var(--text-md); }
.table--lines .qty input { width: 2.5rem; }
.table--lines .col-qty { text-align: center; font-variant-numeric: tabular-nums; }
.table--lines .input--money { width: 6rem; min-height: 2rem; }
.is-warn .input--money { border-color: var(--warn); }
/* A one-click fix on the line itself ("Set to 1"): a small text button, so the row stays two lines */
.line-card__fix { padding: 0 var(--space-2); min-height: 1.4rem; font: 700 var(--text-sm) var(--font-sans); color: var(--accent); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer; }
.line-card__fix:hover { border-color: var(--accent); background: var(--accent-tint); }
.table--lines .button--icon { width: 2rem; min-height: 2rem; }
/* The side panel (offer totals) stays in view while a long list scrolls */
.work__side--sticky { position: sticky; top: var(--space-4); align-self: flex-start; }

/* ---------- Empty, loading, error states ---------- */
.empty { display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-7) var(--space-5); text-align: center; color: var(--muted); border: 2px dashed var(--border); border-radius: var(--radius-lg); }
.empty__title { font-size: var(--text-lg); font-weight: 700; color: var(--text); }
.empty svg { width: 2.67rem; height: 2.67rem; }
.skeleton { display: block; height: 1em; border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--surface-sunken) 0%, var(--bg) 50%, var(--surface-sunken) 100%); background-size: 200% 100%; animation: skeleton 1.2s linear infinite; }
.skeleton--thumb { width: 2.22rem; height: 3.1rem; }
.skeleton--long { width: 14rem; }
.skeleton--medium { width: 10rem; }
@keyframes skeleton { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* ---------- Keyboard map ---------- */
.keymap { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-2) var(--space-4); margin: 0; font-size: var(--text-sm); }
.keymap dt { text-align: right; }
.keymap dd { margin: 0; }

/* ---------- Home: list of screens (existing) ---------- */
.screens { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); }
.screen { display: grid; gap: var(--space-1); align-content: start; padding: var(--space-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.screen__name { font-weight: 900; font-size: var(--text-lg); }
.screen__description { color: var(--muted); font-size: var(--text-sm); }
.screen__status { font-size: var(--text-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
a.screen__name { color: var(--link); }
.screen:has(a.screen__name):hover { border-color: var(--accent); }

/* ---------- Mockup-only helpers (not for the app) ---------- */
.mock-note { font-size: var(--text-sm); color: var(--muted); border-top: 1px dashed var(--border-strong); padding-top: var(--space-3); }
.state-label { font: 900 var(--text-sm) var(--font-sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.state-grid { display: grid; gap: var(--space-5); }
