/* =============================================================================
   BrickWise web app
   Reuses the design tokens from the marketing site (Website/index.html) so the
   app looks like the same product, then adds app layout.

   Responsive strategy: one markup tree, two layouts.
     - phone  (<= 1020px): bottom tab bar, single column, cards replace tables
     - desktop (> 1020px): inline top nav, multi-column grids, real tables
   Both breakpoints are measured fit points, not device classes:
     1160px  below this the row hands the account pill and the theme toggle to
             the header menu (see .app-head__in and .app-head__menu)
     1020px  below this the six nav links move to the bottom tab bar
   ========================================================================== */

:root {
  --bg: #F1F4F9; --bg-soft: #E7EBF2; --surface: #FFFFFF; --surface-2: #EDF1F7;
  --line: rgba(13, 20, 32, .10); --line-strong: rgba(13, 20, 32, .20);
  --ink: #0F1725; --ink-dim: #4B586C; --ink-faint: #7B8798;
  --brand: #1F49C7; --brand-lit: #3568E8; --brand-deep: #143393;
  --gold: #B8860B; --stud: #FFD500; --mint: #0E9F76; --danger: #C2382C; --warn: #96650A;
  --violet: #6B3FD4;
  --ok-soft: rgba(14, 159, 118, .12); --warn-soft: rgba(184, 134, 11, .14);
  --bad-soft: rgba(194, 56, 44, .12); --brand-soft: rgba(31, 73, 199, .10);
  --shadow-sm: 0 1px 2px rgba(13, 20, 32, .06);
  --shadow-md: 0 18px 40px -18px rgba(13, 20, 32, .30);
  --shadow-lg: 0 44px 80px -34px rgba(13, 20, 32, .40);
  --radius: 14px; --radius-sm: 9px; --shell: 1240px;
  --head-h: 64px; --nav-h: 62px;
  --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(.22, .61, .36, 1);
  color-scheme: light;
}

[data-theme=dark] {
  --bg: #0E1219; --bg-soft: #141A24; --surface: #171E2A; --surface-2: #1E2634;
  --line: rgba(255, 255, 255, .09); --line-strong: rgba(255, 255, 255, .17);
  --ink: #F1F5FB; --ink-dim: #A3AFC2; --ink-faint: #6E7A8C;
  --brand: #5A87FF; --brand-lit: #84AAFF; --brand-deep: #2C55D6;
  --gold: #FFD24A; --stud: #FFD24A; --mint: #2ED3A3; --danger: #F0685A; --warn: #E2A93B;
  --violet: #A98BFF;
  --ok-soft: rgba(46, 211, 163, .14); --warn-soft: rgba(255, 210, 74, .14);
  --bad-soft: rgba(240, 104, 90, .14); --brand-soft: rgba(90, 135, 255, .16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-md: 0 20px 44px -18px rgba(0, 0, 0, .75);
  --shadow-lg: 0 50px 90px -34px rgba(0, 0, 0, .85);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

/*
 * The UA stylesheet hides [hidden] with `display: none`, but any class rule that
 * sets a display value (.camera{display:grid}) overrides it and the element
 * reappears. Views rely on [hidden] for panel switching, so make it win.
 */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  /* Prices and part numbers sit in columns, so the figures must align. */
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
}

h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -.028em; line-height: 1.1; margin: 0; }
a { color: inherit; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
code.code--wrap { white-space: pre-wrap; word-break: break-all; display: inline-block; }

/* A catalogue image BrickLink has no file for is hidden rather than shown broken. */
.img--broken { visibility: hidden; }

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 8px; top: 8px; z-index: 200; background: var(--surface); padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line-strong); }
.muted { color: var(--ink-dim); margin: 4px 0 0; }
.faint { color: var(--ink-faint); font-size: .87em; }
.hint { color: var(--ink-faint); font-size: .85em; margin: 6px 0 0; }
.row { display: flex; gap: 10px; align-items: center; }
.row--wrap { flex-wrap: wrap; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/*
 * A PAIR OF FIELDS THAT SHARE ONE LINE ON A PHONE.
 *
 * "Item type" and "item number" are answered in one breath, and so are colour
 * and condition - yet each was a full-width row, which is most of why a phone
 * screen could not show one whole step at a time. display:contents makes the
 * wrapper vanish on a wide screen (the fields lay out exactly as they always
 * did), and only the narrow block turns it into two columns.
 */
.field-pair { display: contents; }

/* ============================ HEADER ============================ */

.app-head {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--line);
}
/*
 * THE ROW, AND THE ONE POLICY THAT KEEPS IT FROM CROWDING ITSELF.
 *
 * The row used to hold five things at once (brand, six nav links, the green Play
 * button, the account pill, the theme toggle) and no single breakpoint made them
 * all fit: measured, the pill-and-toggle pair needs 1061-1119px on its own, so
 * every threshold was a guess that a slightly longer guest name or a slightly
 * narrower window could beat - and when it did, the nav items or the Play label
 * drew straight through whatever sat next to them.
 *
 * So the row no longer tries. At or below 1160px it keeps the brand, the Play
 * button and the burger, and the account pill and the theme toggle move into the
 * menu (see .app-head__menu); above 1160px there is room for all five and they
 * stay where they are. `flex-wrap` is the belt to that braces: in the one case
 * this reasoning could still miss - nothing can shrink any further - the row
 * wraps into two lines instead of painting one control over another.
 */
.app-head__in {
  --head-pad: 18px;
  position: relative; /* the menu anchors to this row's right edge */
  max-width: var(--shell); margin-inline: auto;
  padding: 10px var(--head-pad); min-height: var(--head-h);
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--font-display); font-weight: 700; font-size: 18px; flex: none; }
.brand__mark { width: 32px; height: 32px; flex: none; border-radius: 9px; object-fit: contain;
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }
.brand b span { color: var(--brand); }
[data-theme=dark] .brand b span { color: var(--brand-lit); }

.app-nav { display: flex; gap: 4px; margin-left: auto; }
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 13px; border-radius: 11px; text-decoration: none;
  color: var(--ink-dim); font-size: 14.5px; font-weight: 500;
  transition: .18s var(--ease);
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 7%, transparent); }
.nav-item.is-on { color: var(--ink); background: var(--brand-soft); }

.app-head__tools { display: flex; align-items: center; gap: 8px; flex: none; }

/*
 * The green Play-Store button in the app header. On the narrowest phones it
 * shrinks to an icon-only tile so the brand keeps its room; everywhere else the
 * label and the mark both show, which is now possible because the account pill
 * and the theme toggle are in the menu out of the row's way.
 *
 * SCOPED TO .app-head__tools ON PURPOSE. This button also carries .btn and
 * .btn-sm, and .btn-sm is defined LATER in this file with the same specificity -
 * so a bare `.app-head__android` rule loses the cascade: it can set width, but
 * its padding and font-size are overwritten by .btn-sm's. That is exactly what
 * broke the icon-only state: the tile was 34px wide but still drew its 13.5px
 * label, which then spilled out of the box on BOTH sides - across "BrickWise"
 * on the left and across the account pill on the right, so the header looked
 * like three controls on top of each other. One extra class in the selector
 * (0,2,0) puts these rules back in charge of their own padding and font-size.
 */
.app-head__tools .app-head__android { padding: 7px 12px; border-radius: 9px; font-size: 12.5px; color: #fff; text-decoration: none; }
.app-head__tools .app-head__android:before { width: 14px; height: 14px; }

/*
 * HOW MUCH HEADER EACH FORM OF THIS BUTTON NEEDS (measured, not estimated).
 *
 *   icon-only tile                     ~262px   brand + tile + burger
 *   icon + text label (>= 461px)       ~348px   brand + labelled button + burger
 *   icon + text label, wide row        ~1005px  brand + six nav links + label + burger
 *
 * The wide number is the one that matters, and it is why the label can now stay
 * on: with the pill and the theme toggle in the menu, the desktop row needs about
 * 1005px, and the desktop row only exists from 1021px (below that the nav is the
 * bottom bar and the same row needs about 348px). The icon-only tile therefore
 * survives only where a phone is genuinely too narrow for the words - 460px - and
 * never on a tablet or desktop, where the tile used to leave a bare green square
 * with nothing to identify it. title and aria-label are unchanged either way.
 */
@media (max-width: 460px) {
  .app-head__tools .app-head__android { padding: 7px; width: 34px; font-size: 0; }
  .app-head__tools .app-head__android:before { width: 16px; height: 16px; }
}


.status-pill {
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink-dim); font: inherit; font-size: 13px; font-weight: 600;
  padding: 7px 12px; border-radius: 999px; cursor: default; white-space: nowrap;
}
.status-pill--off { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: var(--bad-soft); }
/* The pill is the guest account now: this browser's display name, clickable to
   start fresh. Server capacity numbers are admin information and have no pill. */
