/* ============================================================
   外贸单证 A4 版式与打印控制
   —— 单证样式的唯一出处，界面样式在 style.css
   ============================================================ */

/* ---------- 屏幕上的 A4 纸张 ---------- */
.a4-page {
  width: 210mm;
  min-height: 297mm;
  padding: 12mm 14mm;
  margin: 0 auto 16px;
  background: #ffffff;
  box-sizing: border-box;
  box-shadow: 0 2px 14px rgba(16, 24, 40, .16);
  /* 单据用衬线体更正式；中文自动回退到宋体 */
  font-family: "Times New Roman", "SimSun", "宋体", "Songti SC", serif;
  font-size: 10.5pt;
  line-height: 1.5;
  color: #000;
  position: relative;
}

/* ---------- 打印控制 ---------- */
@page {
  size: A4;
  /* 边距归零，让 .a4-page 的 padding 成为唯一边距控制点 */
  margin: 0;
}

@media print {
  /* 1. 隐藏界面外壳，只留打印容器 */
  body > *:not(#printRoot) { display: none !important; }
  #printRoot { display: block !important; }
  html, body {
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* 2. 纸张去掉装饰，宽度显式回到 210mm（防"适应页面"缩放裁边） */
  .a4-page {
    box-shadow: none !important;
    margin: 0 !important;
    width: 210mm !important;
    min-height: auto !important;
    page-break-after: always;
  }
  .a4-page:last-child { page-break-after: auto; }

  /* 3. 强制打印背景色（表头底色、条款底纹） */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* 4. 分页控制 */
  .no-break { break-inside: avoid; page-break-inside: avoid; }
  .page-break { break-after: page; page-break-after: always; }
  thead { display: table-header-group; }   /* ★ 表头跨页重复 */
  tfoot { display: table-footer-group; }
  tr { break-inside: avoid; page-break-inside: avoid; }
}

/* ============================================================
   单据内部版式
   ============================================================ */

/* ---------- 抬头 ---------- */
.doc-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12mm;
  padding-bottom: 4mm;
  border-bottom: 2px solid #1a4d8f;
  margin-bottom: 5mm;
}
.doc-head-left { flex: 1; }
.doc-company-cn {
  font-size: 14pt;
  font-weight: bold;
  color: #1a4d8f;
  letter-spacing: .5px;
  margin-bottom: 1mm;
}
.doc-company-en {
  font-size: 11pt;
  font-weight: bold;
  color: #1a4d8f;
  margin-bottom: 1.5mm;
}
.doc-company-info {
  font-size: 8.5pt;
  line-height: 1.45;
  color: #333;
}

/* ---------- 大标题 ---------- */
.doc-title {
  text-align: right;
  flex-shrink: 0;
}
.doc-title-cn {
  font-size: 17pt;
  font-weight: bold;
  color: #1a4d8f;
  letter-spacing: 3px;
}
.doc-title-en {
  font-size: 15pt;
  font-weight: bold;
  color: #1a4d8f;
  letter-spacing: 1px;
}
.doc-meta {
  margin-top: 3mm;
  font-size: 8.5pt;
  line-height: 1.6;
  text-align: right;
}
.doc-meta span { display: block; }

/* ---------- 买卖双方 ---------- */
.parties {
  display: flex;
  gap: 6mm;
  margin-bottom: 4mm;
}
.party {
  flex: 1;
  border: 1px solid #b9c6d8;
  padding: 2.5mm 3mm;
  border-radius: 1mm;
}
.party-label {
  font-size: 8.5pt;
  font-weight: bold;
  color: #1a4d8f;
  border-bottom: 1px solid #d5dee9;
  padding-bottom: 1mm;
  margin-bottom: 1.5mm;
  letter-spacing: .5px;
}
.party-body {
  font-size: 8.5pt;
  line-height: 1.55;
  white-space: pre-wrap;
}

/* ---------- 引导语 ---------- */
.doc-lead {
  font-size: 9pt;
  line-height: 1.6;
  margin-bottom: 3mm;
  text-align: justify;
}

/* ---------- 明细表格 ---------- */
.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 8.5pt;
  margin-bottom: 3mm;
}
.doc-table th {
  background: #dce6f2;
  border: 1px solid #8ba5c4;
  padding: 1.6mm 1.5mm;
  font-weight: bold;
  text-align: center;
  line-height: 1.3;
  color: #14304f;
}
.doc-table td {
  border: 1px solid #a8bcd4;
  padding: 1.6mm 1.5mm;
  vertical-align: top;
  line-height: 1.4;
}
.doc-table .c { text-align: center; }
.doc-table .r { text-align: right; }
.doc-table .idx { width: 8mm; text-align: center; }
.doc-table .desc { text-align: left; }
.doc-table tfoot td {
  background: #eef3f9;
  font-weight: bold;
}
.doc-table .total-label {
  text-align: right;
  font-weight: bold;
}

/* ---------- 金额大写 ---------- */
.say-total {
  font-size: 9pt;
  font-weight: bold;
  margin: 2mm 0 4mm;
  padding: 1.5mm 2mm;
  background: #f2f6fb;
  border-left: 3px solid #1a4d8f;
}

/* ---------- 条款区 ---------- */
.clause-block { margin-bottom: 3.5mm; }
.clause-title {
  font-size: 9.5pt;
  font-weight: bold;
  color: #14304f;
  margin-bottom: 1mm;
  text-transform: uppercase;
}
.clause-cn {
  font-size: 8.5pt;
  line-height: 1.55;
  text-align: justify;
  margin-bottom: .8mm;
}
.clause-en {
  font-size: 8.5pt;
  line-height: 1.5;
  text-align: justify;
  color: #333;
  font-style: italic;
}

/* ---------- 银行信息 ---------- */
.bank-box {
  border: 1px solid #b9c6d8;
  background: #f7fafd;
  padding: 2.5mm 3mm;
  margin-bottom: 4mm;
  font-size: 8.5pt;
  line-height: 1.6;
  border-radius: 1mm;
}
.bank-box .bank-title {
  font-weight: bold;
  color: #1a4d8f;
  margin-bottom: 1mm;
}

/* ---------- 签章区 ---------- */
.signature-block {
  display: flex;
  justify-content: space-between;
  gap: 10mm;
  margin-top: 8mm;
}
.sig-party { flex: 1; }
.sig-label {
  font-size: 9pt;
  font-weight: bold;
  color: #14304f;
  margin-bottom: 1mm;
}
.sig-space {
  height: 22mm;
  border-bottom: 1px solid #666;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 1mm;
}
.sig-space img { max-height: 20mm; max-width: 60mm; }
.sig-note {
  font-size: 7.5pt;
  color: #666;
  margin-top: 1mm;
}

/* ---------- 页脚 ---------- */
.doc-foot {
  margin-top: 6mm;
  padding-top: 2mm;
  border-top: 1px solid #c3cfe0;
  font-size: 7.5pt;
  color: #666;
  text-align: center;
}

/* ---------- 报关资料：要素汇总表 ---------- */
.customs-section-title {
  font-size: 10pt;
  font-weight: bold;
  color: #14304f;
  background: #e8eff8;
  padding: 1.5mm 2mm;
  margin: 3mm 0 2mm;
  border-left: 3px solid #1a4d8f;
}
.kv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 8.5pt;
  margin-bottom: 3mm;
}
.kv-table th {
  background: #dce6f2;
  border: 1px solid #8ba5c4;
  padding: 1.6mm;
  text-align: left;
  width: 30mm;
  font-weight: bold;
  color: #14304f;
}
.kv-table td {
  border: 1px solid #a8bcd4;
  padding: 1.6mm;
}
