/* ================================================================
   合同排版样式 — A4 纸张模拟 + 打印优化
   严格按照正式合同文书排版规范
   ================================================================ */

/* 合同容器（A4 纸张内部） */
.contract-page {
  width: 794px; /* A4 96dpi 规范物理宽度 */
  height: 1120px; /* A4 96dpi 规范物理高度，留有微量高度舍入安全距，防止产生多余空白页 */
  min-height: 1120px;
  max-height: 1120px;
  background: #ffffff;
  padding: 90px 75px; /* 黄金比例 A4 页边距，上下对称约 24mm，左右约 20mm */
  margin: 0 auto; /* 彻底取消页面之间的间距，使其贴合成一条连续流淌的瀑布长卷 */
  box-sizing: border-box;
  font-family: 'SimSun', '宋体', 'Noto Serif SC', serif;
  font-size: 14px;
  line-height: 2;
  color: #000;
  word-break: break-all;
  position: relative;
  overflow: hidden; /* 强制物理1:1不发生溢出滚动 */
  border-bottom: 1px dashed #e2e8f0; /* 在页面交界处仅留微弱虚线提示 */
}

/* 页脚页码 */
.page-number {
  position: absolute;
  bottom: 40px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 12px;
  color: #666;
  font-family: 'SimSun', '宋体', serif;
  pointer-events: none;
}

/* ----- 合同标题 ----- */
.contract-title {
  font-family: 'SimHei', '黑体', 'Noto Sans SC', sans-serif;
  font-size: 26px;
  font-weight: bold;
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: 4px;
  line-height: 1.6;
}

/* 合同编号 */
.contract-no {
  text-align: right;
  font-size: 13px;
  color: #333;
  margin-bottom: 16px;
  font-family: 'SimSun', '宋体', serif;
  letter-spacing: 0;
}

/* ----- 当事人信息 ----- */
.party-info {
  margin-bottom: 12px;
  line-height: 2.2;
}

.party-info p {
  text-indent: 0;
  margin: 0;
}

/* ----- 前言 ----- */
.contract-preface {
  text-indent: 2em;
  margin-bottom: 12px;
}

/* ----- 条款标题 ----- */
.clause-title {
  font-family: 'SimHei', '黑体', 'Noto Sans SC', sans-serif;
  font-size: 14px;
  font-weight: bold;
  margin-top: 10px;
  margin-bottom: 2px;
  text-indent: 2em;
  page-break-after: avoid; /* 防止标题与后面的条款正文在页尾断开 */
  break-after: avoid;
}

/* ----- 条款正文 ----- */
.clause-content {
  text-indent: 2em;
  margin-bottom: 4px;
  text-align: justify;
  /* 允许在段落文字中间发生自然的分页与换行流 */
}

/* 子条款 */
.clause-sub {
  text-indent: 2em;
  margin-bottom: 2px;
  padding-left: 0;
  /* 允许在子条款内部发生自然的分页与换行流 */
}

/* ----- 填写内容（下划线样式） ----- */
.fill-blank {
  border-bottom: 1px solid #000;
  padding: 0 4px;
  min-width: 60px;
  display: inline;
  font-weight: 500;
  color: #000;
  transition: all 0.2s ease;
}

/* 屏幕上未填写的占位提示（净化为淡灰色虚线，杜绝任何彩色） */
.fill-blank.placeholder {
  background-color: rgba(0, 0, 0, 0.03);
  border-bottom: 1px dashed rgba(0, 0, 0, 0.2);
  color: rgba(0, 0, 0, 0.3) !important;
  padding: 0 4px;
  border-radius: 2px;
}

/* 左侧输入框聚焦时，右侧对应填空高亮样式（净化为经典灰黑高亮，去除彩色） */
.fill-blank.is-active-field {
  background-color: rgba(0, 0, 0, 0.05) !important;
  border-bottom: 2px solid #000 !important;
  color: #000 !important;
  display: inline-block;
  padding: 0 4px !important;
  border-radius: 2px;
  transition: all 0.2s ease;
}

/* 空白占位 */
.fill-blank:empty::after,
.fill-blank.placeholder::after {
  content: '\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0';
}

/* 较长的空白 */
.fill-blank.long {
  min-width: 120px;
}

.fill-blank.long:empty::after,
.fill-blank.long.placeholder::after {
  content: '\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0';
}

/* ----- 合同表格 ----- */
.contract-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13px;
}

.contract-table tr {
  page-break-inside: avoid;
  break-inside: avoid;
}

.contract-table th,
.contract-table td {
  border: 1px solid #000;
  padding: 6px 10px;
  text-align: left;
  vertical-align: middle;
  line-height: 1.6;
}

.contract-table th {
  font-weight: normal;
  background: #f8f8f8;
  width: 120px;
  white-space: nowrap;
}

.contract-table .full-width {
  text-align: left;
}

/* 物业信息表格 */
.property-table th {
  width: 130px;
  text-align: center;
}

/* ----- 勾选项 ----- */
.check-option {
  font-size: 15px;
  margin-right: 2px;
}

.check-option.checked {
  font-weight: bold;
}

