/* ============================================
   叁恒业务管理系统 v2 - 简约设计系统
   灵感: Apple HIG + 小米 HyperOS · 纯净·留白·层次
   ============================================ */

:root {
  /* 主色 — Apple 蓝 */
  --sh-primary: #007AFF;
  --sh-primary-hover: #1a8aff;
  --sh-primary-active: #0056CC;
  --sh-primary-tint: #E8F4FD;
  --sh-primary-lighter: #F0F7FF;

  /* 状态 */
  --sh-success: #34C759;
  --sh-warning: #FF9500;
  --sh-danger:  #FF3B30;
  --sh-info:    #5856D6;

  /* 文字 */
  --sh-text-1: #1d1d1f;
  --sh-text-2: #6e6e73;
  --sh-text-3: #aeaeb2;
  --sh-text-ph: #767679;

  /* 背景 */
  --sh-bg-page: #f5f5f7;
  --sh-bg-card: #ffffff;
  --sh-bg-hover: #f5f5f7;
  --sh-bg-input: #ffffff;

  /* 边框 */
  --sh-border: #e5e5ea;
  --sh-border-light: #f2f2f7;
  --sh-border-strong: #d1d1d6;

  /* 阴影 */
  --sh-shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --sh-shadow-md: 0 2px 8px rgba(0,0,0,0.06);
  --sh-shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
  --sh-shadow-xl: 0 24px 48px rgba(0,0,0,0.12);

  /* 圆角 */
  --sh-r-sm: 8px;
  --sh-r-md: 12px;
  --sh-r-lg: 16px;
  --sh-r-xl: 20px;
  --sh-r-pill: 999px;

  /* 间距 */
  --sh-s-1: 4px;
  --sh-s-2: 8px;
  --sh-s-3: 12px;
  --sh-s-4: 16px;
  --sh-s-5: 24px;
  --sh-s-6: 32px;

  /* 布局 */
  --sh-sidebar: 240px;
  --sh-header: 52px;

  /* 字体 */
  --sh-font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --sh-font-num: -apple-system, 'SF Mono', Menlo, Consolas, 'PingFang SC', sans-serif;
  --sh-tx: 14px;
  --sh-tx-sm: 12px;
  --sh-tx-xs: 11px;
  --sh-tx-lg: 16px;
  --sh-tx-xl: 22px;

  /* 过渡 */
  --sh-tr: 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* ===== Reset ===== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--sh-font);
  font-size: var(--sh-tx);
  font-weight: 400;
  color: var(--sh-text-1);
  background: var(--sh-bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
}
a { color: var(--sh-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, button, textarea { font-family: inherit; }

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.2); }

