/* ---------- fonts ---------- */
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(vendor/fonts/inter-latin-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(vendor/fonts/inter-latin-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- tokens ---------- */
/* Neutral greys; the ink colour (--text) doubles as the primary button colour. */
:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --surface-3: #e4e4e7;
  --text: #18181b;
  --text-2: #3f3f46;
  --muted: #71717a;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --primary: #4f46e5;
  --primary-soft: #eef2ff;
  --green: #059669;
  --green-soft: rgba(16, 185, 129, .1);
  --red: #dc2626;
  --red-soft: rgba(239, 68, 68, .09);
  --amber: #d97706;
  --amber-soft: rgba(245, 158, 11, .12);
  --btn-green: #16a34a;
  --btn-red: #dc2626;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-lg: 0 8px 24px -8px rgba(0, 0, 0, .14);
  --ring: 0 0 0 3px rgba(79, 70, 229, .15);
  --overlay: rgba(9, 9, 11, .4);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #09090b;
    --surface: #111113;
    --surface-2: #18181b;
    --surface-3: #27272a;
    --text: #fafafa;
    --text-2: #d4d4d8;
    --muted: #a1a1aa;
    --border: #232326;
    --border-strong: #2e2e32;
    --primary: #818cf8;
    --primary-soft: rgba(129, 140, 248, .1);
    --green: #34d399;
    --green-soft: rgba(52, 211, 153, .12);
    --red: #f87171;
    --red-soft: rgba(248, 113, 113, .12);
    --amber: #fbbf24;
    --amber-soft: rgba(251, 191, 36, .12);
    --btn-green: #15803d;
    --btn-red: #b91c1c;
    --shadow: none;
    --shadow-lg: 0 12px 32px -8px rgba(0, 0, 0, .6);
    --overlay: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #09090b;
  --surface: #111113;
  --surface-2: #18181b;
  --surface-3: #27272a;
  --text: #fafafa;
  --text-2: #d4d4d8;
  --muted: #a1a1aa;
  --border: #232326;
  --border-strong: #2e2e32;
  --primary: #818cf8;
  --primary-soft: rgba(129, 140, 248, .1);
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, .12);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, .12);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, .12);
  --btn-green: #15803d;
  --btn-red: #b91c1c;
  --shadow: none;
  --shadow-lg: 0 12px 32px -8px rgba(0, 0, 0, .6);
  --overlay: rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
html, body { background: var(--bg); }
body {
  font: 15px/1.5 'Inter Variable', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-feature-settings: 'cv11', 'ss01';
  letter-spacing: -.006em;
  color: var(--text);
  display: flex;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; }
h1 { font-size: 1.85rem; line-height: 1.15; margin: 0; font-weight: 750; letter-spacing: -.03em; }
h2 { font-size: 1.05rem; margin: 0 0 .85rem; font-weight: 650; letter-spacing: -.015em; display: flex; align-items: center; gap: .5rem; }
h3 { font-size: .95rem; margin: 0 0 .5rem; font-weight: 650; }
h2 .i { color: var(--muted); }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.mono { font-family: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, monospace; letter-spacing: 0; }
.hidden { display: none !important; }
::selection { background: rgba(79, 70, 229, .2); }

.i { width: 1.15em; height: 1.15em; flex-shrink: 0; vertical-align: -.2em; display: inline-block; }

/* ---------- layout ---------- */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
}
.sidebar-inner {
  flex: 1;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem .7rem .7rem;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .7rem; font-weight: 750; font-size: 1.15rem; letter-spacing: -.02em; padding: .2rem .55rem 1rem; color: var(--text); line-height: 1.2; }
.brand img { width: 36px; height: 36px; }
.brand small { display: block; white-space: nowrap; font-size: .68rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.nav-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 650; padding: .9rem .75rem .35rem; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  position: relative;
  display: flex; align-items: center; gap: .7rem;
  color: var(--text-2); padding: .55rem .75rem; border-radius: 10px;
  font-weight: 520; transition: background .15s, color .15s;
}
.side-nav a .i { color: var(--muted); transition: color .15s; }
.side-nav a:hover { background: var(--surface-2); color: var(--text); }
.side-nav a.active { background: var(--surface-2); color: var(--text); font-weight: 650; }
.side-nav a.active .i { color: var(--text); }
.side-scan { margin: .2rem 0 .4rem; }
.side-user { margin-top: auto; padding-top: .7rem; }
.user-card { display: flex; align-items: center; gap: .65rem; padding: .55rem; border-radius: 12px; background: var(--surface-2); color: var(--text); }
.user-card .grow { flex: 1; min-width: 0; }
.user-card .title { font-weight: 650; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card .sub { font-size: .75rem; color: var(--muted); }

.avatar {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--text); font-weight: 700; font-size: .85rem; letter-spacing: .02em;
}
.avatar.off { color: var(--muted); }

