/* ============================================================
   Jones & Horan Inventory — Admin UI
   Style: "the horologist's ledger" — warm paper field, espresso
   ink, old-brass identity. Catalog serif (Fraunces) for display,
   Instrument Sans for UI, Spline Sans Mono for barcodes/lots.
   Green is reserved strictly for semantic success/sold.
   ============================================================ */

:root {
  /* Color system — paper / ink / brass */
  --c-primary:        #26201a;   /* espresso ink: sidebar, segmented controls, bulk bar */
  --c-primary-700:    #191512;
  --c-primary-50:     #f3ede1;   /* warm cream highlight */
  --c-accent:         #916018;   /* old brass — the identity color */
  --c-accent-700:     #7a4f12;
  --c-secondary:      #8a5a10;   /* links: bronze */
  --c-bg:             #f6f4ef;   /* paper */
  --c-surface:        #FFFFFF;
  --c-surface-2:      #faf8f2;
  --c-text:           #221d15;   /* warm ink */
  --c-muted:          #6e6555;
  --c-muted-2:        #a29883;
  --c-border:         #e7e1d3;
  --c-border-strong:  #cfc6b0;
  --c-danger:         #b3261e;
  --c-danger-50:      #fbeeea;
  --c-warn:           #9a6a03;
  --c-ring:           color-mix(in srgb, var(--c-accent) 40%, transparent);

  /* Brass ramp (identity accents) */
  --brass-100: #f6ead0;
  --brass-300: #d9b878;
  --brass-400: #c39a45;
  --brass-500: #a67c28;

  /* Semantic success / "sold" (kept green on purpose) */
  --c-ok:     #0f7a4a;
  --c-ok-700: #0c5f3a;
  --c-ok-50:  #ecfdf5;
  --c-ok-200: #bbf7d0;

  /* Spacing scale (4px) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  /* Radius — a touch crisper than before; ledger plates, not bubbles */
  --r-sm: 5px; --r-md: 7px; --r-lg: 10px; --r-pill: 999px;

  /* Shadow (warm-tinted) */
  --sh-1: 0 1px 2px rgba(46,36,20,.05), 0 1px 3px rgba(46,36,20,.07);
  --sh-2: 0 4px 12px rgba(46,36,20,.09);
  --sh-pop: 0 10px 30px rgba(34,25,12,.20);

  /* Type */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Spline Sans Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Textures */
  --grain-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.045 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");

  /* Sidebar */
  --sb-w: 240px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--c-bg);
  color: var(--c-text);
  font: 14px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

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

/* Native controls pick up the brass identity too. */
input[type=checkbox], input[type=radio], progress { accent-color: var(--c-accent); }
::selection { background: var(--brass-100); color: var(--c-text); }

/* --- Auth (login) layout --- */
main.auth {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-4);
  padding: var(--sp-4);
  /* Espresso field with a faint brass glow and paper grain — the one
     theatrical moment in an otherwise workmanlike tool. */
  background:
    var(--grain-light),
    radial-gradient(90% 70% at 50% 0%, rgba(195,154,69,.16), transparent 60%),
    linear-gradient(180deg, #221c15 0%, #171310 100%);
  background-color: #171310;
}

