/* A4 print rules and the paper-style protocol sheet (.protocol, rendered by lib/protocol-render.js). */
@page { size: A4; margin: 10mm; }

/* ---------- Protocol sheet: always black on white paper, also in dark mode on screen ---------- */
.protocol {
  --pr-line: 8mm;                 /* writing line height */
  --pr-cb: 5.5mm;                 /* checkbox size */
  color: #000; font-size: 9.5pt; line-height: 1.2;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.proto-page {
  background: #fff; color: #000;
  width: 190mm; height: 277mm; overflow: hidden;
  display: flex; flex-direction: column;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
.proto-page * { box-sizing: border-box; }
.proto-page header.pr-head { display: block; margin-bottom: 1.5mm; }
.pr-head { border: 0.5mm solid #000; padding: 1.5mm 2mm; margin-bottom: 1.5mm; }
.pr-title { font-size: 12pt; margin-bottom: 0.5mm; }
.pr-title-2 { border: 0.5mm solid #000; padding: 1.5mm 2mm; margin-bottom: 1.5mm; }
.pr-toprow { display: flex; align-items: flex-end; justify-content: space-between; gap: 4mm; }
.pr-opt-group { display: inline-flex; gap: 5mm; align-items: center; }

.pr-sec { border: 0.3mm solid #000; padding: 1mm 2mm 1.2mm; margin-bottom: 1.3mm; break-inside: avoid; }
.pr-sec.pr-grow { flex: 1 1 auto; display: flex; flex-direction: column; }
.pr-sec.pr-grow .pr-lines { flex: 1 1 auto; }
.pr-h { font-size: 9.5pt; margin: 0 0 0.5mm; text-transform: uppercase; letter-spacing: .02em; display: flex; align-items: center; gap: 2mm; color: #000; }
.pr-letter { display: inline-flex; align-items: center; justify-content: center; width: 5mm; height: 5mm; background: #000; color: #fff; font-weight: 800; }

.pr-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1mm 4mm; min-height: var(--pr-line); }
.pr-row.pr-checks { align-items: center; }
.pr-field { display: flex; align-items: flex-end; gap: 1.5mm; flex: 1 1 30mm; min-width: 0; }
.pr-field.grow2 { flex: 2 1 50mm; }
.pr-field.w-xs, .pr-fill.w-xs { flex: 0 0 9mm; width: 9mm; }
.pr-field.w-sm { flex: 0 0 30mm; }
.pr-field.w-md { flex: 0 0 38mm; }
.pr-field.w-date { flex: 0 0 40mm; }
.pr-field.w-time { flex: 0 0 30mm; }
.pr-lbl { font-size: 8.5pt; font-weight: 600; white-space: nowrap; }
.pr-fill { flex: 1 1 auto; min-width: 8mm; min-height: var(--pr-line); border-bottom: 0.3mm solid #000; padding: 0 1mm; line-height: var(--pr-line); font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pr-fill.w-sm { flex: 0 0 20mm; }
.pr-fill.w-md { flex: 0 0 28mm; }
.pr-unit { font-size: 8.5pt; white-space: nowrap; align-self: center; }
.pr-note { font-size: 7.5pt; color: #222; line-height: 1.15; }
.pr-formula { font-size: 8pt; color: #222; align-self: center; white-space: nowrap; }

.pr-opt { display: inline-flex; align-items: center; gap: 1.5mm; white-space: nowrap; }
.pr-cb svg { width: 4.2mm; height: 4.2mm; stroke-width: 3.2; }
.pr-cb { display: inline-flex; align-items: center; justify-content: center; width: var(--pr-cb); height: var(--pr-cb); border: 0.4mm solid #000; font-weight: 800; font-size: 11pt; line-height: 1; flex: none; }
.pr-calc { flex-wrap: nowrap; gap: 2mm; }
.pr-calc .w-label { flex: 0 0 40mm; align-self: center; }

.pr-ft { border-collapse: collapse; width: 100%; margin-top: 1mm; font-size: 7.5pt; text-align: center; }
.pr-ft th, .pr-ft td { border: 0.2mm solid #000; padding: 0.3mm 0.5mm; }
.pr-ft th { background: #ddd; width: 8mm; }

.pr-table { width: 100%; border-collapse: collapse; font-size: 8.5pt; }
.pr-table th, .pr-table td { border: 0.3mm solid #000; padding: 0.5mm 1.2mm; vertical-align: middle; }
.pr-table thead th { background: #ddd; font-size: 8pt; text-align: center; }
.pr-table tbody th { text-align: left; font-weight: 700; }
.pr-table td.time { text-align: center; font-weight: 600; }
.pr-table td.cbc { text-align: center; width: 14mm; }
.pr-table td.cbc .pr-cb { vertical-align: middle; }
.pr-reg tbody tr { height: 14mm; }
.pr-reg td.tel { width: 33mm; }
.pr-reg .pr-fill { display: block; min-height: 6mm; line-height: 6mm; margin: 1mm 0; }
.pr-log tbody tr { height: var(--pr-line); }
.pr-log tbody th { width: 11mm; text-align: center; }
.pr-log thead th:last-child { width: 40mm; }
.pr-log td.who { font-size: 8pt; text-align: left; width: 24mm; }
.pr-log thead th { font-size: 7.5pt; }

.pr-lines {
  min-height: 4 * var(--pr-line); white-space: pre-wrap; overflow: hidden; font-weight: 600;
  line-height: var(--pr-line);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--pr-line) - 0.3mm), #000 calc(var(--pr-line) - 0.3mm), #000 var(--pr-line));
}
.pr-final { margin-top: auto; border-top: 0.3mm solid #000; padding-top: 1mm; }
.pr-foot { margin-top: auto; font-size: 7.5pt; color: #222; padding-top: 1mm; }
.pr-final + .pr-foot { margin-top: 1mm; }
.pr-foot-row { display: flex; justify-content: space-between; gap: 4mm; }
.pr-digital { font-weight: 700; border: 0.2mm solid #000; padding: 0.5mm 1.5mm; margin-bottom: 0.8mm; }

/* ---------- Generic print rules for all pages ---------- */
.print-only { display: none; }
@media print {
  html, body { background: #fff !important; color: #000 !important; }
  body { padding: 0 !important; margin: 0; font-size: 10pt; line-height: 1.3; }
  main { max-width: none; margin: 0; }
  .no-print { display: none !important; }
  .print-only { display: block; }
  a { color: #000; text-decoration: none; font-weight: 600; }
  .card, .step-card, .box, figure, table, tr { break-inside: avoid; page-break-inside: avoid; }
  h1, h2, h3 { break-after: avoid; }
  .card { border: 0.4mm solid #000; border-radius: 2mm; background: #fff; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* Protocol: exactly one sheet per A4 page */
  .protocol { display: block; gap: 0; }
  .proto-page { width: 190mm; height: 276mm; break-inside: avoid; break-after: page; page-break-after: always; }
  .proto-page:last-child { break-after: auto; page-break-after: auto; }
}
@media screen {
  .protocol { padding: 8px 0; }
  .proto-page { box-shadow: 0 0 0 1px #888, 0 6px 18px rgba(0,0,0,.35); padding: 4mm; height: auto; min-height: 277mm; }
}
@media screen and (max-width: 820px) {
  /* scale the paper sheet down on phones/tablets; the ratio stays A4 */
  .protocol { zoom: .62; }
}
@media screen and (min-width: 821px) and (max-width: 1100px) {
  .protocol { zoom: .85; }
}
