/* ==========================================================
   生产制造 ERP — 全局样式
   零依赖，纯 CSS。变量集中在 :root，便于换肤。
   ========================================================== */
:root {
  /* 主色：管家婆蓝 */
  --primary: #2b5fd9;
  --primary-dark: #1e46b4;
  --primary-light: #dce7fb;
  --primary-soft: #eef3fd;

  /* 顶部品牌栏深蓝渐变 */
  --brand-1: #1f3a8f;
  --brand-2: #2b58c5;

  /* 中性色 */
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e4e7ee;
  --border-strong: #cdd4e0;
  --text: #1f2530;
  --text-2: #5f6470;
  --text-3: #9aa1ae;

  /* 状态色 */
  --success: #00b578;
  --success-bg: #e6f7f0;
  --warning: #ff8f1f;
  --warning-bg: #fff3e6;
  --danger: #fa5151;
  --danger-bg: #feecec;
  --info: #0891b2;
  --info-bg: #e0f6fa;
  --purple: #7c3aed;
  --purple-bg: #ede9fe;

  /* 尺寸 */
  --sidebar-w: 180px;
  --sidebar-w-collapsed: 56px;
  --topbar-h: 48px;
  --radius: 6px;
  --radius-sm: 4px;
  --shadow-sm: 0 1px 2px rgba(31, 42, 68, .05);
  --shadow: 0 2px 8px rgba(31, 42, 68, .07);
  --shadow-lg: 0 16px 48px rgba(31, 42, 68, .2);
}

* { box-sizing: border-box; }

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

.hidden { display: none !important; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 数字用等宽，表格金额才对得齐 */
.num, td.num, .kpi-value, .stat-value {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d3dae5; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aab6c8; }
html { scrollbar-width: thin; scrollbar-color: #d3dae5 transparent; }

/* ==========================================================
   登录页
   ========================================================== */
.login-view {
  position: fixed; inset: 0; display: flex;
  align-items: center; justify-content: center; padding: 20px;
  background: #fff;
}
.login-view::before { display: none; }
.login-card {
  position: relative; width: 100%; max-width: 400px;
  background: #fff; border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.04);
  padding: 48px 32px 28px; animation: card-in .35s ease;
  border: 1px solid #f0f0f0;
}
@keyframes card-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.login-brand { text-align: center; margin-bottom: 28px; }
.login-logo {
  width: 140px; height: auto; margin: 0 auto 16px;
  display: block;
  border-radius: 8px;
}
.login-brand h1 { margin: 0 0 4px; font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: 1px; }
.login-brand p { margin: 0; font-size: 13px; color: var(--text-3); }

.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block; margin-bottom: 6px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
}
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; color: var(--text);
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(43,95,217,.12);
}
.field textarea { resize: vertical; min-height: 64px; }
.field .hint { display: block; margin-top: 5px; font-size: 12px; color: var(--text-3); }
.field-error { display: block; margin-top: 5px; font-size: 12px; color: var(--danger); }

