/* ============================================================
   paper.css - A4 문서 본체. 이 부분만 인쇄됩니다.

   인쇄 여백은 @page 가 담당하고 .pv 는 padding 을 0 으로 둡니다.
   둘 다 여백을 주면 내용이 밀려서 2페이지가 됩니다.
   ============================================================ */

.pv{
  width:210mm;min-height:297mm;padding:13mm;
  background:#fff;color:#000;
  box-shadow:0 1px 2px rgba(22,32,43,.10),0 10px 28px rgba(22,32,43,.14);
  font-size:9.5pt;line-height:1.45;
}
.pv--half{min-height:148.5mm;padding:13mm}

/* 문서 제목 - 한국 서식 관습대로 자간을 벌립니다 */
.pv__head{text-align:center;margin-bottom:7mm}
.pv__title{
  margin:0;font-size:19pt;font-weight:700;
  letter-spacing:.38em;text-indent:.38em;
}

.pv__meta{
  display:flex;justify-content:flex-end;gap:14px;flex-wrap:wrap;
  font-size:8.5pt;margin-bottom:3mm;
}
.pv__meta b{font-weight:600;margin-right:4px;color:#333}

/* 당사자 */
.pv__parties{display:grid;grid-template-columns:1fr 1fr;gap:4mm;margin-bottom:5mm}
.pv__parties--one{grid-template-columns:1fr;max-width:94mm}
.pv__party{width:100%;border-collapse:collapse;font-size:8.5pt}
.pv__party caption{text-align:left;font-weight:700;padding-bottom:1.6mm;font-size:9.5pt}
.pv__party th,.pv__party td{border:.3mm solid #000;padding:1.2mm 2mm}
.pv__party th{width:22mm;background:#F1F3F5;font-weight:500;text-align:center;white-space:nowrap}

/* 품목 표 */
.pv__items{width:100%;border-collapse:collapse;font-size:8.5pt;margin-bottom:3mm}
.pv__items th,.pv__items td{border:.3mm solid #000;padding:1.3mm 1.8mm}
.pv__items thead th{background:#ECEFF2;font-weight:600;text-align:center;white-space:nowrap}
.pv__items td.n{text-align:right;font-variant-numeric:tabular-nums}
.pv__items tbody tr{height:6.2mm}
.pv__items tfoot td{background:#F5F7F9;font-weight:600;text-align:center}
.pv__items tfoot td.n{text-align:right}
.pv__items tfoot tr.big td{
  background:#fff;font-size:10.5pt;padding:2mm 1.8mm;border-top:.6mm solid #000;
}
.pv__items tfoot tr.big td.n{color:#C0392B;font-weight:700}

/* 잔액 줄 */
.pv__ledger{width:100%;border-collapse:collapse;font-size:8.5pt;margin-bottom:5mm}
.pv__ledger th,.pv__ledger td{border:.3mm solid #000;padding:1.3mm 1.8mm}
.pv__ledger th{background:#F1F3F5;font-weight:500;white-space:nowrap}
.pv__ledger td.n{text-align:right;font-variant-numeric:tabular-nums}
.pv__ledger td.b{font-weight:700;color:#C0392B}

/* 영수증 금액 */
.pv__amount{
  border:.6mm solid #000;padding:4mm 5mm;margin-bottom:4mm;
  display:flex;justify-content:space-between;align-items:baseline;gap:7mm;
}
.pv__amount-h{font-size:13pt;font-weight:700}
.pv__amount-n{font-size:12pt;font-variant-numeric:tabular-nums;white-space:nowrap}

/* 라벨-값 표 */
.pv__fields{width:100%;border-collapse:collapse;font-size:8.5pt;margin-bottom:4mm}
.pv__fields caption{text-align:left;font-weight:700;padding-bottom:1.6mm;font-size:9.5pt}
.pv__fields th,.pv__fields td{border:.3mm solid #000;padding:1.5mm 2mm}
.pv__fields th{width:24mm;background:#F1F3F5;font-weight:500;white-space:nowrap}

/* 조항 */
.pv__clauses{margin-bottom:4mm}
.pv__clauses h3{margin:0 0 2mm;font-size:9.5pt;font-weight:700}
.pv__clauses ol{margin:0;padding-left:5.5mm}
.pv__clauses li{margin-bottom:1.4mm;text-align:justify}
.pv__clauses li::marker{font-weight:600}

/* 본문 */
.pv__body{margin-bottom:5mm}
.pv__body h3{margin:0 0 2mm;font-size:9.5pt;font-weight:700}
.pv__body p{margin:0;min-height:7mm;text-align:justify;white-space:pre-wrap}

/* 서명 */
.pv__sign{margin-top:8mm;text-align:center}
.pv__sign-lead{margin:0 0 6mm;font-size:9.5pt}
.pv__sign-date{margin:0 0 6mm;font-size:10.5pt;letter-spacing:.06em}
.pv__sign-lines{display:flex;flex-direction:column;gap:4mm;align-items:center}
.pv__sign-line{display:flex;align-items:baseline;gap:3.5mm;min-width:90mm;justify-content:flex-end}
.pv__sign-line .r{font-weight:600;min-width:19mm;text-align:right}
.pv__sign-line .v{
  min-width:46mm;border-bottom:.3mm solid #000;text-align:center;padding-bottom:.8mm;
}
.pv__sign-line .seal{color:#C0392B;font-size:8.5pt;min-width:11mm;text-align:left}


/* ══ 인쇄 ══════════════════════════════════════════════
   여백은 @page 하나만 담당합니다. .pv 의 padding 은 0.
   둘 다 주면 내용이 밀려 2페이지가 됩니다.
   ══════════════════════════════════════════════════════ */
/* 좌우 여백을 12mm → 13mm 로 넓혀 테두리가 잘릴 여유를 둡니다.
   표 테두리는 바깥쪽으로 그려져서 100% 폭을 조금 넘습니다. */
@page{size:A4 portrait;margin:13mm}

/* 인쇄용 사본은 화면에서 보이지 않습니다 */
#printroot{display:none}

@media print{
  html,body{
    background:#fff!important;margin:0!important;padding:0!important;
    height:auto!important;min-height:0!important;display:block!important;
    -webkit-print-color-adjust:exact;print-color-adjust:exact;
  }

  /* ★ 이름을 하나하나 적지 않습니다.
     body 바로 아래 모든 것을 숨기고 인쇄용 사본만 살립니다.
     새 요소가 추가돼도 자동으로 숨겨집니다. */
  body > *{display:none!important}
  body > #printroot{display:block!important;margin:0!important;padding:0!important}

  #printroot .pv{
    /* 안전 여백 1mm. 표 테두리(0.3mm × 2)가 폭을 넘어 잘리는 것을 막습니다. */
    width:calc(100% - 1mm)!important;max-width:100%!important;
    min-height:0!important;height:auto!important;
    padding:0!important;margin:0!important;
    box-shadow:none!important;border:0!important;
    transform:none!important;position:static!important;
    font-size:9pt;
  }
  #printroot .pv > *:last-child{margin-bottom:0!important}

  /* 표는 테두리를 폭 안에 포함시켜 계산합니다 */
  #printroot table{
    box-sizing:border-box!important;
    max-width:100%!important;table-layout:fixed!important;
  }
  #printroot th,#printroot td{
    box-sizing:border-box!important;
    overflow-wrap:break-word;word-break:break-word;
  }

  /* 여러 장이 될 때 표 머리글을 각 페이지에 반복합니다.
     tfoot 은 기본값이 table-footer-group 이라 매 페이지에 합계가 찍히므로 막습니다. */
  #printroot .pv__items thead{display:table-header-group}
  #printroot .pv__items tfoot{display:table-row-group}
  #printroot .pv__items tr,
  #printroot .pv__party,
  #printroot .pv__fields,
  #printroot .pv__ledger{page-break-inside:avoid}
  #printroot .pv__sign{page-break-inside:avoid}
}

/* 화면이 좁을 때 - 종이 자체가 화면 폭을 넘지 않도록 */
