/* ============================================================================
 * 掌合人工智能 · 「一品一码」库存 H5 —— 共享样式
 * 品牌：国潮红金 · 喜庆高级感
 * 主色 中国红 #B11D2E ｜ 哑光金 #C8A45C ｜ 暖象牙白 #FAF6F0
 * 禁止：蓝/绿/粉混用、火焰/爆炸/鞭炮火星、emoji 图标（一律红金线性 SVG）
 * ========================================================================== */

:root {
  --red: #B11D2E;
  --red-deep: #8E1626;
  --red-soft: #F4E3E5;
  --gold: #C8A45C;
  --gold-bright: #D9BC7F;
  --gold-soft: #F3EADA;
  --ivory: #FAF6F0;
  --paper: #FFFFFF;
  --ink: #3B2A2A;
  --ink-2: #6B5750;
  --ink-3: #9A8779;
  --line: #EADCC8;
  --line-soft: #F1E7D8;
  --ok: #1E7A4F;
  --warn: #B07912;
  --err: #B11D2E;
  --radius: 16px;
  --radius-s: 10px;
  --shadow: 0 8px 28px rgba(177, 29, 46, 0.08);
  --shadow-sm: 0 3px 12px rgba(177, 29, 46, 0.06);
}

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

html { font-size: 16px; }

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: var(--ivory);
  color: var(--ink);
  line-height: 1.55;
  padding-bottom: env(safe-area-inset-bottom);
  min-height: 100vh;
}

