/* A4 document paper - used for screen preview and for browser Print / Save as PDF */
.paper { position: relative; width: 210mm; min-height: 297mm; margin: 0 auto 16px; background: #fff; color: #111; padding: 12mm 12mm 10mm; font-size: 12.5px; line-height: 1.45; box-shadow: 0 2px 12px rgba(0, 0, 0, .15); display: flex; flex-direction: column; overflow: hidden; }
.paper .pre { white-space: pre-wrap; }
.paper .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.p-head { display: flex; justify-content: space-between; gap: 12px; border-bottom: 2px solid var(--doc-theme, #3a3a3a); padding-bottom: 8px; margin-bottom: 10px; }
.p-company { display: flex; gap: 10px; align-items: flex-start; flex: 1 1 58%; min-width: 0; }
.p-logo { max-width: 70px; max-height: 60px; object-fit: contain; }
.p-cname { font-size: 15px; font-weight: 600; }
.p-title { text-align: right; flex: 0 1 42%; min-width: 0; }
.p-title h1 { font-size: 17px; color: var(--doc-theme, #3a3a3a); margin: 2px 0 0; line-height: 1.3; overflow-wrap: anywhere; }
.p-title-en { font-size: 11px; color: #555; }
.p-copy { display: inline-block; border: 1px solid var(--doc-theme, #3a3a3a); color: var(--doc-theme, #3a3a3a); border-radius: 4px; padding: 0 8px; font-size: 12px; font-weight: 600; }
.p-sheet { font-size: 11px; color: #555; margin-top: 2px; }
.p-info { display: grid; grid-template-columns: 1.5fr 1fr; gap: 10px; margin-bottom: 8px; }
.p-box { border: 1px solid #ccd; border-radius: 6px; padding: 6px 9px; }
.p-lbl { font-size: 11px; color: #666; }
.p-bname { font-weight: 600; font-size: 13.5px; }
.p-meta table { width: 100%; border-collapse: collapse; }
.p-meta th { text-align: left; font-weight: 600; color: #444; padding: 1px 6px 1px 0; white-space: nowrap; width: 1%; }
.p-meta td { padding: 1px 0; }
.p-job { margin-bottom: 6px; }
.p-lines { width: 100%; border-collapse: collapse; margin-top: 4px; }
.p-lines th { background: var(--doc-theme, #3a3a3a); color: #fff; font-weight: 600; padding: 5px 6px; text-align: left; font-size: 12px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.p-lines th.num { text-align: right; }
.p-lines td { padding: 4px 6px; border-bottom: 1px solid #e3e5ea; vertical-align: top; }
.p-lines .c-no { width: 36px; text-align: center; }
.p-cont { margin-top: auto; text-align: right; font-style: italic; color: #555; padding-top: 8px; }
.p-totals { display: grid; grid-template-columns: 1fr 75mm; gap: 12px; margin-top: 8px; }
.p-words { background: color-mix(in srgb, var(--doc-theme, #3a3a3a) 9%, #fff); border-radius: 4px; padding: 5px 8px; font-weight: 600; text-align: center; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.p-remarks { margin-top: 6px; font-size: 12px; }
.p-sum { width: 100%; border-collapse: collapse; }
.p-sum td { padding: 2px 0; }
.p-sum td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.p-sum .p-grand td { font-weight: 600; border-top: 1px solid #999; border-bottom: 1px solid #999; padding: 4px 0; }
.p-sum .p-pay td { font-weight: 600; }
.p-sign { margin-top: auto; padding-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 22px; break-inside: avoid; page-break-inside: avoid; }
.p-sigblock { font-size: 12px; text-align: center; }
.p-onbehalf { font-weight: 600; text-align: center; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-sigrow { position: relative; display: grid; grid-template-columns: 1.6fr 1fr; gap: 12px; }
.p-ours .p-sigrow { padding-left: 64px; }
.p-sigspace { height: 50px; display: flex; justify-content: center; align-items: flex-end; }
.p-sigspace img { max-height: 46px; max-width: 130px; }
.p-sign .p-stamp { position: absolute; left: 0; bottom: 6px; max-height: 62px; max-width: 62px; opacity: .85; }
.p-sigline { border-top: 1px dotted #555; padding-top: 3px; }
.p-sigdate { font-size: 12px; padding-bottom: 2px; }
.watermark { position: absolute; inset: 0; display: grid; place-items: center; font-size: 120px; font-weight: 700; color: rgba(154, 52, 18, .16); transform: rotate(-28deg); pointer-events: none; z-index: 5; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.watermark.wm-draft { color: rgba(91, 100, 114, .14); }

@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; }
  .sidebar, .topbar, .no-print, .trial-banner, #toasts, .modal-back, .menu { display: none !important; }
  .shell, .main, .view, .view-layout { display: block !important; padding: 0 !important; margin: 0 !important; max-width: none !important; }
  .paper-stage { background: none !important; padding: 0 !important; border-radius: 0 !important; overflow: visible !important; }
  .paper { box-shadow: none; margin: 0; width: 210mm; height: 297mm; min-height: 0; page-break-after: always; break-after: page; }
  .paper:last-child { page-break-after: auto; break-after: auto; }
}
.p-legal { font-size: 11px; font-weight: 600; color: var(--rust); margin-top: 2px; }

/* document colour theme (settings: สีเอกสาร); images (logo / stamp / signature) are never filtered */
.paper { --doc-theme: #3a3a3a; }
.paper::before { content: ""; position: absolute; top: 0; right: 0; border-style: solid; border-width: 0 16mm 16mm 0; border-color: transparent var(--doc-theme, #3a3a3a) transparent transparent; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.p-lines thead th { border-bottom: 1px solid var(--doc-theme, #3a3a3a); }
.paper img { filter: none !important; }
