/* Design A — iOS-native checklist. White canvas, system type, plain grouped rows,
   status carried by dots and round controls. Tokens first; everything below uses them. */
:root {
  --bg: #fff;
  --ink: #111714;
  --muted: #7A807C;
  --faint: #C4C7C5;
  --line: #E7E9E7;
  --fill: #F4F5F4;
  --brand: #2E5E4E;
  --brand-ink: #fff;
  --ok: #2E8B57;
  --bad: #D2452B;
  --warn: #C27A0E;
  --na: #A6AAA7;
  --radius: 14px;
  --radius-s: 10px;
  --gutter: 20px;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --t-title: 700 34px/1.1 var(--font);
  --t-h2: 700 22px/1.2 var(--font);
  --t-body: 400 17px/1.35 var(--font);
  --t-sub: 400 15px/1.35 var(--font);
  --t-small: 400 13px/1.3 var(--font);
  --tabs-h: 58px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: var(--t-body);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 28px);
}
main { max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 8px) var(--gutter) 0; }
h1, h2, h3, p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
input, textarea {
  font: var(--t-body); color: var(--ink); width: 100%; min-width: 0; display: block;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 12px;
}
input:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; min-height: 72px; }
input[type=date] { -webkit-appearance: none; appearance: none; min-height: 46px; text-align: left; }
input[type=date]::-webkit-date-and-time-value { text-align: left; }
input[type=checkbox] { display: inline-block; width: 20px; height: 20px; accent-color: var(--brand); flex: none; }
.muted { color: var(--muted); }
.nw { white-space: nowrap; }

