:root {
  --bg: #F6F3EF; --card: #FFFFFF; --ink: #2B2522; --muted: #7A716B; --line: #E7E1D9;
  --brand: #6B3E26; --brand-ink: #FFFFFF; --brand-soft: #F3E9E0; --accent: #C8742F;
  --green: #1E7A3C; --green-soft: #E3F2E7; --red: #B42318; --red-soft: #FBE7E5; --amber: #9A6200; --amber-soft: #FBF0D9;
  --grey-soft: #EFEBE6; --shadow: 0 1px 2px rgba(43,37,34,.06), 0 4px 14px rgba(43,37,34,.06);
  --radius: 14px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171412; --card: #221E1B; --ink: #F1ECE6; --muted: #A89F97; --line: #352F2A;
    --brand: #D9A47E; --brand-ink: #1E1410; --brand-soft: #3A2A20; --accent: #E0995B;
    --green: #6FCF8E; --green-soft: #1D3324; --red: #FF8A7E; --red-soft: #3D1F1C; --amber: #F2C26B; --amber-soft: #3A2E15;
    --grey-soft: #2C2723; --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- layout */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: calc(10px + var(--safe-t)) 16px 8px; }
.top-row { display: flex; align-items: center; gap: 10px; }
.top h1 { font-size: 20px; margin: 0; flex: 1; letter-spacing: -.01em; }
.chip { font-size: 12px; padding: 4px 9px; border-radius: 99px; background: var(--grey-soft); color: var(--muted); white-space: nowrap; }
.chip.old { background: var(--amber-soft); color: var(--amber); }
main { padding: 4px 16px calc(84px + var(--safe-b)); max-width: 720px; margin: 0 auto; }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; background: var(--card);
       border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.nav button { flex: 1; background: none; border: 0; padding: 8px 0 9px; display: flex; flex-direction: column; align-items: center;
              gap: 2px; font-size: 12px; color: var(--muted); }
.nav button svg { width: 24px; height: 24px; }
.nav button.on { color: var(--brand); font-weight: 600; }

/* ---------- search */
.search { display: flex; gap: 8px; margin-top: 8px; }
.search .box { flex: 1; position: relative; }
.search input { width: 100%; height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
                padding: 0 40px 0 42px; font-size: 17px; outline: none; }
.search input:focus { border-color: var(--brand); }
.search .ico { position: absolute; left: 12px; top: 12px; width: 22px; height: 22px; color: var(--muted); }
.search .clear { position: absolute; right: 6px; top: 6px; width: 36px; height: 36px; border: 0; background: none; color: var(--muted); }
.scan { width: 48px; height: 48px; border-radius: 12px; border: 0; background: var(--brand); color: var(--brand-ink);
        display: grid; place-items: center; flex: none; }
.scan svg { width: 24px; height: 24px; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin: 10px 2px 2px; }
.toggle input { width: 18px; height: 18px; accent-color: var(--brand); }

/* ---------- product list */
.list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.prod { display: flex; gap: 12px; padding: 10px; align-items: center; width: 100%; text-align: left; border: 1px solid var(--line); }
.thumb { width: 64px; height: 64px; border-radius: 10px; object-fit: contain; background: #fff; flex: none; border: 1px solid var(--line); }
.thumb.none { display: grid; place-items: center; color: var(--muted); background: var(--grey-soft); }
.prod .info { flex: 1; min-width: 0; }
.prod .name { font-weight: 600; font-size: 15px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.prod .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prod .right { text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.price { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.price s { font-weight: 400; color: var(--muted); font-size: 12.5px; margin-right: 4px; }
.price .promo { color: var(--red); }
.badge { font-size: 12.5px; font-weight: 600; padding: 3px 8px; border-radius: 99px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.no { background: var(--red-soft); color: var(--red); }
.badge.na { background: var(--grey-soft); color: var(--muted); font-weight: 500; }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--grey-soft); color: var(--muted); margin-left: 4px; vertical-align: 1px; }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty svg { width: 48px; height: 48px; opacity: .5; }
.empty b { display: block; color: var(--ink); margin: 8px 0 4px; font-size: 17px; }

/* ---------- detail sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; display: flex; align-items: flex-end; justify-content: center;
            animation: fade .15s ease-out; }
.sheet { background: var(--bg); width: 100%; max-width: 720px; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0;
         padding: 0 0 calc(20px + var(--safe-b)); animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .5 } }
@keyframes fade { from { opacity: 0 } }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto; }
.sheet .close { position: sticky; top: 8px; float: right; margin: 0 10px -44px 0; width: 36px; height: 36px; border-radius: 50%; border: 0;
                background: var(--card); box-shadow: var(--shadow); z-index: 2; }
.hero { background: #fff; display: grid; place-items: center; height: 240px; margin: 0 16px; border-radius: var(--radius); border: 1px solid var(--line); }
.hero img { max-width: 92%; max-height: 220px; object-fit: contain; }
.sheet h2 { font-size: 20px; margin: 14px 16px 2px; line-height: 1.25; }
.sheet .cat { margin: 0 16px; color: var(--muted); font-size: 14px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 16px 0; }
.stat { padding: 12px; }
.stat .k { font-size: 12.5px; color: var(--muted); }
.stat .v { white-space: nowrap; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; line-height: 1.15; }
.stat .v.ok { color: var(--green); } .stat .v.no { color: var(--red); }
.stat .d { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.stat .v s { font-size: 15px; color: var(--muted); font-weight: 400; }
.rows { margin: 12px 16px 0; padding: 4px 14px; }
.rows .r { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.rows .r:last-child { border-bottom: 0; }
.rows .r span:first-child { color: var(--muted); }
.rows .r span:last-child { text-align: right; font-weight: 500; word-break: break-word; }
.admin { margin: 12px 16px 0; border: 1px dashed var(--brand); background: var(--brand-soft); padding: 4px 14px; border-radius: var(--radius); }
.admin .t { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--brand); font-weight: 700; padding-top: 8px; }
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; height: 48px; border-radius: 12px; border: 1px solid var(--line);
       background: var(--card); font-weight: 600; text-decoration: none; color: var(--ink); width: 100%; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.danger { color: var(--red); }
.btn svg { width: 20px; height: 20px; }
.actions { margin: 14px 16px 0; display: grid; gap: 10px; }

/* ---------- scanner */
.scanner { position: fixed; inset: 0; background: #000; z-index: 30; display: flex; flex-direction: column; }
.scanner video { flex: 1; width: 100%; object-fit: cover; }
.scanner .frame { position: absolute; left: 10%; right: 10%; top: 35%; height: 26%; border: 3px solid rgba(255,255,255,.9); border-radius: 16px;
                  box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
.scanner .line { position: absolute; left: 12%; right: 12%; top: 48%; height: 2px; background: #ff5a4a; animation: scan 1.6s ease-in-out infinite; }
@keyframes scan { 50% { transform: translateY(20px) } }
.scanner .bar { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 16px calc(20px + var(--safe-b)); display: flex; flex-direction: column; gap: 10px;
                background: linear-gradient(transparent, rgba(0,0,0,.7)); color: #fff; text-align: center; }
.scanner .bar .btn { background: rgba(255,255,255,.95); color: #222; border: 0; }
.scanner .msg { font-size: 15px; }

/* ---------- forms / login / menu */
.login { max-width: 400px; margin: 0 auto; padding: calc(40px + var(--safe-t)) 20px 20px; }
.login .logo { width: 72px; height: 72px; border-radius: 18px; display: block; margin: 0 auto 14px; }
.login h1 { text-align: center; margin: 0 0 4px; font-size: 24px; }
.login p { text-align: center; margin: 0 0 24px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 5px 2px; }
.field input[type=text], .field input[type=password] { width: 100%; height: 50px; border-radius: 12px; border: 1px solid var(--line);
                    background: var(--card); padding: 0 14px; font-size: 17px; outline: none; }
.field input:focus { border-color: var(--brand); }
.check { display: flex; gap: 10px; align-items: center; margin: 4px 2px 14px; font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }
.err { color: var(--red); font-weight: 600; margin: 0 0 12px; min-height: 1em; }
.menu { padding: 4px 0; }
.menu button, .menu a { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; background: none; border: 0;
                         border-bottom: 1px solid var(--line); text-align: left; font-size: 16px; text-decoration: none; color: var(--ink); }
.menu > :last-child { border-bottom: 0; }
.menu svg { width: 22px; height: 22px; color: var(--muted); flex: none; }
.menu .grow { flex: 1; }
.section { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 20px 4px 8px; font-weight: 600; }
.who { padding: 16px; display: flex; gap: 12px; align-items: center; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; font-size: 18px; }
.token { word-break: break-all; font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--grey-soft); padding: 12px; border-radius: 10px; user-select: all; font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: var(--bg);
         padding: 10px 16px; border-radius: 10px; z-index: 40; font-size: 14px; max-width: 90vw; animation: fade .2s; }
.spin { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: rot .8s linear infinite; margin: 30px auto; }
@keyframes rot { to { transform: rotate(360deg) } }
.soon { padding: 24px 20px; text-align: center; }
.soon svg { width: 44px; height: 44px; color: var(--brand); }
input[type=search]::-webkit-search-cancel-button, input[type=search]::-webkit-search-decoration { -webkit-appearance: none; display: none; }

/* ---------- v1.1: start page categories */
.cats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 10px; }
@media (min-width: 560px) { .cats { grid-template-columns: repeat(3, 1fr); } }
.cat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px 8px 10px;
       text-align: left; display: flex; flex-direction: column; gap: 2px; }
.cimg { aspect-ratio: 1 / 1; background: #fff; border-radius: 10px; display: grid; place-items: center; overflow: hidden; margin-bottom: 6px; color: var(--muted); }
.cimg img { width: 100%; height: 100%; object-fit: contain; }
.cimg svg { width: 36px; height: 36px; }
.cname { font-weight: 600; font-size: 14.5px; line-height: 1.25; }
.ccount { font-size: 12.5px; color: var(--muted); }
.backbar { display: flex; align-items: center; gap: 4px; background: none; border: 0; color: var(--brand); font-weight: 600; padding: 8px 0 2px; }
.backbar svg { width: 20px; height: 20px; }

/* ---------- picking list */
.seg { display: flex; gap: 6px; margin-top: 8px; }
.seg button { flex: 1; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: 14.5px; }
.seg button.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.seg .ref { flex: 0 0 44px; display: grid; place-items: center; }
.seg .ref svg { width: 20px; height: 20px; }
.seg .ref.turn svg { animation: rot .8s linear infinite; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.schip { flex: none; padding: 7px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.schip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }
.pmeta { margin: 6px 2px 4px; }
.progress { height: 6px; border-radius: 3px; background: var(--grey-soft); overflow: hidden; margin-top: 8px; }
.progress div { height: 100%; background: var(--green); transition: width .3s; }
.pk { display: flex; gap: 12px; padding: 10px; width: 100%; text-align: left; align-items: flex-start; }
.pimg { position: relative; width: 76px; height: 76px; border-radius: 12px; background: #fff; border: 1px solid var(--line); flex: none;
        display: grid; place-items: center; color: var(--muted); }
.pimg img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 12px; }
.pimg .tick { position: absolute; inset: 0; border-radius: 12px; background: rgba(30,122,60,.82); color: #fff; display: none; place-items: center; }
.pimg .tick svg { width: 38px; height: 38px; stroke-width: 3; }
.pk.ck { opacity: .62; }
.pk.ck .tick { display: grid; }
.pk.ck .name { text-decoration: line-through; }
.pk .info { flex: 1; min-width: 0; }
.pk .name { font-weight: 600; font-size: 15px; line-height: 1.25; }
.pk .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.parts { font-size: 12.5px; color: var(--muted); margin-top: 4px; line-height: 1.35; }
.warn { font-size: 12.5px; color: var(--red); font-weight: 600; margin-top: 4px; }
.olinks { margin-top: 5px; font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 4px 8px; }
.olinks a, .rows a { color: var(--brand); text-decoration: none; font-weight: 600; }
.pk .qty { flex: none; text-align: center; min-width: 56px; }
.pk .qty span { display: block; font-size: 11.5px; color: var(--muted); }
.pk .qty b { display: block; font-size: 28px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.red { color: var(--red) !important; }
.section.red { margin-top: 22px; }
.ord { padding: 12px 14px; margin-top: 10px; }
.ord.done { border-color: var(--green); }
.ohead { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 6px; }
.onum { font-weight: 700; font-size: 17px; text-decoration: none; color: var(--brand); }
.obtn { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: 14px; color: var(--muted); }
.obtn svg { width: 18px; height: 18px; }
.obtn.on { background: var(--green); border-color: var(--green); color: #fff; }
.oit { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14.5px; }
.oit img, .oit .noimg, .crow img, .crow .noimg { width: 40px; height: 40px; border-radius: 8px; object-fit: contain; background: #fff; border: 1px solid var(--line); flex: none; }
.noimg { display: grid; place-items: center; color: var(--muted); background: var(--grey-soft) !important; }
.noimg svg { width: 20px; height: 20px; }
.oit.ck span, .oit.ck b { text-decoration: line-through; color: var(--muted); }
.grow { flex: 1; min-width: 0; }

/* ---------- profit */
.dates { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.dates input { flex: 1; height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); padding: 0 10px; font-size: 15px; }
.total { padding: 14px 16px; margin-top: 6px; }
.total .k { font-size: 13px; color: var(--muted); }
.total .big { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 2px 0 10px; color: var(--green); }
.tgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tgrid span { display: block; font-size: 12px; color: var(--muted); }
.tgrid b { font-variant-numeric: tabular-nums; font-size: 14.5px; }
.obj { padding: 12px 14px; margin-top: 10px; }
.oprof { text-align: right; font-weight: 700; font-size: 18px; color: var(--green); font-variant-numeric: tabular-nums; white-space: nowrap; }
.oprof span { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.bar { height: 6px; border-radius: 3px; background: var(--grey-soft); margin: 4px 0 10px; overflow: hidden; }
.bar div { height: 100%; background: var(--brand); }

/* ---------- settings lists */
.crow { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 15px; }
.crow:last-child { border-bottom: 0; }
.crow input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--brand); flex: none; }
.ib { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; flex: none; padding: 0; }
.ib svg { width: 18px; height: 18px; }
.ib:disabled { opacity: .35; }

.clist { padding: 2px 0; }
.cimg, .thumb, .pimg, .hero { position: relative; }
