/* ==========================================================================
   appBHP – dokumenty do druku: karta identyfikacyjna maszyny (A5 poziomo),
   karta maszyny, karta ŚOI, protokół przeglądu, skrócona karta SDS, plakat QR.
   ========================================================================== */
:root {
  --pd-text: #102133; --pd-muted: #56697b; --pd-line: #445363; --pd-soft: #d2dbe3;
  --pd-accent: #1676c7; --pd-brand: #003a70; --pd-red: #c81e1e; --pd-amber: #b45309; --pd-green: #047857;
}
* { box-sizing: border-box; }
body.print-doc {
  margin: 0; font-family: Arial, Helvetica, sans-serif; color: var(--pd-text); background: #e9edf1;
  -webkit-print-color-adjust: exact; print-color-adjust: exact; font-size: 12px; line-height: 1.35;
}
.pd-toolbar {
  position: sticky; top: 0; z-index: 5; padding: 12px; background: #fff; border-bottom: 1px solid #d8e0e8;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.pd-toolbar button, .pd-toolbar a {
  display: inline-block; text-decoration: none; border: 0; border-radius: 10px; background: #12202d; color: #fff;
  font-weight: 700; font-size: 13px; padding: 10px 14px; cursor: pointer; font-family: inherit;
}
.pd-toolbar .light { background: #eef3f7; color: #334155; }
.pd-toolbar .pd-hint { color: #64748b; font-size: 12px; }
.pd-toolbar form { display: inline-flex; gap: 6px; align-items: center; }
.pd-toolbar select { padding: 8px; border-radius: 8px; border: 1px solid #cbd5e1; font: inherit; }

/* ---------- Arkusz A4 / A5 ---------- */
.pd-sheet { width: 210mm; min-height: 297mm; margin: 12px auto; padding: 12mm; background: #fff; box-shadow: 0 4px 24px rgba(15, 23, 42, .12); }
.page-a5 .pd-sheet { width: 148mm; min-height: 210mm; padding: 8mm; font-size: 10.5px; }
.page-a4l .pd-sheet { width: 297mm; min-height: 210mm; }
.pd-sheet + .pd-sheet { margin-top: 18px; }
.pd-head { display: flex; justify-content: space-between; gap: 6mm; align-items: flex-start; border-bottom: 2px solid var(--pd-brand); padding-bottom: 4mm; }
.pd-head .pd-logo { max-height: 15mm; max-width: 45mm; object-fit: contain; }
.pd-logo-title { display: flex; gap: 5mm; align-items: center; }
.pd-title { font-size: 20px; font-weight: 800; color: #12263a; line-height: 1.1; }
.page-a5 .pd-title { font-size: 16px; }
.pd-sub { color: var(--pd-muted); font-size: 11px; margin-top: 2px; }
.pd-qr { text-align: center; font-size: 9px; color: var(--pd-muted); line-height: 1.15; }
.pd-qr [data-qr] { display: inline-block; margin-bottom: 1mm; }
.pd-qr [data-qr] img, .pd-qr [data-qr] canvas { width: 24mm !important; height: 24mm !important; }
.pd-h1-row { display: flex; gap: 5mm; align-items: center; justify-content: space-between; }
.pd-h1-row .pd-qr { flex-shrink: 0; margin-top: 4mm; }
.pd-qr.sm { width: 22mm; font-size: 8px; }
.pd-qr.sm [data-qr] img, .pd-qr.sm [data-qr] canvas { width: 18mm !important; height: 18mm !important; }
.pd-h1 { font-size: 22px; font-weight: 800; margin: 5mm 0 1mm; }
.page-a5 .pd-h1 { font-size: 17px; }
.pd-h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--pd-brand); border-bottom: 1px solid var(--pd-soft); padding-bottom: 1mm; margin: 5mm 0 2.5mm; }
.pd-status { display: inline-block; padding: 2px 10px; border-radius: 999px; font-weight: 700; font-size: 11px; background: #e0f2fe; color: #075985; }
.pd-status.ok { background: #d1fae5; color: var(--pd-green); }
.pd-status.over, .pd-status.nok { background: #fee2e2; color: var(--pd-red); }
.pd-status.warn { background: #fef3c7; color: var(--pd-amber); }
.pd-alert { margin-top: 3mm; padding: 3mm 4mm; border-radius: 3mm; border: 2px solid var(--pd-red); background: #fef2f2; color: #7f1d1d; font-weight: 700; }
.pd-alert.archive { border-color: #64748b; background: #f1f5f9; color: #1e293b; }
.pd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2mm; }
.page-a4l .pd-grid { grid-template-columns: repeat(3, 1fr); }
.pd-box { border: 1px solid var(--pd-soft); border-radius: 2.5mm; padding: 2mm 3mm; break-inside: avoid; }
.pd-box .l { font-size: 9px; text-transform: uppercase; letter-spacing: .05em; color: var(--pd-muted); font-weight: 700; }
.pd-box .v { font-size: 12.5px; font-weight: 700; margin-top: .5mm; white-space: pre-line; overflow-wrap: anywhere; }
.page-a5 .pd-box .v { font-size: 11px; }
.pd-box.wide { grid-column: 1 / -1; }
.pd-box.over { border-color: #fca5a5; background: #fef2f2; }
.pd-box.warn { border-color: #fcd34d; background: #fffbeb; }
.pd-notes { white-space: pre-line; border: 1px solid var(--pd-soft); border-radius: 2.5mm; padding: 3mm; }
.pd-photos { display: flex; gap: 3mm; flex-wrap: wrap; }
.pd-photos img { max-width: 80mm; max-height: 60mm; border-radius: 2mm; border: 1px solid var(--pd-soft); object-fit: contain; }
.page-a5 .pd-photos img { max-width: 60mm; max-height: 45mm; }
table.pd-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.pd-table th, .pd-table td { border: 1px solid #cbd5e1; padding: 1.5mm 2mm; text-align: left; vertical-align: top; }
.pd-table th { background: #f1f5f9; font-size: 9.5px; text-transform: uppercase; letter-spacing: .04em; color: #334155; }
.pd-table tr { break-inside: avoid; }
.pd-table .ok { color: var(--pd-green); font-weight: 700; }
.pd-table .nok { color: var(--pd-red); font-weight: 700; }
.pd-docs { margin: 0; padding-left: 5mm; }
.pd-docs li { margin: .8mm 0; }
.pd-footer { margin-top: 6mm; padding-top: 2mm; border-top: 1px solid var(--pd-soft); color: var(--pd-muted); font-size: 9.5px; font-style: italic; }
.pd-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 10mm; margin-top: 14mm; }
.pd-sign div { border-top: 1px dotted #475569; padding-top: 1.5mm; text-align: center; font-size: 10px; color: var(--pd-muted); }
.pd-check { display: inline-block; width: 4mm; height: 4mm; border: 1.5px solid #334155; border-radius: .8mm; vertical-align: -0.8mm; margin-right: 1.5mm; text-align: center; line-height: 3.2mm; font-size: 10px; font-weight: 800; }
.pd-empty { color: var(--pd-muted); font-style: italic; }

/* ---------- Karta identyfikacyjna maszyny – A5 poziomo (jak w poprzedniej wersji) ---------- */
.mi-sheet { width: 210mm; height: 148mm; margin: 12px auto; padding: 2.5mm; overflow: hidden; break-inside: avoid; page-break-inside: avoid; background: #e9edf1; }
.mi-sheet + .mi-sheet { break-before: page; page-break-before: always; }
.mi-shell { width: 100%; height: 100%; background: #f3f5f7; border: 1px solid #c8d3dd; border-radius: 5.5mm; padding: 4mm; overflow: hidden; }
.mi-header { display: grid; grid-template-columns: 47mm 1fr 40mm; align-items: start; gap: 4mm; padding-bottom: 2.5mm; border-bottom: 1px solid #d2dbe3; }
.mi-logo { max-width: 42mm; max-height: 17mm; object-fit: contain; }
.mi-title-wrap { text-align: center; padding-top: .8mm; }
.mi-title { font-size: 6.5mm; line-height: .96; font-weight: 800; color: #12263a; }
.mi-subtitle { margin-top: 1.1mm; font-size: 2.95mm; color: #4f6376; text-transform: uppercase; letter-spacing: .02em; }
.mi-side { display: grid; grid-template-columns: 1fr 1fr; gap: 2mm; }
.mi-small { border: 1px solid var(--pd-line); border-radius: 3mm; background: #fff; overflow: hidden; min-height: 24mm; }
.mi-small-label { border-bottom: 1px solid #d8e0e8; color: #4c6175; font-size: 2.3mm; font-weight: 700; text-align: center; padding: 1mm .8mm; line-height: 1.05; }
.mi-qr { display: grid; justify-items: center; align-content: start; padding-top: .7mm; }
.mi-qr [data-qr] img, .mi-qr [data-qr] canvas { width: 13.5mm !important; height: 13.5mm !important; display: block; }
.mi-qr-note { margin-top: .6mm; padding: 0 1mm .8mm; color: #4f6376; font-size: 2.1mm; line-height: 1.05; text-align: center; }
.mi-inv { min-height: 16.5mm; display: flex; align-items: center; justify-content: center; font-size: 8mm; font-weight: 800; color: #11263a; text-align: center; overflow-wrap: anywhere; line-height: 1; padding: 0 .5mm; }
.mi-inv.compact { font-size: 5mm; }
.mi-accent { margin: 1.6mm 0 1.8mm; width: 48mm; height: 2px; background: var(--pd-accent); border-radius: 999px; }
.mi-rows { display: grid; gap: 1mm; }
.mi-row { display: grid; border: 1px solid var(--pd-line); border-radius: 3mm; overflow: hidden; background: #fff; }
.mi-label { border-right: 1px solid var(--pd-line); background: #f7fafc; color: #203446; font-size: 3.1mm; line-height: 1.08; font-weight: 700; padding: 1.6mm 1.5mm; display: flex; align-items: center; justify-content: center; text-align: center; }
.mi-value { padding: 1.35mm 2.1mm; }
.mi-build { grid-template-columns: 23mm 1fr; min-height: 12.5mm; }
.mi-build .mi-value { font-size: 4.9mm; line-height: 1.02; font-style: italic; font-weight: 700; white-space: pre-line; }
.mi-build .mi-value.compact { font-size: 4.2mm; }
.mi-contractor { grid-template-columns: 23mm 1fr; min-height: 10.1mm; }
.mi-contractor .mi-value { font-size: 6.1mm; font-weight: 800; display: flex; align-items: center; }
.mi-machine { grid-template-columns: 23mm .82fr 1.18fr; min-height: 31.5mm; }
.mi-machine-left { border-right: 1px solid var(--pd-line); padding: 1.2mm 2mm; }
.mi-section-head { color: #4f6376; font-size: 2.45mm; font-weight: 700; text-transform: uppercase; line-height: 1.05; margin-bottom: .45mm; }
.mi-type { font-size: 5.25mm; line-height: .95; font-weight: 800; color: #0f2438; }
.mi-type.compact { font-size: 4.55mm; }
.mi-machine-sub { margin-top: .2mm; font-size: 4.1mm; line-height: 1.02; font-weight: 700; color: #162d41; }
.mi-machine-right { display: grid; grid-template-rows: auto auto; }
.mi-udt-head { padding: 1.2mm 1.8mm; border-bottom: 1px solid var(--pd-line); color: #42576b; font-size: 2.55mm; line-height: 1.05; font-weight: 700; text-transform: uppercase; }
.mi-udt-numbers { display: flex; align-items: center; gap: .7mm; min-height: 12mm; padding: 0 1.8mm; border-bottom: 1px solid var(--pd-line); white-space: nowrap; overflow: hidden; }
.mi-num { font-size: 4.55mm; line-height: 1; font-weight: 800; white-space: nowrap; }
.mi-num.compact { font-size: 3.95mm; letter-spacing: -0.06mm; }
.mi-slash { font-size: 4.7mm; font-weight: 700; color: #42576b; }
.mi-udt-valid { display: grid; grid-template-columns: 19mm 1fr; min-height: 11.7mm; }
.mi-udt-valid .mi-mini { padding: 1.2mm 1.5mm; display: flex; align-items: center; font-size: 2.8mm; line-height: 1.05; color: #42576b; font-weight: 700; text-transform: uppercase; }
.mi-udt-valid .mi-date { display: flex; align-items: center; justify-content: center; font-size: 5.8mm; font-weight: 800; color: var(--pd-accent); }
.mi-udt-valid .mi-date.over { color: var(--pd-red); }
.mi-dates { grid-template-columns: 23mm 1fr 1fr; min-height: 10mm; }
.mi-date-box { display: grid; grid-template-columns: 9mm 1fr; border-left: 1px solid var(--pd-line); }
.mi-date-box:first-of-type { border-left: 0; }
.mi-date-label, .mi-date-value { display: flex; align-items: center; padding: 1.5mm 1.4mm; }
.mi-date-label { font-size: 3.35mm; color: #42576b; font-weight: 700; }
.mi-date-value { font-size: 3.95mm; font-weight: 800; }
.mi-contact { grid-template-columns: 23mm 1fr 1fr; min-height: 12.3mm; }
.mi-contact-col { padding: 1.2mm 2mm; border-left: 1px solid var(--pd-line); }
.mi-contact-col:first-of-type { border-left: 0; }
.mi-contact-value { white-space: pre-line; font-size: 4.15mm; line-height: 1.06; font-weight: 700; }
.mi-contact-value.compact { font-size: 3.65mm; }
.mi-users { grid-template-columns: 23mm 1fr 1fr 35mm; min-height: 12.1mm; }
.mi-user-col { padding: 1mm 1.5mm; border-left: 1px solid var(--pd-line); }
.mi-user-col:first-of-type { border-left: 0; }
.mi-mini-head { color: #42576b; font-size: 2.2mm; font-weight: 700; text-transform: uppercase; line-height: 1.05; }
.mi-user-value { margin-top: .45mm; white-space: pre-line; font-size: 3.45mm; line-height: 1.04; font-weight: 800; }
.mi-user-value.compact { font-size: 3mm; }
.mi-note { margin-top: 1.15mm; border: 1px solid #bfd2e1; border-radius: 3mm; background: #e7f2fb; color: #455d72; padding: 1.25mm 1.8mm; font-size: 2.45mm; line-height: 1.1; font-style: italic; }

/* ---------- Skrócona karta SDS ---------- */
.sds-icons { display: flex; flex-wrap: wrap; gap: 2mm; align-items: center; }
.sds-icons figure { margin: 0; text-align: center; width: 20mm; font-size: 8.5px; color: var(--pd-muted); line-height: 1.1; }
.sds-icons img { width: 17mm; height: 17mm; object-fit: contain; display: block; margin: 0 auto 1mm; }
.sds-signal { display: inline-block; font-weight: 800; font-size: 14px; padding: 1mm 4mm; border-radius: 2mm; background: #fee2e2; color: var(--pd-red); border: 2px solid var(--pd-red); text-transform: uppercase; }
.sds-signal.warning { background: #fef3c7; color: var(--pd-amber); border-color: var(--pd-amber); }
.sds-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 3mm; }
.sds-sec { border: 1px solid var(--pd-soft); border-radius: 2.5mm; overflow: hidden; break-inside: avoid; }
.sds-sec h3 { margin: 0; padding: 1.5mm 3mm; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #fff; background: var(--pd-brand); }
.sds-sec.red h3 { background: var(--pd-red); }
.sds-sec.green h3 { background: var(--pd-green); }
.sds-sec.amber h3 { background: var(--pd-amber); }
.sds-sec div { padding: 2mm 3mm; white-space: pre-line; font-size: 11px; }
.sds-emergency { margin-top: 3mm; display: flex; gap: 4mm; flex-wrap: wrap; font-weight: 700; border: 2px solid var(--pd-red); border-radius: 2.5mm; padding: 2mm 3mm; }

/* ---------- Plakat QR (karty SDS budowy, katalog instrukcji ŚOI) ---------- */
.poster { text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: space-between; }
.poster .pd-title { font-size: 34px; margin-top: 10mm; }
.poster .poster-lead { font-size: 18px; color: #334155; max-width: 150mm; margin: 4mm auto; }
.poster .poster-site { font-size: 26px; font-weight: 800; color: var(--pd-brand); margin-top: 6mm; }
.poster [data-qr] { display: inline-block; padding: 6mm; border: 3mm solid #12202d; border-radius: 6mm; margin: 8mm auto; background: #fff; }
.poster [data-qr] img, .poster [data-qr] canvas { width: 110mm !important; height: 110mm !important; }
.poster .poster-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4mm; text-align: left; font-size: 13px; width: 100%; }
.poster .poster-steps div { border: 1px solid var(--pd-soft); border-radius: 3mm; padding: 3mm; }
.poster .poster-steps b { display: block; font-size: 22px; color: var(--pd-accent); }
.poster .poster-url { font-family: monospace; font-size: 11px; color: var(--pd-muted); word-break: break-all; margin-top: 4mm; }

/* ---------- Karta ewidencyjna ŚOI pracownika ---------- */
.pc-person { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2mm; margin-top: 4mm; }
.pc-sizes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2mm; margin-top: 2mm; }
.pd-table td.sig { width: 28mm; }

@media print {
  body.print-doc { background: #fff; }
  .pd-toolbar { display: none !important; }
  .pd-sheet { margin: 0; padding: 0; box-shadow: none; width: auto; min-height: 0; }
  .pd-sheet + .pd-sheet { break-before: page; page-break-before: always; margin-top: 0; }
  .page-a5l body, body.page-a5l { width: 210mm; }
  .mi-sheet { margin: 0 !important; background: #fff; }
  a { color: inherit; text-decoration: none; }
}
@media print { .no-print { display: none !important; } }

/* Podgląd na telefonie (np. karta SDS otwarta z kodu QR) – arkusz dopasowany do szerokości ekranu */
@media screen and (max-width: 820px) {
  .pd-sheet, .page-a5 .pd-sheet, .page-a4l .pd-sheet { width: auto; min-height: 0; margin: 8px; padding: 14px; }
  .pd-head, .pd-logo-title { flex-wrap: wrap; }
  .pd-logo-title > div { min-width: 0; }
  .pd-title { font-size: 17px !important; }
  .pd-h1 { font-size: 18px; }
  .pd-grid, .page-a4l .pd-grid, .sds-cols, .pd-sign { grid-template-columns: 1fr !important; }
  .pc-person, .pc-sizes { grid-template-columns: 1fr 1fr !important; }
  .pd-sheet > div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  .pd-table { font-size: 10px; }
  .pd-hint { display: none; }
  .poster [data-qr] img, .poster [data-qr] canvas { width: 70vw !important; height: 70vw !important; }
  .poster .poster-steps { grid-template-columns: 1fr; }
  .mi-sheet { transform-origin: top left; }
}

/* ---------- Etykiety magazynowe 62 × 29 mm ---------- */
.wh-labels { display: grid; grid-template-columns: repeat(auto-fill, 62mm); gap: 3mm; }
.wh-label { width: 62mm; height: 29mm; border: 1px dashed #94a3b8; border-radius: 1.5mm; padding: 1.5mm; display: flex; gap: 2mm; align-items: center; overflow: hidden; break-inside: avoid; background: #fff; }
.wh-label [data-qr] img, .wh-label [data-qr] canvas { width: 25mm !important; height: 25mm !important; display: block; }
.wh-label__txt { display: flex; flex-direction: column; gap: .8mm; min-width: 0; line-height: 1.1; }
.wh-label__txt strong { font-size: 10.5px; overflow-wrap: anywhere; }
.wh-label__size { font-size: 10px; }
.wh-label__size b { font-size: 13px; }
.wh-label__meta { font-size: 8.5px; color: #475569; font-family: monospace; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
/* Diagram Ishikawy (A4 poziomo) */
.ishikawa-sheet { width: 277mm; margin: 12px auto; background: #fff; padding: 4mm; }
.ishikawa-figure svg { width: 100%; height: auto; display: block; }
.ishikawa-note { margin: 4mm 2mm 0; font: 11pt/1.4 Arial, Helvetica, sans-serif; color: #15191E; white-space: pre-line; }
/* Raport z wpisu (A4): nagłówek firmy, treść z edytora, stopka na każdej stronie */
.rep-sheet { width: 190mm; margin: 12px auto; background: #fff; padding: 8mm 10mm 18mm; font: 10.5pt/1.5 Arial, Helvetica, sans-serif; color: #15191E; }
.rep-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8mm; padding-bottom: 3mm; border-bottom: 1.5mm solid #FFC400; }
.rep-logo { height: 14mm; width: auto; object-fit: contain; }
.rep-head__meta { text-align: right; font-size: 9pt; line-height: 1.45; }
.rep-head__company { font-weight: 700; font-size: 11pt; }
.rep-title { font-size: 16pt; line-height: 1.25; margin: 5mm 0 4mm; }
.rep-body h1, .rep-body h2 { font-size: 12.5pt; margin: 5mm 0 2mm; padding-bottom: 1mm; border-bottom: .3mm solid #BFC5BE; break-after: avoid; }
.rep-body h3 { font-size: 11pt; margin: 4mm 0 1.5mm; break-after: avoid; }
.rep-body h4 { font-size: 10.5pt; margin: 3mm 0 1mm; }
.rep-body p { margin: 0 0 2mm; }
.rep-body ul { list-style: disc; padding-left: 6mm; margin: 0 0 2mm; }
.rep-body ol { list-style: decimal; padding-left: 6mm; margin: 0 0 2mm; }
.rep-body table { width: 100%; border-collapse: collapse; margin: 1mm 0 3mm; font-size: 9.5pt; }
.rep-body th, .rep-body td { border: .3mm solid #8D959C; padding: 1.5mm 2mm; text-align: left; vertical-align: top; }
.rep-body th { background: #ECEEEB; width: 32%; }
.rep-body tr:first-child th + th { width: auto; }
.rep-body tr { break-inside: avoid; }
.rep-body blockquote { border-left: 1.2mm solid #FFC400; padding-left: 3mm; margin: 2mm 0; font-style: italic; color: #3A424B; }
.rep-body a { color: #0B5CAD; }
.rep-foot { display: flex; justify-content: space-between; gap: 4mm; margin-top: 8mm; padding-top: 2mm; border-top: .3mm solid #BFC5BE; font-size: 8pt; color: #5C6670; }
@media print {
  .rep-sheet { width: auto; margin: 0; padding: 0 0 12mm; }
  .rep-foot { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; }
}
