/* =====================================================================
 * 采购管理系统 · 全局样式表
 * ---------------------------------------------------------------------
 * 设计系统：清爽企业蓝（白底 + 企业蓝主色 + 轻卡片）。
 * 断点：<768px 单列 + 底部 4 Tab；>=768px 左侧固定导航 + 双栏/表格；
 *       >=1280px 内容区限宽居中；@media print A4 纵向一页、黑白友好。
 *
 * 类名约定（供后续批次 main.js / ui.js / pages-*.js 稳定引用）：
 *   框架   .app-shell .sidebar .sidebar-brand .sidebar-nav .nav-item
 *          .main-area .topbar .topbar-back .topbar-title .main-content
 *          .tabbar .tab-item .tab-icon .tab-label .tab-badge
 *          .page .page-header .page-title .page-subtitle .container
 *   布局   .grid-2 .two-col .row .between .stack .gap-8 .gap-12 .gap-16
 *   卡片   .card .card-header .card-title .card-body .card-footer .divider
 *   列表   .list .list-item .list-item-title .list-item-meta .list-item-extra
 *   按钮   .btn .btn-primary .btn-secondary .btn-ghost .btn-danger .btn-block .btn-sm
 *          .action-bar .action-bar-inner（表单页给 .app-shell 加 .has-action-bar 隐藏底部 Tab）
 *   表单   .form .form-group .form-label .form-control .form-row .form-hint .form-error
 *          .required .segmented .chip .filter-bar .item-row .item-row-summary .item-row-editor
 *   标签   .tag .tag-draft/.tag-pending/.tag-approved/.tag-ordered/
 *          .tag-received/.tag-rejected/.tag-void .badge .dot
 *   文本   .muted .primary-text .danger-text .money .num .text-right .section-title
 *   表格   .table-wrap .table .table-empty .desktop-only .mobile-only .mobile-cards
 *   字典   .dict-tabs .dict-tab .dict-panel .dict-panel__head .dict-panel__hint
 *          .dict-row--disabled .dict-actions
 *   反馈   .toast-wrap .toast .toast-success .toast-error .modal-mask .modal
 *          .modal-header .modal-body .modal-footer .drawer .drawer-mask
 *          .empty .empty-title .empty-desc .skeleton .skeleton-line
 *   首页   .todo-grid .todo-card .todo-count .todo-label .quick-grid .quick-item
 *   登录   .auth-wrap .auth-card .auth-title .auth-desc
 *   打印   .print-root（#print-root，默认隐藏，print 时显示）
 *          .print-view .print-title .print-header .print-table .print-footer
 *          .no-print（打印隐藏） .print-only（仅打印显示） .screen-root（打印时整体隐藏）
 *          打印时给 body 加 .print-active 可隐藏 #app 全部屏幕内容
 *   工具   .hidden .grow .flex
 * ===================================================================== */

/* ---------- 1. 设计令牌 ---------- */
:root {
  --bg: #F5F7FA;
  --card: #FFFFFF;
  --primary: #1A5FD6;
  --primary-soft: #E8F0FE;
  --primary-dark: #154CB0;
  --text: #1F2937;
  --text-muted: #6B7280;
  --border: #E5E7EB;

  --st-draft: #9CA3AF;
  --st-pending: #F59E0B;
  --st-approved: #1A5FD6;
  --st-ordered: #0891B2;
  --st-received: #16A34A;
  --st-rejected: #DC2626;
  --st-void: #6B7280;
  --st-arrived: #7C3AED;
  --danger: #DC2626;

  --st-draft-bg: #F3F4F6;
  --st-pending-bg: #FEF3C7;
  --st-approved-bg: #E8F0FE;
  --st-ordered-bg: #ECFEFF;
  --st-received-bg: #DCFCE7;
  --st-rejected-bg: #FEE2E2;
  --st-void-bg: #F3F4F6;
  --st-arrived-bg: #F3E8FF;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, .06);
  --pad: 16px;
  --gap: 12px;
  --sidebar-w: 236px;
  --tabbar-h: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

/* ---------- 2. 基础重置 ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
table { border-collapse: collapse; }

#app { min-height: 100vh; }

/* 首屏静态占位 */
.boot-loading {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-muted);
}
.boot-loading__spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: boot-spin .8s linear infinite;
}
.boot-loading__text { font-size: 14px; letter-spacing: .5px; }
@keyframes boot-spin { to { transform: rotate(360deg); } }