/* Admin-set system alert banner (test-db warning etc.) */
.sys-alert {
  display: flex; align-items: flex-start; gap: 10px;
  width: 100%; max-width: 400px;
  margin: 0 auto;
  padding: 12px 14px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: var(--r-md);
  color: #7c4a03;
  font-size: 13px; font-weight: 500;
  line-height: 1.4;
}
.sys-alert .icon-sm { width: 18px; height: 18px; color: #b45309; flex-shrink: 0; margin-top: 1px; }
/* In-app (post-login) the banner spans the content column. */
.content > .sys-alert { max-width: none; margin-bottom: var(--sp-4); }
.card.login-card {
  width: 100%; max-width: 400px;
  border-top: 4px solid var(--c-accent);
  box-shadow: var(--sh-pop);
}
.login-card h1 { margin-top: 0; font-size: 24px; }
.login-card .login-lead { color: var(--c-muted); margin-bottom: var(--sp-5); }
.login-card .login-brand {
  display:flex; align-items:center; gap: var(--sp-3); margin-bottom: var(--sp-5);
}
.login-card .login-brand .brand-mark { width: 36px; height: 36px; }

/* --- App shell --- */
.nav-toggle-input { position: absolute; opacity: 0; pointer-events: none; }
.app {
  display: grid;
  grid-template-columns: var(--sb-w) 1fr;
  min-height: 100vh;
}
.sidebar {
  background:
    var(--grain-light),
    linear-gradient(180deg, #241e17 0%, #191512 100%);
  background-color: #1b1712;
  color: #d8d1c4;
  display: flex; flex-direction: column;
  position: sticky; top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 30;
  box-shadow: inset -1px 0 0 rgba(195, 154, 69, .22);   /* brass hairline edge */
}
.sidebar-brand {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand-mark {
  width: 32px; height: 32px; border-radius: var(--r-md);
  background: linear-gradient(140deg, var(--brass-400), var(--c-accent-700));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.28);
  color: #fff;
  font-family: var(--font-display); font-weight: 650; letter-spacing: .02em;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.brand-title {
  color: #fff;
  font-family: var(--font-display);
  font-weight: 600; font-size: 15px; line-height: 1.2; letter-spacing: .015em;
}
.brand-sub { color: rgba(255,255,255,.6); font-size: 11px; }
.nav-close { display: none; margin-left: auto; color: rgba(255,255,255,.7); padding: 4px; cursor: pointer; }

.sidenav { display: flex; flex-direction: column; gap: 2px; padding: var(--sp-3) var(--sp-3); }
.navlink {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 9px 12px;
  color: rgba(255,255,255,.78);
  border-radius: var(--r-md);
  font-size: 13px; font-weight: 500;
  transition: background 150ms ease, color 150ms ease;
}
.navlink:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.navlink.active {
  background: linear-gradient(180deg, rgba(217,184,120,.16), rgba(217,184,120,.07));
  color: #fff;
  box-shadow: inset 3px 0 0 var(--brass-400);
}
.navlink .icon { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }

.sidebar-foot {
  margin-top: auto;
  padding: var(--sp-3) var(--sp-3) var(--sp-4);
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex; flex-direction: column; gap: var(--sp-2);
}
.user-chip { display: flex; align-items: center; gap: var(--sp-3); padding: 6px 8px; }
.avatar {
  width: 32px; height: 32px; border-radius: var(--r-pill);
  background: linear-gradient(140deg, var(--brass-400), var(--c-accent-700));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 600; font-size: 13px;
}
.user-name { color: #fff; font-size: 13px; font-weight: 500; }
.user-role { color: rgba(255,255,255,.55); font-size: 11px; }
.logout-link {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 8px 10px; border-radius: var(--r-md);
  color: rgba(255,255,255,.75); font-size: 13px;
}
.logout-link:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }

/* --- Main area --- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  padding: var(--sp-3) var(--sp-6);
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: 60px;
}
.nav-open { display: none; cursor: pointer; padding: 6px; }
.topbar h1 { margin: 0; font-size: 19px; }
.crumbs { display: flex; align-items: center; gap: 4px; color: var(--c-muted); font-size: 12px; margin-bottom: 2px; }
.crumbs a { color: var(--c-muted); }
.crumbs a:hover { color: var(--c-text); }
.crumbs .icon-xs { width: 12px; height: 12px; opacity: .6; }
.topbar-title { min-width: 0; }
.content { padding: var(--sp-6); max-width: 1400px; width: 100%; margin: 0 auto; }

/* --- Mobile nav --- */
.nav-scrim {
  display: none;
  position: fixed; inset: 0;
  background: rgba(23,19,16,.5);
  z-index: 25;
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: 280px; transform: translateX(-100%);
    transition: transform 220ms ease;
  }
  .nav-toggle-input:checked ~ .app .sidebar { transform: translateX(0); }
  .nav-toggle-input:checked ~ .app .nav-scrim { display: block; }
  .nav-open  { display: inline-flex; }
  .nav-close { display: inline-flex; }
}
.nav-open, .nav-close { color: inherit; border-radius: var(--r-sm); }
.nav-open:hover, .nav-close:hover { background: rgba(0,0,0,.04); }

/* --- Common --- */
h1 {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 650; letter-spacing: .005em;
  margin: 0;
}
h2 {
  font-family: var(--font-display);
  font-size: 16px; font-weight: 600; letter-spacing: .01em;
  margin: 0 0 var(--sp-3);
}
h3 { font-size: 13px; font-weight: 600; margin: 0 0 var(--sp-2); }
.muted { color: var(--c-muted); }
.small { font-size: 12px; }
.mono  { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.icon { width: 20px; height: 20px; flex-shrink: 0; }
.icon-sm { width: 16px; height: 16px; }
.icon-xs { width: 12px; height: 12px; }

.row { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.spread { display:flex; align-items:center; justify-content:space-between; gap: var(--sp-3); }
.stack { display:flex; flex-direction:column; gap: var(--sp-3); }

/* --- Card --- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--sh-1);
}
.card + .card { margin-top: var(--sp-4); }
.card-h {
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom: var(--sp-4);
}
.card-h h2 { margin: 0; }

/* --- Forms --- */
label { display: block; font-size: 12px; color: var(--c-muted); font-weight: 500; }
label > input, label > select, label > textarea { display: block; margin-top: 4px; }
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=search], input[type=tel], input[type=url],
select, textarea {
  font: 14px/1.4 var(--font-sans);
  padding: 9px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: #fff;
  color: var(--c-text);
  width: 100%;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-ring);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-4) var(--sp-5);
}
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid .form-actions { display:flex; gap: var(--sp-2); margin-top: var(--sp-2); }
@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; gap: var(--sp-4); }
  /* Bigger, tap-friendly fields on phones. 16px font stops iOS Safari
     from auto-zooming when a field gains focus. */
  input[type=text], input[type=password], input[type=email], input[type=number],
  input[type=date], input[type=search], input[type=tel], input[type=url],
  select, textarea {
    font-size: 16px;
    padding: 12px 14px;
  }
  textarea { min-height: 96px; }
  label { font-size: 13px; }
}

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  font: inherit; font-weight: 500;
  border: 1px solid var(--c-border);
  background: #fff;
  color: var(--c-text);
  border-radius: var(--r-md);
  cursor: pointer;
  text-decoration: none;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 80ms ease;
  white-space: nowrap;
}
.btn:hover { background: var(--c-surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--c-ring); }
.btn .icon, .btn .icon-sm { width: 16px; height: 16px; }
.btn.primary {
  background: var(--c-accent); border-color: var(--c-accent); color: #fff;
}
.btn.primary:hover { background: var(--c-accent-700); border-color: var(--c-accent-700); }
.btn.secondary {
  background: var(--c-primary); border-color: var(--c-primary); color: #fff;
}
.btn.secondary:hover { background: var(--c-primary-700); border-color: var(--c-primary-700); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--c-muted); }
.btn.ghost:hover { background: var(--c-surface-2); color: var(--c-text); }
.btn.danger { color: var(--c-danger); border-color: #f3c8c2; background: #fff; }
.btn.danger:hover { background: var(--c-danger-50); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }

/* Submitting: spinner in front of the label (added by the footer script). */
.btn-loading { position: relative; pointer-events: none; }
.btn-loading::before {
  content: "";
  width: 14px; height: 14px; flex: none;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 600ms linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px;
  border: 1px solid var(--c-border);
  background: #fff;
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--c-muted);
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}
.icon-btn:hover { background: var(--c-surface-2); color: var(--c-text); text-decoration: none; }
.icon-btn.danger:hover { background: var(--c-danger-50); color: var(--c-danger); border-color: #f3c8c2; }

/* --- Record edit lock (edit.php) --- */
.lock-banner {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap;
  padding: 12px 14px; margin-bottom: var(--sp-4);
  background: #fdf3d7; border: 1px solid var(--brass-300);
  border-left: 3px solid var(--c-accent);
  border-radius: var(--r-md); color: #6b4b13;
}
.lock-banner-text { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.lock-banner-text .icon-sm { width: 20px; height: 20px; color: var(--c-accent-700); flex: none; margin-top: 1px; }
.lock-banner-text strong { color: var(--c-accent-700); }
.lock-banner-text .small { color: #6b4b13; margin-top: 2px; line-height: 1.45; }
.lock-banner-action { flex: none; }
.lock-hint {
  display: flex; align-items: center; gap: 6px;
  margin: 0 0 var(--sp-4);
}
.lock-hint .icon-sm { width: 15px; height: 15px; flex: none; }

/* --- Flash --- */
.flash {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: 10px 14px; border-radius: var(--r-md); margin-bottom: var(--sp-4);
  font-size: 13px;
  animation: flash-in 220ms ease-out;
  transition: opacity 260ms ease, transform 260ms ease;
}
.flash-ok    { background: var(--c-ok-50); color: var(--c-ok-700); border: 1px solid var(--c-ok-200); }
.flash-error { background: var(--c-danger-50); color: var(--c-danger); border: 1px solid #efc7bd; }
.flash ul { margin: 0; padding-left: 20px; }
.flash-msg { flex: 1; }
.flash-x {
  flex: none; margin: -4px -6px -4px 0;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border: 0; background: none; color: inherit;
  font-size: 18px; line-height: 1; opacity: .55;
  border-radius: var(--r-md); cursor: pointer;
}
.flash-x:hover { opacity: 1; background: rgba(0,0,0,.06); }
.flash-x:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--c-ring); opacity: 1; }
.flash-hide { opacity: 0; transform: translateY(-4px); }
@keyframes flash-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}

/* --- Toolbar --- */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap;
}
.toolbar .left { display:flex; align-items: center; gap: var(--sp-3); }
.toolbar .right { display:flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.toolbar .actions { display:flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }

/* --- Sort-group reordering (drag & drop) --- */
.sg-hint { display: inline-flex; align-items: center; gap: 6px; }
.sg-hint .icon-sm { width: 15px; height: 15px; opacity: .8; }
.sg-status { font-size: 12px; font-weight: 500; min-height: 1em; }
.sg-status.saving { color: var(--c-muted); }
.sg-status.ok  { color: var(--c-ok-700); }
.sg-status.err { color: var(--c-danger); }
th.sg-grip-col, td.sg-grip-col { width: 34px; text-align: center; padding-left: 8px; padding-right: 0; }
.sg-grip {
  display: inline-grid; place-items: center;
  color: var(--c-muted-2); cursor: grab; line-height: 0;
}
.sg-grip:active { cursor: grabbing; }
#sgBody tr { transition: background 120ms ease; }
#sgBody tr:hover { background: #f8f4eb; }
#sgBody tr.sg-dragging {
  opacity: .5;
  background: var(--brass-100);
  box-shadow: var(--sh-2);
}
#sgBody .actions-cell { gap: 4px; }
@media (max-width: 720px) {
  /* Touch can't use native drag — hide the grip; the up/down arrows reorder.
     Specificity must beat table.grid.stack-mobile td { display:flex }. */
  table.grid.stack-mobile th.sg-grip-col,
  table.grid.stack-mobile td.sg-grip-col { display: none; }
}

