/* ============================================================
 * 工业企业订单全链路管理工具 — 公共样式 shared.css
 * 设计令牌集中在 :root，换肤只改这里
 * ============================================================ */

:root {
  /* 品牌色 */
  --primary: #2563eb;
  --primary-2: #7ba3f7;
  --primary-hover: #1d4ed8;
  --primary-soft: rgba(37, 99, 235, .10);
  --primary-ring: rgba(37, 99, 235, .22);

  /* 中性色 */
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f8;
  --text: #0f172a;
  --text-2: #526077;
  --text-3: #93a0b4;
  --border: #e7ebf2;
  --border-2: #d8dfe9;

  /* 语义色 */
  --success: #0ea371;   --success-soft: rgba(14, 163, 113, .12);
  --warning: #d99413;   --warning-soft: rgba(217, 148, 19, .14);
  --danger:  #e5484d;   --danger-soft:  rgba(229, 72, 77, .12);
  --info:    #0ea5e9;   --info-soft:    rgba(14, 165, 233, .12);
  --violet:  #7c5cfc;   --violet-soft:  rgba(124, 92, 252, .12);

  /* 图表色 */
  --c1: #2563eb; --c2: #0ea371; --c3: #d99413; --c4: #7c5cfc; --c5: #e5484d;

  /* 圆角 / 阴影 / 尺寸 */
  --r-xs: 6px; --r-sm: 9px; --r: 13px; --r-lg: 18px; --r-full: 999px;
  --sh-1: 0 1px 2px rgba(15, 23, 42, .04);
  --sh-2: 0 4px 14px rgba(15, 23, 42, .06);
  --sh-3: 0 16px 44px rgba(15, 23, 42, .14);
  --sidebar-w: 236px;
  --topbar-h: 62px;
  --gap: 18px;

  --font: "Inter", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei",
          system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --tr: .22s cubic-bezier(.4, 0, .2, 1);
}

/* 兼容旧变量名（shared.js 内联样式引用） */
:root {
  --c-primary: var(--primary);
  --c-primary-dark: var(--primary-hover);
  --c-primary-light: var(--primary-soft);
  --c-text: var(--text);
  --c-text-2: var(--text-2);
  --c-text-3: var(--text-3);
  --c-border: var(--border);
  --c-surface: var(--surface);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font); font-size: 14px; line-height: 1.6;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
ul { margin: 0; padding: 0; list-style: none; }
svg { display: block; }