/* accounts */
body:not(.is-admin) .admin-only { display: none !important; }
body.auth .sidebar, body.auth .bottom-nav { display: none !important; }

main { flex: 1; min-width: 0; padding: 2rem 2.5rem 4rem; max-width: 1280px; margin: 0 auto; }
main > * { animation: rise .4s cubic-bezier(.2, .8, .2, 1) both; }
main > *:nth-child(2) { animation-delay: .04s; }
main > *:nth-child(3) { animation-delay: .08s; }
main > *:nth-child(4) { animation-delay: .12s; }
main > *:nth-child(n+5) { animation-delay: .16s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes fade { from { opacity: 0; } }

.bottom-nav { display: none; }

@media (max-width: 800px) {
  .sidebar { display: none; }
  main { padding: calc(1rem + env(safe-area-inset-top)) 1rem calc(96px + env(safe-area-inset-bottom)); }
  h1 { font-size: 1.6rem; }
  .bottom-nav {
    display: flex; align-items: flex-end;
    position: fixed; z-index: 50;
    left: 0; right: 0; bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: .4rem .3rem calc(.4rem + env(safe-area-inset-bottom));
  }
  .bottom-nav a {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-size: .66rem; font-weight: 600; color: var(--muted); padding: .3rem 0 .15rem;
    border-radius: 16px; transition: color .15s;
  }
  .bottom-nav a .i { width: 22px; height: 22px; }
  .bottom-nav a.active { color: var(--text); }
  .bottom-nav .scan-btn .fab {
    width: 58px; height: 58px; margin-top: -30px; margin-bottom: 1px;
    display: grid; place-items: center;
    background: var(--text); color: var(--bg); border-radius: 18px;
    box-shadow: 0 0 0 5px var(--surface);
    transition: transform .15s;
  }
  .bottom-nav .scan-btn:active .fab { transform: scale(.94); }
  .bottom-nav .scan-btn .fab .i { width: 26px; height: 26px; }
}

.page-head { display: flex; align-items: flex-end; gap: .75rem 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head h1 { flex: 1; min-width: 0; }
.page-head .eyebrow { display: block; font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .09em; margin-bottom: .35rem; }
.back { display: inline-flex; align-items: center; gap: .35rem; margin-bottom: .9rem; color: var(--muted); font-weight: 550; font-size: .88rem; padding: .32rem .8rem .32rem .55rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.back:hover { color: var(--text); }
@media (max-width: 600px) {
  .page-head { align-items: center; }
  .page-head > .btns { width: 100%; }
  .page-head > .btns > .btn.primary { flex: 1; }
}

/* ---------- components ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.card > .list:only-child { margin: -.5rem -.6rem; }
.card-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .8rem; }
.card-head h2 { flex: 1; margin: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.grid > * { min-width: 0; }
@media (max-width: 600px) {
  .card { padding: 1rem 1rem; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* greeting (home) */
.hero { margin-bottom: 1.5rem; padding-top: .25rem; }
.hero .hello { font-size: .88rem; color: var(--muted); font-weight: 600; text-transform: capitalize; }
.hero h1 { font-size: 2.1rem; margin: .25rem 0 .35rem; }
.hero p { color: var(--muted); margin: 0 0 1.2rem; max-width: 560px; }
@media (max-width: 600px) {
  .hero h1 { font-size: 1.7rem; }
  .hero .btns { display: grid; grid-template-columns: 1fr 1fr; }
  .hero .btns .primary { grid-column: 1 / -1; }
}

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .8rem; margin-bottom: 1.1rem; }
.stat {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: .15rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow); color: var(--text);
  transition: border-color .15s;
}
a.stat:hover { border-color: var(--border-strong); }
.stat .ico {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; margin-bottom: .6rem;
  background: var(--surface-2); color: var(--muted);
}
.stat .ico.amber { background: var(--amber-soft); color: var(--amber); }
.stat .v { font-size: 1.75rem; font-weight: 750; letter-spacing: -.035em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: .95rem; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.stat .v.money { font-size: 1.35rem; }
.stat .l { color: var(--muted); font-size: .82rem; font-weight: 550; }
.stat.warn { border-color: rgba(245, 158, 11, .45); }
.stat.warn .v { color: var(--amber); }
.stat .arrow { position: absolute; top: 1rem; right: 1rem; color: var(--muted); opacity: 0; transition: opacity .18s, transform .18s; }
a.stat:hover .arrow { opacity: 1; transform: translate(2px, -2px); }
.progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: .6rem; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--text); }
@media (max-width: 600px) {
  .stats { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .stat { padding: .85rem .9rem; }
  .stat .v { font-size: 1.45rem; }
  .stat .v.money { font-size: 1.15rem; }
  .stat .ico { width: 34px; height: 34px; margin-bottom: .45rem; }
  .stat .arrow { display: none; }
  .stats > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: .55rem 1rem;
  border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; font-size: .92rem;
  cursor: pointer;
  white-space: nowrap;
  min-height: 42px;
  transition: background .15s, transform .1s, box-shadow .15s, opacity .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn .i { width: 1.1em; height: 1.1em; }
.btn.primary { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn.green { background: var(--btn-green); border-color: transparent; color: #fff; }
.btn.red { background: var(--btn-red); border-color: transparent; color: #fff; }
.btn.primary:hover, .btn.green:hover, .btn.red:hover { opacity: .88; }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-soft); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: .3rem .65rem; min-height: 34px; font-size: .83rem; border-radius: 10px; }
.btn.lg { padding: .8rem 1.3rem; min-height: 52px; font-size: 1.02rem; border-radius: 12px; }
.btn.block { width: 100%; }
.btn.icon { padding: 0; width: 42px; flex-shrink: 0; }
.btn.sm.icon { width: 34px; }
.btns { display: flex; gap: .5rem; flex-wrap: wrap; }
label.btn input[type=checkbox] { margin: 0; width: 18px; height: 18px; }

/* forms */
input, select, textarea {
  font: inherit;
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: .6rem .8rem;
  width: 100%;
  min-height: 44px;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 2.2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8fa8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center; background-size: 16px;
}
textarea { min-height: 90px; resize: vertical; }
/* iOS zooms into any field under 16px when it gets focus. */
@media (max-width: 800px) { input, select, textarea { font-size: 16px; } }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
input[type=color] { padding: .25rem; width: 56px; cursor: pointer; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--text); flex-shrink: 0; cursor: pointer; }
input[type=search] {
  padding-left: 2.4rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8fa8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: .8rem center; background-size: 17px;
}
label.field { display: block; margin-bottom: .9rem; }
label.field > span { display: block; font-size: .8rem; color: var(--text-2); margin-bottom: .35rem; font-weight: 600; }
.row { display: flex; gap: .75rem; }
.row > * { flex: 1; min-width: 0; }
.input-btn { display: flex; gap: .45rem; }
.input-btn input, .input-btn select { flex: 1; min-width: 0; }
.input-btn .btn { min-height: 44px; }
.check-row { display: flex; gap: .6rem; align-items: center; padding: .7rem .8rem; border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer; font-weight: 550; }

.toolbar { display: flex; gap: .55rem; flex-wrap: wrap; margin-bottom: 1.1rem; align-items: center; }
.toolbar input[type=search] { flex: 1; min-width: 220px; }
.toolbar select { width: auto; }
.tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.tabs button { display: inline-flex; align-items: center; gap: .4rem; border: 0; background: none; padding: .45rem .85rem; border-radius: 8px; font: inherit; font-size: .88rem; font-weight: 600; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.tabs button:hover { color: var(--text); }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
@media (max-width: 600px) {
  .toolbar input[type=search] { min-width: 0; flex: 1 1 calc(100% - 3.5rem); }
  .toolbar .tabs { width: 100%; display: flex; }
  .toolbar .tabs button { flex: 1; justify-content: center; padding: .45rem .3rem; }
  .toolbar select { flex: 1; }
  .page-head > .tabs { width: 100%; display: flex; }
  .page-head > .tabs button { flex: 1; justify-content: center; }
}

.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 650; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); align-self: flex-start; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .55rem; border-radius: 8px; font-size: .72rem; font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
.badge .i { width: 12px; height: 12px; }
.b-green { background: var(--green-soft); color: var(--green); }
.b-red { background: var(--red-soft); color: var(--red); }
.b-amber { background: var(--amber-soft); color: var(--amber); }
.b-blue { background: var(--primary-soft); color: var(--primary); }
.b-gray { background: var(--surface-2); color: var(--muted); }

/* lists */
.list { display: flex; flex-direction: column; }
.item {
  display: flex; align-items: center; gap: .85rem;
  padding: .7rem .6rem;
  border-radius: 10px;
  color: var(--text);
  transition: background .12s;
  position: relative;
}
.item + .item::before { content: ''; position: absolute; top: 0; left: .6rem; right: .6rem; height: 1px; background: var(--border); }
a.item:hover, label.item:hover, .picker-list .item:hover { background: var(--surface-2); }
a.item:hover::before, a.item:hover + .item::before, label.item:hover::before, label.item:hover + .item::before { opacity: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub .i { width: 13px; height: 13px; vertical-align: -2px; }
.item .right { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; display: flex; flex-direction: column; align-items: flex-end; gap: .1rem; }
.item .right.inline { flex-direction: row; align-items: center; gap: .35rem; }
.item .chev { color: var(--muted); opacity: .6; }
.thumb { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; background: var(--surface-2); flex-shrink: 0; display: grid; place-items: center; color: var(--muted); border: 1px solid var(--border); }
.thumb .i { width: 22px; height: 22px; }
.thumb.tone { background: var(--surface-2); color: var(--text-2); }
.thumb.dim { background: transparent; border-style: dashed; }
.thumb.lg { width: 72px; height: 72px; border-radius: 12px; }
.qty { font-weight: 750; font-size: 1.05rem; letter-spacing: -.02em; }
.qty.low { color: var(--amber); }
.mv-badge { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.mv-badge .i { width: 19px; height: 19px; }

/* product grid */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .9rem; }
.pcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; color: var(--text); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  transition: border-color .15s;
}
.pcard:hover { border-color: var(--border-strong); }
.pcard .img { position: relative; aspect-ratio: 4/3; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); overflow: hidden; }
.pcard .img > .i { width: 40px; height: 40px; opacity: .45; }
.pcard .img img { width: 100%; height: 100%; object-fit: cover; }
.pcard .img .badge { position: absolute; top: .55rem; right: .55rem; background: #fff; color: #b45309; }
.pcard .body { padding: .75rem .9rem .9rem; display: flex; flex-direction: column; gap: .3rem; flex: 1; }
.pcard .name { font-weight: 650; line-height: 1.3; letter-spacing: -.01em; }
.pcard .meta { display: flex; justify-content: space-between; align-items: baseline; margin-top: auto; padding-top: .45rem; gap: .5rem; }
.pcard .meta .qty { font-size: 1.3rem; }
@media (max-width: 500px) {
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
  .pcard .body { padding: .6rem .7rem .75rem; }
  .pcard .name { font-size: .9rem; }
  .pcard .meta .qty { font-size: 1.1rem; }
}

.count { font-size: .82rem; color: var(--muted); font-weight: 550; margin: 0 0 .7rem; }

.group-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem; }
.group-head h3 { flex: 1; margin: 0; display: flex; align-items: center; gap: .5rem; }
.group-head h3 .i { color: var(--muted); }
.group-head .n { font-size: .72rem; font-weight: 700; color: var(--muted); background: var(--surface-2); border-radius: 99px; padding: .05rem .55rem; }

.selbar {
  position: sticky; top: .75rem; z-index: 20;
  display: flex; gap: .5rem; align-items: center; flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--text); border-radius: var(--radius);
  padding: .65rem .8rem; margin-bottom: 1rem; box-shadow: var(--shadow-lg);
}
.empty { text-align: center; padding: 2.8rem 1rem; color: var(--muted); }
.empty .ico { width: 56px; height: 56px; margin: 0 auto .9rem; border-radius: 14px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.empty .ico .i { width: 30px; height: 30px; }
.empty p { margin-bottom: 1rem; }
.empty.compact { padding: 1.6rem 1rem; }
.empty.compact .ico { width: 44px; height: 44px; border-radius: 12px; margin-bottom: .6rem; }
.empty.compact .ico .i { width: 22px; height: 22px; }

.loader { display: grid; place-items: center; padding: 4rem 0; }
.loader span { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--text); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* product detail */
.gallery-main { aspect-ratio: 1; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; color: var(--muted); cursor: zoom-in; box-shadow: var(--shadow); }
.gallery-main > .i { width: 72px; height: 72px; opacity: .4; }
.gallery-main img { width: 100%; height: 100%; object-fit: contain; }
.thumbs { display: flex; gap: .5rem; margin-top: .7rem; flex-wrap: wrap; }
.thumbs .t { position: relative; width: 66px; height: 66px; border-radius: 10px; overflow: hidden; border: 2px solid transparent; cursor: pointer; background: var(--surface-2); opacity: .7; transition: opacity .15s, border-color .15s; }
.thumbs .t:hover { opacity: 1; }
.thumbs .t.active { border-color: var(--text); opacity: 1; }
.thumbs .t img { width: 100%; height: 100%; object-fit: cover; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .6rem 1.2rem; margin: 0; }
.kv dt { color: var(--muted); font-size: .88rem; }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.stock-hero { display: flex; align-items: baseline; gap: .3rem .7rem; flex-wrap: wrap; padding-bottom: 1.1rem; margin-bottom: 1.1rem; border-bottom: 1px solid var(--border); }
.stock-hero .lbl { width: 100%; font-size: .74rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.stock-hero .big-qty { text-align: left; }

/* location detail */
.loc-head { text-align: center; padding: .8rem 0 1.2rem; }
.loc-code {
  font-size: 2.7rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.05;
  overflow-wrap: anywhere;
}
.loc-head .crumbs { display: flex; justify-content: center; gap: .35rem; flex-wrap: wrap; margin-top: .7rem; }
.loc-head .desc { color: var(--muted); margin-top: .5rem; font-size: .9rem; }
.big-qty { font-size: 3.6rem; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; line-height: 1; letter-spacing: -.05em; }
.big-qty.low { color: var(--amber); }
.qty-label { text-align: center; color: var(--muted); font-weight: 550; margin-top: .35rem; }
.qty-ctrl { display: grid; grid-template-columns: 64px 1fr 64px; gap: .5rem; align-items: center; margin: 1.3rem 0 .75rem; }
.qty-ctrl input { text-align: center; font-size: 1.6rem; font-weight: 750; min-height: 60px; border-radius: 12px; letter-spacing: -.02em; }
.qty-ctrl .btn { min-height: 60px; border-radius: 12px; }
.qty-ctrl .btn .i { width: 24px; height: 24px; }
.stock-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.stock-actions .btn { min-height: 66px; flex-direction: column; gap: .15rem; font-size: .95rem; border-radius: 12px; }
.stock-actions .btn small { font-weight: 500; font-size: .7rem; opacity: .85; }
.assigned { display: flex; gap: .9rem; align-items: center; border: 1px solid var(--border); border-radius: 12px; padding: .7rem; background: var(--surface-2); color: var(--text); transition: border-color .15s; }
.assigned:hover { border-color: var(--border-strong); }
.qr-card { display: flex; gap: 1.1rem; align-items: center; }
.qr-card img { width: 124px; height: 124px; background: #fff; border-radius: 12px; padding: 7px; border: 1px solid var(--border); flex-shrink: 0; }
.qr-card .btns { flex-direction: column; align-items: stretch; flex: 1; }
.action-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .5rem; margin-bottom: 1rem; }

/* movements */
.mv-change { font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.mv-change.pos { color: var(--green); }
.mv-change.neg { color: var(--red); }

/* table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--border); }
th { font-size: .78rem; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }

/* ---------- modal ---------- */
.modal-bg {
  position: fixed; inset: 0;
  background: var(--overlay);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 1rem;
  animation: fade .18s;
}
.modal {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 18px;
  width: 100%; max-width: 520px; max-height: calc(100vh - 2rem);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: pop .2s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.97); } }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; padding: 1.2rem 1.3rem .6rem; gap: .5rem; }
