/* หน้าพิมพ์รายงาน A4 — ฟอนต์ TH SarabunPSK */
@font-face { font-family: 'TH SarabunPSK'; src: url('/fonts/THSarabunPSK.ttf') format('truetype'); font-weight: 400; }
@font-face { font-family: 'TH SarabunPSK'; src: url('/fonts/THSarabunPSK-Bold.ttf') format('truetype'); font-weight: 700; }

:root { --ink: #000; --line: #000; --soft: #f2f2f2; }
* { box-sizing: border-box; }
html, body { margin: 0; background: #e9ebee; color: var(--ink); font-family: 'TH SarabunPSK', sans-serif; font-size: 15pt; line-height: 1.15; }

/* ---------- แถบเครื่องมือ (ไม่พิมพ์) ---------- */
.toolbar { position: sticky; top: 0; z-index: 10; background: #1f4e8c; color: #fff; padding: 8px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 14pt; }
.toolbar button { font: inherit; font-size: 14pt; padding: 2px 16px; border-radius: 6px; border: 1px solid #fff; background: #fff; color: #1f4e8c; cursor: pointer; font-weight: 700; }
.toolbar button.ghost { background: transparent; color: #fff; }
.toolbar .tip { font-size: 12pt; opacity: .9; }
#msg { padding: 24px; font-size: 16pt; }

/* ---------- แผ่นกระดาษ ---------- */
.sheet { width: 210mm; height: 297mm; margin: 10mm auto; background: #fff; padding: 11mm 13mm 9mm; position: relative; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,.18); page: card; }
.sheet.land { width: 297mm; height: 210mm; padding: 9mm 11mm; page: land; }
.sheet.flow { height: auto; min-height: 297mm; overflow: visible; page: flow; }
@page card { size: A4 portrait; margin: 0; }
@page land { size: A4 landscape; margin: 0; }
@page flow { size: A4 portrait; margin: 11mm 13mm 11mm; }
.sheet.land.flow { height: auto; min-height: 210mm; page: landflow; }
@page landflow { size: A4 landscape; margin: 8mm 10mm; }

@media print {
  html, body { background: #fff; }
  .toolbar, #msg { display: none !important; }
  .sheet { margin: 0; box-shadow: none; break-after: page; }
  .sheet:last-child { break-after: auto; }
  .sheet.flow { padding: 0; min-height: 0; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
}

/* ---------- หัวรายงาน ---------- */
.hdr { display: grid; grid-template-columns: 24mm 1fr 24mm; align-items: center; gap: 3mm; }
.hdr .logo img { width: 22mm; height: 22mm; object-fit: contain; }
.hdr .ttl { text-align: center; }
.hdr h1 { font-size: 20pt; margin: 0; line-height: 1.1; }
.hdr h2 { font-size: 17pt; margin: 0; font-weight: 700; line-height: 1.15; }
.hdr h3 { font-size: 15pt; margin: 0; font-weight: 400; }
.hdr .boxed { border: 1px solid var(--line); display: inline-block; padding: 0 10mm; margin: 1mm 0; }

.info { display: grid; gap: 0 4mm; margin: 2.5mm 0 2mm; font-size: 15pt; }
.info b { font-weight: 700; }
.info .lbl { font-weight: 700; }
.u { border-bottom: 1px dotted #555; padding: 0 2mm; }

/* ---------- ตาราง ---------- */
table.rep { width: 100%; border-collapse: collapse; font-size: 14pt; }
table.rep th, table.rep td { border: 1px solid var(--line); padding: 0 1.6mm; height: 6.4mm; line-height: 1.05; }
table.rep th { font-weight: 700; text-align: center; background: var(--soft); }
table.rep td.c { text-align: center; }
table.rep td.r { text-align: right; }
table.rep tfoot td { font-weight: 700; background: var(--soft); }
table.rep td.vlabel { writing-mode: vertical-rl; transform: rotate(180deg); text-align: center; font-size: 13pt; width: 7mm; padding: 1mm 0; background: #fff; }
table.rep.tight th, table.rep.tight td { height: 5.6mm; font-size: 13pt; }
table.rep th.vert { height: 32mm; padding: .5mm 0; vertical-align: bottom; }
table.rep th.vert > div { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; height: 31mm; overflow: hidden; margin: 0 auto; font-size: 11.5pt; text-align: left; line-height: 1; }
table.rep.xs th, table.rep.xs td { height: 5mm; font-size: 12pt; padding: 0 1mm; }

/* ---------- สรุป / ลายเซ็น ---------- */
.lines { margin: 3mm 0 0 30mm; font-size: 15pt; }
.lines div { display: grid; grid-template-columns: 95mm auto; }
.lines .v { font-weight: 700; }
.sigs { display: grid; grid-template-columns: 1fr 1fr; gap: 7mm 10mm; margin-top: 9mm; }
.sigs.three-col { grid-template-columns: 1fr 1fr 1fr; }
.sig { text-align: center; font-size: 15pt; line-height: 1.35; }
.sig.center { grid-column: 1 / -1; justify-self: center; width: 50%; }
.sig .dots { letter-spacing: 1px; }

/* มัธยม: กรอบสรุปซ้าย + ลายเซ็นขวา */
.bottom { display: grid; grid-template-columns: 100mm 1fr; gap: 6mm; margin-top: 3mm; }
table.box { width: 100%; border-collapse: collapse; font-size: 13.5pt; }
table.box td, table.box th { border: 1px solid var(--line); padding: 0 2mm; height: 6.2mm; }
table.box th { background: var(--soft); text-align: center; }
table.box td.v { text-align: center; width: 28mm; font-weight: 700; }
.sigcol { display: flex; flex-direction: column; justify-content: space-around; }
.sigcol .sig { text-align: left; padding-left: 4mm; }
.sigcol .sig .t { padding-left: 22mm; }

/* ประกาศ */
.notice p { text-indent: 18mm; margin: 0 0 2mm; text-align: justify; font-size: 16pt; line-height: 1.35; }
.room-head { font-weight: 700; margin: 3mm 0 1mm; font-size: 16pt; }
.foot-note { font-size: 12pt; color: #333; margin-top: 2mm; }
