@font-face {
  font-family: "DM Sans";
  src: url("fonts/dm-sans-latin-wght-normal.woff2") format("woff2-variations"),
       url("fonts/dm-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 1000;
  font-style: normal;
  font-display: swap;
}

/* ------------------------------------------------------------------ tokens
   Coombes identity (coombesgroup.com): near-black, white, warm grey, web orange, amber.
   Answer states keep safety-sign meaning: green Yes, red No, amber warning. */
:root {
  --ground: #f2f1ef;
  --face: #ffffff;
  --face-muted: #f7f6f4;
  --ink: #101012;
  --ink-2: #5e5e60;
  --rule: #8a8a8c;
  --rule-soft: #d1d1d1;
  --brand-black: #101012;
  --brand-orange: #e84e1b;
  --brand-amber: #f39200;
  --on-orange: #ffffff;
  --safe: #007a3d;
  --stop: #c8102e;
  --warning: #f39200;
  --on-state: #ffffff;
  --on-warning: #101012;
  --stop-tint: #fcecee;
  --safe-tint: #eaf5ee;
  --panel-dark: #101012;
  --focus: #e84e1b;
  --tap: 60px;
  --radius: 16px;
  --radius-sm: 10px;
  --pad: clamp(18px, 3vw, 28px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #101012;
    --face: #1b1b1d;
    --face-muted: #232325;
    --ink: #f2f1ef;
    --ink-2: #a9a9ab;
    --rule: #7a7a7c;
    --rule-soft: #333335;
    --safe: #34c26d;
    --stop: #ff5a4f;
    --on-state: #101012;
    --stop-tint: #3a1618;
    --safe-tint: #13301f;
    --panel-dark: #232325;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #101012;
  --face: #1b1b1d;
  --face-muted: #232325;
  --ink: #f2f1ef;
  --ink-2: #a9a9ab;
  --rule: #7a7a7c;
  --rule-soft: #333335;
  --safe: #34c26d;
  --stop: #ff5a4f;
  --on-state: #101012;
  --stop-tint: #3a1618;
  --safe-tint: #13301f;
  --panel-dark: #232325;
  color-scheme: dark;
}

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  background: var(--ground);
  color: var(--ink);
  caret-color: var(--brand-orange);
  scrollbar-color: var(--rule) var(--ground);
}
::selection { background: var(--brand-orange); color: #101012; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.icon { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.legend { font-weight: 600; letter-spacing: -0.02em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.error { color: var(--stop); font-weight: 600; }

/* ------------------------------------------------------------------ header */
.topbar {
  background: var(--brand-black);
  color: #fff;
  position: sticky; top: 0; z-index: 20;
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 920px; margin: 0 auto;
  padding: 14px var(--pad);
  display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 18px; min-width: 0; margin-right: auto; }
.brand img { height: 28px; width: auto; display: block; }
.brand-ref { font-size: 13px; line-height: 1.3; color: #a9a9ab; border-left: 1px solid #3a3a3c; padding-left: 18px; white-space: nowrap; }
.brand-ref strong { display: block; color: #fff; font-size: 15px; font-weight: 500; }
.save-state { font-size: 13px; color: #a9a9ab; white-space: nowrap; }
.save-state:not(:empty)::before { content: "\B7"; margin: 0 8px; }
.topbar .btn { color: #fff; border-color: #5a5a5c; background: transparent; }
.theme-switch { display: inline-flex; padding: 3px; border: 1px solid #5a5a5c; border-radius: 999px; }
.theme-switch button {
  min-height: 42px; padding: 0 14px; background: transparent; color: #c9c9cb; border: 0; border-radius: 999px;
  font: inherit; font-size: 15px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
}
.theme-switch button[aria-pressed="true"] { background: #fff; color: var(--brand-black); }

/* ------------------------------------------------------------------ layout */
.wrap { max-width: 920px; margin: 0 auto; padding: 24px var(--pad) 0; }
.part-title {
  display: flex; align-items: center; gap: 14px;
  margin: 56px 0 18px; font-size: 38px; line-height: 1.1; font-weight: 500; letter-spacing: -0.03em;
}
.part-title:first-of-type { margin-top: 28px; }
.part-id {
  width: 44px; height: 44px; flex: none; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--brand-orange); color: #fff; font-size: 19px; font-weight: 700; letter-spacing: 0;
}
.part-sub { margin: -8px 0 16px; color: var(--ink-2); }
.section-title { font-size: 20px; font-weight: 600; margin: 36px 0 12px; }

/* Panel: white face, hairline rule, soft corners. Never nested. */
.plate {
  background: var(--face);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius);
  padding: var(--pad);
  margin: 0 0 16px;
}
.plate h3 { margin: 0 0 18px; font-size: 19px; }
.plate h3 .muted { font-weight: 400; }
.plate h3:not(:first-child) { margin-top: 30px; padding-top: 24px; border-top: 1px solid var(--rule-soft); }
.plate h4 { margin: 24px 0 12px; font-size: 16px; }
.plate > .btn { margin-top: 22px; }

/* Instruction panel: near-black, orange mandatory mark */
.sign-mandatory {
  display: flex; gap: 16px; align-items: flex-start;
  background: var(--panel-dark); color: #f2f1ef;
  border-radius: var(--radius); padding: 18px 20px; margin: 0 0 16px;
}
.sign-mandatory .pict { width: 34px; height: 34px; flex: none; color: var(--brand-orange); }
.sign-mandatory p { margin: 0; padding-top: 5px; }
.sign-mandatory ol { margin: 0; padding: 5px 0 0; list-style: none; display: grid; gap: 4px; }
.sign-mandatory strong { color: #fff; font-weight: 600; }

/* ------------------------------------------------------------------ fields */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px 20px; }
.grid + .grid, .grid + .q-inline, .q-inline + .grid { margin-top: 20px; }
.span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 7px; font-size: 15px; font-weight: 500; color: var(--ink); min-width: 0; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--ink); background: var(--face);
  border: 1.5px solid var(--rule); border-radius: var(--radius-sm);
  min-height: var(--tap); padding: 12px 16px; width: 100%;
}
input::placeholder { color: var(--ink-2); opacity: 1; }
input[type="date"], [data-bind$="sentinel"], [data-bind$="Sentinel"], [data-bind$="Time"] { font-variant-numeric: tabular-nums; }
select {
  appearance: none; padding-right: 46px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e84e1b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 22px;
}
input:focus, select:focus, textarea:focus { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--ink); }
input[readonly] { background: var(--face-muted); border-style: dashed; border-color: var(--rule-soft); }
.grid-limits { grid-template-columns: 1fr auto 1fr; align-items: end; }
.grid-limits .to { padding-bottom: 18px; color: var(--ink-2); }

/* Status chips under fields */
.hint { font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; }
.hint:empty { display: none; }
.hint .icon { width: 18px; height: 18px; }
.hint.good { color: var(--safe); }
.hint.warn { background: var(--warning); color: var(--on-warning); padding: 4px 12px 4px 9px; border-radius: 999px; }
.hint.bad { background: var(--stop); color: var(--on-state); padding: 4px 12px 4px 9px; border-radius: 999px; }
.missing { outline: 3px solid var(--stop) !important; outline-offset: 3px; border-radius: var(--radius-sm); }

/* ------------------------------------------------------------------ answer keys (glove sized pills) */
.choice { display: inline-flex; gap: 8px; flex: none; }
.choice button {
  min-width: 96px; min-height: 64px; padding: 0 20px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 17px;
  border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--ink); background: var(--face); color: var(--ink);
  transition: background-color .12s ease-out, color .12s ease-out, border-color .12s ease-out;
}
.choice button .icon { width: 22px; height: 22px; stroke-width: 2.6; }
.choice button[aria-pressed="true"][data-v="Yes"] { background: var(--safe); border-color: var(--safe); color: var(--on-state); }
.choice button[aria-pressed="true"][data-v="No"] { background: var(--stop); border-color: var(--stop); color: var(--on-state); }
.choice button[aria-pressed="true"][data-v="N/A"] { background: var(--ink); border-color: var(--ink); color: var(--face); }

/* ------------------------------------------------------------------ question rows */
.q-list { display: grid; gap: 10px; margin-bottom: 16px; }
.q {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 56px 1fr auto; gap: 18px; align-items: start;
  background: var(--face); border: 1px solid var(--rule-soft); border-radius: var(--radius);
  padding: 18px 18px 22px;
  transition: border-color .16s ease-out, background-color .16s ease-out;
}
.q-num {
  height: 40px; border-radius: 999px; display: grid; place-items: center;
  font-weight: 700; font-size: 15px; letter-spacing: 0; font-variant-numeric: tabular-nums;
  background: var(--ground); color: var(--ink);
  transition: background-color .16s ease-out, color .16s ease-out;
}
.q-text { padding-top: 7px; min-width: 0; }
.q-extra { margin-top: 14px; max-width: 280px; }
.q-legend { display: none; margin-top: 10px; font-size: 15px; font-weight: 600; color: var(--stop); }
/* Signature interaction: the state colour band wipes across the answered row */
.q::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5px;
  background: var(--band, transparent);
  clip-path: inset(0 100% 0 0);
  transition: clip-path .16s cubic-bezier(.2, .8, .2, 1);
}
.q[data-state]::after { clip-path: inset(0 0 0 0); }
.q[data-state="yes"] { border-color: var(--safe); --band: var(--safe); }
.q[data-state="yes"] .q-num { background: var(--safe); color: var(--on-state); }
.q[data-state="no"] { border-color: var(--stop); --band: var(--stop); background: var(--stop-tint); }
.q[data-state="no"] .q-num { background: var(--stop); color: var(--on-state); }
.q[data-state="no"] .q-legend { display: flex; align-items: center; gap: 6px; }
.q[data-state="na"] { border-color: var(--rule); --band: var(--rule); }
.q[data-state="na"] .q-num { background: var(--ink); color: var(--face); }
@media (prefers-reduced-motion: reduce) {
  .q, .q::after, .q-num, .choice button { transition: none; }
}

/* Inline decisions inside panels (isolation, lifting, shift checks) */
.q-inline { display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 14px 0; border-top: 1px solid var(--rule-soft); }
.q-inline:first-child { border-top: 0; padding-top: 0; }
.q-inline:last-child { padding-bottom: 0; }
.q-inline .q-text { padding-top: 0; }

/* ------------------------------------------------------------------ plant */
.plant-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 36px 40px; }
.plant-col { display: flex; flex-direction: column; gap: 16px; }
.plant-col h4 { margin: 0; font-size: 17px; }
.plant-col .choice button { min-width: 88px; }
@media (max-width: 700px) {
  .plant-grid { gap: 0; }
  .plant-col { padding: 24px 0 0; margin-top: 24px; border-top: 1px solid var(--rule-soft); }
  .plant-grid .plant-col:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
}

