/* A4 work order sheet. Tuned to fit one A4 page; readable on screen too. */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 10pt;
  color: #111;
}

@page { size: A4; margin: 10mm; }

.sheet { max-width: 186mm; margin: 0 auto; padding: 8mm; }
@media print { .sheet { padding: 0; } }

/* Header */
.head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #111; padding-bottom: 3px; margin-bottom: 5px; }
/* 11.5pt keeps the long title ("Arbeitsauftrag & Gefährdungsbeurteilung
   Obstbaumpflege") on one line next to the QR code and photo. */
.head h1 { font-size: 11.5pt; margin: 0 0 2px; }
.tree-id { font-size: 10pt; color: #333; display: flex; gap: 4mm; flex-wrap: wrap; }
/* Ids must not break across lines — a hyphenated "m4p-dq" is unreadable and
   unsearchable. */
.tree-id > span { white-space: nowrap; }

/* Tree sheet header: finding the sheet that belongs to a tree is the job the
   stack of printouts has to do, so the Blatt number (= the number on the map
   and in the Baumliste) is the biggest thing on the page. The document kind
   repeats on every sheet and carries no information — it goes small. */
/* One number at each outer edge: fanning a stack of sheets exposes either the
   left or the right margin, and the number has to be readable from both. */
.sheet-nr { flex: 0 0 auto; text-align: center; line-height: 1; }
.head > .sheet-nr:first-child { margin-right: 4mm; }
.head > .sheet-nr:last-child { margin-left: 4mm; }
.sheet-nr span { display: block; font-size: 34pt; font-weight: 700; letter-spacing: -.02em; }
.sheet-nr small { display: block; font-size: 7pt; color: #666; letter-spacing: .08em; text-transform: uppercase; }
.doc-kind { font-size: 8.5pt; color: #666; }
.head h1.tree-name { font-size: 14pt; margin: 1px 0 2px; line-height: 1.15; }
.head-media { display: flex; gap: 5px; align-items: flex-start; }
.qr { width: 18mm; height: 18mm; border: 1px solid #ccc; }
.tree-photo { width: 23mm; height: 23mm; object-fit: cover; border: 1px solid #999; }

/* Panels */
.panel { border: 1px solid #bbb; border-radius: 3px; padding: 4px 7px; margin-bottom: 3px; }
.panel h2 { font-size: 9.5pt; margin: 0 0 3px; text-transform: uppercase; letter-spacing: .04em; color: #222; border-bottom: 1px solid #ddd; padding-bottom: 2px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.grid-2 .panel { margin-bottom: 0; }

/* Key/value tables */
table.kv { width: 100%; border-collapse: collapse; }
/* Labels are short and are followed by their value — a wrapped label ("Zugang
   zu Fuß" breaks in Safari) just costs a line and reads worse. */
table.kv th { text-align: left; font-weight: 600; color: #444; width: 38%; padding: 1px 6px 1px 0; vertical-align: top; font-size: 9pt; white-space: nowrap; }
table.kv td { padding: 1px 0; vertical-align: top; }

.map { width: 100%; height: 30mm; object-fit: cover; border: 1px solid #999; margin-top: 5px; }
/* Overview maps are shown whole (contain) — cropping could hide a marker. */
.map-wide { width: 100%; height: 60mm; object-fit: contain; border: 1px solid #999; display: block; }
.map-trees { width: 100%; height: 128mm; object-fit: contain; border: 1px solid #999; display: block; }
.map-caption { font-size: 8.5pt; color: #666; margin: 3px 0 8px; line-height: 1.5; }
/* Legend swatch for a tree with a note: violet dot inside a violet ring. */
.mk-note { display: inline-block; width: 11px; height: 11px; border-radius: 50%;
  background: #6a1b9a; box-shadow: 0 0 0 1.5px #fff, 0 0 0 3px #6a1b9a; margin: 0 5px 0 2px; vertical-align: -1px; }
.map-panel { display: flex; padding: 4px; }
/* The map is the largest single block on the sheet, so its height decides
   whether the sheet survives a browser that prints with generous margins
   (Safari defaults to ~1 inch plus header/footer). 58mm keeps the whole sheet
   under ~215mm even with a note — small enough for those, and still a usable
   locator. */
.map-big { width: 100%; object-fit: cover; border: 1px solid #999; border-radius: 2px; align-self: stretch; min-height: 65mm; }
table.kv-2col th { width: 20%; }
table.kv-2col td { width: 30%; }

/* Handwriting field rows */
.fields-row { display: flex; flex-wrap: wrap; gap: 7px 16px; }
.fields-row label { display: inline-flex; align-items: flex-end; gap: 6px; font-weight: 600; color: #333; }
.blank { display: inline-block; border-bottom: 1px solid #333; min-width: 32mm; height: 1.1em; }
/* A field that eats the rest of its row (e.g. Personen). */
.fields-row label.grow { flex: 1 1 auto; }
.fields-row label.grow .blank { flex: 1 1 auto; min-width: 70mm; }
.blank.sm { min-width: 18mm; }
.blank.wide { min-width: 130mm; }

/* Hazard checklist. 9pt packs more boxes per line, which keeps both sheets
   on one page; the labels stay legible at arm's length. */
.hazard { font-size: 9pt; }
.hazard .prefill { margin: 0 0 3px; font-size: 9pt; color: #333; }
.hz-block { margin: 2px 0; line-height: 1.32; }
.hz-label { font-weight: 700; margin-right: 6px; }
.cb { display: inline-block; margin-right: 9px; white-space: nowrap; }
.box { display: inline-block; width: 10px; height: 10px; border: 1.3px solid #111; margin-right: 3px; vertical-align: -1px; }
.box.big { width: 16px; height: 16px; border-width: 1.5px; }
.muted { color: #888; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 3px; }
.mk { display: inline-block; width: 15px; height: 15px; line-height: 15px; text-align: center; border-radius: 50%;
  color: #fff; font-size: 8pt; font-weight: 700; vertical-align: -2px; margin-right: 3px; }
.mk-park { background: #1e7d32; } .mk-foot { background: #1565c0; } .mk-drive { background: #ef6c00; }
/* Map legend under the overview map: each entry stays on one line. */
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 8pt; margin-top: 3px; }
.legend > span { white-space: nowrap; }
.verdict .hz-label { color: #000; }
.hz-remark { margin: 4px 0 1px; }
.person-block { margin-top: 6px; }
.person-head { font-weight: 600; color: #333; margin-bottom: 4px; }
.pline { margin: 5px 0; }

/* WO-Bogen (cover) extras */
table.wo-trees th, table.wo-trees td { width: auto; font-size: 9pt; padding: 2px 8px 2px 0; border-bottom: 1px solid #f0f0ee; }
table.wo-trees th { color: #666; font-weight: 600; border-bottom: 1px solid #ddd; }
table.wo-trees tr.no-border td { border-bottom: none; }
/* Notes carry the reason a tree needs attention — bold so they are not read
   past when working down the list. */
table.wo-trees td.row-note { font-size: 8.5pt; font-weight: 700; color: #111; white-space: pre-line; padding-bottom: 4px; }

/* A tree whose data could not be fetched. Loud on purpose: the sheet is in the
   stack and looks like the others, so it has to say why it is empty. */
.fail-panel { border: 2px solid #b5342b; }
.fail-panel h2 { color: #b5342b; border-bottom-color: #e6bdb9; }
.fail-panel p { margin: 2px 0; }
.fail-panel .fail-id { font-size: 9pt; color: #444; }
table.wo-trees td.row-fail { font-size: 8.5pt; font-weight: 700; color: #b5342b; padding-bottom: 4px; }

/* Per-tree note on the TO sheet */
.note-panel { border-color: #888; }
.tree-note { white-space: pre-line; font-size: 9.5pt; line-height: 1.35; }
.hazard .notes { font-size: 9.5pt; }
/* Notes are prose in a dense sheet: smaller and tighter than on screen, so a
   longer note still fits before the cover runs onto a second page. */
.notes { font-size: 9pt; line-height: 1.4; margin-top: 2px; }
.notes > :first-child { margin-top: 0; }
.notes p { margin: .25em 0; }
.notes ul, .notes ol { margin: .25em 0; padding-left: 1.3em; }
.sign-row { display: flex; gap: 24px; margin-top: 14px; }
.sign { flex: 1; font-size: 9pt; color: #444; }
.sign-line { display: block; border-top: 1px solid #333; margin-bottom: 3px; height: 22px; }

.foot { margin-top: 5px; font-size: 8pt; color: #777; text-align: center; }

@media print {
  .panel { break-inside: avoid; }
  .grid-2 { break-inside: avoid; }
}