.status-pill--account {
  cursor: pointer; color: var(--brand);
  border-color: color-mix(in srgb, var(--brand) 38%, transparent); background: var(--brand-soft);
  /* A guest name is two words, but it is SERVER-CHOSEN and unbounded in length:
     without a ceiling a long one widened the header (and the top row's fit
     point) past the viewport. Truncate instead of pushing the theme toggle off
     the screen. */
  max-width: 150px; overflow: hidden; text-overflow: ellipsis;
  transition: .16s var(--ease);
}
.status-pill--account:hover { background: color-mix(in srgb, var(--brand) 18%, transparent); }
[data-theme=dark] .status-pill--account { color: var(--brand-lit); border-color: color-mix(in srgb, var(--brand-lit) 34%, transparent); }

.icon-btn {
  width: 38px; height: 38px; border-radius: 11px;
  border: 1px solid var(--line-strong); background: color-mix(in srgb, var(--ink) 4%, transparent);
  color: var(--ink); display: grid; place-items: center; cursor: pointer;
  transition: .2s var(--ease); flex: none;
}
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 9%, transparent); }
.icon-moon { display: none; }
[data-theme=dark] .icon-moon { display: block; }
[data-theme=dark] .icon-sun { display: none; }

/* ============================ HEADER MENU ============================ */

/*
 * THE BURGER, AND THE PANEL IT OPENS.
 *
 * 1160px is the width below which the row hands the account pill and the theme
 * toggle over to this panel (see .app-head__in). main.js moves the two controls
 * at exactly the same number - if you change it here, change it there too.
 */
.head-burger { display: none; }
.head-burger .burger-x { display: none; }
.head-burger[aria-expanded="true"] .burger-bars { display: none; }
.head-burger[aria-expanded="true"] .burger-x { display: block; }

.app-head__menu {
  position: absolute; top: calc(100% - 6px); right: var(--head-pad);
  z-index: 60; width: 262px; max-width: calc(100vw - 2 * var(--head-pad));
  padding: 12px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-md);
}
.head-menu__group {
  margin: 0 0 6px; font-size: 11px; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase; color: var(--ink-faint);
}
.head-menu__group:not(:first-child) { margin-top: 14px; }
.head-menu__hint { margin: 6px 0 0; font-size: 11.5px; line-height: 1.45; color: var(--ink-faint); }
.head-menu__slot:empty { display: none; }

/* The two controls, restyled as menu rows. Both keep their own id and handler -
   they are the same elements the wide row shows, just in their menu clothes. */
.app-head__menu .status-pill--account {
  display: block; width: 100%; max-width: none; text-align: left;
  padding: 9px 12px; border-radius: 10px; font-size: 13.5px;
}
.app-head__menu .icon-btn {
  display: flex; align-items: center; justify-content: flex-start; gap: 9px;
  width: 100%; height: auto; padding: 9px 12px; border-radius: 10px;
  font-size: 13.5px; font-weight: 600;
}
/* The word only has room inside the menu; in the row the tile alone says it. */
.icon-btn__label { display: none; }
.app-head__menu .icon-btn__label { display: inline; }
.lbl-sw-light { display: none; }
[data-theme=dark] .lbl-sw-light { display: inline; }
[data-theme=dark] .lbl-sw-dark { display: none; }

@media (max-width: 1160px) {
  .head-burger { display: grid; }
}

/* ============================ LAYOUT ============================ */

.view-root {
  max-width: var(--shell); margin-inline: auto;
  padding: 22px 18px 40px;
  display: block; min-height: 40vh;
}
.app-foot { border-top: 1px solid var(--line); margin-top: 20px; }
.app-foot__in {
  max-width: var(--shell); margin-inline: auto; padding: 20px 18px 34px;
  display: flex; flex-wrap: wrap; gap: 10px 20px;
  color: var(--ink-faint); font-size: 13.5px;
}
.app-foot__links { display: flex; flex-wrap: wrap; gap: 14px; margin-left: auto; }
.app-foot__links a { text-decoration: none; }
.app-foot__links a:hover { color: var(--ink); }
.noscript { margin: 20px; padding: 16px; border-radius: 12px; background: var(--warn-soft); }

.view__head { margin-bottom: 18px; }
.view__head h2 { font-size: clamp(1.4rem, 1.1rem + 1.6vw, 2rem); }
.view__head--hero h2 { font-size: clamp(1.7rem, 1.2rem + 2.6vw, 2.5rem); }

/* ============================ CARDS ============================ */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px; box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

/* Review windows (batch + bucket) tighten up further: rows carry their own
   padding, so card padding on top of it just adds dead space. */
.view--scan .card[data-slot="batch-card"] { padding: 12px; }

.bucket-row__actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.bucket-row__actions .faint { font-size: 12.5px; }
.icon-btn--sm { width: 30px; height: 30px; border-radius: 9px; }
.icon-btn--sm svg { pointer-events: none; }
.card--muted { background: var(--surface-2); }
.card__title {
  font-size: 1.02rem; font-weight: 600; margin-bottom: 12px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}

.scan-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.scan-grid > .card { margin-bottom: 0; }

/* ============================ FORMS ============================ */

.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field--grow { flex: 1; }
.field > label { font-size: 13px; font-weight: 600; color: var(--ink-dim); }

input[type=text], input[type=url], input[type=number], input[type=search],
input[type=password], select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; font-size: 15px;
  color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line-strong); border-radius: 10px;
  transition: .16s var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--brand) 45%, transparent);
  outline-offset: 1px; border-color: var(--brand);
}
input[type=number] { max-width: 130px; }

.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-dim); cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); }
.check--sm { font-size: 12.5px; gap: 6px; }

.segmented { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; }
.segment {
  border: 0; background: transparent; color: var(--ink-dim); font: inherit; font-size: 14px;
  padding: 8px 16px; border-radius: 9px; cursor: pointer;
}
.segment.is-on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }

/*
 * Filter chip, like the app's FilterChip: a pill that toggles one option
 * (Group by type, Only staged changes). Used instead of a bare checkbox in
 * toolbars so a toggle reads as a control, matching the reference design.
 */
.chip {
  border: 1px solid transparent; background: color-mix(in srgb, var(--ink) 5%, transparent);
  color: var(--ink-dim); font: inherit; font-size: 14px; font-weight: 500;
  padding: 8px 14px; border-radius: 999px; cursor: pointer; transition: .16s var(--ease);
  white-space: nowrap;
}
.chip:hover:not(:disabled) { color: var(--ink); background: color-mix(in srgb, var(--ink) 9%, transparent); }
.chip:disabled { opacity: .45; cursor: not-allowed; }
.chip--on { background: var(--brand-soft); color: var(--ink); border-color: color-mix(in srgb, var(--brand) 30%, transparent); font-weight: 600; }
.chip--on:hover:not(:disabled) { background: var(--brand-soft); }

.tabs { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  border: 1px solid transparent; background: color-mix(in srgb, var(--ink) 5%, transparent);
  color: var(--ink-dim); font: inherit; font-size: 14px; font-weight: 500;
  padding: 8px 14px; border-radius: 999px; cursor: pointer; transition: .16s var(--ease);
}
.tab.is-on { background: var(--brand-soft); color: var(--ink); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }

/* ============================ BUTTONS ============================ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 11px; font: inherit; font-size: 14.5px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; transition: .18s var(--ease); white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-lit); }
[data-theme=dark] .btn-primary { color: #0B0F16; }
.btn-ghost { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 11%, transparent); }
.btn-danger { background: var(--bad-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 32%, transparent); }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 20%, transparent); }
.btn-sm { padding: 7px 12px; font-size: 13.5px; border-radius: 9px; }
/* Play Store green - shared with the landing pages' site.css (same class, same
   mask file), so the app header button and the site buttons look identical. */
