/* 咕力通 · 设计令牌（与《设计规范 v1.0》一致） */
:root {
  --bg: #F2F7F8;
  --card: #ffffff;
  --ink: #0F172A;
  --ink2: #475569;
  --ink3: #94A3B8;
  --line: #DCE6EB;
  --line2: #CBD5E1;
  --brand: #0E7490;
  --brand-soft: #CFFAFE;
  --brand-dark: #155E75;
  --brown: #155E75;
  --green: #4c8c6b;
  --green-soft: #e6f1ea;
  --red: #c4543f;
  --red-soft: #fbe6e2;
  --gold: #b8884a;
  --gold-soft: #f8efdf;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Inter", sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

/* hidden 属性必须真的藏起来：.btn 这类作者样式会盖过浏览器默认的 [hidden] 规则 */
[hidden] { display: none !important; }

.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ------------------------------------------------------------------ 布局 */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 216px; flex: 0 0 216px;
  background: var(--brown);
  display: flex; flex-direction: column;
  padding: 18px 12px 12px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; letter-spacing: 1px;
}
.brand-text { color: #F0FAFC; font-size: 15px; font-weight: 600; line-height: 1.2; }
.brand-text small { display: block; font-size: 10px; color: #7FC9DA; font-weight: 400; margin-top: 3px; letter-spacing: .5px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: #BFE2EC; font-size: 12.5px; text-align: left;
  transition: background .14s, color .14s;
}
/* 没权限的菜单直接消失（hidden 属性会被 display:flex 盖掉，得显式写） */
.nav-item[hidden] { display: none; }
.nav-item:hover { background: #1D6E88; color: #F0FAFC; }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav-ico { width: 16px; text-align: center; font-size: 12px; opacity: .85; }
.nav-disabled { color: #6FA9BC; cursor: default; }
.nav-disabled:hover { background: none; color: #6FA9BC; }
.nav-sep { height: 1px; background: #2B7C96; margin: 10px 6px; }
.nav-label { font-size: 10px; color: #6FA9BC; padding: 2px 10px 6px; letter-spacing: .5px; }

.sb-foot {
  display: flex; align-items: center; gap: 7px;
  padding: 10px 10px 4px; border-top: 1px solid #2B7C96;
  color: #7FC9DA; font-size: 10.5px;
}
.dot-live { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: 56px; flex: 0 0 56px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.page-head h1 { font-size: 15px; font-weight: 600; letter-spacing: .2px; }
.page-head p { font-size: 11px; color: var(--ink3); margin-top: 2px; }
.ph-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
/* 账套标识：门店账号一眼知道自己只看本店，不会误以为数据丢了 */
.scope-pill {
  flex: none; font-size: 10px; line-height: 1.6; padding: 0 7px; border-radius: 99px;
  background: #E6F7FA; color: #0F5468; border: 1px solid #A5E3EC; white-space: nowrap;
}
.scope-pill.hq { background: #E6F4F8; color: #155E75; border-color: #BFE0EA; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.view { flex: 1; overflow-y: auto; padding: 18px 22px 40px; }

/* ------------------------------------------------------------------ 通用控件 */
.btn {
  height: 32px; padding: 0 14px; border-radius: 8px;
  font-size: 12.5px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .14s, border-color .14s, opacity .14s;
  white-space: nowrap;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: #0C647C; }
.btn-ghost { border: 1px solid var(--line2); color: var(--ink2); background: var(--card); }
.btn-ghost:hover { border-color: #B7CDD6; background: #F7FAFB; }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-danger:hover { background: #f8dad4; }
.btn-sm { height: 26px; padding: 0 10px; font-size: 11.5px; border-radius: 6px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.input, .select {
  height: 34px; padding: 0 11px; border-radius: 8px;
  border: 1px solid var(--line2); background: var(--card);
  font-size: 12.5px; outline: none; transition: border-color .14s;
  min-width: 0;
}
.input:focus, .select:focus { border-color: var(--brand); }
.input::placeholder { color: #BFE2EC; }
textarea.input { height: auto; padding: 9px 11px; resize: vertical; line-height: 1.6; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 11.5px; color: var(--ink2); font-weight: 500; }
.field .hint { font-size: 10.5px; color: var(--ink3); }

.search { position: relative; }
.search .input { padding-left: 30px; width: 220px; }
.search::before {
  content: "⌕"; position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--ink3); font-size: 14px;
}

/* ------------------------------------------------------------------ 卡片 / KPI */
.card {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 14px 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; }
.card-title { font-size: 12.5px; font-weight: 600; letter-spacing: .2px; }
.card-sub { font-size: 10.5px; color: var(--ink3); }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi-label { font-size: 11px; color: var(--ink3); }
.kpi-value { font-size: 24px; font-weight: 600; margin-top: 6px; letter-spacing: -.3px; }
.kpi-value small { font-size: 11px; font-weight: 400; color: var(--ink3); margin-left: 4px; }
.kpi-foot { font-size: 10.5px; color: var(--ink3); margin-top: 5px; }
.kpi-foot.warn { color: var(--red); }
.kpi-foot.ok { color: var(--green); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.grid-3-1 { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr); gap: 12px; }

/* ------------------------------------------------------------------ 表格 */
.table-wrap { overflow-x: auto; }
table.tb { width: 100%; border-collapse: collapse; font-size: 12px; }
.tb thead th {
  text-align: left; font-size: 11px; font-weight: 500; color: var(--ink3);
  padding: 0 10px 9px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tb tbody td {
  padding: 11px 10px; border-bottom: 1px solid #F1F6F8;
  color: var(--ink2); white-space: nowrap; vertical-align: middle;
}
.tb tbody tr:hover { background: #F7FAFB; }
.tb tbody tr:last-child td { border-bottom: none; }
.tb .strong { color: var(--ink); font-weight: 600; }
.tb .muted { color: var(--ink3); font-size: 11px; }
.tb .right { text-align: right; }
.tb .blank { text-align: center; color: var(--ink3); padding: 40px 0; font-size: 12px; }

.tag {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 8px; border-radius: 5px;
  font-size: 10.5px; white-space: nowrap;
}
.tag-plain { background: #F1F6F8; color: var(--ink2); }
.tag-green { background: var(--green-soft); color: var(--green); }
.tag-red { background: var(--red-soft); color: var(--red); }
.tag-gold { background: var(--gold-soft); color: var(--gold); }
.tag-brand { background: var(--brand-soft); color: var(--brand-dark); }

.chip-row { display: flex; flex-wrap: wrap; gap: 5px; }

/* ------------------------------------------------------------------ 弹窗 */
/* z-index 层级：底部导航 50 < 抽屉 70/80 < 弹窗 100 < 登录 200 < toast 9999
   （不设的话手机端底部导航会盖住弹窗的「确认」按钮） */
.modal-root { position: fixed; inset: 0; display: none; z-index: 100; }
.modal-root.open { display: block; }
.modal-mask { position: absolute; inset: 0; background: rgba(15, 35, 44, .42); }
.modal {
  position: relative; margin: 6vh auto 0;
  width: 720px; max-width: calc(100vw - 40px); max-height: 86vh;
  background: var(--card); border-radius: 14px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 50px rgba(15, 35, 44, .22);
}
.modal.narrow { width: 480px; }
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h2 { font-size: 14px; font-weight: 600; }
.modal-head p { font-size: 11px; color: var(--ink3); margin-top: 3px; }
.modal-close { color: var(--ink3); font-size: 18px; line-height: 1; padding: 4px 8px; border-radius: 6px; }
.modal-close:hover { background: #F1F6F8; }
.modal-body { padding: 18px 20px; overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.modal-foot {
  padding: 13px 20px; border-top: 1px solid var(--line);
  display: flex; justify-content: flex-end; gap: 8px; background: #F7FAFB;
  flex: 0 0 auto;
  box-shadow: 0 -6px 16px rgba(15, 35, 44, .06);
}

.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: span 3; }

/* 弹窗内的错误条：提交失败必须看得见，别再让用户以为「点了没反应」 */
.modal-err {
  flex: 0 0 auto;
  margin: 0 20px 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.6;
  color: #8f3a2c;
  background: #fbeee9;
  border: 1px solid #ecc9bd;
  border-left: 3px solid #c0563f;
}
.modal-err[hidden] { display: none; }

/* 字段级提示：红色=不合格，绿色=可用 */
.hint.hint-err { color: #a8462f; font-weight: 500; }
.hint.hint-ok { color: #2f5d47; }
.field .input.bad, .field .select.bad { border-color: #d08974; background: #fdf6f3; }

/* ------------------------------------------------------------------ 提示 */
.toast-wrap { position: fixed; top: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; pointer-events: none; }
.toast {
  padding: 10px 14px; border-radius: 9px; font-size: 12px;
  background: var(--brown); color: #F0FAFC;
  box-shadow: 0 8px 20px rgba(15, 35, 44, .2);
  animation: slide-in .18s ease-out;
  max-width: 360px;
}
.toast.ok { background: #2f5d47; }
.toast.err { background: #8f3a2c; }
@keyframes slide-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ 空态 / 骨架 */
.empty { text-align: center; padding: 50px 0; color: var(--ink3); font-size: 12px; }
.empty b { display: block; font-size: 13px; color: var(--ink2); margin-bottom: 6px; font-weight: 500; }

/* ------------------------------------------------------------------ 矩阵 */
.matrix { border-collapse: collapse; font-size: 11.5px; }
.matrix th, .matrix td { border: 1px solid var(--line); padding: 7px 12px; text-align: center; white-space: nowrap; }
.matrix thead th { background: #EFF5F7; color: var(--ink2); font-weight: 500; }
.matrix tbody th { background: #EFF5F7; color: var(--ink2); font-weight: 500; }
.matrix .cell-0 { color: #8FB9C6; }
.matrix .cell-total { background: #F3FAFB; font-weight: 600; color: var(--ink); }
.matrix .col-total { background: #F3FAFB; font-weight: 600; color: var(--ink); }

/* ------------------------------------------------------------------ 条状 */
.bar-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.bar-name { width: 110px; flex: 0 0 110px; font-size: 12px; color: var(--ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 6px; border-radius: 3px; background: #E4EEF2; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; background: var(--brand); }
.bar-val { width: 64px; text-align: right; font-size: 11.5px; color: var(--ink2); }

.row-actions { display: flex; gap: 6px; }
.link { color: var(--brand-dark); font-size: 11.5px; }
.link:hover { text-decoration: underline; }

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-3-1 { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .span-3 { grid-column: span 2; }
}

/* ------------------------------------------------------------------ 销售开单 */
.sale-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 12px; align-items: start; }

.scan-bar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 12px 14px; background: #F3FAFB; border: 1px solid var(--line);
  border-radius: 10px; margin-bottom: 12px;
}
.scan-bar .input { width: 240px; background: #fff; }
.scan-tip { font-size: 10.5px; color: var(--ink3); }

.sale-table td { vertical-align: middle; }
.sale-table .qty-box { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--line2); border-radius: 7px; overflow: hidden; background: #fff; }
.sale-table .qty-box button { width: 24px; height: 26px; font-size: 13px; color: var(--ink2); background: #F7FAFB; }
.sale-table .qty-box button:hover { background: #F1F6F8; }
.sale-table .qty-box input { width: 40px; height: 26px; text-align: center; border: none; border-left: 1px solid var(--line); border-right: 1px solid var(--line); font-size: 12px; }
.sale-table .price-in { width: 74px; height: 26px; padding: 0 8px; text-align: right; border: 1px solid var(--line2); border-radius: 6px; font-size: 12px; background: #fff; }
.sale-table .price-in:focus { outline: none; border-color: var(--brand); }

/* 行内零售价：顾客问原价、店员改完价核对，都靠这一行小字 */
.sale-table .line-retail {
  margin-top: 2px;
  font-size: 10.5px;
  color: var(--ink3);
  white-space: nowrap;
  cursor: pointer;
  letter-spacing: .1px;
}
.sale-table .line-retail:hover { color: var(--brand); }
.sale-table .line-retail-cut { color: var(--red); font-weight: 600; }
.sale-table .line-retail-none { color: #c0392b; font-style: italic; }
.sale-table .del { color: var(--ink3); font-size: 14px; padding: 2px 6px; border-radius: 5px; }
.sale-table .del:hover { background: var(--red-soft); color: var(--red); }
.sale-table .warn { color: var(--red); font-size: 10.5px; }

.sale-side { position: sticky; top: 0; }
.sum-total { font-size: 30px; font-weight: 600; letter-spacing: -.5px; line-height: 1.15; }
.sum-total small { font-size: 12px; font-weight: 400; color: var(--ink3); margin-left: 4px; }
.sum-row { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink3); padding: 5px 0; }
.sum-row b { color: var(--ink2); font-weight: 600; }

.pay-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pay-chip {
  height: 30px; padding: 0 12px; border-radius: 8px; font-size: 11.5px;
  border: 1px solid var(--line2); background: #fff; color: var(--ink2);
}
.pay-chip.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

.sale-submit { width: 100%; height: 44px; font-size: 14px; border-radius: 10px; }

/* 规格选择器 */
.picker-cell {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 6px; text-align: center;
  background: #fff; min-width: 84px;
}
.picker-cell .c-name { font-size: 10.5px; color: var(--ink3); }
.picker-cell .c-qty { font-size: 15px; font-weight: 600; margin-top: 2px; }
.picker-cell .c-add { font-size: 10px; color: var(--brand-dark); margin-top: 2px; }
.picker-cell:hover { border-color: var(--brand); background: var(--brand-soft); }
.picker-cell.out { opacity: .45; cursor: not-allowed; }
.picker-cell.out:hover { border-color: var(--line); background: #fff; }

/* 撤销栏 */
.void-note { background: var(--red-soft); border-radius: 9px; padding: 10px 12px; font-size: 11px; color: #8f3a2c; line-height: 1.75; }
.reason-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.reason-chip { height: 28px; padding: 0 11px; border-radius: 7px; font-size: 11.5px; border: 1px solid var(--line2); background: #fff; color: var(--ink2); }
.reason-chip.on { background: var(--red); border-color: var(--red); color: #fff; }

/* ---------- 报表统计 ---------- */
.rep-chart { display: flex; align-items: flex-end; gap: 4px; height: 168px; padding-top: 6px; }
.rep-bar-wrap {
  flex: 1 1 0; min-width: 6px; height: 100%; display: flex; flex-direction: column;
  justify-content: flex-end; align-items: center; gap: 6px;
}
.rep-bar {
  width: 100%; max-width: 34px; min-height: 2px; border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, #2FB0C9, var(--brand));
}
.rep-bar-wrap:hover .rep-bar { background: var(--brand-dark); }
.rep-bar-x { font-size: 9.5px; color: var(--ink3); white-space: nowrap; height: 12px; }
.rep-track { height: 6px; background: #E4EEF2; border-radius: 999px; overflow: hidden; }
.rep-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), #2FB0C9); }
.rep-2col { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 12px; }

@media (max-width: 980px) {
  .rep-2col { grid-template-columns: minmax(0, 1fr); }
  .rep-chart { height: 140px; }
}

/* ================================================================== 登录页 */
.login-root { position: fixed; inset: 0; z-index: 200; display: none; }
.login-root.open { display: flex; align-items: center; justify-content: center; }
.login-root::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(1100px 520px at 15% 0%, #1D6E88 0%, transparent 60%),
    radial-gradient(800px 500px at 100% 100%, #0E4A5E 0%, transparent 55%),
    var(--brown);
}
.login-card {
  position: relative; width: 360px; max-width: calc(100vw - 32px);
  background: var(--card); border-radius: 16px; padding: 26px 24px 20px;
  box-shadow: 0 26px 60px rgba(0, 0, 0, .3);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-title { font-size: 19px; font-weight: 600; letter-spacing: 1px; }
.login-sub { font-size: 11px; color: var(--ink3); margin-top: 2px; letter-spacing: .5px; }
.login-label { display: block; font-size: 11.5px; color: var(--ink2); margin: 0 0 6px; font-weight: 500; }
.login-input { width: 100%; height: 40px; margin-bottom: 14px; font-size: 14px; }
.login-btn { width: 100%; height: 42px; justify-content: center; font-size: 14px; letter-spacing: 2px; margin-top: 4px; }
.login-tip { min-height: 17px; font-size: 11.5px; color: var(--red); margin-bottom: 6px; }
.login-reg {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; flex-wrap: wrap; margin-top: 14px;
  padding-top: 14px; border-top: 1px dashed var(--line);
}
.login-reg-label { font-size: 11.5px; color: var(--ink3); }
.login-foot { text-align: center; font-size: 10.5px; color: var(--ink3); margin-top: 16px; letter-spacing: .5px; }
/* 登录页上的注册弹窗：登录层是 200，弹窗要临时压过它 */
.modal-root.above-login { z-index: 300; }

/* ================================================================== 侧栏用户卡 */
.sb-user {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; margin: 6px 2px 8px;
  background: #114F65; border-radius: 9px;
}
.sb-user-avatar {
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 12px;
  display: flex; align-items: center; justify-content: center; font-weight: 600;
}
.sb-user-info { flex: 1; min-width: 0; }
.sb-user-name { color: #F0FAFC; font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-role { color: #7FC9DA; font-size: 10px; margin-top: 2px; }
.sb-user-out { color: #7FC9DA; font-size: 13px; padding: 4px; border-radius: 6px; }
.sb-user-out:hover { background: #1D6E88; color: var(--brand); }

.sb-close, .top-menu, .tabbar, .drawer-mask { display: none; }

/* ================================================================== 权限页 */
.perm-chip {
  display: inline-block; padding: 2px 7px; margin: 2px 3px 2px 0;
  background: #F1F6F8; border: 1px solid var(--line);
  border-radius: 5px; font-size: 10.5px; color: var(--ink2);
}
.row-off { opacity: .5; }
.btn-danger-ghost { border: 1px solid #efd0c8; color: var(--red); background: var(--card); }
.btn-danger-ghost:hover { background: var(--red-soft); }
.code-inline {
  background: #F1F6F8; border: 1px solid var(--line); border-radius: 4px;
  padding: 1px 5px; font-size: 11px; color: var(--brand-dark);
}


/* ================================================================== 备份与导出 */
.backup-note { font-size: 12px; color: var(--ink2); line-height: 1.9; }
.export-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.export-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px 13px; background: #FAFCFD; }
.export-name { font-size: 12.5px; font-weight: 600; }
.export-desc { font-size: 10.5px; color: var(--ink3); margin-top: 3px; }
.export-ctl { display: flex; align-items: center; gap: 6px; margin-top: 9px; flex-wrap: wrap; }
.export-ctl .input { height: 30px; font-size: 11.5px; flex: 1 1 110px; min-width: 0; }

@media (max-width: 900px) {
  .export-grid { grid-template-columns: minmax(0, 1fr); }
  .export-ctl .input { height: 36px; font-size: 16px; }
}

/* ================================================================== 手机 / 平板 */
@media (max-width: 900px) {
  .app { height: 100dvh; }

  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 256px; flex-basis: 256px;
    z-index: 80; transform: translateX(-102%);
    transition: transform .22s ease;
    padding-top: max(18px, env(safe-area-inset-top));
  }
  .sidebar.open { transform: none; box-shadow: 18px 0 50px rgba(0, 0, 0, .35); }
  .sb-close { display: block; margin-left: auto; color: #7FC9DA; font-size: 20px; line-height: 1; padding: 2px 6px; }
  .drawer-mask { display: block; position: fixed; inset: 0; z-index: 70; background: rgba(10, 30, 38, .45); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .drawer-mask.open { opacity: 1; pointer-events: auto; }

  .main { width: 100%; }

  .topbar {
    height: auto; min-height: 52px; flex: 0 0 auto;
    padding: max(8px, env(safe-area-inset-top)) 12px 8px;
    gap: 10px; align-items: center;
  }
  .top-menu {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; flex: 0 0 34px; border-radius: 8px;
    border: 1px solid var(--line2); background: var(--card); color: var(--ink2); font-size: 15px;
  }
  .page-head { flex: 1; min-width: 0; }
  .page-head h1 { font-size: 15px; }
  .page-head p { display: none; }
  .top-actions { gap: 6px; overflow-x: auto; max-width: 52%; padding-bottom: 1px; }
  .top-actions::-webkit-scrollbar { display: none; }
  .top-actions .btn { height: 32px; padding: 0 10px; font-size: 12px; }

  .view { padding: 12px 12px calc(72px + env(safe-area-inset-bottom)); }

  /* 底部导航 */
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: rgba(255, 255, 255, .97); backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tab-item {
    flex: 1; height: 56px; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 3px;
    color: var(--ink3); font-size: 10px;
  }
  .tab-item i { font-style: normal; font-size: 16px; line-height: 1; }
  .tab-item.active { color: var(--brand); font-weight: 600; }
  .tab-item[hidden] { display: none; }

  /* 指标卡：两列 */
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px; margin-bottom: 10px; }
  .kpi { padding: 11px 12px; }
  .kpi-value { font-size: 19px; margin-top: 4px; }
  .kpi-label, .kpi-foot { font-size: 10px; }

  .grid-2, .grid-3-1, .rep-2col, .sale-layout { grid-template-columns: minmax(0, 1fr) !important; }
  .scan-tip { display: none; }  /* 手机上这行提示太占地方 */

  .card { padding: 12px; border-radius: 10px; }
  .card-head { flex-direction: column; align-items: flex-start; gap: 3px; }

  /* 表格：横向滑动，不挤成蚂蚁字 */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -12px; padding: 0 12px; }
  table.tb { font-size: 12.5px; min-width: 520px; }
  .tb tbody td { padding: 10px 8px; }
  .tb thead th { padding: 0 8px 8px; }

  /* 触屏尺寸 */
  .btn { height: 36px; padding: 0 12px; }
  .btn-sm { height: 30px; padding: 0 9px; font-size: 11.5px; }
  .input, .select { height: 40px; font-size: 16px; }  /* 16px 以下 iOS 会自动放大页面 */
  textarea.input { font-size: 16px; }
  .search .input { width: 100%; }
  .search { flex: 1 1 160px; }

  /* 弹窗：手机上从底部整屏弹出 */
  .modal {
    margin: 0; width: 100%; max-width: 100%;
    height: 100dvh; max-height: 100dvh; border-radius: 0;
  }
  .modal.narrow { width: 100%; }
  .modal-head { padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top)); }
  .modal-body { padding: 14px 16px; }
  .modal-foot {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    position: sticky; bottom: 0; background: var(--card);
  }
  .modal-foot .btn { flex: 1; height: 44px; justify-content: center; font-size: 14px; }
  .toast-wrap { bottom: calc(68px + env(safe-area-inset-bottom)) !important; left: 12px; right: 12px; align-items: center; }

  .form-grid { grid-template-columns: minmax(0, 1fr) !important; }
}

@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .kpi-value { font-size: 17px; }
  .rep-chart { height: 120px; }
}

/* 触屏设备：去掉 hover 的粘滞感，按下给反馈 */
@media (hover: none) {
  .tb tbody tr:hover { background: transparent; }
  .btn:active { opacity: .75; }
}

/* ================================================================== 卡片式陈列（v1.1 视觉改版） */
/* 销售单据卡片 */
.ocard-list { display: flex; flex-direction: column; gap: 10px; }
.ocard {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 16px; cursor: pointer; transition: box-shadow .15s, border-color .15s;
}
.ocard:hover { box-shadow: 0 3px 12px rgba(15,35,44,.08); border-color: var(--line2); }
.ocard-icon {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700;
}
.ocard-icon.ok { background: #E0F5F9; color: #0E7490; }
.ocard-icon.debt { background: var(--gold-soft); color: var(--gold); }
.ocard-icon.void { background: #F1F6F8; color: var(--ink3); }
.ocard-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ocard-title { font-size: 15px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ocard-line { font-size: 12px; color: var(--ink3); display: flex; gap: 10px; flex-wrap: wrap; }
.ocard-right { text-align: right; flex: 0 0 auto; display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }
.ocard-qty { font-size: 12.5px; color: var(--ink2); }
.ocard-amt { font-size: 16.5px; font-weight: 700; color: var(--gold); }
.ocard-acts { display: flex; gap: 6px; margin-top: 4px; }
.ocard.voided { opacity: .62; }

/* 商品图文卡片 */
.prod-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 12px; }
.prod-card {
  display: flex; gap: 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px; cursor: pointer; transition: box-shadow .15s, border-color .15s;
}
.prod-card:hover { box-shadow: 0 3px 12px rgba(15,35,44,.08); border-color: var(--line2); }
.prod-card.inactive { opacity: .65; }
.prod-img {
  width: 92px; height: 92px; flex: 0 0 92px; border-radius: 10px; object-fit: cover;
  background: #F1F6F8;
}
.prod-img-ph {
  width: 92px; height: 92px; flex: 0 0 92px; border-radius: 10px; background: #F1F6F8;
  display: flex; align-items: center; justify-content: center; color: var(--ink3);
  font-size: 11.5px; text-align: center; line-height: 1.5; padding: 6px;
}
.prod-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.prod-name { font-size: 15.5px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prod-code { font-size: 12.5px; color: var(--ink3); }
.prod-prices { display: flex; gap: 20px; margin: 5px 0 2px; }
.prod-price b { display: block; font-size: 14.5px; color: var(--gold); font-weight: 600; }
.prod-price span { font-size: 11px; color: var(--ink3); }
.prod-foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--ink2); margin-top: auto; }

/* 商品详情页 */
.pd-back {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink2);
  background: none; border: none; cursor: pointer; padding: 4px 0; margin-bottom: 10px;
}
.pd-back:hover { color: var(--ink); }
.pd-head { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.pd-img-wrap { position: relative; flex: 0 0 auto; }
.pd-img { width: 132px; height: 132px; border-radius: 12px; object-fit: cover; background: #F1F6F8; }
.pd-img-ph {
  width: 132px; height: 132px; border-radius: 12px; background: #F1F6F8;
  display: flex; align-items: center; justify-content: center; color: var(--ink3);
  font-size: 12px; text-align: center; line-height: 1.6; padding: 10px;
}
.pd-img-edit {
  position: absolute; left: 0; right: 0; bottom: 0; text-align: center;
  background: rgba(15,35,44,.55); color: #fff; font-size: 11px; padding: 4px 0;
  border-radius: 0 0 12px 12px; cursor: pointer;
}
.pd-info { flex: 1; min-width: 260px; }
.pd-title { font-size: 19px; font-weight: 700; }
.pd-sub { font-size: 12.5px; color: var(--ink3); margin-top: 3px; }
.pd-prices { display: flex; gap: 26px; margin-top: 12px; flex-wrap: wrap; }
.pd-price b { display: block; font-size: 16px; font-weight: 700; color: var(--gold); }
.pd-price span { font-size: 11.5px; color: var(--ink3); }
.pd-sect { margin-top: 14px; }
.pd-sect-title { font-size: 13.5px; font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.pd-mini-kpis { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.pd-mini {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 16px; min-width: 120px;
}
.pd-mini b { display: block; font-size: 17px; font-weight: 700; }
.pd-mini span { font-size: 11.5px; color: var(--ink3); }
.cust-row {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px;
}
.cust-row .cname { font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cust-row .cstat { font-size: 12.5px; color: var(--ink2); white-space: nowrap; }

/* 手机端卡片适配 */
@media (max-width: 900px) {
  .prod-list { grid-template-columns: 1fr; }
  .prod-img, .prod-img-ph { width: 76px; height: 76px; flex-basis: 76px; }
  .pd-head { gap: 12px; }
  .pd-img, .pd-img-ph { width: 96px; height: 96px; }
  .ocard { flex-wrap: wrap; }
  .ocard-right { flex-direction: row; align-items: center; gap: 10px; width: 100%; justify-content: space-between; }
}

/* ---------------------------------------------------------- 前台收银：会员卡 */
/* 收银台的核心动作是「输手机号 → 认人 → 记积分」，所以会员卡要一眼看完：
   是谁、多少分、这单能加多少、有没有欠款。数字比文字大，站着也看得清。 */
.mem-card {
  margin-top: 8px;
  padding: 11px 12px;
  border: 1px solid var(--line2);
  border-left: 3px solid var(--brand);
  border-radius: 10px;
  background: linear-gradient(180deg, #FAFCFD, #F3FAFB);
}
.mem-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.mem-name { font-size: 14px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 6px; }
.mem-meta { margin-top: 3px; font-size: 11px; color: var(--ink3); letter-spacing: .2px; }
.mem-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px dashed var(--line2);
}
.mem-stats > div { display: flex; flex-direction: column; gap: 1px; }
.mem-stats b { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); line-height: 1.2; }
.mem-stats span { font-size: 10px; color: var(--ink3); }
.mem-stats b.mem-gain { color: var(--brand-dark); }
.mem-stats b.mem-debt { color: var(--red); }
.mem-recent {
  margin-top: 9px;
  font-size: 10.5px;
  color: var(--ink3);
  line-height: 1.5;
}

/* 同尾号多个候选：列出来让人点，绝不替收银员猜 */
.mem-list { margin-top: 7px; display: flex; flex-direction: column; gap: 5px; }
.mem-list-tip { font-size: 10.5px; color: var(--gold); }
.mem-opt {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding: 8px 10px; text-align: left;
  border: 1px solid var(--line2); border-radius: 9px; background: #fff;
  transition: border-color .12s, background .12s;
}
.mem-opt:hover { border-color: var(--brand); background: var(--brand-soft); }
.mem-opt-name { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.mem-opt-meta { font-size: 10.5px; color: var(--ink3); font-variant-numeric: tabular-nums; }

.mem-empty {
  margin-top: 7px; padding: 8px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 11px; color: var(--ink3);
  background: #F0F5F7; border-radius: 9px; border: 1px dashed var(--line2);
}

/* 开单成功页的一句积分播报：当面念给顾客听 */
.sale-points-done {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 11.5px;
}

/* 扫码回显：连续扫货时不用弹窗打断，眼睛扫一下就知道扫中了什么 */
.scan-echo {
  min-height: 0;
  font-size: 11.5px;
  color: var(--ink2);
  padding: 0 2px;
}
.scan-echo:not(:empty) {
  margin: -6px 0 10px;
  padding: 7px 12px;
  border-radius: 9px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  animation: echo-in .18s ease-out;
}
@keyframes echo-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

/* 店内收款码：全屏铺开给客户扫，金额要能隔着柜台看清 */
.qr-overlay {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(10, 30, 38, .72);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.qr-card {
  background: #fff; border-radius: 20px;
  padding: 26px 30px 22px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .32);
  max-width: 92vw;
}
.qr-title { font-size: 13px; color: var(--ink3); letter-spacing: 2px; }
.qr-amount {
  font-size: 40px; font-weight: 800; color: var(--ink);
  margin: 4px 0 14px; letter-spacing: -1px;
}
.qr-img {
  width: 240px; height: 240px; object-fit: contain;
  border-radius: 12px; background: #fff; border: 1px solid var(--line);
}
.qr-none {
  width: 240px; min-height: 200px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--ink3); font-size: 12px; line-height: 1.7;
  border: 1px dashed var(--line2); border-radius: 14px;
}
.qr-tip { margin-top: 12px; font-size: 11px; color: var(--ink3); }
@media (max-width: 640px) {
  .qr-amount { font-size: 32px; }
  .qr-img { width: 200px; height: 200px; }
}

/* ===== 收银台 · 小票机状态条 ===== */
.printer-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border-radius: 9px;
  font-size: 11.5px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 10px;
  transition: background .15s, border-color .15s;
  user-select: none;
}
.printer-bar .pb-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.printer-bar .pb-txt {
  flex: 1;
  font-weight: 600;
  display: flex;
  align-items: baseline;
  gap: 6px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.printer-bar .pb-txt i { font-style: normal; font-weight: 400; opacity: .62; font-size: 10.5px; }
.printer-bar .pb-extra { font-size: 10.5px; opacity: .8; flex: none; }
.printer-bar .pb-btn {
  flex: none;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 10.5px;
  cursor: pointer;
  opacity: .85;
}
.printer-bar .pb-btn:hover { opacity: 1; background: rgba(0,0,0,.04); }

.printer-bar.pb-ok { background: var(--green-soft); border-color: #cfe3d7; color: #2f6b4d; }
.printer-bar.pb-ok .pb-dot { background: var(--green); box-shadow: 0 0 0 3px rgba(76,140,107,.16); }
.printer-bar.pb-busy { background: #fbf4e6; border-color: #eadcc0; color: #8a6725; }
.printer-bar.pb-busy .pb-dot { background: #b08540; animation: pbPulse 1s infinite; }
.printer-bar.pb-err { background: var(--red-soft); border-color: #f0d5cf; color: #a8412c; }
.printer-bar.pb-err .pb-dot { background: var(--red); }
.printer-bar.pb-off { background: #EEF3F6; border-color: #D7E1E8; color: #64748B; }
.printer-bar.pb-off .pb-dot { background: #9AAAB6; }

@keyframes pbPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

/* ---------------------------------------------------------- 单据里的商品缩略图
   对货靠款式，不靠款号猜。40px 足够认出是哪件，点一下看大图。 */
.tb-img-cell { width: 52px; padding-right: 0; }
.tb-thumb {
  width: 40px; height: 40px; border-radius: 8px; object-fit: cover;
  background: #F1F6F8; display: block; cursor: zoom-in;
}
.tb-thumb-ph {
  display: flex; align-items: center; justify-content: center;
  color: var(--ink3); font-size: 10px; cursor: default;
}

/* 看大图的浮层：独立一层，不占弹窗栈（弹窗是单层替换的） */
.peek-mask {
  position: fixed; inset: 0; z-index: 320; background: rgba(8, 20, 26, .74);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  cursor: zoom-out; animation: peekIn .12s ease-out;
}
.peek-box {
  max-width: 88vw; max-height: 88vh; background: #fff; border-radius: 14px;
  padding: 10px; box-shadow: 0 20px 60px rgba(8, 20, 26, .35);
}
.peek-box img {
  max-width: 100%; max-height: 74vh; border-radius: 10px;
  display: block; object-fit: contain; margin: 0 auto;
}
.peek-cap { text-align: center; font-size: 12px; color: var(--ink3); padding-top: 8px; }
@keyframes peekIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------------------------------------------------------- 门店待收货：共欠条 */
.debt-bar {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line);
  border-left: 3px solid var(--green); border-radius: var(--radius);
  padding: 13px 16px; margin-bottom: 12px;
}
.debt-bar.owe { border-left-color: var(--red); }
.db-main { min-width: 170px; }
.db-label { font-size: 11px; color: var(--ink3); }
.db-num { font-size: 25px; font-weight: 800; line-height: 1.3; color: var(--green); }
.debt-bar.owe .db-num { color: var(--red); }
.db-num small { font-size: 12px; font-weight: 600; margin-left: 3px; }
.db-meta {
  flex: 1; min-width: 210px; font-size: 12px; color: var(--ink2);
  display: flex; flex-direction: column; gap: 3px;
}
.db-meta b { font-weight: 600; color: var(--ink); }

@media (max-width: 640px) {
  .tb-img-cell { width: 44px; }
  .tb-thumb { width: 34px; height: 34px; border-radius: 6px; }
  .debt-bar { gap: 12px; padding: 12px 13px; }
  .db-num { font-size: 21px; }
  .db-meta { min-width: 0; }
}
