/* 辉哥库管 —— 样式
 * 设计约束：手机优先 / 浅色主题 / 大触控区 / 高对比度 / 兼容 iOS Safari 与微信内置浏览器
 * 避免使用过新语法：不使用 CSS 父选择器、不使用 flex gap、不使用实验特性，兼容 iOS Safari 12+
 */

:root {
  --red: #E1251B;
  --red-dark: #B81B14;
  --red-soft: #FDECEA;
  --green: #12A150;
  --green-soft: #E8F7EE;
  --amber: #B26A00;
  --amber-soft: #FFF6E5;
  --blue: #1668DC;
  --text: #1F2126;
  --text-2: #5B616B;
  --text-3: #8B919B;
  --line: #E5E7EB;
  --bg: #F4F5F7;
  --card: #FFFFFF;
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

#app { display: flex; flex-direction: column; min-height: 100vh; }

/* ---------- 顶栏 ---------- */
#topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: calc(var(--safe-t) + 10px) 14px 10px;
  background: var(--red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#topbar h1 { margin: 0; font-size: 19px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; max-width: 70%; justify-content: flex-end; }
#topbarMeta { font-size: 13px; opacity: .9; max-width: 45%; text-align: right; }
.sync-badge {
  font-size: 11px; font-weight: 600; white-space: nowrap;
  padding: 3px 8px; border-radius: 999px; margin-right: 8px;
}
.sync-badge.on { background: var(--green-soft); color: var(--green); }
.sync-badge.off { background: var(--amber-soft); color: var(--amber); }
#countResume {
  font-size: 12px; font-weight: 600; color: var(--red); background: #fff;
  border: none; border-radius: 999px; padding: 5px 10px; white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
#countResume:active { transform: scale(.96); }
.hint.warn { color: var(--amber); font-weight: 600; }
.hint.ok { color: #12A150; font-weight: 600; }

/* ---------- 主体 ---------- */
#main {
  flex: 1;
  padding: 12px 12px calc(84px + var(--safe-b));
}
.page { display: none; }
.page.is-active { display: block; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
.card + .card { margin-top: 0; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.card-title { font-size: 15px; font-weight: 600; }
.sync-status-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; padding: 6px 0; border-bottom: 1px solid var(--line);
}
.sync-status-row:last-of-type { border-bottom: none; }
.sync-label { color: var(--text-2); }
.sync-value { color: var(--text); font-weight: 600; word-break: break-all; text-align: right; max-width: 65%; }

.hint { font-size: 13px; color: var(--text-2); margin-top: 8px; }
.hint code { background: #F0F1F3; padding: 1px 4px; border-radius: 4px; font-size: 12px; }
.stat { font-size: 13px; color: var(--text-2); margin-top: 10px; }

.chip {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #F0F1F3;
  color: var(--text-2);
}
.chip.ok { background: var(--green-soft); color: var(--green); }
.chip.warn { background: var(--amber-soft); color: var(--amber); }
.chip.bad { background: var(--red-soft); color: var(--red); }

/* ---------- 分段控件 ---------- */
.seg {
  display: flex;
  background: #fff;
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
.seg-btn {
  flex: 1;
  min-height: 46px;
  border: 0;
  background: transparent;
  border-radius: 9px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-2);
}
.seg-btn.is-active { background: var(--red); color: #fff; }

/* ---------- 按钮 ---------- */
.btn {
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
}
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:active { background: var(--red-dark); }
.btn.ghost { background: #fff; color: var(--text-2); transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s; cursor: pointer; }
/* 导出等幽灵按钮：鼠标移入给出明显反馈，确认按钮可点击 */
.btn.ghost:hover { background: var(--red-soft); border-color: var(--red); color: var(--red); box-shadow: 0 2px 8px rgba(225,37,27,.18); }
.btn.ghost:active { background: #FBD9D6; border-color: var(--red-dark); color: var(--red-dark); }
.btn.danger { background: #fff; border-color: var(--red); color: var(--red); width: 100%; }
.btn.danger-ghost { background: #fff; border-color: var(--red); color: var(--red); }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn[disabled] { opacity: .5; }

.btn-row { display: flex; }
.btn-row .btn + .btn { margin-left: 8px; }
.btn-row .btn { flex: 1; }

.row-btn {
  display: block;
  width: 100%;
  min-height: 50px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 16px;
  color: var(--text);
  text-align: left;
  padding: 0 14px;
}
.row-btn.primary { background: var(--red); border-color: var(--red); color: #fff; text-align: center; font-weight: 600; }
.row-btn.danger { color: var(--red); border-color: #F3C4C1; text-align: center; }

/* ---------- 表单 ---------- */
.full-input, .select, .date-input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 16px;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}
.date-input { min-height: 44px; font-size: 15px; padding: 0 8px; }
.filter-row { display: flex; margin-top: 10px; }
.filter-row > * { flex: 1; }
.filter-row > * + * { margin-left: 8px; }
.filter-row .dash { flex: 0 0 22px; text-align: center; color: var(--text-3); line-height: 44px; margin-left: 0; }
.checkline { display: flex; align-items: center; font-size: 14px; color: var(--text-2); flex: 0 0 auto; padding: 0 4px; }
.checkline input { width: 20px; height: 20px; margin-right: 6px; }

.field { display: block; margin-top: 12px; }
.field > span { display: block; font-size: 14px; color: var(--text-2); margin-bottom: 6px; }
.dt-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; margin-top: 12px; }
.dt-form-grid .field { margin-top: 0; }
.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.sortable:hover { background: #eef2f7; }
.code-hl { display: inline-block; font-family: ui-monospace, Menlo, Consolas, monospace; background: #fff3cd; color: #8a6d00; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.dt-mini-btn { margin-right: 4px; padding: 2px 8px; font-size: 12px; border: 1px solid #c8d0da; background: #fff; border-radius: 4px; cursor: pointer; }
.dt-mini-btn:hover { background: #f1f5f9; }
.dt-mini-btn.dt-delete-btn { color: var(--red); border-color: #F3C4C1; }
.dt-mini-btn.dt-archive-btn { color: var(--amber); border-color: #F0A33A; }
.dt-history { margin-top: 14px; border-top: 1px dashed #d6dde6; padding-top: 10px; }
.dt-history-title { font-weight: 600; margin-bottom: 6px; }
.dt-history table { width: 100%; border-collapse: collapse; font-size: 12px; }
.dt-history td { padding: 3px 6px; border-bottom: 1px solid #eef1f5; }
.dt-history-empty { color: var(--text-3); font-size: 12px; }
.dt-active { background: var(--red-soft); border-color: #F3C4C1; color: var(--red); }

/* ===== 数据保险区块（v42） ===== */
.insure-status { margin: 6px 0 10px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fafbfc; }
.insure-status-row { display: flex; align-items: center; gap: 8px; font-size: 13px; line-height: 1.9; }
.insure-status-row .insure-label { color: var(--text-3); min-width: 64px; }
.insure-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: #c2cbd6; }
.insure-dot.ok { background: #2bb673; }
.insure-dot.warn { background: #f0a33a; }
.insure-err { color: var(--red); }
.insure-sub { font-weight: 600; margin: 14px 0 6px; font-size: 13px; }
.dt-insure-snapshots { margin-top: 4px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; max-height: 260px; overflow: auto; }
.dt-insure-snapshots:empty::after { content: '读取中…'; color: var(--text-3); font-size: 12px; }
.insure-snap-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 4px; border-bottom: 1px solid #eef1f5; }
.insure-snap-row:last-child { border-bottom: none; }
.insure-snap-info { display: flex; align-items: center; gap: 10px; font-size: 12px; flex-wrap: wrap; }
.insure-snap-when { color: var(--text-1); font-family: ui-monospace, Menlo, Consolas, monospace; }
.insure-snap-reason { color: var(--text-3); }
.insure-snap-size { color: #8a93a0; }
/* ===== 移动端 Wave5 补充样式（回收站/排序/操作按钮） ===== */
.m-recycle-btn { font-size: 13px; padding: 7px 12px; border-radius: 8px; }
.m-recycle-btn.active { background: var(--red-soft); border-color: #F3C4C1; color: var(--red); }
.m-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.m-sortable:active { background: #eef2f7; }
.cell-op { display: flex; flex-wrap: wrap; gap: 6px; }
.cell-op > button { font-size: 13px; min-height: 34px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text-2); cursor: pointer; }
.cell-op .m-archive-btn { color: var(--amber); border-color: #F0A33A; }
.cell-op .m-restore-btn { color: var(--green); border-color: #7FD3A6; }
.cell-op .m-delete-btn { color: var(--red); border-color: #F3C4C1; }
.cell-op > button:active { background: #f1f5f9; }
.m-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-top: 4px; }
.m-form-cell .form-label { margin: 0 0 6px; }
@media (max-width: 380px) { .m-form-grid { grid-template-columns: 1fr; } }
.switch-field { display: flex; align-items: center; justify-content: space-between; }
.switch-field > span { margin-bottom: 0; }

.switch { position: relative; display: inline-block; width: 50px; height: 30px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; }
.switch span { position: absolute; inset: 0; background: #D4D7DD; border-radius: 999px; transition: background .18s; }
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  background: #fff; border-radius: 50%; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + span { background: var(--red); }
.switch input:checked + span::after { transform: translateX(20px); }

/* ---------- 摄像头 ---------- */
.cam-box {
  position: relative;
  width: 100%;
  height: 0;
  padding-top: 62%;
  background: #101216;
  border-radius: 10px;
  overflow: hidden;
}
.cam-box video {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  object-fit: cover; background: #101216;
}
.cam-box.is-off video { display: none; }
.cam-mask { position: absolute; inset: 0; pointer-events: none; }
.cam-mask::before {
  content: ""; position: absolute; left: 12%; right: 12%; top: 34%; bottom: 34%;
  border: 2px solid rgba(255,255,255,.85); border-radius: 10px;
}
.cam-line {
  position: absolute; left: 12%; right: 12%; top: 34%; height: 2px;
  background: var(--red); box-shadow: 0 0 8px var(--red);
  animation: scanline 2s linear infinite;
}
@keyframes scanline { 0% { top: 34%; } 50% { top: 66%; } 100% { top: 34%; } }

.gun-row { display: flex; }
.gun-row input { flex: 1; }
.gun-row .btn { margin-left: 8px; flex: 0 0 auto; }

/* ---------- 列表 ---------- */
.list { display: block; }
.list-item {
  background: #fff;
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
.list-item:active { background: #FAFAFB; }
.li-head { display: flex; align-items: baseline; justify-content: space-between; }
.li-title { font-size: 16px; font-weight: 600; flex: 1; padding-right: 8px; }
.li-qty { font-size: 18px; font-weight: 700; flex: 0 0 auto; }
.li-qty.low { color: var(--red); }
.li-sub { font-size: 13px; color: var(--text-2); margin-top: 4px; word-break: break-all; }
.li-foot { font-size: 12px; color: var(--text-3); margin-top: 6px; display: flex; flex-wrap: wrap; }
.li-foot span { margin-right: 10px; }

.badge {
  display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px;
  background: var(--amber-soft); color: var(--amber); margin-left: 6px; vertical-align: 1px;
}
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.gray { background: #F0F1F3; color: var(--text-3); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.blue { background: #E8F1FE; color: var(--blue); }

.txn-in { color: var(--green); font-weight: 700; }
.txn-out { color: var(--red); font-weight: 700; }
.txn-count { color: var(--blue); font-weight: 700; }
.txn-reverse { color: var(--text-3); font-weight: 700; text-decoration: line-through; }

.mini-list { margin-top: 8px; }
.mini-item {
  padding: 10px 2px; border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; font-size: 15px;
}
.mini-item .m-name { flex: 1; padding-right: 8px; }
.mini-item .m-code { font-size: 12px; color: var(--text-3); }
.empty { text-align: center; color: var(--text-3); font-size: 14px; padding: 28px 10px; }
.link-new { color: var(--blue); text-decoration: underline; font-weight: 600; }

/* ---------- 扫码结果 ---------- */
.result-card { border-left: 4px solid var(--red); }
.result-card.ok { border-left-color: var(--green); }
.result-card.warn { border-left-color: var(--amber); }
.result-name { font-size: 18px; font-weight: 700; }
.result-stock { font-size: 15px; margin-top: 6px; }
.alert {
  background: var(--amber-soft); color: var(--amber);
  border-radius: 8px; padding: 10px; font-size: 14px; margin-top: 10px;
}
.alert.red { background: var(--red-soft); color: var(--red); }

/* ---------- 数字键盘 ---------- */
.qty-pad {
  background: #fff; border-radius: var(--radius); padding: 12px; margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(16,24,40,.06);
}
.qty-display {
  text-align: center; font-size: 34px; font-weight: 700; padding: 6px 0 12px;
  border-bottom: 1px solid var(--line); margin-bottom: 12px;
}
.qty-display span:last-child { font-size: 16px; color: var(--text-3); margin-left: 6px; font-weight: 500; }
.pad-grid { display: flex; flex-wrap: wrap; }
.pad-grid button {
  width: 33.33%; min-height: 56px; border: 0; background: transparent;
  font-size: 22px; font-weight: 600; color: var(--text);
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.pad-grid button:nth-child(3n) { border-right: 0; }
.pad-grid button:active { background: #F0F1F3; }
.qty-pad .full-input { margin-top: 12px; }
.qty-pad .btn-row { margin-top: 12px; }
.hidden { display: none !important; }

/* ---------- 盘点 ---------- */
.count-head { display: flex; align-items: center; justify-content: space-between; }
.count-big { font-size: 26px; font-weight: 700; color: var(--red); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-b));
  transform: translateX(-50%);
  max-width: 86%;
  background: rgba(28, 30, 36, .94);
  color: #fff;
  font-size: 15px;
  padding: 11px 16px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  /* 必须高于 .modal-mask(z-index:300)，否则弹窗打开时 toast 会被遮罩挡在下面，用户看不到任何反馈 */
  z-index: 400;
  text-align: center;
}
/* 弹窗打开时把 toast 抬到弹窗之上 */
.modal-mask ~ .toast,
body.has-modal .toast { z-index: 400; }
.toast.show { opacity: 1; }
.toast.ok { background: rgba(18, 161, 80, .96); }
.toast.err { background: rgba(225, 37, 27, .96); }
.toast.warn { background: rgba(178, 106, 0, .96); }

/* ---------- 底部 Tab ---------- */
#tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tab {
  flex: 1;
  min-height: 56px;
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 0 4px;
}
.tab i { font-style: normal; font-size: 20px; line-height: 1; margin-bottom: 3px; }
.tab.is-active { color: var(--red); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(16, 18, 24, .5);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; width: 100%; max-height: 86vh; overflow: auto;
  border-radius: 16px 16px 0 0;
  padding: 14px 14px calc(14px + var(--safe-b));
  -webkit-overflow-scrolling: touch;
}
.modal h3 { margin: 0 0 12px; font-size: 17px; }
.modal .btn-row { margin-top: 14px; }
.modal .full-input { margin-top: 10px; }
.modal textarea {
  width: 100%; min-height: 150px; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; font-size: 14px; line-height: 1.6; font-family: monospace; resize: vertical;
}
.report-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
.report-table th, .report-table td { border: 1px solid var(--line); padding: 6px 4px; text-align: left; }
.report-table th { background: #F7F8FA; }
.report-table td.code-cell { font-size: 11px; font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--text-3); word-break: break-all; }

/* 商品库表格（对齐盘点表列，窄屏横向滚动） */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 8px; }
.prod-table { border-collapse: collapse; font-size: 13px; width: 100%; min-width: 1040px; }
.prod-table th, .prod-table td { border: 1px solid var(--line); padding: 7px 6px; text-align: left; vertical-align: top; }
.prod-table th { background: #F7F8FA; position: sticky; top: 0; white-space: nowrap; }
.prod-table tbody tr:active { background: #FAFAFB; }
.prod-table tbody tr[data-barcode] { cursor: pointer; }
.prod-table .cell-code { font-size: 11px; font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--text-3); word-break: break-all; }
.prod-table .cell-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.prod-table .cell-idx { text-align: center; color: var(--text-3); width: 44px; font-variant-numeric: tabular-nums; }
.prod-table .cell-unit { color: var(--text-3); font-size: 12px; margin-left: 3px; }

/* 计量单位候选（更多 → 计量单位） */
.unit-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.unit-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px;
  border: 1px solid var(--line); border-radius: 999px; background: #F7F8FA; font-size: 13px; }
.unit-chip .unit-del { border: none; background: transparent; color: var(--text-3);
  cursor: pointer; font-size: 12px; padding: 0 2px; line-height: 1; }

/* 单位选择区（新建商品 / 商品详情）：输入框可手打，"选择"按钮展开可滚动候选面板。
 * 不用 <datalist> —— iOS Safari 支持极差，且在 innerHTML 里拼接容易变成悬空 datalist。 */
.unit-field { margin-top: 8px; }
.unit-field-row { display: flex; align-items: stretch; }
.unit-field-row .full-input { flex: 1 1 auto; min-width: 0; }
.unit-field-row .unit-toggle { flex: 0 0 auto; margin-left: 8px; min-width: 72px; }
.unit-panel {
  max-height: 42vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #FAFAFB;
}
.unit-panel .unit-chip { margin: 0 6px 6px 0; min-height: 36px; font-size: 15px; cursor: pointer; }
.unit-panel .unit-chip:active { background: var(--red-soft); border-color: var(--red); color: var(--red); }

/* 商品库合并列（品牌 · 产品名称 · 品类 · 型号）——内容较长，允许换行且不限宽 */
.prod-table .cell-combo { min-width: 180px; word-break: break-word; line-height: 1.45; }

.form-label { display: block; font-size: 14px; color: var(--text-2); margin-top: 12px; }

/* 摄像头未开启时的大号启动按钮（年长同事一眼就懂） */
.cam-start {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 190px;
  padding: 18px 26px;
  border: none;
  border-radius: 16px;
  background: var(--brand, #E1251B);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  box-shadow: 0 6px 18px rgba(225, 37, 27, .35);
  cursor: pointer;
}
.cam-start:active { transform: translate(-50%, -50%) scale(.97); }
.cam-start-icon { font-size: 30px; line-height: 1; }
.cam-start-text { white-space: nowrap; }
.cam-box.is-live .cam-start { display: none; }

/* 快扫结果：大字确认，方便远距离/弱光下扫一眼 */
.quick-done {
  margin: 10px 0 4px;
  font-size: 20px;
  font-weight: 700;
  color: #1E7A34;
}
.quick-done b { font-size: 24px; }

/* 自检按钮：门店排障的主要入口，做得显眼一些 */
.btn.warn-btn {
  background: #FFF4E5;
  color: #B45309;
  border: 1px solid #F0A33A;
  font-weight: 700;
  width: 100%;
}
.btn.warn-btn:active { background: #FFE8CC; }

/* 微信环境警告：用最显眼的方式挡住，避免用户在微信里白折腾 */
.wx-warn {
  padding: 14px 16px;
  background: #FFF4E5;
  border: 2px solid #F0A33A;
  border-radius: 12px;
}
.wx-warn-title { font-size: 17px; font-weight: 700; color: #B45309; line-height: 1.5; }
.wx-warn-body { margin-top: 8px; font-size: 15px; line-height: 1.75; color: var(--text-1); }
.wx-warn-steps {
  margin-top: 10px;
  padding: 10px 12px;
  background: #fff;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.9;
  color: var(--text-1);
}
.wx-warn-steps code {
  background: #F3F4F6;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  word-break: break-all;
}
.wx-warn .btn { margin-top: 12px; }

/* 摄像头自检结果 */
.diag-box {
  margin-top: 10px;
  padding: 12px 14px;
  background: #FFF8F8;
  border: 1px solid #F3C6C6;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--text-1);
  word-break: break-all;
}
.diag-box .diag-line { display: block; }
.diag-box .diag-cause {
  display: block;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #E3B4B4;
  font-weight: 700;
  color: #C0392B;
}
.diag-box .diag-fix {
  display: block;
  margin-top: 6px;
  padding: 8px 10px;
  background: #fff;
  border-radius: 8px;
  color: var(--text-1);
  font-weight: 500;
}
.diag-box .diag-copy { display: block; margin-top: 10px; }
.diag-box .diag-copy .btn { width: 100%; font-size: 13px; }
.diag-box.is-ok { background: #F4FBF5; border-color: #B7DFBC; }
.diag-box.is-ok .diag-cause { color: #1E7A34; border-top-color: #B7DFBC; }

/* ---------- 商品样图（手机端 / 电脑端共用） ---------- */
/* 列表中的「产品样图」缩略图列，点击放大预览 */
.cell-img { text-align: center; vertical-align: middle; width: 66px; }
.prod-table .cell-img .cell-img-thumb {
  width: 52px; height: 52px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line); background: #F0F1F3; cursor: pointer;
  display: inline-block; vertical-align: middle;
}
.prod-table .cell-img .cell-img-thumb:active { opacity: .7; }
.cell-img-none, .cell-img .cell-img-none { color: var(--text-3); }

/* 弹窗内样图编辑区（顶部，可上传 / 替换 / 删除） */
.img-edit {
  border: 1px solid var(--line); border-radius: 12px; background: #FAFAFB;
  padding: 12px; margin-bottom: 4px; text-align: center;
}
.img-edit-prev {
  max-width: 160px; max-height: 160px; width: auto; height: auto;
  border-radius: 10px; border: 1px solid var(--line); background: #F0F1F3;
  display: block; margin: 0 auto 10px;
}
.img-edit-empty {
  max-width: 160px; min-height: 92px; margin: 0 auto 10px;
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--line); border-radius: 10px; color: var(--text-3); font-size: 14px;
}
.img-edit-btns { display: flex; justify-content: center; }
.img-edit-btns .btn + .btn { margin-left: 8px; }

/* 全屏预览（点击任意处关闭）—— 必须覆盖旧的内联 .img-preview 定义 */
.img-preview {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(16, 18, 24, .88);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.img-preview-inner { max-width: 92vw; max-height: 80vh; overflow: hidden; }
.img-preview-inner img {
  max-width: 92vw; max-height: 80vh; width: auto; height: auto;
  border-radius: 8px; background: #fff;
}
.img-preview-tip {
  margin-top: 14px; color: rgba(255, 255, 255, .85); font-size: 13px;
}

/* 电脑端：弹窗内样图放大一些，全屏预览更宽松 */
@media (min-width: 900px) {
  .img-edit-prev, .img-edit-empty { max-width: 220px; max-height: 220px; }
  .img-preview-inner img { max-width: 70vw; max-height: 82vh; }
}

@media (min-width: 640px) {
  #main { max-width: 560px; margin: 0 auto; width: 100%; }
  #topbar { padding-left: calc(50% - 280px + 14px); padding-right: calc(50% - 280px + 14px); }
  #tabbar { justify-content: center; }
  #tabbar .tab { max-width: 112px; }
  .modal-mask { align-items: center; }
  .modal { max-width: 520px; border-radius: 16px; }
}

/* ============ 电脑端（≥900px）专属样式：仅新增 .dt-* 类，绝不改动移动端现有类 ============ */
#desktop { display: none; }

@media (min-width: 900px) {
  #app { display: none !important; }
  #desktop { display: flex; height: 100vh; overflow: hidden; }

  /* 电脑端弹窗居中、限宽（复用 .modal / .modal-mask） */
  .modal-mask { align-items: center; }
  .modal { max-width: 560px; border-radius: 16px; }

  /* 电脑端条码列放大，便于看清 */
  .prod-table .cell-code { font-size: 14px; line-height: 1.5; }
  /* 条码图形列：居中、可点击放大 */
  .prod-table .cell-barcode { text-align: center; vertical-align: middle; }
  .prod-table .cell-barcode .dt-bar-svg {
    width: 100%; max-width: 240px; height: auto;
    cursor: pointer; display: inline-block; vertical-align: middle;
  }
  .prod-table .cell-barcode .dt-bar-svg:hover { opacity: 0.7; }
  /* 弹窗内大号条码（供手机扫码） */
  .dt-bar-big { width: 100%; max-width: 460px; height: auto; display: block; margin: 0 auto; }
  .dt-bar-text { font-size: 12px; color: var(--text-3); word-break: break-all; }
}

#dt-sidebar {
  width: 208px; flex: 0 0 208px;
  background: #ffffff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.dt-brand { display: flex; align-items: center; padding: 16px; border-bottom: 1px solid var(--line); }
.dt-logo {
  width: 34px; height: 34px; border-radius: 8px; background: var(--red); color: #fff;
  font-size: 18px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  margin-right: 10px;
}
.dt-brand-txt b { font-size: 16px; }
.dt-brand-txt small { display: block; font-size: 11px; color: var(--text-3); }

#dt-nav { padding: 8px 0; }
.dt-nav-item {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 12px 18px; font-size: 15px; color: var(--text-2); cursor: pointer;
  border-left: 3px solid transparent;
}
.dt-nav-item.is-active { background: var(--red-soft); color: var(--red); border-left-color: var(--red); font-weight: 600; }

#dt-right { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#dt-topbar {
  height: 56px; flex: 0 0 56px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
}
#dt-topbar h1 { font-size: 18px; margin: 0; }
.dt-topbar-right { display: flex; align-items: center; }
.dt-op { font-size: 13px; color: var(--text-2); margin-right: 14px; }
.dt-sync {
  font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
}
.dt-sync.on { background: var(--green-soft); color: var(--green); border-color: transparent; }
.dt-sync.off { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.dt-sync.local { background: #F0F1F3; color: var(--text-2); }

.dt-version { margin-top: auto; padding: 12px 18px; font-size: 12px; color: var(--text-3); border-top: 1px solid var(--line); user-select: none; }
.dt-pager { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 14px 0 4px; flex-wrap: wrap; }
.dt-page-btn { min-height: 34px; padding: 0 16px; font-size: 14px; border: 1px solid var(--line); background: #fff; color: var(--text-2); border-radius: 8px; cursor: pointer; }
.dt-page-btn:hover:not([disabled]) { background: #f1f5f9; }
.dt-page-btn[disabled] { opacity: .45; cursor: default; }
.dt-page-info { font-size: 13px; color: var(--text-2); }

#dt-main { flex: 1; overflow: auto; padding: 20px; background: var(--bg); }
.dt-panel { display: none; }
.dt-panel.is-active { display: block; }

.dt-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.dt-panel-head h2 { font-size: 17px; margin: 0; }

.dt-stat-grid { display: flex; flex-wrap: wrap; margin: -8px; }
.dt-stat { flex: 1 1 200px; margin: 8px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.dt-stat .num { font-size: 26px; font-weight: 700; }
.dt-stat .lbl { font-size: 13px; color: var(--text-2); margin-top: 4px; }
.dt-stat.warn .num { color: var(--red); }
.dt-stat.warn { background: var(--red-soft); border-color: #F3C4C1; }

/* ============ 导出 PDF 打印视图（零依赖，调用 window.print，用户在打印窗口选“另存为 PDF”） ============ */
#print-holder { display: none; }
@media print {
  body > *:not(#print-holder) { display: none !important; }
  #print-holder { display: block !important; }
  .print-area { padding: 0; color: #000; }
  .print-title { font-size: 18px; font-weight: 700; margin: 0 0 4px; }
  .print-meta { font-size: 12px; color: #555; margin-bottom: 10px; }
  .print-table { border-collapse: collapse; width: 100%; font-size: 11px; }
  .print-table th, .print-table td { border: 1px solid #999; padding: 3px 6px; text-align: left; }
  .print-table thead th { background: #f2f3f5; font-weight: 700; }
}

.dt-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.dt-toolbar > * { margin: 4px 8px 4px 0; }

.dt-entry { display: flex; flex-wrap: wrap; }
.dt-entry > .dt-col { flex: 1 1 360px; margin: 8px; min-width: 300px; }

.dt-chips { margin-top: 8px; }
.dt-chips .unit-chip { margin: 0 6px 6px 0; cursor: pointer; }
.dt-chips .unit-chip:active { background: var(--red-soft); border-color: var(--red); color: var(--red); }

.dt-field-wrap { position: relative; }
.dt-dropdown {
  position: absolute; top: 100%; left: 0; z-index: 20; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 4px 12px rgba(16,24,40,.12);
  max-height: 240px; overflow-y: auto; width: 100%; display: none; margin-top: 2px;
}

.ac-wrap { position: relative; }
.ac-drop {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 9999;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 6px 18px rgba(16,24,40,.18);
  max-height: 240px; overflow-y: auto; display: none; margin-top: 2px;
}
.ac-item { padding: 10px 12px; font-size: 15px; cursor: pointer; border-bottom: 1px solid #f0f0f0; }
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item:active { background: var(--red-soft); }

.dt-selected {
  background: var(--red-soft); border: 1px solid #F3C4C1; border-radius: 10px;
  padding: 10px 12px; margin-bottom: 12px; font-size: 14px;
}
.dt-selected b { color: var(--red); }

.dt-table-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-top: 12px; }
.dt-table-card .card-title { margin-bottom: 8px; display: block; }

.dt-row-btn-row { margin-top: 12px; }
.dt-row-btn-row .btn { margin: 0 8px 0 0; }

.dt-muted { color: var(--text-3); font-size: 13px; }