.modal-head h2 { flex: 1; margin: 0; font-size: 1.15rem; }
.modal-body { padding: .5rem 1.3rem; overflow-y: auto; }
.modal-foot { padding: .9rem 1.3rem 1.2rem; display: flex; gap: .5rem; justify-content: flex-end; }
.x { border: 0; background: var(--surface-2); width: 36px; height: 36px; border-radius: 10px; cursor: pointer; color: var(--muted); display: grid; place-items: center; transition: background .15s, color .15s; flex-shrink: 0; }
.x:hover { background: var(--surface-3); color: var(--text); }
.x .i { width: 18px; height: 18px; }
.choice-list { display: flex; flex-direction: column; gap: .5rem; }
@media (max-width: 600px) {
  .modal-bg { align-items: flex-end; padding: 0; }
  .modal { border-radius: 18px 18px 0 0; max-height: 92vh; padding-bottom: env(safe-area-inset-bottom); border-bottom: 0; animation: sheet .32s cubic-bezier(.2, .9, .3, 1); }
  .modal::before { content: ''; width: 40px; height: 5px; border-radius: 9px; background: var(--surface-3); margin: .55rem auto 0; flex-shrink: 0; }
  .modal-head { padding-top: .7rem; }
  .modal-foot .btn { flex: 1; min-height: 50px; }
}
@keyframes sheet { from { transform: translateY(100%); } }

