/*! Paree สต็อก · Copyright: Sitthichai Chanmaniloet. All rights reserved. */
/* Paree stock: styles */

:root {
  /* Layout: a navy brand band (the logo's own colour) over a shelf of bag-photo cards;
     ledger and summary sit in quiet panels. Bottom tabs on phone, tabs inside the band on desktop. */
  --brand: #214052;
  --brand-2: #2C5468;
  --brand-ink: #FFFFFF;
  --brand-ink-2: #B9CCD5;
  --bg: #EDF1F1;
  --surface: #FFFFFF;
  --surface-2: #F4F7F7;
  --line: #D5DEE0;
  --fg: #15252D;
  --muted: #5A6C73;
  --accent: #214052;
  --on-accent: #FFFFFF;
  --leather: #9A5A2A;
  --income: #00809A;
  --expense: #C8642A;
  --in-ink: #006A80;
  --out-ink: #A44E1D;
  --good: #1D7346;
  --bad: #B3261E;
  --warn-bg: #FCEFD3;
  --warn-ink: #7A4D00;
  --sold-bg: #DFE4E5;
  --sold-ink: #6E7B80;
  --sold-tag: rgba(21, 37, 45, .84);
  --sold-tag-ink: #FFFFFF;
  --sel: #E2ECEF;
  --notice-bg: #FFF8E8;
  --notice-line: #E2C88F;
  --shadow: rgba(21, 37, 45, .12);
  --toast-bg: #15252D;
  --toast-ink: #FFFFFF;
  --toast-action: #8FD0E0;

  --font-display: "Bai Jamjuree", "Noto Sans Thai", Thonburi, Tahoma, sans-serif;
  --font-body: "IBM Plex Sans Thai Looped", "Noto Sans Thai Looped", "Noto Sans Thai", Thonburi, Tahoma, system-ui, sans-serif;
  --r-lg: 16px;
  --r-md: 12px;
  --tabbar-h: 64px;

  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #1B3746;
    --brand-2: #284C5E;
    --brand-ink: #FFFFFF;
    --brand-ink-2: #A9BFC9;
    --bg: #0E1A20;
    --surface: #15252D;
    --surface-2: #1B2D36;
    --line: #29404A;
    --fg: #E5EDEF;
    --muted: #93A6AD;
    --accent: #8CC6D6;
    --on-accent: #0E1A20;
    --leather: #E2A878;
    --income: #2A9DB5;
    --expense: #D9773F;
    --in-ink: #6CC7DB;
    --out-ink: #EFA06C;
    --good: #6BCB93;
    --bad: #F28B82;
    --warn-bg: #3D3017;
    --warn-ink: #F2CB7A;
    --sold-bg: #1C262B;
    --sold-ink: #7F8E94;
    --sold-tag: rgba(229, 237, 239, .9);
    --sold-tag-ink: #15252D;
    --sel: #1F3640;
    --notice-bg: #2A2516;
    --notice-line: #6B5A2E;
    --shadow: rgba(0, 0, 0, .4);
    --toast-bg: #E5EDEF;
    --toast-ink: #15252D;
    --toast-action: #006A80;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --brand: #1B3746;
  --brand-2: #284C5E;
  --brand-ink: #FFFFFF;
  --brand-ink-2: #A9BFC9;
  --bg: #0E1A20;
  --surface: #15252D;
  --surface-2: #1B2D36;
  --line: #29404A;
  --fg: #E5EDEF;
  --muted: #93A6AD;
  --accent: #8CC6D6;
  --on-accent: #0E1A20;
  --leather: #E2A878;
  --income: #2A9DB5;
  --expense: #D9773F;
  --in-ink: #6CC7DB;
  --out-ink: #EFA06C;
  --good: #6BCB93;
  --bad: #F28B82;
  --warn-bg: #3D3017;
  --warn-ink: #F2CB7A;
  --sold-bg: #1C262B;
  --sold-ink: #7F8E94;
  --sold-tag: rgba(229, 237, 239, .9);
  --sold-tag-ink: #15252D;
  --sel: #1F3640;
  --notice-bg: #2A2516;
  --notice-line: #6B5A2E;
  --shadow: rgba(0, 0, 0, .4);
  --toast-bg: #E5EDEF;
  --toast-ink: #15252D;
  --toast-action: #006A80;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 15px/1.55 var(--font-body);
  -webkit-tap-highlight-color: transparent;
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 30;
  background: var(--brand);
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; text-wrap: balance; line-height: 1.25; }
p { margin: 0; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { flex: none; }

.wrap {
  width: 100%;
  max-width: 1240px;
  margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* ── Brand band ─────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  background: var(--brand);
  color: var(--brand-ink);
}
/* a woven zig-zag edge, like the border of the ikat cloth */
.topbar::after {
  content: "";
  display: block;
  height: 6px;
  background:
    linear-gradient(135deg, var(--brand) 33.3%, transparent 33.3%) 0 0 / 12px 6px,
    linear-gradient(225deg, var(--brand) 33.3%, transparent 33.3%) 0 0 / 12px 6px,
    var(--brand-2);
}
.topbar-inner { display: flex; align-items: center; gap: 12px; min-height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; margin-right: auto; min-width: 0; }
.brand img { width: 44px; height: auto; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 1.35rem; letter-spacing: .01em; }
.brand-sub { font-size: .8rem; color: var(--brand-ink-2); padding-left: 10px; border-left: 1px solid var(--brand-2); white-space: nowrap; }

.icon-btn {
  width: 44px; height: 44px;
  display: inline-grid; place-items: center;
  border: 0; border-radius: var(--r-md);
  background: transparent; color: inherit;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover:not(:disabled) { background: var(--surface-2); }
.icon-btn:disabled { opacity: .35; }
.icon-btn.on-brand:hover { background: var(--brand-2); }

/* Tabs: bottom bar on phone */
.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 25;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 6px max(16px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 52px;
  border: 0; border-radius: var(--r-md);
  background: none; color: var(--muted);
  font-size: .78rem;
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--accent); font-weight: 600; }
.tab[aria-current="page"] svg { stroke-width: 2.2; }

main { padding-block: 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 16px; }
.view { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.view-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
h1 { font-size: 1.45rem; }

/* ── Buttons & inputs ───────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); color: var(--fg);
  font-weight: 600; white-space: nowrap; text-decoration: none;
}
.btn svg { width: 20px; height: 20px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-lg { min-height: 52px; padding: 0 22px; font-size: 1.02rem; }
.btn-small { min-height: 36px; padding: 0 12px; font-size: .88rem; }
.btn-quiet { background: transparent; color: var(--muted); }
.btn-danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.armed { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.grow { flex: 1; }

.input {
  width: 100%; min-width: 0;
  height: 48px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--fg);
  font-size: 16px; /* 16px keeps iPhone from zooming in */
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
input[type="date"].input { appearance: none; -webkit-appearance: none; display: flex; align-items: center; }
.affix { position: relative; }
.affix > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.affix .input { padding-left: 28px; font-variant-numeric: tabular-nums; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: .85rem; font-weight: 500; color: var(--muted); }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: end; }
.check { display: flex; align-items: center; gap: 10px; min-height: 48px; font-size: .9rem; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.hint { font-size: .8rem; color: var(--muted); }
.error { color: var(--bad); font-size: .88rem; font-weight: 500; }

.stepper { display: grid; grid-template-columns: 56px minmax(0, 1fr) 56px; gap: 8px; }
.stepper .btn { font-size: 1.5rem; padding: 0; min-height: 52px; }
.stepper .input { height: 52px; text-align: center; font-family: var(--font-display); font-size: 1.4rem; font-weight: 600; }

/* segmented choice + chip choices (radio inputs underneath) */
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px;
  padding: 4px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--line);
}
.seg label, .choices label { position: relative; cursor: pointer; }
.seg input, .choices input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg span { display: block; text-align: center; padding: 9px 6px; border-radius: 9px; font-size: .9rem; color: var(--muted); }
.seg input:checked + span { background: var(--surface); color: var(--fg); font-weight: 600; box-shadow: 0 1px 3px var(--shadow); }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices span { display: block; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; font-size: .9rem; background: var(--surface); }
.choices input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.seg input:focus-visible + span, .choices input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Notice ─────────────────────────────────────────────── */
.notice {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  padding: 10px 14px;
  background: var(--notice-bg);
  border: 1px dashed var(--notice-line);
  border-radius: var(--r-md);
  font-size: .86rem;
}
.notice p { flex: 1 1 260px; }