/* ---------- 3. 应用框架 ---------- */
.app-shell { min-height: 100vh; }

/* 顶部标题栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 12px;
  padding-top: var(--safe-top);
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.topbar-title {
  flex: 1;
  min-width: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-back {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--primary);
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* PC 左侧固定导航：移动端隐藏 */
.sidebar { display: none; }
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
}
.sidebar-brand__name { white-space: nowrap; }
.sidebar-brand__version {
  margin-left: auto;
  flex: 0 0 auto;
  padding: 2px 7px;
  border: 1px solid var(--primary-soft);
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  line-height: 1.5;
}
.sidebar-nav { padding: 12px 8px; display: flex; flex-direction: column; gap: 4px; }

/* ---------- ERP 职能分组菜单（PC 全展开 / 手机分组 Tab） ---------- */
/* 层级表达：分组标题带品牌色竖条 + 组间细分隔线；子项相对标题缩进并带圆点标记 */
.nav-group {
  margin-bottom: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.nav-group:last-child { border-bottom: none; padding-bottom: 0; }
.nav-group-title {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 12px 8px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--text);
  white-space: nowrap;
}
.nav-group-title::before {
  content: '';
  flex: 0 0 auto;
  width: 3px;
  height: 13px;
  border-radius: 2px;
  background: var(--primary);
  opacity: .6;
}
.nav-group-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 8px;
}
.sidebar-nav { gap: 0; }

/* 子项：相对分组标题缩进 + 圆点标记，形成父子层级 */
.sidebar-nav .nav-item {
  position: relative;
  min-height: 38px;
  padding-left: 24px;
  font-size: 13.5px;
}
.sidebar-nav .nav-item::before {
  content: '';
  position: absolute;
  left: 13px;
  top: 50%;
  width: 5px;
  height: 5px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--border);
  transition: background-color .15s ease;
}
.sidebar-nav .nav-item.active::before { background: var(--primary); }
.sidebar-nav .nav-item:hover::before { background: var(--text-muted); }

.mobile-nav { background: var(--card); border-bottom: 1px solid var(--border); }
.group-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 12px;
  scrollbar-width: none;
}
.group-tabs::-webkit-scrollbar { display: none; }
.group-tab {
  flex: 0 0 auto;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  cursor: pointer;
}
.group-tab.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}
.group-menu {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 12px 10px;
  scrollbar-width: none;
}
.group-menu::-webkit-scrollbar { display: none; }
.group-menu .nav-item {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
}
/* 手机端横向胶囊：不继承 PC 侧栏的圆点标记与缩进 */
.group-menu .nav-item { padding-left: 12px; }
.group-menu .nav-item::before { display: none; }
.group-menu .nav-item.active { border-color: var(--primary); }

@media (min-width: 768px) {
  .mobile-nav { display: none !important; }
  .sidebar-nav { flex: 1; min-height: 0; overflow-y: auto; }
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-item .badge { margin-left: auto; }

.main-area { min-height: 100vh; }
.main-content {
  padding: 12px 12px calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
}
.container { width: 100%; max-width: 100%; margin: 0 auto; }

/* 移动端底部 4 Tab 固定 */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, .04);
}
.tab-item {
  position: relative;
  flex: 1;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 11px;
}
.tab-item.active { color: var(--primary); font-weight: 600; }
.tab-icon { font-size: 20px; line-height: 1; }
.tab-label { line-height: 1.2; }
.tab-badge {
  position: absolute;
  top: 4px;
  left: 50%;
  margin-left: 6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--st-rejected);
  color: #FFFFFF;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
}
.app-shell.has-action-bar .tabbar { display: none; }

.page { display: block; }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.page-title { font-size: 18px; font-weight: 700; }
.page-subtitle { margin-top: 2px; font-size: 13px; color: var(--text-muted); }
.section-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 8px; }

/* ---------- 4. 布局工具 ---------- */
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.flex { display: flex; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.grid-2, .two-col { display: flex; flex-direction: column; gap: var(--gap); }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--border); margin: 12px 0; }