/* Navigation bar & titles */
.navbar { display: flex; justify-content: space-between; align-items: center; height: 44px; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--fill); display: inline-grid; place-items: center; flex: none; }
.icon-btn svg { width: 18px; height: 18px; stroke: var(--ink); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.title { font: var(--t-title); letter-spacing: -.02em; color: var(--brand); margin-top: 4px; overflow-wrap: anywhere; }
.subtitle { font: var(--t-sub); color: var(--muted); margin-top: 4px; }
.h2 { font: var(--t-h2); letter-spacing: -.01em; margin: 32px 0 2px; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.h2 a, .h2 button { font: 500 15px/1 var(--font); color: var(--brand); }
.group-label { font: 600 13px/1.3 var(--font); color: var(--muted); margin: 24px 0 0; }
.blurb { font: var(--t-sub); color: var(--muted); margin-top: 8px; }

/* Figures + progress */
.figs { display: grid; grid-template-columns: repeat(3, 1fr); margin: 22px 0 12px; }
.figs > div { padding-left: 12px; border-left: 1px solid var(--line); min-width: 0; }
.figs > div:first-child { padding-left: 0; border: 0; }
.figs b { display: block; font: 700 26px/1.1 var(--font); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.figs span { font: var(--t-small); color: var(--muted); }
.figs .is-bad b { color: var(--bad); }
.bar { height: 4px; border-radius: 2px; background: var(--line); display: flex; overflow: hidden; }
.bar i { display: block; height: 100%; }
.bar .b-ok { background: var(--ok); } .bar .b-bad { background: var(--bad); } .bar .b-na { background: var(--na); }

/* Rows */
.row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); color: inherit; width: 100%; text-align: left; }
.row-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row-sub { display: block; font: var(--t-sub); font-size: 14px; color: var(--muted); margin-top: 2px; }
.row-end { font: var(--t-sub); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; padding-top: 1px; display: flex; align-items: center; gap: 8px; }
.row-end .count-bad { color: var(--bad); font-weight: 600; }
.chev { color: var(--faint); font-size: 20px; line-height: 1; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin: 0 7px 1px 0; vertical-align: middle; flex: none; }
.dot.open { background: var(--bad); } .dot.reported { background: var(--warn); } .dot.fixed { background: var(--ok); }
.row.done .row-main { color: var(--muted); }

/* Check rows */
.check { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--faint); flex: none; display: grid; place-items: center; margin-top: -1px; }
.check svg { width: 14px; height: 14px; stroke: #fff; stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.check.ok { background: var(--ok); border-color: var(--ok); }
.check.defect { background: var(--bad); border-color: var(--bad); }
.check.na { background: var(--na); border-color: var(--na); }
.flag { width: 30px; height: 30px; margin: -3px -4px 0 0; display: grid; place-items: center; flex: none; }
.flag svg { width: 20px; height: 20px; stroke: var(--faint); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.flag.on svg { stroke: var(--bad); fill: var(--bad); }
.item { scroll-margin-top: calc(env(safe-area-inset-top) + 12px); }
.item .row-main { cursor: pointer; }
.item.s-na .item-title { color: var(--muted); }
.item-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font: var(--t-small); color: var(--muted); margin-top: 3px; }
.item-meta .st-open { color: var(--bad); } .item-meta .st-reported { color: var(--warn); } .item-meta .st-fixed { color: var(--ok); }
.item.open { background: var(--fill); margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter); }
.item.open .row { border-bottom: 0; }
.item-body { padding: 0 0 16px 38px; border-bottom: 1px solid var(--line); }
.item-title { font-weight: 400; }
.item.open .item-title { font-weight: 600; }
.text-tabs { display: flex; gap: 18px; font: 600 15px/1 var(--font); color: var(--muted); margin: 0 0 12px; }
.text-tabs button { padding: 2px 0 6px; color: var(--muted); }
.text-tabs button.on { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }
.text-tabs button.on[data-ds=open] { color: var(--bad); box-shadow: inset 0 -2px 0 var(--bad); }
.text-tabs button.on[data-ds=reported] { color: var(--warn); box-shadow: inset 0 -2px 0 var(--warn); }
.text-tabs button.on[data-ds=fixed] { color: var(--ok); box-shadow: inset 0 -2px 0 var(--ok); }
.spa-line { font: var(--t-small); color: var(--brand); margin: 0 0 8px; }
.hint { font: var(--t-sub); color: var(--muted); margin: 0 0 10px; }
.field-label { display: block; font: 600 13px/1.3 var(--font); color: var(--muted); margin: 12px 0 6px; }
.photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.photos .ph, .photos .add { width: 68px; height: 68px; border-radius: var(--radius-s); overflow: hidden; position: relative; flex: none; }
.photos .ph img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.photos .ph.pending img { opacity: .55; }
.photos .add { border: 1.5px dashed var(--faint); display: grid; place-items: center; cursor: pointer; }
.photos .add svg { width: 22px; height: 22px; stroke: var(--brand); fill: none; stroke-width: 1.8; }
.photos .add input { display: none; }
.item-actions { display: flex; gap: 18px; margin-top: 12px; font: 500 15px/1 var(--font); }
.item-actions button { color: var(--brand); }
.item-actions .danger { color: var(--bad); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 50px; padding: 0 18px; border-radius: var(--radius); font: 600 17px/1 var(--font); background: var(--fill); color: var(--ink); }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.btn:active { transform: scale(.98); }
.link-btn { font: 500 15px/1.2 var(--font); color: var(--brand); padding: 6px 0; }
.fab { position: fixed; right: max(var(--gutter), calc(50% - 320px + var(--gutter))); bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px); z-index: 15; height: 52px; padding: 0 20px 0 16px; border-radius: 26px; background: var(--brand); color: var(--brand-ink); font: 600 16px/1 var(--font); display: flex; align-items: center; gap: 8px; box-shadow: 0 6px 18px rgba(46, 94, 78, .35); }
.fab svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; }

/* Add-item row */
.add-row { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.add-row .plus { width: 26px; height: 26px; border-radius: 50%; border: 1.5px dashed var(--faint); flex: none; }
.add-row input { border: 0; padding: 4px 0; border-radius: 0; }
.add-row input:focus { outline: 0; }

/* Filter tabs */
.filter-tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--line); margin-top: 14px; overflow-x: auto; scrollbar-width: none; }
.filter-tabs button { padding: 10px 0; font: 600 15px/1 var(--font); color: var(--muted); white-space: nowrap; }
.filter-tabs button.on { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }

/* Defect rows */
.drow { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); color: inherit; }
.drow .thumb { width: 72px; height: 72px; border-radius: 12px; background: var(--fill) center/cover; flex: none; display: grid; place-items: center; }
.drow .thumb svg { width: 24px; height: 24px; stroke: var(--faint); fill: none; stroke-width: 1.6; }
.drow-title { font-weight: 600; overflow-wrap: anywhere; }
.drow-status { font: var(--t-sub); font-size: 14px; margin-top: 6px; }