/* ===== 左侧目录 — 整体白色 ===== */
.sidebar {
  width: var(--sh-sidebar);
  background: var(--sh-bg-card);
  color: var(--sh-text-1);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--sh-border-light);
}
.sidebar .brand {
  padding: 18px 20px;
  border-bottom: 1px solid var(--sh-border-light);
}
.sidebar .brand .logo {
  color: var(--sh-text-1);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 8px;
}
.sidebar .brand .sub {
  color: var(--sh-text-3);
  font-size: 11px;
  margin-top: 4px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.sidebar .nav-title {
  padding: 16px 20px 6px;
  color: var(--sh-text-3);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.sidebar .nav { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.sidebar .nav li a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 20px;
  color: var(--sh-text-2);
  cursor: pointer;
  text-decoration: none;
  font-size: var(--sh-tx);
  font-weight: 500;
  border-left: 3px solid transparent;
  border-radius: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar .nav li a:hover { background: var(--sh-bg-hover); color: var(--sh-text-1); text-decoration: none; }
.sidebar .nav li a.active {
  background: var(--sh-primary-lighter);
  color: var(--sh-primary);
  border-left-color: var(--sh-primary);
}
.sidebar .nav li a .icon { width: 18px; text-align: center; font-size: 14px; opacity: 0.8; }
.sidebar .nav li a.active .icon { opacity: 1; }
.sidebar .nav li a .badge-count {
  margin-left: auto;
  background: var(--sh-bg-hover);
  color: var(--sh-text-2);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: var(--sh-r-pill);
  font-variant-numeric: tabular-nums;
}
.sidebar .nav li a.active .badge-count { background: var(--sh-primary); color: #fff; }
.sidebar .footer {
  margin-top: auto;
  padding: 14px 20px;
  border-top: 1px solid var(--sh-border-light);
  font-size: var(--sh-tx-xs);
  color: var(--sh-text-3);
}
.sidebar .footer .user { color: var(--sh-text-1); font-size: 12px; margin-bottom: 4px; font-weight: 500; }
.sidebar .footer a { color: var(--sh-primary); cursor: pointer; }
.sidebar .footer a:hover { text-decoration: underline; }

/* ===== 主区 ===== */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

header {
  background: var(--sh-bg-card);
  padding: 0 24px;
  min-height: var(--sh-header);
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--sh-border-light);
}
header h1 {
  font-size: 17px;
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}
header .count {
  color: var(--sh-text-2);
  font-size: var(--sh-tx-sm);
  background: var(--sh-bg-hover);
  padding: 2px 10px;
  border-radius: var(--sh-r-pill);
  font-variant-numeric: tabular-nums;
}
header .spacer { flex: 1; }
header .back-link {
  color: var(--sh-primary);
  cursor: pointer;
  font-size: var(--sh-tx-sm);
  font-weight: 500;
}
header .back-link:hover { text-decoration: underline; }
header .stage-rule {
  color: var(--sh-text-3);
  font-size: var(--sh-tx-xs);
  margin-left: 8px;
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== 工具栏 — 极简白底按钮 ===== */
.toolbar {
  background: var(--sh-bg-card);
  padding: 12px 24px;
  border-bottom: 1px solid var(--sh-border-light);
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}
.tb-btn {
  padding: 6px 14px;
  border: 1px solid var(--sh-border-light);
  border-radius: var(--sh-r-sm);
  background: var(--sh-bg-card);
  cursor: pointer;
  font-size: var(--sh-tx-sm);
  font-weight: 500;
  color: var(--sh-text-2);
  font-family: inherit;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.15s ease;
}
.tb-btn:hover {
  background: var(--sh-bg-hover);
  border-color: var(--sh-border);
  color: var(--sh-text-1);
}
.tb-btn.active {
  background: var(--sh-primary-lighter);
  border-color: var(--sh-primary-lighter);
  color: var(--sh-primary);
}
.tb-btn .badge {
  background: var(--sh-primary);
  color: #fff;
  border-radius: var(--sh-r-pill);
  padding: 0 6px;
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  min-width: 16px;
  text-align: center;
}
.tb-btn.active .badge { background: var(--sh-primary); }
.tb-btn-primary {
  background: var(--sh-primary);
  border-color: var(--sh-primary);
  color: #fff;
  font-weight: 600;
}
.tb-btn-primary:hover { background: var(--sh-primary-hover); border-color: var(--sh-primary-hover); color: #fff; }

#searchBox {
  padding: 6px 12px;
  border: 1px solid var(--sh-border-light);
  border-radius: var(--sh-r-sm);
  font-size: var(--sh-tx-sm);
  width: 260px;
  background: var(--sh-bg-card);
  color: var(--sh-text-1);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
  outline: none;
}
#searchBox::placeholder { color: var(--sh-text-ph); }
#searchBox:hover { border-color: var(--sh-border); }
#searchBox:focus { border-color: var(--sh-primary); box-shadow: 0 0 0 3px var(--sh-primary-lighter); }

/* ===== 已激活筛选 chips ===== */
.chips-bar {
  background: #fffbef;
  border-bottom: 1px solid #ffe58f;
  padding: 8px 24px;
  font-size: var(--sh-tx-sm);
  color: #874d00;
  display: none;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.chips-bar.show { display: flex; }
.chips-bar .conj {
  background: #fff7d9;
  border: 1px solid #ffd666;
  padding: 1px 10px;
  border-radius: var(--sh-r-pill);
  font-size: var(--sh-tx-xs);
  font-weight: 600;
}
.chips-bar .chip {
  background: #fff;
  border: 1px solid #ffd666;
  padding: 2px 4px 2px 10px;
  border-radius: var(--sh-r-pill);
  font-size: var(--sh-tx-xs);
  display: inline-flex; align-items: center; gap: 4px;
}
.chips-bar .chip .x {
  cursor: pointer;
  color: #aaa;
  padding: 0 6px;
  font-size: 14px;
  line-height: 1;
}
.chips-bar .chip .x:hover { color: var(--sh-danger); }
.chips-bar a { color: var(--sh-primary); cursor: pointer; margin-left: auto; font-weight: 500; }

/* ===== 表格 ===== */
.table-wrap {
  margin: 16px 24px;
  background: var(--sh-bg-card);
  border-radius: var(--sh-r-md);
  box-shadow: var(--sh-shadow-sm);
  border: 1px solid var(--sh-border-light);
  overflow: auto;
  max-height: calc(100vh - 220px);
}
table { border-collapse: separate; border-spacing: 0; width: 100%; }
th, td {
  border-bottom: 1px solid var(--sh-border-light);
  padding: 8px 12px;
  white-space: nowrap;
  text-align: left;
  font-size: var(--sh-tx-sm);
}
th {
  background: var(--sh-bg-card);
  position: sticky;
  top: 0;
  font-weight: 600;
  color: var(--sh-text-2);
  cursor: pointer;
  user-select: none;
  z-index: 2;
  font-size: var(--sh-tx-xs);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--sh-border);
}
th:hover { background: var(--sh-bg-hover); color: var(--sh-text-1); }
th .sort { color: var(--sh-text-3); font-size: 10px; margin-left: 4px; }
th .sort.active { color: var(--sh-primary); }
th { position: relative; }
th .resize {
  position: absolute; top: 0; right: 0; width: 6px; height: 100%;
  cursor: col-resize; user-select: none;
}
th .resize:hover, th .resize.active { background: var(--sh-primary); opacity: 0.4; }
th.dragging { opacity: 0.4; }
th.drag-over-left::before { content: ''; position: absolute; left: -1px; top: 0; bottom: 0; width: 2px; background: var(--sh-primary); }
th.drag-over-right::after { content: ''; position: absolute; right: -1px; top: 0; bottom: 0; width: 2px; background: var(--sh-primary); }
td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--sh-font-num); }
td.empty { color: var(--sh-text-3); }
td.action { padding: 4px 8px; }
tbody tr:hover { background: var(--sh-bg-hover); }
tbody tr:last-child td { border-bottom: none; }
.edit-btn {
  border: 1px solid var(--sh-primary);
  background: var(--sh-primary-tint);
  color: var(--sh-primary);
  padding: 3px 12px;
  border-radius: var(--sh-r-sm);
  cursor: pointer;
  font-size: var(--sh-tx-xs);
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s ease;
}
.edit-btn:hover { background: var(--sh-primary); color: #fff; }
.assign-btn {
  border: 1px solid var(--sh-warning);
  background: #FFF4E0;
  color: var(--sh-warning);
  padding: 3px 12px;
  border-radius: var(--sh-r-sm);
  cursor: pointer;
  font-size: var(--sh-tx-xs);
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s ease;
}
.assign-btn:hover { background: var(--sh-warning); color: #fff; }
.feedback-btn {
  border: 1px solid var(--sh-success);
  background: #E8F8EE;
  color: var(--sh-success);
  padding: 3px 12px;
  border-radius: var(--sh-r-sm);
  cursor: pointer;
  font-size: var(--sh-tx-xs);
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s ease;
}
.feedback-btn:hover { background: var(--sh-success); color: #fff; }
.confirm-btn {
  border: 1px solid var(--sh-info);
  background: #EEF0FF;
  color: var(--sh-info);
  padding: 3px 12px;
  border-radius: var(--sh-r-sm);
  cursor: pointer;
  font-size: var(--sh-tx-xs);
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s ease;
}
.confirm-btn:hover { background: var(--sh-info); color: #fff; }
.make-verify-btn {
  border: 1px solid #5856D6;
  background: #EEF0FF;
  color: #5856D6;
  padding: 3px 12px;
  border-radius: var(--sh-r-sm);
  cursor: pointer;
  font-size: var(--sh-tx-xs);
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s ease;
}
.make-verify-btn:hover { background: #5856D6; color: #fff; }
.issue-cert-btn {
  border: 1px solid #34C759;
  background: #E8F8EE;
  color: #1F7A33;
  padding: 3px 12px;
  border-radius: var(--sh-r-sm);
  cursor: pointer;
  font-size: var(--sh-tx-xs);
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s ease;
}
.issue-cert-btn:hover { background: #34C759; color: #fff; }
.make-invoice-btn {
  border: 1px solid #007AFF;
  background: #E5F1FF;
  color: #0050B3;
  padding: 3px 12px;
  border-radius: var(--sh-r-sm);
  cursor: pointer;
  font-size: var(--sh-tx-xs);
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s ease;
}
.make-invoice-btn:hover { background: #007AFF; color: #fff; }
.confirm-invoice-btn {
  border: 1px solid #5856D6;
  background: #EEF0FF;
  color: #5856D6;
  padding: 3px 12px;
  border-radius: var(--sh-r-sm);
  cursor: pointer;
  font-size: var(--sh-tx-xs);
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s ease;
}
.confirm-invoice-btn:hover { background: #5856D6; color: #fff; }
.payment-btn {
  border: 1px solid #34C759;
  background: #E8F8EE;
  color: #1F7A33;
  padding: 3px 12px;
  border-radius: var(--sh-r-sm);
  cursor: pointer;
  font-size: var(--sh-tx-xs);
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s ease;
}
.payment-btn:hover { background: #34C759; color: #fff; }
.approve-btn {
  border: 1px solid #5856D6;
  background: #EEF0FF;
  color: #5856D6;
  padding: 3px 12px;
  border-radius: var(--sh-r-sm);
  cursor: pointer;
  font-size: var(--sh-tx-xs);
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s ease;
}
.approve-btn:hover { background: #5856D6; color: #fff; }
.send-verify-btn {
  border: 1px solid #FF9500;
  background: #FFF4E0;
  color: #FF9500;
  padding: 3px 12px;
  border-radius: var(--sh-r-sm);
  cursor: pointer;
  font-size: var(--sh-tx-xs);
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s ease;
}
.send-verify-btn:hover { background: #FF9500; color: #fff; }
.send-cert-btn {
  border: 1px solid #007AFF;
  background: #E5F1FF;
  color: #007AFF;
  padding: 3px 12px;
  border-radius: var(--sh-r-sm);
  cursor: pointer;
  font-size: var(--sh-tx-xs);
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s ease;
}
.send-cert-btn:hover { background: #007AFF; color: #fff; }
.apply-fee-btn {
  border: 1px solid #FF9500;
  background: #FFF4E0;
  color: #FF9500;
  padding: 3px 12px;
  border-radius: var(--sh-r-sm);
  cursor: pointer;
  font-size: var(--sh-tx-xs);
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s ease;
}
.apply-fee-btn:hover { background: #FF9500; color: #fff; }
.approve-fee-btn {
  border: 1px solid #5856D6;
  background: #EEF0FF;
  color: #5856D6;
  padding: 3px 12px;
  border-radius: var(--sh-r-sm);
  cursor: pointer;
  font-size: var(--sh-tx-xs);
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s ease;
}
.approve-fee-btn:hover { background: #5856D6; color: #fff; }
.reject-btn {
  border: 1px solid #FF3B30;
  background: #FFE5E5;
  color: #FF3B30;
  padding: 6px 16px;
  border-radius: var(--sh-r-sm);
  cursor: pointer;
  font-size: var(--sh-tx-sm);
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s ease;
}
.reject-btn:hover { background: #FF3B30; color: #fff; }

/* ===== 客户确认弹窗 — 附件列表 ===== */
.cf-attachments { display: flex; flex-direction: column; gap: 6px; }
.cf-attach-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px;
  background: #fff;
  border: 1px solid var(--sh-border-light);
  border-radius: var(--sh-r-sm);
  font-size: var(--sh-tx-sm);
}
.cf-attach-icon { font-size: 16px; }
.cf-attach-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--sh-primary); text-decoration: none;
}
.cf-attach-name:hover { text-decoration: underline; }
.cf-attach-size { color: var(--sh-text-3); font-size: var(--sh-tx-xs); font-variant-numeric: tabular-nums; }

/* ===== 详情页附件区 — 1 张图直接铺开, 多张缩略图 + 打包下载 ===== */
.det-attach-wrap { display: flex; flex-direction: column; gap: 10px; }
.det-attach-single-img {
  display: block; max-width: 100%; max-height: 360px;
  border: 1px solid var(--sh-border-light); border-radius: var(--sh-r-sm);
  object-fit: contain; background: #fafafa;
}
.det-attach-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px; padding: 4px;
}
.det-attach-thumb {
  position: relative;
  border: 1px solid var(--sh-border-light); border-radius: var(--sh-r-sm);
  background: #fff; overflow: hidden; cursor: pointer;
  display: flex; flex-direction: column;
}
.det-attach-thumb:hover { border-color: var(--sh-primary); }
.det-attach-thumb img {
  width: 100%; height: 100px; object-fit: cover; background: #fafafa;
}
.det-attach-thumb .det-thumb-name {
  font-size: 11px; color: var(--sh-text-1);
  padding: 6px 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.det-attach-zip-btn {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--sh-primary); color: #fff;
  border-radius: var(--sh-r-sm);
  text-decoration: none; font-size: var(--sh-tx-sm); font-weight: 600;
  cursor: pointer;
}
.det-attach-zip-btn:hover { background: #0070e0; }
.det-attach-empty { color: var(--sh-text-3); font-size: var(--sh-tx-sm); padding: 4px 0; }

/* ===== 施工反馈 — 拖拽上传 ===== */
.fb-drop {
  border: 2px dashed var(--sh-border-strong);
  border-radius: var(--sh-r-md);
  padding: 22px 16px;
  text-align: center;
  background: #fafbfc;
  cursor: pointer;
  transition: all 0.15s ease;
}
.fb-drop:hover { border-color: var(--sh-primary); background: var(--sh-primary-lighter); }
.fb-drop.drag { border-color: var(--sh-primary); background: var(--sh-primary-tint); }
.fb-drop-hint { color: var(--sh-text-2); font-size: 13px; font-weight: 500; }
.fb-files { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.fb-file-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px;
  background: #fff;
  border: 1px solid var(--sh-border-light);
  border-radius: var(--sh-r-sm);
  font-size: var(--sh-tx-sm);
}
.fb-file-icon { font-size: 16px; }
.fb-file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--sh-text-1); }
.fb-file-size { color: var(--sh-text-3); font-size: var(--sh-tx-xs); font-variant-numeric: tabular-nums; }
.fb-file-del {
  cursor: pointer;
  color: var(--sh-text-3);
  font-size: 18px;
  line-height: 1;
  padding: 0 8px;
  font-weight: 300;
}
.fb-file-del:hover { color: var(--sh-danger); }
.empty-table {
  text-align: center;
  padding: 80px 20px;
  color: var(--sh-text-3);
  font-size: var(--sh-tx);
}
.empty-table .icon { font-size: 48px; opacity: 0.4; margin-bottom: 12px; display: block; }

/* ===== 分页 ===== */
.pager {
  display: flex; justify-content: center; align-items: center; gap: 8px;
  padding: 12px 16px 16px;
}
.pager button {
  padding: 5px 14px;
  border: 1px solid var(--sh-border);
  background: var(--sh-bg-card);
  border-radius: var(--sh-r-sm);
  cursor: pointer;
  font-size: var(--sh-tx-sm);
  font-weight: 500;
  color: var(--sh-text-1);
  font-family: inherit;
  transition: all 0.15s ease;
}
.pager button:hover:not(:disabled) { background: var(--sh-bg-hover); border-color: var(--sh-border-strong); }
.pager button:disabled { color: var(--sh-text-3); cursor: not-allowed; }
.pager #pageInfo { color: var(--sh-text-2); font-size: var(--sh-tx-sm); font-variant-numeric: tabular-nums; }
.pager select {
  padding: 4px 8px;
  font-size: var(--sh-tx-sm);
  border: 1px solid var(--sh-border);
  border-radius: var(--sh-r-sm);
  background: var(--sh-bg-card);
  color: var(--sh-text-1);
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

/* ===== 工作台 卡片 ===== */
.dash { padding: 24px; }
.dash-header {
  margin-bottom: 16px;
  color: var(--sh-text-2);
  font-size: var(--sh-tx-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.dash-header strong { color: var(--sh-text-1); font-weight: 600; }
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.dash-card {
  background: var(--sh-bg-card);
  border: 1px solid var(--sh-border-light);
  border-radius: var(--sh-r-md);
  padding: 18px 20px;
  cursor: pointer;
  text-decoration: none;
  color: var(--sh-text-1);
  transition: all 0.18s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--sh-shadow-sm);
}
.dash-card:hover {
  border-color: var(--sh-primary);
  box-shadow: var(--sh-shadow-md);
  transform: translateY(-1px);
  text-decoration: none;
}
.dash-card .ctitle {
  font-size: 15px;
  font-weight: 600;
  display: flex; align-items: center; gap: 6px;
  letter-spacing: -0.01em;
}
.dash-card .ctitle .tag {
  font-size: 10px;
  background: var(--sh-primary-tint);
  color: var(--sh-primary);
  padding: 1px 8px;
  border-radius: var(--sh-r-pill);
  font-weight: 600;
}
.dash-card .ccount {
  font-size: 28px;
  font-weight: 700;
  color: var(--sh-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  font-family: var(--sh-font-num);
  letter-spacing: -0.02em;
}
.dash-card .ccount.zero { color: var(--sh-text-3); }
.dash-card .crule {
  color: var(--sh-text-2);
  font-size: var(--sh-tx-xs);
  line-height: 1.5;
  max-height: 36px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.dash-card .cgo {
  font-size: var(--sh-tx-xs);
  color: var(--sh-primary);
  font-weight: 500;
  margin-top: 2px;
}

/* ===== 弹窗 (筛选/编辑/列设置) ===== */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.32);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 100;
  padding-top: 80px;
  animation: fadeIn 0.15s ease;
}
.modal-mask.open { display: flex; }

.filter-panel, .col-modal, .edit-modal {
  background: var(--sh-bg-card);
  border-radius: var(--sh-r-lg);
  display: flex;
  flex-direction: column;
  box-shadow: var(--sh-shadow-xl);
  border: 1px solid var(--sh-border-light);
  animation: slideUp 0.2s ease;
}
@keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.filter-panel { width: 720px; max-height: 80vh; }
.filter-panel .head, .col-modal h2, .edit-modal h2 {
  padding: 16px 24px;
  border-bottom: 1px solid var(--sh-border-light);
  display: flex; align-items: center; gap: 12px;
}
.filter-panel .head h2, .col-modal h2, .edit-modal h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  border: none;
  padding: 0;
}
.filter-panel .head .conj-toggle {
  display: inline-flex;
  border: 1px solid var(--sh-border);
  border-radius: var(--sh-r-sm);
  overflow: hidden;
  font-size: var(--sh-tx-sm);
  background: var(--sh-bg-card);
}
.filter-panel .head .conj-toggle button {
  padding: 4px 14px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  color: var(--sh-text-2);
  transition: all 0.15s ease;
}
.filter-panel .head .conj-toggle button.active { background: var(--sh-primary); color: #fff; }
.filter-panel .head .spacer { flex: 1; }
.filter-panel .head .close, .edit-modal h2 .close {
  cursor: pointer;
  color: var(--sh-text-3);
  font-size: 22px;
  line-height: 1;
  padding: 0 8px;
  font-weight: 300;
  transition: color 0.15s ease;
}
.filter-panel .head .close:hover, .edit-modal h2 .close:hover { color: var(--sh-text-1); }

.filter-panel .body, .col-modal .body, .edit-modal .body {
  padding: 16px 24px;
  overflow: auto;
  flex: 1;
}
.filter-panel .foot, .col-modal .footer, .edit-modal .footer {
  padding: 14px 24px;
  border-top: 1px solid var(--sh-border-light);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}
.filter-panel .foot button, .col-modal .footer button, .edit-modal .footer button {
  padding: 7px 18px;
  border-radius: var(--sh-r-sm);
  border: 1px solid var(--sh-border);
  background: var(--sh-bg-card);
  cursor: pointer;
  font-size: var(--sh-tx-sm);
  font-weight: 500;
  font-family: inherit;
  color: var(--sh-text-1);
  transition: all 0.15s ease;
}
.filter-panel .foot button:hover, .col-modal .footer button:hover { background: var(--sh-bg-hover); border-color: var(--sh-border-strong); }
.filter-panel .foot button.primary, .col-modal .footer button.primary, .edit-modal .footer button.primary {
  background: var(--sh-primary);
  color: #fff;
  border-color: var(--sh-primary);
}
.filter-panel .foot button.primary:hover, .col-modal .footer button.primary:hover, .edit-modal .footer button.primary:hover {
  background: var(--sh-primary-hover);
  border-color: var(--sh-primary-hover);
}
.filter-panel .actions { display: flex; gap: 12px; padding: 8px 0 4px; font-size: var(--sh-tx-sm); }
.filter-panel .actions a { color: var(--sh-primary); cursor: pointer; font-weight: 500; }

/* 条件行 */
.cond-row {
  display: flex; gap: 6px; align-items: center;
  margin-bottom: 8px;
  padding: 8px 10px;
  background: var(--sh-bg-page);
  border: 1px solid var(--sh-border-light);
  border-radius: var(--sh-r-sm);
}
.cond-row .field, .cond-row .op {
  padding: 5px 10px;
  border: 1px solid var(--sh-border);
  border-radius: var(--sh-r-sm);
  font-size: var(--sh-tx-sm);
  font-family: inherit;
  background: var(--sh-bg-card);
  min-width: 110px;
  outline: none;
}
.cond-row .field { min-width: 140px; }
.cond-row .val {
  padding: 5px 10px;
  border: 1px solid var(--sh-border);
  border-radius: var(--sh-r-sm);
  font-size: var(--sh-tx-sm);
  font-family: inherit;
  background: var(--sh-bg-card);
  flex: 1;
  min-width: 80px;
  outline: none;
}
.cond-row .val:focus { border-color: var(--sh-primary); box-shadow: 0 0 0 3px var(--sh-primary-lighter); }
.cond-row .val-range { display: flex; gap: 4px; flex: 1; }
.cond-row .val-range input {
  padding: 5px 10px;
  border: 1px solid var(--sh-border);
  border-radius: var(--sh-r-sm);
  font-size: var(--sh-tx-sm);
  font-family: inherit;
  background: var(--sh-bg-card);
  flex: 1;
  outline: none;
}
.cond-row .val-range input:focus { border-color: var(--sh-primary); box-shadow: 0 0 0 3px var(--sh-primary-lighter); }
.cond-row .del {
  cursor: pointer;
  color: var(--sh-text-3);
  font-size: 18px;
  line-height: 1;
  padding: 0 8px;
  user-select: none;
  font-weight: 300;
}
.cond-row .del:hover { color: var(--sh-danger); }
.cond-row.disabled .val, .cond-row.disabled .val-range input { background: var(--sh-bg-hover); color: var(--sh-text-3); cursor: not-allowed; }
.empty-conds { color: var(--sh-text-3); text-align: center; padding: 32px 20px; font-size: var(--sh-tx-sm); }

/* ===== 列设置 ===== */
.col-modal { width: 720px; max-height: 80vh; }
.col-modal .body { padding: 14px 24px; }
.col-modal .footer { justify-content: space-between; }
.col-modal .footer > div { display: flex; gap: 8px; }
.col-list { display: flex; flex-direction: column; gap: 2px; max-height: 50vh; overflow: auto; }
.col-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: var(--sh-r-sm);
  cursor: grab;
  user-select: none;
  font-size: var(--sh-tx-sm);
  transition: all 0.12s ease;
}
.col-item:hover { background: var(--sh-primary-lighter); border-color: var(--sh-primary-lighter); }
.col-item.dragging { opacity: 0.4; }
.col-item.drag-over { border-top: 2px solid var(--sh-primary); }
.col-item .grip { color: var(--sh-text-3); font-size: 16px; cursor: grab; }
.col-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-item .typ { color: var(--sh-text-3); font-size: var(--sh-tx-xs); }
.col-item .width-input {
  width: 64px;
  padding: 3px 6px;
  border: 1px solid var(--sh-border);
  border-radius: 6px;
  font-size: var(--sh-tx-xs);
  outline: none;
}
.col-item .width-input:focus { border-color: var(--sh-primary); box-shadow: 0 0 0 3px var(--sh-primary-lighter); }

/* ===== 编辑订单 弹窗 ===== */
.edit-modal { width: 900px; max-height: 85vh; }
.edit-modal h2 { display: flex; align-items: center; gap: 10px; }
.edit-modal h2 .spacer { flex: 1; }
.edit-modal .footer { gap: 8px; }
.edit-modal .footer .spacer { flex: 1; }
.edit-modal .footer #editErr { color: var(--sh-danger); font-size: var(--sh-tx-sm); }
.edit-section { margin-bottom: 20px; }
.edit-section h3 {
  margin: 0 0 10px;
  font-size: var(--sh-tx-xs);
  color: var(--sh-text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  border-bottom: 1px dashed var(--sh-border);
  padding-bottom: 6px;
}
.edit-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 16px;
}
.edit-grid label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: var(--sh-tx-xs);
  color: var(--sh-text-2);
  font-weight: 500;
}
.edit-grid input, .edit-grid textarea {
  padding: 7px 10px;
  border: 1px solid var(--sh-border);
  border-radius: var(--sh-r-sm);
  font-size: var(--sh-tx-sm);
  font-family: inherit;
  background: var(--sh-bg-input);
  color: var(--sh-text-1);
  outline: none;
  transition: all 0.15s ease;
}
.edit-grid input:focus, .edit-grid textarea:focus {
  border-color: var(--sh-primary);
  box-shadow: 0 0 0 3px var(--sh-primary-lighter);
}
.edit-grid textarea { resize: vertical; min-height: 56px; }
.edit-grid .full { grid-column: span 2; }

/* ===== 详情弹窗 (只读, 紧凑) ===== */
.detail-modal {
  background: var(--sh-bg-card);
  border-radius: var(--sh-r-lg);
  width: 880px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--sh-shadow-xl);
  border: 1px solid var(--sh-border-light);
  animation: slideUp 0.2s ease;
}
.detail-modal .body { padding: 16px 24px; overflow: auto; flex: 1; }
.detail-modal .footer { padding: 12px 24px; border-top: 1px solid var(--sh-border-light); display: flex; align-items: center; gap: 8px; }
.detail-modal .footer .spacer { flex: 1; }
.detail-modal .footer button {
  padding: 6px 16px;
  border: 1px solid var(--sh-border);
  border-radius: var(--sh-r-sm);
  background: var(--sh-bg-card);
  cursor: pointer;
  font-size: var(--sh-tx-sm);
  font-weight: 500;
  font-family: inherit;
  color: var(--sh-text-1);
}
.detail-modal .footer button:hover { background: var(--sh-bg-hover); }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 24px;
}
.detail-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--sh-border-light);
  font-size: var(--sh-tx-sm);
}
.detail-item .lbl {
  color: var(--sh-text-3);
  font-size: var(--sh-tx-xs);
  font-weight: 500;
  min-width: 84px;
  flex-shrink: 0;
}
.detail-item .val {
  color: var(--sh-text-1);
  font-weight: 500;
  word-break: break-all;
  flex: 1;
  min-width: 0;
}
.detail-item .val.num { font-family: var(--sh-font-num); font-variant-numeric: tabular-nums; text-align: right; }
.detail-item.empty .val { color: var(--sh-text-3); font-weight: 400; }
.detail-item.full { grid-column: span 2; }

/* 客户名点击态 */
td.link {
  color: var(--sh-primary);
  cursor: pointer;
  font-weight: 500;
}
td.link:hover { text-decoration: underline; background: var(--sh-primary-lighter); }

/* ===== 通用工具 ===== */
.sh-page-title {
  font-size: var(--sh-tx-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}
.sh-section-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 var(--sh-s-4);
}
.sh-empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--sh-text-3);
}
.sh-empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; display: block; }
.sh-empty-state .text { font-size: var(--sh-tx); }

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
  :root { --sh-sidebar: 200px; --sh-s-4: 12px; --sh-s-5: 16px; }
  .filter-panel, .col-modal, .edit-modal { width: 90vw; }
}
@media (max-width: 767px) {
  :root { --sh-sidebar: 0px; --sh-s-4: 10px; --sh-s-5: 14px; }
  body { font-size: 13px; }
  .sidebar { display: none; }
  .edit-grid { grid-template-columns: 1fr; }
  .edit-grid .full { grid-column: span 1; }
  #searchBox { width: 180px; }
}

/* ===== 新建订单 全屏页 (完整版) ===== */
.create-page {
  position: fixed;
  inset: 0;
  background: var(--sh-bg-page);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fadeIn 0.18s ease;
}
.create-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 14px 24px;
  background: var(--sh-bg-card);
  border-bottom: 1px solid var(--sh-border-light);
}
.create-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}
.create-header .sub-desc {
  color: #86868b;
  font-size: 12px;
}
.create-header .spacer { flex: 1; }

.create-body {
  flex: 1;
  overflow: auto;
  padding: 16px 24px 60px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

.create-section {
  background: var(--sh-bg-card);
  border: 1px solid var(--sh-border-light);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 12px;
  box-shadow: var(--sh-shadow-sm);
}
.create-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--sh-text-1);
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}

.create-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 16px;
}
.create-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 16px;
}
.create-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px 16px;
}
.create-section label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: #6e6e73;
  font-weight: 500;
}
.create-section label em {
  color: #ff3b30;
  font-style: normal;
  margin-left: 2px;
}
.create-section label.switch-label {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #fafafa;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--sh-border-light);
}
.create-section input[type=text],
.create-section input[type=number],
.create-section input[type=date],
.create-section select,
.create-section textarea {
  padding: 7px 10px;
  border: 1px solid var(--sh-border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: var(--sh-text-1);
  outline: none;
  transition: all 0.15s ease;
  width: 100%;
}
.create-section textarea {
  resize: vertical;
  min-height: 56px;
  font-family: inherit;
}
.create-section input:focus,
.create-section select:focus,
.create-section textarea:focus {
  border-color: var(--sh-primary);
  box-shadow: 0 0 0 3px var(--sh-primary-lighter);
}

/* iOS 风格开关 */
.sh-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.sh-switch input { opacity: 0; width: 0; height: 0; }
.sh-switch-slider {
  position: absolute;
  inset: 0;
  background: #e5e5ea;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
}
.sh-switch-slider::before {
  content: "";
  position: absolute;
  width: 20px; height: 20px;
  left: 2px; top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.sh-switch input:checked + .sh-switch-slider {
  background: var(--sh-success);
}
.sh-switch input:checked + .sh-switch-slider::before {
  transform: translateX(20px);
}

/* AI 解析面板 */
#aiPanelBody { margin-top: 10px; }
#aiInput {
  width: 100%;
  min-height: 110px;
  padding: 12px;
  border: 1px solid var(--sh-border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  background: #fff;
  color: var(--sh-text-1);
  outline: none;
  resize: vertical;
}
#aiInput:focus {
  border-color: var(--sh-primary);
  box-shadow: 0 0 0 3px var(--sh-primary-lighter);
}
.ai-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* 自动建议下拉 */
.customer-suggest {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--sh-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
  z-index: 200;
  max-height: 280px;
  overflow: auto;
  margin-top: 2px;
}
.cust-sug-item {
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--sh-border-light);
}
.cust-sug-item:last-child { border-bottom: none; }
.cust-sug-item:hover { background: var(--sh-primary-lighter); }

