:root{
  --bg:#f5f7fb;
  --card:#ffffff;
  --text:#0f172a;
  --muted:#64748b;
  --border:#e2e8f0;
  --primary:#2563eb;
  --primary-600:#1d4ed8;
  --danger:#dc2626;
  --success:#16a34a;
  --warning:#f59e0b;
  --shadow:0 1px 2px rgba(15,23,42,0.06);
  --radius:14px;
  --radius-sm:10px;
  --mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans:ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:var(--sans);
  color:var(--text);
  background:var(--bg);
}

a{color:inherit}

.container{
  max-width:1520px;
  margin:0 auto;
  padding:18px 18px 28px;
}

.header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  padding:6px 2px 0;
}

.title{
  font-size:28px;
  font-weight:800;
  letter-spacing:.2px;
}

.subline{
  margin-top:6px;
  font-size:13px;
  color:var(--muted);
}

.header-right{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.health{
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border:1px solid var(--border);
  border-radius:999px;
  background:var(--card);
  box-shadow:var(--shadow);
  font-size:13px;
  color:var(--muted);
}

.dot{
  width:10px;
  height:10px;
  border-radius:999px;
  background:#cbd5e1;
}
.dot.ok{background:var(--success)}
.dot.bad{background:var(--danger)}

.btn{
  border:1px solid var(--border);
  background:var(--card);
  padding:8px 12px;
  border-radius:10px;
  font-size:13px;
  cursor:pointer;
  box-shadow:var(--shadow);
  transition:120ms ease;
}
.btn:hover{transform:translateY(-1px)}
.btn:active{transform:translateY(0)}
.btn.primary{
  background:var(--primary);
  border-color:var(--primary);
  color:#fff;
}
.btn.primary:hover{background:var(--primary-600)}
.btn:disabled{
  opacity:.55;
  cursor:not-allowed;
  transform:none !important;
}

.tabs{
  margin-top:12px;
  display:flex;
  gap:18px;
  border-bottom:1px solid var(--border);
  overflow:auto;
}

.tab{
  position:relative;
  padding:12px 0;
  font-size:14px;
  color:var(--muted);
  cursor:pointer;
  user-select:none;
  white-space:nowrap;
}

.tab.active{
  color:var(--text);
  font-weight:700;
}

.tab.active::after{
  content:"";
  position:absolute;
  left:0;
  right:0;
  bottom:-1px;
  height:2px;
  background:var(--primary);
  border-radius:2px;
}

.card{
  margin-top:14px;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
}

.card-header{
  padding:14px 14px 10px;
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
}

.card-title{
  font-size:16px;
  font-weight:800;
}

.card-sub{
  margin-top:4px;
  font-size:12px;
  color:var(--muted);
}

.card-body{padding:12px 14px 14px}

.filters{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:end;
}

.field{
  display:flex;
  flex-direction:column;
  gap:6px;
}

.field-grow{
  min-width:260px;
  flex:1;
}

label{
  font-size:12px;
  color:var(--muted);
}

input[type="text"],
input[type="number"],
input[type="datetime-local"],
select{
  padding:8px 10px;
  border:1px solid var(--border);
  border-radius:10px;
  background:#fff;
  font-size:13px;
  outline:none;
}

input:focus,select:focus{
  border-color:rgba(37,99,235,.35);
  box-shadow:0 0 0 3px rgba(37,99,235,.12);
}

.small{
  font-size:12px;
  color:var(--muted);
}

.mono{font-family:var(--mono)}

.legend-row{
  margin-top:12px;
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  align-items:center;
}

.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background:#fff;
  color:var(--muted);
  white-space:nowrap;
}