.footnote { font-size: 14px; color: var(--ink-2); margin: 18px 0 0; }

/* ------------------------------------------------------------------ notes & staff */
.notes-row { display: grid; grid-template-columns: 120px 1fr; gap: 10px; margin-bottom: 10px; }
.notes-row:last-child { margin-bottom: 0; }
.staff-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; padding: 20px 0; border-top: 1px solid var(--rule-soft); }
.staff-row:first-child { border-top: 0; padding-top: 0; }
.staff-row:last-child { padding-bottom: 0; }

/* ------------------------------------------------------------------ signatures */
.sign-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 22px; }
.sign-cell { display: flex; flex-direction: column; gap: 8px; }
.sig-btn {
  min-height: 118px; width: 100%; border: 1.5px dashed var(--rule); border-radius: var(--radius-sm);
  background: var(--face-muted); color: var(--ink-2);
  font: inherit; font-weight: 500; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px;
}
.sig-btn .icon { width: 22px; height: 22px; color: var(--brand-orange); }
.sig-btn img { max-width: 100%; max-height: 92px; }
/* Signed box stays white in both themes: the signature is dark ink on a transparent PNG, as it lands on the paper form */
.sig-btn.signed { border: 1.5px solid var(--safe); background: #fff; }
.sig-actions { display: flex; gap: 8px; align-items: flex-end; }
.sig-actions .field { flex: 1; }

/* ------------------------------------------------------------------ shift changeover */
.shift-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.shift-head h3 { margin: 0; }
.shift-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); margin-top: 20px; border-top: 1px solid var(--rule-soft); }
.shift-col { display: flex; flex-direction: column; gap: 16px; padding: 20px 22px 0; border-left: 1px solid var(--rule-soft); }
.shift-cols .shift-col:first-child { border-left: 0; padding-left: 0; }
.shift-col h4 { margin: 0; }
@media (max-width: 700px) {
  .shift-col { border-left: 0; padding-left: 0; }
  .shift-cols .shift-col + .shift-col { border-top: 1px solid var(--rule-soft); margin-top: 20px; }
}