/* 业务明细表格 */
.items-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--sh-border-light);
  border-radius: 8px;
}
.items-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.items-table thead th {
  background: #fafafa;
  font-weight: 600;
  color: #6e6e73;
  padding: 8px 10px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--sh-border);
  white-space: nowrap;
  position: static;
  cursor: default;
}
.items-table tbody td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--sh-border-light);
  vertical-align: middle;
}
.items-table tbody tr:last-child td { border-bottom: none; }
.items-table tbody tr:hover { background: #fafbfc; }
.items-table input,
.items-table select {
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
  width: 100%;
  outline: none;
  font-variant-numeric: tabular-nums;
}
.items-table input:hover,
.items-table select:hover { border-color: var(--sh-border); background: #fff; }
.items-table input:focus,
.items-table select:focus {
  border-color: var(--sh-primary);
  background: #fff;
  box-shadow: 0 0 0 3px var(--sh-primary-lighter);
}
.items-table .row-sub {
  color: #34C759;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  display: inline-block;
  padding: 0 8px;
}
.items-table .row-del {
  width: 28px; height: 28px;
  border: none;
  background: transparent;
  color: var(--sh-text-3);
  cursor: pointer;
  font-size: 18px;
  border-radius: 50%;
  line-height: 1;
  font-weight: 300;
  font-family: inherit;
}
.items-table .row-del:hover {
  background: #ffebee;
  color: var(--sh-danger);
}
.items-table .row-del:disabled {
  color: var(--sh-text-3);
  cursor: not-allowed;
  background: transparent;
}

/* ===== 开发票弹窗 — invoice_items 行表 ===== */
#mi_itemsTable tbody td { padding: 6px 8px; vertical-align: middle; }
#mi_itemsTable tbody tr:hover { background: #fafbfc; }
#mi_itemsTable .mi-row-item,
#mi_itemsTable .mi-row-detail,
#mi_itemsTable .mi-row-amount { margin: 0; }
#mi_itemsTable .mi-row-amount { font-variant-numeric: tabular-nums; }

/* 居间信息小标题 */
#invoiceTypeWrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: #6e6e73;
  font-weight: 500;
}
#invoiceTypeWrap select { margin-top: 0; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* R0 验证失败样式 */
.r0-error,
.r0-error:focus {
  border-color: #ff3b30 !important;
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.12) !important;
  background: #FFF5F5 !important;
  animation: r0Shake 0.32s ease;
}
@keyframes r0Shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-3px); }
  75%      { transform: translateX(3px); }
}

