/* ============================================================
 * doc.css — A4 单据版式（屏幕预览 + 打印共用）
 * 单据恒为白底黑字，不随界面主题变化
 * ============================================================ */

:root {
  --doc-w: 210mm;
  --doc-h: 297mm;
  --doc-pad: 12mm;
  --doc-fs: 10.2pt;
  --doc-line: 1.35;
}

/* ---------- 纸张 ---------- */
.paper {
  width: var(--doc-w);
  min-height: var(--doc-h);
  margin: 0 auto;
  background: #fff;
  color: #000;
  font-family: "Times New Roman", "SimSun", "宋体", Georgia, serif;
  font-size: var(--doc-fs);
  line-height: var(--doc-line);
  padding: var(--doc-pad);
  box-sizing: border-box;
  position: relative;
  display: flex;
  flex-direction: column;
}
.paper-wrap .paper { box-shadow: 0 3px 16px rgba(0,0,0,.28); }

/* 表格线条 */
.doc-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  margin: 2mm 0;
  font-size: 9.6pt;
}
.doc-table th,
.doc-table td {
  border: 0.35pt solid #000;
  padding: 1.1mm 1.6mm;
  vertical-align: top;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.doc-table th {
  font-weight: bold;
  text-align: center;
  background: #fff;
  letter-spacing: .1px;
}
.doc-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.doc-table td.ctr { text-align: center; }
.doc-table td.bold { font-weight: bold; }
.doc-table td.top { vertical-align: top; }
.doc-table tfoot td { font-weight: bold; background: #fff; }
.doc-table .row-line { border-bottom: none; }
.doc-table .no-br { word-break: keep-all; }

/* 无边框网格（用于抬头信息） */
.doc-grid {
  display: grid;
  gap: 0;
  border: 0.35pt solid #000;
  border-right: none;
  border-bottom: none;
  margin-bottom: 2mm;
  font-size: 9.6pt;
}
.doc-grid > div {
  border-right: 0.35pt solid #000;
  border-bottom: 0.35pt solid #000;
  padding: 1.2mm 1.6mm;
  min-height: 7mm;
  vertical-align: top;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.doc-grid .lbl {
  font-weight: bold;
  letter-spacing: .2px;
  display: block;
}
.doc-grid .span2 { grid-column: 1 / -1; }
.doc-grid .spanr2 { grid-column: span 2; }
.doc-grid .fill { height: 100%; }

/* 单据抬头 */
.doc-title {
  text-align: center;
  font-size: 15pt;
  font-weight: bold;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin: 1mm 0 2.5mm;
  line-height: 1.2;
}
.doc-title-cn { font-size: 11.5pt; letter-spacing: 2px; margin-bottom: 1mm; }
.doc-subtitle {
  text-align: center;
  font-size: 8.6pt;
  color: #333;
  margin-bottom: 2.5mm;
  letter-spacing: .3px;
}

/* 公司抬头块 */
.doc-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6mm;
  padding-bottom: 2mm;
  margin-bottom: 2mm;
  border-bottom: 1.2pt solid #000;
}
.doc-head .logo { flex: 0 0 auto; max-height: 20mm; max-width: 45mm; }
.doc-head .logo img { max-height: 20mm; display: block; }
.doc-head .co-en { font-size: 13pt; font-weight: bold; letter-spacing: .4px; line-height: 1.25; }
.doc-head .co-cn { font-size: 9.5pt; letter-spacing: .5px; }
.doc-head .co-meta { font-size: 8.4pt; line-height: 1.5; color: #000; }
.doc-head .co-meta b { font-weight: bold; }
.doc-no-box {
  flex: 0 0 auto;
  text-align: right;
  font-size: 9.6pt;
  line-height: 1.7;
  white-space: nowrap;
}
.doc-no-box .no { font-size: 11pt; font-weight: bold; letter-spacing: .5px; }

/* 两栏（商业发票头 / 提单收发货人） */
.doc-cols { display: flex; gap: 0; border: 0.35pt solid #000; border-bottom: none; }
.doc-cols > div {
  flex: 1;
  border-right: 0.35pt solid #000;
  padding: 1.4mm 1.8mm;
}
.doc-cols > div:last-child { border-right: none; }

/* 说明行 */
.doc-note {
  font-size: 9pt;
  line-height: 1.55;
  margin: 1.5mm 0;
  text-align: justify;
}
.doc-note b { font-weight: bold; }

/* 金额大写 */
.amount-words {
  border: 0.35pt solid #000;
  padding: 1.4mm 1.8mm;
  font-size: 9.8pt;
  margin: 1.5mm 0;
  display: flex;
  gap: 3mm;
  align-items: baseline;
}
.amount-words .k { font-weight: bold; white-space: nowrap; }
.amount-words .v { flex: 1; }

/* 签名区 */
.doc-sign {
  display: flex;
  gap: 4mm;
  margin-top: auto;
  padding-top: 4mm;
  font-size: 9.4pt;
}
.doc-sign .sbox { flex: 1; }
.doc-sign .sline {
  border-bottom: 0.35pt solid #000;
  height: 14mm;
  margin-bottom: 1mm;
}
.doc-sign .slbl { font-weight: bold; letter-spacing: .2px; }

/* 盖章位 */
.seal-box {
  position: relative;
  min-height: 24mm;
}
.seal-box .stamp {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%) rotate(-14deg);
  border: 1.6pt solid #d33;
  border-radius: 50%;
  color: #d33;
  padding: 3mm 5mm;
  text-align: center;
  font-size: 7.4pt;
  font-weight: bold;
  letter-spacing: .5px;
  opacity: .82;
  width: 30mm; height: 30mm;
  display: flex; align-items: center; justify-content: center;
  line-height: 1.3;
  pointer-events: none;
}

/* 提单：留白条款行 */
.bl-term {
  font-size: 9pt;
  line-height: 1.7;
  margin-top: 1mm;
}
.bl-term .row {
  display: flex;
  gap: 2mm;
  padding: 0.6mm 0;
}
.bl-term .row .rn { flex: 0 0 6mm; font-weight: bold; }
.bl-term .row .rt { flex: 1; }

/* 产地证专用 */
.coo-mark {
  font-size: 8.2pt;
  line-height: 1.6;
  border: 0.35pt solid #000;
  padding: 1.2mm 1.6mm;
  margin-bottom: 1.5mm;
}
.coo-body {
  font-size: 8.8pt;
  line-height: 1.55;
  white-space: pre-wrap;
}

/* 原产地证标题栏 */
.coo-banner {
  display: flex;
  border: 1.2pt solid #000;
  margin-bottom: 0;
}
.coo-banner > div {
  flex: 1;
  border-right: 0.5pt solid #000;
  padding: 1.4mm 2mm;
  text-align: center;
}
.coo-banner > div:last-child { border-right: none; }
.coo-banner .t1 { font-size: 10.5pt; font-weight: bold; letter-spacing: .4px; }
.coo-banner .t2 { font-size: 7.6pt; color: #333; }

/* 页脚 */
.doc-foot {
  margin-top: auto;
  padding-top: 2mm;
  border-top: 0.35pt solid #000;
  display: flex;
  justify-content: space-between;
  font-size: 8pt;
  color: #333;
}
.doc-foot .pg { font-weight: bold; }

/* 单据工具条（屏幕上显示，打印隐藏） */
.doc-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.doc-bar .spacer { flex: 1; }
.doc-hint {
  font-size: 11.5px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 5px;
}

/* 打印时：去掉阴影、留出页边距 */
@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  html, body {
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
    width: auto; height: auto;
  }
  .print-root { display: block !important; }
  .print-root .paper {
    box-shadow: none !important;
    margin: 0 !important;
    width: var(--doc-w);
    min-height: var(--doc-h);
    page-break-after: always;
  }
  .print-root .paper:last-child { page-break-after: auto; }
  /* 防止表格跨页断裂 */
  .doc-table { page-break-inside: auto; }
  .doc-table tr { page-break-inside: avoid; }
  .doc-table thead { display: table-header-group; }
  .doc-head { page-break-inside: avoid; }
  .amount-words, .doc-note { page-break-inside: avoid; }
  .no-print { display: none !important; }
}

/* 屏幕上的纸张容器 */
.paper-scroll { overflow-x: auto; padding-bottom: 8px; }