/* ---------- 5. 卡片与列表 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--pad);
  margin-bottom: var(--gap);
}
.card:last-child { margin-bottom: 0; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-body { font-size: 14px; }
.card-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.list { display: flex; flex-direction: column; gap: 0; }
.list-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: 0; }
.list-item-title { font-size: 14px; font-weight: 500; word-break: break-all; }
.list-item-meta { margin-top: 4px; font-size: 12px; color: var(--text-muted); }
.list-item-extra { flex-shrink: 0; text-align: right; }

/* ---------- 6. 按钮与操作条 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: opacity .15s ease, background-color .15s ease;
  white-space: nowrap;
}
.btn:active { opacity: .82; }
.btn:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #FFFFFF; }
.btn-secondary { background: var(--card); color: var(--primary); border-color: var(--primary); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-danger { background: var(--danger); color: #FFFFFF; }
.btn-danger-outline { background: var(--card); color: var(--danger); border-color: var(--danger); }
.btn-block { display: flex; width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; }

.action-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: var(--card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, .05);
}
.action-bar-inner { display: flex; gap: 10px; }
.action-bar-inner .btn { flex: 1; }
.app-shell.has-action-bar .main-content { padding-bottom: calc(78px + var(--safe-bottom)); }

/* ---------- 7. 表单 ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  /* 微信 iOS 输入框 <16px 会触发自动缩放，必须保持 16px */
  font-size: 16px;
  line-height: 1.4;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-control::placeholder { color: #9CA3AF; }
.form-control:disabled, .form-control[readonly] { background: var(--bg); color: var(--text-muted); }
textarea.form-control { min-height: 88px; resize: vertical; }
select.form-control {
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}
.form-row { display: flex; gap: 10px; }
.form-row > .form-group { flex: 1; min-width: 0; }
.form-hint { font-size: 12px; color: var(--text-muted); }
.form-error { font-size: 12px; color: var(--danger); }
.form-group.has-error .form-control { border-color: var(--danger); }

.segmented {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.chip {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
}
.chip.active { background: var(--card); color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }
.filter-bar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }

.item-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
  background: var(--card);
}
.item-row-summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
.item-row-editor { padding-top: 10px; border-top: 1px dashed var(--border); margin-top: 8px; }
/* 明细行的参考单价提示：独占整行，避免与数量/单价输入框挤在一行 */
.item-row-editor .ops-item-ref { display: block; margin: -2px 0 6px; }

/* ---------- 8. 标签、徽标与文本 ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.tag-draft { color: var(--st-draft); background: var(--st-draft-bg); }
.tag-pending { color: var(--st-pending); background: var(--st-pending-bg); }
.tag-approved { color: var(--st-approved); background: var(--st-approved-bg); }
.tag-ordered { color: var(--st-ordered); background: var(--st-ordered-bg); }
.tag-received { color: var(--st-received); background: var(--st-received-bg); }
.tag-rejected { color: var(--st-rejected); background: var(--st-rejected-bg); }
.tag-void { color: var(--st-void); background: var(--st-void-bg); text-decoration: line-through; }
/* 已到货状态标签（另一批任务引入的到货环节使用） */
.tag-arrived { color: var(--st-arrived); background: var(--st-arrived-bg); }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--st-rejected);
  color: #FFFFFF;
  font-size: 11px;
  line-height: 18px;
}
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--st-rejected);
  vertical-align: middle;
}

.muted { color: var(--text-muted); }
.primary-text { color: var(--primary); }
.danger-text { color: var(--danger); }
.text-right { text-align: right; }
.money, .num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.money { font-weight: 600; white-space: nowrap; }

/* ---------- 9. 表格与卡片流 ---------- */
.table-wrap { display: none; }
.table { width: 100%; font-size: 13px; }
.table th, .table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th { color: var(--text-muted); font-weight: 500; background: var(--bg); white-space: nowrap; }
.table tbody tr:hover { background: var(--primary-soft); }
.table .text-right { text-align: right; }
.table-empty { padding: 32px 12px; text-align: center; color: var(--text-muted); }

