:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --bg: #f4f6fa;
  --card: #ffffff;
  --border: #e4e8ef;
  --border-2: #d3d9e3;
  --text: #1f2733;
  --text-2: #5a6878;
  --text-3: #93a0b0;
  --success: #15a34a;
  --success-soft: #eaf7ef;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warn: #d97706;
  --warn-soft: #fdf4e7;
  --radius: 10px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--primary); text-decoration: none; }

/* ---------------- 登录页 ---------------- */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, #eef3fb 0%, #f7f9fc 100%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: 0 8px 32px rgba(31, 39, 51, .06);
}

.login-brand { text-align: center; margin-bottom: 26px; }

.brand-mark {
  width: 52px; height: 52px;
  margin: 0 auto 12px;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  font-size: 24px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-brand h1 { font-size: 18px; font-weight: 500; margin: 0 0 4px; }
.login-brand p { margin: 0; font-size: 13px; color: var(--text-3); }

.login-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 20px;
  margin: 4px 0 8px;
}

.login-wrap {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* ---------------- 页脚（备案号，工信部要求可点击） ---------------- */

.site-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 10px;
  margin-top: 18px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-3);
  text-align: center;
}
.site-foot a {
  color: var(--text-3);
  text-decoration: none;
}
.site-foot a:hover { color: var(--primary); text-decoration: underline; }
.site-foot .site-foot-ver { opacity: .7; }
.site-foot .site-foot-ver:empty { display: none; }

/* ---------------- 通用控件 ---------------- */

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 4px; font-weight: 400; }