/* --- Lot Number Manager --- */
#lotBody .lot-num {
  width: 64px; padding: 5px 6px; text-align: center;
  font-family: var(--font-mono); font-size: 13px; font-variant-numeric: tabular-nums;
  border-color: var(--c-border);
}
#lotBody .lot-num:focus { border-color: var(--c-accent); }
#lotBody tr.lot-changed .lot-num { color: var(--c-accent-700); font-weight: 600; }
#lotBody tr.lot-changed { background: #fdfaf2; }          /* number will change on save */
#lotBody tr.lot-changed:hover { background: #f8f4eb; }
#lotBody tr.sg-dragging { opacity: .5; background: var(--brass-100); box-shadow: var(--sh-2); }
#lotBody tr.lot-flash { animation: lot-flash 1.2s ease-out; }   /* pulse after a number jump */
@keyframes lot-flash {
  0%   { background: var(--brass-300); }
  100% { background: transparent; }
}
#lotBody .actions-cell { gap: 4px; }
#lotTable td .desc { max-width: 420px; }

/* --- Customer extra addresses (collapse when empty) --- */
details.addr-extra { border-top: 1px solid var(--c-border); }
details.addr-extra:first-of-type { border-top: 0; }
details.addr-extra > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 0; font-weight: 600; font-size: 13px;
}
details.addr-extra > summary::-webkit-details-marker { display: none; }
details.addr-extra > summary::before {
  content: ""; width: 7px; height: 7px; flex: none;
  border-right: 2px solid var(--c-muted); border-bottom: 2px solid var(--c-muted);
  transform: rotate(-45deg); transition: transform 150ms ease;
}
details.addr-extra[open] > summary::before { transform: rotate(45deg); }
details.addr-extra > div { padding-bottom: var(--sp-4); }

/* --- Consignor commission editor --- */
#commTiers td { padding: 6px 10px; vertical-align: middle; }
#commTiers input { width: 100%; max-width: 160px; text-align: right; font-variant-numeric: tabular-nums; }
#commTiers thead th { font-size: 11px; }
#commTestOut { font-variant-numeric: tabular-nums; }
.search-input {
  position: relative; display:flex; align-items:center;
}
.search-input input { padding-left: 32px; min-width: 240px; }
.search-input .icon {
  position: absolute; left: 9px; width: 16px; height: 16px; color: var(--c-muted);
}

