:root {
  --bg: #f2f4f8;
  --panel: #ffffff;
  --border: #e3e7ef;
  --text: #1f2633;
  --muted: #6b7488;
  --primary: #1a5ff0;
  --primary-dark: #1448b8;
  --green: #16a34a;
  --red: #dc2626;
  --orange: #d97706;
  --teal: #0d9488;
  --purple: #7c3aed;
  --gray: #64748b;
  --blue: #2563eb;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", 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: 216px; flex: none; background: #10172a; color: #cbd5e1;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 20px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-name { font-size: 17px; font-weight: 700; color: #fff; }
.brand-sub { font-size: 12px; color: #64748b; margin-top: 2px; }
.sidebar nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.sidebar nav a {
  display: block; padding: 9px 20px; color: #cbd5e1; font-size: 14px;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidebar nav a.active { background: rgba(26,95,240,.18); color: #fff; border-left-color: #3b82f6; }
.sidebar-foot { padding: 12px 20px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-foot a { color: #94a3b8; font-size: 13px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 52px; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-weight: 600; font-size: 15px; }
.topbar-user { color: var(--muted); font-size: 13px; }
.content { padding: 24px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ---------- 卡片/统计 ---------- */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-2 { grid-template-columns: 1fr; } }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; }
.card h3 { font-size: 15px; margin-bottom: 12px; }
.stat-card .stat-label { color: var(--muted); font-size: 13px; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat-card .stat-value small { font-size: 14px; color: var(--muted); font-weight: 400; }
.stat-card .stat-note { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.tbl th { background: #f8fafc; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tbl tr:hover td { background: #f8fafd; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .actions { white-space: nowrap; text-align: right; }
.tbl .actions a, .tbl .actions button { margin-left: 6px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- 徽章/状态 ---------- */
.st { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.st-gray { background: #eef1f6; color: #475569; }
.st-blue { background: #e0ecff; color: #1d4ed8; }
.st-green { background: #dcfce7; color: #15803d; }
.st-red { background: #fee2e2; color: #b91c1c; }
.st-orange { background: #ffedd5; color: #b45309; }
.st-teal { background: #ccfbf1; color: #0f766e; }
.st-purple { background: #ede9fe; color: #6d28d9; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 18px; }
.form-grid .full { grid-column: span 3; }
.form-grid .half { grid-column: span 1.5; }
@media (max-width: 1100px) { .form-grid { grid-template-columns: repeat(2, 1fr); } .form-grid .full { grid-column: span 2; } }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field label .req { color: var(--red); }
.field input[type=text], .field input[type=number], .field input[type=password], .field input[type=date],
.field input[type=month], .field input[type=email], .field select, .field textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; background: #fff; color: var(--text); font-family: inherit;
}
.field textarea { min-height: 64px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid rgba(26,95,240,.25); border-color: var(--primary);
}
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-block; cursor: pointer; border: 1px solid transparent; border-radius: 8px;
  padding: 8px 16px; font-size: 14px; font-weight: 500; line-height: 1.4; text-align: center;
  background: var(--primary); color: #fff; font-family: inherit;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 6px; }
.btn-outline { background: #fff; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: #f1f5f9; color: var(--text); }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #b91c1c; }
.btn-green { background: var(--green); }
.btn-green:hover { background: #15803d; }
.btn-ghost { background: transparent; color: var(--primary); padding: 4px 8px; }
.btn-ghost:hover { background: #eef4ff; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- 顶部工具条 ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.toolbar input[type=text], .toolbar select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13.5px; background: #fff;
  min-width: 180px;
}

/* ---------- Flash ---------- */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; transition: opacity .4s; }
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ---------- 试用/到期横幅 ---------- */
.trial-banner {
  background: #fffbeb; border-bottom: 1px solid #fde68a; color: #92400e;
  padding: 9px 24px; font-size: 13.5px;
}
.trial-banner.trial-urgent { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }

/* ---------- 登录页 ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg,#10172a,#1e2b52); }
.login-card { background: #fff; border-radius: 14px; padding: 40px 36px; width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-card input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.login-card .btn { width: 100%; padding: 10px; }

/* ---------- 详情视图 ---------- */
.kv { display: grid; grid-template-columns: 130px 1fr; row-gap: 8px; }
.kv dt { color: var(--muted); }
.kv dd { font-weight: 500; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.section-title { font-size: 15px; font-weight: 600; margin: 22px 0 10px; display: flex; align-items: center; gap: 10px; }
.section-title .line { flex: 1; height: 1px; background: var(--border); }

/* ---------- 明细动态表（订单编辑） ---------- */
.dyn-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dyn-table th { background: #f8fafc; padding: 6px 6px; border: 1px solid var(--border); color: var(--muted); font-weight: 600; text-align: left; }
.dyn-table td { padding: 4px; border: 1px solid var(--border); vertical-align: middle; }
.dyn-table input, .dyn-table select { width: 100%; padding: 6px 7px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }

/* ---------- 条形图 ---------- */
.bars { display: flex; align-items: flex-end; gap: 14px; height: 150px; padding: 8px 4px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; max-width: 56px; background: linear-gradient(180deg,#3b82f6,#1a5ff0); border-radius: 6px 6px 0 0; min-height: 2px; }
.bar-val { font-size: 11px; color: var(--muted); }
.bar-label { font-size: 12px; color: var(--muted); }

/* ---------- 打印（单据/质检/工资条） ---------- */
/* 全部打印页统一 A4 竖版。屏幕预览展示真实纸张比例（210mm×297mm），
   内容区与打印版心一致，做到「所见即所得」，防止打印时右边内容被裁。 */
@page { size: A4 portrait; }
@media screen {
  .print-page { width: 210mm; max-width: 100%; margin: 0 auto 24px; }
}
.doc-paper {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  width: 210mm; min-height: 297mm; box-sizing: border-box;
  padding: 14mm 14mm;
  font-family: "Times New Roman", "SimSun", serif;
}
@media screen and (max-width: 800px) {
  .doc-paper { padding: 18px 16px; }
}
@media print {
  body.print { background: #fff; }
  /* 打印宽度写死为 184mm（≤ 各种浏览器默认边距下的最窄版心），
     不再依赖 @page margin，任何边距设置下都不会裁掉右侧内容 */
  .print-page { width: 184mm; max-width: none; margin: 0 auto; box-shadow: none; }
  .doc-paper { width: 184mm; min-height: 0; border: none; border-radius: 0; padding: 0; background: #fff; }
  .slip { width: 184mm; max-width: none; }
  .no-print { display: none !important; }
  body * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* 184mm 版心内排版更紧凑，避免溢出 */
  .doc-table { font-size: 12px; }
  .doc-table th, .doc-table td { padding: 5px 6px; word-break: break-word; }
  .doc-meta, .doc-words, .doc-clause, .doc-sign { font-size: 12.5px; }
  /* 分页保护：表格行、表头、签章区、备注不跨页断开 */
  .doc-table tr, .doc-table thead, .doc-meta, .doc-sign, .doc-note, .doc-head, .doc-title { page-break-inside: avoid; }
  .doc-table thead { display: table-header-group; }
}
.doc-head { text-align: center; margin-bottom: 26px; }
.doc-head .co-name { font-size: 20px; font-weight: 700; letter-spacing: 1px; }
.doc-head .co-en { font-size: 15px; margin-top: 2px; }
.doc-head .co-addr { font-size: 11px; color: #444; margin-top: 4px; }
.doc-title { text-align: center; font-size: 17px; font-weight: 700; text-decoration: underline; margin: 18px 0 20px; letter-spacing: 2px; }
.doc-meta { display: flex; justify-content: space-between; gap: 20px; font-size: 12.5px; margin-bottom: 14px; }
.doc-meta dl { flex: 1; }
.doc-meta dt { color: #555; display: inline; }
.doc-meta dd { display: inline; font-weight: 600; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 10px 0; }
.doc-table th, .doc-table td { border: 1px solid #333; padding: 6px 8px; }
.doc-table th { background: #f2f2f2; }
.doc-table .r { text-align: right; }
.doc-total-line { text-align: right; font-weight: 700; margin-top: 6px; font-size: 13px; }
.doc-words { font-size: 12.5px; margin-top: 8px; }
.doc-sign { display: flex; justify-content: space-between; margin-top: 44px; font-size: 13px; }
.doc-note { font-size: 11px; color: #555; margin-top: 22px; border-top: 1px dashed #999; padding-top: 8px; }

/* 单据收款二维码 */
.doc-qr { width: 24mm; height: 24mm; object-fit: contain; border: 1px solid #999; padding: 1mm; background: #fff; flex: none; }
.qr-caption { font-size: 10.5px; color: #555; text-align: center; line-height: 1.5; flex: none; }
.doc-qr-inline { width: 18mm; height: 18mm; vertical-align: middle; margin-left: 6px; object-fit: contain; }
@media print {
  .doc-qr, .doc-qr-inline { border: 1px solid #000; }
}

/* 单据银行信息块：左侧账户信息（另起行、空两格）、右侧收款二维码 */
.doc-bank-box { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 10px 0; }
.doc-bank-info { flex: 1; min-width: 0; text-align: left; }
.doc-bank-label { font-size: 12.5px; }
.doc-bank-lines { margin-top: 2px; }
.doc-bank-lines .bl { padding-left: 2em; font-weight: 600; font-size: 12.5px; margin: 3px 0; }
.doc-bank-qr { flex: none; display: flex; flex-direction: column; align-items: center; gap: 3px; }

/* 单据竖排信息行（一行一条、左对齐） */
.doc-lines { margin: 10px 0; }
.doc-lines dl { display: block; margin: 5px 0; text-align: left; }
.doc-lines dt { color: #555; display: inline; }
.doc-lines dd { display: inline; font-weight: 600; }

/* 合同买卖方：标签定宽；公司名/地址整体右移，名称换行与第一行对齐 */
.doc-meta dl.party { flex: 1.2; position: relative; padding-left: 6.5em; }
.doc-meta dl.party dt { position: absolute; left: 0; top: 0; width: 6em; }
.doc-meta dl.party dd { display: block; }
.doc-meta dl.party .kv2 { padding-left: 0; margin-top: 3px; text-align: left; }

/* 清关版单据标记 */
.clearance-tag { display: inline-block; border: 1.5px solid #333; padding: 2px 14px; font-size: 12.5px; font-weight: 700; letter-spacing: 1.5px; }

/* 单据货描中的产品自定义字段 */
.desc-field { font-size: 11.5px; color: #555; margin-top: 2px; }

/* 订单明细行：选中产品后展示的产品完整字段 */
.item-fields { font-size: 11px; color: var(--muted); line-height: 1.55; margin-top: 3px; min-width: 150px; }

/* 托盘装箱明细卡片 */
.pc-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: #fbfcfe; }
.pc-card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.pc-card-head input.pc-no { width: 70px; }
.pc-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 4px 0; }
.pc-row select.pc-item { min-width: 240px; }
.pc-row input.pc-ctns { width: 90px; }
.pc-meta { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.pc-meta input { width: 66px; }
.pc-meta select { width: 92px; }
.pc-hidden { display: none; }

.doc-clause { font-size: 12.5px; margin-top: 16px; line-height: 1.9; }
.doc-clause h4 { font-size: 13px; margin-bottom: 6px; }
.doc-clause ol { padding-left: 20px; }

/* 工资条 */
.slip { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 34px 40px; max-width: 640px; margin: 0 auto; }
.slip h2 { text-align: center; margin-bottom: 4px; }
.slip .period { text-align: center; color: var(--muted); margin-bottom: 20px; }

/* misc */
.text-muted { color: var(--muted); }
.text-success { color: var(--green); }
.text-danger { color: var(--red); }
.mt16 { margin-top: 16px; }
.mt8 { margin-top: 8px; }
.mb16 { margin-bottom: 16px; }
.flex { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.chk-line { display: flex; align-items: center; gap: 8px; }
.pill-tab { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.pill-tab a {
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); font-size: 13px;
}
.pill-tab a.active, .pill-tab a:hover { background: var(--primary); color: #fff; border-color: var(--primary); text-decoration: none; }
/* ===== 整体放大（用户反馈字体偏小）=====
   .layout 是登录后主界面的容器（打印页/登录页不包含，不受影响）。
   zoom 按比例放大全部界面元素，保持原有字号层级与布局比例。 */
@media screen {
  .layout { zoom: 1.1; }
}
