* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #e5e9f2;
  --text: #1f2937;
  --muted: #6b7280;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08);
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0; background: #ffffff; color: #334155;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  border-right: 1px solid #e5e9f2;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 18px; border-bottom: 1px solid #eef2f7; }
.brand-icon {
  width: 38px; height: 38px; border-radius: 10px; background: var(--brand);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px;
}
.brand-title { font-weight: 700; font-size: 16px; color: #0f172a; }
.brand-sub { font-size: 12px; color: #94a3b8; margin-top: 2px; }
.nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 5px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 8px; color: #475569;
  text-decoration: none; font-size: 15px; font-weight: 500; letter-spacing: .2px;
  transition: background .15s;
}
.nav-item:hover { background: #f8fafc; color: #0f172a; }
.nav-item.active { background: #eff6ff; color: var(--brand); font-weight: 600; }
.nav-group { margin-top: 12px; padding-top: 8px; border-top: 1px solid #eef2f7; }
.nav-group-title {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: none; background: none; cursor: pointer;
  padding: 10px 14px 6px; font-size: 11px; color: #94a3b8;
  font-weight: 700; letter-spacing: .8px; text-transform: uppercase; font-family: inherit;
}
.nav-group-title:hover { color: var(--brand); }
.nav-icon { width: 22px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-text { flex: 1; text-align: left; }
.nav-chevron { transition: transform .2s; font-size: 12px; color: #94a3b8; }
.nav-group.collapsed .nav-children { display: none; }
.nav-group.collapsed .nav-chevron { transform: rotate(-90deg); }
.nav-children { display: flex; flex-direction: column; gap: 3px; }
.nav-item.nav-sub { padding-left: 34px; font-size: 14px; position: relative; }
.nav-item.nav-sub::before { content: ''; position: absolute; left: 18px; top: 50%; width: 5px; height: 5px; border-radius: 50%; background: #cbd5e1; transform: translateY(-50%); }
.nav-item.nav-sub.active::before { background: var(--brand); }
.sidebar-footer { margin-top: auto; padding: 16px 18px; font-size: 11px; color: #94a3b8; border-top: 1px solid #eef2f7; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 19px; }
.view { padding: 24px 28px 60px; }

/* 通用 */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  background: #fff; color: var(--text); padding: 9px 14px; border-radius: 8px;
  font-size: 13px; cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: #c7d2fe; background: #f8faff; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .view { padding: 16px; }
}

.stat-card { padding: 18px; }
.stat-label { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; }
.stat-value.blue { color: var(--brand); }
.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }
.stat-value.amber { color: var(--amber); }

.section-title { font-size: 15px; font-weight: 600; margin: 26px 0 12px; }
.section-title:first-child { margin-top: 0; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; }
th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: 12px; }
tbody tr:hover { background: #f8fafc; }
.table-wrap { overflow-x: auto; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
  font-size: 13px; outline: none; background: #fff; min-width: 0;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); }
.field input[type="number"] { width: 100%; }

/* 模板卡片 */
.tpl-card { padding: 18px; cursor: pointer; transition: all .15s; }
.tpl-card:hover { border-color: #bfdbfe; box-shadow: 0 4px 16px rgba(37,99,235,.1); transform: translateY(-1px); }
.tpl-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.tpl-name { font-weight: 700; font-size: 18px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; background: #eff6ff; color: var(--brand); }
.tpl-meta { color: var(--muted); font-size: 12px; line-height: 1.9; }
.progress { height: 6px; background: #eef2f7; border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }

/* 货道网格 */
.slot-grid {
  display: grid; grid-template-columns: repeat(10, minmax(100px, 1fr)); gap: 12px;
  overflow-x: auto; padding-bottom: 8px;
}
.slot {
  min-height: 132px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 12px; text-align: center; cursor: pointer; padding: 8px; transition: all .12s;
  overflow: hidden;
}
.cap-row { display: flex; align-items: center; justify-content: center; gap: 3px; margin-top: 4px; }
.cap-btn {
  width: 22px; height: 22px; padding: 0; border-radius: 5px; border: 1px solid #cbd5e1;
  background: #fff; cursor: pointer; font-size: 14px; line-height: 20px; color: var(--text);
}
.cap-btn:hover { border-color: var(--brand); color: var(--brand); }
.cap-value { font-size: 13px; color: var(--muted); min-width: 18px; text-align: center; }
.shortage-row { display: flex; align-items: center; justify-content: center; gap: 3px; margin-top: 4px; }
.shortage-label { font-size: 12px; color: var(--muted); }
.shortage-value { font-size: 14px; font-weight: 700; color: var(--red); min-width: 18px; text-align: center; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper input { width: 90px; text-align: center; }
.slot:hover { border-color: var(--brand); }
.slot .slot-code { font-weight: 700; font-size: 14px; color: var(--muted); }
.slot .slot-product { font-size: 13px; line-height: 1.35; margin-top: 4px; word-break: break-all; }
.slot.bound { background: #f0f9ff; border-color: #bae6fd; }
.slot.shortage { background: #fef2f2; border-color: #fca5a5; }
.slot.shortage .slot-product { color: var(--red); }
.layer-label { font-size: 15px; color: var(--muted); margin: 22px 0 12px; font-weight: 600; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: 14px; width: 520px; max-width: 100%;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 24px 64px rgba(15,23,42,.25);
}
.modal.wide { width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--line); }
.close-x { border: none; background: none; font-size: 20px; cursor: pointer; color: var(--muted); }

/* 提示 */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #0f172a; color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red); }

/* Tabs */
.tabs { display: flex; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tab {
  padding: 10px 16px; border: none; background: none; cursor: pointer; font-size: 13px;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.pill { padding: 2px 8px; border-radius: 999px; font-size: 11px; }
.pill-green { background: #dcfce7; color: #15803d; }
.pill-amber { background: #fef3c7; color: #b45309; }
.pill-red { background: #fee2e2; color: #b91c1c; }
.pill-gray { background: #f1f5f9; color: #475569; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.muted { color: var(--muted); font-size: 12px; }
.mt-12 { margin-top: 12px; }
.mt-20 { margin-top: 20px; }

/* 打印 */
.print-area { display: none; }
@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { display: block; position: absolute; left: 0; top: 0; width: 100%; padding: 0; }
  .no-print { display: none !important; }
}
.print-sheet { font-family: "Microsoft YaHei", sans-serif; color: #000; }
.print-sheet h2 { text-align: center; margin-bottom: 6px; }
.print-sheet h3 { font-size: 13px; margin: 14px 0 6px; }
.print-sheet .print-meta { display: flex; justify-content: space-between; font-size: 12px; margin: 14px 0; }
.print-sheet table { width: 100%; border-collapse: collapse; }
.print-sheet th, .print-sheet td { border: 1px solid #000; padding: 7px 8px; font-size: 12px; }
.print-sheet th { background: #f2f2f2; }