/* --- KPI cards --- */
.kpis {
  display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  margin-bottom: var(--sp-5);
}
.kpi {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-5);
  box-shadow: var(--sh-1);
  display: flex; align-items: center; gap: var(--sp-4);
  color: inherit;
  text-decoration: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 80ms ease;
}
/* Anchor variants are clickable — give them a subtle lift on hover. */
a.kpi { cursor: pointer; }
a.kpi:hover {
  border-color: var(--c-border-strong);
  box-shadow: 0 4px 12px rgba(46,36,20,.09);
  text-decoration: none;
}
a.kpi:active { transform: translateY(1px); }
a.kpi:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--c-ring); }
.kpi .kpi-icon {
  width: 40px; height: 40px; border-radius: var(--r-md);
  background: var(--c-primary-50); color: var(--c-primary);
  display: grid; place-items: center;
}
.kpi .kpi-icon.green  { background: var(--c-ok-50); color: var(--c-ok-700); }
.kpi .kpi-icon.blue   { background: var(--brass-100); color: var(--c-accent-700); }
.kpi .kpi-icon.amber  { background: #fdf3d7; color: #92610e; }
.kpi .kpi-label { color: var(--c-muted); font-size: 12px; font-weight: 500; }
.kpi .kpi-value {
  font-family: var(--font-display);
  font-size: 26px; font-weight: 650; line-height: 1.05;
  font-variant-numeric: tabular-nums; letter-spacing: .01em;
  margin-top: 2px;
}

/* --- Table --- */
.table-wrap {
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* Scroll-edge shadows: hint that the table pans sideways (phones). The
     surface-colored "covers" scroll with the content and reveal the fixed
     edge shadows only when there is more to see in that direction. */
  background:
    linear-gradient(to right, var(--c-surface) 30%, rgba(255,255,255,0)),
    linear-gradient(to left,  var(--c-surface) 30%, rgba(255,255,255,0)) 100% 0,
    radial-gradient(farthest-side at 0 50%, rgba(46,36,20,.18), transparent),
    radial-gradient(farthest-side at 100% 50%, rgba(46,36,20,.18), transparent) 100% 0;
  background-color: var(--c-surface);
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--c-border);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}
table.grid thead th {
  /* Sticky to the top of the horizontal-scroll wrap (top:0). A 60px offset
     here would push the header 60px below the table top — since .table-wrap's
     overflow-x makes it the scroll container, not the viewport — leaving an
     empty band and hiding the first row. */
  position: sticky; top: 0; background: var(--c-surface-2);
  color: var(--c-muted); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .07em;
  z-index: 2;
  box-shadow: inset 0 -1px 0 var(--c-border-strong);
}
table.grid tbody tr { transition: background 120ms ease; }
table.grid tbody tr:hover { background: #f8f4eb; }
table.grid tbody tr.row-clickable { cursor: pointer; }
table.grid tbody tr.row-clickable:hover { background: var(--c-primary-50); }

/* Bulk select column */
table.grid th.select-col, table.grid td.select-col {
  width: 34px; text-align: center; padding-left: 10px; padding-right: 4px;
}
table.grid td.select-col input, table.grid th.select-col input {
  width: 16px; height: 16px; cursor: pointer; margin: 0;
}
table.grid tbody tr:has(.row-check:checked) { background: var(--c-primary-50); }

/* Bulk action bar (sticky bottom; appears when items are selected) */
.bulk-bar {
  position: sticky; bottom: var(--sp-4);
  margin-top: var(--sp-4);
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--c-primary);
  color: #fff;
  border-radius: var(--r-lg);
  box-shadow: 0 10px 24px rgba(34,25,12,.22);
  z-index: 15;
  transition: transform 180ms ease, opacity 150ms ease;
}
.bulk-bar[data-empty="true"] {
  transform: translateY(16px); opacity: 0; pointer-events: none; visibility: hidden;
}
.bulk-count { font-size: 13px; }
.bulk-count strong { font-size: 15px; }
.bulk-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.bulk-inline { display: inline-flex; align-items: center; gap: 4px; }
.bulk-bar select, .bulk-bar input[type=text] {
  height: 30px; font-size: 12px; padding: 4px 8px; width: auto;
  background: #fff; border: 0; border-radius: var(--r-md);
}
.bulk-bar .btn.sm { background: rgba(255,255,255,.16); color: #fff; border-color: transparent; }
.bulk-bar .btn.sm:hover { background: rgba(255,255,255,.28); }
.bulk-bar .btn.ghost { color: rgba(255,255,255,.85); }
.bulk-bar .btn.ghost:hover { background: rgba(255,255,255,.14); }

/* Click-to-sort column headers */
table.grid th.sortable { padding: 0; }
table.grid th.sortable a {
  display: flex; align-items: center; gap: 3px;
  padding: 11px 14px;
  color: var(--c-muted); text-decoration: none;
  white-space: nowrap;
}
table.grid th.sortable.num a { justify-content: flex-end; }
table.grid th.sortable a:hover { color: var(--c-text); background: #eef1f5; }
table.grid th.sortable.active a { color: var(--c-primary); }
table.grid th.sortable .sort-caret { font-size: 9px; line-height: 1; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.grid td.condition { color: var(--c-muted); font-size: 12px; }
table.grid td.condition .clip { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
table.grid td .desc { max-width: 440px; white-space: pre-wrap; font-size: 13px; }
table.grid td .desc-clip { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

/* Inventory filter bar (below the primary toolbar). */
.filter-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
}
.filter-field {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--c-muted); font-weight: 500;
}
.filter-field .filter-label {
  color: var(--c-muted); font-weight: 500;
}
.filter-field select,
.filter-field input[type=text],
.filter-field input[type=date] {
  padding: 5px 8px; font-size: 12px; height: 30px; min-width: 130px; width: auto;
}
.filter-field input[type=date] { min-width: 140px; }

.filter-check {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--c-text); cursor: pointer;
  padding: 5px 10px; border: 1px solid var(--c-border); border-radius: var(--r-pill);
  background: var(--c-surface-2); font-weight: 500;
}
.filter-check input { margin: 0; width: auto; }
.filter-check:has(input:checked) {
  background: var(--brass-100); border-color: var(--c-accent); color: var(--c-accent-700);
}

/* Sold / Unsold segmented control */
.pill-toggle {
  display: inline-flex;
  border: 1px solid var(--c-border);
  border-radius: var(--r-pill);
  background: var(--c-surface-2);
  padding: 2px;
}
.pill-toggle label {
  padding: 5px 14px;
  font-size: 12px; font-weight: 500;
  border-radius: var(--r-pill);
  cursor: pointer;
  color: var(--c-muted);
  transition: background 120ms ease, color 120ms ease;
  display: inline-flex; align-items: center;
}
.pill-toggle label:hover { color: var(--c-text); }
.pill-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.pill-toggle label.active,
.pill-toggle label:has(input:checked) {
  background: var(--c-primary);
  color: #fff;
}

/* Item column — everything stacks top-left, no truncation. */
table.grid td.item-cell { vertical-align: top; text-align: left; }
table.grid td.item-cell .desc {
  margin-top: 2px;
  max-width: 320px;
  white-space: pre-wrap;
  font-size: 13px;
  color: var(--c-text);
  line-height: 1.35;
  overflow: visible;
  display: block;
}

/* Description-Condition — render inline HTML (br / strong / etc.) with full
   text and readable line-height.  No max-width cap. */
table.grid td.condition-cell {
  vertical-align: top;
  color: var(--c-muted);
  font-size: 12px;
  line-height: 1.45;
  min-width: 260px;
}
table.grid td.condition-cell strong,
table.grid td.condition-cell b { color: var(--c-text); font-weight: 600; }
table.grid td.condition-cell em,
table.grid td.condition-cell i { color: var(--c-text); }

/* --- Thumbnails --- */
.thumbs { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.thumbs a { display: inline-block; line-height: 0; }
.thumbs img {
  width: 48px; height: 48px;
  object-fit: cover;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  background: var(--c-surface-2);
  transition: transform 150ms ease;
}
.thumbs img:hover { transform: scale(1.05); }
.thumbs.big img { width: 140px; height: 140px; }

/* --- Badges/pills --- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 500;
  padding: 2px 8px; border-radius: var(--r-pill);
  background: var(--c-primary-50); color: var(--c-primary);
  border: 1px solid color-mix(in srgb, var(--c-primary) 18%, transparent);
}
.pill.green { background: var(--c-ok-50); color: var(--c-ok-700); border-color: var(--c-ok-200); }
.pill.muted { background: var(--c-surface-2); color: var(--c-muted); border-color: var(--c-border); }

/* --- Empty state --- */
.empty {
  padding: var(--sp-8) var(--sp-5);
  text-align: center;
  border: 1px dashed var(--c-border-strong);
  border-radius: var(--r-lg);
  background: var(--c-surface);
  color: var(--c-muted);
}
.empty h3 { color: var(--c-text); margin-bottom: 4px; }
.empty .icon { width: 32px; height: 32px; color: var(--c-muted-2); margin-bottom: 8px; }

/* --- Pager --- */
.pager {
  display: flex; gap: var(--sp-3); align-items: center; justify-content: center;
  margin: var(--sp-4) 0 0;
  flex-wrap: wrap;
}
.pager-nums { display: inline-flex; gap: 2px; align-items: center; }
.pager-num {
  display: inline-grid; place-items: center;
  min-width: 32px; height: 32px; padding: 0 8px;
  border-radius: var(--r-md);
  color: var(--c-text); text-decoration: none;
  font-size: 13px; font-variant-numeric: tabular-nums;
  border: 1px solid transparent;
}
.pager-num:hover { background: var(--c-surface-2); text-decoration: none; border-color: var(--c-border); }
.pager-num.active { background: var(--c-primary); color: #fff; }
.pager-gap { color: var(--c-muted-2); padding: 0 4px; }

/* --- Actions cell --- */
.actions-cell {
  display: flex; gap: 4px; justify-content: flex-end; align-items: center;
}
.inline { display: inline-flex; gap: 4px; align-items: center; }

/* --- Two-col layout for dashboard --- */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: var(--sp-4); }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }

/* --- Mini list --- */
.mini-list { display: flex; flex-direction: column; }
.mini-list .row-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--c-border);
  font-size: 13px;
}
.mini-list .row-item:last-child { border-bottom: 0; }
.mini-list .row-item .meta { color: var(--c-muted); font-size: 12px; }

