/* Clozit admin (#514). Tokens from the owner-approved portal mockup. */
:root {
  --page: #F5F3EF;
  --card: #FFFFFF;
  --ink: #48312A;
  --ink-deep: #2A1C18;
  --ink-2: #6B6663;
  --outline: #D3C3BF;
  --hairline: #EFEEEA;
  --sidebar-rule: #E6DDD9;
  --on-espresso: #FBF9F5;
  --green: #2D6A4F;
  --warn: #9C6E00;
  --danger: #A3261B;
  --serif: 'Noto Serif', Georgia, serif;
  --sans: Manrope, system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, Menlo, monospace;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); color: var(--ink); font-family: var(--sans); font-size: 14px; }
a { color: var(--ink); }
a:hover { color: var(--ink-deep); }
button, input, select { font-family: var(--sans); color: var(--ink); }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- gate (sign-in / notices) ---------- */
.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.gate-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 20px; padding: 28px 24px; display: flex; flex-direction: column; gap: 18px; }
.gate-text { margin: 0; font-size: 15px; line-height: 1.5; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.stack .btn { margin-top: 6px; }
.form-error { margin: 0; min-height: 18px; font-size: 13px; color: var(--danger); }
.gate-sent { margin-bottom: 8px; }
.input-code { font-family: var(--mono); font-size: 20px; letter-spacing: 6px; }
/* Secondary links under a sign-in form: 44px tall so they are a thumb's target on a phone. */
.gate-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 16px; }
.gate-link { min-height: 44px; font-size: 13px; align-self: center; }
.gate-link:disabled { color: var(--ink-2); text-decoration: none; }

/* ---------- shell ---------- */
/* No wrap: between 761 and ~780px the 220px sidebar + the main's 560px basis used to wrap the sidebar
   into a block ABOVE the page on a tablet. Wider, it never wrapped; narrower, phone.css takes over. */
