/* ============================================================
   invantree — "Spruce & Ledger"
   A light, card-based workspace: pale sage canvas, white sidebar,
   deep spruce-green as the working color, optic-lime kept as a
   single reserved spark for deltas and highlights. Tabular mono
   figures carry the "scoreboard precision" the brand started with,
   now inside a calmer, more spacious shell.
   ============================================================ */

/* The UA's [hidden] rule is a bare attribute selector, so any class that sets
   display (.inline-form, .card, …) outranks it and the element stays visible.
   Restore the attribute's meaning for everything. */
[hidden] { display: none !important; }

@font-face {
  font-family: 'Unbounded';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/static/fonts/unbounded-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Plex Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/static/fonts/ibm-plex-mono-600.woff2') format('woff2');
}

:root {
  --canvas: #eef2ec;       /* pale sage page canvas */
  --card: #ffffff;
  --sidebar: #ffffff;
  --ink: #16211d;
  --muted: #67766d;
  --line: #dfe6de;
  --spruce: #146349;       /* deep working green — replaces old --court */
  --spruce-2: #0f5039;     /* hover / pressed */
  --spruce-tint: #dcefe3;  /* pale mint fill */
  --cream-tint: #f6f1de;   /* alternate pastel fill, warm counterweight */
  --optic: #c8ec1e;        /* the ball — reserved spark, deltas & focus rings */
  --optic-ink: #1c2b12;
  --danger: #b23a28;
  --danger-tint: #f6ded7;
  --add: #146349;
  --deduct: #b23a28;
  --radius: 18px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(22,33,29,.04), 0 8px 24px -12px rgba(22,33,29,.12);

  --display: 'Unbounded', system-ui, sans-serif;
  --mono: 'Plex Mono', ui-monospace, 'Cascadia Code', Menlo, monospace;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --sidebar-w: 236px;

  /* chart data colors — validated: CVD ΔE 72.6, contrast ≥3:1 vs light surface */
  --chart-sales: #4a72d4;
  --chart-profit: #146349;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--canvas);
  color: var(--ink);
  font-size: 15.5px;
  line-height: 1.45;
}
a { color: var(--spruce); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0; letter-spacing: -0.02em; font-weight: 650; }
h2 { font-size: 1.02rem; margin: 0 0 .75rem; letter-spacing: -0.01em; }
h3 { letter-spacing: -0.01em; }
code {
  font-family: var(--mono); font-weight: 600;
  background: var(--spruce-tint); color: var(--spruce);
  padding: .08em .4em; border-radius: 5px; font-size: .85em;
}
::selection { background: var(--optic); color: var(--optic-ink); }
:focus-visible { outline: 2px solid var(--spruce); outline-offset: 2px; }

/* ============================================================
   App shell — fixed sidebar + scrolling content column
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 auto;
  background: var(--sidebar); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center;
  padding: 1.35rem 1.3rem 1.1rem;
  font-size: 1.05rem;
}

/* ---- Wordmark: "invantree" in text, never an image. A straight
   brand-color underline sits under "invantr" only (a real text-decoration,
   not a drawn shape), "ee" runs past it bare, and a lime dot follows. ---- */
.wordmark {
  font-family: var(--display); font-weight: 700; color: var(--ink);
  letter-spacing: -0.02em;
}
.wordmark-underline {
  text-decoration: underline;
  text-decoration-color: var(--optic);
  text-decoration-thickness: 3px;
  text-underline-offset: 3px;
}
.wordmark-dot {
  display: inline-block;
  width: .3em; height: .3em;
  background: var(--optic); border-radius: 50%;
  margin-left: .15em; vertical-align: middle;
}
.sidebar-nav { flex: 1 1 auto; padding: .4rem .8rem; display: flex; flex-direction: column; gap: .15rem; }
.sidebar-nav a {
  display: flex; align-items: center; gap: .7rem;
  padding: .62rem .8rem; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 600; font-size: .88rem;
}
.sidebar-nav a:hover { background: var(--spruce-tint); color: var(--spruce); text-decoration: none; }
.sidebar-nav a.active { background: var(--spruce); color: #fff; }
.sidebar-nav a svg { flex: 0 0 auto; width: 18px; height: 18px; }
.sidebar-nav .nav-gap { height: .6rem; border-top: 1px solid var(--line); margin: .5rem .2rem 0; }
.sidebar-foot { padding: .9rem .9rem 1.1rem; border-top: 1px solid var(--line); }
.sidebar-user { display: flex; align-items: center; gap: .6rem; padding: .4rem .3rem .8rem; }
.sidebar-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
  background: var(--spruce-tint); color: var(--spruce);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 700; font-size: .82rem;
}
.sidebar-user div { min-width: 0; }
.sidebar-user .name { font-weight: 650; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .role { color: var(--muted); font-size: .74rem; text-transform: capitalize; }
.desktop-user { padding: 0; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; }
.topbar-logout-form { margin: 0; }
.mobile-user { display: none; }
.sidebar-foot .btn { width: 100%; }

.content-col { flex: 1 1 auto; min-width: 0; }
.topbar-page {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; padding: 1.5rem 1.6rem 0;
  max-width: 1180px; margin: 0 auto;
}
.crumb { font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--spruce); }
.crumb .sep { margin: 0 .35rem; opacity: .6; }