.btn-android { background: #34A853; color: #fff; }
/* The dark themes' global ink overrides must not grey the label out. */
[data-theme=dark] .btn-android { color: #fff; }
/*
  The Google Play mark. It used to be a hand-drawn path pasted inline here (and
  again in site.css), which at button size read as a deformed blob. It is one
  FILE now - ../play-store.svg, outside /app so the landing pages and the app
  share the identical mark instead of two copies that can drift.
*/
.btn-android:before { content: ""; width: 16px; height: 16px; flex: none;
  -webkit-mask: url("../play-store.svg") center/contain no-repeat;
  mask: url("../play-store.svg") center/contain no-repeat;
  background: #fff; }
.btn-android:hover { filter: brightness(1.06); }
.link-btn { border: 0; background: none; color: var(--brand); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 2px 4px; }
[data-theme=dark] .link-btn { color: var(--brand-lit); }

/*
 * Primary inline link: bold, in the accent colour, underlined. Used for the one
 * link inside a hint that the seller is expected to click (e.g. BrickLink's API
 * settings page), so it reads as a control rather than as part of the sentence.
 */
.primary-link { color: var(--brand); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.primary-link:hover { color: var(--brand-deep); }
[data-theme=dark] .primary-link { color: var(--brand-lit); }
[data-theme=dark] .primary-link:hover { color: var(--brand); }

.toolbar { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin: 12px 0; }
.toolbar--filters { align-items: end; }
.toolbar--filters .field { margin-bottom: 0; min-width: 180px; }

/*
 * The search field grows to take spare space, but no further: enough room to
 * type a number, while Sort/Group/Expand and the export buttons stay on the
 * same line instead of wrapping onto their own.
 */
.field--search { max-width: 320px; }

/* ============================ BADGES / ALERTS ============================ */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink-dim);
  border: 1px solid var(--line);
}
.badge--ok { background: var(--ok-soft); color: var(--mint); border-color: transparent; }
.badge--warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge--bad { background: var(--bad-soft); color: var(--danger); border-color: transparent; }
.badge--brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
[data-theme=dark] .badge--brand { color: var(--brand-lit); }
.badge--unknown { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink-dim); border-color: transparent; }

/*
 * Price provenance chip. Deliberately the same idea as the app's price-source
 * icon: a yellow brick when the figure came live from BrickLink, a green globe
 * when it was served from the shared community catalogue.
 */
/*
 * Price provenance chip - ICON ONLY, like the app: a yellow brick when the figure
 * came live from BrickLink, a green globe when it was served from the shared
 * community catalogue. The wording lives in title/aria-label, not on screen.
 */
.src-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 999px; flex: none; cursor: help;
  background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink-dim);
}
.src-chip__ico { width: 15px; height: 15px; flex: none; }
.src-chip--bricklink { background: var(--warn-soft); color: var(--warn); }
.src-chip--community { background: var(--ok-soft); color: var(--mint); }

.alert { padding: 12px 14px; border-radius: 12px; margin: 10px 0; font-size: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.alert p { margin: 4px 0 0; }
.alert--error { background: var(--bad-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }
.alert--warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.alert--ok, .alert--info { background: var(--ok-soft); border-color: color-mix(in srgb, var(--mint) 28%, transparent); }

.empty { text-align: center; color: var(--ink-dim); padding: 26px 10px; }
.empty p { margin: 4px 0; }

.loading { display: flex; align-items: center; gap: 10px; color: var(--ink-dim); padding: 16px 4px; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  border: 2px solid color-mix(in srgb, var(--ink) 18%, transparent);
  border-top-color: var(--brand); animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================ STATS ============================ */

.stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 14px; }
.stat {
  flex: 1 1 130px; min-width: 120px; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 13px;
  display: grid; gap: 2px;
}
.stat--warn { background: var(--warn-soft); border-color: transparent; }
.stat__value { font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; }
.stat__label { font-size: 12.5px; color: var(--ink-dim); }

/* ============================ HOME ============================ */

.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 6px; }
/*
 * Each destination carries its own accent, because the arrow that used to mark
 * "this is clickable" is gone. The tint is mixed into the surface and the
 * border, and the heading takes the accent too, so the four cards read as four
 * different places rather than four copies of the same card.
 */
.quick {
  --accent: var(--brand);
  position: relative; text-align: left; display: grid; gap: 5px;
  padding: 18px; border-radius: var(--radius); cursor: pointer; font: inherit;
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line));
  color: var(--ink);
  box-shadow: var(--shadow-sm); transition: .2s var(--ease);
}
.quick:hover {
  transform: translateY(-2px); box-shadow: var(--shadow-md);
  background: color-mix(in srgb, var(--accent) 13%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
}
.quick strong { font-family: var(--font-display); font-size: 1.06rem; color: color-mix(in srgb, var(--accent) 74%, var(--ink)); }
/* The tinted surface costs the sub-line some contrast, so it steps up a level. */
.quick .faint { color: var(--ink-dim); }

.quick--scan { --accent: var(--brand); }
.quick--bucket { --accent: var(--mint); }
.quick--cmf { --accent: var(--gold); }
.quick--store { --accent: var(--violet); }

/* ============================ SCAN ============================ */

.dropzone {
  border: 2px dashed var(--line-strong); border-radius: var(--radius);
  padding: 22px 16px; text-align: center; background: var(--surface-2); transition: .18s var(--ease);
}
.dropzone.is-over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone p { margin: 4px 0 10px; }

/*
 * A FIXED-HEIGHT BOX, not a scaled image. `width: auto` let a landscape camera
 * photo grow wider than the card it sat in, so the preview spilled over the
 * neighbouring colour card; a square photo could grow to 260px tall the same
 * way. The photo is now contained inside a small box that can never overflow.
 */
.scan-preview { margin-top: 14px; display: grid; gap: 12px; }
.scan-preview img {
  display: block; width: 100%; height: 200px; object-fit: contain;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2);
}

.camera { display: grid; gap: 10px; margin-top: 12px; }
/* `contain`, not `cover`: cover cropped the piece out of the viewfinder. */
.camera video { width: 100%; max-width: 100%; max-height: 340px; border-radius: var(--radius-sm); background: #000; object-fit: contain; }
.camera__bar { display: flex; gap: 8px; flex-wrap: wrap; }

.candidates { display: grid; gap: 8px; margin-top: 14px; }
.candidate {
  display: flex; gap: 12px; align-items: center; text-align: left; width: 100%;
  padding: 11px 13px; border-radius: 12px; cursor: pointer; font: inherit; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line); transition: .16s var(--ease);
}
.candidate:hover { border-color: var(--brand); background: var(--brand-soft); }
.candidate__score { font-weight: 700; color: var(--brand); font-size: 13px; min-width: 38px; }
.candidate__main { display: grid; gap: 1px; }

.item-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.item-head__img { width: 84px; height: 84px; object-fit: contain; background: var(--surface-2); border-radius: 12px; border: 1px solid var(--line); flex: none; }
.item-head__name { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; margin: 0 0 2px; }

/* ============================ COLOUR PICKER ============================
   One swatch-aware dropdown for every colour field (single scan, batch rows,
   bucket rows). A native <select> cannot show a colour per option, and the old
   71-button grid crowded the row it sat in.
   The popup is absolutely positioned over the row it belongs to. */

.cselect { position: relative; display: inline-flex; min-width: 0; max-width: 190px; flex: 0 1 auto; }
/*
 * The "why is every colour listed?" affordance: a small ⓘ beside the trigger
 * whose title carries the explanation, so the reason is reachable on hover but
 * never permanently on screen. Only rendered when there IS something to explain
 * (`has-note`), so an ordinary colour field gains no chrome - and the trigger
 * keeps its own width budget, with the wrapper growing to fit the icon.
 */
.cselect.has-note { max-width: none; align-items: center; gap: 6px; }
.cselect.has-note .cselect__btn { flex: 0 1 auto; }
.cselect__info {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 21px; height: 21px; padding: 0; border-radius: 999px;
  border: 1px solid var(--line-strong); background: none;
  color: var(--ink-faint); cursor: help; transition: .16s var(--ease);
}
.cselect__info svg { width: 13px; height: 13px; }
.cselect__info:hover, .cselect__info:focus-visible {
  color: var(--ink); border-color: color-mix(in srgb, var(--brand) 45%, transparent);
}
.cselect__btn {
  display: inline-flex; align-items: center; gap: 7px; width: 100%;
  font: inherit; font-size: 13.5px; padding: 7px 9px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  cursor: pointer; transition: .16s var(--ease);
}
.cselect__btn:hover:not(:disabled) { border-color: color-mix(in srgb, var(--brand) 45%, transparent); }
.cselect__btn[aria-expanded="true"] { border-color: var(--brand); background: var(--brand-soft); }
.cselect.is-disabled .cselect__btn, .cselect__btn:disabled { opacity: .5; cursor: not-allowed; }
.cselect__dot {
  width: 13px; height: 13px; border-radius: 50%; flex: none;
  background: repeating-conic-gradient(var(--line-strong) 0% 25%, transparent 0% 50%) 50% / 8px 8px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .22);
}
.cselect__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cselect__caret { width: 12px; height: 12px; flex: none; margin-left: auto; color: var(--ink-faint); }
/*
 * FIXED, not absolute. The rows this menu lives in set `overflow: hidden`, which
 * clipped an absolutely-positioned popup to a sliver and made the row jump when
 * the search box took focus. Coordinates are set by place() in colour.js.
 * Sits above the sticky header (z-index 40) but below modals (100) and toasts
 * (120), so it never covers a dialog.
 */