.shell { min-height: 100vh; display: flex; flex-wrap: nowrap; }
.sidebar { flex: 1 1 220px; max-width: 240px; background: var(--card); border-right: 1px solid var(--sidebar-rule); padding: 24px 16px; display: flex; flex-direction: column; gap: 4px; }
.brand { font-family: var(--serif); font-size: 20px; font-weight: 600; padding: 0 10px 18px; }
.gate-card .brand { padding: 0; }
.nav-link { padding: 11px 12px; border-radius: 10px; text-decoration: none; font-size: 14px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.nav-link:hover { background: var(--page); }
.nav-link[aria-current="page"] { background: var(--ink); color: var(--on-espresso); font-weight: 700; }
/* The links' wrapper and the brand row take no box on desktop (their children stay the sidebar's own
   flex items, as before). Below 1024px the sidebar is the menu drawer (phone.css). */
.nav-links, .brand-row { display: contents; }
.topbar, .drawer-scrim, .drawer-close { display: none; }
.badge { background: var(--warn); color: #FFFFFF; border-radius: 999px; padding: 0 8px; font-size: 12px; line-height: 20px; }
.who { margin-top: auto; padding: 18px 10px 0; font-size: 12px; color: var(--ink-2); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.link-button { border: none; background: none; padding: 0; font-size: 12px; font-weight: 700; color: var(--ink); text-decoration: underline; }
.main { flex: 999 1 560px; min-width: 0; padding: 28px 32px; display: flex; flex-direction: column; gap: 18px; }

/* ---------- type ---------- */
h1 { margin: 0; font-family: var(--serif); font-size: 30px; font-weight: 600; }
.lede { font-size: 14px; color: var(--ink-2); max-width: 680px; line-height: 1.45; margin: 0; }
.note { font-size: 13px; color: var(--ink-2); line-height: 1.45; max-width: 680px; margin: 0; }
.back { font-size: 13px; font-weight: 600; }
.field-label { font-size: 12px; font-weight: 700; letter-spacing: 1px; color: var(--ink-2); }
.head-row { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: flex-end; }
.head-col { display: flex; flex-direction: column; gap: 4px; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; height: 44px; padding: 0 18px; border-radius: 12px; font-size: 14px; font-weight: 700; text-decoration: none; border: 1px solid transparent; }
.btn-primary { background: var(--ink); color: var(--on-espresso); }
.btn-primary:hover { color: var(--on-espresso); background: var(--ink-deep); }
.btn-primary:disabled { background: var(--outline); color: #FFFFFF; }
.btn-ghost { background: #FFFFFF; border-color: var(--outline); color: var(--ink); }
.btn-danger { background: var(--danger); color: #FFFFFF; }
.btn-sm { height: 36px; padding: 0 14px; border-radius: 10px; font-size: 13px; }
.input, .select { height: 44px; border: 1px solid var(--outline); border-radius: 12px; padding: 0 12px; font-size: 14px; background: #FFFFFF; min-width: 0; }
.select { min-width: 220px; }

/* ---------- pool ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--outline); background: #FFFFFF; color: var(--ink); font-size: 13px; font-weight: 700; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--on-espresso); }
.search { display: flex; align-items: center; gap: 8px; background: #FFFFFF; border: 1px solid var(--outline); border-radius: 12px; padding: 0 12px; height: 42px; flex: 0 1 300px; }
.search input { border: none; outline: none; flex-grow: 1; min-width: 0; font-size: 14px; background: transparent; }
.search:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }
.table-box { background: var(--card); border-radius: 16px; overflow-x: auto; }
/* The mockup's columns, tightened so the whole row fits beside the sidebar in a 1280px window:
   768px of fixed columns + the item column's 140px floor + 7 gaps of 8 + 2 x 12 row padding =
   988px. STATUS still holds the ONE 150px pill and ACTIONS keeps both 112px slots. Narrower than
   that, the box scrolls and ACTIONS stays pinned (.sticky-end). */
.pool-table { min-width: 1012px; }
.pool-grid { display: grid; grid-template-columns: 80px minmax(140px, 2fr) 88px 64px 156px 88px 80px 236px; gap: 8px; padding: 12px 12px; align-items: center; border-bottom: 1px solid var(--hairline); }
.table-head { font-size: 11px; font-weight: 700; letter-spacing: 1px; color: var(--ink-2); }
.cell-right { text-align: right; }
.cell-mono { font-family: var(--mono); font-size: 13px; }
.cell-dim { color: var(--ink-2); }
.cell-strong { font-weight: 700; }
.cell-clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.item-cell { display: flex; gap: 10px; align-items: center; min-width: 0; }
.thumb { width: 36px; height: 44px; border-radius: 8px; background: var(--page); flex-shrink: 0; object-fit: cover; display: block; }
.item-text { min-width: 0; }
.item-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-detail { font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-block; width: 150px; text-align: center; font-size: 11px; font-weight: 700; letter-spacing: 0.8px; padding: 5px 0; border-radius: 999px; }
.pill-available { background: #EFEEEA; color: #48312A; }
.pill-on_hold { background: #FFF3CD; color: #5C4100; }
.pill-awaiting_approval { background: #D4E6EB; color: #25475C; }
.pill-sold { background: #D8F3DC; color: #1E4D38; }
.actions { display: grid; grid-template-columns: 112px 112px; gap: 12px; justify-content: end; }
/* The ACTIONS slot stays on screen while the columns before it scroll under it on a narrow box. */
.sticky-end { position: sticky; right: 0; align-self: stretch; align-items: center; background: var(--card); box-shadow: -8px 0 0 var(--card), 12px 0 0 var(--card); }
.table-head .sticky-end { display: flex; justify-content: flex-end; }
/* Set by app.js while columns are scrolled out of view under ACTIONS: a soft edge says so. */
.table-box.has-more .sticky-end { box-shadow: -8px 0 0 var(--card), -16px 0 12px -8px rgba(26, 21, 16, 0.22), 12px 0 0 var(--card); }
.action-btn { width: 112px; height: 36px; border-radius: 10px; font-size: 13px; font-weight: 600; border: 1px solid var(--outline); background: #FFFFFF; color: var(--ink); }
.empty { padding: 28px 18px; font-size: 14px; color: var(--ink-2); text-align: center; }

/* ---------- add items ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filter { display: flex; flex-direction: column; gap: 6px; }
.filter-grow { flex-grow: 1; max-width: 360px; }
.cand-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.pick-row { display: flex; align-items: center; gap: 12px; margin: 4px 0 12px; }
.cand-picked { font-size: 13px; color: var(--ink-2); }
.cand-grid .empty { grid-column: 1 / -1; }
.cand { background: var(--card); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 8px; border: 2px solid transparent; cursor: pointer; }
.cand.is-picked { border-color: var(--ink); }
.cand-photo { aspect-ratio: 3 / 4; border-radius: 10px; background: #FDF0F1; width: 100%; object-fit: contain; display: block; }
.cand-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cand-name { font-weight: 700; font-size: 14px; }
.cand-meta { font-size: 12px; color: var(--ink-2); }
.cand input { width: 20px; height: 20px; accent-color: var(--ink); flex-shrink: 0; }
.footer-row { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* ---------- staff ---------- */
.card { background: var(--card); border-radius: 16px; padding: 18px 20px; display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.find { display: flex; flex-direction: column; gap: 6px; flex: 1 1 280px; }
.hits { flex: 1 1 280px; display: flex; flex-direction: column; gap: 8px; }
.hit { display: flex; justify-content: space-between; align-items: center; gap: 10px; border: 1px solid var(--hairline); border-radius: 12px; padding: 8px 8px 8px 14px; }
.hit-name { font-weight: 700; font-size: 14px; }
.hit-meta { font-size: 12px; color: var(--ink-2); }
.hit-tag { font-size: 12px; font-weight: 700; color: var(--green); padding: 0 8px; }
.staff-table { min-width: 620px; }
.staff-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1.4fr; gap: 12px; padding: 14px 20px; align-items: center; border-bottom: 1px solid var(--hairline); }
.staff-grid.table-head { padding: 12px 20px; }

/* ---------- placeholder ---------- */
.soon { background: var(--card); border-radius: 16px; padding: 28px 20px; color: var(--ink-2); font-size: 14px; }

/* ---------- dialog + toast ---------- */
.scrim { position: fixed; inset: 0; background: rgba(26, 21, 16, 0.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.dialog { width: 100%; max-width: 440px; background: #FFFFFF; border-radius: 20px; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.dialog-title { font-family: var(--serif); font-size: 22px; font-weight: 600; margin: 0; }
.dialog-body { font-size: 14px; line-height: 1.5; margin: 0; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.dialog-actions .btn { height: 42px; padding: 0 16px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--on-espresso); padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; z-index: 20; max-width: calc(100% - 32px); }

/* A laptop width: 8px less side padding is what lets the pool row fit at 1280. */
@media (max-width: 1400px) { .main { padding: 28px 24px; } }

/* ---------- narrow screens (the shell — top bar + drawer — is in phone.css) ---------- */
@media (max-width: 760px) {
  .main { padding: 20px 16px; flex: 1 1 auto; }
  h1 { font-size: 26px; }
  .search { flex: 1 1 100%; }
  .select { min-width: 0; width: 100%; }
  .filter { width: 100%; }
  .filter-grow { max-width: none; }
  .cand-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* On a phone a pinned 236px ACTIONS slot would cover most of the box: the row just scrolls. */
  .sticky-end, .table-box.has-more .sticky-end { position: static; box-shadow: none; }
}

/* The sign-in screen's reCAPTCHA never shows over the portal (app.js also removes it on sign-in). */
#app:not([hidden]) ~ #recaptcha-slot { display: none; }

/* ---------- loading: skeletons, a re-fetch in progress, a busy button ---------- */
.sk { position: relative; overflow: hidden; background: #ECE7E1; border-radius: 8px; }
.sk::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0));
  animation: sk-shimmer 1.4s ease-in-out infinite;
}
@keyframes sk-shimmer { to { transform: translateX(100%); } }
.sk-line { height: 12px; width: 100%; }
.sk-w40 { width: 40%; }
.sk-w60 { width: 60%; }
.sk-w70 { width: 70%; }
.sk-thumb { width: 40px; height: 48px; border-radius: 8px; flex-shrink: 0; }
.sk-thumb-lg { width: 56px; height: 68px; border-radius: 10px; }
.sk-pill { width: 104px; height: 22px; border-radius: 999px; flex-shrink: 0; }
.sk-value { height: 28px; width: 55%; }
.sk-photo { width: 100%; aspect-ratio: 3 / 4; border-radius: 10px; }
.sk-qr { width: 120px; height: 120px; }
.sk-look { flex: 0 1 220px; height: 64px; border-radius: 12px; }
.sk-btn { width: 120px; height: 44px; border-radius: 12px; }
.sk-chart { width: 100%; border-radius: 12px; }
.sk-chart-bars { height: 236px; }
.sk-chart-line { height: 200px; }
.sk-row-line { height: 16px; margin: 12px 0; }
.sk-item { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--hairline); background: var(--card); }
.sk-lines { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.sk-cand { cursor: default; gap: 10px; }
.sk-tag { gap: 12px; }
.sk-pay .pay-main { gap: 10px; }

.is-refreshing { position: relative; }
.is-refreshing > * { opacity: 0.55; transition: opacity 0.15s; }
.is-refreshing::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; z-index: 2; border-radius: 2px;
  background: linear-gradient(90deg, rgba(72, 49, 42, 0), var(--ink), rgba(72, 49, 42, 0)) no-repeat;
  background-size: 40% 100%; animation: refresh-bar 1s linear infinite;
}
@keyframes refresh-bar { from { background-position: -60% 0; } to { background-position: 160% 0; } }

.is-busy::before {
  content: ""; display: inline-block; flex-shrink: 0; width: 14px; height: 14px; margin-right: 8px; box-sizing: border-box;
  border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.action-btn.is-busy { display: inline-flex; align-items: center; justify-content: center; }
/* A busy primary keeps its colour (a plain disabled one greys out): it is working, not unavailable. */
.btn-primary.is-busy:disabled { background: var(--ink); color: var(--on-espresso); opacity: 0.85; }

@media (prefers-reduced-motion: reduce) {
  .sk::after { animation: none; display: none; }
  .is-refreshing::before { animation: none; background: var(--outline); }
  .is-busy::before { animation: none; border-right-color: currentColor; opacity: 0.5; }
}

/* ---------- touch screens: form controls drawn the same everywhere ---------- */
/* iOS Safari gives date/time inputs and selects their own appearance — and a date input an
   intrinsic minimum width that pushed it past its card. Drawn plainly instead, at the field height,
   left-aligned, with a chevron for a select (a CSS background — the page has no inline style). */
@media (max-width: 1023px), (pointer: coarse) {
  input[type="date"].input, input[type="datetime-local"].input, input[type="time"].input {
    -webkit-appearance: none; appearance: none; display: block; text-align: left; min-width: 0; max-width: 100%;
    padding-top: 0; padding-bottom: 0; line-height: 42px; /* without its own appearance iOS top-aligns the value */
  }
  input[type="date"]::-webkit-date-and-time-value, input[type="datetime-local"]::-webkit-date-and-time-value {
    text-align: left; margin: 0; line-height: 42px;
  }
  .input-sm[type="date"] { line-height: 38px; }
  .input-sm[type="date"]::-webkit-date-and-time-value { line-height: 38px; }
  select.select, select.select-sm {
    -webkit-appearance: none; appearance: none; text-align: left; padding-right: 36px; max-width: 100%;
    background: #FFFFFF url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2348312A' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 14px center / 12px 8px;
  }
  select.select:disabled, select.select-sm:disabled { color: var(--ink-2); }
}

/* ---------- 087: pop-up pool tag scanner + Mark sold amount ---------- */
.scan-btn { height: 42px; }
.dialog-field { display: block; margin: 14px 0 6px; }
.dialog-body .input { width: 100%; }
.scan-scrim { position: fixed; inset: 0; z-index: 60; background: rgba(26, 21, 16, 0.72); display: flex; align-items: center; justify-content: center; padding: 16px; }
.scan-card { background: var(--card); border-radius: 18px; padding: 16px; width: min(420px, 100%); display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.scan-frame { position: relative; border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 3 / 4; }
.scan-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-target { position: absolute; inset: 18%; border: 3px solid var(--on-espresso); border-radius: 14px; box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.25); }
.scan-hint { font-size: 14px; color: var(--ink-2); text-align: center; }

/* ---------- 091: pool multi-select + the offline checkout dialog ---------- */
.pick-cell { display: flex; align-items: center; gap: 8px; }
.pick { width: 18px; height: 18px; margin: 0; flex-shrink: 0; accent-color: var(--ink); cursor: pointer; }
.pick-spacer { width: 18px; flex-shrink: 0; }
.sel-bar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding: 12px 16px; background: var(--card); border: 1px solid var(--hairline); border-radius: 16px; box-shadow: 0 6px 20px rgba(26, 21, 16, 0.12); }
.sel-bar[hidden] { display: none; }
.sel-note { font-weight: 700; }
.sel-actions { display: flex; gap: 10px; }
.co-dialog { max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto; gap: 10px; }
.co-lines { display: flex; flex-direction: column; gap: 8px; max-height: 280px; overflow-y: auto; }
.co-line { display: grid; grid-template-columns: 36px minmax(0, 1fr) 112px; gap: 10px; align-items: center; padding: 6px; border-radius: 12px; border: 1px solid transparent; }
.co-line.is-bad { border-color: #A0574F; background: #FDF0F1; }
.co-amount-wrap { display: flex; align-items: center; gap: 4px; }
.co-amount-wrap .input { width: 100%; text-align: right; }
.co-total { font-weight: 700; text-align: right; }
.co-buyer .input { width: 100%; }
.co-hits { display: flex; flex-direction: column; margin-top: 6px; max-height: 200px; overflow-y: auto; }
.co-hit { display: flex; gap: 8px; align-items: baseline; text-align: left; padding: 10px 8px; background: none; border: none; border-bottom: 1px solid var(--hairline); cursor: pointer; font: inherit; color: inherit; }
.co-hit:hover, .co-hit:focus-visible { background: var(--page); }
.co-hit-handle { font-weight: 700; }
.co-hit-name { color: var(--ink-2); font-size: 13px; }
.co-hit-empty { color: var(--ink-2); font-size: 13px; padding: 8px; }
.co-picked { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--page); }
.co-change { height: 36px; padding: 0 12px; }
.co-note { margin: 0; font-size: 13px; color: var(--ink-2); }
.co-error { color: #A0574F; font-size: 14px; font-weight: 600; }
.co-error:empty { display: none; }
