:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede7;
  --text: #1d1d1b;
  --text-2: #5f5e5a;
  --text-3: #8c8b85;
  --border: rgba(29, 29, 27, 0.10);
  --border-2: rgba(29, 29, 27, 0.18);
  --accent: #0f6e56;
  --accent-hover: #0b5e49;
  --accent-soft: #e1f5ee;
  --on-accent: #ffffff;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.18);
  --radius: 12px;
  --radius-lg: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, system-ui, sans-serif;

  --c-teal-bg: #e1f5ee;   --c-teal-fg: #0f6e56;
  --c-coral-bg: #faece7;  --c-coral-fg: #993c1d;
  --c-pink-bg: #fbeaf0;   --c-pink-fg: #993556;
  --c-amber-bg: #faeeda;  --c-amber-fg: #854f0b;
  --c-purple-bg: #eeedfe; --c-purple-fg: #534ab7;
  --c-blue-bg: #e6f1fb;   --c-blue-fg: #185fa5;
  --c-green-bg: #eaf3de;  --c-green-fg: #3b6d11;
  --c-gray-bg: #f1efe8;   --c-gray-fg: #5f5e5a;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514;
    --surface: #1f1f1d;
    --surface-2: #2a2a27;
    --text: #f1efe8;
    --text-2: #b4b2a9;
    --text-3: #888780;
    --border: rgba(241, 239, 232, 0.10);
    --border-2: rgba(241, 239, 232, 0.18);
    --accent: #5dcaa5;
    --accent-hover: #7dd8b8;
    --accent-soft: #10362c;
    --on-accent: #04342c;
    --danger: #f09595;
    --danger-soft: #3a1717;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.5);
    --c-teal-bg: #0b3a2f;   --c-teal-fg: #9fe1cb;
    --c-coral-bg: #4a1f10;  --c-coral-fg: #f5c4b3;
    --c-pink-bg: #4b1a2c;   --c-pink-fg: #f4c0d1;
    --c-amber-bg: #3f2a08;  --c-amber-fg: #fac775;
    --c-purple-bg: #2c2766; --c-purple-fg: #cecbf6;
    --c-blue-bg: #0c2f55;   --c-blue-fg: #b5d4f4;
    --c-green-bg: #1f3a0b;  --c-green-fg: #c0dd97;
    --c-gray-bg: #2c2c2a;   --c-gray-fg: #d3d1c7;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 26px; line-height: 1.2; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
  transition: background .15s, transform .1s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn i { font-size: 18px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.block { width: 100%; height: 48px; font-size: 16px; }
.btn.sm { height: 34px; padding: 0 10px; font-size: 13px; }
.btn.icon-only { width: 40px; padding: 0; }
.btn[disabled] { opacity: .6; pointer-events: none; }

input, textarea, select {
  width: 100%; font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 10px;
  padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; font-weight: 550; color: var(--text-2); margin-bottom: 6px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { min-width: 0; }
.grow { flex: 1; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: calc(10px + var(--safe-top)) max(20px, env(safe-area-inset-right)) 10px max(20px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-size: 20px; }
.search { flex: 1; max-width: 560px; position: relative; margin: 0 auto; }
.search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 18px; }
.search input { padding-left: 38px; height: 42px; background: var(--surface); border-radius: 12px; }
.top-actions { display: flex; gap: 6px; align-items: center; }
main { max-width: 1180px; margin: 0 auto; padding: 24px 20px 120px; outline: none; }

.tabbar { display: none; }

@media (max-width: 760px) {
  .topbar { gap: 10px; padding-left: 16px; padding-right: 16px; }
  .brand > span:last-child { display: none; }
  .top-actions { display: none; }
  main { padding: 16px 16px calc(110px + var(--safe-bottom)); }
  h1 { font-size: 23px; }
  .tabbar {
    display: flex; position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    padding: 6px 6px calc(6px + var(--safe-bottom));
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
    border-top: 1px solid var(--border);
  }
  .tabbar > * {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    background: none; border: 0; font: inherit; font-size: 10.5px; font-weight: 550; color: var(--text-3);
    padding: 4px 0; cursor: pointer;
  }
  .tabbar i { font-size: 24px; }
  .tabbar .active { color: var(--accent); }
  .tab-scan { justify-content: center; }
  .scan-bubble {
    width: 54px; height: 54px; margin-top: -24px; border-radius: 18px; display: grid; place-items: center;
    background: var(--accent); color: var(--on-accent); box-shadow: 0 6px 18px rgba(15, 110, 86, .35);
  }
  .scan-bubble i { font-size: 28px; }
}

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); margin-bottom: 10px; }
.crumbs a:hover { color: var(--accent); }
.crumbs i { font-size: 14px; color: var(--text-3); }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; color: var(--text-2); margin-bottom: 12px; }
.back-link:hover { color: var(--accent); }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.stat .label i { font-size: 16px; color: var(--text-3); }
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.stat .value.sm { font-size: 15px; font-weight: 600; margin-top: 8px; }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .stat .value { font-size: 22px; } }