/* ----- 签字区域 ----- */
.signature-area {
  margin-top: 30px;
  page-break-inside: avoid;
}

.signature-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
  line-height: 2.5;
}

.signature-col {
  width: 45%;
}


 
.signature-line {
  border-bottom: 1px solid #000;
  min-width: 120px;
  display: inline-block;
  min-height: 1em;
}

/* 三方签字 */
.signature-three {
  margin-top: 24px;
  page-break-inside: avoid;
  break-inside: avoid;
}

.signature-three .signature-full {
  margin-bottom: 14px;
  line-height: 2.5;
}

/* ----- 备注区域 ----- */
.remarks-area {
  margin-top: 12px;
  margin-bottom: 12px;
  page-break-inside: avoid;
  break-inside: avoid;
}

.remarks-content {
  min-height: 60px;
  border-bottom: 1px solid #000;
  padding: 4px 0;
}

/* ----- 附件标题 ----- */
.appendix-title {
  font-family: 'SimHei', '黑体', 'Noto Sans SC', sans-serif;
  font-size: 14px;
  font-weight: bold;
  text-align: center;
  margin-top: 16px;
  margin-bottom: 6px;
}

/* ----- 收据样式 ----- */
.receipt-container {
  margin-top: 10px;
}

.receipt-title {
  font-family: 'SimHei', '黑体', 'Noto Sans SC', sans-serif;
  font-size: 22px;
  font-weight: bold;
  text-align: center;
  margin-bottom: 20px;
  letter-spacing: 3px;
}

.appendix-main-title {
  font-family: 'SimHei', '黑体', 'Noto Sans SC', sans-serif;
  font-size: 22px;
  font-weight: bold;
  text-align: center;
  margin-bottom: 12px;
  letter-spacing: 3px;
  line-height: 1.6;
}

/* ----- 分页标记 ----- */
.page-break {
  display: none !important; /* 彻底隐去裁切线，打通无缝瀑布流 */
}

.page-break::after {
  content: '✂️ 裁剪线 · 打印时在此处分页';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: #f3f4f6;
  padding: 2px 12px;
  font-size: 11px;
  color: #64748b;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  letter-spacing: 0.1em;
  pointer-events: none;
  border-radius: 4px;
}

.page-break-before {
  page-break-before: always;
  break-before: page;
}

/* 避免在关键区域分页 */
.no-break {
  page-break-inside: avoid;
  break-inside: avoid;
}

/* ----- 设备清单表格 ----- */
.equipment-list-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
}

.equipment-list-table th,
.equipment-list-table td {
  border: 1px solid #000;
  padding: 6px 10px;
  text-align: center;
  font-size: 13px;
  line-height: 1.6;
}

.equipment-list-table th {
  font-weight: bold;
  background: #f8f8f8;
}

.equipment-list-table td.text-left {
  text-align: left;
}