.cselect__menu {
  position: fixed; z-index: 90; top: 0; left: 0;
  width: min(264px, calc(100vw - 16px));
  max-height: min(400px, calc(100vh - 24px));
  padding: 8px; display: grid; gap: 6px; grid-auto-rows: min-content; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 13px; box-shadow: var(--shadow-md);
}
.cselect__search { font-size: 13.5px; padding: 7px 9px; border-radius: 9px; }
.cselect__list { max-height: min(232px, 46vh); min-height: 0; overflow: auto; display: grid; gap: 1px; }
.cselect__opt {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  font: inherit; font-size: 13.5px; padding: 6px 8px; border-radius: 8px;
  border: 0; background: none; color: var(--ink); cursor: pointer;
}
.cselect__opt:hover { background: var(--surface-2); }
.cselect__opt.is-on { background: var(--brand-soft); font-weight: 600; }
.cselect__opt .cselect__dot { flex: none; }
.cselect__empty { margin: 4px 6px; color: var(--ink-faint); font-size: 13px; }
/* The "show all colours" escape: a quiet footer action, so a normal list never
   looks like it is missing something, but a wrong one is one click from fixed. */
.cselect__more { border-top: 1px solid var(--line); padding-top: 6px; }
.cselect__more-btn {
  width: 100%; text-align: left; font: inherit; font-size: 12.5px; line-height: 1.35;
  padding: 5px 8px; border-radius: 8px; border: 0; cursor: pointer;
  background: none; color: var(--brand);
}
.cselect__more-btn:hover { background: var(--brand-soft); }

/* Thumbnails of the photos chosen for a batch run, shown before identifying.
   The strip carries the gap on BOTH sides: the Identify button that follows it
   used to touch the thumbnails. */
.photo-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.photo-strip img {
  width: 62px; height: 62px; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2);
}

.guide-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.guide-head__price { font-family: var(--font-display); font-size: 1.8rem; font-weight: 700; }
.guide-head__flags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
/*
 * PADDING IS THE POINT. The figures used to sit 6px apart with the selected
 * cell's underline drawn from a negative margin, so the highlight ran into the
 * next number. Column gap and cell padding now keep every figure in its own
 * box, and the selection is a tinted pill rather than a bare rule.
 */
.guide-table { display: grid; gap: 3px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.guide-row { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: 12px; padding: 11px 14px; background: var(--surface-2); font-size: 14px; }
.guide-row:nth-child(odd) { background: var(--surface); }
/* Column headings stay in sentence case: the values are already short, and
   tracked-out capitals are harder to read than they are impressive. */
.guide-row--head { font-size: 12px; font-weight: 600; color: var(--ink-faint); }
.guide-row__label { color: var(--ink-dim); }

/* A guide figure you can tap to adopt as your own price. Styled as text so the
   table still reads as a table, but with a real hit area and hover/focus states. */
.guide-cell {
  border: 0; background: none; font: inherit; color: inherit;
  padding: 6px 8px; margin: 0; border-radius: 8px;
  text-align: left; cursor: pointer; transition: background .15s var(--ease), color .15s var(--ease);
}
.guide-cell:hover:not(:disabled) { background: var(--brand-soft); color: var(--brand); }
.guide-cell:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
/* Chosen figure: colour, weight AND a tinted background, so the selection reads
   at a glance instead of relying on a 2px rule that could touch its neighbour. */
.guide-cell.is-on { color: var(--brand); font-weight: 700; background: var(--brand-soft); box-shadow: inset 0 -2px 0 var(--brand); }
[data-theme=dark] .guide-cell.is-on { color: var(--brand-lit); background: var(--brand-soft); box-shadow: inset 0 -2px 0 var(--brand-lit); }
.guide-cell:disabled { color: var(--ink-faint); cursor: default; }

/*
 * Everything UNDER the guide in a single scan: four controls of identical size
 * in one 2x2 grid, then three actions of identical width. They used to be two
 * separately-sized two-up rows plus a button row whose members sized to their
 * own labels, which read as four unrelated scraps.
 */
.guide-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; margin-top: 14px; }
.guide-controls .field { margin-bottom: 0; }
/* The global 130px cap on number inputs is what made "Your price" narrower
   than the selects beside it; inside this card every field fills its cell. */
.guide-controls input[type=number] { max-width: none; width: 100%; }
/* Selects and number inputs report different intrinsic heights (43 vs 46 here),
   which is exactly the "all different sizes" complaint - pin them together. */
.guide-controls .field input,
.guide-controls .field select { height: 46px; }
/*
 * Stacked, not side by side. This card is one column of a three-up grid, so
 * three equal buttons would get ~80px each and "Use suggested A$0.14" would
 * not fit in any of them. Full-width and equal is the only layout that is
 * symmetrical AND readable at this width - on every screen size.
 */
.price-actions { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 14px; }
.price-actions .btn { width: 100%; min-width: 0; padding-inline: 10px; font-size: 14px; }
.guide-pill { display: inline-block; padding: 3px 9px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-weight: 600; font-size: 13px; }
[data-theme=dark] .guide-pill { color: var(--brand-lit); }

/* ============================ TABLES ============================ */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 720px; }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table thead th { font-size: 12.5px; font-weight: 600; color: var(--ink-faint); background: var(--surface-2); position: sticky; top: 0; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--ink) 3%, transparent); }
.data-table tr.is-edited { background: var(--warn-soft); }
.data-table tr.is-delete { background: var(--bad-soft); }
.data-table tr.is-blocked { background: color-mix(in srgb, var(--warn) 7%, transparent); }
.col-num { text-align: right; }
.col-num .cell-input { text-align: right; }
.col-actions { white-space: nowrap; }

.cell-item { display: flex; gap: 10px; align-items: center; }
.cell-item img { width: 42px; height: 42px; object-fit: contain; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); flex: none; }
.cell-item > span { display: grid; gap: 1px; }
.cell-note { display: block; font-size: 11.5px; color: var(--warn); }
.cell-input { padding: 6px 8px; font-size: 14px; max-width: 104px; }
.cell-input--text { max-width: 100%; min-width: 120px; }
.cell-input.is-staged { border-color: var(--gold); background: var(--warn-soft); box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 25%, transparent); }
.stack { display: grid; gap: 4px; justify-items: start; }

/* ============================ CMF ============================ */

.cmf-result { display: flex; gap: 14px; align-items: flex-start; }
.cmf-result__img { width: 96px; height: 96px; object-fit: contain; background: var(--surface-2); border-radius: 12px; border: 1px solid var(--line); flex: none; }
.cmf-result__name { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; margin: 0 0 2px; }

/*
 * Scan-first card: the big scan button is the primary action; manual entry and
 * photo decoding live under a collapsible "Other ways" so the first thing the
 * eye meets is what the seller usually wants, like the app's home screen.
 */
.card--scan .btn-primary { margin: 4px 0 10px; }

/*
 * The report card sits OUTSIDE the scan-grid, so it needs its own breathing
 * room: the grid above has no bottom margin, and the cards visually touched.
 */
.view--cmf .scan-grid { margin-bottom: 22px; }
.view--cmf [data-slot="cmf-report"] { margin-top: 0; }
.cmf-alt { margin-top: 4px; }
.cmf-alt summary {
  cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--ink-dim);
  padding: 7px 10px; border-radius: 10px; background: var(--surface-2);
  border: 1px solid var(--line); display: inline-block; user-select: none;
}
.cmf-alt summary:hover { color: var(--ink); }
.cmf-alt[open] { border: 0; }
.cmf-alt[open] summary { margin-bottom: 10px; }
.cmf-alt .form { margin-top: 10px; }

/* The missing-code report: deliberately its own, quieter card. */
.cmf-report__pic {
  display: flex; align-items: center; justify-content: center;
  min-height: 140px; border-radius: 12px; margin-bottom: 10px;
  background: var(--surface-2); border: 1px dashed var(--line);
  overflow: hidden;
}
.cmf-report__pic img { max-width: 100%; max-height: 240px; object-fit: contain; }

/* The not-found result links down to the report card. */
.card--scan [data-photo-status], [data-photo-status] { min-height: 1.2em; margin-top: 8px; }

