/* ==================================================================
 * ERP 设计系统
 * 无外部依赖，全部手写 CSS
 * ================================================================== */
:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-light: #eff6ff;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --border: #e5e8ef;
  --border-strong: #d3d8e3;
  --text: #1f2430;
  --text-2: #5b6478;
  --text-3: #8b93a7;
  --green: #16a34a;
  --green-bg: #ecfdf3;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --orange: #ea580c;
  --orange-bg: #fff7ed;
  --purple: #7c3aed;
  --purple-bg: #f5f3ff;
  --blue-bg: #eff6ff;
  --gray-bg: #f1f3f7;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 4px 16px rgba(16, 24, 40, .08);
  --shadow-lg: 0 18px 48px rgba(16, 24, 40, .18);
  --sidebar-w: 224px;
  --topbar-h: 48px;
  --font: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
.muted { color: var(--text-3); }
.strong { font-weight: 600; }
.align-right { text-align: right; }
.align-center { text-align: center; }
/* 表格自带的 .xxx-table th { text-align: left } 优先级是 (0,1,1)，会盖掉只有 (0,1,0) 的
   .align-right / .align-center。结果就是「表头永远左对齐、数据却右对齐/居中」，每列都对不上。
   这里用更高的优先级把对齐类救回来（表头和数据用同一套对齐规则才能对齐）。 */