/* ---------- chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--border-2); background: var(--surface); color: var(--text-2);
  font: inherit; font-size: 13.5px; font-weight: 550; cursor: pointer;
}
.chip .n { color: var(--text-3); font-weight: 500; }
.chip.active { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip.active .n { color: inherit; opacity: .7; }

/* ---------- box grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
@media (max-width: 760px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; transition: transform .15s, box-shadow .15s, border-color .15s; display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-2); }
.card:active { transform: scale(.98); }
.cover { aspect-ratio: 4 / 3; position: relative; overflow: hidden; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover .ph { width: 100%; height: 100%; display: grid; place-items: center; }
.cover .ph-inner { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.cover .ph i { font-size: 34px; opacity: .85; }
.cover .ph b { font-size: 22px; font-weight: 750; letter-spacing: -0.02em; }
.code-badge {
  position: absolute; top: 10px; left: 10px; padding: 3px 8px; border-radius: 8px;
  background: rgba(255,255,255,.92); color: #1d1d1b; font-size: 12px; font-weight: 700; letter-spacing: .01em;
}
.card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card .title { font-weight: 650; font-size: 15px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card .meta { font-size: 12.5px; color: var(--text-2); display: flex; gap: 10px; flex-wrap: wrap; }
.card .meta span { display: inline-flex; align-items: center; gap: 4px; }
.card .meta i { font-size: 14px; color: var(--text-3); }
.loc { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 550; padding: 3px 8px; border-radius: 7px; background: var(--surface-2); color: var(--text-2); max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.loc i { font-size: 13px; }
.card .loc { margin-top: auto; align-self: flex-start; }

.tint-teal   { background: var(--c-teal-bg);   color: var(--c-teal-fg); }
.tint-coral  { background: var(--c-coral-bg);  color: var(--c-coral-fg); }
.tint-pink   { background: var(--c-pink-bg);   color: var(--c-pink-fg); }
.tint-amber  { background: var(--c-amber-bg);  color: var(--c-amber-fg); }
.tint-purple { background: var(--c-purple-bg); color: var(--c-purple-fg); }
.tint-blue   { background: var(--c-blue-bg);   color: var(--c-blue-fg); }
.tint-green  { background: var(--c-green-bg);  color: var(--c-green-fg); }
.tint-gray   { background: var(--c-gray-bg);   color: var(--c-gray-fg); }

/* ---------- box detail ---------- */
.box-hero { display: grid; grid-template-columns: 300px minmax(0, 1fr) 190px; gap: 24px; align-items: start; margin-bottom: 28px; }
.box-hero .cover { border-radius: var(--radius-lg); border: 1px solid var(--border); aspect-ratio: 1; cursor: zoom-in; }
.box-hero .cover.no-photo { cursor: default; }
.box-info { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.box-info .code { font-size: 13px; font-weight: 700; color: var(--accent); letter-spacing: .02em; }
.box-info .desc { color: var(--text-2); white-space: pre-wrap; line-height: 1.6; }
.box-info .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.qr-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px; text-align: center; }
.qr-card img { width: 100%; aspect-ratio: 1; border-radius: 8px; background: #fff; cursor: zoom-in; }
.qr-card .small { margin-top: 8px; }
.qr-card .btn { margin-top: 10px; width: 100%; }
@media (max-width: 900px) {
  .box-hero { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .box-hero .cover { aspect-ratio: 16 / 10; }
  .qr-card { display: grid; grid-template-columns: 96px 1fr; gap: 14px; text-align: left; align-items: center; }
  .qr-card .small { margin-top: 0; }
  .qr-card .btn { margin-top: 8px; width: auto; }
  .box-info .actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .box-info .actions .btn { min-width: 0; padding: 0 10px; }
  .box-info .actions .primary { grid-column: 1 / -1; height: 46px; }
}
.panel .btn { white-space: normal; text-align: left; height: auto; min-height: 40px; padding-top: 8px; padding-bottom: 8px; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 0 12px; }
.section-head h2 { display: flex; align-items: center; gap: 8px; }
.count { font-size: 13px; font-weight: 600; color: var(--text-3); }

.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--border); transition: background .12s; }
.list-row:first-child { border-top: 0; }
.list-row:hover { background: var(--surface-2); }
.thumb { width: 48px; height: 48px; border-radius: 10px; flex-shrink: 0; overflow: hidden; display: grid; place-items: center; }
.thumb:not([class*="tint-"]) { background: var(--surface-2); color: var(--text-3); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb i { font-size: 22px; }
.list-row .main { flex: 1; min-width: 0; }
.list-row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .sub { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qty { font-size: 13px; font-weight: 650; padding: 3px 9px; border-radius: 8px; background: var(--surface-2); color: var(--text-2); flex-shrink: 0; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 12px; font-weight: 550; padding: 2px 8px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); }

/* ---------- item detail ---------- */
.item-layout { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 28px; align-items: start; }
.item-layout .photo { border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); aspect-ratio: 1; display: grid; place-items: center; color: var(--text-3); cursor: zoom-in; }
.item-layout .photo img { width: 100%; height: 100%; object-fit: cover; }
.item-layout .photo i { font-size: 64px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 10px 16px; margin-top: 18px; font-size: 14.5px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; }
.where {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-top: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); transition: border-color .15s;
}
.where:hover { border-color: var(--accent); }
@media (max-width: 760px) { .item-layout { grid-template-columns: 1fr; gap: 18px; } .item-layout .photo { aspect-ratio: 4/3; } }

