/* ============================================================
   电缆工厂订单管理系统 — 全局样式
   浅色主题 · 响应式（桌面侧边栏 / 移动端抽屉）
   ============================================================ */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --sidebar-w: 224px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 布局骨架 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--border);
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  transition: transform .25s ease;
}
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.content { padding: 20px; flex: 1; }
.content-narrow { max-width: 980px; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 15px;
}
.brand .logo {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex: none;
}
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }

.nav { padding: 10px 10px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  color: #334155;
  margin-bottom: 2px;
  font-weight: 500;
}
.nav a:hover { background: #f1f5f9; text-decoration: none; }
.nav a.active { background: var(--primary-light); color: var(--primary-dark); }
.nav .nav-ico { width: 20px; text-align: center; flex: none; }

.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}
.role-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--primary-light);
  color: var(--primary-dark);
  margin-left: 6px;
}

.topbar h1 { font-size: 16px; font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hamburger { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 16px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.user-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}

.scrim {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .4);
  z-index: 50;
}
body.nav-open .scrim { display: block; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-h {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.card-h h2 { font-size: 15px; font-weight: 600; flex: 1; min-width: 0; }
.card-b { padding: 18px; }
.card-b.flush { padding: 0; }

/* ---------- 统计卡 ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.stat .ico {
  width: 44px; height: 44px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex: none;
}
.stat .lbl { color: var(--muted); font-size: 12px; }
.stat .val { font-size: 21px; font-weight: 700; line-height: 1.25; word-break: break-all; }
.stat .val small { font-size: 12px; font-weight: 400; color: var(--muted); }

/* ---------- 表格 ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; min-width: 640px; }
table.tbl th, table.tbl td {
  text-align: left;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.tbl th { font-size: 12px; color: var(--muted); font-weight: 600; background: #f8fafc; }
table.tbl td { font-size: 13px; }
table.tbl tbody tr:hover { background: #f8fafc; }
table.tbl td.wrap { white-space: normal; min-width: 160px; }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl th.num { text-align: right; }
.empty {
  padding: 42px 16px;
  text-align: center;
  color: var(--muted);
}

/* ---------- 徽标 ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.st-pending   { background: #fef3c7; color: #92400e; }
.st-confirmed { background: #dbeafe; color: #1e40af; }
.st-producing { background: #e0e7ff; color: #3730a3; }
.st-completed { background: #ccfbf1; color: #115e59; }
.st-shipped   { background: #dcfce7; color: #166534; }
.st-cancelled { background: #f1f5f9; color: #64748b; }
.st-danger    { background: var(--danger-light); color: #991b1b; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 15px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: background .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.outline { background: #fff; color: var(--text); border-color: var(--border); }
.btn.outline:hover { background: #f1f5f9; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.danger-outline { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn.danger-outline:hover { background: var(--danger-light); }
.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 7px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.field label .req { color: var(--danger); margin-left: 2px; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  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(37, 99, 235, .12);
}
.field textarea { resize: vertical; min-height: 72px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { min-width: 140px; flex: 1; }
.filters .field.slim { flex: 0 0 auto; min-width: 120px; }

/* ---------- 进度条 ---------- */
.progress { background: #e2e8f0; border-radius: 999px; height: 8px; overflow: hidden; min-width: 90px; }
.progress > i { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.progress > i.done { background: var(--success); }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; gap: 8px; padding: 12px 16px; flex-wrap: wrap; }
.pager .info { color: var(--muted); font-size: 12px; flex: 1; }
.pager button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 7px;
  padding: 5px 11px;
  font-size: 13px;
  cursor: pointer;
}
.pager button:disabled { opacity: .5; cursor: not-allowed; }
.pager button:not(:disabled):hover { border-color: var(--primary); color: var(--primary); }

/* ---------- 模态框 ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .25);
}
.modal-h { padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 15px; display: flex; }
.modal-h .x { margin-left: auto; cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; background: none; border: none; }
.modal-b { padding: 20px; }
.modal-f { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- 轻提示 ---------- */
#toast-wrap { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; width: max-content; max-width: 92vw; }
.toast {
  background: #0f172a;
  color: #fff;
  border-radius: 9px;
  padding: 10px 18px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .25);
  animation: toast-in .2s ease;
  max-width: 100%;
}
.toast.success { background: #065f46; }
.toast.error { background: #991b1b; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- 加载 ---------- */
.loading-mask {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
  flex-direction: column; gap: 12px;
  color: var(--muted);
}
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 登录页 ---------- */
.auth-wrap { min-height: 100vh; display: flex; }
.auth-brand {
  flex: 1;
  background: linear-gradient(150deg, #1e3a8a 0%, #2563eb 55%, #3b82f6 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
}
.auth-brand h1 { font-size: 28px; margin: 18px 0 10px; }
.auth-brand p { opacity: .85; max-width: 420px; line-height: 1.8; }
.auth-brand .feats { margin-top: 26px; display: grid; gap: 12px; }
.auth-brand .feats div { display: flex; gap: 10px; align-items: center; opacity: .95; font-size: 14px; }
.auth-panel { width: 460px; background: var(--card); display: flex; flex-direction: column; justify-content: center; padding: 40px 44px; }
.auth-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.auth-tabs button {
  flex: 1;
  background: none;
  border: none;
  padding: 11px 4px;
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  font-weight: 500;
}
.auth-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.auth-err {
  background: var(--danger-light);
  color: #991b1b;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
}
.auth-err.show { display: block; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }

/* ---------- 图表 ---------- */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-box { position: relative; height: 260px; }

/* ---------- 键值信息 ---------- */
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 10px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { word-break: break-all; }

/* ---------- 响应式 ---------- */
@media (max-width: 992px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(15,23,42,.2); }
  .main { margin-left: 0; }
  .hamburger { display: inline-flex; align-items: center; justify-content: center; }
  .charts-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-panel { width: 100%; padding: 32px 24px; }
}
@media (max-width: 560px) {
  .content { padding: 14px; }
  .topbar { padding: 0 14px; }
  .user-chip .uname { display: none; }
  .stat .val { font-size: 18px; }
  .filters .field { min-width: calc(50% - 5px); }
}
