:root {
  --bg: #f3f6f5;
  --card: #ffffff;
  --card-2: #f8faf9;
  --text: #17211f;
  --muted: #6b7773;
  --line: #e4eae7;
  --primary: #0f766e;
  --primary-2: #0b5f59;
  --primary-soft: #e3f3ef;
  --amber: #b45309;
  --amber-soft: #fdf3e3;
  --danger: #b91c1c;
  --danger-soft: #fdecec;
  --blue: #0369a1;
  --blue-soft: #e8f3fb;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 1px 2px rgba(16, 40, 34, .05), 0 8px 24px rgba(16, 40, 34, .06);
  --nav-h: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { height: 100%; }
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4, p { margin: 0; }

/* ---------- boot ---------- */
.boot-screen {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; padding: 24px;
}
.boot-logo { font-size: 46px; }
.boot-title { font-size: 20px; font-weight: 700; }
.boot-sub { color: var(--muted); font-size: 13px; }

/* ---------- shell ---------- */
.shell { min-height: 100dvh; }
.app-header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  height: 58px; padding: 0 14px;
  padding-top: env(safe-area-inset-top);
  background: rgba(243, 246, 245, .9);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(228, 234, 231, .7);
}
.app-title { font-size: 18px; font-weight: 700; letter-spacing: .2px; flex: 1; }
.app-title small { font-weight: 500; color: var(--muted); font-size: 12px; margin-left: 6px; }
.header-actions { display: flex; gap: 6px; align-items: center; }
.main { padding: 14px 14px calc(var(--nav-h) + 26px + env(safe-area-inset-bottom)); max-width: 1120px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 10px; margin: 2px 0 14px; }
.page-head h1 { font-size: 22px; font-weight: 800; letter-spacing: -.2px; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.page-head .grow { flex: 1; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: 100%; color: var(--muted); font-size: 11px; border: 0; background: none; cursor: pointer;
  padding: 0; text-decoration: none;
}
.nav-item.active { color: var(--primary); font-weight: 700; }
.nav-item svg { width: 23px; height: 23px; }
.nav-scan {
  align-self: center; justify-self: center; width: 58px; height: 58px; border-radius: 50%;
  background: linear-gradient(145deg, #14b8a6, #0f766e); color: #fff;
  display: flex; align-items: center; justify-content: center; margin-top: -22px;
  box-shadow: 0 8px 20px rgba(15, 118, 110, .35); border: 4px solid var(--bg);
}
.nav-scan svg { width: 27px; height: 27px; }

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 236px 1fr; }
  .app-header { display: flex; }
  .bottom-nav { display: none; }
  .main { padding: 26px 34px 60px; margin: 0; max-width: 1180px; }
  .sidebar {
    position: sticky; top: 0; height: 100dvh; padding: 22px 16px;
    background: var(--card); border-right: 1px solid var(--line);
    display: flex; flex-direction: column; gap: 6px;
  }
  .side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 800; font-size: 17px; }
  .side-brand span.logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); }
  .side-item {
    display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: 11px;
    color: var(--muted); font-weight: 600; font-size: 14px; border: 0; background: none; cursor: pointer; width: 100%; text-align: left;
  }
  .side-item svg { width: 20px; height: 20px; }
  .side-item.active { background: var(--primary-soft); color: var(--primary-2); }
  .side-item:hover { background: var(--card-2); }
  .side-foot { margin-top: auto; padding: 12px; color: var(--muted); font-size: 12px; }
}
@media (max-width: 959px) {
  .sidebar { display: none; }
}