/* Inline "add this one?" step: nothing is counted until it is confirmed. */
.cmf-confirm {
  margin-top: 10px; padding: 10px 12px; border-radius: 12px;
  background: var(--brand-soft); border: 1px solid var(--line);
}
.cmf-confirm p { margin: 0 0 8px; }

/* Create a list / Save list toggles - two lines of label plus a hint. */
.toggle-row { margin-bottom: 8px; }
.toggle { display: flex; gap: 11px; align-items: flex-start; cursor: pointer; padding: 9px 11px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.toggle input { margin: 2px 0 0; width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.toggle input:disabled { cursor: not-allowed; }
.toggle strong { display: block; font-weight: 600; }
.toggle em { display: block; font-style: normal; font-size: 12.5px; color: var(--ink-faint); margin-top: 1px; }

/* One series of the checklist. */
.list-section { margin-top: 12px; }
.list-section__head {
  display: flex; justify-content: space-between; gap: 10px; align-items: baseline;
  padding: 8px 11px; border-radius: 11px; margin-bottom: 9px;
  background: var(--surface-2); border: 1px solid var(--line);
}

/* The figure grid. Un-found cells stay visible but greyed, so the shape of the
   series - and how much of the box is left - is obvious at a glance. */
.figure-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.figure-cell { display: grid; gap: 3px; text-align: center; font-size: 12px; }
.figure-cell__art { position: relative; }
.figure-cell__art img, .figure-cell__ph {
  width: 100%; aspect-ratio: 1 / 1.25; object-fit: contain; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line);
  filter: grayscale(1); opacity: .55; padding: 3px;
}
.figure-cell.is-found .figure-cell__art img, .figure-cell.is-found .figure-cell__ph {
  filter: none; opacity: 1; border-color: var(--brand); background: var(--ok-soft);
}
.figure-cell__count {
  position: absolute; top: 4px; right: 4px;
  padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: var(--brand); color: #fff;
}
.figure-cell__name { color: var(--ink-faint); line-height: 1.25; }
.figure-cell.is-found .figure-cell__name { color: var(--ink); font-weight: 600; }

@media (max-width: 520px) {
  .figure-grid { grid-template-columns: repeat(3, 1fr); gap: 7px; }
}

/* ============================ MODAL / TOASTS ============================ */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(6, 8, 14, .58);
  backdrop-filter: blur(3px); display: grid; place-items: center; padding: 18px;
  overflow: auto;
}/* Generated BrickLink XML, shown in a modal for copy/paste. Monospace, scrolls
   inside its own box so a long inventory never stretches the dialog. */
.xml-code {
  width: 100%; margin: 12px 0 0; padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; line-height: 1.55; white-space: pre; overflow: auto;
  max-height: 44vh; resize: vertical;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 12px;
}
.modal--xml { max-width: min(760px, 94vw); }

.modal { 
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); width: min(680px, 100%); max-height: 88vh; overflow: auto;
}
.modal--sm { width: min(460px, 100%); }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.modal__title { font-size: 1.06rem; }
.modal__body { padding: 18px; }
.modal__message { margin-top: 0; }
.modal__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.payload { display: grid; gap: 8px; padding-left: 18px; font-size: 13px; }
.payload li { padding: 8px 10px; background: var(--surface-2); border-radius: 9px; list-style: none; margin-left: -18px; }

.toasts { position: fixed; z-index: 120; bottom: 18px; right: 18px; display: grid; gap: 8px; max-width: min(360px, calc(100vw - 36px)); }
.toast {
  display: flex; gap: 9px; align-items: flex-start; cursor: pointer;
  padding: 12px 14px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--line-strong); box-shadow: var(--shadow-md);
  font-size: 14px; animation: toast-in .2s var(--ease);
}
.toast--out { opacity: 0; transform: translateY(6px); transition: .2s var(--ease); }
.toast__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-top: 7px; flex: none; }
.toast--ok .toast__dot { background: var(--mint); }
.toast--warn .toast__dot { background: var(--warn); }
.toast--error .toast__dot { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ============================ AD SLOTS (app) ================================
   Same class as the landing pages use in site.css, so js/ads.js serves both with
   one loader. Kept visually quiet: dashed border, small ALL-CAPS label.

   Two shapes:
     .bw-ad              full-width band  - Home (below the Shared catalogue),
                         Bucket and Store.
     .bw-ad--rail        narrow side rails - Scan and CMF, in the page gutter each
                         side of the content (see .work-layout below). */
.bw-ad {
  display: grid; gap: 6px; margin: 18px 0 0; min-height: 110px;
  padding: 10px 12px; border: 1px dashed var(--line);
  border-radius: var(--radius-sm); overflow: hidden;
}
.bw-ad .bw-ad__label {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 600;
}

/* Home: the ad sits BELOW the Shared catalogue card with a clear gap, never
   wedged between two cards. */
.view--home > .bw-ad { margin-top: 20px; }

/*
 * Workflow views (Scan, CMF) carry two side-rail ad slots. The rails live in the
 * PAGE GUTTERS, pinned either side of the 1240px content shell - they are NOT
 * columns of it.
 *
 * WHY: as grid columns they stole 2 x 150px from the shell, which squeezed the
 * three workflow cards into a narrow strip: the photo preview overflowed its
 * card and the price guide was cut off. The cards now own the whole shell again
 * and the rails sit outside it, where the .work-layout wrapper no longer needs
 * to be a grid at all.
 */
.work-layout { display: block; }
.work-layout__rail { display: none; }

/*
 * Batch mode shows the Identify card and the review card, nothing else. The
 * Identify card used to keep column 1 of three and leave two empty columns
 * beside it; spanning the row stacks the two cards the way the review section
 * already does.
 */
.scan-grid--batch > .card:first-child { grid-column: 1 / -1; }

/*
 * NOTE: do NOT set justify-items/place-items here. The <ins> Google injects has
 * no intrinsic width before it fills, so centring collapses it to 0px wide and
 * Google then never requests the unit at all (the rail just sat empty). The
 * element must STRETCH; only the label text is centred.
 */
.bw-ad--rail { margin: 0; padding: 10px 8px; align-content: start; }
.bw-ad--rail .bw-ad__label { text-align: center; }

/*
 * `50% - shell/2 - rail - gap` IS the inside edge of the gutter, so the rails
 * hug the content instead of drifting to the screen edge on a wide monitor.
 * 150 + 18 of rail plus 12px of clearance needs a 1600px window before the
 * gutter can hold a rail at all - which is exactly when they appear. Below that
 * they stay display:none, so their placeholders are never armed (ads.js skips
 * invisible containers) and no space is reserved for them.
 */
@media (min-width: 1600px) {
  .work-layout__rail {
    display: block;
    position: fixed;
    top: calc(var(--head-h) + 20px);
    width: 150px;
    height: min(600px, calc(100vh - var(--head-h) - 40px));
  }
  /* Fixed rather than absolute: an absolutely positioned rail hanging outside
     the centred shell can add a horizontal scrollbar on a narrow window. */
  .work-layout__rail--start { left: calc(50% - var(--shell) / 2 - 168px); }
  .work-layout__rail--end { right: calc(50% - var(--shell) / 2 - 168px); }
  .work-layout__rail .bw-ad--rail { height: 100%; }
}

@media (max-width: 640px) {
  .bw-ad { min-height: 96px; padding: 8px; margin-top: 12px; }
  .view--home > .bw-ad { margin-top: 14px; }
}

/* ============================ PHONE LAYOUT ============================ */

/*
 * 1020px: the width below which the six nav links stop fitting on the top row
 * next to the brand, the Play button and the burger (brand 130 + links 569 + the
 * button 144 + burger 38 + the row's padding and gaps = about 957px). Below it the
 * links become the bottom bar. That is what this breakpoint is for - not a device
 * class - and it is the only thing holding the row's width now that the account
 * pill and the theme toggle live in the menu.
 */
@media (max-width: 1020px) {
  body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); }

  /*
   * The bottom nav is a fixed-position child of the header, and any ancestor with
   * backdrop-filter creates a containing block for fixed descendants - which
   * pinned the nav to the HEADER instead of the viewport and pushed it off the
   * top of the screen. Verified by measurement (nav rect bottom 56px vs 844px).
   * Keep the header opaque here; the blur returns above 1020px.
   */
  .app-head { backdrop-filter: none; background: var(--bg); }

  .app-head__in { --head-pad: 14px; padding: 8px var(--head-pad); min-height: 56px; }
  .brand { font-size: 16px; }
  .status-pill { font-size: 12px; padding: 6px 10px; }
  /*
   * The row here is brand + the Play button + the burger - three things that all
   * keep their size, so there is nothing left to shrink and no width at which a
   * 360px phone has to pay for a control with a horizontal scrollbar. The account
   * pill is a menu row at this width and sizes itself from the menu rules above.
   */
  .app-head__tools { flex: 0 1 auto; min-width: 0; }
  .status-pill--account { min-width: 0; }

  /* Nav becomes a fixed bottom tab bar. */
  .app-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    margin: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--bg) 96%, transparent);
    backdrop-filter: blur(14px); border-top: 1px solid var(--line);
    justify-content: space-around; gap: 0;
  }
  .nav-item {
    flex-direction: column; gap: 3px; padding: 7px 4px; border-radius: 10px;
    font-size: 11px; font-weight: 600; flex: 1 1 0; justify-content: center;
  }
  .nav-item svg { width: 21px; height: 21px; }
  .nav-item.is-on { background: transparent; color: var(--brand); }
  [data-theme=dark] .nav-item.is-on { color: var(--brand-lit); }

  .view-root { padding: 16px 13px 30px; }
  .scan-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .card { padding: 15px; }
  .stats { gap: 8px; }
  .stat { flex: 1 1 44%; }
  .toasts { left: 12px; right: 12px; bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom, 0px)); max-width: none; }
  .app-foot__links { margin-left: 0; }
  .guide-row { grid-template-columns: 1.2fr repeat(4, 1fr); font-size: 12.5px; padding: 9px 8px; gap: 8px; }
  .guide-head__price { font-size: 1.5rem; }
}