*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- 布局骨架 ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 60;
  background: #0f1c2e; color: #a9bcd0;
  display: flex; flex-direction: column;
}
.sidebar .brand { padding: 20px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand h1 { font-size: 15px; color: #fff; font-weight: 650; letter-spacing: .2px; }
.sidebar .brand p { font-size: 11px; color: #7c93ac; margin-top: 3px; }

.nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; border-radius: var(--r-sm);
  color: #a9bcd0; font-size: 13.5px; cursor: pointer;
  margin-bottom: 2px; transition: all .16s; user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 500; }
.nav-item .ico { width: 18px; text-align: center; font-size: 15px; flex: none; }
.nav-item .badge-dot { margin-left: auto; display: none; }
.nav-item .badge-dot.on {
  display: inline-flex; min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 9px; background: var(--danger); color: #fff;
  font-size: 10.5px; font-weight: 700; align-items: center; justify-content: center; flex: none;
}
.nav-group { font-size: 11px; color: #5a7899; padding: 12px 12px 5px; letter-spacing: .5px; }

.sidebar .userbox {
  padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 10px;
}
.sidebar .avatar {
  width: 33px; height: 33px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; flex: 0 0 33px;
}
.sidebar .userbox .nm { font-size: 13px; color: #fff; }
.sidebar .userbox .rl { font-size: 11px; color: #7c93ac; }
.sidebar .logout {
  margin-left: auto; font-size: 11px; color: #7c93ac; cursor: pointer;
  padding: 4px 7px; border-radius: var(--r-xs);
}
.sidebar .logout:hover { background: rgba(255,255,255,.08); color: #fff; }

.main {
  margin-left: var(--sidebar-w); flex: 1; min-width: 0;
  display: flex; flex-direction: column; min-height: 100vh;
}
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 24px; height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 16px; font-weight: 650; }
.topbar .spacer { flex: 1; }
.content { padding: 22px 24px 48px; flex: 1; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-1); margin-bottom: var(--gap);
}
.card-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.card-head h3 { font-size: 14.5px; font-weight: 650; }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

/* ---------- 统计卡 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 14px; margin-bottom: var(--gap); }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--sh-1);
}
.stat .lbl { font-size: 12.5px; color: var(--text-2); margin-bottom: 7px; }
.stat .val { font-size: 23px; font-weight: 700; letter-spacing: -.4px; }
.stat .sub { font-size: 11.5px; color: var(--text-3); margin-top: 5px; }
.stat.accent { border-left: 3px solid var(--primary); }
.stat.ok { border-left: 3px solid var(--success); }
.stat.warn { border-left: 3px solid var(--warning); }
.stat.danger { border-left: 3px solid var(--danger); }
.stat.info { border-left: 3px solid var(--info); }
.stat.violet { border-left: 3px solid var(--violet); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 10px 12px; font-weight: 600;
  color: var(--text-2); font-size: 12px; background: var(--surface-3);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: #fbfcfe; }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mask { color: var(--text-3); font-style: italic; }
.sub-cell { font-size: 11.5px; color: var(--text-3); display: block; margin-top: 2px; }

/* ---------- 状态标签 ---------- */
.st { display: inline-block; padding: 2px 9px; border-radius: var(--r-full); font-size: 12px; font-weight: 500; white-space: nowrap; }
.st-pending { background: #eef2f8; color: #475569; }
.st-plan { background: var(--warning-soft); color: #7c4a00; }
.st-doing { background: var(--primary-soft); color: var(--primary-hover); }
.st-ready { background: var(--violet-soft); color: #5b3fd1; }
.st-shipped { background: var(--success-soft); color: #0a7a54; }
.st-received { background: #e6f6e9; color: #1d7a3a; }
.st-done { background: #dcfce7; color: #15803d; }
.tag { display: inline-block; padding: 2px 8px; border-radius: var(--r-xs); font-size: 11.5px; background: var(--surface-3); color: var(--text-2); }
.tag.ok { background: var(--success-soft); color: #0a7a54; }
.tag.warn { background: var(--warning-soft); color: #7c4a00; }
.tag.danger { background: var(--danger-soft); color: #b02525; }
.tag.info { background: var(--info-soft); color: #0369a1; }
.tag.violet { background: var(--violet-soft); color: #5b3fd1; }
.tag.st-cancel { background: var(--danger-soft); color: #b02525; }
.tag.muted { background: var(--surface-3); color: var(--text-3); }

/* ============================================================
 *  SOP 标准作业程序（生产端）
 * ============================================================ */
/* 状态标签 */
.tag.st-draft { background: var(--surface-3); color: var(--text-2); }
.tag.st-trial { background: var(--warning-soft); color: #7c4a00; }
.tag.st-pub { background: var(--success-soft); color: #0a7a54; }

/* SOP 卡片网格 */
.sop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.sop-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 16px 17px 14px; display: flex; flex-direction: column; gap: 10px;
  transition: border-color var(--tr), box-shadow var(--tr), transform var(--tr);
}
.sop-card:hover { border-color: var(--primary); box-shadow: 0 4px 16px rgba(37, 99, 235, .10); transform: translateY(-2px); }
.sop-card .sc-head { display: flex; align-items: flex-start; gap: 10px; }
.sop-card .sc-title { flex: 1; min-width: 0; }
.sop-card .sc-name {
  font-size: 15px; font-weight: 650; color: var(--text); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.sop-card .sc-code { font-size: 11.5px; color: var(--text-3); font-family: ui-monospace, Consolas, monospace; margin-top: 3px; }
.sop-card .sc-desc {
  font-size: 12.5px; color: var(--text-2); line-height: 1.65; min-height: 41px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.sop-card .sc-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sop-card .sc-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); }

/* 完成度进度条 */
.sop-prog { display: flex; align-items: center; gap: 8px; }
.sop-prog .sp-bar { flex: 1; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.sop-prog .sp-fill { height: 100%; border-radius: 999px; transition: width .35s ease; }
.sop-prog .sp-fill.ok { background: #22a06b; }
.sop-prog .sp-fill.warn { background: #e0a020; }
.sop-prog .sp-fill.low { background: #d4574f; }
.sop-prog .sp-num { font-size: 12px; font-weight: 650; color: var(--text-2); min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }

/* 三要素速览 */
.sop-tri { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sop-tri .st-item {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 11px 12px; min-width: 0;
}
.sop-tri .st-item .lbl { font-size: 11.5px; color: var(--text-3); margin-bottom: 5px; letter-spacing: .3px; }
.sop-tri .st-item .val { font-size: 13px; color: var(--text); line-height: 1.6; word-break: break-word; }
.sop-tri .st-item .val.empty { color: var(--text-3); font-style: italic; }

/* 动作步骤编辑行 */
.sop-step {
  display: grid; grid-template-columns: 26px 1fr 130px 130px 30px; gap: 8px; align-items: start;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px;
}
.sop-step .ss-idx {
  width: 24px; height: 24px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; margin-top: 6px;
}
.sop-step textarea { min-height: 38px; resize: vertical; }
.sop-step .ss-del {
  width: 28px; height: 28px; border-radius: var(--r-xs); border: 1px solid var(--border);
  background: var(--surface); color: var(--text-3); cursor: pointer; margin-top: 4px;
  display: flex; align-items: center; justify-content: center; font-size: 15px; line-height: 1;
}
.sop-step .ss-del:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }

/* 检查项清单 */
.sop-checks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px 14px; }
.sop-checks .sc-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.sop-checks .sc-item .dot {
  width: 16px; height: 16px; border-radius: 50%; flex: none; display: flex;
  align-items: center; justify-content: center; font-size: 10px; color: #fff;
}
.sop-checks .sc-item .dot.y { background: #22a06b; }
.sop-checks .sc-item .dot.n { background: var(--surface-3); color: var(--text-3); }

/* 自查清单勾选 */
.sop-cl { display: flex; flex-direction: column; gap: 7px; }
.sop-cl .cl-item {
  display: flex; align-items: flex-start; gap: 9px; font-size: 12.5px; color: var(--text-2);
  line-height: 1.6; cursor: pointer; padding: 7px 10px; border-radius: var(--r-xs);
  border: 1px solid transparent; transition: background var(--tr), border-color var(--tr);
}
.sop-cl .cl-item:hover { background: var(--surface-2); border-color: var(--border); }
.sop-cl .cl-item input { margin-top: 2px; flex: none; }
.sop-cl .cl-item.on { color: var(--text); }

/* 只读提示条 */
.sop-lock {
  display: flex; align-items: center; gap: 9px; padding: 10px 13px; border-radius: var(--r-sm);
  background: var(--surface-3); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-2);
  margin-bottom: 14px;
}
.sop-lock .ico { font-size: 15px; }

/* 模板选择卡 */
.sop-tmpl { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.sop-tmpl .tm-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 14px 15px; cursor: pointer; transition: border-color var(--tr), box-shadow var(--tr), transform var(--tr);
}
.sop-tmpl .tm-card:hover { border-color: var(--primary); box-shadow: 0 4px 14px rgba(37, 99, 235, .10); transform: translateY(-2px); }
.sop-tmpl .tm-card .tm-name { font-size: 14px; font-weight: 650; color: var(--text); margin-bottom: 6px; }
.sop-tmpl .tm-card .tm-desc { font-size: 12.5px; color: var(--text-2); line-height: 1.6; min-height: 40px; }
.sop-tmpl .tm-card .tm-foot { display: flex; gap: 6px; margin-top: 10px; align-items: center; }

/* 详情抽屉 */
.sop-detail-sec { margin-bottom: 18px; }
.sop-detail-sec > .sd-title {
  font-size: 12.5px; font-weight: 650; color: var(--text-3); letter-spacing: .5px;
  margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.sop-detail-sec .sd-body { font-size: 13.5px; color: var(--text); line-height: 1.75; }
.sop-detail-sec .sd-body.empty { color: var(--text-3); font-style: italic; }

/* 步骤只读列表 */
.sop-steps-ro { display: flex; flex-direction: column; gap: 9px; }
.sop-steps-ro .sr-item { display: flex; gap: 11px; align-items: flex-start; }
.sop-steps-ro .sr-idx {
  width: 22px; height: 22px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 700; flex: none; margin-top: 1px;
}
.sop-steps-ro .sr-body { flex: 1; min-width: 0; }
.sop-steps-ro .sr-what { font-size: 13.5px; color: var(--text); line-height: 1.6; }
.sop-steps-ro .sr-meta { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }

/* 移动端 */
@media (max-width: 900px) {
  .sop-tri { grid-template-columns: 1fr; }
  .sop-checks { grid-template-columns: 1fr; }
  .sop-step { grid-template-columns: 26px 1fr 30px; }
  .sop-step > *:nth-child(3), .sop-step > *:nth-child(4) { grid-column: 2; }
  .sop-step .ss-del { grid-row: 1; grid-column: 3; }
}
.ro {
  padding: 8px 11px; border-radius: var(--r-xs); background: var(--surface-3);
  font-size: 13px; color: var(--text); min-height: 36px; display: flex; align-items: center;
}
.cell-input {
  padding: 6px 9px; border: 1px solid var(--border); border-radius: var(--r-xs);
  background: var(--surface); color: var(--text); font-size: 13px; font-family: inherit;
  transition: border-color var(--tr);
}
.cell-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--r-sm); border: 1px solid var(--border-2);
  background: var(--surface); color: var(--text); font-size: 13px; font-weight: 500;
  white-space: nowrap; font-family: inherit;
  /* 只过渡需要的属性（比 all 更省），并给按下反馈 */
  transition: background-color .15s ease, border-color .15s ease,
              color .15s ease, box-shadow .15s ease, transform .1s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.ok { background: var(--success); border-color: var(--success); color: #fff; }
.btn.ok:hover { filter: brightness(.94); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(.94); }
.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: var(--r-xs); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--primary); }
.btn.ghost:hover { background: var(--primary-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
/* 键盘可达性：焦点环 */
.btn:focus-visible { outline: 2px solid var(--primary-ring); outline-offset: 1px; }

/* ---------- 表格操作列（统一按钮组） ---------- */
/* 目的：等高、等距、主次分明，杜绝行内按钮宽窄参差、上下错位 */
th.op-h { text-align: right; }
td.op-c { white-space: nowrap; text-align: right; padding-right: 16px; }
.op-bar {
  display: inline-flex; align-items: center; justify-content: flex-end;
  gap: 6px; flex-wrap: nowrap; vertical-align: middle;
}
.op-bar .btn {
  height: 28px; min-height: 28px; padding: 0 11px; font-size: 12px;
  line-height: 1; border-radius: var(--r-xs); justify-content: center;
  font-variant-numeric: tabular-nums;
}
/* 次要动作：细描边，弱于主操作 */
.op-bar .btn.plain { border-color: var(--border); background: var(--surface); color: var(--text-2); }
.op-bar .btn.plain:hover { border-color: var(--text-3); background: var(--surface-2); color: var(--text); }
/* 最轻动作：纯文字，如「详情」 */
.op-bar .btn.quiet { border-color: transparent; background: transparent; color: var(--text-2); padding: 0 9px; }
.op-bar .btn.quiet:hover { background: var(--surface-3); color: var(--text); }
/* 主操作加一点点投影，形成视觉锚点 */
.op-bar .btn.primary, .op-bar .btn.ok { box-shadow: 0 1px 2px rgba(16, 24, 40, .08); }
/* 动作分组分隔线 */
.op-bar .sep { width: 1px; height: 15px; background: var(--border); flex: none; margin: 0 2px; }
/* 占位标签，保证列宽不随状态跳动 */
.op-bar .op-hold { display: inline-flex; align-items: center; height: 28px; }

@media (max-width: 900px) {
  td.op-c { padding-right: 12px; }
  .op-bar { gap: 5px; }
  .op-bar .btn { padding: 0 9px; }
}
/* 操作列放两个以上按钮时允许换行，保持右对齐整齐 */
.op-bar.wrap { flex-wrap: wrap; row-gap: 6px; }

/* ---------- 库存直发提示 ---------- */
.direct-box {
  border: 1px solid #b7e4c9; background: var(--success-soft);
  border-radius: var(--r-sm); padding: 12px 14px;
}
.direct-box .db-hd {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 650; color: #0a7a54; margin-bottom: 8px;
}
.direct-box .db-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--success); flex: none;
}
.direct-box .db-lines { display: flex; flex-direction: column; gap: 5px; }
.direct-box .db-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  font-size: 12.5px; color: #0f5c40; padding: 3px 0;
  border-bottom: 1px dashed rgba(10, 122, 84, .16);
}
.direct-box .db-row:last-child { border-bottom: none; }
.direct-box .db-row .nm { min-width: 0; }
.direct-box .db-row .qt { font-variant-numeric: tabular-nums; white-space: nowrap; color: #0a7a54; }
.direct-box .db-row.miss .nm, .direct-box .db-row.miss .qt { color: #7c4a00; }
.direct-box .db-note { font-size: 11.5px; color: #0f5c40; opacity: .8; margin-top: 8px; }

/* ---------- 回款凭证 ---------- */
.vch-list { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; max-width: 340px; }
.vch {
  display: inline-flex; align-items: center; gap: 7px; max-width: 230px;
  padding: 4px 10px 4px 5px; border: 1px solid var(--border); border-radius: var(--r-xs);
  background: var(--surface); font-size: 12px; color: var(--text-2); cursor: pointer;
  transition: border-color var(--tr), background-color var(--tr), color var(--tr);
}
.vch:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.vch img { width: 24px; height: 24px; border-radius: 4px; object-fit: cover; flex: none; }
.vch-nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vch-ico {
  width: 24px; height: 24px; border-radius: 4px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 8.5px; font-weight: 700; letter-spacing: .3px; color: #fff; background: #64748b;
}
.vch-ico.pdf { background: #d64541; }
.vch-ico.doc { background: #2b579a; }
.vch-ico.xls { background: #1f7145; }
.vch-ico.lg { width: 52px; height: 52px; border-radius: 10px; font-size: 14px; }
.vch-file { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 10px; }
.vch-fnm { font-size: 14px; font-weight: 600; word-break: break-all; text-align: center; }
.vch-x { margin-left: 2px; padding: 0 2px; color: var(--text-3); font-weight: 700; line-height: 1; }
.vch-x:hover { color: var(--danger); }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }

/* ---------- 分段表单 + 订单产品明细 ---------- */
.form-sec { margin-bottom: 24px; }
.form-sec:last-of-type { margin-bottom: 0; }
.sec-hd {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 13.5px; font-weight: 600; color: var(--text);
  padding: 0 0 12px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.sec-no {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: var(--r-full); flex: none;
  background: var(--primary-soft); color: var(--primary);
  font-size: 11.5px; font-weight: 700;
}
.sec-tip { font-weight: 400; font-size: 12px; color: var(--text-3); }

.items-head, .item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px 120px 108px 28px;
  gap: 10px; align-items: center;
}
.items-head { font-size: 12px; color: var(--text-3); font-weight: 500; padding: 0 0 8px; }
.item-row { padding: 8px 0; border-bottom: 1px dashed var(--border); }
.item-row:last-child { border-bottom: none; }
.item-row input { padding: 7px 10px; font-size: 13px; }
.it-sub {
  font-size: 13px; color: var(--text-2); text-align: right;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.it-del {
  width: 26px; height: 26px; border-radius: var(--r-xs);
  border: 1px solid var(--border-2); background: #fff; color: var(--text-3);
  cursor: pointer; font-size: 15px; line-height: 1; transition: .15s;
}
.it-del:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.items-sum { font-size: 13px; color: var(--text-2); display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.items-sum b { font-size: 17px; color: var(--text); font-variant-numeric: tabular-nums; margin: 0 2px; }

/* 订单产品明细表格（详情页只读展示） */
.it-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.it-table th {
  text-align: left; font-weight: 500; font-size: 12px; color: var(--text-3);
  padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.it-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.it-table tr:last-child td { border-bottom: none; }
.it-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.it-table tfoot td { font-weight: 600; background: var(--surface-2); }

@media (max-width: 720px) {
  .items-head { display: none; }
  .item-row {
    grid-template-columns: 1fr 1fr; gap: 8px;
    padding: 12px; margin-bottom: 10px; position: relative;
    border: 1px solid var(--border); border-radius: var(--r-sm);
    background: var(--surface-2);
  }
  .item-row .it-spec { grid-column: 1 / -1; padding-right: 40px; }
  .item-row .it-qty { grid-column: 1 / 2; }
  .item-row .it-price { grid-column: 2 / 3; }
  .it-sub { grid-column: 1 / -1; text-align: left; }
  .it-del { position: absolute; right: 8px; top: 8px; }
  .it-table th:nth-child(4), .it-table td:nth-child(4) { display: none; }
}
.field label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.field label .req { color: var(--danger); margin-left: 2px; }
input, select, textarea {
  padding: 8px 11px; border: 1px solid var(--border-2); border-radius: var(--r-sm);
  font-size: 13.5px; font-family: inherit; color: var(--text); background: #fff;
  transition: border .16s, box-shadow .16s; width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring);
}
textarea { resize: vertical; min-height: 68px; }
input[readonly] { background: var(--surface-2); color: var(--text-2); }
.hint { font-size: 11.5px; color: var(--text-3); }

/* ---------- 过滤条 ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters .field { min-width: 140px; }
.filters .field.grow { flex: 1; min-width: 200px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  display: none; align-items: flex-start; justify-content: center;
  z-index: 100; padding: 40px 16px; overflow-y: auto;
  /* 打开时的遮罩淡入 + 阻止滚动穿透 */
  opacity: 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.modal-mask.show {
  display: flex;
  animation: maskIn .16s ease-out forwards;
}
.modal-mask.show .modal { animation: pop .22s cubic-bezier(.22, 1, .36, 1); }
.modal {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-3);
  width: 100%; max-width: 760px;
  /* 提早提升为合成层，动画更顺 */
  will-change: transform, opacity;
  transform: translateZ(0);
  backface-visibility: hidden;
}
.modal.wide { max-width: 1000px; }
.modal.narrow { max-width: 440px; }
/* 打开弹窗时锁住页面滚动，避免背景跟着滚 */
body.modal-open { overflow: hidden; }
/* 弹窗内小节标题 */
.sec-title {
  font-size: 12.5px; font-weight: 650; color: var(--text-2); letter-spacing: .4px;
  margin: 18px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.sec-title:first-child { margin-top: 0; }
/* 必填星号 */
.req { color: var(--danger); font-weight: 700; }

/* ---------- 员工档案详情 ---------- */
.emp-detail { display: flex; flex-direction: column; }
.emp-detail-head {
  display: flex; align-items: center; gap: 14px;
  padding: 4px 0 16px; margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.emp-avatar {
  flex: 0 0 auto; width: 54px; height: 54px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 650; color: #fff;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  box-shadow: 0 4px 12px rgba(37, 99, 235, .28);
  user-select: none;
}
.emp-detail-name {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  font-size: 17px; font-weight: 650; color: var(--text); margin-bottom: 3px;
}
.emp-detail-name .tag { font-weight: 500; }
/* 键值行：窄屏两行，宽屏同行 */
.emp-row {
  display: grid; grid-template-columns: 132px 1fr; gap: 10px;
  padding: 9px 0; border-bottom: 1px dashed var(--border);
  font-size: 13.5px; align-items: start; line-height: 1.55;
}
.emp-row:last-child { border-bottom: none; }
.emp-k { color: var(--text-3); font-size: 12.5px; }
.emp-v { color: var(--text); word-break: break-word; }
.emp-remark {
  padding: 12px 14px; border-radius: var(--r-sm); background: var(--surface-3);
  font-size: 13px; line-height: 1.7; color: var(--text-2); white-space: pre-wrap;
  word-break: break-word;
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.8px; letter-spacing: .3px; }
@media (max-width: 520px) {
  .emp-row { grid-template-columns: 1fr; gap: 2px; padding: 8px 0; }
  .emp-k { font-size: 11.5px; }
  .emp-avatar { width: 46px; height: 46px; font-size: 19px; }
  .emp-detail-name { font-size: 15.5px; }
}
@keyframes maskIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop {
  from { transform: translateY(-10px) scale(.985); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
/* 视图切换：淡入微上移，替代硬切 */
.view-fade { animation: viewIn .19s cubic-bezier(.22, 1, .36, 1); }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-head h3 { font-size: 15px; font-weight: 650; }
.modal-head .x { margin-left: auto; cursor: pointer; color: var(--text-3); font-size: 20px; line-height: 1; padding: 0 4px; }
.modal-head .x:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- 时间线 ---------- */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item::before {
  content: ''; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--primary); border: 2px solid #fff; box-shadow: 0 0 0 1.5px var(--primary);
}
.tl-item .tl-st { font-size: 13.5px; font-weight: 600; }
.tl-item .tl-meta { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.tl-item .tl-note { font-size: 12.5px; color: var(--text-2); margin-top: 3px; background: var(--surface-2); padding: 5px 9px; border-radius: var(--r-xs); display: inline-block; }
.tl-item.tl-rb::before { background: var(--warning); box-shadow: 0 0 0 1.5px var(--warning); }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty .big { font-size: 34px; margin-bottom: 10px; opacity: .5; }
.empty p { font-size: 13px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translate(-50%, 16px);
  background: #0f172a; color: #fff; padding: 10px 20px; border-radius: var(--r);
  font-size: 13.5px; box-shadow: var(--sh-3); opacity: 0;
  transition: opacity .22s ease, transform .22s cubic-bezier(.22, 1, .36, 1);
  z-index: 200; pointer-events: none; will-change: transform, opacity;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: #0a7a54; }
.toast.err { background: #b02525; }

/* ---------- 长列表性能：屏幕外不渲染 ---------- */
.sop-card, .stat, .tl-item { content-visibility: auto; contain-intrinsic-size: auto 120px; }

/* ---------- 无障碍：尊重「减少动态效果」系统设置 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f1c2e 0%, #1e40af 100%); padding: 20px;
}
.login-card {
  background: #fff; border-radius: var(--r-lg); box-shadow: 0 24px 64px rgba(0,0,0,.28);
  width: 100%; max-width: 400px; padding: 34px 32px;
}
.login-card .lg-title { font-size: 19px; font-weight: 700; text-align: center; }
.login-card .lg-sub { font-size: 13px; color: var(--text-2); text-align: center; margin: 6px 0 24px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; justify-content: center; padding: 10px; font-size: 14.5px; margin-top: 6px; }
.demo-box { margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--border-2); }
.demo-box .dt { font-size: 12px; color: var(--text-2); margin-bottom: 9px; text-align: center; }
.demo-acc {
  display: flex; align-items: center; gap: 8px; padding: 6px 9px;
  border-radius: var(--r-xs); cursor: pointer; font-size: 12.5px; transition: background .14s;
}
.demo-acc:hover { background: var(--primary-soft); }
.demo-acc .r { color: var(--text-2); }
.demo-acc .u { margin-left: auto; font-family: var(--mono); color: var(--text-3); font-size: 11.5px; }

/* ---------- 入口导航（主网页） ---------- */
.portal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(228px, 1fr)); gap: 16px; }
.portal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 22px 20px; cursor: pointer;
  transition: all .2s; box-shadow: var(--sh-1); display: block;
}
.portal:hover { transform: translateY(-2px); box-shadow: var(--sh-2); border-color: var(--primary); }
.portal .pico {
  width: 44px; height: 44px; border-radius: var(--r); display: flex;
  align-items: center; justify-content: center; font-size: 21px; margin-bottom: 13px;
}
.portal h4 { font-size: 15px; font-weight: 650; margin-bottom: 5px; }
.portal p { font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.portal .plink { font-size: 12px; color: var(--primary); margin-top: 10px; font-weight: 600; }

/* ---------- 权限勾选 ---------- */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 9px; }
.perm-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: var(--r-sm); font-size: 13px; cursor: pointer;
}
.perm-item:hover { background: var(--surface-2); }
.perm-item input { width: auto; }

/* ---------- 比例行（原材料出库） ---------- */
.alloc-head { display: grid; grid-template-columns: 1fr 92px 92px 34px; gap: 8px; align-items: center; font-size: 11.5px; color: var(--text-2); font-weight: 600; margin-bottom: 6px; }
.alloc-row { display: grid; grid-template-columns: 1fr 92px 92px 34px; gap: 8px; align-items: center; margin-bottom: 8px; }
.alloc-row .rm { color: var(--danger); cursor: pointer; text-align: center; font-size: 18px; line-height: 1; }
.alloc-row .rm:hover { opacity: .7; }

/* ---------- 原材料出库明细块 ---------- */
.mat-line {
  border: 1px solid var(--border); border-radius: var(--r); padding: 14px 15px;
  margin-bottom: 12px; background: var(--surface-2);
}
.mat-line .ml-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.mat-line .ml-idx {
  width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex: none;
}
.mat-line .ml-title { font-size: 13.5px; font-weight: 600; flex: 1; }
.mat-line .ml-rm { color: var(--danger); cursor: pointer; font-size: 12.5px; padding: 2px 6px; border-radius: var(--r-xs); }
.mat-line .ml-rm:hover { background: var(--danger-soft); }
.mat-line .ml-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 12px; }
.mat-line .ml-sec { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border-2); }
.mat-line .ml-sec-t { font-size: 12px; color: var(--text-2); font-weight: 600; margin-bottom: 8px; }
.mat-line .hint [data-alloc-hint] { display: block; margin-top: 6px; }

@media (max-width: 620px) {
  .mat-line .ml-grid { grid-template-columns: 1fr; }
}

/* ---------- 分段切换 ---------- */
.seg-toggle {
  display: inline-flex; gap: 3px; padding: 3px;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--r-sm);
  width: fit-content;
}
.seg-toggle button {
  font-size: 13px; padding: 6px 16px; border-radius: var(--r-xs);
  color: var(--text-2); background: none; transition: all .16s; white-space: nowrap;
}
.seg-toggle button:hover { color: var(--text); }
.seg-toggle button.active, .seg-toggle button.on { background: var(--surface); color: var(--primary); font-weight: 600; box-shadow: var(--sh-1); }

/* ---------- 进度条 ---------- */
.bar { height: 7px; background: var(--surface-3); border-radius: var(--r-full); overflow: hidden; min-width: 56px; }
.bar > i { display: block; height: 100%; background: var(--success); border-radius: var(--r-full); }
.bar.low > i { background: var(--warning); }
.bar.zero > i { background: var(--danger); }

/* ---------- 分栏辅助 ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.flex { display: flex; align-items: center; gap: 10px; }
.flex.wrap { flex-wrap: wrap; }
.flex.gap-sm { gap: 6px; }
.mt { margin-top: 14px; }
.perm-lock {
  background: var(--warning-soft); border: 1px solid rgba(217,148,19,.3);
  border-radius: var(--r-sm); padding: 10px 13px; font-size: 12.5px;
  color: #7c4a00; display: flex; gap: 8px; align-items: flex-start; line-height: 1.6;
}

/* ---------- 移动端顶栏与抽屉 ---------- */
.mobile-bar {
  display: none; align-items: center; gap: 10px;
  height: 54px; padding: 0 14px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 55;
}
.mobile-bar .mb-title { font-size: 15px; font-weight: 650; flex: 1; }
.icon-btn {
  width: 38px; height: 38px; border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--text-2); background: var(--surface-2);
  border: 1px solid var(--border); flex: none;
}
.icon-btn:active { background: var(--surface-3); }
.drawer-mask {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5);
  z-index: 70;
}
.drawer-mask.show { display: block; }

/* ---------- 全屏预览壳 ---------- */
.fs-shell {
  display: none; position: fixed; inset: 0; z-index: 130;
  background: var(--bg); flex-direction: column;
}
.fs-shell.show { display: flex; }
.fs-shell .fs-bar {
  height: 52px; flex: none; background: #0f1c2e; color: #fff;
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
}
.fs-shell .fs-bar .t { font-size: 14px; font-weight: 600; flex: 1; }
.fs-shell .fs-bar .x {
  cursor: pointer; font-size: 20px; line-height: 1; padding: 4px 8px;
  border-radius: var(--r-xs); color: #cbd5e1;
}
.fs-shell .fs-bar .x:hover { background: rgba(255,255,255,.12); color: #fff; }
.fs-shell .fs-body { flex: 1; overflow-y: auto; padding: 16px; }

/* ---------- 桌面全屏时隐藏侧栏 ---------- */
body.fs-mode .sidebar { display: none; }
body.fs-mode .main { margin-left: 0; }
body.fs-mode .mobile-bar { display: none; }

/* ---------- 打印 ---------- */
@media print {
  .sidebar, .topbar, .no-print, .modal-foot, .modal-head .x { display: none !important; }
  body { background: #fff; }
  .main { margin-left: 0; }
  .content { padding: 0; }
  .card { box-shadow: none; border: none; margin: 0; }
  .modal-mask { position: static; background: none; padding: 0; display: block; }
  .modal { box-shadow: none; max-width: none; }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    width: 236px; z-index: 80;
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .mobile-bar { display: flex; }
  .topbar { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .alloc-head, .alloc-row { grid-template-columns: 1fr 70px 70px 30px; }
  .content { padding: 16px 14px 60px; }
  .stat .val { font-size: 21px; }
  .modal { max-width: 100% !important; }
  .modal-mask { padding: 0; align-items: stretch; }
  .modal { border-radius: 0; min-height: 100vh; }
  .modal-foot { position: sticky; bottom: 0; background: var(--surface); }
}

@media (max-width: 560px) {
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 13px 14px; }
  .stat .val { font-size: 19px; }
  .form-grid { grid-template-columns: 1fr; }
  .portal-grid { grid-template-columns: 1fr; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters .field { min-width: 0; width: 100%; }
  .alloc-head { display: none; }
  .alloc-row { grid-template-columns: 1fr 60px 60px 28px; }
  th, td { padding: 9px 9px; font-size: 12.5px; }
  .fs-shell .fs-body { padding: 12px; }
}

/* 触屏设备：加大点击区域 */
@media (pointer: coarse) {
  .btn { padding: 9px 15px; }
  .btn.sm { padding: 6px 11px; font-size: 12.5px; }
  .nav-item { padding: 11px 12px; }
  .demo-acc { padding: 9px 10px; }
}