.form-error {
  margin-bottom: 14px; padding: 9px 12px;
  background: var(--danger-bg); border: 1px solid #fecaca;
  border-radius: var(--radius-sm); color: #991b1b; font-size: 13px;
}
.login-foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-3);
}
.login-tabs {
  display: flex; margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.login-tab {
  flex: 1; padding: 10px 0;
  background: none; border: none; cursor: pointer;
  font-size: 14px; font-family: inherit; font-weight: 500;
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.login-tab:hover { color: var(--text-2); }
.login-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.sms-code-row { display: flex; gap: 8px; }
.sms-code-row input { flex: 1; min-width: 0; }
.sms-send-btn { flex-shrink: 0; min-width: 108px; white-space: nowrap; font-size: 13px; }
.sms-send-btn:disabled { opacity: .65; cursor: not-allowed; }

/* ==========================================================
   按钮
   ========================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 32px; padding: 0 14px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface);
  font-size: 13px; font-family: inherit; font-weight: 500;
  color: var(--text); cursor: pointer; white-space: nowrap;
  transition: all .15s; line-height: 1;
}
.btn:hover { background: var(--surface); border-color: var(--primary); color: var(--primary); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.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-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #009a66; border-color: #009a66; color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #e04343; border-color: #e04343; color: #fff; }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-warning:hover { background: #ef7f0d; border-color: #ef7f0d; color: #fff; }
.btn-sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn-lg { height: 38px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; height: 40px; padding: 0; font-size: 14.5px; font-weight: 600; }
.btn-link {
  border: none; background: none; color: var(--primary);
  padding: 3px 6px; font-size: 12.5px; cursor: pointer;
}
.btn-link:hover { text-decoration: underline; background: var(--primary-soft); }
.btn-link.danger { color: var(--danger); }
.btn-link.danger:hover { background: var(--danger-bg); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0;
  border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2);
  font-size: 15px; cursor: pointer; transition: all .15s;
}
.icon-btn:hover { background: var(--border); color: var(--text); }

.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* ==========================================================
   主布局
   ========================================================== */
.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ==========================================================
   顶部品牌栏：深蓝渐变，左 logo 右用户
   ========================================================== */
.app-topbar {
  height: var(--topbar-h); flex-shrink: 0;
  background: linear-gradient(90deg, var(--brand-1), var(--brand-2));
  color: #fff; display: flex; align-items: center; gap: 14px;
  padding: 0 16px; position: relative; z-index: 10;
}
.brand-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 30px; height: 30px; flex-shrink: 0;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 7px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 11px; color: #fff; letter-spacing: .3px;
}
.brand-text { min-width: 0; line-height: 1.25; }
.brand-text strong {
  display: block; font-size: 15px; font-weight: 700; color: #fff; letter-spacing: .5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-text small { display: block; font-size: 11px; color: rgba(255, 255, 255, .72); white-space: nowrap; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-user .avatar {
  width: 28px; height: 28px; font-size: 12px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .28);
}
.topbar-user .user-meta { line-height: 1.25; }
.topbar-user .user-meta strong {
  display: block; font-size: 13px; color: #fff; max-width: 160px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-user .user-meta small {
  display: block; font-size: 11px; color: rgba(255, 255, 255, .72); max-width: 220px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-sep { width: 1px; height: 18px; background: rgba(255, 255, 255, .28); flex-shrink: 0; }
.app-topbar .icon-btn { color: rgba(255, 255, 255, .85); }
.app-topbar .icon-btn:hover { background: rgba(255, 255, 255, .16); color: #fff; }

.app-body { flex: 1; display: flex; min-height: 0; }

/* ==========================================================
   左侧二级菜单
   ========================================================== */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: width .2s ease; overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }

.nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 0 16px; }
.nav::-webkit-scrollbar-thumb { background: #cbd5e1; }
.nav-group { margin-bottom: 6px; }
.nav-group-title {
  padding: 10px 16px 4px; font-size: 11px; font-weight: 600;
  color: var(--text-3); white-space: nowrap;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  height: 36px; padding: 0 16px;
  color: var(--text-2); font-size: 13px; cursor: pointer;
  transition: background .13s, color .13s; white-space: nowrap; position: relative;
  border: none; background: none; width: 100%; text-align: left;
  font-family: inherit;
}
.nav-item:hover { background: #f0f5ff; color: var(--primary); }
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary); font-weight: 600;
}
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 0;
  width: 3px; height: 100%; background: var(--primary);
}
.nav-icon { width: 18px; text-align: center; font-size: 14px; flex-shrink: 0; opacity: .92; }
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-badge {
  padding: 1px 6px; border-radius: 9px; font-size: 10.5px; font-weight: 700;
  background: var(--danger); color: #fff; flex-shrink: 0;
}
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-group-title,
.sidebar.collapsed .nav-badge { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 0 8px; }