@media (max-width: 640px) {
  /*
   * PHONE: THE PAIRS BECOME TWO COLUMNS.
   * Item type | item number, and colour | condition, on one line each. Inside the
   * number cell the Find button wraps under its input rather than squeezing it,
   * so the number stays readable.
   */
  .field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
  .field-pair .row { flex-wrap: wrap; }
  .field-pair .row > input { flex: 1 1 100%; }
  .field-pair .row > .btn { flex: 1 1 auto; }
  .field-pair .cell-select,
  .field-pair .cselect { width: 100%; max-width: none; min-width: 0; }
}

@media (max-width: 520px) {
  .item-head, .cmf-result { flex-direction: column; }
  .guide-row { grid-template-columns: 1.3fr repeat(4, 1fr); gap: 6px; padding: 8px 6px; }
  .guide-cell { padding: 5px 4px; }
  .cell-input { max-width: 78px; }
  /*
   * The price guide's four fields stay TWO per line on a phone: Guide and
   * Statistic are one decision (which number, from which guide) and Quantity and
   * Your price are another, so stacking them one per line was four rows of card
   * for two answers. This used to collapse to a single column here.
   */
  .guide-controls { grid-template-columns: 1fr 1fr; gap: 10px 12px; }
  .guide-controls .field > label { font-size: 12.5px; }
}

/* Smooth the theme swap. */
body, .card, .stat, .data-table thead th, .app-head, .modal, .toast {
  transition: background-color .25s var(--ease), border-color .25s var(--ease), color .25s var(--ease);
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============================ BATCH REVIEW ============================ */

.view__head .segmented { margin-top: 14px; }
.card--wide { grid-column: 1 / -1; }

.batch-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.batch-toolbar__status { margin-left: auto; }

.batch-rows { display: grid; gap: 8px; }
.batch-row {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); overflow: hidden;
}
.batch-row.is-off { opacity: .55; }
.batch-row.is-open { border-color: color-mix(in srgb, var(--brand) 40%, transparent); background: var(--surface); }

/* Row headers use flex-wrap rather than a rigid grid: nine controls cannot all fit
   on one line at tablet widths, and wrapping keeps every control full-size. */
.batch-row__head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 12px;
}
.batch-row__img { width: 44px; height: 44px; object-fit: contain; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); flex: none; }
.batch-row__ph { display: block; background: var(--surface); }
.batch-row__main { display: grid; gap: 1px; min-width: 0; flex: 1 1 170px; }
.batch-row__main strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-row__main .faint { font-size: 12.5px; }
.batch-row__price { font-size: 13px; font-weight: 600; color: var(--mint); white-space: nowrap; flex: 0 0 auto; }

/*
 * Photos the recogniser could not read, each one shown with the shot it came
 * from. A failure nobody can see is a failure nobody can fix, so the picture is
 * the loudest thing in the row and the retry sits right next to it.
 *
 * Warn-coloured and edged on the left only: this is a nudge inside the review
 * card, not another card stacked on top of it.
 */
.batch-fails {
  margin: 0 0 12px; padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--warn) 28%, transparent);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius-sm); background: var(--warn-soft);
}
.batch-fails__head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
.batch-fails__title { font-size: .95rem; }
.batch-fails__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.batch-fails__tip { margin: 6px 0 10px; }
.batch-fails__list { display: grid; gap: 8px; }

.batch-fail {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line);
}
/* The picture IS the control: click it to see the shot that failed. */
.batch-fail__shot {
  padding: 0; border: 0; background: none; cursor: pointer;
  width: 64px; height: 64px; border-radius: 10px; overflow: hidden; flex: none;
}
.batch-fail__shot--empty { border: 1px dashed var(--line-strong); background: var(--surface-2); cursor: default; }
.batch-fail__img { width: 100%; height: 100%; object-fit: cover; display: block; }
.batch-fail__shot:hover .batch-fail__img { opacity: .86; }
.batch-fail__main { display: grid; gap: 1px; min-width: 0; flex: 1 1 220px; }
.batch-fail__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-fail__reason { font-size: 12.5px; color: var(--warn); }
.batch-fail__actions { display: flex; flex-wrap: wrap; gap: 8px; flex: none; margin-left: auto; }

.modal--photo { width: min(560px, 100%); }
.photo-view {
  display: block; width: 100%; height: auto; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2);
}

.cell-select {
  font: inherit; font-size: 13.5px; padding: 7px 9px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  flex: 0 1 160px; min-width: 120px; max-width: 190px;
}
.cell-select--sm { flex: 0 0 92px; min-width: 88px; }
.cell-select:disabled { opacity: .5; }

.qty-step { display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--line-strong); border-radius: 9px; overflow: hidden; background: var(--surface); }
.qty-step button { border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 15px; width: 28px; height: 32px; cursor: pointer; }
.qty-step button:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.qty-step b { min-width: 24px; text-align: center; font-size: 13.5px; }

.batch-row__body { padding: 4px 10px 12px; border-top: 1px solid var(--line); display: grid; gap: 9px; }
.batch-row__fields { display: grid; grid-template-columns: minmax(120px, 200px); gap: 10px; }
.batch-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 10px; }
.batch-toolbar { margin-bottom: 9px; }
.batch-row__head { padding: 9px 10px; gap: 8px; }

@media (max-width: 980px) {
  .batch-row__price { margin-left: 54px; }
}

/* ============================ BUCKET ROWS ============================ */

.bucket-rows { display: grid; gap: 8px; }
.bucket-row {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); overflow: hidden;
}
.bucket-row.is-blocked { border-left: 3px solid var(--warn); }
.bucket-row.is-open { border-color: color-mix(in srgb, var(--brand) 40%, transparent); }

