:root {
  --bg: #f6f4f0;
  --card: #fff;
  --ink: #3a3430;
  --muted: #8a817a;
  --line: #eee9e3;
  --brand: #b8795f;
  --brand2: #c98a6d;
  --green: #3e8e6a;
  --red: #d65a3a;
  --amber: #d99a3a;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
.app { max-width: 720px; margin: 0 auto; padding-bottom: 40px; }

.topbar {
  background: linear-gradient(135deg, var(--brand2), var(--brand));
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar .brand { font-weight: 700; font-size: 16px; }
.topbar .user { display: flex; align-items: center; gap: 8px; cursor: pointer; background: rgba(255,255,255,.18); border-radius: 999px; padding: 5px 12px; font-size: 13px; }
.store-tag { background: rgba(255,255,255,.25); border-radius: 6px; padding: 1px 7px; font-size: 11px; }

.tabs { display: flex; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.tab { flex: 1; text-align: center; padding: 13px 0; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.panel { padding: 14px 12px; }
.hidden { display: none !important; }

.stat-row { display: flex; gap: 8px; margin-bottom: 12px; }
.stat { flex: 1; background: var(--card); border-radius: 12px; padding: 12px 8px; text-align: center; border: 1px solid var(--line); }
.stat .num { font-size: 20px; font-weight: 700; color: var(--brand); }
.stat .lbl { font-size: 11px; color: var(--muted); margin-top: 2px; }

.action-row { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.btn { border: none; border-radius: 10px; padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.warn { background: #fdf1ec; color: var(--red); border: 1px solid #f3d8cd; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: #fdece8; color: var(--red); }
.btn.small { padding: 4px 10px; font-size: 12px; border-radius: 8px; }

.section-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 16px 0 8px; }
.section-title .sub { font-weight: 400; color: var(--muted); font-size: 12px; }

.list { background: var(--card); border-radius: 12px; border: 1px solid var(--line); overflow: hidden; }
.row { padding: 12px 14px; border-bottom: 1px solid #f6f2ed; }
.row:last-child { border-bottom: none; }
.row .t { font-weight: 600; }
.row .t .tag { font-size: 11px; color: #fff; background: var(--brand2); border-radius: 5px; padding: 1px 6px; margin-left: 6px; vertical-align: 1px; }
.row .t .tag.low { background: var(--red); }
.row .t .tag.tag-in { background: var(--green); }
.row .meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.row .right { float: right; text-align: right; }
.row .amt { font-weight: 700; }
.row .amt.neg { color: var(--green); }
.row .amt.pos { color: var(--red); }
.row .op { margin-top: 6px; display: flex; gap: 6px; justify-content: flex-end; }

.empty { padding: 26px; text-align: center; color: var(--muted); font-size: 13px; }

.mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 720px; border-radius: 18px 18px 0 0; max-height: 86vh; display: flex; flex-direction: column; }
.sheet-title { font-size: 16px; font-weight: 700; text-align: center; padding: 16px; border-bottom: 1px solid var(--line); }
.sheet-body { padding: 14px 16px; overflow-y: auto; }
.sheet-foot { display: flex; gap: 10px; padding: 12px 16px 20px; }
.sheet-foot .btn { flex: 1; }

.emp-item { padding: 12px 6px; border-bottom: 1px solid #f6f2ed; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.emp-item:active { background: #faf7f3; }
.emp-item .st { font-size: 12px; color: var(--muted); }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; background: #fff; color: var(--ink); font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand2); }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.filters { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.filters select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; background: #fff; }

.search-box { margin-bottom: 10px; }
.search-box input { width: 100%; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; background: #fff; color: var(--ink); }
.search-box input:focus { outline: none; border-color: var(--brand2); }

.toast { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.78); color: #fff; padding: 9px 18px; border-radius: 999px; font-size: 13px; z-index: 30; }

/* 顶栏操作区 */
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { background: rgba(255,255,255,.18); border: none; color: #fff; border-radius: 999px; width: 36px; height: 36px; font-size: 17px; cursor: pointer; flex-shrink: 0; }

/* 登录 */
.login-tip { font-size: 12px; color: var(--red); margin-top: 8px; min-height: 16px; }
.login-tip.muted { color: var(--muted); }

/* 扫码 */
.scan-reader { width: 100%; max-width: 300px; margin: 0 auto; }
.scan-reader video { border-radius: 12px; width: 100% !important; }
.scan-result { margin-top: 14px; text-align: center; color: var(--muted); font-size: 13px; min-height: 20px; }
.scan-result.found .q-name { font-size: 16px; font-weight: 700; color: var(--ink); }
.scan-result .q-stock { margin: 4px 0 12px; }
.scan-result .q-ops { display: flex; gap: 8px; justify-content: center; }

/* 二维码标签 */
.center { text-align: center; }
.qr-box { display: flex; justify-content: center; margin-bottom: 12px; }
.qr-box #qrCode { padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.qr-name { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.qr-code { font-family: monospace; color: var(--muted); font-size: 13px; margin-bottom: 10px; }

/* 打印：只输出二维码标签 */
@media print {
  body * { visibility: hidden; }
  #qrMask, #qrMask * { visibility: visible; }
  #qrMask { position: absolute; inset: 0; background: #fff; align-items: center; }
  .sheet { border-radius: 0; max-height: none; box-shadow: none; }
  .sheet-foot { display: none; }
  .qr-box #qrCode { border: none; }
}
