:root {
  --bg: #f1f5fb;
  --panel: #ffffff;
  --panel-soft: #f8fafd;
  --border: #e3e9f2;
  --border-strong: #d5dae3;
  --text: #1f2937;
  --text-2: #475569;
  --muted: #8a94a6;
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --primary-soft: #e8effd;
  --ok: #16a34a;
  --ok-soft: #e8f6ee;
  --ok-dark: #15803d;
  --info: #2563eb;
  --info-soft: #e8effd;
  --warn: #d97706;
  --warn-soft: #fdf1e0;
  --danger: #dc2626;
  --danger-soft: #fdeaea;
  --purple: #7c3aed;
  --purple-soft: #f1eafd;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p { margin: 0; }
button { font-family: inherit; }
img { max-width: 100%; }

/* ---------- Layout ---------- */
.layout {
  display: flex;
  height: 100vh;
  height: 100dvh; /* 移动端浏览器地址栏收缩时不跳动 */
  overflow: hidden;
}

/* 移动端菜单按钮 / 遮罩 / 侧栏快捷操作：桌面端隐藏 */
.icon-btn {
  display: none; width: 38px; height: 38px; flex: 0 0 38px;
  border: 1px solid var(--border-strong); background: #fff; border-radius: 10px;
  font-size: 17px; line-height: 1; color: var(--text-2); cursor: pointer;
  align-items: center; justify-content: center;
}
.nav-mask { display: none; position: fixed; inset: 0; background: rgba(17, 24, 39, .42); z-index: 80; }
.side-actions { display: none; gap: 8px; padding: 12px 8px 0; border-top: 1px solid var(--border); }
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ttl-wrap { min-width: 0; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px 12px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 16px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #1e40af);
  color: #fff; font-size: 18px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(29, 78, 216, .28);
}
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: .3px; }
.brand-sub { font-size: 11px; color: var(--muted); }

.nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-group { font-size: 11px; color: var(--muted); padding: 14px 10px 6px; letter-spacing: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); cursor: pointer; font-size: 13.5px;
  border: 1px solid transparent; transition: .15s;
  text-decoration: none;
}
.nav-item:hover { background: #f2f4f7; }
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 600;
  border-color: #c7d9fb;
}
.nav-item .ico { width: 18px; text-align: center; font-size: 15px; }
.nav-badge {
  margin-left: auto; background: var(--danger-soft); color: var(--danger);
  font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 20px;
}

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; display: grid; gap: 4px; }
.foot-item { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); padding: 0 8px; }
.foot-item b { color: var(--text-2); font-weight: 600; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 68px; flex: 0 0 68px; background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
}
.topbar-left h1 { font-size: 17px; font-weight: 700; }
.topbar-left p { font-size: 12px; color: var(--muted); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.clock { font-size: 12.5px; color: var(--muted); margin-right: 4px; font-variant-numeric: tabular-nums; }

.user { display: flex; align-items: center; gap: 8px; padding-left: 12px; border-left: 1px solid var(--border); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft);
  color: var(--primary-dark); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-meta b { font-size: 13px; }
.user-meta span { font-size: 11px; color: var(--muted); }

.content { flex: 1; overflow-y: auto; padding: 20px 24px 40px; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border-strong); background: #fff; color: var(--text-2);
  padding: 7px 14px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 13px; transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-danger { color: var(--danger); border-color: #f3c9c9; background: #fff; }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.panel-head h3 { font-size: 14.5px; font-weight: 700; }
.panel-head .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.panel-body { padding: 18px; }
.panel-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 16px;
}
.toolbar .spacer { flex: 1; }
.search {
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 7px 12px; font-size: 13px; min-width: 200px; outline: none; background: #fff; color: var(--text);
}
.search:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.select {
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 7px 10px; font-size: 13px; background: #fff; outline: none; color: var(--text); cursor: pointer;
}
.select:focus { border-color: var(--primary); }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.kpi {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; right: -18px; top: -18px; width: 70px; height: 70px;
  border-radius: 50%; background: var(--primary-soft); opacity: .55;
}
.kpi.warn::after { background: var(--warn-soft); }
.kpi.danger::after { background: var(--danger-soft); }
.kpi.info::after { background: #dbeafe; opacity: .8; }
.kpi.purple::after { background: var(--purple-soft); }
.kpi.ok::after { background: var(--ok-soft); }
.kpi-label { font-size: 12.5px; color: var(--muted); position: relative; z-index: 1; }
.kpi-value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -.5px; position: relative; z-index: 1; }
.kpi-value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.kpi-foot { font-size: 12px; margin-top: 8px; color: var(--muted); position: relative; z-index: 1; }
.kpi-foot .up { color: var(--primary); font-weight: 600; }
.kpi-foot .down { color: var(--danger); font-weight: 600; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; padding: 11px 14px; background: var(--panel-soft);
  color: var(--muted); font-weight: 600; font-size: 12px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.tbl td { padding: 11px 14px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
table.tbl tbody tr:hover { background: #fafbfc; }
table.tbl tbody tr:last-child td { border-bottom: none; }
td.right, th.right { text-align: right; font-variant-numeric: tabular-nums; }
td.center, th.center { text-align: center; }
td.strong { font-weight: 600; }
.mono { font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
.empty { padding: 44px; text-align: center; color: var(--muted); font-size: 13px; }
.empty .ico { font-size: 30px; display: block; margin-bottom: 8px; opacity: .45; }

/* ---------- Pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600;
  background: #f1f3f7; color: var(--text-2); white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.green { background: var(--ok-soft); color: var(--ok-dark); }
.pill.blue { background: var(--info-soft); color: var(--info); }
.pill.orange { background: var(--warn-soft); color: var(--warn); }
.pill.red { background: var(--danger-soft); color: var(--danger); }
.pill.purple { background: var(--purple-soft); color: var(--purple); }
.pill.gray { background: #f1f3f7; color: var(--muted); }
/* V3.31.0：直接选原料的产品（分装类，不建配方） */
.pill.teal { background: #d9f2ee; color: #0f766e; }

/* ---------- Progress ---------- */
.bar { width: 100%; height: 6px; background: #eef1f5; border-radius: 20px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: 20px; }
.bar.orange > i { background: var(--warn); }
.bar.red > i { background: var(--danger); }
.bar.blue > i { background: var(--info); }
.prog-cell { min-width: 110px; }
.prog-cell .pv { font-size: 12px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }

/* ---------- Modal ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .45);
  display: flex; align-items: center; justify-content: center; z-index: 90;
  padding: 24px; animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.modal {
  background: #fff; border-radius: 14px; width: 560px; max-width: 100%;
  max-height: 88vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  animation: pop .18s ease;
}
@keyframes pop { from { transform: translateY(8px); opacity: 0 } to { transform: none; opacity: 1 } }
.modal.wide { width: 820px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 15px; font-weight: 700; }
.modal-close { border: none; background: none; font-size: 20px; color: var(--muted); cursor: pointer; line-height: 1; }
.modal-body { padding: 18px 20px; overflow: auto; -webkit-overflow-scrolling: touch; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.field label .req { color: var(--danger); }
.field input, .field select, .field textarea {
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 13px; outline: none; background: #fff; color: var(--text);
  font-family: inherit; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field textarea { resize: vertical; min-height: 68px; }
.field .hint { font-size: 11.5px; color: var(--muted); }

/* repeater */
.repeater { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.rep-head, .rep-row { display: grid; gap: 8px; padding: 8px 10px; align-items: center; }
.rep-head { background: var(--panel-soft); font-size: 12px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); }
.rep-row { border-bottom: 1px solid #f0f2f5; }
.rep-row:last-child { border-bottom: none; }
.rep-row input, .rep-row select {
  border: 1px solid var(--border-strong); border-radius: 6px; padding: 6px 8px; font-size: 12.5px; outline: none; width: 100%;
}
.rep-add { padding: 8px 10px; background: var(--panel-soft); }
/* 自动算出来的只读子列（如配方占比） */
.rep-row input.rep-ro {
  background: #f6f8fa; color: #1d4ed8; font-weight: 600; text-align: right;
  border-color: var(--border); cursor: default; padding-right: 14px;
}
.rep-row input.rep-ro:focus { box-shadow: none; border-color: var(--border); }
/* 包材/计数项不参与配比，显示破折号 */
.rep-row input.rep-ro.muted { color: #b7bec9; font-weight: 400; }

/* 配方配比总览：百分比合计与配平校验 */
.pct-sum {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin: 0 18px 16px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--panel-soft);
}
.pct-cell { display: grid; gap: 3px; }
.pct-cell span { font-size: 11.5px; color: var(--muted); }
.pct-cell b { font-size: 17px; color: var(--text); font-variant-numeric: tabular-nums; }
.pct-cell b.ok { color: #15803d; }
.pct-cell b.warn { color: #b45309; }
.pct-tip { grid-column: 1 / -1; font-size: 12.5px; padding-top: 2px; border-top: 1px dashed var(--border); }
@media (max-width: 640px) { .pct-sum { grid-template-columns: 1fr; } }

/* 表格合计行 */
.tbl-sum td { background: var(--panel-soft); border-top: 1px solid var(--border-strong) !important; }

/* ---------- Toast ---------- */
#toastRoot { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; }
.toast {
  background: #fff; border: 1px solid var(--border); border-left: 3px solid var(--primary);
  padding: 10px 18px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  font-size: 13px; animation: pop .18s ease; min-width: 220px;
}
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }

/* ---------- Timeline ---------- */
.timeline { display: grid; gap: 0; }
.tl-item { display: flex; gap: 14px; position: relative; padding-bottom: 18px; }
.tl-item:not(:last-child)::before {
  content: ""; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--border);
}
.tl-dot {
  width: 28px; height: 28px; border-radius: 50%; flex: 0 0 28px; display: flex;
  align-items: center; justify-content: center; font-size: 13px;
  background: var(--primary-soft); color: var(--primary-dark); border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary-soft); z-index: 1;
}
.tl-dot.blue { background: var(--info-soft); color: var(--info); box-shadow: 0 0 0 2px var(--info-soft); }
.tl-dot.orange { background: var(--warn-soft); color: var(--warn); box-shadow: 0 0 0 2px var(--warn-soft); }
.tl-dot.red { background: var(--danger-soft); color: var(--danger); box-shadow: 0 0 0 2px var(--danger-soft); }
.tl-title { font-size: 13.5px; font-weight: 600; }
.tl-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- Cards / misc ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 16px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-title { font-size: 14px; font-weight: 700; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.card-body { margin-top: 14px; display: grid; gap: 8px; }
.kv { display: flex; justify-content: space-between; font-size: 12.5px; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; }

.chart-box { width: 100%; }
.chart-box svg { display: block; width: 100%; height: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }

.split { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; }
.split-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 1180px) {
  .split, .split-3 { grid-template-columns: 1fr; }
}

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--panel-soft); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; font-size: 12px; color: var(--text-2); }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.link {
  background: none; border: none; color: var(--info); cursor: pointer; font-size: 12.5px; padding: 2px 4px;
}
.link:hover { text-decoration: underline; }
.link.danger { color: var(--danger); }
/* 产品库操作栏的「去生产」：主色调，跟编辑/查看区分开 */
.link.produce { color: var(--primary); font-weight: 600; }

.notice {
  background: var(--warn-soft); border: 1px solid #f6dfba; color: #8a5a08;
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 12.5px; margin-bottom: 16px;
  display: flex; gap: 8px; align-items: center;
}

.notice.ok {
  background: var(--ok-soft); border-color: #bfe6cd; color: var(--ok-dark);
}
.notice.warn {
  background: var(--warn-soft); border-color: #f6dfba; color: #8a5a08;
}
.notice.danger {
  background: var(--danger-soft); border-color: #f7c9c9; color: #b91c1c;
}

.trace-chain { display: flex; align-items: stretch; gap: 0; flex-wrap: wrap; }

/* ===========================================================
 * 移动端适配
 * =========================================================== */
html { -webkit-text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; }

/* ---------- ≤980px：侧栏改抽屉，内容区紧凑化 ---------- */
@media (max-width: 980px) {
  .icon-btn { display: flex; }
  .nav-mask.show { display: block; }

  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 85;
    width: 264px; flex-basis: 264px;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .sidebar.open { transform: none; }
  .side-actions { display: flex; }
  .nav-item { padding: 11px 12px; font-size: 14px; }

  .topbar { height: 58px; flex-basis: 58px; padding: 0 14px; }
  .topbar-left h1 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .clock { display: none; }
  .topbar-right .btn-ghost { display: none; }
  .user { padding-left: 0; border-left: none; }
  .user-meta { display: none; }

  .content { padding: 14px 14px calc(30px + env(safe-area-inset-bottom)); }
  .panel-body { padding: 14px; }
  .panel-head { padding: 12px 14px; }

  .toolbar { gap: 8px; }
  .toolbar .search { min-width: 0; flex: 1 1 100%; }
  .toolbar .select { flex: 1 1 140px; min-width: 0; }
  .toolbar .btn { padding: 8px 12px; }

  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 12px; }
  .kpi { padding: 14px 15px; }
  .kpi-value { font-size: 22px; }
  .cards { grid-template-columns: 1fr; gap: 12px; }

  /* iOS 聚焦自动放大：输入框字号提到 16px */
  .field input, .field select, .field textarea,
  .search, .select, .rep-row input, .rep-row select { font-size: 16px; }

  /* 表格横向滚动，列宽保持可读 */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.tbl th, table.tbl td { white-space: nowrap; padding: 9px 11px; }
  td.center, th.center { text-align: center; }

  .link { padding: 8px 6px; font-size: 13px; }
  .row-actions { flex-wrap: wrap; gap: 4px; }
  .row-actions .link { padding: 8px 8px; }

  .notice { align-items: flex-start; line-height: 1.6; }
  .empty { padding: 34px 16px; }
  #toastRoot { top: 12px; width: calc(100% - 24px); left: 12px; transform: none; }
  .toast { min-width: 0; width: 100%; }
}

/* ---------- ≤720px：弹窗改底部抽屉、表单单列 ---------- */
@media (max-width: 720px) {
  .mask { align-items: flex-end; padding: 0; }
  .modal, .modal.wide {
    width: 100%; max-width: 100%; border-radius: 16px 16px 0 0;
    max-height: 92vh; max-height: 92dvh;
    animation: sheet .22s ease;
  }
  @keyframes sheet { from { transform: translateY(40px); opacity: 0 } to { transform: none; opacity: 1 } }
  .modal-head { padding: 14px 16px; }
  .modal-body { padding: 14px 16px; }
  .modal-foot {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    position: sticky; bottom: 0; background: #fff;
  }
  .modal-foot .btn { flex: 1; padding: 11px 12px; font-size: 14px; }

  .form-grid { grid-template-columns: 1fr; gap: 12px; }

  /* 明细行编辑器：表头隐藏，行内自动折行排布 */
  .rep-head { display: none; }
  .rep-row {
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)) !important;
    padding: 10px; gap: 8px; border-bottom: 1px solid var(--border);
  }
  .rep-row:last-child { border-bottom: none; }
  .rep-row input, .rep-row select { padding: 8px 9px; }
  .rep-row .btn-danger { min-height: 34px; width: 100%; }

  /* 追溯链路改为纵向 */
  .trace-chain { flex-direction: column; }
  .tc-node { min-width: 0; width: 100%; }
  .tc-arrow { transform: rotate(90deg); justify-content: center; padding: 6px 0; }

  .split { gap: 12px; }
  .legend { gap: 10px; font-size: 11.5px; }
  .topbar-left p { display: none; }
}

/* ---------- ≤400px：极窄屏再压缩 ---------- */
@media (max-width: 400px) {
  .content { padding: 12px 10px calc(28px + env(safe-area-inset-bottom)); }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi { padding: 12px; }
  .kpi-value { font-size: 19px; }
  .sidebar { width: 84vw; flex-basis: 84vw; }
  .btn { padding: 8px 10px; font-size: 12.5px; }
}

/* ---------- 页签 ---------- */
.tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--border);
  margin-bottom: 16px; overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.tab-btn {
  border: 0; background: transparent; padding: 10px 16px; font-size: 14px;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent;
  white-space: nowrap; font-weight: 500; transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
@media (max-width: 560px) {
  .tab-btn { padding: 10px 12px; font-size: 13px; }
}

/* ---------- 打印 / 投屏看板 ---------- */
@media print {
  .sidebar, .topbar, .toolbar, .tabs { display: none !important; }
  .layout { height: auto; overflow: visible; }
  .content { overflow: visible; padding: 0; }
}
.tc-node {
  flex: 1; min-width: 180px; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; background: var(--panel-soft); position: relative;
}
.tc-arrow { display: flex; align-items: center; padding: 0 10px; color: var(--muted); font-size: 18px; }

/* ---------- 工资表：可编辑网格 ---------- */
.pay-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 12px; padding: 8px 10px; background: var(--panel-soft);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.pay-bar .spacer { flex: 1; }
.pay-grid { font-size: 12.5px; }
.pay-grid th { white-space: nowrap; font-size: 11.5px; line-height: 1.35; }
.pay-grid th small { font-weight: 400; color: var(--muted); font-size: 10px; }
.pay-grid td { padding: 4px 6px; vertical-align: middle; }
.pay-grid input.pc, .pay-grid select.pc {
  width: 100%; min-width: 58px; box-sizing: border-box;
  padding: 4px 6px; font-size: 12.5px; font-family: inherit;
  border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text);
}
.pay-grid input.pc:focus, .pay-grid select.pc:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(29, 78, 216, .12);
}
.pay-grid input.pc:disabled { background: var(--panel-soft); color: var(--muted); }
.pay-grid input.pname { min-width: 74px; font-weight: 600; }
.pay-grid .psub { font-size: 10.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.pay-grid td.calc { background: var(--panel-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pay-grid tfoot td { background: var(--panel-soft); font-weight: 600; border-top: 2px solid var(--border); }
.pay-grid tfoot td.left { text-align: left; font-weight: 400; font-size: 11.5px; }
.pay-preview b { color: var(--primary); }
@media (max-width: 560px) {
  .pay-bar { gap: 6px; padding: 8px; }
  .pay-bar .btn { font-size: 12px; padding: 6px 8px; }
}

/* ============ 考勤管理 ============ */
.att-tabs { display: flex; gap: 8px; margin: 10px 0 12px; }
/* 考勤录入页：只有一条细工具条 + 两个页签，剩下的高度全留给表格，一屏能看更多人 */
.att-entry-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 8px 10px; background: var(--panel-soft); border-radius: 8px; margin-bottom: 10px;
}
.att-entry-bar .spacer { flex: 1; }
.att-entry-tip { font-size: 12px; color: var(--muted); }
.att-entry-tip b { color: #334155; background: #eef2f7; border-radius: 3px; padding: 0 4px; font-weight: 600; }
.att-entry .att-tabs { margin: 0 0 10px; }
/* 录入页没有 KPI / 汇总 / panel 标题，表格能一直铺到屏幕底部 */
.att-sheet-wrap { max-height: calc(100vh - 216px); overflow: auto; }
.att-keys { margin-top: 8px; font-size: 12px; color: var(--muted); }
.att-brush {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  padding: 8px 10px; background: var(--panel-soft); border-radius: 8px;
  font-size: 12.5px; color: var(--muted); margin-bottom: 10px;
}
.att-brush .spacer { flex: 1; }
.att-brush .brush.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.att-brush input { padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; font-size: 12.5px; }
.att-grid { font-size: 12px; }
.att-grid th { font-size: 11px; padding: 4px 3px; white-space: nowrap; }
.att-grid td { padding: 2px; }
.att-grid .att-name {
  position: sticky; left: 0; z-index: 2; background: #fff;
  min-width: 96px; font-weight: 600; text-align: left; padding: 4px 8px;
  border-right: 1px solid var(--border);
}
.att-grid .att-sum {
  position: sticky; right: 0; background: var(--panel-soft);
  min-width: 42px; text-align: center; font-variant-numeric: tabular-nums;
  box-shadow: inset 1px 0 0 var(--border);
}
.att-grid .att-d { min-width: 26px; text-align: center; }
.att-grid .att-d small { display: block; font-weight: 400; color: var(--muted); font-size: 9px; }
.att-grid .att-d.we { background: #f4f6f9; }
.acell {
  width: 26px; min-width: 26px; height: 26px; text-align: center; cursor: pointer;
  font-size: 12px; font-weight: 600; border-radius: 5px; user-select: none;
}
.acell:hover { outline: 2px solid var(--primary); }
.acell i { display: block; font-style: normal; font-size: 9px; font-weight: 400; color: var(--muted); }
.acell.we { background: #f7f8fa; }
.acell.s-w { background: #e7f6ec; color: #15803d; }
.acell.s-ot { background: #e3edfd; color: #1d4ed8; }
.acell.s-h { background: #d9f2ee; color: #0f766e; }
.acell.s-tr { background: #efe7fd; color: #6d28d9; }
.acell.s-r { background: #f1f3f6; color: #6b7280; }
.acell.s-lv { background: #fdf0e0; color: #b45309; }
.acell.s-ab { background: #fde7e7; color: #dc2626; }
/* 日历格里的计件角标：当天有计件就显示金额 */
.acell b.pz { display: block; font-size: 9px; font-weight: 700; color: #0f766e; line-height: 1.1; }
.acell.pzonly { background: #e9f9f1; color: #0f766e; }
/* 日历格里的「请假小时」角标（红色，跟加班的黑色角标区分） */
.acell i.lv { color: #b45309; font-weight: 700; }
/* 画笔切到「计件」时的产品 / 数量录入 */
.att-brush .piece-box { display: none; align-items: center; gap: 6px; }
.att-brush.piece .piece-box { display: inline-flex; }
.att-brush.piece .st-box { display: none; }
.att-brush .piece-box select, .att-brush .piece-box input { padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; font-size: 12.5px; }
.att-brush .piece-box .pz-price { font-size: 12px; color: #0f766e; font-weight: 600; }
/* 计件明细弹窗 */
.piece-tbl input, .piece-tbl select { width: 100%; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; font-size: 12.5px; background: #fff; }
.piece-tbl input[type="number"] { text-align: right; }
.piece-tbl td { vertical-align: middle; }
.piece-tbl .pz-amt { font-variant-numeric: tabular-nums; font-weight: 600; color: #0f766e; }
.tbl .psub { font-size: 10.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; }
@media (max-width: 560px) {
  .att-brush { gap: 4px; font-size: 12px; }
  .att-entry-bar { gap: 6px; padding: 7px 8px; }
  .att-entry-tip { display: none; }
  .att-grid .att-name { min-width: 72px; font-size: 11.5px; }
  .att-sheet-wrap { max-height: calc(100vh - 254px); }
}

/* ---- 考勤表录入（与人事 Excel 考勤表同版式：一人三行、一天一列） ---- */
/* 不要撑满整行：31 天 + 汇总正好一屏，屏幕上就不用左右拖了 */
/* 表格不撑满整行（31 天 + 汇总正好一屏）；输入框给死宽度，否则自动布局会把列撑到 50px+ */
table.att-sheet { width: 100%; max-width: 1350px; table-layout: fixed; font-size: 12px; }
.att-sheet th.att-d, .att-sheet td.att-d { width: 34px; }
.att-sheet th.att-name, .att-sheet td.att-name { width: 104px; }
/* 列宽之和必须正好等于表宽（28+88+31×26+66×3=1120）：
   table-layout:fixed 下有富余会把列撑开、sticky 的 right 偏移就对不上；
   1120px 在 1366 宽的笔记本上也不用左右拖。
   注意选择器要写 table.att-sheet td（0,1,2）才能压过全局 table.tbl td（0,1,2）
   —— 只写 .att-sheet td 是 (0,1,1)，会被全局 11px 内边距吃掉，行高变成 50px。 */
table.att-sheet { width: 1186px; table-layout: fixed; font-size: 12px; }
table.att-sheet th.att-d, table.att-sheet td.att-d { width: 26px; min-width: 26px; }
table.att-sheet th.att-name, table.att-sheet td.att-name { width: 88px; }
table.att-sheet th.att-sn, table.att-sheet td.att-sn { width: 28px; min-width: 28px; }
table.att-sheet th.att-sum.k1, table.att-sheet th.att-sum.k2, table.att-sheet th.att-sum.k3, table.att-sheet th.att-sum.k4,
table.att-sheet td.att-sum.k1, table.att-sheet td.att-sum.k2, table.att-sheet td.att-sum.k3, table.att-sheet td.att-sum.k4 { width: 66px; min-width: 66px; }
table.att-sheet th { padding: 3px 2px; text-align: center; font-size: 11px; font-weight: 600; }
.att-sheet th small { display: block; font-weight: 400; color: #b0b7c3; font-size: 9px; }
.att-sheet th.att-sn { text-align: center; padding: 3px 4px; }
.att-sheet th.att-name {
  position: sticky; left: 0; z-index: 4; background: var(--panel-soft);
  text-align: left; padding: 3px 8px; border-right: 1px solid var(--border);
}
/* 表头也要跟数据一样钉在右边，否则汇总数字在上面会「找不到表头」 */
.att-sheet th.att-sum { position: sticky; z-index: 4; background: var(--panel-soft); text-align: right; padding: 3px 8px; }
.att-sheet th.att-sum.k1 { right: 198px; }
.att-sheet th.att-sum.k2 { right: 132px; }
.att-sheet th.att-sum.k3 { right: 66px; }
.att-sheet th.att-sum.k4 { right: 0; }
table.att-sheet td { padding: 1px; border-bottom: 1px solid #f0f2f5; }
.att-sheet td.att-sn { text-align: center; color: #b0b7c3; font-size: 11px; vertical-align: middle; }
.att-sheet td.att-name {
  position: sticky; left: 0; z-index: 2; background: #fff;
  font-weight: 600; text-align: left; padding: 3px 8px;
  vertical-align: middle; border-right: 1px solid var(--border);
}
.att-sheet td.att-sum {
  position: sticky; background: #fbfcfd; text-align: right; padding: 3px 8px;
  font-variant-numeric: tabular-nums; font-weight: 600; vertical-align: middle;
  box-shadow: inset 1px 0 0 var(--border);
}
.att-sheet td.att-sum.k1 { right: 198px; }
.att-sheet td.att-sum.k2 { right: 132px; }
.att-sheet td.att-sum.k3 { right: 66px; }
.att-sheet td.att-sum.k4 { right: 0; }
.att-sheet input.sc {
  width: 24px; min-width: 0; box-sizing: border-box; border: 1px solid transparent;
  background: transparent; text-align: center; font: inherit; color: var(--text);
  padding: 3px 0; border-radius: 5px; outline: none;
}
.att-sheet input.sc:hover { border-color: #dfe3ea; }
.att-sheet input.sc:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 2px var(--primary-soft); }
.att-sheet input.s-h { color: #0f766e; font-weight: 700; }
.att-sheet input.s-tr { color: #6d28d9; font-weight: 700; }
.att-sheet input.s-r { color: #9aa3b2; }
.att-sheet input.s-lv { color: #b45309; font-weight: 700; }
.att-sheet input.s-ab { color: #dc2626; font-weight: 700; }
.att-sheet input.s-ot { color: #1d4ed8; }
/* 中排（加班 / 请假）：这天有按小时的假 —— 红字 + 淡红底，一眼看出来 */
table.att-sheet input.s-ot.has-lv { color: #b45309; background: #fdf3e6; border-color: #f0d3ab; }
.att-sheet td.we { background: #f5f7fa; }
.att-sheet tr.att-ot td { background: #fcfdff; }
.att-sheet tr.att-ot td.we { background: #f2f5f9; }
.att-sheet tr.att-lv td { background: #fffaf2; }
.att-sheet tr.att-lv td.we { background: #fdf3e6; }
/* 第三行 = 计件：格子里显示当天计件金额，点一下开「选产品 + 数量」小窗 */
.att-sheet tr.att-piece td { background: #fbfefc; border-bottom: 1px solid #e3efe9; }
.att-sheet tr.att-piece td.we { background: #f4faf7; }
table.att-sheet td.pcell {
  cursor: pointer; text-align: center; color: #0f766e; font-weight: 600; font-size: 11px;
  font-variant-numeric: tabular-nums; user-select: none;
}
table.att-sheet td.pcell:hover { background: #d9f5e8; box-shadow: inset 0 0 0 1px #34d399; }
table.att-sheet td.pcell.empty { color: #c3cad4; font-weight: 400; }
/* 小时工（V3.28.0）：出勤格空着、只在加班行填了小时 —— 出勤格淡蓝底 + 左侧一道竖线，
   看着像「这天没排班但记了工时」，跟漏填区分开 */
table.att-sheet input.sc.only-ot {
  background: #eef4ff; border-color: #c7d9fb;
  box-shadow: inset 2px 0 0 #6d9bf5;
}
.att-grid td.acell.otonly { background: #eef4ff; box-shadow: inset 2px 0 0 #6d9bf5; }
.att-sheet td.today { box-shadow: inset 2px 0 0 var(--primary), inset -1px 0 0 var(--primary); }
.att-sheet tr.att-att td { border-bottom-color: #e8ecf1; }
table.att-sheet tfoot td { padding: 3px 8px; border-top: 1px solid var(--border); background: #f7f9fb; }
.att-sheet th.today {
  color: var(--primary); background: var(--primary-soft);
  box-shadow: inset 2px 0 0 var(--primary), inset -1px 0 0 var(--primary);
}

/* ===========================================================
   打印：发货单 / 箱唛
   屏幕上就是一张带阴影的 A4 白纸（210×297mm，内边距 14mm）；
   打印时 @page margin 同样是 14mm，内容宽度都是 182mm —— 所见即所得，
   预览里怎么换行，打出来就怎么换行。
   打印瞬间给 body 加 .printing，@media print 只在这个类作用域下
   隐藏界面其它部分（平时 Ctrl+P 打的是正常页面，不受影响）。
   =========================================================== */
@page { size: A4 portrait; margin: 14mm; }

.print-mask {
  position: fixed; inset: 0; z-index: 9000; background: #0f172a;
  display: flex; flex-direction: column;
}
.print-bar {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: #1e293b; color: #e2e8f0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
}
.print-bar .pb-l { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.print-bar .pb-l b { font-size: 14px; color: #fff; font-weight: 700; }
.print-bar .pb-l span { font-size: 12px; color: #94a3b8; }
.print-bar .spacer { flex: 1; }
.print-stage {
  flex: 1; overflow: auto; padding: 20px 0 40px; background: #334155;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}
.print-sheet {
  flex: none; width: 210mm; min-height: 297mm; padding: 14mm;
  background: #fff; color: #000; box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
  font-size: 12px; line-height: 1.5;
}

/* ---------- 条码（Code 128，纯 div 画条，不依赖字体） ---------- */
.bc { position: relative; display: inline-block; vertical-align: top; }
.bc i { position: absolute; top: 0; bottom: 0; display: block; background: #000; }
.bc-txt {
  font: 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 2px; text-align: center; margin-top: 2px; color: #000;
}

/* ---------- 发货单 / 送货单 ---------- */
.dp-hd {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 2px solid #111; padding-bottom: 8px;
}
.dp-co-n { font-size: 20px; font-weight: 800; letter-spacing: .5px; }
.dp-co-s { font-size: 11px; color: #444; margin-top: 3px; }
.dp-t { text-align: right; flex: none; }
.dp-t-n { font-size: 26px; font-weight: 800; letter-spacing: 6px; }
.dp-t-s { font-size: 11px; color: #444; margin-top: 2px; }
.dp-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  border: 1px solid #111; border-bottom: 0; margin-top: 10px;
}
.dp-grid + .dp-grid { margin-top: -1px; }
.dp-grid-1 { grid-template-columns: 1fr; }
.dp-cell {
  display: flex; align-items: baseline; gap: 6px; min-width: 0;
  padding: 5px 8px; border-bottom: 1px solid #111; border-right: 1px solid #111;
}
.dp-cell:nth-child(2n) { border-right: 0; }
.dp-grid-1 .dp-cell { border-right: 0; }
.dp-cell > span { flex: none; color: #555; font-size: 11px; }
.dp-cell > b { font-weight: 600; font-size: 12px; word-break: break-all; }
.mut { color: #999; font-weight: 400; }
.dp-tbl { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 11.5px; }
.dp-tbl th, .dp-tbl td { border: 1px solid #111; padding: 5px 6px; }
.dp-tbl th { background: #f2f2f2; font-weight: 600; text-align: left; }
.dp-tbl td.c { text-align: center; }
.dp-tbl td.r { text-align: right; font-variant-numeric: tabular-nums; }
.dp-tbl tr.sum td { background: #f7f7f7; font-weight: 600; }
.dp-amt {
  display: flex; align-items: baseline; gap: 10px; margin-top: -1px;
  padding: 6px 8px; border: 1px solid #111; font-size: 12px;
}
.dp-amt > b { font-size: 13px; letter-spacing: 1px; }
.dp-amt > span { margin-left: auto; font-variant-numeric: tabular-nums; }
.dp-tot {
  margin-top: 8px; padding: 5px 8px; border: 1px solid #111; background: #f7f7f7;
  font-size: 12px; font-variant-numeric: tabular-nums;
}
.dp-tot > b { font-size: 14px; }
.dp-ft { display: flex; gap: 12px; margin-top: 12px; }
.dp-note { flex: 1; border: 1px solid #111; padding: 6px 8px; font-size: 11px; }
.dp-note > span { display: block; color: #555; margin-bottom: 2px; }
.dp-note > div { min-height: 36px; white-space: pre-wrap; }
.dp-sign { flex: none; width: 48%; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.dp-sign > div { border: 1px solid #111; padding: 4px 6px; display: flex; flex-direction: column; }
.dp-sign > div > span { font-size: 10px; color: #555; }
.dp-sign > div > i { display: block; flex: 1; min-height: 24px; }
.dp-bot {
  margin-top: 10px; padding-top: 6px; border-top: 1px dashed #bbb;
  font-size: 10px; color: #666; text-align: center;
}

/* ---------- 箱唛（外箱标签） ---------- */
.cm-page {
  display: flex; flex-wrap: wrap; align-content: flex-start;
  min-height: 0; height: 269mm;
}
.cm {
  width: calc(100% / var(--cols, 1)); height: calc(100% / var(--rows, 1));
  border: 1px solid #111; padding: 5mm 5mm 4mm; overflow: hidden;
  display: flex; flex-direction: column;
}
.cm-hd { border-bottom: 1px solid #333; padding-bottom: 3px; margin-bottom: 5px; }
.cm-hd span { font-size: 11px; font-weight: 700; letter-spacing: 1px; }
.cm-n { font-size: 30px; font-weight: 800; line-height: 1.22; }
.cm-sp { font-size: 13px; color: #222; margin-top: 3px; }
.cm-kv { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 15px; }
.cm-kv th {
  width: 76px; text-align: left; font-weight: 400; color: #444;
  background: #f4f4f4; border: 1px solid #555; padding: 4px 6px; white-space: nowrap;
}
.cm-kv td { border: 1px solid #555; padding: 4px 6px; font-weight: 700; word-break: break-all; }
.cm-no { margin-top: auto; padding-top: 8px; font-size: 16px; }
.cm-no b { font-size: 22px; }
.cm-bc { margin-top: 6px; }
/* 箱唛底部的生产商行：自动取自「🏭 工厂信息」（可在那里关掉） */
.cm-foot { margin-top: 5px; font-size: 10px; color: #333; line-height: 1.35; }
/* 箱唛也走卷筒标签纸时：纸张尺寸由 JS 传 --pw / --ph，一签一页、内边距交给 .cm */
.print-sheet.cm-page.cm-roll { width: var(--pw, 100mm); height: var(--ph, 150mm); padding: 0; }
/* 每页张数越多，标签越小：字号与条码一起缩 */
.cm-page.s2 .cm-n { font-size: 26px; }
.cm-page.s2 .cm-kv { font-size: 14px; margin-top: 10px; }
.cm-page.s2 .cm-no { font-size: 15px; }
.cm-page.s2 .cm-no b { font-size: 20px; }
.cm-page.s3 .cm { padding: 4mm; }
.cm-page.s3 .cm-hd span { font-size: 9px; }
.cm-page.s3 .cm-n { font-size: 17px; }
.cm-page.s3 .cm-sp { font-size: 10px; }
.cm-page.s3 .cm-kv { font-size: 11px; margin-top: 6px; }
.cm-page.s3 .cm-kv th { width: 54px; padding: 3px 4px; }
.cm-page.s3 .cm-kv td { padding: 3px 4px; }
.cm-page.s3 .cm-no { font-size: 12px; padding-top: 6px; }
.cm-page.s3 .cm-no b { font-size: 15px; }
.cm-page.s3 .bc-txt { font-size: 9px; letter-spacing: 1px; }
.cm-page.s4 .cm { padding: 3mm; }
.cm-page.s4 .cm-hd span { font-size: 8px; }
.cm-page.s4 .cm-n { font-size: 15px; }
.cm-page.s4 .cm-sp { font-size: 9px; }
.cm-page.s4 .cm-kv { font-size: 10px; margin-top: 5px; }
.cm-page.s4 .cm-kv th { width: 48px; padding: 2px 3px; }
.cm-page.s4 .cm-kv td { padding: 2px 3px; }
.cm-page.s4 .cm-no { font-size: 11px; padding-top: 5px; }
.cm-page.s4 .cm-no b { font-size: 13px; }
.cm-page.s4 .bc-txt { font-size: 8px; letter-spacing: .5px; }
.cm-page.s3 .cm-foot { font-size: 8px; margin-top: 3px; }
.cm-page.s4 .cm-foot { font-size: 7px; margin-top: 2px; }

/* ---------- 产品信息标签（卷筒标签纸，一签一页） ----------
   纸张尺寸由 JS 通过 --pw / --ph 传进来（mm），@page 也按同样的尺寸动态注入，
   所以屏幕上这张签多大、打出来就多大。内边距放在 .lb 上而不是纸上，
   保证屏幕与打印的内容宽度一致。 */
.print-sheet.lb-sheet {
  width: var(--pw, 100mm); min-height: var(--ph, 150mm); padding: 0;
}
.lb {
  padding: 4mm 4mm 3.5mm; color: #000; background: #fff;
  font-size: 9pt; line-height: 1.45; word-break: break-word;
}
.lb-row { display: block; }
.lb-row > span { color: #000; }
.lb-row > b { font-weight: 700; }
.lb-gap { margin-left: 1.6em; }
.lb-net { margin-top: 2.4mm; font-size: 14pt; font-weight: 700; letter-spacing: .5px; }
.lb-net > b { font-size: 17pt; }
.lb-net > i { font-style: normal; font-size: 10pt; font-weight: 400; }
.lb-nut { margin-top: 1.6mm; text-align: center; font-size: 11pt; font-weight: 700; letter-spacing: 4px; }
.lb-tbl { width: 100%; border-collapse: collapse; margin-top: 1mm; font-size: 9pt; }
.lb-tbl th, .lb-tbl td { border: 1px solid #000; padding: .6mm 1.6mm; }
.lb-tbl th { text-align: center; font-weight: 700; }
.lb-tbl td.n { width: 30%; }
.lb-tbl td.v { text-align: center; }
.lb-tbl td.r { text-align: right; }
.lb-extra { margin-top: 1.4mm; text-align: right; font-size: 8.5pt; }
.lb-bc { margin-top: 1.4mm; text-align: center; }
/* 小签（≤90mm 宽，JS 会加 .lb-s）：字号整体缩一档，免得十几行信息挤出纸外 */
.print-sheet.lb-sheet.lb-s .lb { font-size: 7.6pt; line-height: 1.38; padding: 3mm; }
.print-sheet.lb-sheet.lb-s .lb-net { font-size: 11pt; margin-top: 1.8mm; }
.print-sheet.lb-sheet.lb-s .lb-net > b { font-size: 13pt; }
.print-sheet.lb-sheet.lb-s .lb-net > i { font-size: 8.5pt; }
.print-sheet.lb-sheet.lb-s .lb-nut { font-size: 9.5pt; letter-spacing: 3px; }
.print-sheet.lb-sheet.lb-s .lb-tbl { font-size: 7.4pt; }
.print-sheet.lb-sheet.lb-s .lb-extra { font-size: 7pt; }

/* ---------- 打印瞬间：只留纸张 ---------- */
@media print {
  body.printing { background: #fff; }
  body.printing > .layout,
  body.printing > #modalRoot,
  body.printing > #toastRoot,
  body.printing > #offlineTip,
  body.printing > #firstGuide { display: none !important; }
  body.printing > #printMask { position: static; display: block; background: none; }
  body.printing .print-bar { display: none !important; }
  body.printing .print-stage {
    display: block; padding: 0; background: none; overflow: visible; gap: 0;
  }
  body.printing .print-sheet {
    width: auto; min-height: 0; padding: 0; margin: 0; box-shadow: none;
    page-break-after: always; break-after: page;
  }
  body.printing .print-sheet:last-child { page-break-after: auto; break-after: auto; }
}

/* ===========================================================
   工厂信息（🏭 工厂信息页）：单据抬头预览
   刻意做成与真实打印件同款的一小块（同样的粗体抬头 / 黑框 / 虚线脚注），
   改完信息立刻能看到打出来长什么样 —— 不必真的打一张。
   =========================================================== */
.fac-prev { border: 1px solid var(--border); border-radius: 10px; background: #fff; padding: 14px 16px; }
.fac-prev + .fac-prev { margin-top: 12px; }
.fac-prev .fp-t { font-size: 11.5px; color: #8a94a6; letter-spacing: .5px; margin-bottom: 10px; }
.fac-prev .fp-hd { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #111; padding-bottom: 8px; }
.fac-prev .fp-co { font-size: 18px; font-weight: 800; letter-spacing: .5px; color: #111; }
.fac-prev .fp-co-s { font-size: 11px; color: #444; margin-top: 3px; }
.fac-prev .fp-doc { flex: none; font-size: 20px; font-weight: 800; letter-spacing: 5px; color: #111; text-align: right; }
.fac-prev .fp-grid {
  display: grid; grid-template-columns: 110px 1fr 110px 1fr;
  border: 1px solid #111; border-bottom: 0; margin-top: 10px; font-size: 12px;
}
.fac-prev .fp-grid > span { padding: 5px 8px; border-bottom: 1px solid #111; color: #555; font-size: 11px; }
.fac-prev .fp-grid > b { padding: 5px 8px; border-bottom: 1px solid #111; border-left: 1px solid #111; font-weight: 600; }
.fac-prev .fp-box { border: 1px solid #111; padding: 10px 12px; }
.fac-prev .fp-brand { border-bottom: 1px solid #333; padding-bottom: 3px; margin-bottom: 5px; font-size: 11px; font-weight: 700; letter-spacing: 1px; color: #111; }
.fac-prev .fp-n { font-size: 22px; font-weight: 800; line-height: 1.22; color: #111; }
.fac-prev .fp-sp { font-size: 12px; color: #333; margin-top: 3px; }
.fac-prev .fp-rows { font-size: 12px; line-height: 1.9; color: #222; word-break: break-all; }
.fac-prev .fp-rows span { color: #8a94a6; display: inline-block; min-width: 62px; font-weight: 400; }
.fac-prev .fp-foot { margin-top: 8px; padding-top: 5px; border-top: 1px dashed #bbb; font-size: 10.5px; color: #555; }
.fac-prev .fp-note { font-size: 11.5px; color: #8a94a6; margin-top: 8px; line-height: 1.7; }
.fac-prev .mut { color: #b45309; font-weight: 400; }

/* ===========================================================
   登录页（V3.24.0）
   全屏遮罩盖在业务界面之上：没登录就只能用这一屏，
   业务界面照常初始化（测试与深浅色都不受影响），登录后摘掉遮罩即可。
   =========================================================== */
.login-mask {
  position: fixed; inset: 0; z-index: 9500;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 55%, #1d4ed8 100%);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.login-box {
  width: 100%; max-width: 380px; background: #fff; border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35); overflow: hidden;
}
.login-box .lg-hd {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 22px 16px; border-bottom: 1px solid #eef1f5;
}
.login-box .lg-logo {
  flex: none; width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, #1d4ed8, #2563eb); color: #fff;
  font-size: 20px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.login-box .lg-name { font-size: 17px; font-weight: 800; color: #0f172a; letter-spacing: .5px; }
.login-box .lg-sub { font-size: 12px; color: #8a94a6; margin-top: 3px; }
.login-box .lg-body { padding: 18px 22px 22px; }
.login-box label { display: block; font-size: 12.5px; color: #475569; margin: 0 0 5px; }
.login-box input {
  width: 100%; padding: 10px 12px; margin-bottom: 12px;
  border: 1px solid #d8dee8; border-radius: 9px; font-size: 14px; color: #1f2937;
}
.login-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.login-box .lg-err {
  display: none; margin-bottom: 10px; padding: 7px 10px; border-radius: 8px;
  background: #fef2f2; color: #dc2626; font-size: 12.5px;
}
.login-box #lgBtn { width: 100%; padding: 11px; font-size: 15px; font-weight: 600; border-radius: 10px; }
/* 登录页标语（V3.36.0）：这个位置原来挂着「初始账号 admin / 密码 admin」的提示，
   已按要求撤掉，改成从 auth.js 的 SLOGANS 池里随机挑一条励志短语。 */
.login-box .lg-tip {
  margin-top: 16px; padding-top: 13px; border-top: 1px dashed #eef1f5;
  font-size: 12px; color: #6b7a90; line-height: 1.65;
  text-align: center; letter-spacing: .3px;
  animation: lgTipIn .45s ease both;
}
@keyframes lgTipIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
@media print { .login-mask { display: none !important; } }

/* 只读留痕字段（V3.25.0）：经办人 / 报工人 / 检验员 / 保养人 / 审核人 / 维护人
   一律由系统取当前登录账号，界面上做成灰底只读格，避免被手填成别人的名字 */
.ro-input {
  background: #f6f8fa !important;
  color: #475569 !important;
  cursor: not-allowed;
  font-weight: 600;
  letter-spacing: .2px;
}

/* 系统使用说明（V3.26.0）：步骤条 / 模块卡 / FAQ 折叠 / 搜索过滤 */
.hp-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.hp-bar .search { flex: 1; min-width: 180px; max-width: 340px; }
.hp-bar .spacer { flex: 1; }
.hp-item.hp-hide { display: none !important; }

.hp-steps { display: grid; gap: 8px; }
.hp-step { display: flex; gap: 10px; align-items: flex-start; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.hp-step .hp-n { width: 22px; height: 22px; flex: none; border-radius: 50%; background: #1d4ed8; color: #fff; font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; margin-top: 1px; }

.hp-mods { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.hp-mod { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 12px; cursor: pointer; transition: border-color .15s, background .15s; }
.hp-mod:hover { border-color: #93b4f5; background: #f8fbff; }
.hp-mt { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.hp-mt .ico { font-size: 16px; }
.hp-mt b { font-size: 13.5px; }
.hp-md { font-size: 12.5px; color: #475569; line-height: 1.75; margin-top: 6px; }
.hp-mu { font-size: 11.5px; color: #8a94a6; line-height: 1.6; margin-top: 6px; }

.hp-faqs { display: grid; gap: 8px; }
.hp-faq { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 0 12px; }
.hp-faq summary { cursor: pointer; font-size: 13px; font-weight: 600; color: #1e293b; padding: 10px 0; list-style: none; }
.hp-faq summary::-webkit-details-marker { display: none; }
.hp-faq summary::before { content: '＋'; display: inline-block; width: 16px; color: #1d4ed8; }
.hp-faq[open] summary::before { content: '−'; }
.hp-fa { font-size: 12.5px; color: #475569; line-height: 1.85; padding: 0 0 10px 16px; border-top: 1px solid #eef1f5; padding-top: 10px; }