.bucket-row__head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 12px;
}
.bucket-row__img {
  width: 44px; height: 44px; object-fit: contain; border-radius: 10px; flex: none;
  background: var(--surface-2); border: 1px solid var(--line);
}
.bucket-row__main { display: grid; gap: 1px; min-width: 0; flex: 1 1 170px; }
.bucket-row__main strong { font-weight: 600; }
.bucket-row__main .faint { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/*
 * The green line total USED to sit here. It is gone on purpose.
 *
 * The row already shows the price the seller sets (the editable box), and the
 * expanded line shows the guide figure and the table cell it came from - so the
 * green total was a FOURTH copy of one number, computed from the other two. Two
 * copies of a number that must agree is already a risk; four is noise, and on a
 * phone it was the thing that pushed the controls off the row.
 */
.bucket-row__head .cell-input { flex: 0 0 96px; }
.bucket-row__head .qty-step { flex: none; }

/*
 * Colour + condition travel together, and so do quantity, price, duplicate and
 * delete: each group is one inline row on a wide screen (the row reads exactly as
 * before) and one LINE each on a phone - see the 640px block below.
 */
.bucket-row__picks,
.bucket-row__amounts { display: flex; align-items: center; gap: 10px; min-width: 0; }

/*
 * THE EXPANDER IS AN AMBER CHEVRON, NOT THE WORD "Details".
 *
 * "Details" was the widest control after the item name, it repeated down the
 * whole list, and in grey it did not read as the thing that opens a line. A
 * chevron says what it does in 30px, points down when closed and up when open,
 * and is TINTED so it is visible against the row it belongs to.
 */
.bucket-row__toggle,
.batch-row__toggle,
.lot-card__toggle {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
}
.bucket-row__toggle:hover,
.batch-row__toggle:hover,
.lot-card__toggle:hover {
  color: var(--ink);
  background: var(--warn-soft);
  border-color: var(--warn);
}
.bucket-row__chev,
.batch-row__chev,
.lot-card__chev { transition: transform .16s var(--ease); }
.bucket-row.is-open .bucket-row__chev,
.batch-row.is-open .batch-row__chev,
.lot-card.is-open .lot-card__chev { transform: rotate(180deg); }

/*
 * The delete icon, in the danger colour: the same bin the Bucket row uses and
 * the same one the store rows use, so "this removes the line" reads the same
 * everywhere. It replaced a grey "remove" text link.
 */
.bucket-row__bin,
.batch-row__bin {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 38%, transparent);
}
.bucket-row__bin:hover,
.batch-row__bin:hover {
  background: color-mix(in srgb, var(--danger) 16%, transparent);
  border-color: var(--danger);
}
.bucket-row__body {
  padding: 10px; border-top: 1px solid var(--line); background: var(--surface-2);
  display: grid; gap: 9px;
}
.bucket-row__fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 220px)); gap: 10px; }

/* ---------------------------------------------------------------------------
   EXPANDED ROW LAYOUT
   An open row used to lay its guide table across the full shell width, so on a
   desktop the four figures sat ~300px apart and the row read as mostly empty.
   Above 900px the body becomes two columns: the guide (capped, so it reads as a
   table) and the controls beside it. Below that it stacks as before.
   --------------------------------------------------------------------------- */
.row-detail { display: grid; gap: 11px; }
.row-detail__main,
.row-detail__side { min-width: 0; display: grid; gap: 10px; align-content: start; }
.row-detail__main > .guide-table { max-width: 100%; }

@media (min-width: 900px) {
  .row-detail {
    grid-template-columns: minmax(0, 620px) minmax(196px, 300px);
    justify-content: space-between;
    gap: 11px 24px;
    align-items: start;
  }
  /* Inside the narrow side column the control fields stack one per row. */
  .row-detail__side .bucket-row__fields,
  .row-detail__side .batch-row__fields { grid-template-columns: 1fr; }
}

/*
 * PHONE: THE SAME THREE LINES FOR A BATCH REVIEW ROW.
 * Colour + condition on one line, quantity + price + the expander + the bin on
 * the next, identity on the first. See the bucket block just below for the full
 * why - this list is the same shape of row and had the same problem.
 */
@media (max-width: 640px) {
  .batch-row__head {
    display: grid;
    grid-template-columns: 18px 34px minmax(0, 1fr);
    align-items: center;
    column-gap: 8px;
    row-gap: 8px;
  }
  .batch-row__head > input[type="checkbox"] { grid-column: 1; grid-row: 1; width: 17px; height: 17px; accent-color: var(--brand); }
  .batch-row__head .batch-row__img { grid-column: 2; grid-row: 1; width: 34px; height: 34px; }
  .batch-row__head .batch-row__main { grid-column: 3; grid-row: 1; flex: none; }

  .batch-row__picks {
    grid-column: 1 / -1; grid-row: 2;
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  }
  .batch-row__picks .cselect,
  .batch-row__picks .cell-select { width: 100%; max-width: none; min-width: 0; flex: none; }

  .batch-row__amounts {
    grid-column: 1 / -1; grid-row: 3;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: 8px;
    align-items: center;
  }
  /* The indent that lined the price up under a wrapped row is not needed once
     the price has a column of its own - and it is what pushed it off a phone. */
  .batch-row__price { margin-left: 0; }
}

/*
 * PHONE: THREE LINES PER BUCKET ROW, NOT SIX.
 *
 * Every control used to claim a full row of its own (colour, then condition,
 * then quantity + price + total, then the buttons), which is what made a single
 * line taller than the card explaining it. The head becomes a grid instead: the
 * identity of the line on the first row - with the expander on its right, where
 * an expander belongs - then colour + condition side by side, then quantity,
 * price, duplicate and delete side by side. Nothing takes a line of its own, and
 * the price box is never pushed past the screen edge.
 */
@media (max-width: 640px) {
  .bucket-row__head {
    display: grid;
    grid-template-columns: 18px 34px minmax(0, 1fr);
    align-items: center;
    column-gap: 8px;
    row-gap: 8px;
  }
  .bucket-row__head .row-check { grid-column: 1; grid-row: 1; }
  .bucket-row__head .bucket-row__img { grid-column: 2; grid-row: 1; width: 34px; height: 34px; }
  .bucket-row__head .bucket-row__main { grid-column: 3; grid-row: 1; flex: none; }

  .bucket-row__picks {
    grid-column: 1 / -1; grid-row: 2;
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  }
  .bucket-row__picks .cselect,
  .bucket-row__picks .cell-select { width: 100%; max-width: none; min-width: 0; flex: none; }

  /* qty | price (grows) | duplicate | delete | expander */
  .bucket-row__amounts {
    grid-column: 1 / -1; grid-row: 3;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto auto;
    gap: 8px;
    align-items: center;
  }
  .bucket-row__amounts .cell-input { width: 100%; min-width: 0; flex: none; }
}

@media (max-width: 640px) {
  .batch-row__head .cell-select { flex: 1 1 100%; max-width: none; }
}

/* ============================ GROUPED LISTS ============================
   Bucket and Store both render collapsible item-type sections, headed by a
   tappable one-line header ("Part (12)") with an expand/collapse-all button
   for the whole list above them. */

.list-group-bar { display: flex; gap: 8px; margin: 0 0 8px; }

.list-section { margin-top: 10px; }
.list-section__head {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  width: 100%; text-align: left;
  padding: 8px 11px; border-radius: 11px; margin-bottom: 8px;
  background: var(--surface-2); border: 1px solid var(--line);
  font: inherit; font-size: 14px; font-weight: 600; color: var(--ink);
  cursor: pointer;
}
.list-section__head:hover { border-color: var(--line-strong); }

/* ========================== BATCH UPDATE PANEL ==========================
   One collapsible panel, shared by Bucket, Store and the scan Batch list (see
   js/bulkPanel.js). Its header IS the state read-out - how many lines are
   ticked - and its body holds the scope (item-type chips + select all/none)
   above the changes, so a 1,000-line batch can be narrowed and selected
   without a single per-row click.

   Collapsed by default. It used to appear, already expanded, the moment one row
   was ticked, which shoved the list out from under the pointer on every tick. */

.bulk-panel {
  margin: 0 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
  transition: border-color .18s var(--ease);
}
.bulk-panel.has-selection { border-color: color-mix(in srgb, var(--brand) 38%, transparent); }

.bulk-panel__head {
  display: flex; align-items: center; gap: 10px; width: 100%;
  font: inherit; text-align: left; cursor: pointer;
  padding: 11px 13px; border: 0; background: var(--surface-2); color: var(--ink);
}
.bulk-panel__head:hover { background: color-mix(in srgb, var(--ink) 7%, var(--surface-2)); }
.bulk-panel__title { flex: none; font-size: 14px; font-weight: 600; }
/* What the collapsed panel would do, so it reads as a control, not a label. */
.bulk-panel__invite {
  font-size: 13px; color: var(--ink-faint); min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/*
 * On a phone the invitation goes. It is the longest thing in a header that has to
 * share a 360px line with the title, the count and the chevron, so it was always
 * truncated to "Change the colour, quantity or price of e..." - three lines of
 * chrome saying nothing. The title plus the count ("2 of 12 selected") is what
 * the seller actually reads, and the invite is still there on a wide screen
 * where there is room for it.
 */
@media (max-width: 640px) {
  .bulk-panel__invite { display: none; }
  .bulk-panel__head { padding: 11px; gap: 8px; }
}
.bulk-panel__count {
  margin-left: auto; flex: none; font-size: 12.5px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink-dim);
}
.bulk-panel.has-selection .bulk-panel__count { background: var(--brand-soft); color: var(--brand); }
[data-theme=dark] .bulk-panel.has-selection .bulk-panel__count { color: var(--brand-lit); }
.bulk-panel__chev { flex: none; font-size: 12px; color: var(--ink-faint); }

