/* ocgmbh barcode — shared styles. Mobile-first, desktop-friendly. */

:root {
  /* BMW M tricolor — identity accent, anchors semantic colors. */
  --m-light-blue: #2E9DEF;
  --m-dark-blue:  #1F2D69;
  --m-red:        #E22718;

  /* Light-mode surfaces. Page is pure white so the white-background
     logo banner blends seamlessly into the topbar and login card. */
  --bg:        #FFFFFF;   /* page */
  --bg-elev:   #FFFFFF;   /* cards / panels (elevation via border + shadow) */
  --bg-elev-2: #F1F5F9;   /* inputs, subtle blocks */

  /* Text on light surfaces */
  --fg:     #0F172A;      /* deep slate */
  --muted:  #64748B;      /* slate-500 */
  --border: #E2E8F0;      /* slate-200 */

  /* Semantic UI colors — adjusted for legibility on white. */
  --accent:    #1F7FD3;   /* slightly deeper blue than the M-blue, better contrast */
  --accent-2:  #0E8C5F;   /* darker teal/green for contrast on white */
  --warn:      #B45309;   /* amber-700 for legibility on white */
  --err:       #C81810;   /* M red, slightly deepened */

  /* Translucent tints reused across components — centralised so each
     repeated rgba() literal lives in exactly one place. Single-use tints
     stay inline at their selector. */
  --warn-fill:       rgba(180,83,9,0.04);    /* faint amber fill — merge archive cards, conflict row */
  --warn-strike:     rgba(180,83,9,0.5);     /* strikethrough rule on archived / discarded text */
  --err-line:        rgba(200,24,16,0.30);   /* danger border — quick-tile, danger-zone */
  --err-line-strong: rgba(200,24,16,0.45);   /* stronger danger border / focus-pulse */

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15,23,42,0.06), 0 1px 3px rgba(15,23,42,0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.45 -apple-system, system-ui, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

main {
  padding: 1rem;
  max-width: 720px;
  margin: 0 auto;
}

/* ── top bar with BMW M tri-stripe ─────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: var(--bg);
  color: var(--fg);
  background-image:
    linear-gradient(var(--bg), var(--bg)),
    linear-gradient(
      to right,
      var(--m-light-blue) 0%, var(--m-light-blue) 33.333%,
      var(--m-dark-blue)  33.333%, var(--m-dark-blue)  66.666%,
      var(--m-red)        66.666%, var(--m-red)        100%
    );
  background-origin: padding-box, border-box;
  background-clip: padding-box, border-box;
  background-repeat: no-repeat;
  border-bottom: 3px solid transparent;
}
.brand {
  display: flex;
  align-items: center;
  line-height: 0;
  text-decoration: none;
}
.brand-banner {
  /* Use the natural aspect ratio of the lockup; we constrain height,
     let width extend naturally. The dark logo background blends into
     the dark topbar. */
  height: 40px;
  width: auto;
  display: block;
}
.topbar-tools { display: flex; gap: 0.5rem; align-items: center; }
.topbar-action {
  font-size: 0.85rem;
  padding: 0.45rem 0.8rem;
  color: var(--muted);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
}
.topbar-action:hover { color: var(--fg); border-color: var(--accent); text-decoration: none; }
.lang-picker { margin: 0; padding: 0; }
.lang-picker select {
  width: auto;
  background: var(--bg-elev);
  color: var(--muted);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* ── messages ──────────────────────────────────────────────────────────── */
.messages { margin: 0 0 1rem; }
.msg {
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
}
.msg.success { background: rgba(14,140,95,0.10); color: var(--accent-2); border: 1px solid rgba(14,140,95,0.25); }
.msg.error   { background: rgba(200,24,16,0.08);  color: var(--err);      border: 1px solid rgba(200,24,16,0.25); }
.msg.warning { background: rgba(180,83,9,0.08);   color: var(--warn);     border: 1px solid rgba(180,83,9,0.25); }
.msg.info    { background: rgba(31,127,211,0.08); color: var(--accent);   border: 1px solid rgba(31,127,211,0.25); }

/* ── home tiles ───────────────────────────────────────────────────────── */
.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}
.home-grid + .home-grid { margin-top: 0.75rem; }
.tile {
  background: var(--bg-elev);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 130px;
  text-decoration: none;
  color: var(--fg);
  position: relative;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}