/* ---------- empty ---------- */
.empty { text-align: center; padding: 56px 20px; background: var(--surface); border: 1px dashed var(--border-2); border-radius: var(--radius-lg); }
.empty .icon { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 32px; }
.empty h2 { margin-bottom: 6px; }
.empty p { color: var(--text-2); max-width: 380px; margin: 0 auto 18px; }

/* ---------- sheets / modals ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.42);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade .18s ease-out;
}
.sheet {
  width: 100%; max-width: 540px; max-height: calc(100vh - 40px); overflow: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 22px; box-shadow: var(--shadow-lg);
  animation: pop .22s cubic-bezier(.2,.9,.3,1.2);
}
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 12px; background: var(--bg); }
.sheet-head h2 { font-size: 18px; }
.sheet-body { padding: 4px 18px 18px; }
.sheet-foot { position: sticky; bottom: 0; display: flex; gap: 10px; padding: 12px 18px calc(14px + var(--safe-bottom)); background: var(--bg); border-top: 1px solid var(--border); }
.sheet-foot .btn { flex: 1; height: 46px; }
@media (max-width: 760px) {
  .overlay { align-items: flex-end; padding: 0; }
  .sheet { max-width: none; max-height: calc(100vh - var(--safe-top) - 24px); border-radius: 22px 22px 0 0; animation: slide .28s cubic-bezier(.2,.9,.3,1); }
  .sheet::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--border-2); margin: 8px auto 0; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } }
@keyframes slide { from { transform: translateY(100%); } }

.photo-pick {
  position: relative; display: grid; place-items: center; aspect-ratio: 16 / 9; margin-bottom: 14px;
  border: 1.5px dashed var(--border-2); border-radius: var(--radius); background: var(--surface); color: var(--text-2);
  cursor: pointer; overflow: hidden; text-align: center;
}
.photo-pick:hover { border-color: var(--accent); color: var(--accent); }
.photo-pick i { font-size: 30px; }
.photo-pick img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-pick input { display: none; }
.photo-pick .remove {
  position: absolute; top: 8px; right: 8px; z-index: 2; width: 34px; height: 34px; border-radius: 10px; border: 0;
  background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center; cursor: pointer; font-size: 18px;
}
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.colors label { cursor: pointer; }
.colors input { display: none; }
.colors span { display: block; width: 34px; height: 34px; border-radius: 10px; border: 2px solid transparent; }
.colors input:checked + span { border-color: var(--text); box-shadow: inset 0 0 0 2px var(--bg); }

.lightbox { position: fixed; inset: 0; z-index: 120; background: rgba(0,0,0,.92); display: grid; place-items: center; padding: 20px; animation: fade .15s; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }
.lightbox img.qr { background: #fff; padding: 16px; width: min(80vw, 420px); }

/* ---------- toast ---------- */
#toast-root { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + var(--safe-bottom)); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
@media (max-width: 760px) { #toast-root { bottom: calc(96px + var(--safe-bottom)); } }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 550; font-size: 14px; box-shadow: var(--shadow-lg); animation: pop .2s; display: flex; align-items: center; gap: 8px; }
.toast.error { background: var(--danger); color: #fff; }

/* ---------- login ---------- */
.login-wrap { min-height: calc(100vh - 160px); display: grid; place-items: center; }
.login { width: 100%; max-width: 380px; text-align: center; }
.login .logo { width: 76px; height: 76px; border-radius: 22px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-size: 42px; margin: 0 auto 18px; }
.login h1 { margin-bottom: 6px; }
.login > p { color: var(--text-2); margin-bottom: 28px; }
.login .divider { display: flex; align-items: center; gap: 10px; color: var(--text-3); font-size: 13px; margin: 18px 0; }
.login .divider::before, .login .divider::after { content: ""; flex: 1; height: 1px; background: var(--border-2); }
.login .error { color: var(--danger); font-size: 14px; margin-top: 12px; min-height: 20px; }
body.logged-out .topbar, body.logged-out .tabbar { display: none; }

/* ---------- scanner ---------- */
.scanner { max-width: 520px; margin: 0 auto; }
.scanner-view { position: relative; aspect-ratio: 1; border-radius: 24px; overflow: hidden; background: #111; }
.scanner-view #reader { width: 100%; height: 100%; }
.scanner-view video { width: 100% !important; height: 100% !important; object-fit: cover; }
.scanner-view #reader img, .scanner-view #reader__dashboard, .scanner-view #qr-shaded-region { display: none !important; }
.scanner-frame { position: absolute; inset: 18%; border-radius: 22px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); pointer-events: none; }
.scanner-frame::before, .scanner-frame::after { content: ""; position: absolute; inset: -3px; border-radius: 24px; border: 3px solid #5dcaa5; clip-path: polygon(0 0, 30% 0, 30% 100%, 70% 100%, 70% 0, 100% 0, 100% 30%, 0 30%, 0 70%, 100% 70%, 100% 100%, 0 100%); }
.scanner-msg { position: absolute; left: 0; right: 0; bottom: 18px; text-align: center; color: #fff; font-size: 14px; font-weight: 550; text-shadow: 0 1px 4px rgba(0,0,0,.6); pointer-events: none; }
.scanner-start { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; text-align: center; padding: 20px; }
.scanner-start i { font-size: 48px; display: block; margin-bottom: 10px; }

/* ---------- settings ---------- */
.settings { max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; }
.panel h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.panel h2 i { color: var(--accent); font-size: 22px; }
.panel > p.muted { margin-bottom: 14px; font-size: 14px; }
.panel .list { border-radius: var(--radius); margin-bottom: 12px; }
.ios-steps { margin: 10px 0 0; padding-left: 20px; color: var(--text-2); font-size: 14px; line-height: 1.8; }
.ios-steps i { color: var(--accent); vertical-align: -2px; }

/* ---------- print labels ---------- */
.print-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.print-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-bottom: 20px; }
.print-pick label { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-size: 14px; }
.print-pick input { width: 18px; height: 18px; accent-color: var(--accent); }
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.label-card { display: flex; align-items: center; gap: 12px; padding: 12px; background: #fff; color: #111; border: 1px dashed #bbb; border-radius: 10px; break-inside: avoid; }
.label-card img { width: 100px; height: 100px; flex-shrink: 0; }
.label-card .code { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.label-card .nm { font-size: 15px; font-weight: 650; margin-top: 4px; line-height: 1.25; }
.label-card .lc { font-size: 12px; color: #555; margin-top: 4px; }
.label-card .brand-s { font-size: 10px; color: #888; margin-top: 6px; letter-spacing: .04em; text-transform: uppercase; }

@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff !important; }
  .topbar, .tabbar, .no-print, #toast-root { display: none !important; }
  main { padding: 0 !important; max-width: none; }
  .labels { grid-template-columns: repeat(2, 1fr); gap: 4mm; }
  .label-card { border-radius: 3mm; padding: 4mm; }
  .label-card img { width: 32mm; height: 32mm; }
}

.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border-2); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- users and spaces ---------- */
.avatar {
  display: inline-grid; place-items: center; flex-shrink: 0; border-radius: 50%; object-fit: cover;
  background: var(--accent-soft); color: var(--accent); font-weight: 650;
}
.avatar.pending { background: var(--surface-2); color: var(--text-3); font-size: 18px; }
.badge {
  display: inline-flex; align-items: center; gap: 3px; vertical-align: 2px; margin-left: 4px;
  font-size: 11px; font-weight: 650; padding: 1px 7px; border-radius: 6px; background: var(--c-amber-bg); color: var(--c-amber-fg);
}
.badge i { font-size: 12px; }
.profile { display: flex; align-items: center; gap: 14px; }
.profile .name { font-size: 17px; font-weight: 650; }
.row-btn { width: 100%; border: 0; border-top: 1px solid var(--border); background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.list .row-btn:first-child { border-top: 0; }
.space-switch {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 2px 8px 2px 0; margin-left: 0;
  background: none; border: 0; font: inherit; color: var(--text); cursor: pointer;
  font-size: 26px; font-weight: 650; letter-spacing: -0.01em; line-height: 1.2;
}
.space-switch span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.space-switch i { font-size: 20px; color: var(--text-3); }
.space-switch:hover i { color: var(--accent); }
@media (max-width: 760px) { .space-switch { font-size: 23px; } }
.google-btn { background: #fff; color: #1f1f1f; border-color: #dadce0; gap: 10px; }
.google-btn:hover { background: #f7f8f8; }
@media (prefers-color-scheme: dark) { .google-btn { background: #131314; color: #e3e3e3; border-color: #8e918f; } .google-btn:hover { background: #1f1f20; } }
.link-btn { background: none; border: 0; padding: 6px; font: inherit; font-size: 14px; color: var(--text-2); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.panel form.row input { flex: 1; }
.panel form.row .btn, .sheet form.row .btn { flex-shrink: 0; width: auto; }
.page-head.home-head { flex-wrap: nowrap; align-items: center; }
.home-head .space-switch { min-width: 0; }
.home-head .btn { flex-shrink: 0; }
