:root {
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --sidebar-w: 228px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: clamp(12px, 1.27vw, 14px); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 1rem;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }

#app { display: flex; min-height: 100vh; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: var(--sidebar-w); background: #0f172a; color: #e2e8f0;
  display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0;
  z-index: 50; transition: transform .2s ease;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid #1e293b; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 10px; background: var(--primary);
  color: #fff; font-weight: 800; font-size: 1.43rem; display: flex;
  align-items: center; justify-content: center; overflow: hidden;
}
.brand-logo-img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; }
.brand-name { font-size: 1.14rem; font-weight: 700; }
.brand-sub { font-size: 0.79rem; color: #94a3b8; }
.nav {
  padding: 10px 8px;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
}
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: 8px; color: #cbd5e1;
  font-size: 1rem; margin-bottom: 2px; cursor: pointer; transition: background .15s;
}
.nav-item:hover { background: #1e293b; color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
/* 菜单 inline 编辑：隐藏项半透明，不消失（原位可见，勾选即回） */
.nav-item.hidden { opacity: .4; filter: grayscale(.6); }
.nav-item-label { display: inline-flex; align-items: center; gap: 2px; }
.nav-item-actions { display: inline-flex; gap: 2px; margin-left: 8px; }
.nav-edit-btn {
  width: 22px; height: 22px; border: 1px solid #334155; border-radius: 5px;
  background: transparent; color: #94a3b8; font-size: 0.85rem; line-height: 1;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.nav-edit-btn:hover { background: #1e293b; color: #fff; }
.nav-edit-btn.show:hover { border-color: #22c55e; color: #22c55e; }
.nav-edit-btn.hide:hover { border-color: #ef4444; color: #ef4444; }
/* 菜单编辑齿轮（品牌区右上角） */
.nav-edit-toggle {
  margin-left: auto; background: transparent; border: 1px solid #334155; border-radius: 6px;
  color: #94a3b8; font-size: 1rem; width: 28px; height: 28px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: all .15s;
}
.nav-edit-toggle:hover { color: #fff; border-color: #64748b; }
.nav-edit-toggle.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.nav-badge {
  margin-left: auto;
  background: #f56c6c;
  color: #fff;
  font-size: 0.79rem;
  line-height: 16px;
  min-width: 16px;
  padding: 0 5px;
  border-radius: 8px;
  text-align: center;
}
/* 导航分组 */
.nav-group { margin-bottom: 4px; }
.nav-group-title {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; font-size: 0.86rem; color: #7c8db5; font-weight: 700;
  letter-spacing: 1px; cursor: pointer; user-select: none; border-radius: 8px;
}
.nav-group-title:hover { color: #cbd5e1; background: rgba(255,255,255,.04); }
.nav-group-arrow { font-size: 0.71rem; transition: transform .2s ease; }
.nav-group.open .nav-group-arrow { transform: rotate(180deg); }
/* 分组整体隐藏（编辑模式）：标题 + 子项全部半透明 */
.nav-group.hidden { opacity: .4; filter: grayscale(.6); }
.nav-group-title .nav-item-actions { margin-left: auto; }
.nav-group-label { flex: 1; }
.nav-group-body { display: none; }
.nav-group.open .nav-group-body { display: block; }
.nav-group-body .nav-item { padding: 8px 12px 8px 20px; font-size: 0.93rem; }
.nav-group-body .nav-item.active { background: var(--primary); }
.nav-group-body .nav-badge { margin-top: 0; line-height: 15px; }
.sidebar-foot { padding: 12px; border-top: 1px solid #1e293b; }
.server-info { font-size: 0.79rem; color: #64748b; margin-bottom: 8px; word-break: break-all; }

/* ---------- 主区域 ---------- */
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
  position: sticky; top: 0; z-index: 40;
}
.topbar h1 { font-size: 1.21rem; font-weight: 700; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.clock { font-size: 0.93rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.user-menu { position: relative; margin-right: 14px; }
.user-chip {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--border);
  background: #fff; border-radius: 999px; padding: 4px 10px 4px 5px; cursor: pointer;
}
.user-chip:hover { border-color: #cbd5e1; background: #f8fafc; }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 0.93rem; font-weight: 700;
}
.user-info { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.user-name { font-size: 0.86rem; font-weight: 700; color: var(--text); max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 0.71rem; color: var(--muted); }
.user-caret { font-size: 0.71rem; color: var(--muted); }
.user-dropdown {
  position: absolute; right: 0; top: 42px; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(15,23,42,.18); min-width: 190px; z-index: 60;
  padding: 6px; display: flex; flex-direction: column;
}
.user-menu-item {
  display: block; width: 100%; text-align: left; padding: 9px 12px; border: none; background: none;
  font-size: 0.93rem; color: var(--text); cursor: pointer; border-radius: 7px; font-family: inherit;
}
.user-menu-item:hover { background: #f1f5f9; }
.user-menu-item.danger { color: var(--red); }
.user-menu-item.danger:hover { background: #fef2f2; }
.menu-btn { display: none; }
.content { padding: 20px; flex: 1; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.card-title { font-size: 1.07rem; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card-title .sub { font-size: 0.86rem; color: var(--muted); font-weight: 400; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 8px; padding: 7px 14px; font-size: 0.93rem; font-weight: 600;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary); opacity: .9; }
.btn-danger { background: #fff; border-color: #fca5a5; color: var(--red); }
.btn-danger:hover { background: #fef2f2; }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f1f5f9; color: var(--text); }
.btn-sm { padding: 4px 9px; font-size: 0.86rem; border-radius: 6px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { background: none; border: none; font-size: 1.43rem; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: #f1f5f9; }
/* 报警铃铛：有未读报警时晃动，0 报警静止 */
.bell-btn.ringing { animation: bell-ring 1.2s ease-in-out infinite; transform-origin: top center; display: inline-block; }
@keyframes bell-ring {
  0%, 100% { transform: rotate(0deg); }
  10% { transform: rotate(18deg); }
  20% { transform: rotate(-16deg); }
  30% { transform: rotate(14deg); }
  40% { transform: rotate(-10deg); }
  50% { transform: rotate(6deg); }
  60% { transform: rotate(-4deg); }
  70% { transform: rotate(0deg); }
}

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }

.input, .select, textarea.input {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 11px;
  font-size: 0.93rem; background: #fff; color: var(--text); outline: none;
  font-family: inherit;
}
.input:disabled, .input[readonly] { background: #f1f5f9; color: #94a3b8; cursor: not-allowed; }
.input:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.input-sm { padding: 5px 8px; font-size: 0.86rem; }

table.table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
.table th {
  text-align: left; padding: 9px 10px; color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--border); white-space: nowrap; font-size: 0.86rem;
  background: #f8fafc;
}
.table td { padding: 9px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table td { word-break: break-word; }
/* 长文本自适应截断：默认换行，.ellipsis 单元格则单行省略号 + 悬停提示 */
.table td.ellipsis { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; word-break: normal; }
.table td.ellipsis:hover { overflow: visible; white-space: normal; background: var(--card); position: relative; z-index: 5; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.table tbody tr:hover { background: #f8fafc; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.86rem; font-weight: 600; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-dark { background: #e2e8f0; color: #334155; }

.progress { background: #e2e8f0; border-radius: 999px; height: 8px; overflow: hidden; min-width: 70px; }
.progress > div { height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s; }
.progress.done > div { background: var(--green); }
.progress-text { font-size: 0.79rem; color: var(--muted); margin-top: 3px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { container-type: inline-size; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.stat-card .stat-label { font-size: 0.86rem; color: var(--muted); margin-bottom: 6px; }
.stat-card .stat-value { font-size: clamp(12px, 10cqw, 26px); font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }
.stat-card .stat-sub { font-size: 0.79rem; color: var(--muted); margin-top: 4px; }
.stat-card.accent { border-top: 3px solid var(--primary); }
.stat-card.green { border-top: 3px solid var(--green); }
.stat-card.amber { border-top: 3px solid var(--amber); }
.stat-card.red { border-top: 3px solid var(--red); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab {
  padding: 9px 16px; border: none; background: none; font-size: 1rem; cursor: pointer;
  color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; white-space: nowrap;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.empty { text-align: center; color: var(--muted); padding: 48px 0; }
.empty .icon { font-size: 2.71rem; margin-bottom: 10px; }

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

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.form-field { display: block; margin-bottom: 12px; min-width: 0; }
.form-field > label { display: block; font-size: 0.86rem; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.form-field .input, .form-field .select { width: 100%; min-width: 0; }
.form-field.full { grid-column: 1 / -1; }
/* 文本自适应：input/select/textarea 长内容不撑破容器 */
.form-field .input, .form-field .select, .form-field textarea { box-sizing: border-box; }
.form-field .input, .form-field .select { font-size: 0.93rem; }
/* 动态行输入列头 */
.detail-head {
  display: flex; gap: 8px; align-items: center; margin-bottom: 6px;
  font-size: 0.86rem; color: var(--muted); font-weight: 600;
}
.detail-head span { white-space: nowrap; }
.ops-grid { display: flex; flex-wrap: wrap; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: #f8fafc; }
/* 图片上传 */
.img-uploader { display: flex; flex-direction: column; gap: 8px; }
.img-upload-preview {
  width: 140px; height: 140px; border: 1px dashed var(--border); border-radius: 10px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: #f8fafc;
}
.img-upload-preview img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.img-upload-actions { display: flex; gap: 8px; }
.img-upload-hint { font-size: 0.79rem; color: var(--muted); line-height: 1.6; }
.thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); cursor: zoom-in; display: block; }
.thumb-empty {
  width: 40px; height: 40px; border-radius: 6px; background: #f1f5f9;
  display: inline-flex; align-items: center; justify-content: center;
  color: #94a3b8; font-size: 0.79rem; border: 1px solid var(--border);
}

.qr-cell { text-align: center; }
.qr-cell img { width: 56px; height: 56px; border: 1px solid var(--border); border-radius: 6px; }

.tooltip { position: relative; }

/* ---------- 甘特图 ---------- */
.gantt-wrap { overflow: auto; max-height: calc(100vh - 260px); border: 1px solid var(--border); border-radius: 10px; background: #fff; position: relative; }
.gantt-inner { position: relative; min-width: 100%; }
.gantt-header { position: sticky; top: 0; z-index: 5; height: 46px; display: grid; grid-template-columns: 150px minmax(0,1fr); background: #f8fafc; border-bottom: 1px solid var(--border); }
.gantt-time-area { position: relative; height: 45px; min-width: 0; }
.gantt-header .gantt-time-area { height: 46px; background: #f8fafc; }
.gantt-day-head {
  position: absolute; top: 0; bottom: 0; border-left: 1px solid #dce3ec;
  display: flex; align-items: center; padding-left: 4px; font-size: 0.79rem; color: var(--muted);
  white-space: nowrap; box-sizing: border-box;
}
.gantt-day-head.today { color: var(--red); font-weight: 700; background: rgba(220,38,38,.025); }
.gantt-hour-line { position: absolute; top: 0; bottom: 0; border-left: 1px dashed #f1f5f9; }
.gantt-hour-line.major { border-left-style: solid; border-color: #dce3ec; }
.gantt-row { display: grid; grid-template-columns: 150px minmax(0,1fr); border-bottom: 1px solid #eef2f6; height: 45px; position: relative; }
.gantt-label {
  position: sticky; left: 0; z-index: 4; width: 150px; min-width: 150px; background: #fff;
  border-right: 1px solid var(--border); padding: 0 12px; display: flex; flex-direction: column;
  justify-content: center; box-sizing: border-box;
}
.gantt-corner { height:46px; color:var(--muted); font-size: 0.79rem; font-weight:700; background:#f8fafc; }
.gantt-label .code { font-size: 0.86rem; font-weight: 700; }
.gantt-label .name { font-size: 0.79rem; color: var(--muted); }
.gantt-bar {
  position: absolute; top: 7px; height: 30px; border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; padding: 0; font-size: 0.79rem; color: #2e4057;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; box-shadow: 0 1px 2px rgba(30,50,75,.08);
  background:#dfe8f2; border:1px solid #c8d5e3; border-left:4px solid var(--customer-color,#64748b); z-index:2;
}
.gantt-bar.in_progress { background:#d9e9e5; border-color:#bdd8d1; border-left-color:var(--customer-color,#277765); }
.gantt-bar.completed { background:#edf0f3; border-color:#dce1e7; border-left-color:#98a3b1; color:#7a8593; box-shadow:none; }
.gantt-fill { position: absolute; top: 0; bottom: 0; left: 0; background: rgba(49,95,155,.10); }
.gantt-bar-text { position: relative; z-index: 1; flex: 1; min-width: 0; padding: 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt-bar.overdue { box-shadow:inset 0 0 0 2px #c84640; }
.gantt-bar.selected { box-shadow:inset 0 0 0 2px #2563eb,0 0 0 2px rgba(37,99,235,.18); z-index:3; }
.gantt-bar:hover { filter:brightness(.98); box-shadow:0 3px 8px rgba(30,50,75,.18); z-index:4; }
.gantt-now { position: absolute; top: 0; bottom: 0; border-left: 2px solid #dc2626; z-index: 3; pointer-events: none; }
.gantt-now-label { position: absolute; top: 2px; left: 3px; font-size: 0.71rem; color: var(--red); background: #fff; padding: 0 3px; border-radius: 3px; white-space: nowrap; }
.gantt-legend { display: flex; gap: 14px; font-size: 0.86rem; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.gantt-legend span { display: inline-flex; align-items: center; gap: 5px; }
.gantt-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

.schedule-toolbar { gap:8px; }
.schedule-strategy-group { position:relative; }
.schedule-strategy-select { width:auto; min-width:150px; }
.schedule-mode-switch { display:inline-flex; gap:2px; padding:3px; margin-left:10px; background:#eef2f6; border-radius:8px; }
.schedule-mode { border:0; background:transparent; color:#66758a; padding:6px 12px; border-radius:6px; cursor:pointer; font-weight:600; }
.schedule-mode.active { color:#245ca6; background:#fff; box-shadow:0 1px 4px rgba(30,50,75,.14); }
.schedule-zoom { min-width:76px; text-align:center; cursor:pointer; }
.schedule-filters { display:flex; align-items:center; gap:8px; margin-bottom:12px; flex-wrap:wrap; }
.schedule-filters .select { width:auto; min-width:145px; }
.schedule-filters .input { width:230px; }
.schedule-filter-note { margin-left:auto; font-size: 0.79rem; }
.schedule-summary { display:grid; grid-template-columns:repeat(6,minmax(105px,1fr)); gap:9px; margin-bottom:12px; }
.schedule-kpi { background:#fff; border:1px solid var(--border); border-radius:9px; padding:9px 11px; box-shadow:0 1px 2px rgba(30,50,75,.03); }
.schedule-kpi span { display:block; color:var(--muted); font-size: 0.79rem; margin-bottom:3px; }
.schedule-kpi b { font-size: 1.36rem; color:#25364a; }
.schedule-kpi.danger { background:#fff7f6; border-color:#f1c8c5; }
.schedule-kpi.danger b { color:#b63f39; }
.schedule-kpi.warn { background:#fffbf1; border-color:#ead6a8; }
.schedule-kpi.warn b { color:#996516; }
.schedule-kpi.ok b { color:#26745c; }
.schedule-gantt-card { padding:16px; }
.schedule-gantt-head { display:flex; align-items:center; gap:8px; margin-bottom:10px; }
.schedule-chart-footer { display:flex; align-items:center; gap:10px; margin-top:8px; flex-wrap:wrap; }
.schedule-chart-footer .gantt-legend { flex:1; margin-top:0; }
.legend-task { background:#dfe8f2; border-left:4px solid #315f9b; }
.legend-customer { background:linear-gradient(90deg,#277765 0 4px,#edf0f3 4px); }
.legend-completed { background:#edf0f3; border:1px solid #dce1e7; }
.legend-overdue { background:#fff; box-shadow:inset 0 0 0 2px #c84640; }
.legend-order-task { background:#e6edf5; border:1px solid #aebed1; }
.legend-critical { background:#fff1e5; border:1px solid #df9b52; }
.legend-due { width:3px !important; background:#c63d38; border-radius:0 !important; }

/* 打印：隐藏导航/筛选等控件，甘特图横向内容跨页分段打印 */
@media print {
  @page { size: A4 landscape; margin: 8mm; }
  .sidebar, .topbar, .schedule-filters, .schedule-mode-switch,
  .schedule-strategy-group, .schedule-chart-footer, #toast-root, #modal-root { display: none !important; }
  .main { margin-left: 0 !important; }
  .content { padding: 0 !important; }
  .gantt-wrap { overflow: visible !important; max-height: none !important; }
}

.gantt-order-wrap .gantt-row { height:48px; }
.gantt-order-wrap .gantt-time-area { height:48px; }
.gantt-order-group-head { position:relative; display:grid; grid-template-columns:150px minmax(0,1fr); min-height:42px; background:#f8fafc; border-bottom:1px solid #dfe5ec; }
.gantt-order-customer { position:sticky; left:0; z-index:4; display:flex; flex-direction:column; justify-content:center; padding:6px 10px; background:#f8fafc; border-right:1px solid #dfe5ec; box-sizing:border-box; }
.gantt-order-customer b { font-size: 0.86rem; }
.gantt-order-customer span { color:var(--muted); font-size: 0.71rem; margin-top:2px; }
.gantt-order-summary { display:flex; align-items:center; gap:12px; padding:6px 10px; color:#637287; }
.gantt-order-summary .btn { margin-left:auto; }
.gantt-risk-text { padding:4px 7px; border-radius:999px; background:#eef2f6; color:#5d6a7b; }
.risk-late .gantt-risk-text { background:#fff0ef; color:#b53a35; }
.risk-due_soon .gantt-risk-text { background:#fff7e6; color:#9a6418; }
.risk-normal .gantt-risk-text { background:#edf8f3; color:#26745c; }
.gantt-order-task { position:absolute; top:9px; height:28px; z-index:2; overflow:hidden; box-sizing:border-box; padding:5px 6px; border-radius:5px; background:#e6edf5; border:1px solid #aebed1; border-left:4px solid var(--customer-color,#64748b); color:#34475e; font-size: 0.71rem; white-space:nowrap; text-overflow:ellipsis; cursor:pointer; }
.gantt-order-task.completed { background:#edf0f3; border-color:#dce1e7; color:#7a8593; }
.gantt-order-task.critical { background:#fff1e5; border-color:#df9b52; color:#874f16; font-weight:700; box-shadow:0 0 0 1px rgba(223,155,82,.25); }
.gantt-order-task.selected { box-shadow:inset 0 0 0 2px #2563eb,0 0 0 2px rgba(37,99,235,.18); }
.gantt-chain-link { position:absolute; top:23px; height:2px; background:#8a9aaf; z-index:1; }
.gantt-chain-link::after { content:"›"; position:absolute; right:-2px; top:-8px; font-size: 1.14rem; color:#71839a; }
.gantt-due { position:absolute; top:0; bottom:0; width:2px; background:#c63d38; z-index:3; pointer-events:none; }
.gantt-due::after { content:"交期"; position:absolute; top:1px; left:3px; padding:0 2px; background:#fff; color:#b53a35; font-size: 0.64rem; white-space:nowrap; }

@media (max-width: 1100px) {
  .schedule-summary { grid-template-columns:repeat(3,1fr); }
  .schedule-mode-hint,.schedule-filter-note { display:none; }
}

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade .15s ease-out;
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 520px; min-width: 0;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: pop .18s ease-out;
}
.modal-lg { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 1.14rem; }
.modal-body { padding: 20px; }
.modal-body { max-height: 72vh; overflow-y: auto; }
.modal-body .field-label { display: block; margin: 10px 0 4px; font-size: 0.86rem; color: var(--muted); }
.modal-body .input, .modal-body .select { width: 100%; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 11px 22px; border-radius: 10px;
  font-size: 1rem; z-index: 200; box-shadow: 0 6px 24px rgba(0,0,0,.3);
  animation: rise .2s ease-out; max-width: 80vw;
}
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- 移动端 ---------- */
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .main { margin-left: 0; }
  .menu-btn { display: block; }
  .content { padding: 14px; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
/* 窄屏模态框全宽自适应 */
@media (max-width: 600px) {
  .modal-mask { padding: 8px; }
  .modal, .modal-lg { max-width: 100%; width: 100%; }
  .table th, .table td { padding: 7px 8px; font-size: 0.86rem; }
  .toolbar { flex-wrap: wrap; gap: 8px; }
}

/* ---------- 其他 ---------- */
.inline-form { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.notice { padding: 9px 11px; margin-bottom: 12px; border: 1px solid #bfdbfe; border-radius: 8px; background: #eff6ff; color: #1e40af; font-size: 0.86rem; }
.receive-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.pager { display: flex; align-items: center; gap: 8px; padding: 12px 2px 2px; font-size: 0.86rem; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.86rem; }
.clickable { cursor: pointer; }
.clickable:hover { text-decoration: underline; }
.row-gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.qr-preview img { width: 120px; height: 120px; border: 1px solid var(--border); border-radius: 8px; }
.load-bar { height: 22px; background: #e2e8f0; border-radius: 6px; overflow: hidden; position: relative; }
.load-bar > div { height: 100%; background: var(--primary); }
.load-bar .done-part { background: var(--green); }
.load-bar span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 0.79rem; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.wc-group td { background: #f1f5f9; font-weight: 700; font-size: 0.93rem; }
.wc-group td .wc-pct { float: right; color: var(--muted); font-weight: 600; font-size: 0.86rem; }

/* 可视化工艺依赖编辑器 */
.routing-product-toolbar { margin-bottom:10px; }
.routing-product-select { width:min(360px,100%); }
.routing-editor { display:grid; gap:12px; }
.routing-editor-toolbar { display:flex; align-items:center; gap:7px; flex-wrap:wrap; }
.routing-editor-title { font-size: 1rem; font-weight:700; }
.routing-validation { padding:9px 12px; border:1px solid var(--border); border-radius:8px; font-size: 0.86rem; }
.routing-validation.valid { border-color:#a8d7c6; background:#f0f9f5; color:#226652; }
.routing-validation.invalid { border-color:#efc0bd; background:#fff5f4; color:#9f302c; }
.routing-validation ul { margin:6px 0 0; padding-left:20px; }
.routing-canvas-viewport { min-height:260px; max-width:100%; overflow:auto; border:1px solid var(--border); border-radius:10px; background:#f7f9fb; overscroll-behavior:contain; }
.routing-canvas { display:block; min-width:100%; touch-action:none; user-select:none; }
.routing-canvas text { font-family:inherit; pointer-events:none; }
.routing-node { cursor:grab; outline:none; transition:opacity .15s; }
.routing-node:active { cursor:grabbing; }
.routing-node.dimmed { opacity:.28; }
.routing-node-box { fill:#fff; stroke:#7f91a6; stroke-width:1.5; filter:drop-shadow(0 2px 3px rgba(15,23,42,.08)); }
.routing-node:hover .routing-node-box,.routing-node:focus .routing-node-box { stroke:#365f91; stroke-width:2; }
.routing-node.selected .routing-node-box { stroke:#1f6d5c; stroke-width:3; }
.routing-node-title { fill:var(--text); font-size: 0.93rem; font-weight:700; }
.routing-node-meta { fill:var(--muted); font-size: 0.79rem; }
.routing-node-time { fill:#718096; font-size: 0.71rem; }
.routing-port { stroke:#fff; stroke-width:3; cursor:crosshair; }
.routing-port.input { fill:#66788e; }
.routing-port.output { fill:#277765; }
.routing-port:hover { r:11; stroke:#d8eee7; }
.routing-edge { color:#64748b; cursor:pointer; }
.routing-edge-path { fill:none; stroke:currentColor; stroke-width:2; }
.routing-edge-hit { fill:none; stroke:transparent; stroke-width:16; }
.routing-edge-label { fill:currentColor; font-size: 0.79rem; font-weight:700; paint-order:stroke; stroke:#f7f9fb; stroke-width:4; }
.routing-edge.relation-SS { color:#277765; stroke-dasharray:7 3; }
.routing-edge.relation-FF { color:#725497; }
.routing-edge.relation-SF { color:#a26424; stroke-dasharray:3 3; }
.routing-edge.connected .routing-edge-path { stroke-width:3; }
.routing-edge.selected .routing-edge-path { stroke:#ba3f3a; stroke-width:3; }
.routing-arrow-head { fill:currentColor; }
.routing-edge-draft { fill:none; stroke:#277765; stroke-width:2; stroke-dasharray:6 4; pointer-events:none; }
.routing-edge-editor { min-height:38px; display:flex; align-items:center; gap:10px; flex-wrap:wrap; padding:8px 12px; border:1px dashed var(--border); border-radius:8px; }
.routing-edge-editor:empty { display:none; }
.routing-tables { display:grid; grid-template-columns:minmax(0,1.35fr) minmax(0,1fr); gap:12px; align-items:start; }
.routing-tables section { min-width:0; border:1px solid var(--border); border-radius:9px; overflow:hidden; }
.routing-tables h4 { margin:0; padding:10px 12px; background:#f5f7fa; border-bottom:1px solid var(--border); font-size: 0.93rem; }
.routing-tables .table-wrap { border:0; border-radius:0; }
.routing-tables .input-sm,.routing-tables .select.input-sm { min-width:72px; }
.routing-relation-FS { background:#edf2f7; color:#475569; }
.routing-relation-SS { background:#e9f6f1; color:#226652; }
.routing-relation-FF { background:#f2ecf8; color:#634183; }
.routing-relation-SF { background:#fff2e4; color:#8d571e; }

@media (pointer:coarse) {
  .routing-port { r:11; stroke-width:5; }
}

@media (max-width: 860px) {
  .routing-tables { grid-template-columns:1fr; }
}

@media (max-width: 640px) {
  .routing-editor-toolbar .spacer { display:none; }
  .routing-editor-toolbar { align-items:stretch; }
  .routing-editor-toolbar .btn { min-height:40px; }
  .routing-canvas-viewport { min-height:220px; max-height:330px; order:3; }
  .routing-tables { order:2; }
  .routing-edge-editor { order:1; }
  .routing-step-table,.routing-dependency-table { overflow-x:auto; max-width:100%; }
  .routing-tables table { min-width:720px; }
}

/* ---------- miniMES execution / quality / genealogy ---------- */
.version-banner { display:flex; align-items:center; gap:12px; padding:13px 16px; margin-bottom:12px; border:1px solid #bdd8d1; border-radius:10px; background:#edf8f3; color:#225f50; }
.version-banner span { font-size: 0.86rem; color:#4c7167; }
.execution-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(320px,1fr)); gap:12px; }
.execution-card { margin:0; border-left:4px solid #94a3b8; }
.execution-card.state-active,.execution-card.state-in_progress { border-left-color:#277765; }
.execution-card.state-paused { border-left-color:#c08325; }
.execution-card.state-quality_hold { border-left-color:#c84640; background:#fff8f7; }
.execution-card-head { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.execution-unit { margin:14px 0; padding:12px; border-radius:8px; background:#f5f7fa; font-family:ui-monospace,SFMono-Regular,Menlo,monospace; }
.execution-actions { display:flex; gap:8px; flex-wrap:wrap; }
.action-44 { min-height:44px; padding:10px 18px; }
.consume-list { display:grid; gap:7px; }
.consume-row { display:grid; grid-template-columns:minmax(140px,1fr) auto 100px; align-items:center; gap:10px; padding:7px 0; border-bottom:1px solid var(--border); }
.notice-danger { background:#fff1f0; border-color:#edbbb7; color:#9f302c; }
.quality-hold-row td { background:#fff5f4; }
.trace-result { margin-top:12px; }
.genealogy-flow { display:grid; grid-template-columns:repeat(4,minmax(150px,1fr)); gap:10px; }
.genealogy-flow section { position:relative; padding:14px; min-height:84px; border:1px solid var(--border); border-radius:9px; background:#f8fafc; }
.genealogy-flow section:not(:last-child)::after { content:"→"; position:absolute; right:-15px; top:34px; z-index:2; color:#71839a; font-weight:700; }
.genealogy-flow p { margin:8px 0 0; font-size: 0.86rem; }
.trace-link { display:block; border:0; background:transparent; padding:6px 0; color:#245ca6; text-align:left; cursor:pointer; }
.genealogy-list { display:grid; gap:8px; }

@media (max-width: 860px) {
  .execution-grid,.genealogy-flow { grid-template-columns:1fr; }
  .genealogy-flow section::after { display:none; }
  .consume-row { grid-template-columns:1fr; }
}

/* 侧边栏菜单布局编辑器 */
.menu-editor { display:flex; flex-direction:column; gap:10px; }
.menu-editor-group { border:1px solid var(--border); border-radius:8px; overflow:hidden; background:#fff; }
.menu-editor-group.drop-before { border-top:2px solid var(--primary); }
.menu-editor-group.drop-after { border-bottom:2px solid var(--primary); }
.menu-editor-group-head { display:flex; align-items:center; gap:6px; padding:6px 8px; background:var(--bg); border-bottom:1px solid var(--border); }
.menu-editor-body { display:flex; flex-direction:column; gap:4px; padding:6px; }
.menu-editor-item { display:flex; align-items:center; gap:6px; padding:3px; border-radius:6px; }
.menu-editor-item.drop-before { box-shadow: inset 0 2px 0 var(--primary); }
.menu-editor-item.drop-after { box-shadow: inset 0 -2px 0 var(--primary); }
.drag-handle { cursor:grab; color:var(--muted); user-select:none; font-size:1.05rem; line-height:1; padding:2px 5px; }
.drag-handle:active { cursor:grabbing; }
/* 作业指导书正文：纯文本与内嵌图片排版 */
.instruction-content { line-height:1.7; color:var(--text); }
.instruction-content .instruction-img { max-width:100%; max-height:420px; margin:8px 0; border-radius:6px; }

/* ---------- 手机端（PDA/手机，≤480px） ---------- */
/* 顶栏紧凑：隐藏姓名/时钟，只留头像 + 铃铛 */
@media (max-width: 480px) {
  .topbar { padding: 0 10px; gap: 8px; }
  #page-title { font-size: 1rem; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-right { gap: 4px; }
  .user-info { display: none; }
  .clock { display: none; }
  .content { padding: 10px; }
  /* 工具栏输入控件整宽（压过内联 width:200px，仅窄屏生效） */
  .toolbar .input, .toolbar .select { width: 100% !important; flex: 1 1 100%; min-width: 0; }
  .toolbar { gap: 8px; }
}

/* 触控目标：触屏设备或窄屏一律 ≥44px（与 .action-44 同口径） */
@media (pointer: coarse), (max-width: 480px) {
  .btn, .icon-btn, .user-menu-item, .seg-btn { min-height: 44px; }
}

/* 窄屏表格→卡片降级（mobile-tables.js 注入 label） */
@media (max-width: 480px) {
  .table-cards thead { display: none; }
  .table-cards tbody tr {
    display: block; margin: 10px 0; padding: 6px 12px;
    border: 1px solid var(--border); border-radius: 10px; background: var(--card);
  }
  .table-cards tbody tr td { display: block; border: 0; padding: 5px 0; }
  .table-cards .cell-label { display: block; font-size: 0.76rem; color: var(--muted); margin-bottom: 2px; }
  /* 横滚兜底表：sticky 首列 + 滚动渐变提示 */
  .table-scroll-xs { position: relative; }
  .table-scroll-xs::after {
    content: "↔"; position: sticky; right: 4px; float: right; margin-top: -26px;
    color: var(--muted); font-size: 0.85rem; background: rgba(255,255,255,.85); padding: 2px 6px; border-radius: 999px;
    pointer-events: none;
  }
  .table-scroll-xs th:first-child, .table-scroll-xs td:first-child { position: sticky; left: 0; background: var(--card); z-index: 1; }
}

/* 手机工作台 #/mobile */
.mobile-wb-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 8px; }
.mobile-wb-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.mobile-wb-card {
  display: flex; align-items: center; gap: 10px; padding: 14px 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  min-height: 68px; text-decoration: none; color: var(--text);
}
.mobile-wb-card:active { background: var(--bg); }
.mobile-wb-icon { font-size: 1.6rem; }
.mobile-wb-title { font-weight: 700; font-size: 0.95rem; }
.mobile-wb-sub { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.mobile-wb-arrow { margin-left: auto; color: var(--muted); font-size: 1.3rem; }
@media (max-width: 480px) {
  .mobile-wb-grid { grid-template-columns: 1fr 1fr; }
  .mobile-wb-card { min-height: 56px; padding: 12px 10px; }
}

/* ---------- 通用扫码相机遮罩（扫码领料/工位确认等复用） ---------- */
.cam-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(2,6,23,.92);
  display: flex; align-items: center; justify-content: center;
}
.cam-box {
  position: relative; width: min(420px, 92vw); text-align: center;
  border-radius: 16px; overflow: hidden; background: #000;
}
.cam-title { display: block; text-align: center; color: #fff; font-size: 15px; padding: 12px; background: rgba(2,6,23,.85); }
.cam-video { width: 100%; height: auto; display: block; }
.cam-frame {
  position: absolute; inset: 12%; border: 3px solid rgba(37,99,235,.85);
  border-radius: 12px; box-shadow: 0 0 0 9999px rgba(2,6,23,.35);
}
.cam-hint { padding: 10px 12px; font-size: 13px; color: #cbd5e1; background: rgba(2,6,23,.7); }
.cam-box .btn { position: absolute; right: 12px; bottom: 44px; background: rgba(255,255,255,.15); color: #fff; }
.cam-close-btn { position: absolute; right: 12px; top: 12px; background: rgba(255,255,255,.15); color: #fff; }