.container { max-width: 1180px; margin: 0 auto; padding: 1.35rem 1.6rem 2.5rem; }

/* Mobile: sidebar becomes an off-canvas drawer with full-word labels,
   opened by a hamburger button in a slim top strip — a horizontally
   scrolling icon-only bar was too cramped to tap accurately on a phone. */
.mobile-topbar { display: none; }
.sidebar-scrim {
  display: none; position: fixed; inset: 0; background: rgba(15, 23, 20, .45);
  z-index: 35; opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.sidebar-scrim.open { opacity: 1; pointer-events: auto; }
.menu-btn {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: var(--radius-sm); flex: 0 0 auto;
  border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer;
}
.menu-btn:hover { background: var(--spruce-tint); }
.menu-btn .icon-close { display: none; }
.menu-btn[aria-expanded="true"] .icon-menu { display: none; }
.menu-btn[aria-expanded="true"] .icon-close { display: block; }

@media (max-width: 880px) {
  .app-shell { flex-direction: column; }
  .mobile-topbar {
    display: flex; align-items: center; gap: .9rem;
    padding: .8rem 1rem; background: var(--sidebar); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 20;
  }
  .sidebar-scrim { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: 280px; max-width: 84vw;
    transform: translateX(-100%); transition: transform .22s ease; z-index: 40;
    flex-direction: column; box-shadow: 0 0 40px rgba(0,0,0,.25);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-nav { flex-direction: column; padding: .4rem .8rem; gap: .15rem; }
  .sidebar-nav a { flex: none; white-space: normal; }
  .sidebar-user .role { display: block; }
  .sidebar-user div .name { max-width: none; }
  .mobile-topbar .mobile-user {
    display: flex; margin-left: auto; padding: 0; max-width: 38vw;
  }
  .mobile-topbar .mobile-user .sidebar-avatar {
    width: 30px; height: 30px; font-size: .72rem;
  }
  .mobile-topbar .mobile-user .name {
    max-width: 100%; font-size: .78rem;
  }
  .mobile-topbar .mobile-user .role { font-size: .68rem; }
  .topbar-page > .desktop-user { display: none; }
  .topbar-page > .topbar-actions { display: none; }
  .topbar-page { padding: .8rem 1.1rem 0; }
  .container { padding: .8rem 1.1rem 2rem; }
}

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem 1.3rem; margin-bottom: 1.1rem;
}

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; align-items: start; }
@media (max-width: 800px) {
  .two-col { grid-template-columns: 1fr; }
  .two-col > * { min-width: 0; }
}

/* ---- Section eyebrow ---- */
.section-label {
  font-family: var(--display); font-weight: 700;
  color: var(--spruce); text-transform: uppercase;
  font-size: .7rem; letter-spacing: .1em;
  margin: 1.7rem 0 .7rem; display: flex; align-items: center; gap: .55rem;
}
.section-label::before {
  content: ''; width: 16px; height: 3px; background: var(--optic); border-radius: 2px; flex: 0 0 auto;
}