.picker-list { max-height: 50vh; overflow-y: auto; margin: .6rem -.4rem 0; }
.picker-list .item { cursor: pointer; }

.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .92); z-index: 200; display: grid; place-items: center; cursor: zoom-out; animation: fade .2s; }
.lightbox img { max-width: 95vw; max-height: 95vh; object-fit: contain; border-radius: 12px; }

/* scanner */
.scanner-box { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; min-height: 280px; }
.scanner-box video { width: 100% !important; display: block; }
.scanner-box::after {
  content: ''; position: absolute; left: 12%; right: 12%; top: 50%; height: 2px; pointer-events: none;
  background: rgba(255, 255, 255, .75);
  animation: scanline 2.4s ease-in-out infinite;
}
.scanner-box.off::after { display: none; }
@keyframes scanline { 0%, 100% { transform: translateY(-90px); opacity: .3; } 50% { transform: translateY(90px); opacity: 1; } }
.scan-hint { text-align: center; color: var(--muted); margin: 1rem 0; }
.scan-or { display: flex; align-items: center; gap: .8rem; color: var(--muted); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; margin: 1rem 0; }
.scan-or::before, .scan-or::after { content: ''; flex: 1; height: 1px; background: var(--border-strong); }
.notice { display: flex; gap: .7rem; align-items: flex-start; padding: 1rem 1.1rem; border-radius: var(--radius); background: var(--amber-soft); color: var(--text); border: 1px solid rgba(245, 158, 11, .3); }
.notice > .i { color: var(--amber); margin-top: .15rem; }
.notice.info { background: var(--surface-2); border-color: var(--border); }
.notice.info > .i { color: var(--muted); }

