/* =============================================================================
   base.css — 设计令牌 / reset / 排版 / 按钮 / 表单 / 表格 / 标签 / 进度 / 工具类
   阿拉尔市沙漠雪家纺有限公司MES · 离线单页应用（无外部字体、无 CDN）
   ========================================================================== */

/* ---------- 1. 设计令牌 ---------- */
:root {
  /* 主色板：棉白 + 棉褐 */
  --c-primary: #b8860b;
  --c-primary-dark: #96690a;
  --c-primary-light: #f6efdc;
  --c-primary-soft: #fbf6e9;
  --c-accent: #8c6239;

  --c-success: #2e9e5b;
  --c-success-light: #e6f6ec;
  --c-warning: #d98324;
  --c-warning-light: #fdf2e3;
  --c-danger: #cf3a3a;
  --c-danger-light: #fbe9e9;
  --c-info: #2f74c0;
  --c-info-light: #e8f1fb;

  /* 中性色阶 */
  --c-text: #22201d;
  --c-text-2: #57524b;
  --c-text-3: #8b857c;
  --c-line: #e3ded4;
  --c-line-2: #f0ece4;
  --c-bg: #f5f3ee;
  --c-surface: #ffffff;
  --c-surface-2: #fbfaf7;

  /* 间距 */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s7: 32px;
  --s8: 40px;

  /* 字号 */
  --f-xs: 12px;
  --f-sm: 13px;
  --f-md: 14px;
  --f-lg: 16px;
  --f-xl: 20px;
  --f-2xl: 26px;
  --f-3xl: 32px;

  /* 圆角 */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-pill: 999px;

  /* 阴影 */
  --sh-1: 0 1px 2px rgba(34, 32, 29, .06);
  --sh-2: 0 2px 8px rgba(34, 32, 29, .08);
  --sh-3: 0 8px 28px rgba(34, 32, 29, .14);
  --sh-4: 0 16px 48px rgba(34, 32, 29, .2);

  /* 布局 */
  --sidebar-w: 232px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 58px;

  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Heiti SC", "Source Han Sans SC",
    "Noto Sans CJK SC", "WenQuanYi Micro Hei", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-num: "SF Mono", "Menlo", "Consolas", "Roboto Mono", "Courier New", monospace;
}