.tile:hover, .tile:active {
  background: var(--bg-elev);
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-1px);
}
.tile .icon { font-size: 2rem; line-height: 1; margin-bottom: 0.4rem; }
.tile .label { font-size: 0.95rem; font-weight: 500; }
.tile .badge {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  min-width: 1.4rem;
  text-align: center;
}
.tile--ghost {
  background: transparent;
  border: 1px dashed var(--border);
  box-shadow: none;
}

.footer-link {
  display: block;
  text-align: center;
  margin: 2rem 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 2rem 0 1rem;
}
.footer-row .footer-link { margin: 0; }
.footer-version {
  color: var(--muted);
  font-size: 0.8rem;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

/* ── desktop tweaks ───────────────────────────────────────────────────── */
@media (min-width: 720px) {
  .home-grid { grid-template-columns: 1fr 1fr 1fr 1fr; }
}

/* ── eBay color-letter mark (used in lieu of an eBay icon asset) ──────── */
.ebay-mark {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 700;
  font-style: italic;
  font-size: 1.8rem;
  line-height: 1;
  letter-spacing: -0.02em;
}
.ebay-mark .e { color: #E53238; }
.ebay-mark .b { color: #0064D2; }
.ebay-mark .a { color: #F5AF02; }
.ebay-mark .y { color: #86B817; }

/* ── Quick action tiles (one-tap) ─────────────────────────────────────── */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
  gap: 0.5rem;
  margin: 0 0 1rem;
}
.quick-actions form { margin: 0; }
.quick-tile {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.3rem;
  text-align: center;
  color: var(--fg);
  font-size: 0.72rem;
  line-height: 1.15;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  text-decoration: none;
  width: 100%;
  min-height: 70px;
  font-family: inherit;
}
.quick-tile:hover { background: var(--bg); border-color: var(--accent); text-decoration: none; }
.quick-tile .icon { font-size: 1.3rem; line-height: 1; }
.quick-tile--warn { color: var(--warn); border-color: rgba(180,83,9,0.30); }
.quick-tile--danger { color: var(--err); border-color: var(--err-line); }

/* ── Action cards (form-requiring) ────────────────────────────────────── */
.action-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 0.6rem;
}
.action-card--primary { border-color: var(--accent-2); border-width: 2px; }
.action-card--danger { border-color: var(--err-line-strong); }

/* ── Danger zone — destructive actions grouped together ───────────────── */
.danger-zone {
  border: 1px solid var(--err-line);
  background: rgba(200,24,16,0.03);
}
.danger-zone .panel-title { color: var(--err); }
.action-card .card-title {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 0.7rem;
}
.action-card form > * + * { margin-top: 0.6rem; }
.action-card .field-row { display: flex; gap: 0.5rem; }
.action-card .field-row > * { flex: 1; }
.action-card label { font-size: 0.8rem; }

/* ── shared panels & lists ────────────────────────────────────────────── */
.panel {
  background: var(--bg-elev);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.panel-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 0.5rem;
  font-weight: 600;
}
.row-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.4rem;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
}
.row-link:last-child { border-bottom: none; }
.row-link:hover { background: var(--bg); text-decoration: none; }
.row-link .meta { color: var(--muted); font-size: 0.85rem; }

/* Rows rendered as <button> (print `js-print` + `picker-btn` variants) reuse
   `.row-link`, but a <button> defaults to fit-content width and carries UA
   chrome — so without this it hugs its content instead of filling the panel.
   Mirror the anchor row: full width, no button background/border (keep only the
   divider from `.row-link`), left-aligned, inherited font. */
button.row-link {
  width: 100%;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
button.row-link:last-child { border-bottom: none; }

/* ── row text wrapper — single-line truncation with ellipsis ─────────── */
.row-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.row-text > strong,
.row-text > .meta,
.row-text > .meta-line,
.row-text > .row-code,
.row-text > .row-name,
.row-text > .row-loc {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── canonical item-list row: three text lines (code / name / location) */
.item-row .row-code {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.25;
}
.item-row .row-name {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.25;
}
.item-row .row-name.empty {
  font-style: italic;
  opacity: 0.75;
}
.item-row .row-loc {
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--accent);
  font-style: italic;
  line-height: 1.3;
  margin-top: 0.05rem;
}

/* Location ancestry path (`{% location_path %}`): root→leaf, leaf emphasised,
   ancestors dimmed so the eye lands on the actual bin. */
.loc-anc { opacity: 0.6; font-weight: 400; }
.loc-leaf { font-weight: 700; }

/* ── native item-detail properties (label left, value right) ──────────── */
.item-properties {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1rem;
  margin: 0.5rem 0 1.2rem;
  align-items: baseline;
}
.item-properties dt {
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}
.item-properties dt::after { content: ":"; }
.item-properties dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

/* ── breadcrumbs (under topbar, on every non-home page) ──────────────── */
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.4rem;
  padding: 0.5rem 1rem 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.2;
}
.crumbs a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px dotted transparent;
}
.crumbs a:hover { color: var(--fg); border-bottom-color: var(--accent); }
.crumbs [aria-current="page"] {
  color: var(--fg);
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crumbs > :not(:first-child)::before {
  content: "›";
  margin-right: 0.35rem;
  color: var(--border);
  font-weight: 400;
}

/* ── list page header (title + count) ────────────────────────────────── */
.list-page-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0 1rem;
}
.list-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── list search input (live-filters via HTMX) ────────────────────────── */
.list-search {
  margin: 0.5rem 0 0.75rem;
}
.list-search input[type="search"] {
  width: 100%;
  font-size: 1rem;
}

/* ── photo gallery (item detail bottom) ───────────────────────────────── */
.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0.4rem;
}
.photo-thumb-link {
  display: block;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
}
.photo-thumb-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-thumb-link:hover { border-color: var(--accent); }