.data-table th.align-right, .data-table td.align-right,
.items-table th.align-right, .items-table td.align-right { text-align: right; }
.data-table th.align-center, .data-table td.align-center,
.items-table th.align-center, .items-table td.align-center { text-align: center; }
/* 数字列用等宽数字，避免每行宽度抖动导致看起来没对齐 */
.data-table td.align-right, .items-table td.align-right { font-variant-numeric: tabular-nums; }
.clickable { cursor: pointer; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cdd3e0; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #b3bbcc; background-clip: content-box; }

/* ==================== 登录页 ==================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 45%, #3b82f6 100%);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 34px 32px 28px;
}
.login-logo { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 6px; }
.login-logo-mark {
  width: 42px; height: 42px; border-radius: 11px;
  background: linear-gradient(135deg, var(--brand), #60a5fa);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 19px; letter-spacing: -.5px;
}
.login-title { font-size: 20px; font-weight: 700; text-align: center; margin-top: 8px; }
.login-sub { text-align: center; color: var(--text-3); font-size: 13px; margin: 6px 0 22px; }
.login-field { margin-bottom: 14px; }
.login-field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.login-notice {
  margin-top: 16px; padding: 10px 12px; background: var(--brand-light);
  border-radius: var(--radius-sm); font-size: 12px; color: #1e40af; line-height: 1.6;
}
.login-error { background: var(--red-bg); color: var(--red); padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 12px; }
.login-foot { text-align: center; color: var(--text-3); font-size: 12px; margin-top: 18px; }

/* ==================== 布局 ==================== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: #111827;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 40;
  transition: transform .22s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--brand), #60a5fa);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}
.sidebar-name { color: #fff; font-weight: 600; font-size: 14px; line-height: 1.25; }
.sidebar-role { color: #7c8798; font-size: 11px; }
.nav { flex: 1; overflow-y: auto; padding: 10px 8px 20px; }
.nav::-webkit-scrollbar-thumb { background: #374151; background-clip: content-box; }
.nav-group { margin-bottom: 4px; }
.nav-group-title {
  padding: 12px 10px 6px; font-size: 11px; letter-spacing: .8px;
  color: #64748b; text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: #cbd5e1; font-size: 13.5px; cursor: pointer;
  user-select: none; transition: background .14s, color .14s;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav-icon { width: 18px; text-align: center; font-size: 14px; flex: none; opacity: .95; }
.nav-badge {
  margin-left: auto; background: var(--red); color: #fff; font-size: 11px;
  padding: 1px 6px; border-radius: 9px; font-weight: 600;
}
.sidebar-foot { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.07); font-size: 11px; color: #64748b; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 18px;
  position: sticky; top: 0; z-index: 30;
}
.topbar-title { font-weight: 600; font-size: 15px; }
.topbar-spacer { flex: 1; }
.hamburger { display: none; background: none; border: 0; font-size: 20px; cursor: pointer; color: var(--text-2); padding: 4px 6px; }
.user-chip { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 5px 9px; border-radius: 20px; }
.user-chip:hover { background: var(--gray-bg); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), #60a5fa);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; flex: none;
}
.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 11px; color: var(--text-3); }
.dropdown {
  position: absolute; right: 14px; top: 52px; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); min-width: 168px; padding: 6px; z-index: 50;
}
.dropdown-item {
  padding: 8px 10px; border-radius: 6px; font-size: 13px; cursor: pointer; display: flex; align-items: center; gap: 8px;
}
.dropdown-item:hover { background: var(--gray-bg); }
.dropdown-item.danger { color: var(--red); }
.dropdown-sep { height: 1px; background: var(--border); margin: 5px 0; }

.content { flex: 1; padding: 18px 20px 40px; min-width: 0; }

/* ==================== 页面 ==================== */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 14px; flex-wrap: wrap;
}
.page-title { font-size: 19px; font-weight: 700; }
.page-subtitle { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }
.breadcrumb { font-size: 12px; color: var(--text-3); margin-bottom: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-body { display: flex; flex-direction: column; gap: 14px; }

/* ==================== 卡片 ==================== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border); gap: 12px;
}
.card-title { font-size: 14.5px; font-weight: 600; }
.card-extra { display: flex; gap: 8px; align-items: center; }
.card-body { padding: 14px 16px; }
.card-body.no-pad { padding: 0; }

/* ==================== 按钮 ==================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: #fff; color: var(--text);
  font-size: 13.5px; font-family: var(--font); cursor: pointer;
  transition: all .14s; white-space: nowrap;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--gray-bg); color: var(--brand); border-color: transparent; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-icon { font-size: 14px; }
.link-btn {
  background: none; border: 0; color: var(--brand); cursor: pointer;
  font-size: 13px; padding: 2px 6px; border-radius: 5px; font-family: var(--font);
}
.link-btn:hover { background: var(--brand-light); }
.link-btn.danger { color: var(--red); }
.link-btn.danger:hover { background: var(--red-bg); }
.row-actions { white-space: nowrap; }

/* ==================== 表格 ==================== */
/* ★ 这里【只能】横向滚动 ✗ 不能让它变成纵向滚动容器 ✓
   原因：overflow-x:auto 会让 CSS 把这个 div 当成「滚动容器」✗
   于是表头的 position:sticky 就吸在这个 div 上 ✗ 而它本身不纵向滚动 →
   往下翻的时候表头一起滚走了 ✗（使用人员反馈：入库/出库列表往下翻看不到表头 ✓）
   改成 overflow-y:clip：横向照样能滚 ✓ 但不算纵向滚动容器 ✓
   表头就吸到外层真正滚动的框上 ✓ 一直看得见 ✓ */
/* ★ 所有表格统一：表头固定在卡片标题下方，只有数据行滚动 ✓
   以前表头跟着数据一起滚走（使用人员要求改）——
   把表格外层做成"高度按屏幕自适应、框内滚动"的容器，
   表头 position:sticky 就能稳稳固定在这个容器顶部。 */
.table-wrap {
  position: relative;
  max-height: clamp(260px, 58vh, 760px);
  overflow: auto;
  overscroll-behavior: contain;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left; font-weight: 600; color: var(--text-2); font-size: 12.5px;
  padding: 10px 12px; background: #fafbfd; border-bottom: 1px solid var(--border);
  white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:hover { background: #fafbff; }
.data-table tbody tr.clickable:hover { background: var(--brand-light); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .num { font-variant-numeric: tabular-nums; }

/* ==================== 徽标 / 状态 ==================== */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 12px; font-weight: 500; line-height: 18px; white-space: nowrap;
}
.badge-gray { background: var(--gray-bg); color: var(--text-2); }
.badge-blue { background: var(--blue-bg); color: #1d4ed8; }
.badge-green { background: var(--green-bg); color: #15803d; }
.badge-red { background: var(--red-bg); color: #b91c1c; }
.badge-orange { background: var(--orange-bg); color: #c2410c; }
.badge-purple { background: var(--purple-bg); color: #6d28d9; }

/* ==================== 统计卡 ==================== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-sm); border-left: 3px solid var(--brand);
}
.stat-card.clickable:hover { box-shadow: var(--shadow); transform: translateY(-1px); transition: all .15s; }
/* 数据卡点击后跳到的模块：闪一下高亮，知道跳到哪了 */
.card.focus-flash { box-shadow: 0 0 0 3px rgba(37, 99, 235, .35), var(--shadow) !important; }
.stat-blue { border-left-color: var(--brand); }
.stat-green { border-left-color: var(--green); }
.stat-orange { border-left-color: var(--orange); }
.stat-red { border-left-color: var(--red); }
.stat-purple { border-left-color: var(--purple); }
.stat-label { font-size: 12.5px; color: var(--text-3); }
.stat-value { font-size: 23px; font-weight: 700; margin-top: 5px; font-variant-numeric: tabular-nums; }
.stat-unit { font-size: 13px; font-weight: 500; color: var(--text-3); margin-left: 3px; }
.stat-hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }

/* ==================== 工具栏 ==================== */
.toolbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.toolbar-fields { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.tb-field { display: flex; flex-direction: column; gap: 4px; }
.tb-field.wide { min-width: 250px; }
.tb-label { font-size: 12px; color: var(--text-3); }
.toolbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar-hint { width: 100%; font-size: 12px; color: var(--text-3); }

/* ==================== 表单 ==================== */
.input {
  height: 34px; padding: 0 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-size: 13.5px; font-family: var(--font);
  color: var(--text); background: #fff; width: 100%; outline: none;
  transition: border-color .14s, box-shadow .14s;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.input:disabled, .input[readonly] { background: #f7f8fa; color: var(--text-2); }

/* 数字框去掉上下小箭头 —— 填数量 / 重量时很容易误点到，
   点一下数字就变了，还不容易发现。滚轮误改的问题在 app.js 里 blur 掉。 */
.input[type="number"]::-webkit-outer-spin-button,
.input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}
.input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.input-sm { height: 30px; font-size: 13px; }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.5; }
select.input { cursor: pointer; }
.switch { width: 40px; height: 22px; appearance: none; background: #cbd5e1; border-radius: 20px; position: relative; cursor: pointer; transition: background .16s; }
.switch:checked { background: var(--brand); }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .16s; }
.switch:checked::after { transform: translateX(18px); }

.form-grid { display: grid; gap: 14px 16px; }
.form-item { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.form-label { font-size: 13px; color: var(--text-2); }
.form-label .req { color: var(--red); }
.form-help { font-size: 12px; color: var(--text-3); }

/* ==================== 明细编辑器 ==================== */
.line-items { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.items-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.items-table th {
  background: #fafbfd; padding: 8px 8px; text-align: left; font-weight: 600;
  font-size: 12.5px; color: var(--text-2); border-bottom: 1px solid var(--border);
}
.items-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.items-table tbody tr:last-child td { border-bottom: 0; }
.items-actions { padding: 8px 10px; background: #fafbfd; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.items-footer {
  display: flex; gap: 22px; justify-content: flex-end; align-items: center;
  padding: 10px 14px; background: #f7f9fc; border-top: 1px solid var(--border);
  font-size: 13px; color: var(--text-2);
}
.items-total { font-size: 15px; font-weight: 700; color: var(--text); }

/* ==================== 下料单（241 × 279.4mm 针式连续纸） ==================== */
.cs-stage { padding: 18px; background: #eef1f5; overflow-x: auto; }
.cs-stage .cut-sheet { box-shadow: 0 2px 14px rgba(0, 0, 0, .16); margin: 0 auto; }

/* ==================== 商品选择弹窗 ==================== */
.pick-list { max-height: 380px; overflow-y: auto; margin-top: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.pick-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13px;
}
.pick-item:last-child { border-bottom: 0; }
.pick-item:hover { background: var(--brand-light); }
.pick-code { color: var(--text-3); font-size: 12px; width: 88px; flex: none; }
.pick-name { flex: 1; font-weight: 500; }
.pick-spec { color: var(--text-3); font-size: 12px; width: 110px; }
.pick-unit { color: var(--text-3); font-size: 12px; width: 46px; }
.pick-price { width: 84px; text-align: right; font-variant-numeric: tabular-nums; }

/* ==================== 弹窗 ==================== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .48);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 16px 32px; z-index: 100; overflow-y: auto;
  opacity: 0; transition: opacity .16s;
}
.modal-overlay.show { opacity: 1; }
.modal-box {
  background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 100%; transform: translateY(-8px); transition: transform .18s;
  display: flex; flex-direction: column; max-height: calc(100vh - 80px);
}
.modal-overlay.show .modal-box { transform: translateY(0); }
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 16px 20px 12px; border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-subtitle { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }
.modal-close {
  background: none; border: 0; font-size: 15px; color: var(--text-3);
  cursor: pointer; padding: 3px 7px; border-radius: 6px; line-height: 1;
}
.modal-close:hover { background: var(--gray-bg); color: var(--text); }
.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 12px 20px 16px; border-top: 1px solid var(--border);
}
.confirm-msg { font-size: 14px; line-height: 1.7; }
.confirm-detail { margin-top: 8px; font-size: 13px; color: var(--text-2); background: var(--gray-bg); padding: 9px 11px; border-radius: var(--radius-sm); }

/* ==================== Toast ==================== */
/* ★ 提示气泡【不能挡鼠标】✗（使用人员反馈：工序那边连着操作，点半天没反应，
   要等一会儿再点才行 —— 就是上一条提示气泡浮在右上角把按钮挡住了 ✓）
   pointer-events:none → 气泡只显示、不吃点击 ✓ */
.toast-host {
  position: fixed; top: 18px; right: 18px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  background: #fff; border: 1px solid var(--border); border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 10px 14px; font-size: 13.5px; min-width: 210px; max-width: 400px;
  opacity: 0; transform: translateX(14px); transition: all .2s;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-icon {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #fff; background: var(--brand); font-weight: 700;
}
.toast-success { border-left-color: var(--green); }
.toast-success .toast-icon { background: var(--green); }
.toast-error { border-left-color: var(--red); }
.toast-error .toast-icon { background: var(--red); }
.toast-warn { border-left-color: var(--orange); }
.toast-warn .toast-icon { background: var(--orange); }
.toast-info .toast-icon { background: var(--brand); }
.toast-msg { line-height: 1.5; }

/* ==================== 加载 / 空状态 ==================== */
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 34px; color: var(--text-3); font-size: 13px; }
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--border-strong);
  border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 34px 16px; color: var(--text-3); }
.empty-icon { font-size: 26px; opacity: .35; }
.empty-text { font-size: 13px; }

/* ==================== 分页 ==================== */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; gap: 10px; }
.page-info { font-size: 12.5px; color: var(--text-3); }
.page-btns { display: flex; gap: 4px; }
.page-btn {
  min-width: 30px; height: 30px; padding: 0 8px; border: 1px solid var(--border-strong);
  background: #fff; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text-2);
  font-family: var(--font);
}
.page-btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.page-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.page-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ==================== 详情 ==================== */
.detail-grid { display: grid; gap: 12px 20px; }
.detail-item { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.detail-label { font-size: 12px; color: var(--text-3); }
.detail-value { font-size: 13.5px; font-weight: 500; word-break: break-all; }
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px; font-weight: 600; padding: 4px 0 10px;
}
.section-extra { font-size: 12.5px; font-weight: 400; color: var(--text-3); }

/* ==================== 角色权限矩阵 ==================== */
.perm-group { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; overflow: hidden; }
.perm-group-head {
  display: flex; align-items: center; justify-content: space-between;
  background: #fafbfd; padding: 9px 12px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600;
}
.perm-items { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 11px 12px; }
.perm-item { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.perm-item input { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }

/* ==================== 移动端 ==================== */
/* 手机底部快捷导航（首页/订单/生产/入库/库存） */
.mobile-tabbar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
  justify-content: space-around; align-items: center;
  box-shadow: 0 -4px 14px rgba(16, 24, 40, .10);
}
.mobile-tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px;
  border: 0; background: transparent; padding: 6px 2px; border-radius: 8px;
  font-size: 11px; color: var(--text-3); cursor: pointer;
}
.mobile-tabbar button.active { color: var(--brand); font-weight: 600; }
.mobile-tabbar .tab-icon { font-size: 19px; line-height: 1.1; }
.sidebar-mask { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 35; }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-mask.show { display: block; }
  .main { margin-left: 0; }
  .hamburger { display: block; }
  .content { padding: 14px 12px 36px; }
  .form-grid { grid-template-columns: 1fr !important; }
  .form-item { grid-column: span 1 !important; }
  .detail-grid { grid-template-columns: 1fr !important; }
  .stat-value { font-size: 20px; }
  .page-title { font-size: 17px; }
  .modal-overlay { padding: 12px 8px; }
  .toolbar { padding: 10px 12px; }
  .toolbar-fields { width: 100%; }
  .tb-field { flex: 1 1 140px; }
  .card-body { padding: 12px; }
  .data-table th, .data-table td { padding: 8px 9px; font-size: 13px; }
  /* 数据卡片：手机两列 */
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px; }
  .stat-card { padding: 9px 11px; }
  .stat-value { font-size: 18px; }
  /* 搜索工具栏：竖排、输入框占满 */
  .toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
  .toolbar-fields { width: 100%; gap: 8px; }
  .tb-field { flex: 1 1 100%; min-width: 0; }
  .toolbar-actions { justify-content: flex-start; flex-wrap: wrap; }
  .page-actions { flex-wrap: wrap; }
  /* 弹窗全屏 */
  .modal-overlay { padding: 0; }
  .modal-box { width: 100% !important; max-width: 100vw !important; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .modal-body { padding: 14px; }
  /* 下面留出底部导航的位置 */
  .content { padding-bottom: 72px; }
  .mobile-tabbar { display: flex; }
  /* 首页那些两栏布局，手机上改成一列 */
  .page-body > div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
}
@media print {
  .sidebar, .topbar, .page-actions, .toolbar, .pagination { display: none !important; }
  .main { margin-left: 0; }
  .card { border: 0; box-shadow: none; }
}

/* 顶栏预警铃铛 */
.bell-btn{position:relative;background:transparent;border:0;font-size:19px;line-height:1;cursor:pointer;padding:6px 9px;border-radius:8px;margin-right:6px}
.bell-btn:hover{background:var(--gray-bg)}
.bell-count{position:absolute;top:0;right:2px;min-width:17px;height:17px;line-height:17px;padding:0 4px;border-radius:9px;background:var(--orange);color:#fff;font-size:11px;font-weight:700;text-align:center}
.bell-count.bell-red{background:var(--red)}
/* 可排序的表头：点一下按这列排序（core.js 的 dataTable 自动加上的） */
.data-table th.th-sort { cursor: pointer; user-select: none; white-space: nowrap; }
.data-table th.th-sort:hover { background: #eef2f7; }
.data-table th .th-arrow { color: var(--brand, #2563eb); font-size: 11px; }
/* 拖动排序（用户管理）：拖起来的那行淡一点，落点那一行上边加条蓝线 */
.data-table tbody tr.dragging { opacity: 0.45; }
.data-table tbody tr.drag-over { box-shadow: inset 0 2px 0 0 var(--brand, #2563eb); }
.data-table tbody tr[draggable="true"] { user-select: none; }
/* 拖动排序的把手：跟手型、浅灰，抓起来才明显 */
.drag-handle { cursor: grab; color: #94a3b8; font-size: 16px; letter-spacing: -1px; user-select: none; }
.drag-handle:active { cursor: grabbing; }
/* 单据抬头（公司名 / 单据标题）：可以直接点着改，鼠标放上去给个提示 */
.cs-head-edit, .dn-head-edit { outline: none; cursor: text; }
.cs-head-edit:hover, .dn-head-edit:hover { background: #f2f7ff; }
.cs-head-edit:focus, .dn-head-edit:focus { background: #e8f1ff; box-shadow: inset 0 0 0 2px #4b7bd6; }

/* 库存明细顶部两栏：里面的卡片要撑满各自那一半（宽 + 高），两栏才铺满、才齐平 */
.top-half > .card { flex: 1 1 auto; width: 100%; min-width: 0; }

/* 滚动框里的表格：表头吸顶（使用人员要求：数据多的时候往下滚，表头要一直看得见） */
div[style*="overflow-y"] table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface, #fff);
  box-shadow: inset 0 -1px 0 var(--border, #e5e7eb);
}

/* ================= 滚动/吸顶（最终版 2026-10-28）=================
   使用人员要求（两次纠正确认）：
   · 【整页滚动】html/body 正常滚，不用"内容区单独滚动" ✗
   · 【顶栏吸顶】滚动时顶栏固定在最上面 ✓
   · 表格表头吸顶：整页滚动的表吸在顶栏下面（56px）；
     放进滚动框的列表，框内滚动、表头吸在框顶 ✓
   · 内容多的列表用【按屏幕高度自适应】的滚动框：最大高度 =
     屏幕高 - 300px（至少 220px）→ 不会把页面撑成很多屏 ✓
   为什么：昨天那套（整页滚动 + 顶栏吸顶）用着最顺手，是对的。
   ============================================================== */
html, body { height: auto; }
.main { height: auto; overflow: visible; }
.topbar { position: sticky; top: 0; }
.content { overflow: visible; min-height: 0; }

/* 页面里直接铺开的表格：表头吸在顶栏下面（顶栏 56px）*/
.data-table th { top: var(--topbar-h); z-index: 2; }

/* 内容多的列表：按屏幕自适应高度的滚动框（框内滚动，表头吸框顶）*/
.table-scroll {
  /* 高度跟屏幕走：大屏一屏能看到 12~16 行，小屏 6~8 行，不会把页面撑成很多屏 ✓ */
  max-height: clamp(200px, 42vh, 560px);
  min-height: 180px;
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 0 0 var(--radius) var(--radius);
}
.table-scroll .data-table th,
div[style*="overflow-y"] table thead th { top: 0; }

@media print {
  html, body { overflow: visible; }
  .table-scroll { max-height: none; overflow: visible; }
}
/* ★ 屏幕自适应（笔记本 1366 / 高缩放 125%~150% 的电脑）：
   内容会挤在一屏里，不用左右找、也不用翻很多页 —— 使用人员要求 */
@media (max-width: 1500px) {
  .content { padding: 14px 14px 32px; }
  .data-table th, .data-table td { padding: 8px 9px; }
  .stat-grid { gap: 10px; }
  .stat-card { padding: 12px 14px; }
  .toolbar { gap: 10px; }
  .toolbar-fields { gap: 10px; }
  .tb-field.wide { min-width: 160px; }
}
@media (max-width: 1280px) {
  .data-table th, .data-table td { padding: 7px 8px; font-size: 12.5px; }
  .data-table { font-size: 12.5px; }
  .card-head { padding: 12px 14px 0; }
  .page-head { gap: 8px; }
}
body { min-height: 100vh; overflow: visible; }
/* ★★ 最终兜底：整页滚动（document 滚动）+ 顶栏吸顶 —— 2026-10-28 第三次修正
   之前 html/body 的 height:100% 会把 body 变成独立滚动容器，导致
   · 浏览器窗口滚不动（用户反馈"无法滚动"）✗
   · window.scrollTo / 回到顶部之类失效 ✗
   这里用 !important 把高度和滚动都交回 document。 */
html, body { height: auto !important; }
body { overflow: visible !important; min-height: 100vh; }
.app { min-height: 100vh; }
.main { height: auto !important; overflow: visible !important; }
.content { overflow: visible !important; min-height: 0; }

/* ★ 表格列自适应（内容显示不全、右边被切 ✗）——
   列多时表头/单元格自动换行、按容器宽度铺满，不再往右溢出。 */
.data-table { width: 100%; }
.data-table th { white-space: normal; word-break: break-word; }
.data-table td { white-space: normal; word-break: break-word; }

/* ★ 库存明细：顶部左右两栏高度由屏幕决定、一样高、各自内部滚动 ✓ */
.top-half { display: flex; flex-direction: column; min-height: 0; }
.top-half > .card {
  flex: 1 1 auto; width: 100%; min-width: 0; height: 100%;
  display: flex; flex-direction: column; overflow: auto;
}
.top-half > .card > .card-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

/* ★ 表格固定布局：列多时按容器宽度分，全部列都显示、右边不再被切 */
/* 列宽适配见 core.js：超出容器时按比例缩列宽（不再全局 fixed）*/

/* ★ 滚动框内的表格：列宽按容器平分，保证每一列都能看到（不被右边切掉）*/
/* 见 core.js：列宽按原比例自动缩放到容器宽度（不再平分）*/

/* ★ 长数字/编码允许换行：最后几像素的横向溢出也消掉 */
.data-table th, .data-table td { overflow-wrap: anywhere; }

/* ★ 列多放不下时：框里横向滚动（滚动条明显一点，方便拉）*/
.table-wrap::-webkit-scrollbar { height: 10px; width: 10px; }
.table-wrap::-webkit-scrollbar-thumb { background: #c7d0dd; border-radius: 6px; }
.table-wrap::-webkit-scrollbar-track { background: #f1f5f9; }

/* ★ 表头固定在滚动容器顶部（卡片标题下方），数据行在下面滚 ✓ */
.table-wrap .data-table th { top: 0; z-index: 3; }

/* 打印时全部展开，不滚动、不裁切 */
@media print {
  .table-wrap { max-height: none; overflow: visible; }
  .table-wrap .data-table th { position: static; }
}

/* ★ 兜底：.table-scroll 只作为分组容器，不再自己滚（滚动统一交给 .table-wrap，表头才固定得住）*/
.table-scroll { max-height: none; min-height: 0; overflow: visible; }

/* ★ 小屏（笔记本）隐藏次要列：保证关键列（含已入库/生产进度/操作）不用横向滚动也能看全 */
@media (max-width: 1500px) {
  .data-table .hide-narrow { display: none !important; }
}

/* ★ 小屏再收紧表格内边距：14 列全部放得下，不用横向滚 */
@media (max-width: 1500px) {
  .data-table th, .data-table td { padding-left: 6px; padding-right: 6px; }
}

/* ★ 卡片副标题（说明文字）*/
.card-title-wrap { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.card-sub { font-size: 12.5px; font-weight: 400; color: var(--text-3); line-height: 1.55; white-space: normal; }

/* ★ 页面标题 + 搜索栏【吸顶固定】（使用人员要求：翻到下面列表时也能搜索/看标题）*/
.page-head {
  position: sticky; top: var(--topbar-h); z-index: 18;
  background: var(--bg);
  padding: 8px 0 6px; margin-bottom: 8px;
}
.page-sticky .card.sticky-toolbar {
  position: sticky;
  top: calc(var(--topbar-h) + var(--page-head-h, 88px));
  z-index: 17;
  background: var(--surface);
  box-shadow: 0 6px 16px rgba(16, 24, 40, .12);
}

/* 少数页面的搜索栏不在卡片里（直接放页面里）：也让它吸顶 */
.page-sticky .sticky-toolbar {
  position: sticky;
  top: calc(var(--topbar-h) + var(--page-head-h, 88px));
  z-index: 17;
  background: var(--surface);
  box-shadow: 0 6px 16px rgba(16, 24, 40, .12);
}
.page-sticky div.sticky-toolbar {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ★ 数据卡片（模块数据）也吸顶：标题 → 数据卡片 → 搜索栏 整块固定，
   翻到下面时数据也一直看得见（使用人员要求）*/
.page-sticky > .page-body > .stat-grid.sticky-stats {
  position: sticky;
  top: calc(var(--topbar-h) + var(--page-head-h, 88px));
  z-index: 16;
  background: var(--bg);
  padding-bottom: 8px;
  /* ★ 用实心同色延伸带把“数据卡和下面内容之间的 14px 间隙”盖住，
     滚动时下面的公司抬头/表格行不会从缝里透出来闪一下 */
  box-shadow: 0 14px 0 0 var(--bg);
  transform: translateZ(0);
}
/* ★ 第二层吸顶卡（生产进度 → 各工序待办）：吸在数据卡片下面 */
.page-sticky > .page-body > .sticky-sub {
  position: sticky;
  top: calc(var(--topbar-h) + var(--page-head-h, 88px) + var(--stats-h, 0px));
  z-index: 15;
  background: var(--surface);
  box-shadow: 0 6px 16px rgba(16, 24, 40, .10);
  transform: translateZ(0);
}
/* 搜索栏吸在「标题 + 数据卡片 + 第二层卡」下面 */

/* 搜索栏吸在「标题 + 数据卡片」下面 */
.page-sticky .card.sticky-toolbar {
  top: calc(var(--topbar-h) + var(--page-head-h, 88px) + var(--stats-h, 0px) + var(--sub-h, 0px));
}
.page-sticky .sticky-toolbar {
  top: calc(var(--topbar-h) + var(--page-head-h, 88px) + var(--stats-h, 0px) + var(--sub-h, 0px));
}
/* 报表页：只固定搜索条本身（查询卡里的统计区间/清筛选随页面滚走） */
.page-report .toolbar.sticky-toolbar {
  border-left: none; border-right: none; border-radius: 0;
  box-shadow: 0 6px 16px rgba(16, 24, 40, .12);
  padding: 10px 16px; background: var(--surface);
}

/* 浏览器打开时的安装提示条（安装版 APP 不显示）*/
.browser-print-hint {
  position: fixed; right: 18px; bottom: 18px; z-index: 60;
  width: 380px; max-width: calc(100vw - 36px);
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--orange); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(16, 24, 40, .18);
  padding: 14px 16px; font-size: 13px; line-height: 1.7;
}
.bph-title { font-weight: 600; font-size: 13.5px; color: var(--orange); margin-bottom: 4px; }
.bph-text { color: var(--text-2); }
.bph-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.bph-actions .btn { min-width: 0; }

/* ===== 紧凑吸顶：所有 sticky 区域整体缩小，给内容留高度 ===== */
.page-head {
  padding: 4px 0 3px;
  margin-bottom: 6px;
  gap: 8px;
  align-items: center;
}
.page-title { font-size: 16px; }
.page-subtitle { font-size: 11.5px; margin-top: 1px; line-height: 1.45; }
.page-actions .btn { height: 28px; padding: 0 10px; font-size: 12.5px; }
.page-body { gap: 10px; }

/* 第一排数据卡：吸顶时压成一行（横向可滑），不再换行占两三层 */
.sticky-stats {
  display: flex !important;
  flex-wrap: nowrap;
  gap: 8px;
  padding-bottom: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.sticky-stats .stat-card {
  flex: 1 1 0;
  min-width: 118px;
  padding: 7px 10px;
}
.sticky-stats .stat-label { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sticky-stats .stat-value { font-size: 17px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sticky-stats .stat-unit { font-size: 11.5px; margin-left: 2px; }
.sticky-stats .stat-hint { display: none; }

/* 第二层吸顶（生产进度 各工序待办）：一行横向，压缩高度 */
/* 第二层吸顶再压 */
.sticky-sub .card-head { padding: 5px 10px; }
.sticky-sub .card-sub { display: none; }
.sticky-sub .stat-card { min-width: 108px; padding: 4px 8px; }
.sticky-sub .stat-value { font-size: 15px !important; }
.sticky-sub .card-title { font-size: 13px; }
.sticky-sub .card-sub { font-size: 11px; }
.sticky-sub .card-body { padding: 7px 12px; }
.sticky-sub .stat-grid { display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; scrollbar-width: thin; }
.sticky-sub .stat-card { flex: 0 0 auto; min-width: 120px; padding: 6px 10px; }
.sticky-sub .stat-label { font-size: 11px; white-space: nowrap; }
.sticky-sub .stat-value { font-size: 16px !important; margin-top: 0; white-space: nowrap; }
.sticky-sub .stat-hint { display: none; }

/* 吸顶搜索栏：单行横向，高度压到最小 */
.sticky-toolbar { box-shadow: 0 4px 12px rgba(16, 24, 40, .10); }
.sticky-toolbar .toolbar {
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 6px;
  padding: 6px 10px;
}
.sticky-toolbar .toolbar-fields {
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 6px;
  padding-bottom: 1px;
  scrollbar-width: thin;
}
.sticky-toolbar .tb-field { flex: 0 0 auto; gap: 1px; }
.sticky-toolbar .tb-label { font-size: 10.5px; line-height: 1.2; }
.sticky-toolbar .input { height: 30px; font-size: 12.5px; padding: 0 8px; }
.sticky-toolbar .toolbar-actions { flex-wrap: nowrap; flex: none; gap: 6px; }
.sticky-toolbar .toolbar-actions .btn { height: 30px; padding: 0 10px; font-size: 12.5px; }
.sticky-toolbar .toolbar-hint { display: none; }
.sticky-toolbar .stat-grid { gap: 8px; }

/* 报表页吸顶查询卡：快捷区间/筛选行都压紧 */
.page-report .sticky-toolbar .card-body > div:first-child { margin-bottom: 4px !important; }
.page-report .sticky-toolbar .card-body > div:first-child .btn { height: 27px; padding: 0 9px; font-size: 12px; }
.page-report .sticky-toolbar .toolbar { padding: 4px 10px; }
.page-report .sticky-toolbar .card-body > div:last-child { margin-top: 4px !important; }

/* 手机：恢复两列数据卡 + 搜索栏可换行 */
@media (max-width: 900px) {
  .sticky-stats {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    overflow: visible;
  }
  .sticky-stats .stat-card { min-width: 0; padding: 8px 10px; }
  .sticky-toolbar .toolbar { flex-direction: column; align-items: stretch; }
  .sticky-toolbar .toolbar-fields { flex-wrap: wrap; overflow: visible; }
  .sticky-toolbar .toolbar-actions { flex-wrap: wrap; }
  .sticky-toolbar .toolbar-hint { display: block; }
  .page-head { padding: 3px 0 2px; }
  .page-title { font-size: 15.5px; }
}
/* 大屏：表格区域按视口高度铺满，避免 2560x1440 这类大显示器下面空一大块 */
@media (min-height: 900px) {
  .table-wrap { max-height: clamp(500px, calc(100vh - 440px), 1400px); }
}