/* ---------- 顶部品牌栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(135deg, var(--red) 0%, var(--red-deep) 100%);
  color: #FFF;
  padding: 12px 16px 14px;
  box-shadow: 0 4px 18px rgba(142, 22, 38, 0.35);
}
.topbar-inner { max-width: 720px; margin: 0 auto; }
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-brand .seal {
  width: 36px; height: 36px; flex: none;
  border-radius: 10px;
  background: var(--gold);
  color: var(--red-deep);
  display: flex; align-items: center; justify-content: center;
}
.topbar-brand .name { font-size: 17px; font-weight: 800; letter-spacing: 1px; }
.topbar-brand .sub { font-size: 11px; opacity: 0.82; margin-top: 1px; letter-spacing: 2px; }
.topbar-user { font-size: 12px; opacity: 0.92; margin-top: 6px; display: flex; align-items: center; gap: 6px; }
.topbar-user .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold-bright); }

/* ---------- 页面导航（三页互链） ---------- */
.page-nav {
  position: sticky; top: 0; z-index: 49;
  background: rgba(250, 246, 240, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.page-nav-inner { max-width: 720px; margin: 0 auto; display: flex; }
.page-nav a {
  flex: 1; text-align: center;
  padding: 11px 4px 12px;
  font-size: 13px; font-weight: 600;
  color: var(--ink-2); text-decoration: none;
  border-bottom: 2px solid transparent;
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.page-nav a svg { width: 15px; height: 15px; flex: none; }
.page-nav a.active { color: var(--red); border-bottom-color: var(--red); }

/* ---------- 布局容器 ---------- */
.wrap { max-width: 720px; margin: 0 auto; padding: 14px 14px 40px; }
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 16px 18px;
  margin-bottom: 14px;
}
.card-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
}
.card-head .ic {
  width: 30px; height: 30px; flex: none;
  border-radius: 8px;
  background: var(--red-soft);
  color: var(--red);
  display: flex; align-items: center; justify-content: center;
}
.card-head .ic svg { width: 17px; height: 17px; }
.card-head h2 { font-size: 15px; font-weight: 700; color: var(--ink); flex: 1; }
.card-head .tag { font-size: 11px; color: var(--gold); font-weight: 600; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700;
  padding: 2px 9px; border-radius: 999px;
}
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.gold { background: var(--gold-soft); color: #8A6A2F; }
.badge.ok { background: #E3F2EA; color: var(--ok); }
.badge.plain { background: #F0E9DF; color: var(--ink-2); }

/* ---------- 统计摘要 ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stats .cell {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 10px 4px 8px;
  text-align: center;
}
.stats .num { font-size: 20px; font-weight: 800; color: var(--red); }
.stats .lbl { font-size: 11px; color: var(--ink-2); margin-top: 1px; }

/* ---------- 扫描区 ---------- */
.scan-box {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #1F1517;
  border: 1px solid var(--gold);
  margin-bottom: 12px;
}
.scan-box video { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #1F1517; }
.scan-mask {
  position: absolute; inset: 0; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
}
.scan-mask .frame {
  width: 66%; height: 42%;
  border: 2px solid var(--gold-bright);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(31, 21, 23, 0.42);
  position: relative;
}
.scan-mask .frame::before, .scan-mask .frame::after {
  content: ""; position: absolute; width: 22px; height: 22px; border: 3px solid var(--gold-bright);
}
.scan-mask .frame::before { top: -3px; left: -3px; border-right: none; border-bottom: none; border-top-left-radius: 10px; }
.scan-mask .frame::after { bottom: -3px; right: -3px; border-left: none; border-top: none; border-bottom-right-radius: 10px; }
.scan-mask .hint {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 10px;
  background: rgba(0, 0, 0, 0.55); color: #fff;
  font-size: 11px; padding: 3px 10px; border-radius: 999px;
  white-space: nowrap;
}
.scan-off {
  aspect-ratio: 4 / 1;
  display: flex; align-items: center; justify-content: center;
  background: var(--gold-soft); color: #8A6A2F;
  border: 1px dashed var(--gold);
  border-radius: var(--radius);
  font-size: 13px; margin-bottom: 12px; padding: 14px;
}
.scan-off svg { width: 18px; height: 18px; margin-right: 8px; flex: none; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 12px; }
.field label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.field label svg { width: 14px; height: 14px; color: var(--gold); flex: none; }
.field input, .field select, .field textarea {
  width: 100%; height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: #FFFDF9;
  padding: 0 12px;
  font-size: 15px; color: var(--ink);
  outline: none;
}
.field textarea { height: auto; padding: 10px 12px; min-height: 40px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--gold); background: #fff; }
.field .hint { font-size: 11px; color: var(--ink-3); margin-top: 4px; }
.field .req { color: var(--red); }

/* 商品选择行 */
.goods-line {
  display: flex; gap: 10px; align-items: flex-start;
}
.goods-line .field { flex: 1; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 46px; padding: 0 18px;
  border: none; border-radius: var(--radius-s);
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  transition: transform 0.06s ease, opacity 0.15s ease;
  width: 100%;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--red), var(--red-deep));
  color: #FFF;
  box-shadow: 0 6px 16px rgba(177, 29, 46, 0.32);
}
.btn-gold {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: #5C3E0A;
  box-shadow: 0 6px 16px rgba(200, 164, 92, 0.35);
}
.btn-ghost {
  background: transparent; color: var(--red);
  border: 1.5px solid var(--red);
}
.btn-plain {
  background: var(--paper); color: var(--ink-2);
  border: 1px solid var(--line);
}
.btn-sm { height: 36px; font-size: 13px; width: auto; padding: 0 14px; }
.btn-block { display: flex; }

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ---------- 已扫列表 ---------- */
.scan-list { margin-top: 4px; }
.scan-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 9px 10px;
  margin-bottom: 8px;
  background: #FFFDF9;
}
.scan-item .no {
  flex: none; width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--red); color: #fff;
  font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.scan-item .code {
  flex: 1; font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12px; color: var(--ink);
  word-break: break-all;
}
.scan-item .del {
  flex: none; width: 30px; height: 30px;
  border: none; background: transparent;
  color: var(--ink-3); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.scan-item .del svg { width: 16px; height: 16px; }
.empty { text-align: center; color: var(--ink-3); font-size: 13px; padding: 22px 0 18px; }

/* ---------- 结果面板 ---------- */
.result-panel { border-radius: var(--radius); overflow: hidden; margin-top: 4px; }
.result-head { padding: 14px 16px; color: #fff; font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.result-head svg { width: 18px; height: 18px; flex: none; }
.result-head.ok { background: linear-gradient(135deg, #2E8B5F, #1E7A4F); }
.result-head.warn { background: linear-gradient(135deg, #C79A3A, #A87F24); }
.result-head.err { background: linear-gradient(135deg, var(--red), var(--red-deep)); }
.result-body { background: var(--paper); border: 1px solid var(--line); border-top: none; padding: 14px 16px; }
.result-body .kv { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 13px; }
.result-body .kv .k { color: var(--ink-3); flex: none; }
.result-body .kv .v { color: var(--ink); font-weight: 600; text-align: right; word-break: break-all; }
.result-body .kv .v.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.result-body .kv .v.good { color: var(--ok); }
.result-body .kv .v.warn { color: var(--warn); }
.result-body .kv .v.red { color: var(--red); }
.result-sub { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 8px; }

/* ---------- 看板表格 ---------- */
.tbl-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.tbl th {
  text-align: left; color: var(--ink-3); font-weight: 600;
  padding: 8px 6px; border-bottom: 2px solid var(--line);
  white-space: nowrap; font-size: 11.5px;
}
table.tbl td { padding: 10px 6px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl .num { font-weight: 700; color: var(--ink); }
table.tbl .num.red { color: var(--red); }
table.tbl .num.gold { color: #8A6A2F; }
table.tbl .low { color: var(--red); font-weight: 800; }
.goods-name { font-weight: 700; color: var(--ink); font-size: 13px; }
.goods-sub { font-size: 10.5px; color: var(--ink-3); margin-top: 1px; }

/* ---------- 流水列表 ---------- */
.txn-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #FFFDF9;
}
.txn-item .row1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.txn-item .row2 { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.txn-item .name { font-weight: 700; font-size: 13px; }
.txn-item .code { font-family: ui-monospace, Consolas, monospace; font-size: 10.5px; color: var(--ink-3); word-break: break-all; }
.txn-item .meta { font-size: 11px; color: var(--ink-3); }
.txn-item .meta svg { width: 12px; height: 12px; vertical-align: -2px; color: var(--gold); }

/* ---------- 页脚 ---------- */
.footer {
  max-width: 720px; margin: 26px auto 0; padding: 14px 14px 26px;
  text-align: center; color: var(--ink-3); font-size: 11.5px;
}
.footer .brand { color: var(--gold); font-weight: 700; letter-spacing: 1px; }
.footer .sepline { width: 40px; height: 2px; background: linear-gradient(90deg, transparent, var(--gold), transparent); margin: 8px auto; }

/* ---------- 顶部红金纹样分隔 ---------- */
.ornament { display: flex; align-items: center; gap: 10px; margin: 2px 0 12px; }
.ornament::before, .ornament::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--gold)); }
.ornament::after { background: linear-gradient(90deg, var(--gold), transparent); }
.ornament span { color: var(--gold); font-size: 11px; letter-spacing: 3px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; top: 18%; transform: translateX(-50%);
  max-width: 84vw; z-index: 999;
  background: rgba(59, 42, 42, 0.94); color: #fff;
  font-size: 13px; padding: 10px 18px; border-radius: 10px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
#toast.show { opacity: 1; }
#toast.ok { background: rgba(30, 122, 79, 0.95); }
#toast.err { background: rgba(177, 29, 46, 0.96); }

/* ---------- 加载态 ---------- */
.loading { text-align: center; color: var(--ink-3); padding: 26px 0; font-size: 13px; }
.loading .spin {
  width: 26px; height: 26px; margin: 0 auto 8px;
  border: 3px solid var(--line);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; }
.pager .info { font-size: 12px; color: var(--ink-2); }
.pager .btn { width: auto; height: 34px; font-size: 13px; padding: 0 16px; }

/* ---------- 模态 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(31, 21, 23, 0.6);
  display: none; align-items: flex-end; justify-content: center;
}
.modal-mask.show { display: flex; }
.modal {
  width: 100%; max-width: 720px;
  background: var(--ivory);
  border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
  max-height: 82vh; overflow-y: auto;
}
.modal .m-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal .m-head h3 { font-size: 16px; font-weight: 800; color: var(--ink); }
.modal .m-close { border: none; background: transparent; color: var(--ink-3); cursor: pointer; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }
.modal .m-close svg { width: 18px; height: 18px; }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .tool { flex: 1; min-width: 120px; }
.toolbar .tool select, .toolbar .tool input { height: 38px; font-size: 13px; }
.toolbar .btn { flex: none; width: auto; height: 38px; font-size: 13px; padding: 0 14px; }

/* ---------- 小工具 ---------- */
.flex { display: flex; align-items: center; gap: 8px; }
.flex-1 { flex: 1; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mb-12 { margin-bottom: 12px; }
.text-red { color: var(--red); }
.text-gold { color: #8A6A2F; }
.text-3 { color: var(--ink-3); }
.text-sm { font-size: 12px; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.divider { border: none; border-top: 1px solid var(--line); margin: 14px 0; }

/* ---------- 步骤指示 ---------- */
.steps { display: flex; gap: 6px; margin-bottom: 14px; }
.steps .step {
  flex: 1; text-align: center;
  padding: 8px 4px; border-radius: var(--radius-s);
  background: #F0E9DF; color: var(--ink-3);
  font-size: 12px; font-weight: 700;
  border: 1px solid var(--line);
  position: relative;
}
.steps .step .st-no {
  display: inline-flex; width: 18px; height: 18px; border-radius: 50%;
  background: var(--ink-3); color: #fff; font-size: 10px;
  align-items: center; justify-content: center; margin-right: 4px;
}
.steps .step.done { background: var(--gold-soft); color: #8A6A2F; border-color: var(--gold); }
.steps .step.done .st-no { background: var(--gold); }
.steps .step.active { background: var(--red-soft); color: var(--red); border-color: var(--red); }
.steps .step.active .st-no { background: var(--red); }

/* ---------- 手机适配 ---------- */
@media (min-width: 720px) {
  body { background: #F1E9DC; }
  .wrap, .topbar-inner, .page-nav-inner, .footer { max-width: 720px; }
  .modal-mask { align-items: center; }
  .modal { border-radius: 20px; }
}