/* Empty state */
.empty { padding: 48px 8px; text-align: center; color: var(--muted); font: var(--t-sub); }

/* Contacts */
.contacts { margin-top: 4px; }
.contact { padding: 14px 0; border-bottom: 1px solid var(--line); }
.contact-head b { display: block; font-weight: 600; }
.contact-head span { display: block; font: var(--t-sub); font-size: 14px; color: var(--muted); margin-top: 2px; }
.contact-app { font: var(--t-sub); font-size: 14px; margin-top: 6px; }
.contact-actions { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font: 500 15px/1.3 var(--font); }
.contact-actions a { overflow-wrap: anywhere; }

/* Tip */
.note-block { font: var(--t-sub); color: var(--muted); padding: 14px 0; border-bottom: 1px solid var(--line); }
.note-block b { color: var(--ink); font-weight: 600; display: block; margin-bottom: 2px; }

/* Setup */
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; margin: 20px 0 4px; }
.facts dt { font: var(--t-small); color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; }
.check-row { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }

/* Tab bar */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around; background: rgba(255, 255, 255, .94); backdrop-filter: saturate(1.8) blur(14px); -webkit-backdrop-filter: saturate(1.8) blur(14px); border-top: 1px solid var(--line); padding: 6px 0 calc(6px + env(safe-area-inset-bottom)); }
.tabs a { position: relative; flex: 0 1 120px; display: flex; flex-direction: column; align-items: center; gap: 3px; font: 600 11px/1 var(--font); color: var(--muted); padding: 4px; }
.tabs a.on { color: var(--brand); }
.tabs svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabs .badge { position: absolute; top: 0; left: calc(50% + 6px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--bad); color: #fff; font: 600 11px/18px var(--font); text-align: center; padding: 0 5px; }

/* Sync status */
.sync { position: fixed; top: calc(env(safe-area-inset-top) + 8px); left: 50%; transform: translateX(-50%); z-index: 30; background: var(--ink); color: #fff; font: 600 13px/1.3 var(--font); padding: 8px 14px; border-radius: 12px; box-shadow: 0 4px 14px rgba(0, 0, 0, .15); max-width: calc(100% - 32px); text-align: center; }
.sync.offline { background: var(--warn); }

/* Photo viewer */
.viewer { position: fixed; inset: 0; z-index: 50; background: rgba(8, 10, 9, .95); display: flex; flex-direction: column; animation: fade .15s ease-out; }
.viewer img { flex: 1; min-height: 0; object-fit: contain; width: 100%; }
.viewer .bar-top { display: flex; justify-content: space-between; padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; }
.viewer .bar-top button { color: #fff; font: 600 16px/1 var(--font); padding: 10px 4px; }

/* Bottom sheet */
body.noscroll { overflow: hidden; }
.sheet-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(17, 23, 20, .4); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out; }
.sheet { width: 100%; max-width: 640px; background: var(--bg); border-radius: 18px 18px 0 0; padding: 8px var(--gutter) calc(20px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto; animation: up .22s cubic-bezier(.2, .8, .2, 1); }
.sheet .grab { width: 36px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.sheet h2 { font: var(--t-h2); margin-bottom: 6px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions .btn { flex: 1; }
.choice-list { margin-top: 8px; }
.choice-list button { display: flex; width: 100%; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); text-align: left; }
.choice-list button > span { display: block; }
.choice-list button b { font-weight: 600; }
.choice-list button > span > span, .choice-list button > span:only-child + span { font: var(--t-sub); font-size: 14px; color: var(--muted); display: block; margin-top: 2px; }
.choice-list button.on::after { content: ''; width: 10px; height: 6px; border: solid var(--brand); border-width: 0 0 2.5px 2.5px; transform: rotate(-45deg); margin-right: 4px; flex: none; }
.choice-list .danger b { color: var(--bad); }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Print: the PDF is generated server-side; keep screen chrome out of any browser print. */
@media print { .tabs, .sync, .fab, .navbar { display: none !important; } }

/* Collapsible list group */
details.more-numbers > summary { list-style: none; cursor: pointer; }
details.more-numbers > summary::-webkit-details-marker { display: none; }
details.more-numbers[open] > summary .chev { transform: rotate(90deg); display: inline-block; }

.note-preview { color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