/* --- Misc --- */
.required-mark { color: var(--c-danger); margin-left: 2px; }
hr.sep { border: 0; border-top: 1px solid var(--c-border); margin: var(--sp-4) 0; }
.kbd {
  font-family: var(--font-mono); font-size: 11px;
  padding: 1px 6px; border-radius: 4px;
  background: var(--c-surface-2); border: 1px solid var(--c-border);
  color: var(--c-muted);
}
.or { color: var(--c-muted); text-align: center; font-size: 12px; padding: 4px 0; }

/* Reports page layout */
.reports-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}
@media (max-width: 900px) {
  .reports-grid { grid-template-columns: 1fr; }
}
.reports-src {
  display: flex;
  margin-bottom: var(--sp-3);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-md);
  overflow: hidden;
}
.reports-src a {
  flex: 1;
  text-align: center;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: var(--c-muted);
  background: var(--c-surface-2);
}
.reports-src a + a { border-left: 1px solid var(--c-border-strong); }
.reports-src a:hover { color: var(--c-text); }
.reports-src a.active {
  background: var(--c-accent);
  color: #fff;
}

/* Segmented status toggle (consignors list) */
.status-toggle {
  display: inline-flex;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-md);
  overflow: hidden;
  flex: none;
}
.status-toggle a {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  color: var(--c-muted);
  background: var(--c-surface-2);
}
.status-toggle a + a { border-left: 1px solid var(--c-border-strong); }
.status-toggle a:hover { color: var(--c-text); }
.status-toggle a.active,
.status-toggle a.active:hover {
  background: var(--c-accent);
  color: #fff;
}

/* Live invoice totals (new-invoice items card) */
.inv-live-totals {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 26px;
  align-items: baseline;
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--c-border);
  font-size: 14px;
  color: var(--c-muted);
  font-variant-numeric: tabular-nums;
}
.inv-live-totals b { color: var(--c-text); font-weight: 600; margin-left: 4px; }
.inv-live-totals .lt-grand { font-size: 16px; }
.inv-live-totals .lt-grand b { color: var(--c-accent); font-size: 20px; }

/* Two-factor authentication (security.php, twofactor.php) */
.totp-code {
  font-family: var(--font-mono, monospace);
  font-size: 20px;
  letter-spacing: 6px;
  text-align: center;
}
.totp-key {
  display: inline-block;
  margin-top: 4px;
  padding: 6px 10px;
  font-size: 14px;
  letter-spacing: 1px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  user-select: all;
}
.qr-box {
  display: inline-block;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-md);
  line-height: 0;
}
.qr-box svg { width: 180px; height: 180px; }
.totp-setup { display: grid; gap: var(--sp-5); }
.totp-step h3 { margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.totp-n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--c-accent); color: #fff;
  font-size: 13px; font-weight: 600;
}
.reports-list .reports-search input { width: 100%; margin-bottom: var(--sp-3); }
.reports-list-scroll {
  max-height: 65vh;
  overflow-y: auto;
  margin: 0 calc(-1 * var(--sp-2));
}
.report-row {
  display: block;
  padding: 10px 12px;
  border-radius: var(--r-md);
  color: var(--c-text);
  text-decoration: none;
  border: 1px solid transparent;
  margin: 0 var(--sp-2);
}
.report-row[hidden] { display: none; }   /* class display: block would otherwise defeat the filter */
.report-row:hover { background: var(--c-surface-2); text-decoration: none; }
.report-row.active {
  background: var(--c-primary-50);
  border-color: color-mix(in srgb, var(--c-primary) 20%, transparent);
}
.report-title { font-weight: 500; font-size: 13px; margin-bottom: 4px; line-height: 1.3; }
.report-meta { display: flex; gap: 4px; flex-wrap: wrap; }

.lead-star {
  display: inline-block;
  color: var(--brass-500);   /* old brass */
  font-size: 14px;
  line-height: 1;
  margin-right: 4px;
  text-shadow: 0 1px 0 rgba(245,158,11,.3);
}