/* =====================================================
   移动端响应式 (≤768px)
   设计原则: 减法 + 触摸友好
   ===================================================== */

/* Hamburger 按钮: 桌面隐藏 */
.menu-toggle {
  display: none;
  background: transparent;
  border: none;
  font-size: 24px;
  padding: 4px 8px;
  margin-right: 8px;
  cursor: pointer;
  color: var(--sh-text-1);
  -webkit-tap-highlight-color: transparent;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}
.menu-toggle:active { opacity: 0.5; }

/* Sidebar 遮罩 (默认隐藏) */
.sidebar-mask { display: none; }
.sidebar-mask.open {
  display: block;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 99;
  animation: r0FadeIn 0.2s;
}

/* 底部 Tab Bar (≥769 隐藏, ≤768 显示) */
.bottom-nav {
  display: none;
}
@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: 56px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    z-index: 95;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bn-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--sh-text-3);
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    padding: 6px 0;
    min-height: 56px;
  }
  .bn-tab:active { opacity: 0.6; }
  .bn-tab.active { color: var(--sh-primary); }
  .bn-icon { font-size: 22px; line-height: 1; }
  .bn-text { font-size: 11px; margin-top: 2px; }
  .bn-badge {
    position: absolute;
    top: 4px; right: 22%;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    background: var(--sh-danger);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    border-radius: 9px;
    line-height: 18px;
    text-align: center;
    box-sizing: border-box;
  }

  /* "我" 底部抽屉 */
  .bottom-sheet-mask { display: none; }
  .bottom-sheet-mask.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 96;
    animation: r0FadeIn 0.2s;
  }
  .bottom-sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--sh-bg-card);
    border-radius: 12px 12px 0 0;
    transform: translateY(100%);
    transition: transform 0.25s ease;
    z-index: 97;
    padding-bottom: env(safe-area-inset-bottom);
    max-height: 70vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  }
  .bottom-sheet.open { transform: translateY(0); }
  .bottom-sheet .bs-head {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--sh-bg-hover);
    position: sticky;
    top: 0;
    background: var(--sh-bg-card);
  }
  .bottom-sheet .bs-head h3 { margin: 0; flex: 1; font-size: 16px; font-weight: 600; }
  .bottom-sheet .bs-head .close {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 24px; color: var(--sh-text-2);
  }
  .bottom-sheet .bs-body { padding: 8px 0; }
  .bottom-sheet .bs-item {
    display: block;
    padding: 14px 20px;
    color: var(--sh-text-1);
    font-size: 15px;
    text-decoration: none;
    border-bottom: 1px solid var(--sh-bg-hover);
    cursor: pointer;
    min-height: 44px;
  }
  .bottom-sheet .bs-item:active { background: var(--sh-bg-hover); }
  .bottom-sheet .bs-item.danger { color: var(--sh-danger); }
  .bottom-sheet .bs-meta {
    padding: 12px 20px;
    font-size: 12px;
    color: var(--sh-text-3);
    text-align: center;
  }

  /* 给主区加底部留白, 不让内容被 nav 挡住 */
  .main { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
}

