:root {
  --brand: #0f766e;
  --brand-dark: #0b5a54;
  --brand-soft: #e6f4f2;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warn: #d97706;
  --warn-soft: #fef3e2;
  --ok: #15803d;
  --ok-soft: #e8f7ee;
  --info: #1d4ed8;
  --info-soft: #e8eefc;
  --ink: #16211f;
  --ink-2: #5b6b68;
  --ink-3: #8c9a97;
  --line: #e2e8e7;
  --bg: #f4f6f6;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 40, 38, .05), 0 6px 18px -12px rgba(16, 40, 38, .18);
  --tap: 46px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--ink);
  font-size: 16px; line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; }

/* ── 布局 ── */
.app { max-width: 720px; margin: 0 auto; padding-bottom: 24px; }
.app.has-tabbar { padding-bottom: 84px; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--brand); color: #fff;
  padding: 10px 14px; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 2px 10px -6px rgba(0,0,0,.5);
}
.topbar .title { font-size: 17px; font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .sub { font-size: 12px; opacity: .85; font-weight: 400; }
.topbar a, .topbar button.link {
  color: #fff; background: rgba(255,255,255,.16); border: 0; border-radius: 9px;
  padding: 7px 11px; font-size: 13px; font-family: inherit; cursor: pointer;
}
.page { padding: 12px 12px 0; }
.section-title { font-size: 13px; color: var(--ink-2); font-weight: 600; margin: 16px 2px 8px; display: flex; align-items: center; gap: 8px; }
.section-title .count { color: var(--ink-3); font-weight: 500; }

/* ── 卡片 ── */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 10px; }
.card.tight { padding: 10px 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.muted { color: var(--ink-2); font-size: 13px; }
.tiny { font-size: 12px; color: var(--ink-3); }
.mono { font-variant-numeric: tabular-nums; }

/* ── 按钮 ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 16px; border-radius: 11px; border: 1px solid transparent;
  background: var(--brand); color: #fff; font-size: 16px; font-weight: 600;
  font-family: inherit; cursor: pointer; width: 100%;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; }
.btn.ghost { background: #fff; color: var(--brand); border-color: var(--line); }
.btn.soft { background: var(--brand-soft); color: var(--brand-dark); }
.btn.danger { background: var(--danger); }
.btn.danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn.ok { background: var(--ok); }
.btn.warn { background: var(--warn); }
.btn.sm { min-height: 38px; font-size: 14px; padding: 0 12px; border-radius: 9px; width: auto; }
.btn-row { display: flex; gap: 8px; }
.btn-row > .btn { flex: 1; }
/* 点货单明细行「🗑 删除」：警示色 + 触控区 ≥44px（与「保存」各占半宽，防误触） */
.btn.danger-soft.del { min-height: 44px; }
/* 门店「我的点货单」卡片上的「✏️ 修改 / 🗑 删除」：并排各占半宽 + 触控区 ≥44px（防误触） */
.item .acts { display: flex; gap: 8px; margin-top: 8px; }
.item .acts > .btn { flex: 1; min-height: 44px; }

/* ── 表单 ── */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 5px; font-weight: 600; }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; font-size: 16px; font-family: inherit;
  color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 11px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { min-height: 76px; resize: vertical; }
input[type=number] { font-variant-numeric: tabular-nums; }
.inline { display: flex; gap: 8px; align-items: center; }
.qty { width: 74px; text-align: center; }