/* ---------- cards & grids ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }
.card-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-title .more { font-size: 13px; color: var(--primary); font-weight: 600; cursor: pointer; background: none; border: 0; }
.section { margin-top: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 0 2px 9px; }
.section-head h2 { font-size: 15px; font-weight: 800; }
.section-head .link { border: 0; background: none; color: var(--primary); font-size: 13px; cursor: pointer; padding: 4px; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 14px; box-shadow: var(--shadow); min-width: 0;
}
.stat .label { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 5px; }
.stat .value { font-size: 21px; font-weight: 800; margin-top: 3px; letter-spacing: -.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .foot { color: var(--muted); font-size: 11px; margin-top: 2px; }
.stat.warn .value { color: var(--amber); }
.stat.danger .value { color: var(--danger); }
.stat.primary .value { color: var(--primary-2); }

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-weight: 650; font-size: 14px;
  cursor: pointer; transition: transform .06s ease, background .15s ease; user-select: none;
}
.btn:active { transform: scale(.985); }
.btn svg { width: 19px; height: 19px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); }
.btn-soft { background: var(--primary-soft); border-color: transparent; color: var(--primary-2); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--card-2); color: var(--text); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 11px; border: 1px solid transparent;
  background: transparent; display: inline-grid; place-items: center; cursor: pointer; color: var(--text);
}
.icon-btn:hover { background: rgba(0, 0, 0, .05); }
.icon-btn svg { width: 21px; height: 21px; }
.btn-row { display: flex; gap: 9px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1; min-width: 110px; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); font-weight: 650; margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 11px 13px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--card); outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 118, 110, .12); }
textarea.input { min-height: 78px; resize: vertical; }
.input-row { display: flex; gap: 9px; }
.input-row > * { min-width: 0; }
.input-row .input { flex: 1; }
.field-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
@media (max-width: 420px) { .field-3 { grid-template-columns: 1fr 1fr; } }
.field-3.shelf { grid-template-columns: repeat(3, 1fr); }
.affix { position: relative; flex: 1; }
.affix .input { padding-left: 30px; }
.affix .affix-text { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; }
.checkline { display: flex; align-items: center; gap: 9px; font-size: 14px; }
.checkline input { width: 18px; height: 18px; accent-color: var(--primary); }

/* ---------- chips & badges ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--primary-2); border-color: var(--primary-2); color: #fff; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; line-height: 1.7; white-space: nowrap;
}
.badge.ok { background: var(--primary-soft); color: var(--primary-2); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.muted { background: #eef1f0; color: var(--muted); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }

/* ---------- search ---------- */
.searchbar { position: relative; margin-bottom: 10px; }
.searchbar svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 19px; height: 19px; color: var(--muted); }
.searchbar input {
  width: 100%; height: 48px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--card); padding: 0 44px 0 40px; font-size: 15px; outline: none; box-shadow: var(--shadow);
}
.searchbar input:focus { border-color: var(--primary); }
.searchbar .scan-inline {
  position: absolute; right: 6px; top: 6px; width: 36px; height: 36px; border: 0; border-radius: 10px;
  background: var(--primary-soft); color: var(--primary-2); display: grid; place-items: center; cursor: pointer;
}

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; gap: 9px; }
.list-item {
  display: flex; align-items: center; gap: 11px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 11px 12px; box-shadow: var(--shadow); cursor: pointer; min-width: 0;
}
.list-item:active { transform: scale(.995); }
.thumb {
  width: 50px; height: 50px; border-radius: 12px; background: var(--card-2); flex: 0 0 auto;
  display: grid; place-items: center; color: var(--muted); overflow: hidden; font-size: 19px;
  border: 1px solid var(--line);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.list-main { flex: 1; min-width: 0; }
.list-title { font-weight: 700; font-size: 14.5px; display: flex; align-items: center; gap: 6px; }
.list-title .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-sub { color: var(--muted); font-size: 12px; margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px 9px; }
.list-end { text-align: right; flex: 0 0 auto; }
.list-end .qty { font-weight: 800; font-size: 16px; }
.list-end .qty small { font-size: 11px; color: var(--muted); font-weight: 600; margin-left: 2px; }
.list-end .price { color: var(--muted); font-size: 12px; }
.list-item .chev { color: #b9c2bf; flex: 0 0 auto; display: inline-flex; align-items: center; }
.list-item .chev svg { width: 18px; height: 18px; }

/* ---------- product row extras ---------- */
.expiry-line { display: flex; align-items: center; gap: 6px; margin-top: 5px; flex-wrap: wrap; }
.progress { height: 5px; border-radius: 999px; background: #eef1f0; overflow: hidden; margin-top: 6px; }
.progress > i { display: block; height: 100%; border-radius: 999px; background: var(--primary); }

/* ---------- batch ---------- */
.batch-list { display: flex; flex-direction: column; gap: 8px; }
.batch {
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--card-2);
  display: flex; align-items: center; gap: 10px;
}
.batch .b-main { flex: 1; min-width: 0; }
.batch .b-title { font-size: 13px; font-weight: 650; display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.batch .b-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.batch .b-qty { font-weight: 800; font-size: 15px; text-align: right; }
.batch.expired { border-color: #f3cccc; background: #fff8f8; }

/* ---------- detail ---------- */
.detail-hero { display: flex; gap: 13px; align-items: flex-start; }
.detail-hero .thumb { width: 78px; height: 78px; border-radius: 15px; font-size: 26px; }
.detail-name { font-size: 20px; font-weight: 800; line-height: 1.3; }
.detail-meta { color: var(--muted); font-size: 12.5px; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.price-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 13px; }
.price-row.four { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 700px) { .price-row.four { grid-template-columns: repeat(4, 1fr); } }
.price-box { background: var(--card-2); border-radius: 12px; padding: 9px 11px; }
.price-box .k { color: var(--muted); font-size: 11.5px; }
.price-box .v { font-weight: 800; font-size: 16px; margin-top: 1px; }
.action-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin-top: 13px; }
.action-grid .btn { flex-direction: column; gap: 3px; min-height: 64px; font-size: 12.5px; padding: 8px; }
.action-grid .btn svg { width: 21px; height: 21px; }
@media (min-width: 700px) { .action-grid { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); } }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(12, 24, 21, .45);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .16s ease;
  padding: 0; backdrop-filter: blur(2px);
}
.modal {
  background: var(--card); width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto;
  border-radius: 22px 22px 0 0; box-shadow: 0 -8px 40px rgba(0,0,0,.18);
  animation: sheet .22s cubic-bezier(.2,.8,.2,1); padding-bottom: env(safe-area-inset-bottom);
}
.modal-head { display: flex; align-items: center; gap: 8px; padding: 15px 16px 10px; position: sticky; top: 0; background: var(--card); z-index: 2; }
.modal-head h3 { flex: 1; font-size: 16.5px; font-weight: 800; }
.modal-body { padding: 4px 16px 16px; }
.modal-foot { display: flex; gap: 9px; padding: 10px 16px 16px; position: sticky; bottom: 0; background: linear-gradient(180deg, rgba(255,255,255,0), var(--card) 30%); }
.modal-foot .btn { flex: 1; }
@media (min-width: 680px) {
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal { border-radius: 20px; animation: pop .18s ease; }
}
@keyframes sheet { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes pop { from { transform: scale(.97); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- toast ---------- */
#toast-root { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + 22px + env(safe-area-inset-bottom)); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
@media (min-width: 960px) { #toast-root { bottom: 28px; } }
.toast {
  background: #1d2a26; color: #fff; border-radius: 12px; padding: 10px 15px; font-size: 13.5px;
  box-shadow: 0 8px 26px rgba(0,0,0,.22); max-width: 460px; animation: toast-in .2s ease; pointer-events: none;
}
.toast.error { background: #8f1d1d; }
.toast.success { background: #0b5f59; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- empty / misc ---------- */
.empty { text-align: center; color: var(--muted); padding: 38px 18px; }
.empty .icon { font-size: 34px; margin-bottom: 8px; opacity: .8; }
.empty h3 { color: var(--text); font-size: 15px; margin-bottom: 4px; }
.empty p { font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.center { text-align: center; }
.right { text-align: right; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.hide { display: none !important; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 13.5px; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 650; text-align: right; }

.alert-banner {
  display: flex; align-items: flex-start; gap: 10px; background: var(--amber-soft); border: 1px solid #f3dfc0;
  border-radius: var(--radius); padding: 11px 13px; font-size: 13px; color: #7a4708; margin-bottom: 12px;
}
.alert-banner.info { background: var(--blue-soft); border-color: #cde6f7; color: #0b4f77; }
.alert-banner .grow { flex: 1; }
.alert-banner strong { display: block; margin-bottom: 1px; }

.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.quick {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 13px 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; cursor: pointer;
  font-size: 12px; color: var(--text); font-weight: 600; box-shadow: var(--shadow);
}
.quick .qi { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-2); }
.quick .qi svg { width: 21px; height: 21px; }

/* ---------- charts ---------- */
.chart-box { width: 100%; overflow: hidden; }
.chart-box svg { width: 100%; height: auto; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend .lg { display: flex; align-items: center; gap: 5px; }
.legend .dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

/* ---------- scanner ---------- */
.scan-wrap { position: relative; background: #0b1512; border-radius: var(--radius); overflow: hidden; aspect-ratio: 3 / 4; max-height: 62dvh; }
.scan-wrap video { width: 100%; height: 100%; object-fit: cover; }
.scan-wrap #scan-reader { width: 100%; height: 100%; }
.scan-frame { position: absolute; inset: 0; pointer-events: none; display: grid; place-items: center; }
.scan-frame .box { width: 76%; height: 34%; border-radius: 14px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.32); position: relative; }
.scan-frame .box::before, .scan-frame .box::after, .scan-frame .box i::before, .scan-frame .box i::after {
  content: ""; position: absolute; width: 22px; height: 22px; border-color: #5eead4; border-style: solid;
}
.scan-frame .box::before { left: -2px; top: -2px; border-width: 3px 0 0 3px; border-radius: 6px 0 0 0; }
.scan-frame .box::after { right: -2px; top: -2px; border-width: 3px 3px 0 0; border-radius: 0 6px 0 0; }
.scan-frame .box i::before { left: -2px; bottom: -2px; border-width: 0 0 3px 3px; border-radius: 0 0 0 6px; }
.scan-frame .box i::after { right: -2px; bottom: -2px; border-width: 0 3px 3px 0; border-radius: 0 0 6px 0; }
.scan-top { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 8px; z-index: 3; }
.scan-top .icon-btn { background: rgba(0,0,0,.42); color: #fff; backdrop-filter: blur(6px); }
.scan-hint { position: absolute; bottom: 12px; left: 12px; right: 12px; text-align: center; color: #fff; font-size: 12.5px; text-shadow: 0 1px 3px rgba(0,0,0,.6); z-index: 3; }
.scan-actions { display: flex; gap: 9px; margin-top: 12px; }
.scan-actions .btn { flex: 1; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.switch input { appearance: none; width: 42px; height: 25px; border-radius: 999px; background: #d7dedb; position: relative; transition: background .18s; cursor: pointer; }
.switch input::after { content: ""; position: absolute; width: 19px; height: 19px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(17px); }

/* ---------- store open/close ---------- */
.store-status-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.store-status-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.status-dot.open { background: #16a34a; box-shadow: 0 0 0 4px rgba(22, 163, 74, .14); }
.status-dot.closed { background: #94a3b8; box-shadow: 0 0 0 4px rgba(148, 163, 184, .16); }
.store-status-actions { display: flex; gap: 7px; flex: 0 0 auto; }
.day-report {
  white-space: pre-wrap; font-size: 12px; line-height: 1.65; max-height: 260px; overflow: auto;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  margin: 12px 0 0; font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

/* ---------- sales ---------- */
.quick-sale-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 700px) { .quick-sale-grid { grid-template-columns: repeat(4, 1fr); } }
.quick-sale {
  display: flex; flex-direction: column; gap: 3px; align-items: flex-start; text-align: left;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  cursor: pointer; box-shadow: var(--shadow); min-width: 0;
}
.quick-sale .qs-name { font-weight: 700; font-size: 13.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-sale .qs-meta { color: var(--muted); font-size: 11.5px; }
.sale-result {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 11px; margin-bottom: 7px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card); cursor: pointer; box-shadow: var(--shadow);
}
.sale-result .list-sub { display: block; margin-top: 1px; }
.cart-list { display: flex; flex-direction: column; gap: 8px; }
.cart-line {
  display: flex; gap: 8px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 11px 12px; box-shadow: var(--shadow);
}
.cart-main { flex: 1; min-width: 0; }
.cart-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: 0 0 auto; }
.cart-controls { display: flex; align-items: center; gap: 9px; margin-top: 8px; flex-wrap: wrap; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.stepper button { width: 32px; height: 32px; border: 0; background: var(--card-2); font-size: 17px; cursor: pointer; color: var(--text); }
.stepper span { min-width: 34px; text-align: center; font-weight: 700; font-size: 14px; }
.price-edit { display: inline-flex; align-items: center; gap: 2px; border-bottom: 1px dashed var(--line); padding: 2px 0; }
.price-edit span { color: var(--muted); font-size: 12px; }
.price-edit input { width: 74px; border: 0; background: transparent; font-weight: 700; font-size: 15px; text-align: right; outline: none; padding: 2px; }
.price-edit input:focus { background: var(--primary-soft); border-radius: 4px; }
.cart-total { margin-left: auto; font-weight: 800; font-size: 15px; }
.sale-payment { margin-top: 14px; }
.sale-actions { display: flex; gap: 8px; margin-top: 12px; }
.sale-actions .btn { flex: 1; font-size: 13px; padding: 9px 8px; }
.sale-actions .btn svg { width: 17px; height: 17px; }
.sale-sticky {
  position: fixed; left: 0; right: 0; z-index: 35;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: rgba(255, 255, 255, .97);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 18px rgba(16, 40, 34, .06);
}
.sale-sticky-total { flex: 1; display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.sale-sticky-total strong { font-size: 20px; color: var(--primary-2); letter-spacing: -.3px; }
.sale-sticky .btn { min-width: 128px; }
.sale-sticky-space { height: 82px; }
@media (min-width: 960px) {
  .sale-sticky { position: static; background: transparent; border: 0; box-shadow: none; padding: 12px 0 0; backdrop-filter: none; }
  .sale-sticky-space { display: none; }
}
@media (max-width: 380px) {
  .cart-controls { gap: 6px; }
  .price-edit input { width: 62px; }
}

/* ---------- category color dot ---------- */
.cat-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }

/* ---------- sync ---------- */
.sync-steps { counter-reset: step; padding: 0; margin: 0; list-style: none; }
.sync-steps li { position: relative; padding: 0 0 14px 32px; font-size: 13px; color: var(--muted); }
.sync-steps li::before { counter-increment: step; content: counter(step); position: absolute; left: 0; top: 0; width: 21px; height: 21px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-2); font-size: 11px; font-weight: 800; display: grid; place-items: center; }
.sync-steps li strong { color: var(--text); }
.sync-steps li + li::after { content: ""; position: absolute; left: 10px; top: 23px; bottom: 4px; width: 1px; background: var(--line); }

/* ---------- onboarding ---------- */
.onboard { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(circle at 50% 0%, #e3f3ef, transparent 55%), var(--bg); }
.onboard-card { width: 100%; max-width: 430px; }
.onboard-logo { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; background: var(--primary); color: #fff; font-size: 30px; margin-bottom: 14px; box-shadow: 0 10px 26px rgba(15,118,110,.3); }
.onboard h1 { font-size: 23px; font-weight: 800; }
.onboard p.lead { color: var(--muted); font-size: 13.5px; margin: 5px 0 18px; }

/* ---------- desk tables ---------- */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 680px; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { color: var(--muted); font-size: 12px; font-weight: 700; background: var(--card-2); position: sticky; top: 0; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.clickable { cursor: pointer; }
table.data tr:hover td { background: #fafcfb; }
.mobile-only { display: block; }
@media (min-width: 760px) { .mobile-only { display: none; } }
.desktop-only { display: none; }
@media (min-width: 760px) { .desktop-only { display: block; } }

/* ---------- safe area ---------- */
@supports (padding: max(0px)) {
  .app-header { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  .main { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* v3：批次点击、日期年月日下拉、规格数字+单位 */
.date-ymd { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 6px; }
.date-ymd .input { padding-left: 8px; padding-right: 20px; min-width: 0; }
.input-group { display: flex; gap: 6px; align-items: center; }
.input-group .input:first-child { flex: 0 0 42%; }
.batch { cursor: pointer; }
.batch:active { background: var(--surface-2, #f4f7f5); }
.batch .b-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.batch .b-total { font-weight: 700; color: var(--primary-2); }
.filter-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--primary); color: #fff; font-size: 10px; }
.icon-btn:disabled { opacity: .32; cursor: not-allowed; }
.icon-btn:disabled:hover { background: transparent; }
.input-group .input { width: auto; flex: 1 1 0; min-width: 0; }
.input-group .input:first-child { flex: 0 0 42%; }
.undo-btn { width: auto; min-width: 40px; display: inline-flex; gap: 6px; padding: 0 9px; }
.undo-label { display: none; font-size: 12px; font-weight: 700; white-space: nowrap; }
@media (min-width: 960px) { .undo-label { display: inline; } }

/* v3 多销售单 */
.sale-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 0 2px 10px; }
.sale-head-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.sale-orders-card { padding-bottom: 4px; }
.order-list { display: flex; flex-direction: column; }
.order-row { width: 100%; text-align: left; background: transparent; border-radius: 10px; }
.order-row.selected { background: var(--primary-soft); }
.order-row .chev { flex: 0 0 auto; }
.sale-order-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; }
.sale-order-head .badge { margin-right: 6px; }
.sale-detail .kv { padding: 7px 0; }
@media (max-width: 420px) {
  .sale-head-actions .btn { padding-left: 8px; padding-right: 8px; }
}

/* 通用卡片折叠 */
.card-title, .section-head { position: relative; }
.card-toggle { margin-left: auto; border: 0; background: transparent; color: var(--muted); font-size: 15px; padding: 2px 4px; cursor: pointer; line-height: 1; }
.card.collapsed > :not(.card-title), .section.collapsed > :not(.section-head) { display: none !important; }
.card-title .badge { margin-left: 6px; }

/* 开门事件栏与草稿删除 */
.issue-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 0 8px; border-bottom: 1px solid var(--line); }
.issue-toolbar .checkline { margin: 0; }
.issue-row { cursor: default; }
.issue-check { width: 18px; height: 18px; flex: 0 0 18px; }
.order-row { cursor: pointer; }
.order-row:active { opacity: .85; }
.order-del { color: var(--danger); flex: 0 0 auto; }