/* Picker rows (`.picker-btn`) are styled by the shared `button.row-link` reset
   above — no separate rule needed. */

/* ── location row: code on top, description below (one-line ellipsis) ── */
.loc-row {
  display: flex;
  flex-direction: column;
  /* `.row-link` sets `align-items: center` for the row-direction default,
     which becomes horizontal-centering once we flip to column here. Force
     left-alignment so location code/description hug the leading edge. */
  align-items: flex-start;
  text-align: left;
  min-width: 0;
  overflow: hidden;
}
.loc-row .loc-code {
  display: block;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.loc-row .loc-desc {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.05rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── reorganize flow ──────────────────────────────────────────────────── */
.reorg-summary {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 0.4rem 0;
  background: var(--bg);
}
.reorg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.reorg-row:last-child { border-bottom: none; }
.reorg-batch { margin-bottom: 0.5rem; }
.reorg-batch-row { padding: 0.6rem 0.4rem; }

/* ── pack-page photo strip: one per row on mobile, two on desktop ────── */
.pack-photos {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}
@media (min-width: 720px) {
  .pack-photos { grid-template-columns: 1fr 1fr; }
}
.pack-photo {
  display: block;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
}
.pack-photo img {
  width: 100%;
  height: auto;
  display: block;
}
.pack-photo:hover { border-color: var(--accent); }

/* ── pagination controls ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin: 0.8rem 0 0.4rem;
}
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2rem;
  height: 2.2rem;
  padding: 0 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 600;
  text-decoration: none;
  line-height: 1;
}
.page-link:hover { background: var(--bg); border-color: var(--accent); text-decoration: none; }
.page-link--disabled { color: var(--border); cursor: default; }
.page-link--disabled:hover { background: var(--bg-elev); border-color: var(--border); }
.page-meta { color: var(--muted); font-size: 0.9rem; min-width: 4rem; text-align: center; }
.row-thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  display: block;
  margin-right: 0.5rem;
  flex-shrink: 0;
}
.row-thumb--ghost {
  background: var(--bg-elev-2);
  border: 1px dashed var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.85rem;
}
.mono { font-family: ui-monospace, "SF Mono", monospace; font-size: 0.92em; }

.empty {
  color: var(--muted);
  font-style: italic;
}
/* Block-level empty placeholders ("Nothing matched." rows in panels) */
p.empty {
  text-align: center;
  padding: 1.5rem 1rem;
}

/* ── buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 500;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn--ok { background: var(--accent-2); color: #fff; }
.btn--warn { background: var(--warn); color: #fff; }
.btn--err { background: var(--err); color: #fff; }
.btn--ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn--block { width: 100%; }
.btn--big { padding: 1rem 1.2rem; font-size: 1.1rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ── merge items ──────────────────────────────────────────────────────── */
/* Selection is the two-slot picker (keep / archive); slots reuse the shared
   `.reorg-row` / `.item-row` chip styling. Below: the preview cards. */
.merge-go { margin-top: 0.8rem; }

/* preview: keep ⟸ archive summary cards */
.merge-cards {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 0.6rem;
  margin: 0.5rem 0 1rem;
}
.merge-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.85rem;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  min-width: 0;
}
.merge-card--keep    { border-color: var(--accent-2); }
.merge-card--archive { border-color: var(--warn); background: var(--warn-fill); }
.merge-role { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; }
.merge-card--keep    .merge-role { color: var(--accent-2); }
.merge-card--archive .merge-role { color: var(--warn); }
.merge-code { font-size: 1.05rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.merge-cardname { font-size: 0.85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.merge-card--archive .merge-code { text-decoration: line-through; text-decoration-color: var(--warn-strike); }
.merge-arrow { align-self: center; font-size: 1.7rem; color: var(--accent-2); }

/* donor-conflict warning uses the shared .msg.warning alert component. */

/* result field rows */
.merge-fields { display: flex; flex-direction: column; }
.merge-field {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.55rem 0.5rem;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
}
.merge-field:last-child { border-bottom: none; }
.merge-field.is-from-b   { border-left-color: var(--accent-2); background: rgba(14,140,95,0.04); }
.merge-field.is-conflict { border-left-color: var(--warn);     background: var(--warn-fill); }
.mf-label { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.mf-label--block { display: block; margin: 0.8rem 0 0.3rem; }
.mf-value { text-align: right; min-width: 0; overflow-wrap: anywhere; }
.mf-result { font-weight: 500; }
.mf-tag {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  vertical-align: middle;
  white-space: nowrap;
}
.mf-tag--b   { background: rgba(14,140,95,0.12); color: var(--accent-2); }
.mf-tag--x   { background: rgba(180,83,9,0.12);  color: var(--warn); text-decoration: line-through; }
.mf-tag--sum { background: var(--bg-elev-2);     color: var(--muted); }
.merge-field--cost { border-bottom: none; padding-left: 0; }
.merge-notes {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.7rem;
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.45;
}
.merge-photos { color: var(--muted); font-size: 0.85rem; margin: 0.7rem 0 0; }

/* commit zone — amber, irreversible */
.merge-commit { margin-top: 1.2rem; }
.merge-irreversible { color: var(--warn); font-size: 0.8rem; text-align: center; margin: 0.5rem 0 0.8rem; }

@media (max-width: 560px) {
  .merge-cards { grid-template-columns: 1fr; }
  .merge-arrow { transform: rotate(-90deg); justify-self: center; }
}

/* ── forms ────────────────────────────────────────────────────────────── */
input[type=text], input[type=number], input[type=password], input[type=url],
input[type=email], input[type=search], input[type=tel], input:not([type]),
textarea, select {
  background: var(--bg-elev-2);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  width: 100%;
  display: block;
  box-sizing: border-box;
}
label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.3rem; }

/* ── camera / QR ──────────────────────────────────────────────────────── */
.qr-reader {
  width: 100%;
  /* Proportional preview: smaller than full-screen on portrait phones, but the
     video keeps its TRUE aspect (no letterbox, no crop). html5-qrcode measures
     this box at start and aligns its scan box to it, so the drawn box matches
     what actually decodes — and detection stays as accurate/fast as full-screen.
     Height follows the camera aspect; shrink/grow by changing max-width only.
     Do NOT cap height or set object-fit here (cover crops → no decode;
     contain letterboxes → scan box desyncs and detection drops). */
  max-width: 300px;
  margin: 0 auto;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  position: relative;
}
.qr-reader video { width: 100% !important; height: auto !important; display: block; }
.qr-torch {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 5;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 1.1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  line-height: 1;
}
.qr-torch.is-on {
  background: rgba(245, 158, 11, 0.9);
  border-color: rgba(255, 255, 255, 0.6);
}
.qr-hint {
  position: absolute;
  bottom: 0.5rem;
  left: 0;
  right: 0;
  text-align: center;
  color: #fff;
  font-size: 0.85rem;
  text-shadow: 0 1px 2px rgba(0,0,0,0.7);
  pointer-events: none;
}

/* ── pills ────────────────────────────────────────────────────────────── */
.pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  background: var(--bg-elev-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
/* State pills — soft tints with M tricolor semantics, legible on white. */
.pill { border: 1px solid var(--border); background: var(--bg); color: var(--muted); }
.pill--draft        { background: #F1F5F9; color: #475569; border-color: #E2E8F0; }
.pill--new          { background: #E8F2FE; color: #1F7FD3; border-color: #BFDCFB; }
.pill--ready_to_list { background: #E8F2FE; color: #1F7FD3; border-color: #BFDCFB; }
.pill--listed       { background: #DCEAFC; color: #1666B4; border-color: #A8C9F0; }
.pill--sold         { background: #FEF3C7; color: #B45309; border-color: #FCD7A0; }
.pill--packaged     { background: #FDE9B8; color: #92400E; border-color: #F7CB75; }
.pill--shipped      { background: #DCFCE7; color: #0E8C5F; border-color: #A7E5BE; }
.pill--returned     { background: #FEE2E2; color: #C81810; border-color: #FBBFBA; }
.pill--disposed     { background: #FEE2E2; color: #C81810; border-color: #FBBFBA; }

/* ── login ────────────────────────────────────────────────────────────── */
.login-card {
  max-width: 380px;
  margin: 4rem auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  box-shadow: 0 10px 30px rgba(15,23,42,0.10), 0 2px 6px rgba(15,23,42,0.06);
}
.login-card h2 { margin-top: 0; }
.login-card p { margin: 0.75rem 0; }

/* ── voice-fill modal (edit page) ────────────────────────────────────── */
.voice-trigger { white-space: nowrap; padding: 0.4rem 0.8rem; }
@media (max-width: 480px) {
  .voice-trigger-label { display: none; }
  .voice-trigger { padding: 0.4rem 0.6rem; }
}

.voice-modal {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.voice-modal[hidden] { display: none !important; }

.voice-modal-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(15,23,42,0.25);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
@media (max-width: 600px) {
  .voice-modal { padding: 0; align-items: stretch; }
  .voice-modal-card {
    max-width: none; max-height: 100vh;
    border-radius: 0;
  }
}

.voice-modal-head {
  padding: 1rem 1rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
.voice-modal-foot {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  display: flex; gap: 0.5rem; align-items: center;
  background: var(--bg);
}
.voice-modal-foot .voice-record-btn {
  flex: 1; min-width: 0;
  background: var(--err); color: #fff; border-color: var(--err);
}
.voice-modal-foot .voice-record-btn.is-recording {
  background: var(--bg); color: var(--err);
  animation: voice-pulse 1.2s ease-in-out infinite;
}
.voice-modal-foot .voice-record-btn:disabled { opacity: 0.6; }
.voice-modal-foot .voice-save-btn:disabled { opacity: 0.5; cursor: not-allowed; }

@keyframes voice-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--err-line-strong); }
  50%      { box-shadow: 0 0 0 8px rgba(200,24,16,0.0); }
}

.voice-fields {
  padding: 0.5rem 1rem;
  overflow-y: auto;
  flex: 1;
}
.voice-row {
  display: flex; align-items: baseline; gap: 0.75rem;
  padding: 0.4rem 0; border-bottom: 1px solid var(--border);
}
.voice-row:last-child { border-bottom: none; }
.voice-row.is-changed { background: rgba(46,157,239,0.06); }
.voice-row.is-cleared .voice-new::before { content: "✕ "; color: var(--err); }
.voice-key {
  color: var(--muted); font-size: 0.85rem;
  min-width: 30%; flex-shrink: 0;
}
.voice-vals { flex: 1; min-width: 0; word-break: break-word; }
.voice-orig { color: var(--fg); }
.voice-row.is-changed .voice-orig {
  color: var(--muted); text-decoration: line-through; font-size: 0.85rem;
}
.voice-arrow { color: var(--muted); margin: 0 0.25rem; }
.voice-new {
  color: var(--accent-2); font-weight: 600;
}
.voice-row.is-cleared .voice-new { color: var(--err); }

.voice-status {
  padding: 0.6rem 1rem;
  margin: 0;
  background: var(--bg-elev-2);
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
.voice-status.is-error { color: var(--err); }

.voice-level-wrap {
  height: 4px; background: var(--bg-elev-2); margin: 0;
  border-top: 1px solid var(--border);
}
.voice-level {
  height: 100%; width: 0%;
  background: var(--err);
  transition: width 80ms linear;
}

/* ── bulk-extract modal (receive page) — reuses .voice-modal-* layout ── */
.bulk-pickers {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
}
.bulk-pickers > label { flex: 1; min-width: 8rem; }
.bulk-list {
  list-style: none; padding: 0; margin: 0.75rem 0 0;
  display: flex; flex-direction: column; gap: 0.25rem;
}
.bulk-list li {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  background: var(--bg-elev-2);
  border-radius: 6px;
  font-size: 0.85rem;
}
.bulk-list .bulk-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bulk-list .bulk-size { color: var(--muted); font-size: 0.75rem; }
.bulk-list .bulk-remove {
  background: transparent; border: 0; color: var(--err);
  cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 0.25rem;
}
.bulk-summary-card {
  background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.6rem 0.75rem;
}
.bulk-summary-card h4 { margin: 0 0 0.4rem; font-size: 0.95rem; }
.bulk-fills { display: grid; grid-template-columns: 1fr 1fr; gap: 0.1rem 0.6rem; font-size: 0.8rem; }
.bulk-fills .bulk-fill-key { color: var(--muted); }
.bulk-fills .bulk-fill-bad { color: var(--err); }

/* Read-only detail of exactly what the AI returned, grouped donor → parts.
   Scrolls on its own so a big batch doesn't push Accept/Cancel off-screen. */
.bulk-detections-card {
  margin-top: 0.6rem;
  background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.6rem 0.75rem;
  max-height: 42vh; overflow-y: auto;
}
.bulk-detections-card h4 { margin: 0 0 0.4rem; font-size: 0.95rem; }
.bulk-car { margin: 0 0 0.55rem; }
.bulk-car:last-child { margin-bottom: 0; }
.bulk-car-head { font-weight: 600; font-size: 0.85rem; }
.bulk-car-notes { color: var(--muted); font-size: 0.75rem; margin: 0.1rem 0; }
.bulk-part { padding: 0.15rem 0 0.15rem 0.6rem; border-left: 2px solid var(--border); margin-top: 0.2rem; }
.bulk-part-name { font-size: 0.82rem; }
.bulk-part-meta { color: var(--muted); font-size: 0.75rem; margin-left: 0.4rem; }
.bulk-part-notes { color: var(--muted); font-size: 0.72rem; }
.bulk-part--empty { color: var(--muted); font-style: italic; font-size: 0.8rem; }