/* ----- 页脚页码区域 (仅打印) ----- */
@media print {
  @page {
    size: A4 portrait;
    margin: 0 !important; /* 强制物理纸张 0 边距，页边距完全由 CSS padding 无损接管，杜绝空白页 */
  }

  body {
    background: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .contract-page {
    width: 794px !important; /* 物理 1:1 宽度 */
    height: 1120px !important; /* 物理 1:1 高度 */
    min-height: 1120px !important;
    max-height: 1120px !important;
    padding: 90px 75px !important; /* 物理页边距 */
    margin: 0 auto !important; /* 居中消除纸张外间距 */
    box-shadow: none !important;
    background: #ffffff !important;
    overflow: hidden !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .contract-page:not(:last-child) {
    page-break-after: always !important; /* 强行物理分页 */
    break-before: auto !important;
    break-after: page !important;
  }

  .page-number {
    display: none !important; /* 物理打印时直接使用浏览器系统原生页码，隐藏 HTML 码防字迹重叠 */
  }

  .fill-blank {
    border-bottom-color: #000;
  }

  .fill-blank.placeholder {
    background-color: transparent !important;
    border-bottom: 1px solid #000 !important;
    color: transparent !important;
    padding: 0 !important;
  }

  .fill-blank.is-active-field {
    background-color: transparent !important;
    border-bottom: 1px solid #000 !important;
    color: #000 !important;
    box-shadow: none !important;
    transform: none !important;
    padding: 0 4px !important;
  }

  .page-break {
    display: none !important;
  }

  .contract-table th {
    background: #f0f0f0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ================================================================
   PDF 导出临时状态覆盖样式 (html2pdf 仿真打印)
   ================================================================ */
.is-printing .contract-page {
  width: 794px !important; /* 维持 1:1 物理宽度，零失真 */
  height: 1120px !important; /* 维持 1:1 物理高度，零失真 */
  min-height: 1120px !important;
  max-height: 1120px !important;
  padding: 90px 75px !important; /* 维持 1:1 物理页边距，零失真 */
  margin: 0 auto !important; /* 消除页面外间距 */
  box-shadow: none !important;
  background: #ffffff !important;
  overflow: hidden !important;
}

.is-printing .contract-page:not(:last-child) {
  page-break-after: always !important; /* 仿真切页，精准切到下一物理页 */
  break-after: page !important;
}

.is-printing .fill-blank.placeholder {
  background-color: transparent !important;
  border-bottom: 1px solid #000 !important;
  color: transparent !important;
  padding: 0 !important;
}

.is-printing .fill-blank.is-active-field {
  background-color: transparent !important;
  border-bottom: 1px solid #000 !important;
  color: #000 !important;
  box-shadow: none !important;
  transform: none !important;
  padding: 0 4px !important;
}

.is-printing .page-break {
  display: none !important;
}

.is-printing .contract-table th {
  background: #f0f0f0 !important;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* 纯行内防折断样式，绝不使用 inline-block，保持基线对齐 and text-align 流畅对齐 */
.no-wrap {
  white-space: nowrap !important;
}

/* ================================================================
   通用打印防截断（防腰斩）规则
   ================================================================ */
.clause-content,
.clause-sub,
.party-info p,
.signature-row,
.signature-area,
.remarks-area,
.contract-table tr {
  page-break-inside: avoid !important;
  break-inside: avoid !important;
}

/* ================================================================
   租赁合同 (Rental) 专属精细公文排版重写
   ================================================================ */
.rental-page {
  line-height: 1.8 !important; /* 紧凑公文行高，消除超高风险 */
}
.rental-page .clause-content,
.rental-page .clause-sub {
  margin-bottom: 2px !important; /* 精细调小段落底边距，使内容高度分布更加均匀 */
}
.rental-page .clause-title {
  margin-top: 8px !important;
  margin-bottom: 2px !important;
}
.rental-page .signature-area {
  margin-top: 20px !important;
}

/* ================================================================
   买卖合同 (Sale) 专属尊贵大宗交易排版重写
   ================================================================ */
.sale-page {
  line-height: 1.6 !important; /* 买卖合同专用行高，防止法务项扩充后溢出 */
}
.sale-page .clause-content {
  margin-bottom: 2px !important; /* 精简段落底边距 */
}
.sale-page .clause-title {
  margin-top: 6px !important; /* 精简小标题顶边距 */
  margin-bottom: 2px !important;
}
.sale-page .contract-table {
  margin: 4px 0 !important; /* 精简物业表格外间距 */
}




/* ================================================================
   表格内填空精细净化 (清除多余的下划线和占位底色，防止与格子边框视觉冲突)
   ================================================================ */
.contract-table .fill-blank,
.equipment-list-table .fill-blank {
  border-bottom: none !important;
  padding: 0 !important;
}
.contract-table .fill-blank.placeholder,
.equipment-list-table .fill-blank.placeholder {
  border-bottom: none !important;
  background-color: transparent !important;
}

/* ================================================================
   W3C Paged Media & Paged.js 自动分页排版配置
   ================================================================ */

/* 定义 A4 物理纸张尺寸与安全区 */
@page {
  size: A4 portrait;
  margin-top: 90px;
  margin-bottom: 90px;
  margin-left: 75px;
  margin-right: 75px;

  /* 右下角自动计算页码 */
  @bottom-right {
    content: counter(page) " / " counter(pages);
    font-family: "Microsoft YaHei", "SimSun", sans-serif;
    font-size: 11px;
    color: #4b5563;
  }
}

/* 预览大长卷模式：拼合成无缝长卷 */
.pagedjs_pages {
  background: #fff !important;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pagedjs_page {
  background: #ffffff !important;
  box-shadow: none !important;
  margin: 0 auto !important;
  border-bottom: 1px dashed #e2e8f0 !important; /* 相邻页交界仅保留虚线 */
}

/* 打印时去掉分界线 */
@media print {
  .pagedjs_page {
    border-bottom: none !important;
  }
}

/* 合同大纲流式内容容器 */
.contract-content {
  font-family: 'SimSun', '宋体', 'Noto Serif SC', serif;
  font-size: 14px;
  line-height: 2;
  color: #000;
  word-break: break-all;
}

/* 签字区绝对防断裂（避免甲方和乙方签字栏被物理页切断到两页） */
.signature-area {
  break-inside: avoid !important;
  page-break-inside: avoid !important;
}

/* 表格防单行被截断 */
.contract-table tr {
  break-inside: avoid !important;
  page-break-inside: avoid !important;
}

/* 避免大标题孤立在页尾 */
.clause-title, .appendix-title {
  break-after: avoid !important;
  page-break-after: avoid !important;
}

/* ================================================================
   📄 合同防伪水印样式
   ================================================================ */
.contract-page {
  position: relative !important;
}

.contract-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-30deg);
  font-size: 5.2rem;
  font-weight: 800;
  color: rgba(0, 0, 0, 0.02) !important; /* 极其清淡的淡网点，防干扰 */
  white-space: nowrap;
  letter-spacing: 12px;
  pointer-events: none; /* 防止影响点击与选择 */
  user-select: none;
  z-index: 0; /* 底层铺垫 */
  font-family: "Microsoft YaHei", "SimHei", sans-serif;
}

@media print {
  .contract-watermark {
    color: rgba(0, 0, 0, 0.015) !important; /* 打印时稍微再调浅，确保不遮字 */
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