/* toasts */
#toasts { position: fixed; top: calc(1rem + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; width: max-content; max-width: 92vw; }
.toast {
  display: flex; align-items: center; gap: .55rem;
  background: #18181b; color: #fff;
  border: 1px solid rgba(255, 255, 255, .1);
  padding: .7rem 1.1rem .7rem .85rem; border-radius: 12px;
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, .35);
  font-weight: 600; font-size: .92rem;
  animation: toast .25s ease-out;
}
.toast .i { width: 20px; height: 20px; }
.toast.ok .i { color: #34d399; }
.toast.err .i { color: #fb7185; }
@keyframes toast { from { opacity: 0; transform: translateY(-14px) scale(.95); } }

/* photo picker previews */
.previews { display: flex; gap: .6rem; flex-wrap: wrap; margin: .8rem 0; }
.previews:empty { display: none; }
.previews .t { position: relative; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.previews .t img { width: 100%; height: 100%; object-fit: cover; }
.previews .t .acts { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; padding: 3px; }
.previews .t button { border: 0; background: rgba(0, 0, 0, .6); color: #fff; border-radius: 8px; width: 26px; height: 26px; display: grid; place-items: center; cursor: pointer; padding: 0; }
.previews .t button .i { width: 14px; height: 14px; }
.previews .t .star { position: absolute; top: 4px; left: 4px; background: #18181b; color: #fff; border-radius: 6px; font-size: .62rem; padding: 1px 5px; font-weight: 700; }
.dropzone { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.dropzone .btn { flex-direction: column; min-height: 92px; border-style: dashed; border-width: 1.5px; background: var(--surface-2); color: var(--text-2); box-shadow: none; }
.dropzone .btn:hover { border-color: var(--muted); }
.dropzone .btn .i { width: 26px; height: 26px; color: var(--muted); }

/* menu (mobile "more") */
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin-bottom: 1rem; }
.menu-tile { display: flex; flex-direction: column; gap: .8rem; padding: 1.1rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 650; box-shadow: var(--shadow); transition: transform .12s; }
.menu-tile:active { transform: scale(.97); }
.menu-tile .ico { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.menu-tile .ico .i { width: 22px; height: 22px; }
.menu-tile small { display: block; font-weight: 500; color: var(--muted); font-size: .76rem; margin-top: .15rem; }
.menu-user { display: flex; align-items: center; gap: .9rem; }
.menu-user .avatar { width: 52px; height: 52px; border-radius: 14px; font-size: 1.05rem; }

/* segmented control (theme) */
.seg { display: flex; flex-wrap: nowrap; width: 100%; }
.seg button { flex: 1; justify-content: center; padding: .45rem .4rem; min-width: 0; }

/* ---------- auth ---------- */
body.auth main { display: grid; place-items: center; min-height: 100vh; max-width: none; padding: 1.5rem; }
.auth-card {
  width: 100%; max-width: 410px; margin: 0;
  padding: 2.1rem 1.8rem 1.8rem;
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
}
.auth-brand { text-align: center; margin-bottom: 1.6rem; }
.auth-brand img { width: 56px; height: 56px; }
.auth-brand h2 { display: block; font-size: 1.7rem; font-weight: 800; letter-spacing: -.035em; margin: .8rem 0 .25rem; }
.auth-brand p { color: var(--muted); margin: 0; font-size: .92rem; }

/* ---------- labels / print ---------- */
.label-sheet { display: flex; flex-wrap: wrap; gap: 4mm; }
#lbsheet { background: var(--surface-2); padding: .9rem; border-radius: 14px; align-content: flex-start; }
.label {
  border: 1px dashed #bbb; border-radius: 2mm;
  display: flex; align-items: center; gap: 3mm;
  padding: 2.5mm; background: #fff; color: #000;
  break-inside: avoid; page-break-inside: avoid;
  overflow: hidden;
}
.label img { flex-shrink: 0; }
.label .lt { min-width: 0; }
.label .lc { font-weight: 800; font-family: ui-monospace, Menlo, monospace; line-height: 1.1; overflow-wrap: anywhere; }
.label .ld { font-size: 9pt; line-height: 1.2; }
.label .lp { font-size: 8pt; color: #444; margin-top: 1mm; }
.label.s { width: 50mm; height: 30mm; }
.label.s img { width: 24mm; height: 24mm; }
.label.s .lc { font-size: 11pt; }
.label.m { width: 70mm; height: 40mm; }
.label.m img { width: 34mm; height: 34mm; }
.label.m .lc { font-size: 15pt; }
.label.l { width: 100mm; height: 60mm; }
.label.l img { width: 52mm; height: 52mm; }
.label.l .lc { font-size: 22pt; }
.label.l .ld { font-size: 12pt; }
/* DYMO 30336: 1 × 2.125 in (25 × 54 mm), printed landscape, one label per page */
.label.dymo { width: 54mm; height: 25.4mm; padding: 1.5mm 2mm; gap: 2mm; }
.label.dymo img { width: 21mm; height: 21mm; }
.label.dymo .lt { overflow: hidden; }
.label.dymo .lc { font-size: 12pt; }
.label.dymo .ld { font-size: 7pt; }
.label.dymo .lp { font-size: 7pt; margin-top: .5mm; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#print-area { display: none; }

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

@media print {
  @page { margin: 8mm; }
  html, body { background: #fff; display: block; min-height: 0; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; }
  .label { border-color: #ddd; }
  .label-sheet.roll { display: block; }
  .label-sheet.roll .label { border: 0; border-radius: 0; height: 25mm; break-after: page; page-break-after: always; }
  .label-sheet.roll .label:last-child { break-after: auto; page-break-after: auto; }
}
