/* ============================================================
   仓库库存与发货管理系统 —— 简洁、清晰、适合非专业人员
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root{
  --primary:#2563eb; --primary-dark:#1d4ed8;
  --bg:#f5f6f8; --card:#fff; --line:#e4e7ec;
  --text:#1f2937; --muted:#6b7280;
  --warn:#f59e0b; --danger:#dc2626; --ok:#16a34a; --info:#0891b2;
}
body{ font-family:"Microsoft YaHei","PingFang SC",system-ui,sans-serif; background:var(--bg); color:var(--text); font-size:15px; }

/* ---- 布局 ---- */
.layout{ display:flex; min-height:100vh; }
.sidebar{ width:210px; background:#0f172a; color:#cbd5e1; flex-shrink:0; display:flex; flex-direction:column; position:sticky; top:0; height:100vh; }
.sidebar .brand{ padding:18px 16px; font-size:18px; font-weight:700; color:#fff; border-bottom:1px solid #1e293b; }
.sidebar nav{ flex:1; padding:10px 8px; overflow-y:auto; }
.sidebar nav a{ display:flex; align-items:center; gap:10px; padding:11px 14px; border-radius:8px; color:#cbd5e1; text-decoration:none; margin-bottom:2px; font-size:14.5px; }
.sidebar nav a:hover{ background:#1e293b; color:#fff; }
.sidebar nav a.active{ background:var(--primary); color:#fff; }
.sidebar .ic{ width:22px; text-align:center; }
.side-foot{ padding:12px 16px; border-top:1px solid #1e293b; font-size:12.5px; color:#94a3b8; }

.main{ flex:1; display:flex; flex-direction:column; min-width:0; }
.topbar{ background:var(--card); border-bottom:1px solid var(--line); padding:12px 24px; display:flex; align-items:center; justify-content:space-between; }
.top-actions{ display:flex; gap:8px; }
.content{ padding:24px; }

/* ---- 卡片 / 页面标题 ---- */
.card{ background:var(--card); border:1px solid var(--line); border-radius:12px; padding:20px 22px; margin-bottom:20px; }
.card h3{ font-size:17px; margin-bottom:14px; }
.page-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:18px; flex-wrap:wrap; gap:12px; }
.page-head h1{ font-size:22px; }
.page-head .sub{ color:var(--muted); font-size:13.5px; }

/* ---- 按钮 ---- */
.btn{ display:inline-flex; align-items:center; gap:6px; padding:9px 16px; border-radius:8px; border:1px solid var(--line); background:var(--card); color:var(--text); cursor:pointer; font-size:14.5px; text-decoration:none; transition:.15s; }
.btn:hover{ border-color:var(--primary); color:var(--primary); }
.btn-primary{ background:var(--primary); border-color:var(--primary); color:#fff; }
.btn-primary:hover{ background:var(--primary-dark); color:#fff; }
.btn-danger{ background:#fff; border-color:#fca5a5; color:var(--danger); }
.btn-ghost{ background:transparent; border-color:transparent; color:var(--muted); }
.btn-ghost:hover{ color:var(--primary); border-color:transparent; }
.btn-sm{ padding:5px 10px; font-size:13px; border-radius:6px; }

/* ---- 表单 ---- */
label{ display:block; font-size:13.5px; color:var(--muted); margin-bottom:5px; font-weight:600; }
input[type=text],input[type=date],input[type=number],input[type=password],select,textarea{
  width:100%; padding:9px 11px; border:1px solid var(--line); border-radius:8px; font-size:14.5px; background:#fff; color:var(--text); }
input:focus,select:focus,textarea:focus{ outline:none; border-color:var(--primary); box-shadow:0 0 0 3px rgba(37,99,235,.12); }
.form-grid{ display:grid; grid-template-columns:repeat(auto-fit,minmax(170px,1fr)); gap:14px; }
.form-row{ margin-bottom:14px; }
.hint{ font-size:12.5px; color:var(--muted); margin-top:4px; }

/* ---- 表格 ---- */
table{ width:100%; border-collapse:collapse; background:var(--card); }
th{ text-align:left; padding:11px 12px; font-size:13px; color:var(--muted); border-bottom:2px solid var(--line); white-space:nowrap; background:#fafbfc; }
td{ padding:10px 12px; border-bottom:1px solid var(--line); font-size:14px; }
tr:hover td{ background:#f8fafc; }
.t-wrap{ overflow-x:auto; border:1px solid var(--line); border-radius:12px; }
.num{ font-variant-numeric:tabular-nums; }

/* ---- 徽标 / 状态 ---- */
.badge{ display:inline-block; padding:3px 10px; border-radius:999px; font-size:12px; font-weight:600; }
.badge-ok{ background:#dcfce7; color:var(--ok); }
.badge-warn{ background:#fef3c7; color:#b45309; }
.badge-danger{ background:#fee2e2; color:var(--danger); }
.badge-info{ background:#cffafe; color:#0e7490; }
.badge-gray{ background:#f1f5f9; color:var(--muted); }

/* ---- 统计卡 ---- */
.stats{ display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:16px; margin-bottom:22px; }
.stat{ background:var(--card); border:1px solid var(--line); border-radius:12px; padding:16px 18px; }
.stat .n{ font-size:26px; font-weight:700; }
.stat .l{ color:var(--muted); font-size:13px; margin-top:2px; }
.stat .n.ok{ color:var(--ok);} .stat .n.warn{ color:var(--warn);} .stat .n.danger{ color:var(--danger);} .stat .n.primary{ color:var(--primary);}

/* ---- 库位可视化（按产品分行配货） ---- */
.dispatch-filter{ margin-bottom:16px; padding:14px 18px; }
.filter-grid{ grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); align-items:end; gap:12px 14px; }
.filter-actions{ display:flex; gap:8px; align-items:flex-end; padding-bottom:1px; }

.dispatch-floor .floor-head{ display:flex; align-items:flex-end; justify-content:space-between; gap:12px; flex-wrap:wrap; margin-bottom:14px; }
.dispatch-floor .floor-head h3{ margin:0; }
.floor-legend{ display:flex; flex-wrap:wrap; gap:12px; align-items:center; font-size:12.5px; color:var(--muted); }
.floor-legend .muted{ color:#94a3b8; }
.lg-dot{ display:inline-block; width:8px; height:8px; border-radius:50%; background:#64748b; margin-right:5px; vertical-align:middle; }
.lg-dot.near{ background:var(--warn); }
.lg-dot.over{ background:var(--danger); }
.floor-hint{ margin-top:14px; }

.product-row{ margin-bottom:22px; }
.product-row:last-child{ margin-bottom:4px; }
.product-row-head{
  display:flex; align-items:baseline; justify-content:space-between; gap:10px;
  margin-bottom:10px; padding-bottom:8px; border-bottom:2px solid #e2e8f0;
}
.product-row-title{ margin:0; font-size:16px; font-weight:800; color:#0f172a; display:flex; flex-wrap:wrap; align-items:baseline; gap:8px; }
.product-row-content{ font-size:14px; font-weight:600; color:var(--muted); }
.product-row-stats{ display:inline-flex; flex-wrap:wrap; align-items:center; gap:6px; margin-left:4px; }
.pack-stat{
  display:inline-flex; align-items:center; gap:2px;
  background:#f1f5f9; border:1px solid #e2e8f0; border-radius:999px;
  padding:2px 8px; font-size:12.5px; font-weight:600; color:#334155;
  font-variant-numeric:tabular-nums;
}
.pack-stat b{ font-weight:800; color:#0f172a; }
.pack-stat[hidden]{ display:none !important; }
.pack-total{
  font-size:13px; font-weight:700; color:#1e40af;
  font-variant-numeric:tabular-nums; margin-left:2px;
}
.pack-total b{ font-size:15px; }
.product-row-meta{ font-size:12.5px; color:var(--muted); white-space:nowrap; }

.loc-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(200px,1fr)); gap:12px; }
.loc-grid-row{ grid-template-columns:repeat(auto-fill,minmax(190px,1fr)); }
.loc-card{
  background:linear-gradient(180deg,#fff 0%,#f8fafc 100%);
  border:1px solid var(--line); border-radius:12px; padding:12px;
  min-height:96px; display:flex; flex-direction:column; gap:6px;
  box-shadow:0 1px 2px rgba(15,23,42,.04);
}
.loc-card .code{ display:flex; justify-content:space-between; align-items:center; margin-bottom:2px; }
.loc-code{ font-weight:800; font-size:30px; letter-spacing:.02em; color:#0f172a; line-height:1.1; }
.loc-pieces{ font-weight:700; font-size:12.5px; color:var(--primary); margin-left:8px; letter-spacing:0; vertical-align:middle; }
.loc-pieces b{ font-variant-numeric:tabular-nums; }
.loc-count{ font-size:11px; font-weight:600; color:var(--primary); background:#eff6ff; border:1px solid #bfdbfe; border-radius:999px; padding:2px 8px; }

.chip{
  display:flex; align-items:flex-start; gap:8px;
  background:#fff; border-radius:10px; padding:8px 9px;
  font-size:12.5px; cursor:grab; border:1px solid #e2e8f0;
  transition:border-color .15s, background .15s, box-shadow .15s;
}
.chip:hover{ border-color:#93c5fd; box-shadow:0 2px 8px rgba(37,99,235,.08); }
.chip.dragging{ opacity:.55; }
.chip.selected{ background:#eff6ff; border-color:var(--primary); box-shadow:0 0 0 2px rgba(37,99,235,.15); }
.chip.is-near{ border-left:3px solid var(--warn); }
.chip.is-over{ border-left:3px solid var(--danger); background:#fff7f7; }
.chip[hidden]{ display:none !important; }
.chip input[type=checkbox]{ width:15px; height:15px; margin-top:2px; accent-color:var(--primary); cursor:pointer; flex-shrink:0; }
.chip-body{ flex:1; min-width:0; }
.chip-top{ display:flex; justify-content:space-between; align-items:baseline; gap:8px; }
.chip-pack{ font-weight:800; font-size:14px; color:#0f172a; letter-spacing:.01em; }
.chip-qty{ font-weight:800; font-variant-numeric:tabular-nums; color:var(--primary); flex-shrink:0; }
.chip-dates{
  display:flex; flex-wrap:wrap; gap:6px 10px; margin-top:5px;
  font-size:12px; font-variant-numeric:tabular-nums; font-weight:600; color:#334155;
}
.chip-dates em{ font-style:normal; font-weight:700; color:#94a3b8; margin-right:3px; font-size:11px; }
.chip-prod{ color:#1e40af; }
.chip-exp.is-near{ color:#b45309; }
.chip-exp.is-over{ color:var(--danger); }
.loc-card.dragover,.loc-card.drag-over{
  border-color:var(--primary); background:#eff6ff;
  box-shadow:0 0 0 2px rgba(37,99,235,.2);
}
.loc-card[hidden],.product-row[hidden]{ display:none !important; }

/* ---- 移库弹窗 ---- */
.modal-mask{
  position:fixed; inset:0; z-index:1000;
  background:rgba(15,23,42,.45);
  display:flex; align-items:center; justify-content:center;
  padding:20px;
}
.modal-mask[hidden]{ display:none !important; }
.modal-box{
  width:min(420px,100%); background:#fff; border-radius:14px;
  box-shadow:0 20px 50px rgba(15,23,42,.25); overflow:hidden;
}
.modal-box-wide{ width:min(920px,100%); max-height:min(90vh,860px); display:flex; flex-direction:column; }
.modal-box-wide .modal-body{ overflow:auto; flex:1; }
.ob-prev-table{ width:100%; font-size:13px; }
.ob-prev-table th,.ob-prev-table td{ padding:8px 10px; }
.ob-prev-foot{
  margin-top:16px; text-align:right; font-size:14px;
  display:flex; justify-content:flex-end; align-items:flex-end; gap:24px; flex-wrap:wrap;
}
.ob-sign{
  display:inline-block; min-width:140px; border-top:1px solid #000;
  text-align:center; padding-top:4px; font-size:13px; color:#64748b;
}
.modal-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 16px; border-bottom:1px solid var(--line);
}
.modal-head h3{ margin:0; font-size:17px; }
.modal-close{
  border:none; background:transparent; color:#94a3b8; font-size:18px;
  width:32px; height:32px; border-radius:8px; cursor:pointer;
}
.modal-close:hover{ background:#f1f5f9; color:var(--text); }
.modal-body{ padding:16px; }
.modal-foot{
  display:flex; justify-content:flex-end; gap:8px;
  padding:12px 16px 16px; border-top:1px solid var(--line);
}
.mv-info{ margin-bottom:14px; font-size:14.5px; line-height:1.5; }
.mv-info .mv-sub{ margin-top:4px; color:var(--muted); font-size:13px; }
#mvFrom{ background:#f8fafc; color:var(--muted); }

/* ---- 调度面板 ---- */
.dispatch-wrap{ display:flex; gap:18px; align-items:flex-start; }
.dispatch-main{ flex:1; min-width:0; }
.dispatch-panel{
  width:400px; background:var(--card); border:1px solid var(--line); border-radius:14px;
  position:sticky; top:20px; padding:16px 16px 18px;
  box-shadow:0 8px 24px rgba(15,23,42,.06);
}
.dispatch-panel.drag-over{ border-color:var(--primary); background:#f8fbff; }
.panel-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; }
.panel-head h3{ margin:0; font-size:16px; }
.panel-count{
  min-width:24px; height:24px; padding:0 8px; border-radius:999px;
  background:#0f172a; color:#fff; font-size:12px; font-weight:700;
  display:inline-flex; align-items:center; justify-content:center;
}
.panel-actions{ display:flex; gap:8px; margin-top:10px; }
.dl-list{ max-height:min(58vh,520px); overflow:auto; }
.dl-empty{ color:#94a3b8; font-size:13px; line-height:1.6; padding:18px 8px; text-align:center; }
.dl-row{
  display:flex; gap:8px; align-items:flex-start;
  border:1px solid var(--line); border-radius:10px; padding:10px;
  margin-bottom:8px; background:#fafbfc; font-size:13px;
}
.dl-main{ flex:1; min-width:0; }
.dl-title{ display:flex; flex-wrap:wrap; align-items:center; gap:6px; }
.dl-sub{ color:var(--muted); font-size:12px; margin-top:3px; }
.dl-dates{
  display:flex; gap:12px; margin-top:6px;
  font-size:12.5px; font-weight:700; font-variant-numeric:tabular-nums; color:#1e40af;
}
.dl-dates em{ font-style:normal; font-weight:700; color:#94a3b8; margin-right:3px; font-size:11px; }
.dl-qty{ display:flex; flex-wrap:wrap; gap:6px 8px; align-items:center; margin-top:8px; }
.dl-qty label{ margin:0; font-size:11.5px; font-weight:600; }
.dl-qty input[type=number]{ width:64px; padding:6px 8px; }
.dl-left{ font-size:11.5px; color:var(--muted); }
.dl-row .del{
  color:#94a3b8; cursor:pointer; background:none; border:none; font-size:15px;
  width:28px; height:28px; border-radius:6px; flex-shrink:0;
}
.dl-row .del:hover{ color:var(--danger); background:#fee2e2; }
.tag{ display:inline-block; padding:1px 7px; border-radius:999px; font-size:11px; font-weight:700; }
.tag.near{ background:#fef3c7; color:#b45309; }
.tag.over{ background:#fee2e2; color:var(--danger); }

/* ---- 提示条 ---- */
.alert{ padding:12px 16px; border-radius:10px; margin-bottom:18px; font-size:14px; }
.alert-ok{ background:#dcfce7; color:#166534; border:1px solid #bbf7d0; }
.alert-warn{ background:#fef3c7; color:#92400e; border:1px solid #fde68a; }
.alert-danger{ background:#fee2e2; color:#991b1b; border:1px solid #fecaca; }
.alert-info{ background:#e0f2fe; color:#075985; border:1px solid #bae6fd; }
.error-box{ padding:12px; border-radius:10px; background:#fee2e2; color:#991b1b; margin-bottom:16px; }

/* ---- 打印 ---- */
@media print{
  .sidebar,.topbar,.no-print,.dispatch-panel{ display:none !important; }
  .layout{ display:block; }
  .content{ padding:0; }
  body{ background:#fff; }
  .card{ border:none; }
  .print-title{ font-size:24px; text-align:center; margin-bottom:16px; }
  body.printing-outbound .dispatch-wrap,
  body.printing-outbound .dispatch-filter,
  body.printing-outbound .page-head,
  body.printing-outbound .alert{ display:none !important; }
  body.printing-outbound #outboundPreviewModal{
    display:block !important; position:static; inset:auto;
    background:none; padding:0; z-index:auto;
  }
  body.printing-outbound #outboundPreviewModal .modal-box{
    width:100%; max-height:none; box-shadow:none; border-radius:0;
  }
  body.printing-outbound #outboundPreviewModal .modal-body{ overflow:visible; padding:0; }
}
.print-meta{ display:flex; gap:40px; margin-bottom:16px; }
.print-meta div{ font-size:14px; }

@media (max-width:980px){
  .dispatch-wrap{ flex-direction:column; }
  .dispatch-panel{ width:100%; position:static; }
}

/* ---- 产品管理 ---- */
.cards-2col{ display:grid; grid-template-columns:1.4fr 1fr; gap:20px; align-items:start; }
.prod-block{ border:1px solid var(--line); border-radius:10px; padding:12px 14px; margin-bottom:12px; }
.prod-thumb{ width:40px; height:40px; object-fit:cover; border-radius:8px; border:1px solid var(--line); background:#f8fafc; flex-shrink:0; }
.prod-thumb.lg{ width:72px; height:72px; }
.btn-group{ display:flex; }
.spec-sec{ margin:8px 0 4px; }
.spec-label{ font-size:12px; color:var(--muted); font-weight:600; margin-bottom:5px; }
.spec-chip{ display:inline-flex; align-items:center; gap:4px; background:#eef2ff; color:var(--primary); border:1px solid #c7d2fe; border-radius:8px; padding:4px 8px; margin:2px 4px 2px 0; font-size:12.5px; }
.spec-chip a{ color:inherit; text-decoration:none; }
.spec-chip .spec-x{ color:#94a3b8; font-size:12px; }
.spec-chip .spec-x:hover{ color:var(--danger); }
.spec-chip.spec-off{ background:#f1f5f9; color:#94a3b8; border-color:#e2e8f0; }
.bind-focus td{ background:#f0f9ff; }
.badge-warn{ background:#fef3c7; color:#92400e; }
.prod-editor-head{ display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:16px; flex-wrap:wrap; }
.prod-sec-title{ margin:18px 0 10px; font-size:15px; }
.prod-sec-bar{ display:flex; justify-content:space-between; align-items:center; gap:10px; margin:18px 0 6px; flex-wrap:wrap; }
.prod-editor table input[type=text],
.prod-editor table input[type=number],
.prod-editor table input:not([type]){ width:100%; }
@media (max-width:820px){ .cards-2col{ grid-template-columns:1fr; } }