/* === 平板 + 手机 (≤768px) === */
@media (max-width: 768px) {
  body { font-size: 14px; }
  html, body { -webkit-text-size-adjust: 100%; }

  /* Sidebar 默认隐藏, 抽屉化 */
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 240px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 100;
    box-shadow: none;
    border-right: none;
    background: var(--sh-bg-card);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 2px 0 24px rgba(0, 0, 0, 0.15);
  }

  /* 主区占满 */
  .main { margin-left: 0; padding: 12px; }

  /* 顶部 header: hamburger 显示 */
  .menu-toggle { display: inline-flex; }
  .header { padding: 8px 0 12px; }

  /* Dashboard 卡片: 自适应 (auto-fill 至少 2 列) */
  .dash-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important;
    gap: 10px !important;
  }
  .dash-card { padding: 14px 12px; min-height: 80px; }
  .ctitle { font-size: 13px; }
  .ccount { font-size: 22px !important; }
  .cdesc { font-size: 12px; }

  /* 表格: 横滚容器 + sticky 第 1 列 */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  }
  table { min-width: 720px; }
  thead th {
    position: sticky;
    top: 0;
    background: var(--sh-bg-card);
    z-index: 3;
    font-size: 13px;
  }
  /* sticky 第 1 列 (订单号/客户名) */
  table td:first-child, table th:first-child {
    position: sticky;
    left: 0;
    background: var(--sh-bg-card);
    z-index: 2;
    box-shadow: 1px 0 0 rgba(0,0,0,0.06);
  }
  thead th:first-child { z-index: 4; }

  /* Toolbar: 紧凑, 关键按钮显眼 */
  .toolbar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0;
  }
  .tb-btn {
    padding: 8px 12px;
    font-size: 13px;
    min-height: 36px;
  }
  #searchBox { width: 100%; order: 99; }

  /* Pager 紧凑 */
  .pager { padding: 8px 0; font-size: 13px; }

  /* 表单 (新建订单 / 编辑): 单列, 大字号, 大触摸目标 */
  .edit-grid { grid-template-columns: 1fr !important; gap: 10px !important; }
  input, select, textarea {
    font-size: 16px !important;       /* iOS 不缩放 */
    padding: 10px 12px !important;
    min-height: 44px;
  }
  input[type="checkbox"], input[type="radio"] {
    width: 20px; height: 20px; min-height: auto;
  }

  /* Modal 全屏化 */
  .modal-mask { padding: 0; }
  .modal, .filter-panel, .create-page {
    width: 100% !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }
  .modal .body, .filter-panel .body {
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 弹窗头部更大, sticky */
  .modal .head, .filter-panel .head, .create-page .head {
    padding: 14px 16px;
    position: sticky;
    top: 0;
    background: var(--sh-bg-card);
    z-index: 5;
  }
  .modal .foot, .filter-panel .foot, .create-page .foot {
    padding: 12px 16px;
    position: sticky;
    bottom: 0;
    background: var(--sh-bg-card);
    border-top: 1px solid var(--sh-bg-hover);
  }

  /* Chips bar 换行 */
  .chips-bar { flex-wrap: wrap; padding: 6px 0; font-size: 12px; }

  /* Field chips 触摸友好 */
  .field-chip { min-height: 36px; padding: 6px 10px; font-size: 13px; }
}

/* === 小屏手机 (≤480px) === */
@media (max-width: 480px) {
  body { font-size: 13px; }
  h1 { font-size: 16px; }
  .dash-grid {
    grid-template-columns: 1fr !important;   /* 单列堆叠 */
  }
  .dash-card { min-height: 72px; padding: 12px; }
  .ctitle { font-size: 14px; }
  .ccount { font-size: 26px !important; }
  .tb-btn { padding: 10px 14px; min-height: 40px; }
}

/* 触摸设备反馈 */
@media (hover: none) {
  .tb-btn:active, .dash-card:active { opacity: 0.7; }
}

/* === 全局动画 (移动端用) === */
@keyframes r0FadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