/* Big "create user" form checkbox row */
label.checkrow {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: 8px 0;
  cursor: pointer;
}
label.checkrow input[type=checkbox] { margin-top: 3px; width: auto; }

/* Tight inline checkbox chip for permission toggles in the users table */
.chip-check {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-pill);
  font-size: 12px; cursor: pointer;
}
.chip-check input { margin: 0; }
.chip-check:has(input:checked) {
  background: var(--brass-100);
  border-color: var(--c-accent);
  color: var(--c-accent-700);
}
.chip-check:has(input:disabled) { cursor: not-allowed; opacity: .85; }
.perms-form { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* Inline row link — bold, underline-on-hover. */
.row-link { color: var(--c-text); text-decoration: none; }
.row-link:hover { text-decoration: underline; color: var(--c-primary); }

/* --- Camera scanner modal (Quick Lookup) --- */
.scan-modal {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .55);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-4);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.scan-modal[hidden] { display: none; }
.scan-modal-card {
  background: #fff;
  border-radius: var(--r-lg);
  max-width: 460px;
  width: 100%;
  box-shadow: var(--sh-pop);
  display: flex; flex-direction: column;
  max-height: calc(100dvh - 32px);
  overflow: hidden;
}
.scan-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 15px;
  padding: var(--sp-4);
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}
.scan-reader {
  width: 100%;
  flex: 1 1 auto;
  min-height: 220px;
  max-height: 55vh;
  background: #0f172a;
  overflow: hidden;
  position: relative;
}
/* html5-qrcode injects a <video> + overlay <div>s with inline width/height
   based on the camera's native resolution.  Force them to fill the reader
   and stay inside the modal viewport. */
.scan-reader video,
.scan-reader > div > video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block;
}
.scan-reader > div {
  width: 100% !important;
  height: 100% !important;
  padding: 0 !important;
}
.scan-status {
  text-align: center;
  min-height: 1.4em;
  padding: var(--sp-3) var(--sp-4);
}
.scan-modal-foot {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--c-border);
  display: flex; justify-content: flex-end;
  flex-shrink: 0;
}
@media (max-width: 600px) {
  .scan-modal { padding: 0; align-items: stretch; }
  .scan-modal-card {
    border-radius: 0;
    max-width: none;
    max-height: 100dvh;
    height: 100dvh;
  }
  .scan-reader { max-height: none; }
}

/* Scanner hint banner on Quick Lookup. */
.scan-hint {
  display: flex; align-items: center; gap: var(--sp-3);
  background: var(--brass-100);
  border: 1px solid var(--brass-300);
  color: var(--c-accent-700);
  padding: 10px 14px;
  border-radius: var(--r-md);
  margin-bottom: var(--sp-4);
  font-size: 13px;
}
.scan-hint .icon-sm {
  width: 18px; height: 18px;
  color: var(--c-accent-700);
  flex-shrink: 0;
}
.scan-hint .muted { color: var(--c-accent-700); opacity: .8; }

/* --- Page intro banner (export.php) --- */
.page-intro {
  display: flex; align-items: flex-start; gap: var(--sp-4);
  padding: var(--sp-5);
  background: linear-gradient(180deg, var(--c-primary-50), transparent);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  margin-bottom: var(--sp-4);
}
.page-intro-icon {
  width: 44px; height: 44px;
  border-radius: var(--r-md);
  background: var(--c-primary);
  color: #fff;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.page-intro-icon .icon { width: 22px; height: 22px; }
.info-link {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: 4px;
  font-weight: 500;
}

/* --- Picker toolbar (search + bulk actions) --- */
.picker-toolbar {
  display: flex; align-items: center; gap: var(--sp-3);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}
.search-input { position: relative; }
.search-input .filter-clear {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: transparent; border: 0; cursor: pointer;
  width: 28px; height: 28px; border-radius: var(--r-sm);
  color: var(--c-muted); display: grid; place-items: center;
}
.search-input .filter-clear:hover { background: var(--c-surface-2); color: var(--c-text); }

/* --- Auction card picker --- */
.auction-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--sp-3);
}
.auction-card {
  position: relative;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 12px 14px;
  background: #fff;
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease, transform 80ms ease;
}
.auction-card[hidden] { display: none; }
.auction-card:hover {
  border-color: var(--c-border-strong);
  box-shadow: 0 1px 3px rgba(46,36,20,.07);
}
.auction-card:active { transform: scale(0.99); }
.auction-card .auction-check {
  /* Hide the native control; we use a custom indicator. */
  position: absolute; opacity: 0; pointer-events: none;
}
.auction-card-body { flex: 1; min-width: 0; }
.auction-card-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--c-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.auction-card-meta {
  display: flex; align-items: baseline; gap: 6px;
  margin-top: 3px;
  font-size: 12px;
  color: var(--c-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.auction-card-meta .dot { opacity: .55; }
.auction-card-check {
  flex-shrink: 0;
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 1.5px solid var(--c-border-strong);
  background: #fff;
  display: grid; place-items: center;
  color: transparent;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.auction-card-check .icon-sm { width: 14px; height: 14px; }

/* Selected state */
.auction-card:has(.auction-check:checked) {
  border-color: var(--c-accent);
  background: var(--brass-100);
}
.auction-card:has(.auction-check:checked) .auction-card-check {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: #fff;
}

/* Focus ring on the card when the hidden checkbox is focused (keyboard nav) */
.auction-card:has(.auction-check:focus-visible) {
  box-shadow: 0 0 0 3px var(--c-ring);
  outline: none;
}

/* --- Collapsible "what's in CSV" --- */
.card.collapse details summary {
  cursor: pointer;
  list-style: none;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3);
  padding: 4px 0;
}
.card.collapse details summary::-webkit-details-marker { display: none; }
.card.collapse details summary::after {
  content: '▾';
  color: var(--c-muted);
  transition: transform 150ms ease;
}
.card.collapse details[open] summary::after { transform: rotate(180deg); }
.csv-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px var(--sp-4);
  margin-top: var(--sp-3);
}
.csv-columns > div {
  padding: 6px 10px;
  background: var(--c-surface-2);
  border-radius: var(--r-sm);
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}

/* Inline download bar inside the picker card. */
.picker-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: var(--sp-4); padding-top: var(--sp-4);
  border-top: 1px solid var(--c-border);
  gap: var(--sp-3); flex-wrap: wrap;
}