.badge-ok{border-color:#bbf7d0;color:#166534;background:#f0fdf4}
.badge-fbp{border-color:#fecaca;color:#991b1b;background:#fff1f2}
.badge-print{border-color:#bfdbfe;color:#1e40af;background:#eff6ff}

.table-wrap{
  margin-top:12px;
  border:1px solid var(--border);
  border-radius:12px;
  overflow:auto;
}

.table-wrap.fixed{height:600px}

.table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  font-size:13px;
  min-width:1680px;
}

.table thead th{
  position:sticky;
  top:0;
  z-index:2;
  text-align:left;
  padding:10px 10px;
  background:#f1f5f9;
  border-bottom:1px solid var(--border);
  color:var(--muted);
  font-weight:700;
  white-space:nowrap;
}

.table tbody td{
  padding:10px 10px;
  border-bottom:1px solid var(--border);
  vertical-align:top;
}

.table tbody tr:hover{background:#f8fafc}

.order-no{
  font-size:14px;
  font-weight:700;
}

.status{
  display:inline-flex;
  align-items:center;
  padding:3px 8px;
  border-radius:999px;
  font-size:12px;
  border:1px solid var(--border);
  background:#fff;
  color:var(--muted);
  white-space:nowrap;
}
.status.awaiting_deliver{border-color:#bbf7d0;color:#166534;background:#f0fdf4}
.status.awaiting_packaging{border-color:#fde68a;color:#92400e;background:#fffbeb}
.status.delivering{border-color:#bfdbfe;color:#1e40af;background:#eff6ff}
.status.delivered{border-color:#bbf7d0;color:#166534;background:#f0fdf4}
.status.cancelled{border-color:#fecaca;color:#991b1b;background:#fff1f2}

.store-cell{display:flex;align-items:center;min-height:34px}
.store-badge{
  display:inline-flex;
  align-items:center;
  padding:4px 10px;
  border-radius:999px;
  background:#eff6ff;
  color:#1d4ed8;
  font-size:12px;
  font-weight:600;
  border:1px solid rgba(37,99,235,.2);
}

.preview-stack{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  align-items:center;
  min-height:40px;
}
.preview-stack.empty{
  width:52px;
  height:40px;
  border:1px dashed var(--border);
  border-radius:10px;
  background:#f8fafc;
  justify-content:center;
  color:var(--muted);
  font-size:12px;
}
.preview-thumb{
  width:44px;
  height:44px;
  padding:0;
  border-radius:10px;
  background:#f8fafc;
  border:1px solid var(--border);
  overflow:hidden;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  appearance:none;
}
.preview-thumb img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
  pointer-events:none;
}
.preview-thumb.img-error img{display:none}
.preview-thumb.img-error::after{
  content:"无图";
  font-size:12px;
  color:var(--muted);
}

.item-cell{
  display:flex;
  flex-direction:column;
  gap:6px;
  min-width:220px;
}
.item-title{
  font-weight:600;
  line-height:1.4;
}
.item-lines{
  display:flex;
  flex-direction:column;
  gap:4px;
}
.item-line{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
}
.qty-badge{
  display:inline-flex;
  align-items:center;
  padding:2px 8px;
  border-radius:999px;
  font-size:12px;
  background:#f8fafc;
  border:1px solid var(--border);
  color:var(--muted);
}

.print-badge{
  display:inline-flex;
  align-items:center;
  padding:4px 10px;
  border-radius:999px;
  background:#f8fafc;
  border:1px solid var(--border);
  font-size:12px;
  font-weight:600;
}

.row-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.pill-btn{
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background:#fff;
  font-size:12px;
  cursor:pointer;
}
.pill-btn.primary{
  border-color:rgba(37,99,235,.35);
  color:var(--primary);
}
.pill-btn:disabled{
  opacity:.55;
  cursor:not-allowed;
}

.footer-actions{
  margin-top:12px;
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
  justify-content:space-between;
}

.action-row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.preview{
  margin-top:10px;
  border:1px solid var(--border);
  border-radius:14px;
  overflow:hidden;
}
.preview iframe{
  width:100%;
  height:560px;
  border:0;
  background:#fff;
}
.preview-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px 12px;
  background:#f8fafc;
  border-bottom:1px solid var(--border);
}
.preview-title{
  font-weight:600;
  font-size:13px;
}
.preview-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.preview.collapsed .preview-body{display:none}

.toast{
  position:fixed;
  left:50%;
  bottom:24px;
  transform:translateX(-50%);
  background:rgba(15,23,42,.92);
  color:#fff;
  padding:10px 14px;
  border-radius:12px;
  box-shadow:0 12px 32px rgba(0,0,0,.18);
  font-size:13px;
  max-width:92vw;
  z-index:999;
}
.toast.success{background:rgba(22,163,74,.92)}
.toast.error{background:rgba(220,38,38,.92)}

.hidden{display:none !important}

.store-select{
  padding:8px 10px;
  border:1px solid var(--border);
  border-radius:999px;
  background:var(--card);
  box-shadow:var(--shadow);
  font-size:13px;
  color:var(--text);
  outline:none;
}

.auth-wrap{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
}

.auth-card{
  width:420px;
  max-width:92vw;
}

@media (max-width: 1180px){
  .header{flex-direction:column}
  .header-right{justify-content:flex-start}
}

@media (max-height: 860px){
  .table-wrap.fixed{height:460px}
  .preview iframe{height:420px}
}


.action-cell{white-space:nowrap}
.action-stack{display:flex;align-items:center;gap:8px}
.action-stack .pill-btn{min-width:64px}

.img-viewer{
  position:fixed;
  inset:0;
  background:rgba(15,23,42,.72);
  display:none;
  align-items:center;
  justify-content:center;
  padding:24px;
  z-index:1200;
}
.img-viewer.open{display:flex}
.img-viewer-inner{
  position:relative;
  max-width:min(92vw, 980px);
  max-height:90vh;
  width:auto;
  background:#fff;
  border-radius:16px;
  padding:16px 16px 12px;
  box-shadow:0 24px 64px rgba(0,0,0,.25);
  display:flex;
  flex-direction:column;
  gap:10px;
}
.img-viewer-title{
  font-size:13px;
  font-weight:600;
  color:var(--text);
  padding-right:28px;
}
.img-viewer img{
  display:block;
  max-width:min(88vw, 940px);
  max-height:78vh;
  object-fit:contain;
  border-radius:12px;
  background:#f8fafc;
}
.img-viewer-close{
  position:absolute;
  top:10px;
  right:10px;
  width:30px;
  height:30px;
  border:1px solid var(--border);
  border-radius:999px;
  background:#fff;
  cursor:pointer;
  font-size:20px;
  line-height:1;
}
