/* Inspection reports, QR stations, scanner, sketch pad, labels. Phone first (390px), colors from app.css variables. */

/* ---------- list + start ---------- */
.rf-filters { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; margin-bottom: 12px; }
.rf-filters select { width: auto; }
.rf-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.rf-pick { display: grid; gap: 6px; text-decoration: none; color: var(--ink); }
.rf-pick + .rf-pick { margin-top: 0; }
.rf-pick:hover { border-color: var(--brand-2); }
.rf-pick-top { display: flex; align-items: center; gap: 8px; justify-content: space-between; font-size: 1.05rem; }
.rf-results { margin: -6px 0 10px; max-height: 320px; overflow: auto; }
.rf-result { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line-2); text-align: left; font: inherit; color: var(--ink); cursor: pointer; }
.rf-oneoff { margin-top: 6px; }
.rf-oneoff summary { cursor: pointer; font-weight: 600; color: var(--brand-2); padding: 8px 0; min-height: var(--tap); display: flex; align-items: center; }
.rf-small { font-size: 13.5px; }
.rf-sub { margin: -8px 0 10px; }

/* ---------- fill in ---------- */
.rf-prog { position: sticky; top: 58px; z-index: 6; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 12px 0; box-shadow: var(--shadow); }
.rf-prog-row { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.rf-prog-row .spacer { flex: 1; }
.rf-save { font-size: 13px; color: var(--ink-3); white-space: nowrap; }
.rf-save.ok { color: var(--good); } .rf-save.bad { color: var(--bad); }
.rf-chips { display: flex; gap: 6px; overflow-x: auto; margin-top: 8px; padding-bottom: 2px; scrollbar-width: thin; }
.rf-chip { flex: none; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.rf-chip.ok { background: var(--good-bg); color: var(--good); }
.rf-chip.todo { background: var(--warn-bg); color: var(--warn); }
.rf-sec { scroll-margin-top: 150px; }
.rf-sec h2 { display: flex; align-items: center; gap: 6px; }
.rf-req { color: var(--bad); }
.rf-field > label { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.rf-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.rf-seg button { min-height: var(--tap); min-width: 64px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: 600 15px var(--font); cursor: pointer; }
.rf-seg button.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.rf-seg button:disabled { opacity: .7; cursor: default; }
.rf-table { display: grid; gap: 8px; }
.rf-trow { border: 1px solid var(--line-2); border-radius: var(--radius-s); padding: 8px 10px; background: var(--surface-2); min-width: 0; }
.rf-trow-l { display: block; margin-bottom: 6px; }
.rf-trow-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.rf-trow-head .spacer { flex: 1; }
.rf-tcells { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.rf-cell { min-width: 0; }
@media (min-width: 900px) { .rf-trow-fixed { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 10px; align-items: center; } .rf-trow-fixed .rf-trow-l { margin: 0; } }
.rf-cell-l { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-3); margin-bottom: 2px; }
.rf-cell-multi, .rf-cell-textarea { grid-column: 1 / -1; }
.rf-cell .rf-seg button { min-width: 52px; min-height: 40px; padding: 0 10px; }
.rf-cell select, .rf-cell input { min-height: 40px; }
.rf-sigbox { display: grid; gap: 8px; justify-items: start; }
.rf-sigimg { max-width: min(100%, 360px); height: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.rf-diag { display: grid; gap: 8px; justify-items: start; }
.rf-diagimg { width: 100%; max-width: 640px; height: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.rf-diag-empty { width: 100%; max-width: 640px; aspect-ratio: 10 / 7; display: flex; align-items: center; justify-content: center; border: 2px dashed var(--line); border-radius: 8px; color: var(--ink-3); }
.rf-photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 10px; }
.rf-photo-grid figure { margin: 0; position: relative; display: grid; gap: 4px; }
.rf-photo-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.rf-photo-grid input { min-height: 36px; padding: 4px 8px; font-size: 14px; }
.rf-photo-grid .btn { position: absolute; top: 4px; right: 4px; background: var(--surface); }
.rf-missing { padding-left: 18px; }
.rf-missing li { margin: 4px 0; }
.rep-preview { overflow-x: auto; }
@media (max-width: 640px) {
  .rf-filters { grid-template-columns: 1fr 1fr; }
  .rf-filters input[type=search] { grid-column: 1 / -1; }
  .rf-filters .seg { justify-self: start; }
  .rf-prog { top: 58px; padding: 8px 10px; }
  .rf-tcells { grid-template-columns: 1fr 1fr; }
  .rf-cell-text, .rf-cell-choice { grid-column: 1 / -1; }
}

/* ---------- the report document (screen + print) ---------- */
.rep-doc { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; max-width: 900px; margin: 0 auto; font-size: 14px; line-height: 1.4; }
.rep-doc .doc-head { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: start; border-bottom: 2px solid var(--ink); padding-bottom: 12px; margin-bottom: 12px; }
.rep-doc .doc-logo { max-height: 72px; max-width: 150px; object-fit: contain; }
.rep-doc .doc-co { font-size: 13px; color: var(--ink-2); }
.rep-doc .doc-co-name { font-size: 17px; font-weight: 800; color: var(--ink); }
.rep-doc .doc-lic { font-weight: 600; }
.rep-doc .doc-title { text-align: right; max-width: 300px; }
.rep-doc .doc-title-main { font-size: 16px; font-weight: 800; }
.rep-doc .doc-title-meta { color: var(--ink-3); font-size: 13px; margin-top: 4px; }
.rd-draft { background: var(--warn-bg); color: var(--warn); font-weight: 800; text-align: center; padding: 6px; border-radius: 6px; margin-bottom: 10px; letter-spacing: .02em; }
.rd-meta { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 14px; }
.rd-meta b { display: block; }
.rd-k { display: block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-3); }
.rd-sec { margin-bottom: 14px; break-inside: auto; }
.rd-sec h3 { font-size: 14.5px; background: var(--surface-2); padding: 5px 8px; border-left: 4px solid var(--brand); margin: 0 0 8px; break-after: avoid; }
.rd-kvs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; margin-bottom: 8px; }
.rd-kv { display: flex; gap: 8px; justify-content: space-between; border-bottom: 1px dotted var(--line); padding: 3px 0; break-inside: avoid; }
.rd-kv .rd-k { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.rd-v { text-align: right; font-weight: 600; }
.rd-yn { display: inline-flex; gap: 12px; white-space: nowrap; }
.rd-block { margin: 6px 0 10px; break-inside: avoid; }
.rd-label { font-weight: 700; font-size: 13px; color: var(--ink-2); margin-bottom: 4px; }
.rd-para { white-space: pre-wrap; border: 1px solid var(--line-2); border-radius: 6px; padding: 6px 8px; min-height: 28px; }
.rd-checks { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.rd-check { display: inline-flex; align-items: center; gap: 4px; }
.rd-box { display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border: 1.5px solid var(--ink-2); font-size: 11px; line-height: 1; font-weight: 800; flex: none; }
.rd-box.on { color: var(--ink); border-color: var(--ink); }
.rd-table-wrap { overflow-x: auto; }
.rd-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rd-table th, .rd-table td { border: 1px solid var(--line); padding: 4px 6px; text-align: left; vertical-align: top; }
.rd-table thead th { background: var(--surface-2); font-size: 12px; }
.rd-table tbody th { font-weight: 600; white-space: nowrap; }
.rd-table .num { text-align: right; }
.rd-table tr { break-inside: avoid; }
.rd-diagram img { width: 100%; max-width: 760px; border: 1px solid var(--line); background: #fff; display: block; }
.rd-legend { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.rd-empty { border: 1px dashed var(--line); padding: 20px; text-align: center; color: var(--ink-3); }
.rd-photos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.rd-photos figure { margin: 0; break-inside: avoid; }
.rd-photos img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border: 1px solid var(--line); display: block; }
.rd-photos figcaption { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.rd-sigs { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-top: 8px; }
.rd-sig { break-inside: avoid; }
.rd-sig img { max-width: 100%; height: 64px; object-fit: contain; object-position: left bottom; display: block; background: #fff; }
.rd-sig-blank { height: 64px; }
.rd-sig-line { border-top: 1.5px solid var(--ink); font-size: 12px; color: var(--ink-2); padding-top: 3px; }
.rd-approved { font-weight: 600; }
.rd-notes { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; color: var(--ink-2); break-inside: avoid; }
.rd-notes h3 { font-size: 13px; margin: 0 0 6px; color: var(--ink); }
.rd-notes p { margin: 0 0 6px; }
.rd-foot { margin-top: 14px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-3); font-style: italic; }
@media (max-width: 640px) {
  .rep-doc { padding: 12px; border-radius: 8px; }
  .rep-doc .doc-head { grid-template-columns: 1fr; }
  .rep-doc .doc-title { text-align: left; max-width: none; }
  .rd-meta { grid-template-columns: 1fr 1fr; }
  .rd-kvs { grid-template-columns: 1fr; }
  .rd-photos { grid-template-columns: 1fr 1fr; }
}

/* public share page */
.rep-public main { max-width: 960px; }
.rep-pub-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 auto 12px; max-width: 900px; font-size: 14px; color: var(--ink-2); }
.rep-pub-bar .spacer { flex: 1; }
.rep-pub-msg { max-width: 480px; margin: 12vh auto 0; text-align: center; }

/* ---------- sketch pad ---------- */
body.sk-open { overflow: hidden; }
.sk-back { position: fixed; inset: 0; z-index: 95; background: rgba(10, 20, 17, .55); display: flex; align-items: stretch; justify-content: center; }
.sk-box { background: var(--surface); width: min(1100px, 100vw); max-height: 100vh; overflow: auto; padding: 10px 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.sk-bar, .sk-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sk-bar .spacer, .sk-tools .spacer { flex: 1; }
.sk-title { font-size: 1.05rem; }
.sk-tool.on, .sk-stamp.on { background: var(--brand-3); border-color: var(--brand-2); }
.sk-stamps { display: flex; flex-wrap: wrap; gap: 6px; }
.sk-stamp b { font-size: 16px; }
.sk-hint { font-size: 13px; color: var(--ink-3); }
.sk-stage { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; touch-action: none; }
.sk-canvas { display: block; width: 100%; height: auto; touch-action: none; cursor: crosshair; }
@media (min-width: 700px) { .sk-back { align-items: center; } .sk-box { border-radius: 14px; max-height: 96vh; } }
@media (max-width: 560px) { .sk-stamp span { display: none; } }

/* ---------- QR scanner ---------- */
.qs-back { position: fixed; inset: 0; z-index: 96; background: #000; color: #fff; display: flex; flex-direction: column; }
.qs-top { display: flex; align-items: center; gap: 8px; padding: 10px 14px; }
.qs-top .spacer { flex: 1; }
.qs-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.qs-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.qs-frame { position: absolute; left: 50%; top: 50%; width: min(64vw, 280px); aspect-ratio: 1; transform: translate(-50%, -50%); border: 3px solid rgba(255, 255, 255, .9); border-radius: 18px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .35); }
.qs-msg { padding: 12px 16px; font-weight: 600; text-align: center; }
.qs-form { padding: 6px 16px 22px; max-width: 520px; width: 100%; margin: 0 auto; }
.qs-form label { color: #e6eef5; }
.qs-row { display: flex; gap: 8px; }
.qs-row input { text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.qs-row .btn { flex: none; }
.qs-back .hidden + .qs-msg { margin-top: 20vh; font-size: 1.05rem; }

/* ---------- stations ---------- */
.st-scan { max-width: 560px; margin: 0 auto; text-align: center; }
.st-scan form { text-align: left; margin-top: 12px; }
.st-scan-btn { width: 100%; margin-bottom: 10px; }
.st-head { display: grid; gap: 6px; }
.st-loc { font-weight: 600; }
.st-check label { margin-top: 10px; }
.st-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.st-pick-activity { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.st-pick-consumedPct { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.st-checks .row .main b, .st-checks .row .main small { white-space: normal; }
.st-opt { min-height: 54px; min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); font: 700 16px var(--font); cursor: pointer; padding: 0 8px; }
.st-opt.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.st-activity-high.on { background: var(--bad); border-color: var(--bad); color: #fff; }
.st-activity-medium.on { background: var(--warn); border-color: var(--warn); color: var(--bg); }
.st-save { width: 100%; margin-top: 14px; }
.st-next { margin: 12px 0; }
.st-next .btn { flex: 1 1 200px; }
.st-row .st-num { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-3); color: var(--brand); font-weight: 800; display: flex; align-items: center; justify-content: center; flex: none; }
.st-row .main { text-decoration: none; color: var(--ink); }
.st-row.off { opacity: .6; }
.st-add { display: grid; grid-template-columns: 110px 1fr 1.4fr auto; gap: 10px; align-items: end; }
.st-add .field { margin-bottom: 0; }
.st-client { display: flex; gap: 16px; align-items: center; }
.st-qr-preview { width: 120px; height: 120px; background: #fff; border-radius: 8px; flex: none; }
@media (max-width: 640px) {
  .st-add { grid-template-columns: 1fr 1fr; }
  .st-add .field:nth-child(3), .st-add-btn { grid-column: 1 / -1; }
  .st-add-btn .btn { width: 100%; }
  .st-client { flex-direction: column; align-items: flex-start; }
}

/* ---------- QR labels (2" × 1", 3 across × 10 down on letter paper) ---------- */
.qr-sheet { page: labels; display: grid; grid-template-columns: repeat(3, 2in); grid-auto-rows: 1in; gap: 0.03in 0.3in; justify-content: center; background: #fff; color: #000; }
.qr-label { width: 2in; height: 1in; display: flex; align-items: center; gap: 0.05in; padding: 0.05in; border: 1px dashed #bbb; overflow: hidden; break-inside: avoid; font-family: var(--font); }
.qr-img { width: 0.88in; height: 0.88in; flex: none; image-rendering: pixelated; }
.qr-txt { min-width: 0; display: grid; gap: 1px; font-size: 7pt; line-height: 1.15; }
.qr-co { display: flex; align-items: center; gap: 3px; font-weight: 700; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.qr-co img { height: 0.16in; width: auto; max-width: 0.4in; object-fit: contain; }
.qr-big { font-size: 10pt; font-weight: 800; }
.qr-code { font: 800 11pt ui-monospace, Menlo, Consolas, monospace; letter-spacing: .06em; }
.qr-cl { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.qr-sheet-client { grid-template-columns: 3.5in; grid-auto-rows: 2in; }
.qr-client { width: 3.5in; height: 2in; gap: 0.12in; padding: 0.12in; }
.qr-client .qr-img { width: 1.6in; height: 1.6in; }
.qr-client .qr-txt { font-size: 9pt; gap: 3px; }
.qr-client .qr-big { font-size: 13pt; }
.qr-client .qr-cl { white-space: normal; }

/* ---------- printing (kit.printNode puts a clone in .print-holder and adds body.printing) ---------- */
@media screen { body > .print-holder { position: absolute; left: -10000px; top: 0; width: 800px; } }
@media print {
  @page { size: letter; margin: 0.5in; }
  @page labels { size: letter; margin: 0.35in; }
  body.printing > *:not(.print-holder) { display: none !important; }
  body.printing .print-holder { display: block !important; position: static; }
  body.rep-public .no-print { display: none !important; }
  body.rep-public main { padding: 0; max-width: none; }
  .rep-doc, .qr-sheet { --surface: #fff; --surface-2: #f1f4f7; --ink: #000; --ink-2: #222; --ink-3: #444; --line: #9aa4ae; --line-2: #c9d0d6; --brand: #0e7490; --warn-bg: #fff3d6; --warn: #7a4a00; }
  .rep-doc { border: 0; padding: 0; max-width: none; font-size: 10.5pt; box-shadow: none; }
  .rd-photos { grid-template-columns: repeat(3, 1fr); }
  .qr-label { border-color: #eee; }
  .rd-sec h3 { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