/* --- Result table toolbar (filter chips + download) --- */
.result-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); flex-wrap: wrap;
  margin-bottom: var(--sp-3);
}
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  font: inherit; font-size: 12px; font-weight: 500;
  color: var(--c-muted);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.chip:hover:not([disabled]) {
  background: #fff; color: var(--c-text); border-color: var(--c-border-strong);
}
.chip.active {
  background: var(--c-primary);
  color: #fff;
  border-color: var(--c-primary);
}
.chip.active .chip-count {
  background: rgba(255,255,255,.18); color: #fff;
}
.chip[disabled] { opacity: .45; cursor: not-allowed; }
.chip-count {
  display: inline-grid; place-items: center;
  min-width: 22px; height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--c-border);
  color: var(--c-muted);
  font-size: 11px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.chip-danger.active {
  background: var(--c-danger);
  border-color: var(--c-danger);
}
.chip-danger:hover:not([disabled]) {
  color: var(--c-danger); border-color: #f3c8c2;
}

/* Keep old class names working as aliases (not used post-redesign) */
.auction-picker, .check-row, .check-label { /* legacy */ }

/* --- Invoice screen + print styling --- */
.invoice-sheet {
  max-width: 800px;
  margin: 0 auto var(--sp-5);
  padding: 32px;
}
.invoice-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: var(--sp-4);
  padding-bottom: var(--sp-4);
  border-bottom: 2px solid var(--c-text);
  margin-bottom: var(--sp-4);
}
.invoice-brand { display: flex; align-items: flex-start; gap: 12px; }
.invoice-brand .brand-mark { width: 48px; height: 48px; font-size: 18px; flex-shrink: 0; }
.invoice-logo { max-height: 72px; max-width: 200px; object-fit: contain; flex-shrink: 0; }
.invoice-brand-text { min-width: 0; }
.invoice-brand-text * { line-height: 1.35; }
.invoice-brand-text a { color: inherit; text-decoration: none; }
.invoice-biz { font-size: 18px; font-weight: 700; color: var(--c-text); }
.invoice-biz-line { font-size: 12px; color: var(--c-muted); }
.invoice-meta { text-align: right; font-size: 13px; }
.invoice-meta > div + div { margin-top: 6px; }

.invoice-parties {
  display: grid; grid-template-columns: 1fr 200px; gap: var(--sp-4);
  margin-bottom: var(--sp-4);
  font-size: 13px;
}
.invoice-payment { text-align: right; }

table.invoice-lines {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--sp-4);
  font-size: 13px;
}
table.invoice-lines th, table.invoice-lines td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--c-border);
  text-align: left;
  vertical-align: top;
}
table.invoice-lines thead th { border-bottom: 2px solid var(--c-text); font-size: 11px; color: var(--c-muted); text-transform: uppercase; letter-spacing: .04em; }
table.invoice-lines .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.invoice-lines tfoot th { border-bottom: 0; }
table.invoice-lines tr.invoice-total th, table.invoice-lines tr.invoice-total td {
  border-top: 2px solid var(--c-text);
  font-size: 15px;
  padding-top: 10px;
}
.invoice-notes { margin: var(--sp-4) 0; font-size: 12px; }
.invoice-foot { text-align: center; margin-top: var(--sp-5); }
.invoice-foot-msg { font-size: 13px; color: var(--c-text); margin-bottom: 4px; }

/* Line-item entry table on the New Invoice form. */
table.line-items { width: 100%; }
table.line-items th { font-size: 11px; color: var(--c-muted); }
table.line-items td { padding: 4px; }
table.line-items input { width: 100%; }
table.line-items td:last-child { width: 40px; text-align: right; }

.pay-choices { display: flex; gap: 6px; flex-wrap: wrap; }
.pay-choice {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-pill);
  font-size: 12px; cursor: pointer;
  background: var(--c-surface-2);
}
.pay-choice input { margin: 0; width: auto; }
.pay-choice:has(input:checked) {
  background: var(--c-primary); color: #fff; border-color: var(--c-primary);
}

@media print {
  /* Kill the app chrome. */
  .sidebar, .topbar, .no-print, .filter-bar, .toolbar { display: none !important; }
  body { background: #fff !important; }
  .app, .main, .content { display: block !important; padding: 0 !important; margin: 0 !important; }
  .invoice-sheet {
    box-shadow: none !important;
    border: 0 !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  a { color: inherit; text-decoration: none; }
}

/* Top navigation progress bar (shown while a page/filter loads) */
#nav-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: linear-gradient(90deg, var(--c-accent), var(--brass-400));
  box-shadow: 0 0 8px rgba(195,154,69,.55);
  z-index: 2000;
  opacity: 0;
  transition: width 200ms ease, opacity 200ms ease;
  pointer-events: none;
}
#nav-progress.active { opacity: 1; }

/* --- Accessibility: consistent keyboard focus everywhere --- */
a:focus-visible,
.icon-btn:focus-visible,
.pager-num:focus-visible,
.report-row:focus-visible,
th.sortable a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--c-ring);
  border-radius: var(--r-md);
}
.sidenav a:focus-visible,
.logout:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .35);   /* visible on the navy sidebar */
}
tr.row-clickable:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: -2px;
  background: var(--c-primary-50);
}

/* Faster taps on touch devices (no 300ms double-tap delay). */
a, button, input, select, textarea, label { touch-action: manipulation; }

/* Comfortable touch targets on phones (≥44px primary, ≥40px dense contexts).
   Kept at the end of the sheet so these win over the base component sizes. */
@media (max-width: 720px) {
  .btn { min-height: 44px; }
  .btn.sm { min-height: 40px; }
  .icon-btn { width: 40px; height: 40px; }
  .pager-num { min-width: 40px; height: 40px; }
  .flash-x { width: 36px; height: 36px; }
  .bulk-bar select, .bulk-bar input[type=text] { height: 40px; font-size: 16px; }
}

/* ============================================================
   Mobile: tables become stacked ledger cards, filters collapse,
   form actions stick to the thumb zone.
   ============================================================ */

/* Collapsible filter group — on desktop the <details> wrapper is
   transparent (display:contents) and always open; the summary only
   exists on phones. */
details.filter-more,
details.filter-more > .filter-more-body { display: contents; }
details.filter-more > summary { display: none; list-style: none; }
details.filter-more > summary::-webkit-details-marker { display: none; }
.mob-only { display: none; }
@media (max-width: 720px) { .mob-only { display: inline; } }