.bulk-panel__body {
  display: grid; gap: 12px; padding: 12px 13px;
  border-top: 1px solid var(--line);
}
.bulk-panel__row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bulk-panel__row + .bulk-panel__row { border-top: 1px solid var(--line); padding-top: 12px; }
.bulk-panel__label { flex: none; font-size: 13px; font-weight: 600; color: var(--ink-dim); }
/* The global rule is select { width: 100% }, which in a wrapping flex row means
   one control per line - so the guide row's two selects size to their content. */
.bulk-panel__row select { width: auto; min-width: 132px; }
.bulk-panel__row .faint { flex: 1 1 180px; }
.bulk-panel__chips { display: flex; flex-wrap: wrap; gap: 6px; }
/* Pushed right on a wide row, and when the row wraps it simply starts the next
   line - the store rail is narrow enough that it wraps there every time. */
.bulk-panel__pick { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }
/*
 * THE CHANGE FIELDS ARE ONE GRID, one column per field, all the same width.
 *
 * The row used to be a wrapping flex line, so three different widths met in it:
 * a number input kept the global 130px cap (input[type=number] above), a select
 * filled whatever space was left, and the colour picker sized to its own content
 * - so colour, quantity and price each started at a different x and stood at a
 * different height, and the guide row below looked like a separate feature
 * rather than the answer to "where does the price come from".
 *
 * `align-items: end` with one control height lines every label up along the top
 * and every control along the bottom, whichever fields a screen passes in.
 */
.bulk-panel__fields {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 10px 12px; width: 100%; align-items: end;
}
.bulk-panel__fields .field { margin-bottom: 0; min-width: 0; }
/* Every control fills its own column, input caps and pickers included. */
.bulk-panel__fields .field > *:last-child { width: 100%; min-width: 0; }
.bulk-panel__fields .field input[type=number] { max-width: none; }
.bulk-panel__fields .cselect { width: 100%; max-width: none; }
/*
 * ONE HEIGHT, exactly - not a min-height. The three control types are built
 * differently (an input is 10px of padding around 15px text, a select is 43px,
 * the colour trigger 35px), so a floor left them at 46/43/44 and the LABELS above
 * them, bottom-aligned, sat at three different heights. A fixed height makes the
 * whole row one line again.
 */
.bulk-panel__fields .field select,
.bulk-panel__fields .field input,
.bulk-panel__fields .cselect__btn { height: 44px; }
/* Off means off: the statistic is unusable until a guide is chosen, and it says
   so by looking inert rather than by being hidden and shifting the row. */
.bulk-panel__fields select:disabled { opacity: .55; cursor: not-allowed; }
/* The one destructive action, kept apart from the primary Apply on its right. */
.bulk-panel__danger { margin-left: auto; }
.bulk-panel .chip { padding: 5px 11px; font-size: 13px; }
.bulk-panel .chip__count { margin-left: 6px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.bulk-panel .chip--on .chip__count { color: var(--ink-dim); }
.bulk-panel .hint { margin: 0; }
[data-theme=dark] .bulk-panel__head:hover { background: color-mix(in srgb, var(--ink) 10%, var(--surface-2)); }

/* The row tickboxes: checked = this row joins the batch update. */
.row-check { width: 17px; height: 17px; accent-color: var(--brand); flex: none; cursor: pointer; }

/* ================================= PILLS =================================
   A pill states something small and true about one row: the status of a store
   lot, which lot a bucket line updates, whether a switch is on. It is NOT the
   badge: a badge shouts a value in the middle of a screen ("Not exportable"),
   which is exactly what made every "synced" lot the loudest thing in the store
   list. Pills are deliberately small and quiet, and a pill that toggles carries
   `aria-pressed` so its state is announced rather than only coloured. */

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  flex: none; padding: 2px 9px; border-radius: 999px;
  border: 1px solid transparent;
  background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink-dim);
  font-size: 11px; font-weight: 600; line-height: 1.5; white-space: nowrap;
}
.pill--muted { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.pill--info { background: var(--brand-soft); color: var(--brand); }
[data-theme=dark] .pill--info { color: var(--brand-lit); }
.pill--warn { background: var(--warn-soft); color: var(--warn); }
.pill--bad { background: var(--bad-soft); color: var(--danger); }

/*
   A pill inside a grid cell must not STRETCH to the column width. The bucket
   row's text area is a grid, so its default `justify-items: stretch` turned the
   "Update lot #..." pill into a full-width bar that read as a panel, not a
   status. Only the pill is pinned; the name and subtitle keep their own
   ellipsis behaviour, which stretching is what makes work.
*/
.bucket-row__main .pill { justify-self: start; }

/* A pill that is a control. Quiet until it is on. */
.pill--toggle {
  cursor: pointer; font: inherit; font-size: 12px;
  border-color: var(--line-strong); background: var(--surface); color: var(--ink-dim);
  padding: 5px 11px;
}
.pill--toggle:hover { border-color: var(--brand); color: var(--ink); }
.pill--toggle.is-on {
  background: var(--brand-soft); border-color: transparent; color: var(--brand);
}
[data-theme=dark] .pill--toggle.is-on { color: var(--brand-lit); }
.pill--toggle.pill--danger:hover { border-color: var(--danger); color: var(--danger); }
.pill--toggle.pill--danger.is-on { background: var(--bad-soft); color: var(--danger); }

/* ===================== "ALREADY IN YOUR STORE" (bucket) ==================
   The block that appears in one bucket line's Details only when the piece really
   is in the seller's store. It explains the arithmetic of an Update XML line,
   so it reads as a small panel rather than as a form. */

.match-block {
  display: grid; gap: 8px; width: 100%;
  padding: 10px 11px; border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--brand) 26%, transparent);
  background: color-mix(in srgb, var(--brand) 5%, transparent);
}
/* The fields grid above it is multi-column below 900px; the panel needs the lot. */
.bucket-row__fields .match-block { grid-column: 1 / -1; }
.match-block .field { margin-bottom: 0; }
.match-block .hint { margin: 0; }
/* The "will be included in Update XML" line is the one thing to notice here. */
.match-block .hint--ok { color: var(--mint); font-weight: 600; }

/* ============================ STORE LOT CARDS ============================
   The store table becomes expandable cards, like the app's StoreLotCard: a
   compact head (check, image, name, qty stepper, price, status, Edit) and a
   detail area opened per card (remarks, stockroom, delete, undo).

   TWO-PANE: the lot list is the left pane; connection, summary/push actions
   and the bulk bar live in a sticky right rail (see .store-layout). */

.store-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}
.store-layout__side {
  position: sticky; top: 16px;          /* stays visible while the list scrolls */
  display: grid; gap: 16px;
  max-height: calc(100vh - 32px);       /* long rails scroll internally */
  overflow-y: auto;
  scrollbar-width: thin;
}
.store-layout__side .card { margin-bottom: 0; }
.store-layout__side:empty { display: none; }

/* Narrowed search so the chips share the row instead of wrapping early. */
.store-layout .field--search { max-width: 240px; }

@media (max-width: 1100px) {
  .store-layout { grid-template-columns: 1fr; }
  .store-layout__side { position: static; max-height: none; order: -1; }
}

.lot-cards { display: grid; gap: 8px; }
.lot-card {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); overflow: hidden;
}
.lot-card.is-edited { background: var(--warn-soft); }
.lot-card.is-delete { border-left: 3px solid var(--danger); }
.lot-card.is-open { border-color: color-mix(in srgb, var(--brand) 40%, transparent); }
/*
 * A TICKED row. The tick is applied to the row in place rather than by redrawing
 * the list (repainting 1,400 cards to draw one checkbox is what made the lot list
 * feel frozen), so the row itself has to show it: a quiet brand-coloured edge
 * that reads at a glance down a long inventory and cannot be confused with the
 * staged (amber) or to-delete (red) states.
 */
.lot-card.is-ticked { border-left: 3px solid var(--brand); }
.lot-card.is-ticked.is-delete { border-left-color: var(--danger); }

.lot-card__head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 12px;
}
.lot-card__img {
  width: 44px; height: 44px; object-fit: contain; border-radius: 10px; flex: none;
  background: var(--surface-2); border: 1px solid var(--line);
}
.lot-card__main { display: grid; gap: 1px; min-width: 0; flex: 1 1 180px; }
.lot-card__main strong { font-weight: 600; }
.lot-card__main .faint { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lot-card__body {
  padding: 10px 12px 12px; border-top: 1px solid var(--line); background: var(--surface-2);
}
.lot-card__fields { display: grid; gap: 10px; }
.lot-card__fields .field { margin-bottom: 0; }
.lot-card__actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }

@media (max-width: 640px) {
  .lot-card__head .cell-input { flex: 1 1 100%; }
}