.avatar {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%;
  background: linear-gradient(135deg, #4a7bf7, #2b5fd9);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700;
}
.user-meta { min-width: 0; }

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

/* 二级顶栏：面包屑 + 在线数 + 时钟 */
.topbar {
  height: 40px; flex-shrink: 0;
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  position: relative; z-index: 5;
}
.crumb {
  flex: 1; font-size: 14px; font-weight: 600; color: var(--text); min-width: 0;
}
.crumb small { font-weight: 400; color: var(--text-3); font-size: 12px; margin-left: 8px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.online-badge {
  padding: 2px 10px; border-radius: 10px; font-size: 12px; font-weight: 600;
  background: var(--success-bg); color: #00915f;
  font-variant-numeric: tabular-nums;
}
.online-badge.busy { background: var(--warning-bg); color: #c05c00; }
.clock { font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.content { flex: 1; overflow-y: auto; padding: 16px; }
.page-loading { padding: 60px; text-align: center; color: var(--text-3); }

.overlay {
  position: fixed; inset: 0; background: rgba(31, 42, 68, .5); z-index: 90;
  animation: fade-in .2s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.only-mobile { display: none; }

/* ==========================================================
   通用组件
   ========================================================== */
.page-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.page-head h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.2px; }
.page-head .sub { font-size: 12.5px; color: var(--text-3); }
.page-head .spacer { flex: 1; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  margin-bottom: 16px; overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.card-head h3 { margin: 0; font-size: 14px; font-weight: 700; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

/* 指标卡 */
.kpi-grid {
  display: grid; gap: 14px; margin-bottom: 16px;
  grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
}
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 16px;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: box-shadow .18s, transform .18s;
}
.kpi:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.kpi::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--primary);
}
.kpi.k-success::after { background: var(--success); }
.kpi.k-warning::after { background: var(--warning); }
.kpi.k-danger::after  { background: var(--danger); }
.kpi.k-info::after    { background: var(--info); }
.kpi.k-purple::after  { background: var(--purple); }
.kpi-label { font-size: 12.5px; color: var(--text-3); margin-bottom: 7px; }
.kpi-value { font-size: 23px; font-weight: 700; line-height: 1.2; letter-spacing: -.3px; }
.kpi-value .unit { font-size: 13px; font-weight: 500; color: var(--text-3); margin-left: 3px; }
.kpi-foot {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px; font-size: 12px; color: var(--text-3);
}
.trend { font-weight: 700; font-variant-numeric: tabular-nums; }
.trend.up { color: #009a66; }
.trend.down { color: var(--danger); }
.trend.flat { color: var(--text-3); }

/* 网格布局 */
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

/* 筛选栏：白底卡片内横向筛选 */
.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.toolbar .spacer { flex: 1; }
.toolbar input, .toolbar select {
  padding: 6px 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-size: 13px;
  font-family: inherit; background: var(--surface); color: var(--text);
}
.toolbar input:focus, .toolbar select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(43,95,217,.1);
}
.toolbar input[type="search"] { min-width: 190px; }
.toolbar label { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 5px; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  padding: 10px 12px; text-align: left; font-weight: 700; font-size: 12.5px;
  color: #464c58; background: #f5f6f7;
  border-bottom: 1px solid var(--border); white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
}
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--primary); background: var(--primary-soft); }
table.data th .sort-mark { margin-left: 3px; font-size: 10px; color: var(--primary); }
table.data td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr { transition: background .12s; }
table.data tbody tr:nth-child(even) { background: #fafbfc; }
table.data tbody tr:hover { background: #f0f6ff; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.center, table.data th.center { text-align: center; }
table.data td.actions { white-space: nowrap; text-align: right; }
table.data tr.clickable { cursor: pointer; }
table.data tfoot td {
  padding: 9px 12px; font-weight: 700; background: var(--surface-2);
  border-top: 2px solid var(--border-strong);
}
.table-empty { padding: 48px 16px; text-align: center; color: var(--text-3); }
.table-empty .icon { font-size: 34px; display: block; margin-bottom: 10px; opacity: .45; }

/* 标签 */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 4px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--border); color: var(--text-2);
}
.tag.t-gray   { background: #f1f2f5; color: #5f6470; }
.tag.t-blue   { background: var(--primary-light); color: var(--primary-dark); }
.tag.t-green  { background: var(--success-bg); color: #00915f; }
.tag.t-orange { background: var(--warning-bg); color: #c05c00; }
.tag.t-red    { background: var(--danger-bg); color: #d43c3c; }
.tag.t-cyan   { background: var(--info-bg); color: #155e75; }
.tag.t-purple { background: var(--purple-bg); color: #5b21b6; }
.tag-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* 分页 */
.pager {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 16px; border-top: 1px solid var(--border);
  background: var(--surface); font-size: 12.5px; color: var(--text-2);
}
.pager .spacer { flex: 1; }
.pager select {
  padding: 4px 8px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-size: 12.5px;
  font-family: inherit; background: var(--surface);
}
.page-btns { display: flex; gap: 4px; }
.page-btn {
  min-width: 30px; height: 30px; padding: 0 7px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 12.5px; cursor: pointer;
  color: var(--text-2); font-family: inherit;
}
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.page-btn:disabled { opacity: .42; cursor: not-allowed; }

/* 详情描述列表 */
.desc { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0; }
.desc-item { padding: 9px 0; border-bottom: 1px dashed var(--border); }
.desc-item dt { font-size: 12px; color: var(--text-3); margin-bottom: 3px; }
.desc-item dd { margin: 0; font-size: 13.5px; font-weight: 500; word-break: break-all; }
.desc-item dd.num { font-variant-numeric: tabular-nums; }

/* 图表容器 */
.chart-box { position: relative; width: 100%; height: 268px; }
.chart-box.tall { height: 330px; }
.chart-box.short { height: 200px; }
.chart-box canvas { display: block; width: 100%; height: 100%; }
.chart-legend {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-top: 10px; font-size: 12px; color: var(--text-2);
}
.chart-legend .li { display: flex; align-items: center; gap: 5px; }
.chart-legend .sw { width: 10px; height: 10px; border-radius: 2px; }

/* 提示条 */
.alert {
  padding: 10px 13px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 14px;
  display: flex; align-items: flex-start; gap: 8px;
  border: 1px solid transparent;
}
.alert.a-info    { background: var(--info-bg);    border-color: #b8e9f2; color: #0e6f8c; }
.alert.a-warning { background: var(--warning-bg); border-color: #ffdcb0; color: #b25a00; }
.alert.a-danger  { background: var(--danger-bg);  border-color: #fbc9c9; color: #c73a3a; }
.alert.a-success { background: var(--success-bg); border-color: #b9e9d5; color: #008a5c; }
.alert.a-ok      { background: var(--success-bg); border-color: #b9e9d5; color: #008a5c; }

/* 空状态 */
.empty { padding: 44px 20px; text-align: center; color: var(--text-3); }
.empty .icon { font-size: 40px; display: block; margin-bottom: 12px; opacity: .4; }
.empty p { margin: 0 0 14px; font-size: 13.5px; }

/* 骨架/加载 */
.loading-block { padding: 40px; text-align: center; color: var(--text-3); }
.spinner {
  display: inline-block; width: 15px; height: 15px;
  border: 2px solid var(--border-strong); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================
   弹窗
   ========================================================== */
.modal-host { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal {
  background: var(--surface); border-radius: 8px;
  box-shadow: var(--shadow-lg); width: 100%; max-width: 680px;
  animation: modal-in .22s ease; margin-bottom: 40px;
}
.modal.wide { max-width: 1180px; }
.modal.narrow { max-width: 420px; }
/* 放大状态：接近全屏，body 撑满可滚动 */
.modal.maximized {
  max-width: none; width: 96vw; height: 94vh;
  display: flex; flex-direction: column;
}
.modal.maximized .modal-body { flex: 1; max-height: none; overflow-y: auto; }
/* 放大状态下内容更宽松：表单单列转双列不再拥挤 */
.modal.maximized .form-grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
@keyframes modal-in { from { opacity: 0; transform: translateY(-12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px; border-bottom: 1px solid var(--border);
  background: var(--surface); border-radius: 8px 8px 0 0;
}
.modal-head h3 {
  margin: 0; font-size: 15px; font-weight: 700; flex: 1;
  position: relative; padding-left: 11px;
}
.modal-head h3::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 14px; background: var(--primary); border-radius: 2px;
}
.modal-body { padding: 20px 22px; max-height: calc(100vh - 150px); overflow-y: auto; }
/* 弹窗内表格里的表单字段（如 MRP 整批转单补选供应商）：去掉 label 留白 */
.modal-body table .field { margin-bottom: 0; }
.modal-body table .field > span:empty { display: none; }
.modal-foot {
  display: flex; align-items: center; gap: 8px; justify-content: flex-end;
  padding: 13px 18px; border-top: 1px solid var(--border); background: var(--surface);
}
.modal-foot .spacer { flex: 1; }

.form-grid { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
/* 跟进记录弹窗：字段单列竖排，输入框更宽便于填写 */
.fu-vertical .form-grid { grid-template-columns: 1fr; gap: 4px 0; }
.fu-vertical .form-grid .field { margin-bottom: 8px; }
.form-section {
  grid-column: 1 / -1; margin: 10px 0 2px; padding-bottom: 6px;
  font-size: 13px; font-weight: 600; color: var(--text);
  border-bottom: 1px solid var(--border);
}
.form-section:first-child { margin-top: 0; }

/* ============ 编辑弹窗精细化（参考金蝶云星空） ============ */
/* 1) 输入框统一 34px 高 + hover 态（textarea 除外） */
.modal-body .field > input, .modal-body .form-item > input,
.modal-body .field > select, .modal-body .form-item > select {
  height: 34px; box-sizing: border-box;
  transition: border-color .15s, box-shadow .15s;
}
.modal-body .field > textarea, .modal-body .form-item > textarea { box-sizing: border-box; }
.modal-body input:hover:not(:disabled), .modal-body select:hover:not(:disabled),
.modal-body textarea:hover:not(:disabled) { border-color: #9db6e8; }
/* 2) 必填字段标签前红色 *（label 含 required 类时由 JS 渲染，这里兜底样式） */
.field .req, .form-item .req { color: var(--danger, #fa5151); margin-right: 2px; }
/* 3) 明细表格内输入框"隐形边框"：默认融入表格，hover/聚焦才显示，视觉更干净 */
.modal-body table input[type="text"], .modal-body table input[type="number"],
.modal-body table select {
  height: 30px; box-sizing: border-box;
  border-color: transparent; background: transparent;
  transition: border-color .15s, background .15s;
}
.modal-body table input:hover, .modal-body table select:hover { border-color: #c8d4ea; background: #fff; }
.modal-body table input:focus, .modal-body table select:focus { border-color: var(--primary); background: #fff; }
/* 4) 分组标题加主蓝竖条，与弹窗标题风格一致 */
.form-section { position: relative; padding-left: 9px; }
.form-section::before {
  content: ''; position: absolute; left: 0; top: 2px;
  width: 3px; height: 13px; background: var(--primary); border-radius: 2px;
}
/* 5) 弹窗底部操作栏视觉增强：浅灰底区分内容区 */
.modal-foot { background: var(--surface-2, #f7f8fa); border-radius: 0 0 8px 8px; }

/* 明细行编辑器 */
.lines-editor { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.lines-editor table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.lines-editor th {
  padding: 7px 8px; background: var(--surface-2); text-align: left;
  font-size: 11.5px; font-weight: 600; color: var(--text-2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.lines-editor td { padding: 5px 8px; border-bottom: 1px solid var(--border); }
.lines-editor td.num, .lines-editor th.num { text-align: right; }
.lines-editor input, .lines-editor select {
  width: 100%; padding: 5px 7px; border: 1px solid var(--border-strong);
  border-radius: 4px; font-size: 12.5px; font-family: inherit; background: var(--surface);
}
.lines-editor input:focus, .lines-editor select:focus { outline: none; border-color: var(--primary); }
.lines-editor input.num { text-align: right; font-variant-numeric: tabular-nums; }
.lines-editor tr:hover td { background: var(--primary-soft); }
.lines-foot {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: var(--surface-2); border-top: 1px solid var(--border); flex-wrap: wrap;
}
.lines-sum { margin-left: auto; font-size: 12.5px; color: var(--text-2); }
.lines-sum strong { color: var(--text); font-size: 14px; font-variant-numeric: tabular-nums; }

/* 提示气泡 */
.toast-host {
  position: fixed; top: 16px; right: 16px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
  max-width: min(400px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 11px 14px; border-radius: var(--radius);
  background: #0f172a; color: #f1f5f9; font-size: 13px;
  box-shadow: var(--shadow-lg); pointer-events: auto;
  animation: toast-in .25s ease; border-left: 3px solid var(--primary);
  word-break: break-word;
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast .t-icon { flex-shrink: 0; }
.toast .t-close {
  margin-left: 6px; background: none; border: none; color: #64748b;
  cursor: pointer; font-size: 14px; padding: 0 2px; line-height: 1;
}
.toast .t-close:hover { color: #e2e8f0; }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.toast.out { animation: toast-out .2s ease forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }

/* 标签页 */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab {
  padding: 8px 15px; border: none; background: none; cursor: pointer;
  font-size: 13.5px; font-family: inherit; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  transition: all .15s;
}
.tab:hover { color: var(--primary); background: var(--primary-soft); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* 进度条 */
.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; min-width: 60px; }
.progress > i { display: block; height: 100%; background: var(--primary); border-radius: 3px; transition: width .3s; }
.progress.ok > i { background: var(--success); }
.progress.warn > i { background: var(--warning); }
.progress.bad > i { background: var(--danger); }

/* 权限矩阵 */
.perm-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.perm-table th, .perm-table td { padding: 7px 10px; border: 1px solid var(--border); text-align: center; }
.perm-table th { background: var(--surface-2); font-weight: 600; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; white-space: nowrap; }
.perm-table .yes { color: #009a66; font-weight: 700; }
.perm-table .no { color: var(--text-3); }
.perm-table label { display: inline-flex; align-items: center; cursor: pointer; }

/* 时间线（跟进记录） */
.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: -19px; top: 5px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--primary); border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--primary-light);
}
.tl-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); margin-bottom: 4px; }
.tl-body { font-size: 13px; color: var(--text); }

/* 文本工具类 */
.text-muted { color: var(--text-3); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-12 { font-size: 12px; }
.fs-13 { font-size: 13px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.flex { display: flex; } .items-center { align-items: center; }
.gap-6 { gap: 6px; } .gap-10 { gap: 10px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* ==========================================================
   补充：JS 动态渲染组件的统一样式（tab-btn / form-item / summary-bar 等）
   ========================================================== */
.tab-btn {
  padding: 8px 15px; border: none; background: none; cursor: pointer;
  font-size: 13.5px; font-family: inherit; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  transition: all .15s;
}
.tab-btn:hover { color: var(--primary); background: var(--primary-soft); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.form-item { display: block; margin-bottom: 16px; }
.form-item > .form-label, .form-label {
  display: block; margin-bottom: 6px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
}
.form-item input, .form-item select, .form-item textarea {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; color: var(--text);
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.form-item input:focus, .form-item select:focus, .form-item textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(43, 95, 217, .12);
}
.form-grid .form-item { margin-bottom: 12px; }
/* 管家婆式横向表单：弹窗/表单网格内 label 右对齐，输入靠左 */
.form-grid .field,
.form-grid .form-item {
  display: grid; grid-template-columns: 96px minmax(0, 1fr);
  align-items: center; column-gap: 8px;
}
.form-grid .field > span:first-child,
.form-grid .form-item > .form-label {
  grid-column: 1; margin-bottom: 0;
  text-align: right; font-weight: 400; color: var(--text-2);
  white-space: nowrap;
}
.form-grid .field > input, .form-grid .field > select, .form-grid .field > textarea,
.form-grid .field > div,
.form-grid .form-item > input, .form-grid .form-item > select,
.form-grid .form-item > textarea, .form-grid .form-item > div { grid-column: 2; }
.form-grid .field > .hint, .form-grid .field > .field-error { grid-column: 2; }
.summary-bar {
  display: flex; justify-content: flex-end; align-items: center; gap: 6px;
  padding: 10px 16px; margin-top: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px; color: var(--text-2);
}
.summary-bar strong.num { font-size: 15px; color: var(--text); }
.tip { font-size: 12px; color: var(--text-3); }
.toast .t-msg { flex: 1; min-width: 0; }

/* JS 动态渲染的紧凑表格（production.js 缺料提示等） */
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.table th {
  padding: 10px 12px; text-align: left; font-weight: 700; font-size: 12.5px;
  color: #464c58; background: #f5f6f7;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.table tbody tr { transition: background .12s; }
table.table tbody tr:nth-child(even) { background: #fafbfc; }
table.table tbody tr:hover { background: #f0f6ff; }
table.table td.num, table.table th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.table td.center, table.table th.center { text-align: center; }
table.table.compact th, table.table.compact td { padding: 5px 8px; font-size: 12.5px; }

/* 补充工具类（JS 页面中使用） */
.fw-500 { font-weight: 500; }
.fs-14 { font-size: 14px; } .fs-16 { font-size: 16px; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.mt-4 { margin-top: 4px; } .mb-4 { margin-bottom: 4px; }
.p-12 { padding: 12px; } .pt-4 { padding-top: 4px; }
.justify-between { justify-content: space-between; }

/* ==========================================================
   响应式
   ========================================================== */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-h); bottom: 0; z-index: 95;
    transform: translateX(-100%); transition: transform .22s ease;
    width: var(--sidebar-w) !important;
  }
  .sidebar.mobile-open { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar.collapsed { width: var(--sidebar-w) !important; }
  .sidebar.collapsed .nav-label { display: inline; }
  .sidebar.collapsed .nav-group-title { display: block; }
  .sidebar.collapsed .nav-badge { display: inline-flex; }
  .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 0 16px; }
  .sidebar-collapse { display: none; }
  .only-mobile { display: inline-flex; }
  .content { padding: 12px; }
  .clock { display: none; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
  .kpi-value { font-size: 19px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .modal-host { padding: 12px; }
  .modal-body { max-height: calc(100vh - 190px); }
}
@media (max-width: 560px) {
  .toolbar { padding: 10px 12px; }
  .toolbar input[type="search"] { min-width: 100%; }
  .page-head h2 { font-size: 15px; }
  .online-badge { display: none; }
  .brand-text small, .topbar-user .user-meta small { display: none; }
}

/* 打印 */
@media print {
  .app-topbar, .sidebar, .topbar, .toolbar, .pager, .btn, .toast-host { display: none !important; }
  .app { display: block; height: auto; overflow: visible; }
  .content { padding: 0; overflow: visible; }
  .card { box-shadow: none; border-color: #ccc; page-break-inside: avoid; }
}