@media (max-width: 720px) {

  /* --- Filter bar: full-width stacked fields behind a "Filters" toggle --- */
  .filter-bar { align-items: stretch; }
  .filter-bar .pill-toggle { align-self: flex-start; }
  details.filter-more { display: block; width: 100%; }
  details.filter-more > summary {
    display: flex; align-items: center; gap: 8px;
    min-height: 44px; padding: 8px 4px;
    font-size: 13px; font-weight: 600; color: var(--c-text);
    cursor: pointer; user-select: none;
  }
  details.filter-more > summary::after {
    content: ""; width: 8px; height: 8px;
    border-right: 2px solid var(--c-muted); border-bottom: 2px solid var(--c-muted);
    transform: rotate(45deg); margin-left: auto;
    transition: transform 150ms ease;
  }
  details.filter-more[open] > summary::after { transform: rotate(225deg); }
  details.filter-more > summary .filter-count {
    display: inline-grid; place-items: center;
    min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: var(--r-pill);
    background: var(--c-accent); color: #fff;
    font-size: 11px; font-weight: 600;
  }
  details.filter-more > .filter-more-body {
    display: flex; flex-direction: column; gap: var(--sp-3); padding-top: var(--sp-2);
  }
  .filter-more-body .filter-field {
    display: flex; flex-direction: column; align-items: stretch; gap: 4px;
    font-size: 13px;
  }
  .filter-more-body .filter-field select,
  .filter-more-body .filter-field input[type=text],
  .filter-more-body .filter-field input[type=date] {
    height: 44px; font-size: 16px; min-width: 0; width: 100%; padding: 9px 12px;
  }
  .filter-more-body .filter-check { min-height: 44px; }
  .filter-more-body .btn { width: 100%; }

  /* --- Tables opt in with .stack-mobile: each row is a card --- */
  table.grid.stack-mobile,
  table.grid.stack-mobile tbody { display: block; width: 100%; }
  table.grid.stack-mobile thead { display: none; }
  table.grid.stack-mobile tr {
    display: block; position: relative;
    padding: 12px 14px 10px;
    border-bottom: 1px solid var(--c-border);
  }
  table.grid.stack-mobile tr:last-child { border-bottom: 0; }
  table.grid.stack-mobile td {
    display: flex; gap: 10px; align-items: baseline;
    padding: 2px 0; border-bottom: 0;
    text-align: left;                       /* .num cells are right-aligned on desktop */
  }
  table.grid.stack-mobile td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 92px;
    font-size: 10.5px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .07em;
    color: var(--c-muted-2);
    padding-top: 2px;
  }
  /* Lead cell (barcode/title/etc.) acts as the card header. */
  table.grid.stack-mobile td.item-cell,
  table.grid.stack-mobile td.lead-cell {
    display: block; padding: 0 36px 6px 0; font-size: 14px;
  }
  /* Row-select checkbox pins to the card corner. */
  table.grid.stack-mobile td.select-col {
    position: absolute; top: 12px; right: 12px;
    width: auto; padding: 0;
  }
  table.grid.stack-mobile td.actions-cell {
    justify-content: flex-end; gap: 8px; padding-top: 8px;
  }
  table.grid.stack-mobile td:empty { display: none; }

  /* --- Primary form actions stick to the bottom of the screen --- */
  form .form-actions {
    position: sticky; bottom: 0; z-index: 5;
    flex-wrap: wrap;
    background: color-mix(in srgb, var(--c-bg) 93%, transparent);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    margin-top: var(--sp-4);
    padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--c-border);
  }
  form .form-actions .btn { flex: 1 1 auto; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------------------------------
   NAS path — the Windows folder the originals are filed in (inventory.photo_path).
   A browser cannot open S:\… from a web page, so the path is presented to be
   read and copied, not clicked.
   ------------------------------------------------------------------------ */
.jh-path {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0 0;
  font-size: 12.5px;
}
.jh-path .lbl {
  color: var(--muted, #6f6857);
  text-transform: uppercase;
  letter-spacing: .07em;
  font-size: 10.5px;
  font-weight: 600;
  flex: 0 0 auto;
}
.jh-path .val {
  font-family: var(--font-mono, ui-monospace, Menlo, Consolas, monospace);
  background: var(--surface-2, #fdfaf2);
  border: 1px solid var(--border, #e4dfd2);
  border-radius: 5px;
  padding: 3px 8px;
  overflow-wrap: anywhere;
  min-width: 0;
}
.jh-path .val.none { font-family: inherit; color: var(--muted, #6f6857); font-style: italic; }
.jh-path .copy {
  border: 1px solid var(--border, #d9d3c4);
  background: var(--surface, #fff);
  border-radius: 5px;
  padding: 3px 9px;
  font-size: 11.5px;
  cursor: pointer;
  min-height: 26px;
  flex: 0 0 auto;
}
.jh-path .copy:hover { border-color: #C39F52; }
.jh-path .copy.is-copied { background: #C39F52; border-color: #C39F52; color: #14110b; font-weight: 600; }
.jh-path .warn {
  color: #8a5a12;
  background: #fdf3d7;
  border: 1px solid #e8d49a;
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 11.5px;
}

/* The file name under a photo card doubles as a copy button for its full path. */
.pm-card .pm-path {
  font-family: var(--font-mono, ui-monospace, Menlo, Consolas, monospace);
  font-size: 11px;
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted, #6f6857);
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.pm-card .pm-path:hover { color: var(--text, #221d17); text-decoration: underline; }
.pm-card .pm-path.is-copied { color: #6b4b13; font-weight: 600; text-decoration: none; }

/* The NAS folder is editable on the item page: the same row becomes a picker. */
.jh-path select.val,
.jh-path input.val {
  font-family: var(--font-mono, ui-monospace, Menlo, Consolas, monospace);
  font-size: 12.5px;
  color: inherit;
  max-width: 100%;
  min-width: 0;
  flex: 1 1 22rem;
  min-height: 30px;
  padding: 4px 8px;
}
.jh-path select.val { cursor: pointer; }
.jh-path input.val::placeholder { color: var(--muted, #6f6857); opacity: .7; }
.jh-path button[type="submit"] { background: #C39F52; border-color: #C39F52; color: #14110b; font-weight: 600; }
.jh-path button[type="submit"]:hover { filter: brightness(1.06); }
.jh-path label.lbl { align-self: center; }