/* ── Stat strip (stock + ledger) ────────────────────────── */
.stat-strip {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
}
.stat-strip > div { padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-strip > div + div { border-left: 1px solid var(--line); }
.stat-strip span { font-size: .76rem; color: var(--muted); line-height: 1.3; }
.stat-strip b { font-family: var(--font-display); font-weight: 600; font-size: 1.08rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-strip small { font-size: .74rem; color: var(--muted); }
.in { color: var(--in-ink); }
.out { color: var(--out-ink); }
.pos { color: var(--good); }
.neg { color: var(--bad); }

/* ── Stock toolbar & grid ───────────────────────────────── */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1 1 100%; min-width: 0; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 38px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--fg);
  font-size: .88rem; white-space: nowrap;
}
.chip-n { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip[aria-pressed="true"] .chip-n { color: inherit; opacity: .8; }
.search {
  flex: 1 1 100%; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  color: var(--muted);
}
.search svg { width: 20px; height: 20px; }
.search input { flex: 1; min-width: 0; border: 0; background: none; font-size: 16px; color: var(--fg); outline: none; }
.search:focus-within { outline: 2px solid var(--accent); outline-offset: 0; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.card {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.card-photo {
  position: relative; display: block;
  width: 100%; max-width: 100%; aspect-ratio: 1;
  padding: 0; border: 0;
  background: var(--surface-2);
}
.card-photo img { width: 100%; height: 100%; object-fit: cover; }
.no-photo { display: grid; place-items: center; width: 100%; height: 100%; background: var(--brand); }
.no-photo img { width: 46%; height: auto; opacity: .9; }
.card-body { display: flex; flex-direction: column; gap: 2px; flex: 1; padding: 10px 12px 12px; }
.card-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.code { font-family: var(--font-display); font-weight: 700; font-size: 1.08rem; letter-spacing: .02em; }
.price { color: var(--leather); font-weight: 600; font-variant-numeric: tabular-nums; }
.card-name { font-size: .82rem; line-height: 1.4; color: var(--muted); }
.card-stock { margin-top: auto; padding-top: 10px; display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 6px; }
.qty-btn {
  height: 44px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--fg);
  font-size: 1.5rem; line-height: 1;
}
.qty-btn.plus { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.qty-btn:disabled { opacity: .35; }
.qty { text-align: center; font-size: .82rem; color: var(--muted); white-space: nowrap; }
.qty b { font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; color: var(--fg); font-variant-numeric: tabular-nums; margin-right: 2px; }

.low-tag {
  position: absolute; top: 8px; left: 8px;
  padding: 2px 10px; border-radius: 999px;
  background: var(--warn-bg); color: var(--warn-ink);
  font-size: .74rem; font-weight: 600;
}
.card.is-low .qty b { color: var(--warn-ink); }

/* sold out: the bag stays on the shelf, greyed, with a band across the photo */
.card.is-out { background: var(--sold-bg); border-color: transparent; }
.card.is-out .card-photo img { filter: grayscale(1); opacity: .5; }
.card.is-out .code, .card.is-out .price, .card.is-out .qty b { color: var(--sold-ink); }
.soldout {
  position: absolute; left: 0; right: 0; top: 50%;
  transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 6px;
  background: var(--sold-tag); color: var(--sold-tag-ink);
}
.soldout b { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; line-height: 1.2; }
.soldout small { font-size: .66rem; letter-spacing: .22em; opacity: .85; }
.empty { padding: 32px 12px; text-align: center; color: var(--muted); grid-column: 1 / -1; }

/* ── Ledger ─────────────────────────────────────────────── */
.period { display: flex; align-items: center; gap: 2px; }
.period b { min-width: 8.5em; text-align: center; font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; }
#ledger-list { display: flex; flex-direction: column; gap: 16px; }
.day-head { display: flex; justify-content: space-between; gap: 8px; font-family: var(--font-body); font-size: .82rem; font-weight: 500; color: var(--muted); margin: 0 4px 6px; }
.rows { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.row { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto 44px; align-items: center; gap: 10px; padding: 8px 4px 8px 12px; }
.row + .row { border-top: 1px solid var(--line); }
.row-thumb { width: 42px; height: 42px; border-radius: 10px; overflow: hidden; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); font-weight: 700; }
.row-thumb img { width: 100%; height: 100%; object-fit: cover; }
.row-thumb .no-photo img { width: 70%; height: auto; }
.row-main { display: flex; flex-direction: column; min-width: 0; }
.row-title { font-weight: 600; }
.row-meta { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.amt { font-family: var(--font-display); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt.in { color: var(--in-ink); }
.amt.out { color: var(--out-ink); }
.amt.none { color: var(--muted); }
.del { color: var(--muted); }
.del.armed { width: auto; padding: 0 10px; background: var(--bad); color: var(--surface); font-weight: 600; font-size: .85rem; }

/* ── Summary ────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.kpi { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.kpi span { font-size: .8rem; color: var(--muted); }
.kpi b { font-family: var(--font-display); font-size: 1.4rem; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi small { font-size: .76rem; color: var(--muted); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.panel h2 { font-size: 1.05rem; }
.panel h3 { font-size: .92rem; color: var(--muted); font-family: var(--font-body); font-weight: 500; }
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; }
.legend { display: flex; gap: 14px; font-size: .82rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--income); }
.sw.out { background: var(--expense); }
.split { display: grid; gap: 16px; }

.chart { position: relative; min-height: 210px; }
.chart svg { display: block; max-width: 100%; height: auto; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--muted); stroke-width: 1; }
.chart .tick, .chart .xlab { fill: var(--muted); font-size: 11px; font-family: var(--font-body); font-variant-numeric: tabular-nums; }
.chart svg.narrow .xlab { font-size: 10px; }
.chart .xlab.is-sel { fill: var(--fg); font-weight: 600; }
.chart .peak { fill: var(--fg); font-size: 11px; font-weight: 600; font-family: var(--font-body); }
.chart .bar-in { fill: var(--income); }
.chart .bar-out { fill: var(--expense); }
.chart .band { fill: var(--sel); }
.chart .hit { fill: transparent; cursor: pointer; }
.tip {
  position: absolute; top: 0; z-index: 2;
  display: flex; flex-direction: column; gap: 2px;
  min-width: 150px; padding: 8px 10px;
  background: var(--toast-bg); color: var(--toast-ink);
  border-radius: 10px; font-size: .8rem; pointer-events: none;
  box-shadow: 0 6px 18px var(--shadow);
  font-variant-numeric: tabular-nums;
}
.tip span { display: flex; align-items: center; gap: 6px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 6px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
thead th { font-size: .76rem; font-weight: 500; color: var(--muted); }
th:first-child, td:first-child { text-align: left; }
tbody th { font-weight: 500; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.is-sel { background: var(--sel); }
tbody tr.is-sel th { font-weight: 700; }
tbody tr.is-empty td { color: var(--muted); }
tfoot th, tfoot td { font-weight: 700; border-bottom: 0; }

.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
.mini-stats div { min-width: 0; }
.mini-stats dt { font-size: .76rem; color: var(--muted); }
.mini-stats dd { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.gross { font-size: .86rem; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); }
.rank, .cats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rank li { display: grid; grid-template-columns: 34px 3.6em minmax(0, 1fr) auto; align-items: center; gap: 8px; font-size: .86rem; }
.rank .row-thumb { width: 34px; height: 34px; border-radius: 8px; }
.rank b { font-family: var(--font-display); }
.meter { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 4px; background: var(--income); }
.cats li { display: flex; justify-content: space-between; gap: 12px; font-size: .88rem; padding-bottom: 6px; border-bottom: 1px dashed var(--line); }
.cats li:last-child { border-bottom: 0; }
.cats b { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ── Sheet (bottom sheet on phone, dialog on desktop) ───── */
.sheet {
  width: 100%; max-width: 100%;
  max-height: calc(100dvh - 24px);
  margin: auto 0 0;
  padding: 0; border: 0;
  border-radius: 22px 22px 0 0;
  background: var(--surface); color: var(--fg);
  overflow: auto; overscroll-behavior: contain;
}
.sheet::backdrop { background: rgba(8, 18, 24, .55); }
.sheet-form {
  display: flex; flex-direction: column; gap: 14px;
  padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.sheet-head { display: grid; grid-template-columns: minmax(0, 1fr) 44px; align-items: start; gap: 12px; }
.sheet-head.has-thumb { grid-template-columns: 60px minmax(0, 1fr) 44px; }
.sheet-thumb { width: 60px; height: 60px; border-radius: var(--r-md); overflow: hidden; }
.sheet-thumb img { width: 100%; height: 100%; object-fit: cover; }
.sheet-titles { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sheet-titles h2 { font-size: 1.3rem; }
.sheet-titles .muted { font-size: .86rem; }
.eyebrow { font-size: .74rem; font-weight: 600; letter-spacing: .06em; color: var(--muted); }
.sheet-foot {
  position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 12px;
  margin: 0 -4px; padding: 12px 4px calc(4px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.sheet-foot .btn-primary { margin-left: auto; }
.total { display: flex; flex-direction: column; min-width: 0; }
.total span { font-size: .78rem; color: var(--muted); }
.total b { font-family: var(--font-display); font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.photo-pick { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 14px; align-items: center; }
.photo-preview { width: 132px; height: 132px; border-radius: var(--r-md); overflow: hidden; background: var(--surface-2); }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
.margin-line { font-size: .88rem; color: var(--muted); }
.margin-line b { color: var(--fg); }
.history { display: flex; flex-direction: column; gap: 6px; }
.history ul { list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.history li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.history li span:last-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.settings-block { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.settings-block h3 { font-size: 1rem; }
.settings-block p { font-size: .9rem; color: var(--muted); max-width: 60ch; }

/* ── Loading & sign-in ──────────────────────────────────── */
.loading { padding: 48px 0; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.signed-out .tabs, .signed-out #btn-settings { display: none; }
.login { display: grid; place-items: center; padding-block: 24px; }
.login-card {
  width: 100%; max-width: 380px;
  display: flex; flex-direction: column; gap: 16px;
  padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
}
.login-card img { width: 72px; height: 72px; border-radius: 16px; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.is-staff .owner-only { display: none !important; }

/* picking bags to send to a customer */
.head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#btn-share.is-on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.pick-mark {
  position: absolute; top: 8px; right: 8px;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  border: 2px solid #FFFFFF; background: rgba(0, 0, 0, .28);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}
.card.is-picked { outline: 3px solid var(--accent); outline-offset: -3px; }
.card.is-picked .pick-mark { background: var(--accent); border-color: var(--accent); }
.card.is-picked .pick-mark::after { content: "✓"; color: var(--on-accent); font-weight: 700; font-size: 1rem; }
.picking .card-stock { opacity: .3; pointer-events: none; }
.picking .card.is-out { opacity: .55; }
.picking main { padding-bottom: calc(var(--tabbar-h) + 104px + env(safe-area-inset-bottom, 0px)); }
.picking .toast { bottom: calc(var(--tabbar-h) + 84px + env(safe-area-inset-bottom, 0px)); }
.pick-bar {
  position: fixed; z-index: 26;
  left: max(16px, env(safe-area-inset-left, 0px)); right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 8px;
  max-width: 560px; margin-inline: auto;
  padding: 8px 8px 8px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: 0 8px 24px var(--shadow);
}
.pick-bar #pick-count { flex: 1; min-width: 0; font-weight: 600; }
.share-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.share-thumb { margin: 0; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.share-thumb > span, .share-thumb > img { display: block; width: 100%; max-width: 100%; aspect-ratio: 1; border-radius: 10px; object-fit: cover; background: var(--surface-2); }
.share-thumb figcaption { font-size: .78rem; color: var(--muted); text-align: center; }
.share-thumb.is-missing > span { background: var(--sold-bg); }
.textarea { height: auto; min-height: 96px; padding: 10px 12px; line-height: 1.5; resize: vertical; font-family: inherit; }

/* summary picture to send in LINE */
.report-preview { min-height: 140px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.report-preview img { display: block; width: 100%; height: auto; }
@media (prefers-reduced-motion: no-preference) {
  .share-thumb.is-loading > span { animation: pulse 1s ease-in-out infinite alternate; }
  @keyframes pulse { to { opacity: .45; } }
}
.link-btn { align-self: center; border: 0; background: none; color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; min-height: 40px; padding: 0 8px; }
.done-note { font-size: .9rem; color: var(--good); font-weight: 500; }

/* lists inside sheets: users, passkeys */
.item-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.item-list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item-list li:last-child { border-bottom: 0; }
.item-list li.is-off { opacity: .55; }
.item-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.item-main .muted { font-size: .82rem; overflow-wrap: anywhere; }
.role-chip { flex: none; padding: 2px 10px; border-radius: 999px; font-size: .76rem; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.role-chip.role-owner { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.temp-pass { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: var(--r-md); background: var(--notice-bg); border: 1px dashed var(--notice-line); font-size: .9rem; }
.temp-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.temp-row code { font: 600 1.35rem/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .06em; user-select: all; }

/* activity log */
.log-list { display: flex; flex-direction: column; gap: 14px; }
.log-list ul { list-style: none; margin: 0; padding: 0; }
.log-list li { display: grid; grid-template-columns: 3.2em minmax(0, 1fr); gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: .88rem; }
.log-list li:last-child { border-bottom: 0; }
.log-list time { color: var(--muted); font-variant-numeric: tabular-nums; }
.log-list li.is-alert div { color: var(--bad); }
.log-list li.is-alert b { color: var(--fg); }

/* ── Toast ──────────────────────────────────────────────── */
.toast {
  position: fixed; z-index: 40;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 10px;
  width: max-content; max-width: calc(100% - 32px);
  padding: 8px 8px 8px 16px;
  background: var(--toast-bg); color: var(--toast-ink);
  border-radius: var(--r-md);
  box-shadow: 0 8px 24px var(--shadow);
  font-size: .92rem;
}
.toast button { border: 0; background: none; color: var(--toast-action); font-weight: 700; min-height: 40px; padding: 0 10px; }

/* ── Wider screens ──────────────────────────────────────── */
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chips { flex: 1 1 auto; }
  .search { flex: 0 1 300px; }
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sheet { margin: auto; width: min(540px, calc(100% - 32px)); border-radius: 22px; max-height: calc(100dvh - 64px); }
  .sheet-form { padding: 22px; }
  .sheet-foot { bottom: -22px; margin: 0 -6px; padding: 14px 6px 6px; }
}

@media (min-width: 960px) {
  :root { --tabbar-h: 0px; }
  .brand { margin-right: 20px; }
  .tabs {
    position: static; display: flex; gap: 4px;
    padding: 0; margin-right: auto;
    background: none; border: 0;
  }
  .tab { flex-direction: row; gap: 8px; min-height: 42px; padding: 0 16px; font-size: .95rem; color: var(--brand-ink-2); }
  .tab svg { width: 20px; height: 20px; }
  .tab:hover { color: var(--brand-ink); }
  .tab[aria-current="page"] { background: var(--brand-2); color: var(--brand-ink); }
  main { padding-block: 28px 56px; gap: 20px; }
  h1 { font-size: 1.8rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(208px, 1fr)); gap: 16px; }
  .split { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
  .stat-strip > div { padding: 12px 18px; }
  .stat-strip b { font-size: 1.25rem; }
  .toast { bottom: 24px; }
  .pick-bar { bottom: 24px; }
  .picking .toast { bottom: 96px; }
}

@media (prefers-reduced-motion: no-preference) {
  .qty-btn, .btn, .chip, .tab { transition: background-color .15s, color .15s, transform .1s; }
  .qty-btn:active:not(:disabled), .btn:active { transform: scale(.96); }
  .sheet[open] { animation: sheet-in .22s ease-out; }
  @keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
}
