:root{
  --bg:#f5f7fa; --panel:#fff; --ink:#1f2733; --muted:#7b8794; --line:#e6ebf1;
  --primary:#2563eb; --primary-d:#1d4ed8; --primary-l:#eff5ff;
  --green:#16a34a; --red:#dc2626; --amber:#f59e0b;
  --shadow:0 1px 3px rgba(16,24,40,.06),0 8px 24px rgba(16,24,40,.04);
  --radius:12px;
}
*{box-sizing:border-box;margin:0;padding:0}
body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;
  background:var(--bg);color:var(--ink);font-size:14px;line-height:1.5;-webkit-font-smoothing:antialiased}
button,input,select,textarea{font-family:inherit;font-size:inherit}

/* ---------- 登录 ---------- */
.login-wrap{min-height:100vh;display:flex;align-items:center;justify-content:center;
  background:linear-gradient(135deg,#eef3ff 0%,#f7f9fc 50%,#eef7f4 100%)}
.login-card{width:380px;max-width:90vw;background:#fff;border:1px solid var(--line);border-radius:20px;
  padding:44px 38px;box-shadow:var(--shadow);text-align:center}
.login-logo{width:60px;height:60px;border-radius:16px;background:linear-gradient(135deg,#2563eb,#1d4ed8);
  color:#fff;font-size:28px;font-weight:700;display:flex;align-items:center;justify-content:center;
  margin:0 auto 18px;box-shadow:0 8px 20px rgba(37,99,235,.28)}
.login-card h1{font-size:22px;font-weight:700;letter-spacing:.5px}
.login-sub{color:var(--muted);margin:6px 0 28px;font-size:13px}
.login-card input{width:100%;height:46px;border:1px solid var(--line);border-radius:10px;padding:0 14px;outline:none;transition:.2s}
.login-card input:focus{border-color:var(--primary);box-shadow:0 0 0 3px var(--primary-l)}
.err-msg{color:var(--red);font-size:13px;min-height:20px;text-align:left;margin-top:8px}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;border:0;border-radius:9px;
  padding:9px 16px;cursor:pointer;font-weight:600;transition:.15s;white-space:nowrap}
.btn-primary{background:var(--primary);color:#fff}
.btn-primary:hover{background:var(--primary-d)}
.btn-ghost{background:#fff;color:var(--ink);border:1px solid var(--line)}
.btn-ghost:hover{background:#f8fafc;border-color:#cfd8e3}
.btn-danger{background:#fff;color:var(--red);border:1px solid #fecaca}
.btn-danger:hover{background:#fef2f2}
.btn-sm{padding:5px 11px;font-size:13px;border-radius:7px}
.btn:disabled{opacity:.5;cursor:not-allowed}
.btn-block{width:100%;height:46px;margin-top:8px;font-size:15px}

/* ---------- 布局 ---------- */
.app{display:flex;min-height:100vh}
.sidebar{width:224px;background:#fff;border-right:1px solid var(--line);display:flex;flex-direction:column;
  position:fixed;inset:0 auto 0 0;z-index:20}
.brand{height:68px;display:flex;align-items:center;gap:10px;padding:0 22px;border-bottom:1px solid var(--line)}
.brand-mark{width:32px;height:32px;border-radius:9px;background:linear-gradient(135deg,#2563eb,#1d4ed8);
  color:#fff;font-weight:700;display:flex;align-items:center;justify-content:center;font-size:17px}
.brand-text{font-weight:700;font-size:16px;letter-spacing:.3px}
.nav{padding:14px 12px;flex:1}
.nav-item{display:flex;align-items:center;gap:12px;padding:11px 14px;border-radius:9px;color:#5b6572;
  text-decoration:none;font-weight:600;margin-bottom:4px;transition:.15s;cursor:pointer}
.nav-item:hover{background:#f7f9fc;color:var(--ink)}
.nav-item.active{background:var(--primary-l);color:var(--primary)}
.nav-item .ico{width:20px;text-align:center;font-size:16px}
.sidebar-foot{padding:14px;border-top:1px solid var(--line)}
.btn-logout{width:100%;padding:10px;border:0;border-radius:9px;background:#f7f9fc;color:#5b6572;
  font-weight:600;cursor:pointer;transition:.15s}
.btn-logout:hover{background:#eef2f7;color:var(--ink)}
.main{flex:1;margin-left:224px;min-width:0;display:flex;flex-direction:column}
.topbar{height:68px;background:#fff;border-bottom:1px solid var(--line);display:flex;align-items:center;
  justify-content:space-between;padding:0 32px;position:sticky;top:0;z-index:10}
.topbar-title{font-size:18px;font-weight:700}
.topbar-right{color:var(--muted);font-size:13px;display:flex;align-items:center;gap:8px}
.topbar-right .dot{width:7px;height:7px;border-radius:50%;background:var(--green)}
.content{padding:28px 32px 60px;max-width:1400px;width:100%}

/* ---------- 卡片/表格 ---------- */
.card{background:#fff;border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);
  padding:22px;margin-bottom:20px}
.card-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:18px;gap:12px;flex-wrap:wrap}
.card-title{font-size:16px;font-weight:700}
.card-sub{color:var(--muted);font-size:13px;margin-top:2px}
.toolbar{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
input.f,select.f,textarea.f{border:1px solid var(--line);border-radius:8px;padding:8px 11px;outline:none;
  background:#fff;transition:.15s;height:38px}
textarea.f{height:auto;resize:vertical}
input.f:focus,select.f:focus,textarea.f:focus{border-color:var(--primary);box-shadow:0 0 0 3px var(--primary-l)}
label.fl{display:flex;flex-direction:column;gap:6px;font-size:13px;color:#5b6572;font-weight:600}
label.fl .req{color:var(--red)}

table{width:100%;border-collapse:collapse;font-size:13.5px}
th,td{text-align:left;padding:11px 12px;border-bottom:1px solid var(--line);vertical-align:middle}
th{color:var(--muted);font-weight:600;font-size:12.5px;background:#fafbfc;white-space:nowrap}
tr:hover td{background:#fcfdff}
td.num,th.num{text-align:right;font-variant-numeric:tabular-nums}
.tag{display:inline-block;padding:2px 9px;border-radius:20px;font-size:12px;font-weight:600;background:var(--primary-l);color:var(--primary)}
.tag-green{background:#e9f9ef;color:var(--green)}
.tag-amber{background:#fff5e6;color:#b45309}
.empty{text-align:center;color:var(--muted);padding:44px 12px;font-size:14px}
.row-actions{display:flex;gap:6px;white-space:nowrap}
.link-btn{border:0;background:none;color:var(--primary);cursor:pointer;font-weight:600;padding:3px 5px}
.link-btn:hover{text-decoration:underline}
.link-btn.danger{color:var(--red)}
.amount-strong{font-weight:700;color:var(--ink)}

/* ---------- 开单 ---------- */
.form-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:16px;margin-bottom:20px}
.form-grid .span2{grid-column:span 2}
/* 客户/物料可搜索组合框 */
.combo{position:relative}
.combo .f{width:100%}
.combo-list{display:none;position:absolute;top:100%;left:0;right:0;z-index:60;background:#fff;
  border:1px solid var(--line);border-radius:8px;box-shadow:0 8px 24px rgba(0,0,0,.14);
  max-height:300px;overflow-y:auto;margin-top:2px}
.combo-item{padding:9px 12px;cursor:pointer;border-bottom:1px solid #f0f2f5;line-height:1.4}
.combo-item:last-child{border-bottom:none}
.combo-item:hover{background:#f0f6ff}
.combo-item b{display:block;font-size:13.5px}
.combo-item span{display:block;font-size:12px;color:var(--muted)}
.combo-none{color:var(--muted);cursor:default;font-size:13px}
.search-bar{display:flex;align-items:center;gap:12px;margin-bottom:14px}
.search-bar .f{max-width:520px}
.search-count{color:var(--muted);font-size:13px;white-space:nowrap}
.cust-info{display:flex;flex-wrap:wrap;gap:8px 20px;background:#f0f6ff;border:1px solid #d6e6ff;border-radius:8px;padding:9px 12px;margin:-8px 0 16px;font-size:12.5px;color:#245}
.cust-info b{color:#16324f}
.cust-view{padding:4px 0}
.cv-row{display:flex;gap:12px;padding:11px 4px;border-bottom:1px solid var(--line);font-size:14px;line-height:1.5}
.cv-row:last-child{border-bottom:none}
.cv-label{flex:0 0 78px;color:var(--muted)}
.cv-val{flex:1;color:var(--text);word-break:break-all;font-weight:500}
.cv-empty{color:#b6bec9;font-weight:400}
.section-label{font-weight:700;font-size:14px;margin:4px 0 12px;display:flex;align-items:center;gap:8px}
.section-label::before{content:"";width:3px;height:14px;background:var(--primary);border-radius:2px}
.items-table input,.items-table select{width:100%;border:1px solid var(--line);border-radius:7px;padding:7px 9px;outline:none;height:36px}
.items-table input:focus,.items-table select:focus{border-color:var(--primary);box-shadow:0 0 0 2px var(--primary-l)}
.items-table td{padding:7px 6px}
.items-table .row-no{color:var(--muted);width:30px;text-align:center}
.items-total{text-align:right;padding:14px 6px;font-size:15px}
.items-total b{font-size:22px;color:var(--primary);margin-left:6px}
.inline-add{display:inline-flex;gap:8px;align-items:center;margin-top:6px}
.print-tip{margin-top:14px;padding:9px 14px;background:var(--primary-l);border:1px solid #dbeafe;
  border-radius:8px;color:#1e40af;font-size:12px}

/* 明细行历史出货提示条 */
.items-table tr.hist-tr td{padding:0 6px 4px;border-bottom:1px solid var(--line)}
.hist-bar{display:flex;flex-wrap:wrap;align-items:center;gap:10px;background:var(--primary-l);
  border-radius:7px;padding:5px 10px;font-size:12px;color:#334155}
.hist-who{background:#0f766e;color:#fff;border-radius:5px;padding:1px 8px;font-weight:600;font-size:11px}
.hist-tag{background:var(--primary);color:#fff;border-radius:5px;padding:1px 7px;font-weight:600;font-size:11px}
.hist-bar b{color:var(--primary-d)}
.hist-empty{color:var(--muted)}
.hist-auto{color:#0f766e;font-weight:600}
.hist-apply,.hist-detail{border:1px solid var(--primary);background:#fff;color:var(--primary);
  border-radius:6px;padding:2px 8px;font-size:11px;cursor:pointer;font-weight:600}
.hist-apply:hover,.hist-detail:hover{background:var(--primary);color:#fff}
.hist-table{width:100%;border-collapse:collapse;font-size:12px}
.hist-table th,.hist-table td{border:1px solid var(--line);padding:6px 8px;text-align:center;white-space:nowrap}
.hist-table th{background:#f7f9fc;font-weight:600}
.hist-table td{text-align:left}
.hist-table td:first-child,.hist-table td:nth-child(6),.hist-table td:nth-child(7),.hist-table td:nth-child(8){text-align:center}

/* ---------- 弹窗 ---------- */
.modal-mask{position:fixed;inset:0;background:rgba(15,23,42,.42);display:flex;align-items:center;
  justify-content:center;z-index:50;padding:20px;backdrop-filter:blur(2px)}
.modal{background:#fff;border-radius:14px;width:520px;max-width:100%;max-height:90vh;overflow:auto;
  box-shadow:0 24px 60px rgba(0,0,0,.18)}
.modal.wide{width:760px}
.modal-head{padding:18px 22px;border-bottom:1px solid var(--line);font-weight:700;font-size:16px;
  display:flex;justify-content:space-between;align-items:center}
.modal-close{border:0;background:none;font-size:22px;color:var(--muted);cursor:pointer;line-height:1}
.modal-body{padding:22px}
.modal-foot{padding:16px 22px;border-top:1px solid var(--line);display:flex;justify-content:flex-end;gap:10px}
.modal-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.modal-grid .span2{grid-column:span 2}

/* ---------- toast ---------- */
.toast-root{position:fixed;top:20px;right:20px;z-index:100;display:flex;flex-direction:column;gap:10px}
.toast{background:#fff;border:1px solid var(--line);border-left:4px solid var(--green);border-radius:9px;
  padding:12px 18px;box-shadow:var(--shadow);font-weight:600;min-width:200px;animation:in .2s ease}
.toast.err{border-left-color:var(--red)}
@keyframes in{from{opacity:0;transform:translateX(20px)}to{opacity:1;transform:translateX(0)}}

.stat-row{display:grid;grid-template-columns:repeat(4,1fr);gap:16px;margin-bottom:20px}
.stat{background:#fff;border:1px solid var(--line);border-radius:var(--radius);padding:18px 20px;box-shadow:var(--shadow)}
.stat .k{color:var(--muted);font-size:13px}
.stat .v{font-size:26px;font-weight:700;margin-top:6px;font-variant-numeric:tabular-nums}

@media(max-width:900px){
  .sidebar{width:64px}.brand-text,.nav-item span:not(.ico),.sidebar-foot{display:none}
  .brand{justify-content:center;padding:0}.nav-item{justify-content:center;padding:12px}
  .main{margin-left:64px}.content{padding:20px 16px}.topbar{padding:0 16px}
  .form-grid{grid-template-columns:1fr 1fr}.stat-row{grid-template-columns:1fr 1fr}
}

/* ---------- 打印：仅单据内容页 241×139.7mm（复写纸上半格） ---------- */
.print-only{display:none}

/* 屏幕预览：只显示内容页，不显示下半格空白 */
.print-wrap{display:flex;justify-content:center;padding:18px;background:#eef1f4}
.print-page{width:205mm;min-height:139.7mm;background:#fff;box-shadow:0 2px 14px rgba(0,0,0,.14);
  display:flex;flex-direction:column;box-sizing:border-box;overflow:visible}
.print-half{width:205mm;min-height:139.7mm;box-sizing:border-box;background:#fff;color:#000;
  padding:3mm 5mm 2mm;font-family:"Microsoft YaHei",SimHei,sans-serif;
  display:flex;flex-direction:column;overflow:visible}

.ph-top{display:flex;justify-content:space-between;align-items:flex-end;
  border-bottom:1.5px solid #000;padding-bottom:1.5mm;margin-bottom:1mm}
.ph-company{font-size:13px;font-weight:700;letter-spacing:.2px;line-height:1.2;max-width:72%}
.ph-no{font-size:10px;white-space:nowrap}
.ph-title-row{display:flex;justify-content:space-between;align-items:baseline;margin:1.5mm 0}
.ph-title{font-size:18px;font-weight:700;letter-spacing:7px;margin-left:auto;margin-right:auto}
.ph-copy{font-size:9px;color:#555;white-space:nowrap;position:absolute;right:6mm}
.ph-meta{display:flex;justify-content:space-between;gap:6px;font-size:10px;margin-bottom:1.2mm;line-height:1.3}
.ph-meta div:first-child{flex:1;word-break:break-all}
.ph-meta div:last-child{white-space:nowrap}
/* 客户信息区：左侧三行间距统一、右侧销售日期与经手人两行间距拉开 */
.ph-info{display:flex;justify-content:space-between;gap:6px;font-size:10px;margin-bottom:1.5mm;line-height:1.7}
.ph-info-left{flex:1;word-break:break-all}
.ph-info-left div,.ph-right-stack div{line-height:1.7}
.ph-right-stack{display:flex;flex-direction:column;align-items:flex-start;white-space:nowrap}
.ph-right-stack div{white-space:nowrap}
.ph-right-stack div + div{margin-top:1.2mm}
.ph-cust{margin-bottom:.8mm;color:#222}
.ph-cust div:first-child,.ph-cust div:last-child{flex:1;white-space:normal}
.ph-table{width:100%;border-collapse:collapse;font-size:9px;table-layout:fixed}
.ph-table th,.ph-table td{border:1px solid #333;padding:.7mm .6mm;text-align:center;
  word-break:break-all;overflow:hidden;line-height:1.1}
.ph-table th{background:#f0f0f0;font-weight:700}
.ph-table td{height:3.2mm}
.ph-table tr.ph-sum td{font-weight:700;background:#f7f7f7;border-top:1.5px solid #000}
.ph-bottom{margin-top:auto}
/* 屏幕预览：底部紧跟表格，避免把内容推到容器底部产生大块空白（打印不受影响） */
@media screen{ .ph-bottom{margin-top:3mm} }
.ph-total{text-align:right;font-size:11px;font-weight:700;margin-top:1.5mm;padding-right:14mm}
.ph-pay{margin-top:1mm;font-size:9px;font-weight:600}
.ph-pay div{flex:1;white-space:normal}
.ph-foot{display:flex;justify-content:space-between;font-size:10px;margin-top:2.5mm;
  border-top:1px solid #ccc;padding-top:1.5mm}
/* 底部固定格式 */
.ph-footnote{margin-top:1mm;font-size:9px;line-height:1.5;color:#000}
.fn-line{white-space:normal;word-break:break-all}
.fn-sign{margin-top:.5mm;white-space:nowrap;text-align:right}
.fn-remark{margin-top:0.5mm;line-height:1.4;word-break:break-all;min-height:3.5mm}
.fn-blank{display:none}
.fn-copies{margin-top:.3mm;white-space:nowrap;display:flex;justify-content:space-between}

/* 针式连续复写纸纵向竖着走：高度必须大于宽度(241mm)，否则浏览器判为横向会转90度。走纸只走一联由打印机驱动的页长/撕纸位置设置，CSS 不控制 */
@page{size:241mm 279.4mm;margin:0}
@media print{
  html,body{margin:0!important;padding:0!important;background:#fff!important}
  .no-print{display:none!important}
  .print-only{display:block!important}
  .print-wrap{display:block!important;padding:0!important;margin:0!important}
  .print-page{width:205mm!important;min-height:0!important;height:auto!important;box-shadow:none!important;
    margin:0!important;padding:0!important;page-break-after:avoid;break-after:avoid;overflow:visible!important}
  .print-half{width:205mm!important;min-height:139.7mm!important;height:auto!important;box-shadow:none!important;
    margin:0!important;padding:3mm 5mm 2mm!important;
    page-break-inside:avoid;break-inside:avoid;border:none!important;overflow:visible!important}
  .ph-table th,.ph-table tr.ph-sum td{-webkit-print-color-adjust:exact;print-color-adjust:exact}
}