/* ------------------------------------------------------------------ buttons (Coombes pills) */
.btn {
  min-height: 52px; padding: 0 22px; border-radius: 999px;
  font: inherit; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
}
.btn .icon { width: 20px; height: 20px; color: var(--brand-orange); }
.btn-primary {
  background: var(--brand-orange); border-color: var(--brand-orange); color: var(--on-orange);
  min-height: var(--tap); padding: 0 28px; font-size: 19px; font-weight: 700;
}
.btn-primary .icon { color: currentColor; }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-quiet { background: transparent; }
.btn-danger { border-color: var(--stop); color: var(--stop); }
.btn-danger .icon { color: currentColor; }
.btn-block { width: 100%; }
.btn:active { transform: translateY(1px); }

/* ------------------------------------------------------------------ foot bar */
.bottom-spacer { height: 124px; }
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--brand-black); color: #fff;
  padding-bottom: env(safe-area-inset-bottom);
}
.actionbar-inner { max-width: 920px; margin: 0 auto; padding: 14px var(--pad); display: flex; gap: 20px; align-items: center; }
.progress { flex: 1; display: flex; flex-direction: column; gap: 8px; font-size: 15px; color: #c9c9cb; min-width: 0; }
.progress-track { height: 6px; background: #333335; border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--brand-orange); transform: scaleX(0); transform-origin: left; transition: transform .25s ease-out; }
.progress strong { color: #fff; font-weight: 600; }

/* ------------------------------------------------------------------ modals */
.modal { position: fixed; inset: 0; background: rgba(16, 16, 18, .72); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: var(--face); border-radius: var(--radius); width: 100%; max-width: 760px; max-height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.modal-head, .modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; }
.modal-head { background: var(--brand-black); color: #fff; }
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-head .btn { color: #fff; border-color: #5a5a5c; }
.modal-foot { border-top: 1px solid var(--rule-soft); }
.modal-foot .btn-primary { margin-left: auto; }
.sig-canvas-wrap { position: relative; margin: 18px; background: #fff; border: 1.5px solid var(--rule); border-radius: var(--radius-sm); }
#sigCanvas { display: block; width: 100%; height: 260px; touch-action: none; cursor: crosshair; }
.sig-line { position: absolute; left: 24px; right: 24px; bottom: 56px; border-bottom: 1.5px dashed #b9b9bb; pointer-events: none; }
.review-box { max-width: 920px; height: 100%; }
.review-body { overflow: auto; flex: 1; padding: 18px; background: var(--ground); -webkit-overflow-scrolling: touch; }
.review-body canvas { display: block; width: 100%; height: auto; background: #fff; margin: 0 auto 16px; border: 1px solid var(--rule-soft); border-radius: 4px; }
.notice { background: var(--face); border: 1px solid var(--rule-soft); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }
.notice-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-size: 16px; }
.notice-head .icon { width: 22px; height: 22px; }
.notice-body { padding: 14px 16px 16px; }
.notice-body p { margin: 0 0 8px; }
.notice-body p:last-child { margin-bottom: 0; }
.notice.stop { border-color: var(--stop); }
.notice.stop .notice-head { background: var(--stop); color: var(--on-state); }
.notice.warn { border-color: var(--warning); }
.notice.warn .notice-head { background: var(--warning); color: var(--on-warning); }
.notice.safe { border-color: var(--safe); }
.notice.safe .notice-head { background: var(--safe); color: var(--on-state); }
.notice ul { margin: 0; padding-left: 20px; }
.notice li button { background: none; border: 0; padding: 6px 0; font: inherit; color: var(--ink); text-decoration: underline; text-decoration-color: var(--brand-orange); text-underline-offset: 4px; cursor: pointer; text-align: left; min-height: 36px; }
.dialog-box { max-width: 480px; padding: 24px 24px 0; }
.dialog-box h3 { margin: 0 0 10px; font-size: 20px; }
.dialog-box .modal-foot { padding: 18px 0; margin-top: 16px; flex-wrap: wrap; }
.dialog-box .modal-foot .btn { flex: 1; }
.spinner { width: 36px; height: 36px; border: 4px solid var(--rule-soft); border-top-color: var(--brand-orange); border-radius: 50%; animation: spin 1s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ PIN */
.pin-screen { min-height: 70vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.pin-card { width: 100%; max-width: 400px; }
.pin-card h1 { font-size: 24px; font-weight: 500; margin: 0 0 6px; }
.pin-card input { margin: 16px 0 12px; font-size: 26px; letter-spacing: 8px; text-align: center; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ narrow */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .brand-ref, .save-state { display: none; }
  .topbar-inner { gap: 10px; }
  .brand img { height: 22px; }
  .theme-switch button { padding: 0 11px; }
  .theme-switch button span, .topbar .btn-label { display: none; }
  .topbar .btn { padding: 0 14px; }
  .part-title { font-size: 28px; }
  .q { grid-template-columns: 48px 1fr; gap: 14px; }
  .q .choice { grid-column: 1 / -1; width: 100%; }
  .q .choice button { flex: 1; min-width: 0; }
  .q-inline { flex-direction: column; align-items: stretch; }
  .q-inline .choice button { flex: 1; }
  .notes-row { grid-template-columns: 84px 1fr; }
  .grid-limits { grid-template-columns: 1fr; }
  .grid-limits .to { display: none; }
  .actionbar-inner { gap: 12px; }
  .btn-primary { padding: 0 18px; }
}
