:root {
  --brand: #1E8E4E;
  --brand-dark: #156B3A;
  --brand-soft: #E8F4EC;
  --ink: #1B1F24;
  --muted: #66717D;
  --line: #DCE1E6;
  --bg: #F3F5F7;
  --card: #FFFFFF;
  --danger: #B3261E;
  --danger-soft: #FBE9EA;
  --warn-bg: #FFF6E0;
  --warn-ink: #7A5200;
  --info-soft: #E7F0FB;
  --info-ink: #1B5AA6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", "Noto Sans SC", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 10px; }
h3 { font-size: 13px; margin: 14px 0 6px; color: var(--muted); font-weight: 600; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1 1 auto; min-width: 0; }
.hide { display: none !important; }

/* layout */
.shell { display: grid; grid-template-columns: 208px minmax(0, 1fr); min-height: 100vh; }
.side { background: #12261B; color: #D6E6DC; padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 14px; color: #fff; font-weight: 700; font-size: 14px; line-height: 1.25; }
.brand img { width: 34px; height: 34px; object-fit: contain; background: #fff; border-radius: 8px; padding: 3px; flex: none; }
.side nav a { display: flex; align-items: center; gap: 9px; color: #D6E6DC; padding: 8px 10px; border-radius: 8px; margin: 1px 0; }
.side nav a svg { width: 17px; height: 17px; flex: none; }
.side nav a:hover { background: rgba(255, 255, 255, .07); text-decoration: none; }
.side nav a.on { background: var(--brand); color: #fff; }
.side nav .sep { height: 1px; background: rgba(255, 255, 255, .1); margin: 9px 6px; }
.who { margin-top: auto; padding: 10px; font-size: 12px; color: #9DB5A6; border-top: 1px solid rgba(255, 255, 255, .1); }
.who button { background: none; border: 0; color: #CDE3D5; cursor: pointer; padding: 0; font: inherit; text-decoration: underline; margin-right: 10px; }
.main { padding: 18px 22px 70px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.topbar { display: none; }
.tabbar { display: none; }

/* cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 14px; }
.stat .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--muted); }
.actions-big { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.actions-big a { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 8px; text-align: center; color: var(--ink); font-weight: 600; font-size: 15px; border: 1px solid transparent; }
.actions-big a:hover { border-color: var(--brand); text-decoration: none; }
.actions-big svg { width: 26px; height: 26px; color: var(--brand); display: block; margin: 0 auto 6px; }

/* forms */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
input[type=text], input[type=search], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; background: #fff; color: var(--ink); min-height: 38px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(30, 142, 78, .25); border-color: var(--brand); }
.field { margin-bottom: 10px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 12px; }
.fields .wide { grid-column: 1 / -1; }
.hint { font-size: 11px; color: var(--muted); margin-top: 2px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); margin: 0 12px 0 0; cursor: pointer; }
.check input { width: auto; min-height: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 10px; }
.filters > * { flex: 0 1 170px; }
.filters .wide { flex: 1 1 220px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 13px; border-radius: 8px; font: inherit; cursor: pointer; white-space: nowrap; min-height: 38px; }
.btn:hover { border-color: #B9C2CB; text-decoration: none; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 3px 9px; font-size: 12px; min-height: 28px; }
.btn.lg { padding: 11px 18px; font-size: 16px; min-height: 48px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; overflow-x: auto; }

/* tables */
.tw { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 7px 9px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fff; }
table.list th.num { text-align: right; }
table.list td { padding: 7px 9px; border-bottom: 1px solid #EEF1F4; vertical-align: top; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: #FAFBFC; }
.empty { padding: 26px; text-align: center; color: var(--muted); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; background: #EEF1F4; color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--brand-soft); color: var(--brand-dark); }
.badge.red { background: var(--danger-soft); color: #9B1C22; }
.badge.amber { background: var(--warn-bg); color: var(--warn-ink); }
.badge.blue { background: var(--info-soft); color: var(--info-ink); }

/* alerts */
.alert { padding: 8px 12px; border-radius: 8px; margin-bottom: 6px; background: var(--warn-bg); color: var(--warn-ink); font-size: 13px; }
.alert.red { background: var(--danger-soft); color: #8C1D18; }
.alert.ok { background: var(--brand-soft); color: var(--brand-dark); }
.alert.blue { background: var(--info-soft); color: var(--info-ink); }
.alert .d { font-size: 12px; opacity: .85; }

/* scan page */
.scanbar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding-bottom: 8px; }
.scanbox { display: flex; gap: 8px; align-items: stretch; }
.scanbox input { font-size: 18px; min-height: 52px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; border: 2px solid var(--brand); }
.scanbox .btn { min-height: 52px; }
.banner { border-radius: 10px; padding: 12px 14px; margin-top: 8px; background: #fff; box-shadow: var(--shadow); min-height: 62px; }
.banner .big { font-size: 20px; font-weight: 700; line-height: 1.25; }
.banner.ok { background: var(--brand); color: #fff; }
.banner.warn { background: #F2B23A; color: #3A2A00; }
.banner.err { background: var(--danger); color: #fff; }
.banner.queued { background: var(--info-ink); color: #fff; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px; }
.chip button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0; line-height: 1; }
.chip.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); }
.packs { display: inline-flex; align-items: center; gap: 4px; }
.packs input { width: 64px; min-height: 30px; padding: 2px 6px; text-align: center; font-weight: 700; }
.line { padding: 9px 0; border-bottom: 1px solid #EEF1F4; }
.line:last-child { border-bottom: 0; }
.line .t { font-weight: 600; }
.line .q { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.progress { height: 5px; background: #EEF1F4; border-radius: 3px; margin-top: 5px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand); }
.progress > i.over { background: #F2B23A; }
.footer-actions { position: sticky; bottom: 0; background: var(--bg); padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); display: flex; gap: 8px; flex-wrap: wrap; z-index: 4; }
.net { padding: 6px 12px; font-size: 13px; text-align: center; background: var(--info-ink); color: #fff; }
.net.bad { background: var(--danger); }

/* modal + toast */
.modal-back { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 14px; }
.modal { background: #fff; border-radius: 12px; padding: 16px 18px; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }
.modal h2 { font-size: 17px; }
.modal .actions { margin-top: 14px; justify-content: flex-end; }
#toasts { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 6px; width: min(92vw, 460px); }
.toast { background: #12261B; color: #fff; padding: 9px 14px; border-radius: 8px; font-size: 14px; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); }
.toast.err { background: var(--danger); }
.camera video { width: 100%; border-radius: 8px; background: #000; max-height: 56vh; }

.thumb { width: 44px; height: 44px; flex: none; display: block; border-radius: 6px; object-fit: contain; background: #fff; border: 1px solid #EEF1F4; cursor: zoom-in; }
.thumb.big { width: 132px; height: 132px; }
.thumb.none { display: flex; align-items: center; justify-content: center; color: #B8C0CA; background: #F7F8FA; cursor: default; }
.thumb.none svg { width: 20px; height: 20px; }
.thumb.gone { visibility: hidden; }
.sku-cell { display: flex; gap: 10px; align-items: center; }
.sku-pic { flex: none; display: flex; flex-direction: column; gap: 6px; width: 132px; }

/* login */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; background: linear-gradient(160deg, #E8F4EC, #F3F5F7); }
.login .card { width: 100%; max-width: 380px; padding: 24px; }
.login .icp { margin-top: 16px; font-size: 12px; color: #667085; text-decoration: none; }
.login img { width: 64px; display: block; margin: 0 auto 8px; }
.login h1 { text-align: center; margin-bottom: 16px; }

/* mobile */
@media (max-width: 820px) {
  .shell { display: block; }
  .side { display: none; }
  .topbar { display: flex; align-items: center; gap: 10px; background: #12261B; color: #fff; padding: 8px 12px; position: sticky; top: 0; z-index: 10; }
  .topbar img { width: 28px; height: 28px; background: #fff; border-radius: 6px; padding: 2px; }
  .topbar .title { font-weight: 700; flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar button { background: none; border: 1px solid rgba(255, 255, 255, .3); color: #fff; border-radius: 6px; padding: 3px 8px; font: inherit; font-size: 12px; }
  .main { padding: 10px 10px 86px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); z-index: 10; padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { text-align: center; padding: 6px 0 5px; font-size: 11px; color: var(--muted); }
  .tabbar a svg { width: 21px; height: 21px; display: block; margin: 0 auto 1px; }
  .tabbar a.on { color: var(--brand-dark); font-weight: 600; }
  .scanbar { top: 44px; }
  .actions-big { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .actions-big a { padding: 12px 2px; font-size: 13px; }
  .footer-actions { bottom: 52px; flex-wrap: wrap; }
  .footer-actions .btn.lg { padding: 8px 10px; font-size: 14px; min-height: 42px; }
  .card { padding: 11px 12px; }
  .filters > * { flex: 1 1 45%; }
  input, select, textarea { font-size: 16px !important; }
}
