:root {
  --green: #1f4d2b; --green-2: #2e6b3d; --orange: #e8730c; --bg: #f4f1ea; --card: #fff; --ink: #1b1b1b; --muted: #5d5d5d; --line: #d6d0c4;
  --ok: #1e7a34; --ok-bg: #d8f0dc; --mid: #8a6d00; --mid-bg: #fff1b8; --bad: #b3261e; --bad-bg: #fbdad7; --due: #b85c00; --due-bg: #ffe0bf; --na: #555; --na-bg: #e7e7e7;
  --tap: 58px; --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 18px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--ink); padding-bottom: env(safe-area-inset-bottom); }
h1 { font-size: 1.5rem; margin: .4rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.2rem 0 .5rem; }
a { color: var(--green-2); }
.hidden { display: none !important; }
.main { max-width: 760px; margin: 0 auto; padding: 1rem 1rem 6rem; }

/* header + sync bar */
.hdr { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: .5rem; background: var(--green); color: #fff; padding: calc(env(safe-area-inset-top) + .3rem) .5rem .3rem; min-height: 56px; }
.hdr-title { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.hdr-back, .hdr-user { background: transparent; color: #fff; border: 0; font-size: 1.05rem; min-width: var(--tap); min-height: 48px; cursor: pointer; }
.hdr-back { font-size: 2.2rem; line-height: 1; }
.hdr-sp { min-width: var(--tap); }
.syncbar { position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 19; display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .45rem .9rem; font-size: .9rem; background: #e3eee5; color: #234; }
.syncbar:empty { display: none; }
.syncbar.wait { background: #e8eef7; } .syncbar.amber { background: var(--due-bg); color: #5a2d00; } .syncbar.red { background: var(--bad-bg); color: #5b0f0a; } .syncbar.busy { background: #e8eef7; }
.syncbar button { border: 1px solid currentColor; background: #fff; border-radius: 10px; padding: .45rem .8rem; font-size: .9rem; min-height: 40px; color: inherit; }
.update { position: fixed; bottom: 1rem; left: 1rem; right: 1rem; z-index: 50; padding: 1rem; border: 0; border-radius: var(--radius); background: var(--orange); color: #fff; font-size: 1rem; font-weight: 700; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 48px; padding: .6rem 1.1rem; border-radius: var(--radius); border: 2px solid var(--line); background: #fff; color: var(--ink); font-size: 1rem; font-weight: 600; text-decoration: none; cursor: pointer; touch-action: manipulation; }
.btn.big { min-height: var(--tap); font-size: 1.1rem; padding: .8rem 1.3rem; }
.btn.block { display: flex; width: 100%; margin: .6rem 0; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.small { min-height: 44px; padding: .4rem .8rem; font-size: .95rem; }
.btn:disabled { opacity: .5; }
.row-btns { display: flex; flex-wrap: wrap; gap: .5rem; margin: .6rem 0; }
.link { display: block; text-align: center; margin: 1.5rem 0; font-size: 1.05rem; }

/* forms */
.form { display: block; }
.field { margin: 0 0 1.2rem; }
.field-label { display: block; font-weight: 700; margin: 0 0 .4rem; font-size: 1.02rem; }
.req { color: var(--bad); }
.big-input { width: 100%; min-height: var(--tap); padding: .7rem .9rem; font-size: 1.1rem; border: 2px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--ink); font-family: inherit; }
textarea.big-input { min-height: 120px; line-height: 1.4; }
.big-input:focus { outline: 3px solid var(--orange); outline-offset: 1px; border-color: var(--orange); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .95rem; }
.readonly { min-height: var(--tap); display: flex; align-items: center; padding: .6rem .9rem; border-radius: var(--radius); background: #ece8df; font-weight: 600; }
.help { color: var(--muted); font-size: .95rem; }
.hint { color: var(--muted); font-size: .88rem; margin-top: .3rem; }
.small { font-size: .85rem; }
.notice { display: block; padding: .8rem 1rem; border-radius: var(--radius); margin: .6rem 0 1rem; text-decoration: none; color: var(--ink); }
.notice.info { background: #e3ecf8; } .notice.warn { background: var(--due-bg); } .notice.ok { background: var(--ok-bg); }
.check { display: flex; align-items: center; gap: .5rem; min-height: 48px; }
.check input, .switch-row input { width: 28px; height: 28px; accent-color: var(--green); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 0; min-height: var(--tap); }

/* picker */
.picker { margin: 0 0 1.2rem; }
.picker .results { display: flex; flex-direction: column; gap: .35rem; margin-top: .4rem; }
.result { text-align: left; min-height: 52px; padding: .6rem .9rem; border: 2px solid var(--line); border-radius: 12px; background: #fff; font-size: 1.05rem; color: var(--ink); cursor: pointer; }
.result:active, .result:hover { border-color: var(--green-2); }
.result.add-new { border-style: dashed; border-color: var(--green-2); color: var(--green); font-weight: 700; }
.no-match { color: var(--muted); padding: .3rem .2rem; }
.picked { display: flex; width: 100%; justify-content: space-between; align-items: center; min-height: var(--tap); padding: .6rem .9rem; border: 2px solid var(--green-2); background: #eef6ef; border-radius: var(--radius); font-size: 1.1rem; cursor: pointer; color: var(--ink); }
.picked-name { font-weight: 700; text-align: left; } .picked-change { color: var(--green-2); font-size: .95rem; text-decoration: underline; }

/* chips, pills, badges */
.chip { display: inline-block; padding: .15rem .55rem; border-radius: 999px; background: #e7e2d6; font-size: .8rem; font-weight: 600; margin: .2rem .25rem .2rem 0; vertical-align: middle; }
.chip.small { font-size: .72rem; padding: .05rem .45rem; }
.chip-new { background: #fff1b8; color: #6b5200; } .chip-draft { background: #ffe0bf; color: #7a3a00; } .chip-kiosk { background: var(--orange); color: #fff; }
.chip-hsc { background: #dfe9ff; color: #1d3c7a; } .chip-warn { background: var(--bad-bg); color: var(--bad); }
.role-admin { background: #2b2b2b; color: #fff; } .role-supervisor { background: #d8f0dc; color: #14532d; }
.pill { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 700; margin-right: .3rem; }
.badge { position: absolute; top: .5rem; right: .6rem; min-width: 1.7rem; height: 1.7rem; border-radius: 999px; background: var(--green); color: #fff; font-style: normal; font-size: .85rem; display: flex; align-items: center; justify-content: center; padding: 0 .4rem; }
.badge[hidden] { display: none; }
.badge.warn { background: var(--orange); }
.tab .badge { position: static; display: inline-flex; }

/* status colours (matrix, pills) */
.st-competent { background: var(--ok-bg); color: var(--ok); }
.st-limits { background: var(--mid-bg); color: var(--mid); }
.st-not_yet { background: var(--bad-bg); color: var(--bad); }
.st-due { background: var(--due-bg); color: var(--due); }
.st-overdue { background: var(--bad); color: #fff; }
.st-none { background: #fff; color: #bbb; }
.st-wait { background: #e3ecf8; color: #1d3c7a; }
.out-competent { color: var(--ok); } .out-limits { color: var(--mid); } .out-not_yet { color: var(--bad); }

/* home */
.hello { margin-bottom: .1rem; } .who-line { color: var(--muted); margin-bottom: 1rem; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin: 1rem 0; }
.tile { position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: .4rem; min-height: 120px; padding: 1rem; border-radius: 18px; background: #fff; border: 2px solid var(--line); text-decoration: none; color: var(--ink); font-size: 1.8rem; }
.tile span { font-size: 1.05rem; font-weight: 700; line-height: 1.2; }
.tile.primary { grid-column: 1 / -1; background: var(--green); border-color: var(--green); color: #fff; min-height: 110px; }

/* login + PIN pad */
.login { text-align: center; max-width: 420px; margin: 0 auto; }
.login .field, .login .picker { text-align: left; }
.login-logo { border-radius: 20px; margin-top: .5rem; }
.login h1 { margin: .4rem 0 0; } .login .sub { color: var(--muted); margin: .2rem 0 1rem; }
.pin-dots { display: flex; justify-content: center; gap: 1rem; margin: .6rem 0 1rem; }
.pin-dots span { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--green); }
.pin-dots span.on { background: var(--green); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; max-width: 330px; margin: 0 auto; }
.pin-key { min-height: 72px; font-size: 1.8rem; font-weight: 700; border-radius: 18px; border: 2px solid var(--line); background: #fff; color: var(--ink); touch-action: manipulation; }
.pin-key:active { background: #e8efe9; }
.pin-msg { min-height: 1.6rem; margin: .8rem 0; color: var(--bad); font-weight: 600; }

/* wizard */
.wizard-head { margin-bottom: 1rem; } .wizard-step { color: var(--muted); font-weight: 600; font-size: .9rem; }
.wizard-head h1 { margin: .1rem 0 .5rem; }
.progress { height: 8px; border-radius: 99px; background: #e2ddd2; overflow: hidden; } .progress div { height: 100%; background: var(--orange); }
.wizard-foot.static { position: static; background: none; }
.wizard-foot { position: sticky; bottom: 0; display: grid; grid-template-columns: 1fr 2fr; gap: .6rem; padding: .8rem 0 calc(.8rem + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 80%, transparent); margin-top: 1rem; }

/* segmented & toggles */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .4rem; }
.seg.vertical { grid-auto-flow: row; }
.seg-btn { min-height: var(--tap); padding: .5rem; border: 2px solid var(--line); border-radius: 12px; background: #fff; font-size: 1.02rem; font-weight: 700; color: var(--ink); touch-action: manipulation; }
.seg-btn.on { border-color: var(--green); background: var(--green); color: #fff; }
.seg-btn.ok.on { background: var(--ok); border-color: var(--ok); }
.seg-btn.bad.on { background: var(--bad); border-color: var(--bad); }
.seg-btn.mid.on { background: #a07d00; border-color: #a07d00; }
.seg-btn.na.on { background: var(--na); border-color: var(--na); }
.toggles { display: grid; gap: .5rem; margin-bottom: 1rem; }
.toggle { min-height: var(--tap); border: 2px solid var(--line); border-radius: 12px; background: #fff; font-size: 1.1rem; font-weight: 700; text-align: left; padding: .5rem 1rem; color: var(--ink); }
.toggle::before { content: "☐  "; } .toggle.on { border-color: var(--green); background: #eef6ef; } .toggle.on::before { content: "☑  "; color: var(--green); }

/* checklist */
.task-banner { padding: .7rem 1rem; background: #fff; border-radius: var(--radius); border: 2px solid var(--line); margin-bottom: .6rem; }
.count { font-weight: 700; margin: .4rem 0; }
.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.step { background: #fff; border: 2px solid var(--line); border-radius: var(--radius); padding: .8rem; margin-bottom: .7rem; counter-increment: s; }
.step.common { border-left: 6px solid var(--orange); }
.step-text { font-size: 1.05rem; margin-bottom: .6rem; } .step-text::before { content: counter(s) ". "; font-weight: 700; }
.step.flash { animation: flash 1.2s 2; } @keyframes flash { 50% { border-color: var(--bad); box-shadow: 0 0 0 4px var(--bad-bg); } }

/* media */
.thumbs { display: flex; flex-wrap: wrap; gap: .6rem; margin: .4rem 0; }
.thumb { position: relative; } .thumb img, .thumb video, .thumbs > img, .thumbs > video { width: 120px; height: 120px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.thumb-x { position: absolute; top: -10px; right: -10px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--bad); color: #fff; font-size: 1.1rem; }
.file-btn { cursor: pointer; }

/* signatures */
.sig-box { position: relative; height: 180px; border: 2px dashed #9a9384; border-radius: var(--radius); background: #fff; touch-action: none; margin-bottom: .4rem; }
.sig-box canvas { width: 100%; height: 100%; display: block; border-radius: var(--radius); touch-action: none; }
.sig-line { position: absolute; left: 1rem; right: 1rem; bottom: 2.2rem; border-top: 1px solid #ccc; color: #aaa; font-size: .8rem; pointer-events: none; padding-top: .2rem; }
.sig-img { max-width: 260px; max-height: 110px; border-bottom: 1px solid #999; display: block; }
.sigs { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-top: 1.5rem; }

/* summary, tables */
.summary { background: #fff; border-radius: var(--radius); border: 2px solid var(--line); padding: .5rem 1rem; margin-bottom: 1rem; }
.summary div { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px solid #eee; } .summary div:last-child { border: 0; }
.summary span { color: var(--muted); }
.kv { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; }
.kv th, .kv td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid #eee; vertical-align: top; } .kv th { width: 38%; color: var(--muted); font-weight: 600; }
.steps-table { width: 100%; border-collapse: collapse; background: #fff; font-size: .95rem; }
.steps-table th, .steps-table td { border: 1px solid #ddd; padding: .4rem .5rem; text-align: left; vertical-align: top; }
.mark-shown { color: var(--ok); font-weight: 700; } .mark-needs_work { color: var(--bad); font-weight: 700; } .mark-na { color: var(--na); }
.outcome-box { padding: .8rem 1rem; border-radius: 10px; border: 2px solid currentColor; background: #fff; }
.notes { white-space: pre-wrap; background: #fff; padding: .7rem; border-radius: 10px; }

/* records list */
.chips-row { display: flex; gap: .4rem; overflow-x: auto; padding: .6rem 0; }
.chip-btn { flex: none; min-height: 44px; padding: .3rem .9rem; border-radius: 999px; border: 2px solid var(--line); background: #fff; font-weight: 600; font-size: .95rem; color: var(--ink); }
.chip-btn.on { background: var(--green); color: #fff; border-color: var(--green); }
.rrow { display: block; background: #fff; border-radius: var(--radius); border: 2px solid var(--line); padding: .7rem .9rem; margin-bottom: .5rem; text-decoration: none; color: var(--ink); }
.rrow-main { display: flex; flex-direction: column; } .rrow-main span { color: var(--muted); }
.rrow-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .3rem; font-size: .9rem; color: var(--muted); }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }

/* matrix */
.msum { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .6rem; }
.mfilters { display: grid; gap: .5rem; margin-bottom: .6rem; }
.legend { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .85rem; margin: .4rem 0 .8rem; }
.legend span { display: inline-flex; align-items: center; gap: .3rem; }
.legend i { display: inline-flex; width: 26px; height: 26px; align-items: center; justify-content: center; font-style: normal; font-weight: 700; border: 1px solid #ccc; border-radius: 6px; }
.mwrap { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 10px; background: #fff; -webkit-overflow-scrolling: touch; }
.matrix { border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.matrix th, .matrix td { border-right: 1px solid #e5e5e5; border-bottom: 1px solid #e5e5e5; }
.matrix thead th { position: sticky; top: 0; background: #faf8f3; z-index: 2; height: 170px; vertical-align: bottom; padding: .3rem 0; }
.matrix .vert { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; max-height: 160px; overflow: hidden; text-overflow: ellipsis; font-weight: 600; margin: 0 auto; }
.matrix .corner { left: 0; z-index: 3; min-width: 150px; text-align: left; padding: .4rem; font-size: .8rem; color: var(--muted); }
.matrix .wname { position: sticky; left: 0; background: #faf8f3; z-index: 1; text-align: left; padding: .3rem .5rem; min-width: 150px; max-width: 170px; font-weight: 600; }
.matrix td.mc { width: 44px; min-width: 44px; height: 44px; text-align: center; font-weight: 800; font-size: 1.05rem; cursor: pointer; }

/* lists / admin */
.tabs { display: flex; gap: .3rem; overflow-x: auto; margin-bottom: 1rem; }
.tab { flex: none; padding: .6rem .9rem; border-radius: 12px; background: #fff; border: 2px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 600; min-height: 48px; display: inline-flex; align-items: center; gap: .3rem; }
.tab.on { background: var(--green); color: #fff; border-color: var(--green); }
.card { background: #fff; border: 2px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: 1rem; }
.card.hi { border-color: var(--green-2); } .card h2 { margin-top: 0; }
.review-head { font-size: 1.1rem; margin-bottom: .2rem; }
.ilist { margin-top: .8rem; }
.irow { display: flex; justify-content: space-between; align-items: center; gap: .5rem; background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: .6rem .8rem; margin-bottom: .5rem; text-decoration: none; color: var(--ink); }
.irow.dim { opacity: .6; } .irow .row-btns { margin: 0; flex: none; } .chev { font-size: 1.8rem; color: var(--muted); }
.ob-row { display: flex; justify-content: space-between; gap: .6rem; align-items: center; background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: .6rem .8rem; margin-bottom: .5rem; }
.ob-row.st-error, .ob-row.st-needs_signin { border-color: var(--bad); }
.big-steps { padding-left: 1.4rem; font-size: 1.05rem; } .big-steps li { margin-bottom: .6rem; }
.ios-share { display: inline-block; border: 2px solid #1a73e8; color: #1a73e8; border-radius: 6px; padding: 0 .3rem; font-weight: 700; }
.saved { text-align: center; } .big-check { font-size: 4rem; color: var(--ok); }

/* modal + toast */
.modal-wrap { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 100; display: flex; align-items: flex-end; justify-content: center; padding: 1rem; }
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 520px; max-height: 85vh; overflow: auto; padding: 1.2rem; }
.modal h2 { margin-top: 0; }
.modal-buttons { display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; }
.modal-buttons .btn { min-height: var(--tap); }
.modal .big-input { margin-top: .5rem; }
#toast { position: fixed; left: 50%; bottom: calc(1.5rem + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(150%); background: #222; color: #fff; padding: .9rem 1.2rem; border-radius: 14px; font-weight: 600; z-index: 200; max-width: 92vw; transition: transform .25s; text-align: center; }
#toast.show { transform: translateX(-50%) translateY(0); } #toast.warn { background: var(--bad); }

@media (min-width: 700px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .mfilters { grid-template-columns: 1fr 1fr auto; align-items: center; }
  .modal-wrap { align-items: center; }
}

/* print / PDF for the auditor */
.print-page { background: #fff; padding: 1rem; }
.print-head { display: flex; justify-content: space-between; border-bottom: 3px solid var(--green); padding-bottom: .5rem; margin-bottom: 1rem; font-size: 1.05rem; }
.print-head .right { text-align: right; }
.print-foot { margin-top: 2rem; padding-top: .5rem; border-top: 1px solid #999; font-size: .8rem; color: #444; }
body.print-mode .syncbar { display: none; }
@media print {
  @page { size: letter; margin: 14mm; }
  body { background: #fff; font-size: 11pt; }
  .hdr, .syncbar, .update, .no-print, #toast, .row-btns { display: none !important; }
  .main { max-width: none; padding: 0; }
  .print-page { padding: 0; }
  .thumbs img { width: 150px; height: 150px; }
  .steps-table, .kv { font-size: 10pt; }
  tr, .sigs, .outcome-box { page-break-inside: avoid; }
  h2 { page-break-after: avoid; break-after: avoid; }
}
body[data-screen=matrix] .main { max-width: 1400px; }