/* ---------- 2. reset ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--f-md);
  line-height: 1.6;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: var(--c-primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
table { border-collapse: collapse; width: 100%; }
code, pre, .mono { font-family: var(--font-num); font-size: .92em; }
hr { border: 0; border-top: 1px solid var(--c-line); margin: var(--s4) 0; }
[hidden] { display: none !important; }

::selection { background: var(--c-primary-light); color: var(--c-text); }

/* 细滚动条 */
* { scrollbar-width: thin; scrollbar-color: #cfc8ba transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: #cfc8ba; border-radius: var(--r-pill); }
*::-webkit-scrollbar-thumb:hover { background: #b5ac9b; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- 3. 排版 ---------- */
.h1 { font-size: var(--f-2xl); font-weight: 700; letter-spacing: .5px; }
.h2 { font-size: var(--f-xl); font-weight: 700; }
.h3 { font-size: var(--f-lg); font-weight: 600; }
.h4 { font-size: var(--f-md); font-weight: 600; }
.text-sm { font-size: var(--f-sm); }
.text-xs { font-size: var(--f-xs); }
.text-muted { color: var(--c-text-3); }
.text-2 { color: var(--c-text-2); }
.text-primary { color: var(--c-primary-dark); }
.text-danger { color: var(--c-danger); }
.text-success { color: var(--c-success); }
.text-warning { color: var(--c-warning); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

/* ---------- 4. 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid var(--c-primary);
  border-radius: var(--r-md);
  background: var(--c-primary);
  color: #fff;
  font-size: var(--f-md);
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  transition: background-color .16s, border-color .16s, color .16s, box-shadow .16s;
}
.btn:hover { background: var(--c-primary-dark); border-color: var(--c-primary-dark); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.btn[disabled], .btn.is-disabled { background: #ddd8ce; border-color: #ddd8ce; color: #8d8779; cursor: not-allowed; transform: none; }

.btn-ghost { background: transparent; color: var(--c-text-2); border-color: var(--c-line); }
.btn-ghost:hover { background: var(--c-surface-2); border-color: #d3cbbc; color: var(--c-text); }

.btn-danger { background: var(--c-danger); border-color: var(--c-danger); }
.btn-danger:hover { background: #b32f2f; border-color: #b32f2f; }

.btn-success { background: var(--c-success); border-color: var(--c-success); }
.btn-success:hover { background: #27864d; border-color: #27864d; }

.btn-sm { min-height: 26px; padding: 3px 9px; font-size: var(--f-xs); border-radius: var(--r-sm); }
.btn-lg { min-height: 44px; padding: 10px 22px; font-size: var(--f-lg); border-radius: var(--r-md); }
.btn-block { width: 100%; }

.btn-link {
  padding: 0 2px;
  border: 0;
  min-height: 0;
  background: none;
  color: var(--c-primary-dark);
  font-size: inherit;
}
.btn-link:hover { background: none; text-decoration: underline; }

.btn-group { display: inline-flex; gap: var(--s1); flex-wrap: wrap; }

/* ---------- 5. 表单 ---------- */
.input, .select, .textarea {
  display: block;
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  background: #fff;
  font-size: var(--f-md);
  line-height: 1.4;
  transition: border-color .16s, box-shadow .16s;
}
.input:hover, .select:hover, .textarea:hover { border-color: #d3cbbc; }
.input:focus, .select:focus, .textarea:focus {
  outline: 0;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(184, 134, 11, .13);
}
.input[readonly], .textarea[readonly] { background: var(--c-surface-2); color: var(--c-text-2); }
.input[disabled], .select[disabled], .textarea[disabled] { background: #f2efe9; color: var(--c-text-3); cursor: not-allowed; }
.textarea { min-height: 76px; resize: vertical; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #8b857c 50%), linear-gradient(135deg, #8b857c 50%, transparent 50%); background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 28px; }

.form-row { display: flex; flex-direction: column; gap: 5px; margin-bottom: var(--s3); }
.form-row-inline { display: flex; align-items: center; gap: var(--s2); }
.form-label { font-size: var(--f-sm); font-weight: 600; color: var(--c-text-2); }
.form-label .req { color: var(--c-danger); margin-left: 2px; }
.form-hint { font-size: var(--f-xs); color: var(--c-text-3); }
.form-error { font-size: var(--f-xs); color: var(--c-danger); min-height: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s4); }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-static { padding: 7px 0; font-size: var(--f-md); color: var(--c-text); }

.switch { position: relative; display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { width: 38px; height: 20px; border-radius: var(--r-pill); background: #d8d2c6; transition: background-color .18s; flex: none; }
.switch-track::after { content: ""; display: block; width: 16px; height: 16px; margin: 2px; border-radius: 50%; background: #fff; box-shadow: var(--sh-1); transition: transform .18s; }
.switch input:checked + .switch-track { background: var(--c-primary); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }

/* ---------- 6. 表格 ---------- */
.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--c-line); border-radius: var(--r-md); background: var(--c-surface); }
.table { font-size: var(--f-sm); }
.table th, .table td { padding: 8px 10px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--c-line-2); }
.table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--c-surface-2);
  font-weight: 600;
  color: var(--c-text-2);
  white-space: nowrap;
  border-bottom: 1px solid var(--c-line);
}
.table tbody tr:nth-child(even) { background: #fcfbf8; }
.table tbody tr:hover { background: var(--c-primary-soft); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .ta-r { text-align: right; }
.table .ta-c { text-align: center; }
.table .col-actions { white-space: nowrap; }
.table-th-sort { cursor: pointer; user-select: none; }
.table-th-sort:hover { color: var(--c-primary-dark); }
.table tfoot td { background: var(--c-surface-2); font-weight: 600; border-top: 1px solid var(--c-line); }
.row-warn { background: var(--c-warning-light) !important; }
.row-danger { background: var(--c-danger-light) !important; }

/* ---------- 7. 标签 ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  font-size: var(--f-xs);
  line-height: 18px;
  white-space: nowrap;
  background: var(--c-line-2);
  color: var(--c-text-2);
}
.tag-gray { background: #f0ece4; color: #6f685d; border-color: #e3ded4; }
.tag-blue { background: var(--c-info-light); color: #1f5c9e; border-color: #cfe0f4; }
.tag-green { background: var(--c-success-light); color: #1f7a45; border-color: #c8e9d5; }
.tag-orange { background: var(--c-warning-light); color: #a25f10; border-color: #f4ddba; }
.tag-red { background: var(--c-danger-light); color: #a82c2c; border-color: #f2cfcf; }
.tag-primary { background: var(--c-primary-light); color: var(--c-primary-dark); border-color: #ecdfb8; }
.tag-purple { background: #f1ecfa; color: #6445a8; border-color: #e0d5f5; }
.tag-cyan { background: #e6f6f6; color: #17706f; border-color: #c8e8e7; }

/* ---------- 8. 进度条 ---------- */
.progress { position: relative; height: 8px; border-radius: var(--r-pill); background: #ece7dc; overflow: hidden; min-width: 60px; }
.progress-bar { height: 100%; border-radius: var(--r-pill); background: var(--c-primary); transition: width .3s ease; }
.progress-bar.is-success { background: var(--c-success); }
.progress-bar.is-danger { background: var(--c-danger); }
.progress-sm { height: 5px; }
.progress-label { font-size: var(--f-xs); color: var(--c-text-3); margin-top: 2px; }

/* ---------- 9. KPI ---------- */
.kpi { display: flex; flex-direction: column; gap: 4px; padding: var(--s4); background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.kpi-label { font-size: var(--f-sm); color: var(--c-text-3); }
.kpi-value { font-family: var(--font-num); font-size: var(--f-2xl); font-weight: 700; line-height: 1.15; }
.kpi-unit { font-size: var(--f-sm); font-weight: 400; color: var(--c-text-3); margin-left: 4px; }
.kpi-delta { font-size: var(--f-xs); }
.kpi-delta.up { color: var(--c-success); }
.kpi-delta.down { color: var(--c-danger); }

/* ---------- 10. 工具类 ---------- */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-1 { flex: 1 1 auto; min-width: 0; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: var(--s1); }
.gap-2 { gap: var(--s2); }
.gap-3 { gap: var(--s3); }
.gap-4 { gap: var(--s4); }
.gap-5 { gap: var(--s5); }
.gap-6 { gap: var(--s6); }
.grid { display: grid; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); }
.mt-1 { margin-top: var(--s1); } .mt-2 { margin-top: var(--s2); } .mt-3 { margin-top: var(--s3); }
.mt-4 { margin-top: var(--s4); } .mt-5 { margin-top: var(--s5); } .mt-6 { margin-top: var(--s6); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--s2); } .mb-3 { margin-bottom: var(--s3); }
.mb-4 { margin-bottom: var(--s4); } .mb-5 { margin-bottom: var(--s5); }
.ml-2 { margin-left: var(--s2); } .mr-2 { margin-right: var(--s2); }
.p-0 { padding: 0; } .p-3 { padding: var(--s3); } .p-4 { padding: var(--s4); }
.w-full { width: 100%; }
.h-full { height: 100%; }
.scroll-x { overflow-x: auto; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.divider { height: 1px; background: var(--c-line); margin: var(--s3) 0; }

/* ---------- 11. 车间端大字主题 ---------- */
body[data-mode="workshop"] {
  --f-md: 16px;
  --f-sm: 14px;
  --f-lg: 18px;
  --f-xl: 22px;
  --f-2xl: 30px;
}
body[data-mode="workshop"] .btn { min-height: 56px; padding: 14px 26px; font-size: 18px; border-radius: var(--r-md); }
body[data-mode="workshop"] .btn-sm { min-height: 44px; padding: 8px 14px; font-size: 15px; }
body[data-mode="workshop"] .btn-lg { min-height: 64px; font-size: 20px; }
body[data-mode="workshop"] .input,
body[data-mode="workshop"] .select,
body[data-mode="workshop"] .textarea { min-height: 52px; padding: 12px 14px; font-size: 17px; }
body[data-mode="workshop"] .table th,
body[data-mode="workshop"] .table td { padding: 12px 12px; font-size: 15px; }
body[data-mode="workshop"] .tag { font-size: 13px; line-height: 22px; padding: 2px 10px; }
body[data-mode="workshop"] .kpi-value { font-size: 34px; }
body[data-mode="workshop"] .form-label { font-size: 15px; }

/* ---------- 12. 启动屏与错误兜底 ---------- */
.boot-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s3); }
.boot-logo {
  width: 68px; height: 68px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--c-primary); color: #fff;
  font-size: 30px; font-weight: 700;
  box-shadow: var(--sh-2);
}
.boot-text { font-size: var(--f-lg); font-weight: 600; color: var(--c-text-2); }
.boot-hint { font-size: var(--f-sm); color: var(--c-text-3); }
.boot-error { padding: var(--s6); display: flex; justify-content: center; }
.boot-error-inner {
  max-width: 680px; padding: var(--s5) var(--s6);
  background: var(--c-danger-light); border: 1px solid #f2cfcf; border-radius: var(--r-md);
  color: #7d2626; font-size: var(--f-md);
}
.boot-error-inner h3 { margin-bottom: var(--s2); font-size: var(--f-lg); }
.boot-error-inner p { margin-bottom: var(--s2); }
.boot-error-inner code { background: rgba(0, 0, 0, .06); padding: 1px 5px; border-radius: var(--r-sm); }

/* =============================================================================
   v2.0 追加：甘特图 / 移动端底部 Tab / 角标 / 沙箱徽标 / 仓库分行 / 消息面板
   ========================================================================== */

/* ---------- 甘特图（M16 排程） ---------- */
.gantt-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--c-line); border-radius: var(--r-md); background: var(--c-surface); }
.gantt { position: relative; min-width: 720px; }
.gantt-head { display: flex; border-bottom: 1px solid var(--c-line); background: var(--c-surface-2); position: sticky; top: 0; z-index: 2; }
.gantt-head-cell { flex: none; padding: 6px 8px; font-size: var(--f-xs); color: var(--c-text-2); border-right: 1px solid var(--c-line-2); white-space: nowrap; }
.gantt-row { display: flex; align-items: center; border-bottom: 1px solid var(--c-line-2); min-height: 34px; position: relative; }
.gantt-row:hover { background: var(--c-primary-soft); }
.gantt-row-label { flex: none; width: 150px; padding: 4px 8px; font-size: var(--f-xs); color: var(--c-text-2); border-right: 1px solid var(--c-line-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gantt-row-track { position: relative; flex: 1 1 auto; height: 34px; background: repeating-linear-gradient(90deg, transparent 0, transparent calc(100%/7 - 1px), var(--c-line-2) calc(100%/7 - 1px), var(--c-line-2) calc(100%/7)); }
.gantt-bar { position: absolute; top: 7px; height: 20px; border-radius: var(--r-sm); background: var(--c-info); color: #fff; font-size: 11px; line-height: 20px; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: var(--sh-1); cursor: pointer; }
.gantt-bar.is-done { background: var(--c-success); }
.gantt-bar.is-overdue { background: var(--c-danger); }
.gantt-bar.is-planned { background: var(--c-primary); }
.gantt-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--c-danger); opacity: .6; z-index: 1; }

/* ---------- 移动端底部 Tab（M25） ---------- */
.mobile-tabbar { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; background: var(--c-surface); border-top: 1px solid var(--c-line); padding-bottom: env(safe-area-inset-bottom); }
.mobile-tabbar-item { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; font-size: 11px; color: var(--c-text-3); position: relative; }
.mobile-tabbar-item .ti-ico { font-size: 20px; line-height: 1; }
.mobile-tabbar-item.active { color: var(--c-primary-dark); font-weight: 600; }

/* ---------- 角标 / 铃铛 ---------- */
.badge-dot { position: absolute; top: 6px; right: 10px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--r-pill); background: var(--c-danger); color: #fff; font-size: 10px; line-height: 16px; text-align: center; font-weight: 600; }
.bell-btn { position: relative; width: 34px; height: 34px; border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; font-size: 17px; color: var(--c-text-2); }
.bell-btn:hover { background: var(--c-surface-2); }

/* ---------- 沙箱/真实模式徽标（A5） ---------- */
.mode-flag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: var(--r-pill); font-size: var(--f-xs); font-weight: 600; border: 1px solid; }
.mode-flag.is-sandbox { background: var(--c-warning-light); color: #a25f10; border-color: #f4ddba; }
.mode-flag.is-live { background: var(--c-danger-light); color: #a82c2c; border-color: #f2cfcf; }
.mode-flag .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- 库存按仓分行（H2） ---------- */
.split-row { border-left: 3px solid var(--c-info); }
.split-row.is-second { border-left-color: var(--c-success); }
.split-total td { background: var(--c-surface-2); font-weight: 700; }

/* ---------- 消息面板（铃铛抽屉） ---------- */
.notice-panel-item { display: flex; gap: var(--s2); padding: 10px var(--s4); border-bottom: 1px solid var(--c-line-2); cursor: pointer; }
.notice-panel-item:hover { background: var(--c-primary-soft); }
.notice-panel-item.is-unread .np-title { font-weight: 700; }
.notice-panel-item.is-unread::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c-danger); margin-top: 8px; flex: none; }
.np-title { font-size: var(--f-sm); }
.np-time { font-size: var(--f-xs); color: var(--c-text-3); }

/* ---------- 批量操作栏（R13） ---------- */
.batch-bar { display: flex; align-items: center; gap: var(--s2); padding: 8px var(--s3); background: var(--c-primary-light); border: 1px solid #ecdfb8; border-radius: var(--r-md); font-size: var(--f-sm); }
.batch-bar .count { font-weight: 700; color: var(--c-primary-dark); }