/* ── 徽标 ── */
.chip {
  display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--info-soft); color: var(--info); white-space: nowrap;
}
.chip.open { background: #eef1f1; color: var(--ink-2); }
.chip.picking { background: var(--warn-soft); color: var(--warn); }
.chip.send { background: var(--info-soft); color: var(--info); }
.chip.received { background: var(--ok-soft); color: var(--ok); }
.chip.abnormal, .chip.short { background: var(--danger-soft); color: var(--danger); }
.chip.submitted { background: var(--ok-soft); color: var(--ok); }
.chip.late { background: #f3e8ff; color: #7c3aed; }
.chip.loc { background: #eef1f1; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ── 列表 ── */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  background: var(--card); border-radius: 12px; padding: 12px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px;
}
.item .line1 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.item .name { font-weight: 650; font-size: 15.5px; }
.item .meta { font-size: 12.5px; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.item.clickable:active { background: #fafcfc; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }

/* ── 拣货行 ── */
.pick-row { background: var(--card); border-radius: 12px; padding: 12px; box-shadow: var(--shadow); border-left: 4px solid var(--line); }
.pick-row.picked { border-left-color: var(--ok); background: #fbfefc; }
.pick-row.shortage { border-left-color: var(--danger); background: #fffbfb; }
.pick-row .head { display: flex; align-items: baseline; gap: 8px; justify-content: space-between; }
.pick-row .nm { font-weight: 650; font-size: 16px; }
.pick-row .spec { font-size: 13px; color: var(--ink-2); }
.pick-row .facts { font-size: 13px; color: var(--ink-2); margin-top: 5px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.pick-row .acts { display: flex; gap: 8px; margin-top: 10px; }
.pick-row .acts .btn { flex: 1; }
.grp-head {
  position: sticky; top: 54px; z-index: 20; background: var(--bg);
  padding: 10px 2px 6px; font-weight: 700; font-size: 14px; color: var(--brand-dark);
  display: flex; justify-content: space-between; align-items: center;
}

/* ── 底部导航 ── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: rgba(255,255,255,.97); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); display: flex; padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; text-align: center; padding: 8px 2px 9px; color: var(--ink-3); font-size: 11.5px; font-weight: 600;
}
.tabbar a .ic { display: block; font-size: 19px; line-height: 1.25; }
.tabbar a.active { color: var(--brand); }

/* ── 弹层 ── */
.sheet-mask { position: fixed; inset: 0; background: rgba(12,26,24,.45); z-index: 50; display: none; }
.sheet-mask.on { display: block; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; background: #fff;
  border-radius: 18px 18px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
  max-height: 86vh; overflow-y: auto; display: none;
}
.sheet.on { display: block; }
.sheet h3 { font-size: 16px; margin-bottom: 10px; }

/* ── 商品选择器（打开即全量 + 库存） ── */
#pickerSheet { display: none; flex-direction: column; max-height: 86vh; overflow: hidden; }
#pickerSheet.on { display: flex; }
#pickerSheet h3 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
#pickerSheet .pk-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; margin-top: 10px; }
#pickerSheet .pk-row { min-height: 44px; padding: 11px 12px; cursor: pointer; }
#pickerSheet .pk-row:active { background: var(--brand-soft); }
#pickerSheet .pk-row .line1 { flex-wrap: wrap; }
#pickerSheet .pk-row .name { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
#pickerSheet .pk-foot { padding-top: 8px; text-align: center; font-size: 12.5px; color: var(--ink-3); }
#pickerSheet .pk-foot .btn { width: 100%; }
/* 「☑ 只显示有货（available stock）」：整行可点、触控区 ≥44px，勾中时描边变品牌色 */
#pickerSheet .pk-filter {
  display: flex; align-items: center; gap: 8px; min-height: 44px; margin-top: 8px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-size: 14px; color: var(--ink-2);
}
#pickerSheet .pk-filter:has(input:checked) { border-color: var(--brand); color: var(--ink); background: var(--brand-soft); }
#pickerSheet .pk-filter input { width: 20px; height: 20px; margin: 0; accent-color: var(--brand); }
/* 「本单已有」置顶块（勾了只显示有货时，已加入本单的行即使 0-0 也照显示） */
#pickerSheet .pk-pinned { margin-bottom: 8px; }
#pickerSheet .pk-pinned .pk-pin-head { padding: 2px 2px 6px; color: var(--ink-3); }
#pickerSheet .pk-pinned .pk-row { border: 1px dashed var(--line); border-radius: 10px; }
/* 选择器行内操作（仅仓库登录渲染）：✏️ 改库存 / 🗑 删除，触控区 ≥44px，不挤压上方信息 */
#pickerSheet .pk-acts { display: flex; gap: 8px; margin-top: 8px; }
/* 行内动作区：宽屏「点箱/点个/＋加入」与「✏️改库存/🗑删除」同一行（按钮靠右）；
   手机竖屏 375px 放不下时整体换行到下一行、按钮仍靠右，绝不重叠、不压字 */
#pickerSheet .pk-ops { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#pickerSheet .pk-ops > .pk-qty { order: 1; flex: 1 1 260px; }
#pickerSheet .pk-ops > .pk-acts { order: 2; flex: 0 0 auto; margin-left: auto; }
#pickerSheet .pk-ops > .pk-acts .btn { min-width: 104px; }
#pickerSheet .pk-acts .btn { flex: 1; min-height: 44px; }
/* 弹窗行内填数（点货单调起时渲染）：点箱 / 点个 + ＋加入 / 🗑删除
   一行放得下：手机竖屏 375px 不横向溢出；输入框与按钮触控区均 ≥44px */
#pickerSheet .pk-qty { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: nowrap; }
#pickerSheet .pk-qty .tiny { flex: 0 0 auto; }
#pickerSheet .pk-qty .qty { width: 56px; min-height: 44px; padding: 0 4px; flex: 0 0 auto; }
#pickerSheet .pk-qty .btn { flex: 1 1 auto; min-width: 0; min-height: 44px; padding: 0 10px; white-space: nowrap; }
.chip.added { background: var(--ok-soft); color: var(--ok); }
.chip.off { background: #eef1f1; color: var(--ink-3); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 96px; z-index: 90;
  background: #16211f; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px;
  max-width: 88vw; text-align: center; opacity: 0; transition: opacity .18s; pointer-events: none;
}
.toast.on { opacity: .95; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }

.empty { text-align: center; color: var(--ink-3); padding: 34px 12px; font-size: 14px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--card); border-radius: 12px; padding: 12px; box-shadow: var(--shadow); }
.stat .k { font-size: 12px; color: var(--ink-3); }
.stat .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: #e8eeee; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--brand); }
.alert { background: var(--warn-soft); color: #92400e; border-radius: 11px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 10px; }
.alert.err { background: var(--danger-soft); color: #991b1b; }
.alert.ok { background: var(--ok-soft); color: #14532d; }
.login-wrap { max-width: 420px; margin: 0 auto; padding: 28px 16px; }
.login-wrap .brand { text-align: center; margin-bottom: 22px; }
.login-wrap .brand .logo { font-size: 44px; }
.login-wrap .brand h1 { font-size: 21px; margin-top: 6px; }
.role-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.role-pick button {
  min-height: 76px; border-radius: 13px; border: 1.5px solid var(--line); background: #fff;
  font-family: inherit; font-size: 15px; font-weight: 650; color: var(--ink-2); cursor: pointer;
}
.role-pick button.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); }
.role-pick button .ic { display: block; font-size: 24px; margin-bottom: 2px; }
@media (min-width: 720px) { .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); min-height: 100vh; } }

/* ══ 打印入口（屏幕上显示，打印时隐藏） ══ */
.print-bar { display: flex; gap: 8px; align-items: center; padding: 10px 12px 0; }
.print-bar[hidden] { display: none; }
.print-bar .btn { width: auto; }
.print-bar select { width: auto; min-height: 38px; font-size: 14px; }
.print-root { display: none; }

/* ══ 打印版式：A4 竖版 / 白底黑字 / 单行不切断 / 导航与按钮不进打印 ══ */
/* ── 批量导入：预览校对（仓库端 .bi-row 卡片列表，可改数 / 标黄 / 删行） ── */
.bi-sheet { max-height: 92vh; overflow-y: auto; }
.bi-row { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px; }
.bi-row.warn { background: var(--warn-soft); border-color: var(--warn); }
.bi-head { display: flex; align-items: center; gap: 8px; }
.bi-head .bi-code { flex: 1; min-width: 0; font-weight: 650; font-size: 14px; font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bi-head .bi-del { width: auto; min-height: 36px; }
.bi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; margin-top: 8px; }
.bi-grid .field { margin: 0; }
.bi-grid .field label { font-size: 11px; margin-bottom: 2px; }
.bi-grid input { min-height: 38px; font-size: 14px; padding: 0 8px; }
.bi-warn { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; margin: 8px 0; }
.bi-warn div + div { margin-top: 4px; }
.bi-hit { margin-top: 8px; }
.bi-hit input { min-height: 38px; font-size: 14px; }
/* 预览校对页每行的勾选框（默认全选）：只导勾中的行 —— 触控区 ≥44px，未勾中的整行变淡不藏 */
.bi-head .bi-pick { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; }
.bi-head .bi-pick input[type=checkbox] { width: 22px; height: 22px; margin: 0; }
.bi-row.dim { opacity: .45; }

@media print {
  @page { size: A4; margin: 10mm; }
  html, body { background: #fff !important; background-image: none !important; color: #000 !important; }
  body { font-size: 12pt; }
  /* 页面导航 / 按钮 / 弹层：一律不打印 */
  .app, .topbar, .tabbar, .toast, .sheet, .sheet-mask, .no-print, .print-bar { display: none !important; }
  /* 打印版 DOM：白底黑字，强制覆盖深色主题（--ink/--brand 等不再生效） */
  .print-root { display: block !important; background: #fff !important; color: #000 !important; }
  .print-root, .print-root * { background-color: #fff !important; color: #000 !important; }
  .p-page { break-before: page; break-inside: auto; margin: 0; padding: 0; }
  .p-page:first-child { break-before: auto; }
  .p-head, .p-rowtag, .p-table, .p-table thead, .p-table tr, .p-foot, .p-sign,
  .p-sign-grid > * { break-inside: avoid; }
  .p-head { border-bottom: 2pt solid #000; padding-bottom: 4pt; margin-bottom: 6pt; }
  .p-brand { font-size: 18pt; font-weight: 700; letter-spacing: 1pt; }
  .p-meta { display: flex; flex-wrap: wrap; gap: 2pt 14pt; font-size: 10.5pt; margin-top: 3pt; }
  .p-rowtag { font-size: 12pt; font-weight: 700; margin: 6pt 0 4pt; }
  .p-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
  .p-table th, .p-table td { border: 0.8pt solid #000; padding: 4pt 5pt; vertical-align: middle; background: #fff; }
  .p-table th { font-size: 10pt; font-weight: 700; text-align: left; }
  .p-row td { height: 30pt; font-size: 11pt; }
  .p-sub { display: block; font-size: 8.5pt; }
  .c-loc { width: 20mm; font-size: 17pt; font-weight: 700; text-align: center; letter-spacing: .5pt; }
  .c-name { width: auto; }
  .c-outer { width: 14mm; text-align: center; }
  .c-qty { width: 30mm; text-align: center; font-variant-numeric: tabular-nums; }
  .c-fill { width: 32mm; }
  .c-tick { width: 12mm; text-align: center; }
  .p-short { display: inline-block; margin-left: 4pt; padding: 0 4pt; border: 0.8pt solid #000; font-size: 9pt; font-weight: 700; }
  .p-foot { margin-top: 6pt; font-size: 10pt; }
  .p-write { display: inline-block; min-width: 30mm; border-bottom: 0.8pt solid #000; }
  .p-sign { margin-top: 10pt; border: 0.8pt solid #000; padding: 6pt 8pt; }
  .p-sign-title { font-size: 11pt; font-weight: 700; margin-bottom: 6pt; }
  .p-sign-grid { display: grid; grid-template-columns: 26mm 1fr; gap: 8pt 6pt; align-items: end; font-size: 10.5pt; }
  .p-sign-line { border-bottom: 0.8pt solid #000; height: 12pt; }
  .p-sign-stamp { border: 0.8pt dashed #000; height: 18mm; }
  .p-empty { font-size: 12pt; }
}