/* 职能页双行单元格：主信息 + 灰色补充信息，提高信息密度而不横向堆列 */
.cell-stack { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cell-main { font-size: 13px; font-weight: 500; line-height: 1.35; color: var(--text, #1F2329); white-space: normal; word-break: break-all; }
.cell-sub { font-size: 11px; line-height: 1.35; color: var(--text-muted); white-space: normal; word-break: break-all; }
.cell-main.cell-nowrap, .cell-nowrap { white-space: nowrap; }
.cell-sub--warn { color: #B45309; font-weight: 600; margin-top: 3px; white-space: nowrap; }
.cell-todo-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #F59E0B; margin-right: 6px; vertical-align: middle; }
.mobile-cards { display: block; }
.desktop-only { display: none; }
.mobile-only { display: block; }

/* ---------- 10. 反馈：Toast / 弹窗 / 抽屉 / 空态 / 骨架 ---------- */
.toast-wrap {
  position: fixed;
  top: calc(12px + var(--safe-top));
  left: 0;
  right: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: #FFFFFF;
  font-size: 14px;
  box-shadow: var(--shadow);
  word-break: break-all;
}
.toast-success { background: var(--st-received); }
.toast-error { background: var(--st-rejected); }

.modal-mask, .drawer-mask {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(17, 24, 39, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
/* 弹层：纵向 flex 布局 + 高度上限。
 * 背景：长表单（新建/编辑订单、到货确认、发票登记）在矮屏或内容多时，
 *       整体高度超过视口，底部「生成订单 / 确认」按钮被挤出屏幕看不到。
 * 方案：弹层整体限高（不超过视口），头部与底部操作条固定，
 *       仅中间 .modal-body 独立滚动，保证按钮永远可见可点。 */
.modal {
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header { font-size: 16px; font-weight: 600; margin-bottom: 10px; flex: 0 0 auto; }
.modal-body {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  /* 留出滚动条宽度，避免滚动条压住输入框右边缘 */
  padding-right: 8px;
  scrollbar-gutter: stable;
}
.modal-footer { display: flex; gap: 10px; margin-top: 20px; flex: 0 0 auto; }
.modal-footer .btn { flex: 1; }
/* 弹层内的表单标题（如「商品明细」）不随内容滚动脱离视野 */
.modal-body .form-label { color: var(--text); }

/* 档案表单：分组 + 两列网格。
 * 滚动改由 .modal-body 统一承担（见上方 .modal 布局说明），
 * 此处不再单独设 max-height，避免出现「弹层内滚动区套滚动区」的双滚动条。 */
.catalog-form { padding-right: 6px; }
.catalog-section { margin: 16px 0 10px; padding-bottom: 6px; border-bottom: 1px solid #E5E7EB; }
.catalog-section:first-child { margin-top: 0; }
.catalog-section__title { font-size: 13px; font-weight: 600; color: var(--primary); }
.catalog-section__hint { font-size: 11px; color: var(--text-muted); margin-top: 3px; line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.form-grid .form-group--wide { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}
.drawer-mask { align-items: flex-end; padding: 0; }
.drawer {
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 16px 16px calc(16px + var(--safe-bottom));
}

.empty { padding: 48px 16px; text-align: center; }
.empty-title { font-size: 15px; color: var(--text); margin-bottom: 6px; }
.empty-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.skeleton { padding: 4px 0; }
.skeleton-line {
  height: 14px;
  margin-bottom: 10px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--bg) 25%, #ECEFF3 50%, var(--bg) 75%);
  background-size: 200% 100%;
  animation: skeleton-shine 1.3s ease-in-out infinite;
}
.skeleton-line.short { width: 55%; }
@keyframes skeleton-shine { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- 11. 首页与登录 ---------- */
.todo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.todo-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 10px;
  text-align: center;
  min-height: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.todo-count { font-size: 24px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.todo-count.has-todo { color: var(--st-pending); }
.todo-label { font-size: 12px; color: var(--text-muted); }
.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.quick-item {
  min-height: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 12px;
  color: var(--text);
}
.quick-item__icon { font-size: 22px; color: var(--primary); }

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 20px;
  text-align: center;
}
.auth-title { font-size: 22px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.auth-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; line-height: 1.6; }
.auth-card .form { text-align: left; }
.auth-card .btn-block { margin-top: 8px; }

/* ---------- 12. 打印容器 ---------- */
.print-root { display: none; }
.print-root.print-preview {
  display: block;
  background: #FFFFFF;
  padding: 20px;
  margin: 12px auto;
  max-width: 210mm;
  box-shadow: var(--shadow);
}
.print-view { color: #111111; font-size: 12pt; line-height: 1.5; }
.print-title {
  color: var(--primary);
  font-size: 20pt;
  font-weight: 700;
  text-align: center;
  letter-spacing: 2px;
  margin-bottom: 12px;
}
.print-header { margin-bottom: 12px; }
.print-header__row { display: flex; justify-content: space-between; gap: 16px; font-size: 11pt; }
.print-table, .print-view .table { width: 100%; border-collapse: collapse; }
.print-table th, .print-table td,
.print-view .table th, .print-view .table td {
  border: 1px solid #333333;
  padding: 6px 8px;
  font-size: 11pt;
  text-align: left;
}
.print-table th { font-weight: 600; }
/* 合同合计行：置于 tbody 末尾（避免 tfoot 逐页重复），加浅底与加粗区分 */
.print-table__total td { font-weight: 600; background: #F5F7FA; }
.print-footer { margin-top: 16px; font-size: 11pt; display: flex; justify-content: space-between; gap: 16px; }
.print-only { display: none; }

/* ---------- 13. PC 自适应（>=768px） ---------- */
@media (min-width: 768px) {
  body { font-size: 14px; }

  .tabbar { display: none; }
  .topbar { display: none; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    background: var(--card);
    border-right: 1px solid var(--border);
  }
  .main-area { margin-left: var(--sidebar-w); }
  .main-content { padding: 24px; }

  .grid-2, .two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
  .grid-2 .card, .two-col .card { margin-bottom: 0; }

  .table-wrap {
    display: block;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
  }
  .mobile-cards { display: none; }
  .desktop-only { display: block; }
  .mobile-only { display: none; }

  .action-bar {
    position: sticky;
    top: 0;
    bottom: auto;
    z-index: 20;
    padding: 12px 0;
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  .action-bar-inner { justify-content: flex-end; }
  .action-bar-inner .btn { flex: 0 0 auto; min-width: 120px; }
  .app-shell.has-action-bar .main-content { padding-bottom: 24px; }

  .page-header { margin-bottom: 16px; }
  .page-title { font-size: 20px; }
  .todo-grid { gap: 16px; }
  .quick-grid { max-width: 560px; }
  .modal-mask { align-items: center; }
  .drawer-mask { align-items: center; padding: 20px; }
  .drawer { max-width: 560px; border-radius: var(--radius); padding: 20px; max-height: 80vh; }
  .form-row { gap: 16px; }
}

/* ---------- 14. 大屏限宽（>=1280px） ---------- */
@media (min-width: 1280px) {
  .main-content > .container, .main-content > .page { max-width: 1180px; margin-left: auto; margin-right: auto; }
}

/* ---------- 15. 打印：A4 纵向一页、隐藏导航与按钮、黑白友好 ---------- */
@media print {
  @page { size: A4 portrait; margin: 12mm; }

  html, body {
    background: #FFFFFF !important;
    color: #000000 !important;
    font-size: 11pt;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body { overflow: visible !important; }

  /* 隐藏一切屏幕交互元素 */
  .no-print, .boot-loading, .sidebar, .tabbar, .topbar, .action-bar,
  .btn, .toast-wrap, .modal-mask, .modal, .drawer-mask, .drawer,
  .filter-bar, .segmented, .skeleton, .screen-root {
    display: none !important;
  }
  /* main.js 打印时给 body 加 .print-active 即可只保留打印容器 */
  body.print-active #app { display: none !important; }

  #print-root, .print-root {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    background: #FFFFFF !important;
  }
  .print-only { display: block !important; }
  .main-area, .main-content, .page, .container {
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
    box-shadow: none !important;
  }
  .card {
    box-shadow: none !important;
    border: 1px solid #333333 !important;
    border-radius: 0 !important;
    padding: 8px !important;
    margin: 0 0 8px !important;
    background: #FFFFFF !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-view, .print-table, .print-view .table,
  .print-title, .print-header, .print-footer {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .print-title { color: var(--primary) !important; }
  .print-table th, .print-table td,
  .print-view .table th, .print-view .table td {
    border: 1px solid #333333 !important;
    background: transparent !important;
    color: #000000 !important;
    padding: 5px 7px !important;
  }
  /* 合同合计行：打印时去底色但保留加粗，区分合计行 */
  .print-table__total td { background: transparent !important; font-weight: 700 !important; }
  .table th, .table td { border: 1px solid #333333 !important; color: #000000 !important; background: transparent !important; }
  .tag { border: 1px solid #333333 !important; color: #000000 !important; background: transparent !important; }
  .muted, .list-item-meta, .page-subtitle { color: #333333 !important; }
  a { color: #000000 !important; text-decoration: none !important; }
  .text-right { text-align: right !important; }
}

/* ---------- 16. 基础数据（数据字典）页 ---------- */
/* 视觉语言对齐企业蓝主色与低饱和灰底，与 .tag / .btn / .form-control / .table 一致 */

/* 字典分类切换：横向可滚动的 chip 条 */
.dict-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.dict-tabs::-webkit-scrollbar { display: none; }

.dict-tab {
  flex: 0 0 auto;
  padding: 6px 12px;
  border: none;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.dict-tab:hover { background: var(--primary-soft); color: var(--primary); }
.dict-tab.is-active {
  background: var(--primary);
  color: #FFFFFF;
  font-weight: 600;
}

/* 明细面板：面板自身即横向滚动容器，窄屏不撑破页面 */
.dict-panel {
  margin-top: 12px;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
/* 表格设最小宽度，窄屏时由 .dict-panel 接管横向滚动 */
.dict-panel .table { min-width: 560px; }
/* 兼容 ui.js renderTable 的包装：窄屏同样显示表格，滚动统一交给 .dict-panel */
.dict-panel .table-wrap {
  display: block;
  max-width: 100%;
  overflow-x: visible;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}
.dict-panel .mobile-cards { display: none; }

.dict-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.dict-panel__hint {
  color: var(--text-muted);
  font-size: 12px;
}
.dict-row--disabled { opacity: .5; }
.dict-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* 只读输入框：与禁用态区分，明确不可编辑（覆盖第 7 节通用只读规则） */
.form-control[readonly] {
  background: #F3F4F6;
  color: #6B7280;
  cursor: not-allowed;
}
.form-control[readonly]:focus {
  border-color: var(--border);
  box-shadow: none;
}

/* 窄屏自适应：面板锁定容器宽度，标题栏可折行，操作列收紧 */
@media (max-width: 767px) {
  .dict-panel { width: 100%; max-width: 100%; }
  .dict-panel__head { flex-wrap: wrap; }
  .dict-actions { gap: 4px; }
}

/* ---------- 17. 窄屏弹层适配（长表单必须完整可见） ---------- */
/* 手机端把弹层贴近全屏：去掉遮罩留白，底部按钮避开 Home Indicator，
 * 同时让弹层高度按动态视口（dvh）计算，避免浏览器地址栏收起/展开时再次溢出。 */
@media (max-width: 640px) {
  /* 底部抽屉：短表单贴底自适应高度，长表单才撑到满屏（由 max-height 兜底） */
  .modal-mask { padding: 0; align-items: flex-end; }
  .modal {
    max-width: none;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 14px 14px 0 0;
    /* 顶部留出状态栏安全区，标题不被刘海/状态栏遮挡；
       底部不留白，由 .modal-footer 统一处理 Home Indicator 安全区 */
    padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 0;
  }
  .modal-header { font-size: 15px; margin-bottom: 8px; }
  .modal-footer {
    margin: 12px -16px 0;
    gap: 10px;
    /* 操作条横跨整宽并贴到屏幕最底部，手指随时可点「生成订单 / 确认」 */
    position: sticky;
    bottom: 0;
    background: var(--card);
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    /* 吸底栏与上方内容之间加一条分隔线，滚动时层级更清晰 */
    box-shadow: 0 -1px 0 var(--border);
  }
  .modal-footer .btn { min-height: 44px; }
  /* 滚动区底部预留吸底栏高度，最后一行内容不被压住 */
  .modal-body { padding-bottom: 4px; }
}

/* v2.9.8：关联采购订单卡片列表（替代原生下拉，避免移动端长文本截断） */
.order-card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.order-card-group-title { font-size: 12px; color: var(--text-muted); margin: 4px 2px 0; }
.order-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--card);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.order-card:hover { border-color: var(--primary); }
.order-card.selected {
  border-color: var(--primary);
  background: rgba(26, 95, 214, .08);
  box-shadow: 0 0 0 2px rgba(26, 95, 214, .18);
}
.order-card.disabled { opacity: .55; cursor: not-allowed; background: var(--bg); }
.order-card__top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.order-card__no { font-weight: 600; font-size: 14px; color: var(--text); word-break: break-all; }
.order-card__supplier { color: var(--text); font-size: 13px; margin-top: 4px; word-break: break-all; }
.order-card__items { color: var(--text); font-size: 13px; margin-top: 4px; word-break: break-all; }
.order-card__meta {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.order-card__amount { color: #B91C1C; font-weight: 600; }
.order-card__tag { color: #D97706; font-size: 12px; margin-top: 4px; }