/* ============================================================
   KPI tiles — pastel-tinted, alternating mint / cream, matching
   the reference's tonal stat-card row (no white on white here).
   ============================================================ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .85rem; margin-bottom: 1.1rem; }
.stat {
  border: 1px solid transparent; border-radius: var(--radius);
  padding: 1.05rem 1.15rem; margin-bottom: 0; box-shadow: none;
  background: var(--spruce-tint);
}
.stat:nth-child(even) { background: var(--cream-tint); }
.stat-value {
  font-family: var(--mono); font-weight: 600; font-size: 1.7rem;
  letter-spacing: -0.02em; color: var(--ink); font-variant-numeric: tabular-nums;
  display: block;
}
.stat-value.danger { color: var(--danger); }
.stat-label {
  color: var(--muted); font-size: .78rem; margin-top: .35rem; line-height: 1.4; font-weight: 500;
}
.stat-label small { font-size: .95em; }

/* ---- Stock-health rings — signature widget ---- */
.ring-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .85rem; margin-bottom: 1.1rem; }
.ring-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.1rem; text-align: center;
}
.ring-card .ring-title { font-size: .78rem; color: var(--muted); font-weight: 600; margin-bottom: .7rem; }
.ring {
  width: 84px; height: 84px; border-radius: 50%; margin: 0 auto .6rem;
  display: flex; align-items: center; justify-content: center;
  background: conic-gradient(var(--spruce) calc(var(--pct, 0) * 1%), var(--spruce-tint) 0);
  position: relative;
}
.ring::before { content: ''; position: absolute; inset: 8px; border-radius: 50%; background: var(--card); }
.ring-value { position: relative; font-family: var(--mono); font-weight: 600; font-size: 1rem; color: var(--ink); }
.ring-caption { font-size: .72rem; color: var(--muted); }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .65rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th {
  color: var(--muted); font-weight: 650;
  font-size: .68rem; text-transform: uppercase; letter-spacing: .07em;
}
thead th { border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--spruce-tint); }
.num { text-align: right; font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
th.num { font-family: var(--sans); }
.table-wrap { overflow-x: auto; padding: 0; }
.table-wrap table { min-width: 640px; }
.table-wrap th, .table-wrap td { padding-left: 1.1rem; padding-right: 1.1rem; }
/* When .card and .table-wrap land on the same element, the card's own
   padding is restored for non-table content (headings, empty-state text) —
   the table itself bleeds back out to the card's edges via negative margin,
   so it still reads as full-bleed instead of doubly inset. */
.card.table-wrap { padding: 1.2rem 1.3rem; }
.card.table-wrap table { width: calc(100% + 2.6rem); margin: 0 -1.3rem; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.danger { color: var(--danger); }

/* ---- Badges (status pills, reference-style) ---- */
.badge {
  display: inline-block; padding: .22em .7em; border-radius: var(--radius-pill);
  font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  background: var(--spruce-tint); color: var(--spruce); vertical-align: .1em;
}
.badge-add { background: var(--spruce-tint); color: var(--add); }
.badge-deduct { background: var(--danger-tint); color: var(--deduct); }
.badge-adjustment { background: var(--spruce-tint); color: var(--muted); }
.badge-shopify { background: #e3ecfb; color: #2c56b0; }
.badge-review { background: var(--optic); color: var(--optic-ink); }

/* ---- Buttons ---- */
.btn {
  display: inline-block; padding: .58rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-family: var(--sans); font-size: .88rem; font-weight: 650; cursor: pointer;
  text-decoration: none; transition: border-color .12s, background .12s, box-shadow .12s;
}
.btn:hover { border-color: var(--spruce); text-decoration: none; }
.btn-primary { background: var(--spruce); border-color: var(--spruce); color: #fff; }
.btn-primary:hover { background: var(--spruce-2); border-color: var(--spruce-2); }
/* A disabled button has to read as unavailable, not merely be inert —
   otherwise it invites a click that silently does nothing. */
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover, .btn[disabled]:hover { border-color: var(--line); background: inherit; }
.btn-primary:disabled:hover { background: var(--spruce); border-color: var(--spruce); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--spruce-tint); border-color: transparent; }
.btn-sm { padding: .32rem .7rem; font-size: .78rem; }
.btn-block { display: block; width: 100%; text-align: center; }

/* ---- Forms ---- */
label { display: block; margin-bottom: .85rem; font-weight: 600; font-size: .86rem; color: var(--ink); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], input[type="date"], input[type="tel"], input[type="file"], select {
  display: block; width: 100%; margin-top: .35rem;
  padding: .6rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: var(--sans); font-size: 1rem; background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--spruce); outline-offset: 1px; border-color: var(--spruce); }
.checkbox-label { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.checkbox-label input { width: auto; margin: 0; }
fieldset.opening-stock { border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: .9rem 1.1rem; margin: 0 0 .9rem; }
fieldset.opening-stock legend { font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--spruce); padding: 0 .4rem; }
fieldset.opening-stock p { margin-top: 0; font-size: .85rem; }
.form-card { max-width: 580px; }
.form-actions { display: flex; gap: .7rem; margin-top: 1.1rem; }

.inline-form { display: flex; gap: .55rem; flex-wrap: wrap; align-items: center; }
.inline-form input, .inline-form select { display: inline-block; width: auto; margin-top: 0; flex: 1 1 auto; min-width: 0; }
.inline-form .btn { flex: 0 0 auto; }
.filter-form { margin-bottom: 1rem; }

.search-form { display: flex; gap: .55rem; margin-bottom: 1.1rem; }
.search-form input { margin-top: 0; }

.filter-bar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.1rem; }
.filter-bar input, .filter-bar select { margin-top: 0; width: auto; flex: 0 1 auto; }
.filter-bar input[type="search"] { flex: 1 1 12rem; min-width: 10rem; }
.filter-bar .btn { flex: 0 0 auto; }

/* ---- Accounting statements ---- */
.acct-nav { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
tr.subtotal td { border-top: 1px solid var(--line); font-weight: 600; }
tr.total td { border-top: 2px solid var(--spruce); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--spruce); }
tr.total td.num { font-family: var(--mono); font-size: .95rem; letter-spacing: -0.01em; }
tr.total.neg td { color: var(--danger); border-top-color: var(--danger); }
tr.total.neg td.num { color: var(--danger); }
table.pnl td:first-child { width: 65%; }

.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1.1rem; font-size: .92rem; }
.alert-error { background: var(--danger-tint); color: var(--danger); border: 1px solid #e6c3ba; }

/* ---- Login: deep-spruce hero, mirrors the app's working color ---- */
body:has(.login-card) { background: var(--spruce); }
body:has(.login-card)::before {
  content: ''; position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(120% 80% at 50% -10%, rgba(200,236,30,.12), transparent 60%);
}
.login-card {
  max-width: 400px; margin: 14vh auto 0; position: relative;
  border: none; border-top: 4px solid var(--optic); box-shadow: 0 24px 60px rgba(0,0,0,.35);
  padding: 1.9rem;
}
.login-card h1 { text-align: center; }
.login-card .btn-primary { background: var(--optic); border-color: var(--optic); color: var(--optic-ink); }
.login-card .btn-primary:hover { background: #d4f53a; border-color: #d4f53a; }
.brand-logo { font-size: 2.1rem; text-align: center; }
.scanned-tag { font-size: .62rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: .1em .35em; }

/* ---- Thumbnails / photos ---- */
.thumb { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; display: block; border: 1px solid var(--line); }
.thumb-empty { display: flex; align-items: center; justify-content: center; background: var(--spruce-tint); border: 1px dashed var(--line); }
.thumb-cell { width: 56px; }

.sku-photo-card { padding: .55rem; text-align: center; }
.sku-photo { max-width: 100%; max-height: 320px; border-radius: var(--radius-sm); }
.sku-photo-empty { padding: 2.5rem 0; font-size: .95rem; color: var(--muted); background: var(--spruce-tint); border-radius: var(--radius-sm); }
.upload-field { margin-bottom: .85rem; }
.upload-field > label:first-child { margin-bottom: .35rem; }
.upload-dropzone {
  display: grid; place-items: center; gap: .25rem;
  min-height: 148px; margin: .35rem 0 0; padding: 1.1rem;
  text-align: center; border: 1.5px dashed var(--line); border-radius: var(--radius);
  background: linear-gradient(180deg, #fff, #f8fbf7); color: var(--ink);
  cursor: pointer; transition: border-color .14s, background .14s, box-shadow .14s, transform .14s;
  position: relative;
}
/* Hidden paste-catcher textarea: covers the whole zone in paste mode so a
   tap or long-press lands on an editable field, which is what makes the
   OS "Paste" action (iOS callout / Android clipboard) target the image. */
.upload-paste-catcher {
  position: absolute; inset: 0; width: 100%; height: 100%;
  margin: 0; padding: 1.2rem; border: 0; border-radius: inherit;
  background: transparent; color: transparent; caret-color: transparent;
  opacity: 0; resize: none; overflow: hidden; white-space: pre;
  z-index: 1; cursor: text;
}
.upload-field:not(.is-paste-mode) .upload-paste-catcher { display: none; }
.upload-mode-toggle { position: relative; z-index: 2; pointer-events: auto; }
.upload-dropzone:hover,
.upload-field.is-dragover .upload-dropzone {
  border-color: var(--spruce); background: var(--spruce-tint); box-shadow: var(--shadow); transform: translateY(-1px);
}
.upload-dropzone:focus-visible { outline: 2px solid var(--spruce); outline-offset: 2px; }
.upload-field.is-paste-mode .upload-dropzone { cursor: text; }
.upload-dropzone-icon {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--spruce); color: #fff; font-size: 1.35rem; line-height: 1;
}
.upload-dropzone-title { font-weight: 750; font-size: .98rem; }
.upload-dropzone-hint { color: var(--muted); font-size: .82rem; font-weight: 500; }
.upload-dropzone-file {
  margin-top: .2rem; padding: .18rem .55rem; border-radius: var(--radius-pill);
  background: #fff; border: 1px solid var(--line); color: var(--muted);
  font-size: .75rem; font-weight: 650; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.upload-field.has-file .upload-dropzone-file { color: var(--spruce); background: var(--spruce-tint); border-color: transparent; }
.upload-mode-toggle {
  display: inline-flex; align-items: center; gap: .2rem; margin-top: .5rem; padding: .2rem;
  background: var(--spruce-tint); border: 1px solid var(--line); border-radius: var(--radius-pill);
}
.upload-mode-btn {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent;
  color: var(--muted); font-size: .72rem; font-weight: 700; line-height: 1;
  padding: .34rem .7rem; border-radius: var(--radius-pill); cursor: pointer;
  transition: background .12s, color .12s, box-shadow .12s;
}
.upload-mode-btn:hover { color: var(--spruce); }
.upload-mode-btn.is-active { background: #fff; color: var(--spruce); box-shadow: 0 1px 3px rgba(20, 40, 30, .15); }
.upload-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.img-preview { max-width: 220px; max-height: 220px; border-radius: var(--radius-sm); margin-bottom: .8rem; border: 1px solid var(--line); }

/* ---- Scan page ---- */
.scan-page { max-width: 580px; margin: 0 auto; }
.mode-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: 1.1rem; }
.mode-btn {
  padding: 1.15rem; font-size: 1.1rem; font-weight: 700;
  letter-spacing: .01em; border-radius: var(--radius);
  border: 2px solid var(--line); background: #fff; color: var(--muted); cursor: pointer;
}
.mode-btn.mode-add.active { background: var(--add); border-color: var(--add); color: #fff; }
.mode-btn.mode-deduct.active { background: var(--deduct); border-color: var(--deduct); color: #fff; }

.qty-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.qty-row label { margin: 0; }
.stepper { display: flex; gap: .4rem; align-items: center; }
.stepper input { width: 4.5rem; text-align: center; margin-top: 0; font-family: var(--mono); font-weight: 600; }
.stepper .btn { font-size: 1.1rem; padding: .45rem .85rem; }

.scan-input-row { display: flex; gap: .55rem; margin-bottom: .8rem; }
.scan-input-row input { margin-top: 0; font-size: 1.1rem; font-family: var(--mono); }

/* ---- Full-screen camera overlay ---- */
.camera-overlay {
  position: fixed; inset: 0; z-index: 1000; background: #000;
  display: flex; flex-direction: column;
}
.camera-overlay[hidden] { display: none; }
.camera-live { position: relative; flex: 1 1 auto; overflow: hidden; }
.camera-live video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.scan-frame {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  width: min(78vw, 380px); height: min(46vw, 220px);
  border: 3px solid var(--optic); border-radius: var(--radius);
  box-shadow: 0 0 0 2000px rgba(0,0,0,.45);
  pointer-events: none;
}
.camera-hint {
  position: absolute; left: 0; right: 0; bottom: 8vh; text-align: center;
  color: #fff; font-weight: 600; font-size: .95rem; text-shadow: 0 1px 3px rgba(0,0,0,.6);
  margin: 0; pointer-events: none;
}
.camera-close {
  position: absolute; top: max(1rem, env(safe-area-inset-top)); right: 1rem;
  width: 42px; height: 42px; border-radius: 50%; border: none;
  background: rgba(0,0,0,.5); color: #fff; font-size: 1.2rem; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.camera-close:hover { background: rgba(0,0,0,.7); }

.zoom-row {
  position: absolute; left: 50%; bottom: calc(4.2rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex; align-items: center; gap: .5rem;
  width: min(78vw, 380px);
  background: rgba(0,0,0,.45); border-radius: var(--radius-pill);
  padding: .4rem .8rem;
}
.zoom-row[hidden] { display: none; }
.zoom-row .zoom-icon { color: #fff; font-size: .85rem; line-height: 1; user-select: none; }
.zoom-row input[type="range"] {
  flex: 1 1 auto; margin: 0; accent-color: var(--optic);
}

/* ---- Post-scan result sheet — slides up over the (now-stopped) camera ---- */
.camera-result {
  background: var(--canvas); border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.4rem 1.3rem calc(1.4rem + env(safe-area-inset-bottom));
  max-height: 82vh; overflow-y: auto;
  margin-top: auto; /* anchor to the bottom of the overlay, not the top */
  animation: sheet-up .22s ease-out;
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.result-loading { text-align: center; padding: 2.5rem 0; color: var(--muted); font-weight: 600; }
.result-sku { display: flex; align-items: center; gap: .9rem; margin-bottom: 1.1rem; }
.result-sku .thumb, .result-sku .thumb-empty { width: 58px; height: 58px; border-radius: var(--radius-sm); }
.result-sku .code { font-family: var(--mono); font-weight: 700; font-size: 1.05rem; }
.result-sku .name { color: var(--muted); font-size: .9rem; }
.result-onhand { font-size: .85rem; color: var(--muted); margin: -.4rem 0 1.1rem; }
.result-onhand strong { color: var(--ink); font-family: var(--mono); }
.result-new-badge {
  display: inline-block; background: var(--optic); color: var(--optic-ink);
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: .2em .6em; border-radius: var(--radius-pill); margin-bottom: .7rem;
}
.result-actions { display: flex; gap: .6rem; margin-top: 1.2rem; }
.result-actions .btn { flex: 1 1 auto; }
.result-actions .btn-block-full { flex: 1 1 100%; }
.result-secondary { display: flex; justify-content: center; gap: 1.2rem; margin-top: 1rem; font-size: .88rem; }

.camera-wrap { margin-bottom: .8rem; }
.camera-wrap video { width: 100%; border-radius: var(--radius); background: #000; margin-bottom: .5rem; }

.scan-status { padding: .85rem 1.1rem; border-radius: var(--radius); margin-bottom: 1.1rem; font-weight: 600; }
.scan-status.ok { background: var(--spruce-tint); color: var(--add); }
.scan-status.err { background: var(--danger-tint); color: var(--deduct); }

.scan-log { list-style: none; margin: 0; padding: 0; }
.scan-log li {
  display: flex; align-items: center; gap: .7rem;
  padding: .55rem 0; border-bottom: 1px solid var(--line); font-size: .95rem;
}
.scan-log li:last-child { border-bottom: none; }
.scan-log img, .scan-log .thumb-empty { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; }
.scan-log .qty { font-family: var(--mono); font-weight: 600; min-width: 2.4rem; }
.scan-log li.add .qty { color: var(--add); }
.scan-log li.deduct .qty { color: var(--deduct); }
.scan-log .count { margin-left: auto; color: var(--muted); font-size: .85rem; font-family: var(--mono); }

/* ---- Brand chart ---- */
.chart-legend { display: flex; gap: 1.2rem; flex-wrap: wrap; align-items: center; font-size: .85rem; margin-bottom: 1rem; }
.chart-legend .swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.swatch-sales { background: var(--chart-sales); }
.swatch-profit { background: var(--chart-profit); }
.brand-chart { display: flex; flex-direction: column; gap: 1rem; }
.brand-row { display: grid; grid-template-columns: minmax(90px, 150px) 1fr; gap: .9rem; align-items: center; }
.brand-name { font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; font-weight: 700; text-align: right; overflow-wrap: anywhere; color: var(--spruce); }
.brand-bars { display: flex; flex-direction: column; gap: 2px; }
.bar-track { display: flex; align-items: center; gap: .55rem; min-height: 15px; }
.bar { height: 13px; border-radius: 0 3px 3px 0; min-width: 2px; }
.bar-sales { background: var(--chart-sales); }
.bar-profit { background: var(--chart-profit); }
.bar-value { font-size: .78rem; color: var(--muted); white-space: nowrap; font-family: var(--mono); font-weight: 600; }
@media (max-width: 600px) { .brand-row { grid-template-columns: 1fr; gap: .2rem; } .brand-name { text-align: left; } }