input[type="text"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

textarea { resize: vertical; min-height: 64px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }

.btn-danger { color: var(--danger); border-color: #f0c4c4; }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 8px 8px 0; }
.btn-group .btn.active { background: var(--primary); border-color: var(--primary); color: #fff; z-index: 1; }

/* ---------------- 布局 ---------------- */

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

.topbar {
  height: 58px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar .logo {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex: none;
}

.topbar h1 { font-size: 15px; font-weight: 500; margin: 0; flex: 1; }
.topbar .sub { font-size: 12px; color: var(--text-3); font-weight: 400; margin-left: 8px; }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-2);
}
.user-chip .role {
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 20px;
  padding: 1px 9px;
  font-size: 12px;
}

.user-chip .avatar { display: none; }

/* 移动端底部导航：桌面端不显示 */
.tabbar { display: none; }

.layout { flex: 1; display: flex; align-items: stretch; }

.sidenav {
  width: 178px;
  flex: none;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  font-size: 14px;
  border: none;
  background: none;
  text-align: left;
  font-family: inherit;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: #f4f6fa; color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 500; }

/* 父项没权限、只有子项时用的分组标题（不可点）——例：财务看数据看板 */
.nav-group {
  padding: 14px 12px 4px;
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: .3px;
}

/* 左侧导航的二级子菜单（挂在「数据看板」下） */
.nav-sub { padding: 0 0 4px; }
.nav-subitem {
  position: relative;
  display: block;
  width: 100%;
  padding: 7px 12px 7px 24px;
  border: 0;
  border-radius: 8px;
  background: none;
  cursor: pointer;
  text-align: left;
  font: inherit;
  font-size: 13.5px;
  color: var(--text-3);
}
.nav-subitem::before {
  content: '';
  position: absolute;
  left: 13px;
  top: 50%;
  width: 5px;
  height: 5px;
  margin-top: -2.5px;
  border-radius: 50%;
  background: currentColor;
  opacity: .45;
}
.nav-subitem:hover { background: #f4f6fa; color: var(--text-2); }
.nav-subitem.active { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.nav-subitem.active::before { opacity: 1; }

/* 看板组三个子页的切换标签 */
.seg-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; }
.seg-tab {
  padding: 8px 15px;
  border: 1px solid var(--border-2);
  border-radius: 999px;
  background: var(--card);
  color: var(--text-2);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}
.seg-tab:hover { border-color: var(--primary); color: var(--primary); }
.seg-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* 未审批页签上的待办数量角标（订单管理） */
.seg-badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11.5px;
  line-height: 18px;
  text-align: center;
  vertical-align: 1px;
}
.seg-tab.active .seg-badge { background: rgba(255, 255, 255, .3); }

/* 待审批行的标记：左侧一条竖线 + 浅黄底，扫一眼就知道哪些没处理 */
tr.is-pending > td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
tr.is-pending { background: #fffbf0; }
.tag-pending { background: #fdf1d8; color: #96590b; }

/* 看板表格里的明细小字（司机看板按类别拆提成） */
.board-detail { font-size: 12px; color: var(--text-3); line-height: 1.55; margin-top: 4px; }
.board-detail b { color: var(--text-2); font-weight: 500; }

/* ---------------- 角色权限 ---------------- */

/* 「新增账号」弹窗里，选完角色后实时列出的功能清单 */
.perm-preview {
  border: 1px solid var(--border-2);
  border-radius: 8px;
  background: var(--bg);
  padding: 10px 12px;
  max-height: 190px;
  overflow: auto;
}
.perm-list { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 13px; line-height: 1.75; }
.perm-note { color: var(--text-3); font-size: 12.5px; line-height: 1.6; }

/* 「角色权限」页：按功能分组排勾选框 */
.rp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.perm-group { margin-top: 14px; }
.perm-group-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: .04em;
  margin-bottom: 7px;
}
.perm-items { display: flex; flex-wrap: wrap; gap: 8px; }
.perm-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  background: var(--card);
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  min-height: 40px;
}
.perm-item:hover { border-color: var(--primary); }
.perm-item input { margin: 0; width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.perm-item.is-disabled { opacity: .6; cursor: not-allowed; }
.perm-item.is-disabled input { cursor: not-allowed; }
.perm-item:has(input:checked) { border-color: var(--primary); color: var(--text); }

@media (max-width: 820px) {
  .perm-items { flex-direction: column; gap: 7px; }
  .perm-item { width: 100%; min-height: 46px; font-size: 14px; }
}

.content { flex: 1; padding: 20px; min-width: 0; }
.content-inner { max-width: 1180px; margin: 0 auto; }

.page-title { font-size: 17px; font-weight: 500; margin: 0 0 4px; }
.page-desc { font-size: 13px; color: var(--text-3); margin: 0 0 18px; }

/* ---------------- 卡片 ---------------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 14px;
  font-weight: 500;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ---------------- 表单栅格 ---------------- */

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.col-span-2 { grid-column: span 2; }

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ---------------- 统计卡 ---------------- */

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }

.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.kpi .label { font-size: 12px; color: var(--text-3); margin-bottom: 6px; }
.kpi .value { font-size: 24px; font-weight: 500; line-height: 1.2; }
.kpi .value small { font-size: 13px; font-weight: 400; color: var(--text-3); margin-left: 3px; }
.kpi .foot { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.kpi.is-primary .value { color: var(--primary); }
.kpi.is-success .value { color: var(--success); }
.kpi.is-warn .value { color: var(--warn); }
.kpi.is-muted .value { color: var(--text-3); }

/* ---------------- 表格 ---------------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  background: #fafbfd;
  color: var(--text-2);
  font-weight: 500;
  font-size: 12px;
  position: sticky;
  top: 0;
}

tbody tr:hover { background: #fafbfd; }
tbody tr.voided { color: var(--text-3); text-decoration: line-through; }
tbody tr.voided td { text-decoration: line-through; }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 12px;
  line-height: 18px;
}
.tag-in { background: var(--success-soft); color: var(--success); }
.tag-out { background: var(--warn-soft); color: var(--warn); }
.tag-free { background: #f1f3f7; color: var(--text-2); }
.tag-void { background: var(--danger-soft); color: var(--danger); }

.empty {
  text-align: center;
  color: var(--text-3);
  padding: 40px 16px;
  font-size: 13px;
}

/* ---------------- 筛选栏 ---------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 16px;
}
.filters .field { margin-bottom: 0; min-width: 130px; }
.filters .field.grow { flex: 1; min-width: 160px; }

/* 看板里的「按名字搜」输入框（带清空按钮） */
.kw-wrap { display: block; position: relative; }
.kw-wrap input[type=search] { width: 100%; padding-right: 34px; }
/* 去掉浏览器自带的清除叉，改用我们自己的按钮（各端样式才统一） */
.kw-wrap input[type=search]::-webkit-search-cancel-button,
.kw-wrap input[type=search]::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.kw-clear {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%;
  background: var(--border-2); color: var(--text-2);
  font-size: 13px; line-height: 1; cursor: pointer;
}
.kw-clear:hover { background: var(--border); color: var(--text); }
.kw-clear[hidden] { display: none; }

/* ---------------- 照片 ---------------- */

.photo-picker {
  display: block;
  border: 1px dashed var(--border-2);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  cursor: pointer;
  background: #fafbfd;
  transition: border-color .15s, background .15s;
}
.photo-picker .ico { display: none; }
.photo-picker .ico svg { width: 100%; height: 100%; }
.photo-picker:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.photo-picker input { display: none; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.photo-item { position: relative; padding-top: 100%; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.photo-item img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.photo-item .del {
  position: absolute;
  top: 4px; right: 4px;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

.thumb-count { color: var(--primary); cursor: pointer; font-size: 13px; }

/* ---------------- 弹窗 ---------------- */

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 26, 34, .45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-mask.show { display: flex; }

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 20px;
}

.modal h3 { font-size: 15px; font-weight: 500; margin: 0 0 16px; }
.modal.wide { max-width: 760px; }

/*
 * 审批弹窗里的客户下拉：.modal 有 overflow-y:auto（为了长内容能滚），
 * 而 .combo-list 是 absolute 定位 —— 会被裁掉、显示不全。
 * 实测：z-index 治不了 overflow 裁剪，得看这个弹窗是不是被裁的那一个。
 * 这里给审批弹窗加一个专用类，把 overflow 让开（内容本来就不高）。
 */
.modal.modal-approve { overflow: visible; max-height: none; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.86); display: none; align-items: center; justify-content: center; z-index: 200; }
.lightbox.show { display: flex; }
.lightbox img { max-width: 94vw; max-height: 90vh; border-radius: 8px; }

/* ---------------- 提示 ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 20px);
  background: #1f2733;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 300;
  max-width: 88vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

/* ---------------- 图表 ---------------- */

.chart { width: 100%; overflow-x: auto; }
.chart svg { display: block; }

.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------------- 提示条 ---------------- */

.notice {
  background: var(--primary-soft);
  border: 1px solid #d5e4fb;
  color: #1c4ed8;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

.notice.warn { background: var(--warn-soft); border-color: #f6e0bd; color: #96560b; }

/* ---------------- 数据看板：盈亏拆解条 ---------------- */

.kpi.is-danger .value { color: var(--danger); }

.wf { display: flex; flex-direction: column; gap: 10px; }
.wf-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.wf-name { flex: 0 0 78px; color: var(--text-2); }
.wf-track { flex: 1; min-width: 0; height: 14px; background: #f1f3f7; border-radius: 3px; overflow: hidden; }
.wf-fill { display: block; height: 100%; border-radius: 3px; }
.wf-val { flex: 0 0 94px; text-align: right; font-variant-numeric: tabular-nums; }
.wf-row.is-total { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 2px; font-weight: 500; }
.wf-row.is-total .wf-name { color: var(--text); }

/* ---------------- 数据看板：成本 / 提成明细行 ---------------- */

.cost-row { display: flex; align-items: center; gap: 10px; font-size: 13px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.cost-row:last-child { border-bottom: none; }
.cost-row .cn { flex: 0 0 62px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cost-row .cd { flex: 1; min-width: 0; color: var(--text-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cost-row .cv { flex: 0 0 auto; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- 数量步进器（手机端显示按钮） ---------------- */

.stepper { display: block; }
.step-btn { display: none; }

/* ---------------- 我的（个人中心） ---------------- */

.me-head { display: flex; align-items: center; gap: 14px; padding: 2px 2px 18px; }
.me-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.me-name { font-size: 18px; font-weight: 500; }
.me-role { font-size: 13px; color: var(--text-3); margin-top: 2px; }

.me-menu {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 14px;
  max-width: 560px;
}
.me-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 15px 16px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: none;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background .13s;
}
.me-row:last-child { border-bottom: none; }
.me-row:hover, .me-row:active { background: #fafbfd; }
.me-row .mi { width: 20px; height: 20px; color: var(--primary); flex: none; }
.me-row .txt { flex: 1; min-width: 0; }
.me-row .desc { display: block; font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.me-row .arrow { color: #c8d0dc; flex: none; font-size: 17px; }

/* ---------------- 客户选择器（出库单） ---------------- */

.combo { position: relative; }
.combo input { width: 100%; padding-right: 38px; }
.combo-arrow {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 12px; cursor: pointer; user-select: none;
}
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 5px); z-index: 30;
  max-height: 268px; overflow-y: auto; padding: 5px;
  background: var(--card); border: 1px solid var(--border-2);
  border-radius: var(--radius); box-shadow: 0 10px 26px rgba(24, 32, 46, .12);
}
.combo-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  min-height: 44px; padding: 9px 11px;
  background: none; border: 0; border-radius: 8px;
  color: var(--text); font-size: 14px; font-family: inherit;
  text-align: left; cursor: pointer;
}
.combo-item:hover, .combo-item.active { background: var(--primary-soft); }
.combo-item .ci-name { font-weight: 500; }
.combo-item .ci-meta { margin-left: auto; color: var(--text-3); font-size: 12px; }
.combo-empty { padding: 12px 11px; color: var(--text-3); font-size: 13px; }
.combo-add {
  display: block; width: 100%; min-height: 44px; margin-top: 4px; padding: 10px 11px;
  background: var(--primary-soft); border: 0; border-radius: 8px;
  color: var(--primary); font-size: 13.5px; font-family: inherit;
  text-align: left; cursor: pointer;
}
.req {
  display: inline-block; margin-left: 5px; padding: 1px 6px;
  background: var(--danger-soft); color: var(--danger);
  font-size: 11px; font-weight: 400; border-radius: 4px;
}

/* ================================================================
   移动端（≤ 820px）：App 式布局
   顶部精简栏 + 内容区 + 底部 Tab 导航，所有触摸目标不小于 44px
   ================================================================ */

@media (max-width: 820px) {
  html, body { font-size: 15px; }
  body { overscroll-behavior-y: contain; }

  /* ---------- 顶部栏 ---------- */
  .topbar {
    height: 54px;
    padding: 0 14px;
    gap: 10px;
  }
  .topbar .logo { width: 30px; height: 30px; border-radius: 9px; font-size: 14px; }
  .topbar h1 { font-size: 15px; font-weight: 500; }
  .topbar .sub { display: none; }
  #logoutBtn { display: none; }                 /* 退出入口移到「我的」 */

  .user-chip .name, .user-chip .role { display: none; }
  .user-chip .avatar {
    display: flex;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
    align-items: center;
    justify-content: center;
  }

  /* ---------- 布局：侧栏 → 底部 Tab ---------- */
  .layout { flex-direction: column; }
  .sidenav { display: none; }
  .content {
    padding: 14px 13px;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }
  .content-inner { max-width: 100%; }

  .tabbar {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 60;
    background: rgba(255, 255, 255, .97);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    backdrop-filter: saturate(180%) blur(12px);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 2px 7px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 11px;
    color: var(--text-3);
    cursor: pointer;
    position: relative;
    transition: color .15s;
    -webkit-tap-highlight-color: transparent;
  }
  .tab-item svg { width: 23px; height: 23px; display: block; }
  .tab-item.active { color: var(--primary); font-weight: 500; }
  .tab-item:active { opacity: .55; }

  /* ---------- 卡片与标题 ---------- */
  .card { padding: 15px 14px; margin-bottom: 12px; border-radius: 14px; }
  .card-title { font-size: 14px; margin-bottom: 12px; padding-bottom: 9px; }
  .page-title { font-size: 19px; }
  .page-desc { font-size: 12.5px; margin-bottom: 14px; }

  /* ---------- 表单控件 ---------- */
  input[type="text"], input[type="password"], input[type="number"],
  input[type="date"], input[type="search"], select, textarea {
    padding: 12px 13px;
    font-size: 16px;                /* 16px 可避免 iOS 聚焦时自动放大 */
    border-radius: 10px;
    -webkit-appearance: none;
    appearance: none;
    min-height: 46px;
  }
  select {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%235a6878' stroke-width='1.7' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
    padding-right: 36px;
  }
  textarea { min-height: 76px; line-height: 1.5; }

  .field { margin-bottom: 15px; }
  .field > span { font-size: 13.5px; margin-bottom: 7px; }
  .field .hint { font-size: 12px; margin-top: 5px; }

  .grid { gap: 0; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; gap: 0; }
  .col-span-2 { grid-column: span 1; }

  /* ---------- 按钮 ---------- */
  .btn { padding: 12px 16px; font-size: 15px; border-radius: 10px; min-height: 44px; }
  .btn-sm { padding: 8px 12px; font-size: 13.5px; min-height: 38px; }
  .form-actions { flex-direction: column-reverse; gap: 9px; margin-top: 16px; padding-top: 14px; }
  .form-actions .btn { width: 100%; }
  .form-actions .btn-primary { min-height: 52px; font-size: 16.5px; }

  /* 分段控件铺满整行 */
  .btn-group { display: flex; width: 100%; }
  .btn-group .btn { flex: 1; min-width: 0; }

  /* 托盘类别：大格子点击 */
  #catSwitch { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  #catSwitch .btn { border-radius: 11px; margin: 0; min-height: 54px; font-size: 15px; }
  #catSwitch .btn.active { box-shadow: 0 3px 12px rgba(37, 99, 235, .22); }

  /* 收费 / 不收费：两个大按钮 */
  #chargeSwitch .btn { min-height: 52px; font-size: 15px; }

  /* 看板快捷区间 */
  #dashQuick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #dashQuick .btn { padding: 9px 2px; font-size: 13px; min-height: 42px; }

  /* ---------- 数量步进器 ---------- */
  .stepper { display: flex; align-items: stretch; gap: 8px; }
  .step-btn { display: block; }
  .stepper input {
    flex: 1;
    min-width: 0;
    text-align: center;
    font-size: 20px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    min-height: 54px;
  }
  .stepper button {
    width: 56px;
    flex: none;
    border: 1px solid var(--border-2);
    background: #fff;
    border-radius: 10px;
    color: var(--text-2);
    font-size: 24px;
    line-height: 1;
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: all .12s;
  }
  .stepper button:active {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary);
  }

  /* ---------- 照片 ---------- */
  .photo-picker { padding: 20px 14px; border-radius: 12px; font-size: 14px; }
  .photo-picker .ico { display: block; width: 27px; height: 27px; margin: 0 auto 7px; color: var(--primary); }
  .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .photo-item .del { width: 24px; height: 24px; font-size: 15px; }

  .notice { padding: 11px 13px; font-size: 13px; margin-bottom: 12px; border-radius: 11px; }

  /* ---------- 流水卡片列表 ---------- */
  .m-list { display: flex; flex-direction: column; gap: 10px; }

  .m-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 13px;
    padding: 13px 14px 13px 17px;
    overflow: hidden;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .m-item::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--success);
  }
  .m-item.is-out::before { background: var(--warn); }
  .m-item.is-void::before { background: var(--text-3); }
  .m-item:active { background: #f7f9fc; }
  .m-item.is-void { opacity: .58; }
  .m-item.is-void .m-qty { text-decoration: line-through; }

  .m-main { flex: 1; min-width: 0; }
  .m-line1 { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
  .m-no { flex: 1; min-width: 0; font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .table-wrap.m-list { overflow: visible; }
  .m-sub { font-size: 14.5px; font-weight: 500; margin-bottom: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .m-meta { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .m-meta b { color: var(--text-2); font-weight: 500; }
  .m-meta .dot { margin: 0 5px; color: #cfd6e0; }
  .m-photo { display: inline-flex; align-items: center; gap: 3px; color: var(--primary); }
  .m-photo svg { width: 14px; height: 14px; stroke-width: 2.4; }

  .m-right { flex: none; text-align: right; }
  .m-qty { font-size: 21px; font-weight: 500; line-height: 1.15; font-variant-numeric: tabular-nums; }
  .m-qty small { font-size: 12px; font-weight: 400; color: var(--text-3); margin-left: 2px; }
  .m-qty.in { color: var(--success); }
  .m-qty.out { color: var(--warn); }
  .m-fee { font-size: 12.5px; color: var(--text-2); margin-top: 4px; font-variant-numeric: tabular-nums; }
  .m-fee.free { color: var(--text-3); }
  .m-fee.none { display: none; }

  /* ---------- 筛选栏 ---------- */
  .filters { gap: 9px; align-items: stretch; }
  .filters .field { min-width: 0; flex: 1 1 calc(50% - 5px); }
  .filters .field.grow { flex: 1 1 100%; }
  .filters .btn { flex: 1 1 calc(50% - 5px); }
  #q_search { flex: 1 1 100%; min-height: 48px; font-size: 16px; }

  /* 分页按钮加大 */
  #orderPager > div { justify-content: space-between !important; }
  #pgPrev, #pgNext { flex: 1; min-height: 46px; }

  /* 流水页统计条 */
  .legend { gap: 8px 14px; font-size: 12.5px; }

  /* ---------- KPI ---------- */
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
  .kpi { padding: 14px; border-radius: 13px; }
  .kpi .label { font-size: 12px; margin-bottom: 5px; }
  .kpi .value { font-size: 25px; }
  .kpi .value small { font-size: 12.5px; }
  .kpi .foot { font-size: 11.5px; margin-top: 5px; }

  /* ---------- 表格 ---------- */
  table { font-size: 13.5px; }
  th, td { padding: 11px 9px; }
  th:first-child, td:first-child { padding-left: 13px; }
  th:last-child, td:last-child { padding-right: 13px; }

  /* ---------- 弹窗 → 底部抽屉 ---------- */
  .modal-mask { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 18px 18px 0 0;
    padding: 18px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    animation: sheet-up .22s ease-out;
  }
  .modal.wide { max-width: 100%; }
  .modal h3 { font-size: 16.5px; margin-bottom: 15px; }
  .modal .grid-2, .modal .grid-3 { gap: 0; }
  @keyframes sheet-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  /* ---------- 提示 ---------- */
  .toast {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    font-size: 14px;
    padding: 11px 18px;
    max-width: 86vw;
    border-radius: 10px;
  }

  .empty { padding: 34px 16px; }

  /* ---------- 我的 ---------- */
  .me-head { padding: 2px 2px 16px; }
  .me-avatar { width: 60px; height: 60px; font-size: 24px; }
  .me-name { font-size: 19px; }
  .me-menu { border-radius: 13px; margin-bottom: 12px; max-width: 100%; }
  .me-row { padding: 15px; font-size: 15.5px; -webkit-tap-highlight-color: transparent; }

  .chart { margin: 0 -2px; }
}

@media (max-width: 390px) {
  .content { padding-left: 11px; padding-right: 11px; }
  .m-qty { font-size: 19px; }
  #dashQuick .btn { font-size: 12px; }
  .kpi .value { font-size: 23px; }
}
