/* Site Clock
   Layout: one narrow column (max 520px) — clock face, status, one big action,
   then a checklist of what the clock-in will record. Tab bar pinned to the bottom. */
:root {
  --bg: #F2F4F1;
  --surface: #FFFFFF;
  --ink: #16201B;
  --muted: #5B6862;
  --line: #D8DED9;
  --accent: #0F6B4C;
  --accent-press: #0A5239;
  --on-accent: #FFFFFF;
  --good: #1E6B3A;  --good-bg: #E0F0E4;
  --warn: #8A4F00;  --warn-bg: #FBEBD2;
  --bad:  #A3241C;  --bad-bg:  #FBE1DE;
  --neutral-bg: #E6EAE7;
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 14px;
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1513; --surface: #18201C; --ink: #E5ECE8; --muted: #98A69F; --line: #2A3530;
    --accent: #4CBF8B; --accent-press: #3FA477; --on-accent: #06140E;
    --good: #7DD49A; --good-bg: #15301F; --warn: #F2B866; --warn-bg: #3A2A10; --bad: #F2948B; --bad-bg: #3B1714;
    --neutral-bg: #222C27;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1513; --surface: #18201C; --ink: #E5ECE8; --muted: #98A69F; --line: #2A3530;
  --accent: #4CBF8B; --accent-press: #3FA477; --on-accent: #06140E;
  --good: #7DD49A; --good-bg: #15301F; --warn: #F2B866; --warn-bg: #3A2A10; --bad: #F2948B; --bad-bg: #3B1714;
  --neutral-bg: #222C27;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--font-sans);
  min-height: 100dvh;
}
body.locked { overflow: hidden; }
[hidden] { display: none !important; }
img { max-width: 100%; }
h1, h2, h3 { text-wrap: balance; margin: 0; line-height: 1.2; }
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.375rem; font-weight: 700; }
h3 { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
p { margin: 0; }
code { font-family: var(--font-mono); font-size: 0.9em; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.center { text-align: center; }
.pad-xl { padding-block: 64px; }
.lede { color: var(--muted); max-width: 60ch; }
.error { color: var(--bad); }

/* ---------- app bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  padding-top: env(safe-area-inset-top, 0px);
  border-bottom: 1px solid var(--line);
}
.appbar-inner {
  max-width: 520px; margin: 0 auto;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; }
.brand-mark { width: 28px; height: 28px; }

.chip {
  font: 500 0.8125rem/1 var(--font-sans);
  border: 0; border-radius: 999px; padding: 8px 12px; cursor: pointer;
  background: var(--neutral-bg); color: var(--ink);
}
.chip.good { background: var(--good-bg); color: var(--good); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- main column ---------- */
main {
  max-width: 520px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 20px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom, 0px));
}
.screen { display: flex; flex-direction: column; gap: 20px; }

/* ---------- clock face ---------- */
.clock { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; }
.clock-time {
  font-family: var(--font-mono); font-weight: 500;
  font-size: clamp(3.25rem, 17vw, 4.75rem); line-height: 1;
  letter-spacing: -0.04em; font-variant-numeric: tabular-nums;
}
.clock-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); }
.clock-tz { font-family: var(--font-mono); font-size: 0.8125rem; padding-top: 2px; }

/* ---------- status ---------- */
.status { display: flex; align-items: flex-start; gap: 12px; padding-block: 16px 4px; border-top: 1px solid var(--line); }
.status-dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 9px; flex: none; background: var(--muted); }
.status-dot.on { background: var(--accent); box-shadow: 0 0 0 4px var(--good-bg); }
.status-label { font-size: 1.375rem; font-weight: 700; }
.status-detail { color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer;
  font: 600 1rem/1.2 var(--font-sans);
  border-radius: 12px; padding: 12px 18px;
  background: var(--neutral-bg); color: var(--ink);
  transition: background-color .15s, transform .1s;
}
.btn:active:not(:disabled) { transform: scale(0.985); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-press); }
.btn-ink { background: var(--ink); color: var(--bg); }
.btn-secondary { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn-quiet { background: transparent; color: var(--muted); }
.btn-quiet.danger { color: var(--bad); }
.btn-lg { width: 100%; padding: 16px 20px; font-size: 1.0625rem; }
.btn-xl { width: 100%; min-height: 68px; font-size: 1.25rem; border-radius: var(--radius); }
.btn-small { padding: 7px 12px; font-size: 0.875rem; border-radius: 9px; }
.link { border: 0; background: none; color: var(--accent); font: 600 0.875rem var(--font-sans); padding: 4px 0; cursor: pointer; }
.stack { display: flex; flex-direction: column; gap: 10px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- checklist ---------- */
.checks { margin: 0; display: flex; flex-direction: column; }
.check {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px;
  padding-block: 14px; border-bottom: 1px solid var(--line);
}
.check:first-child { border-top: 1px solid var(--line); }
.check dt { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.check dd { margin: 0; min-width: 0; text-align: right; }
.check-sub { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 12px; text-align: left !important; font-size: 0.8125rem; color: var(--muted); }
.check-sub:empty { display: none; }

.pill {
  display: inline-block; max-width: 100%;
  font: 500 0.8125rem/1.3 var(--font-sans);
  padding: 4px 10px; border-radius: 999px;
  background: var(--neutral-bg); color: var(--ink);
}
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad  { background: var(--bad-bg);  color: var(--bad); }
.pill.small { font-size: 0.75rem; padding: 2px 8px; }

/* ---------- banner ---------- */
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 12px; font-size: 0.9375rem; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner .btn { flex: none; background: var(--surface); color: var(--ink); }

/* ---------- forms ---------- */
.signin { display: flex; flex-direction: column; gap: 18px; padding-top: 24px; }
.form { display: flex; flex-direction: column; gap: 8px; }
.form label { font-size: 0.875rem; font-weight: 600; margin-top: 6px; }
.form input {
  font: 400 1rem var(--font-sans); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 13px 14px;
}
.form .btn { margin-top: 14px; }
.demo-note { background: var(--neutral-bg); padding: 12px 14px; border-radius: 12px; font-size: 0.9375rem; }

.consent { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.consent ul { margin: 0; padding-left: 1.1em; display: flex; flex-direction: column; gap: 8px; font-size: 0.9375rem; }
.tick { display: flex; gap: 12px; align-items: flex-start; font-size: 0.9375rem; cursor: pointer; }
.tick input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }

/* ---------- key/value ---------- */
.kv { margin: 0; display: flex; flex-direction: column; }
.kv > div { display: grid; grid-template-columns: 9.5rem 1fr; gap: 12px; padding-block: 11px; border-bottom: 1px solid var(--line); }
.kv dt { color: var(--muted); font-size: 0.875rem; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv .sub { display: block; color: var(--muted); font-size: 0.8125rem; }
.enrol-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 50%; vertical-align: middle; margin-right: 10px; }
.sites { list-style: none; margin: -8px 0 0; padding: 0; }
.sites li { display: flex; flex-direction: column; padding-block: 9px; border-bottom: 1px solid var(--line); font-size: 0.9375rem; }
.sites .mono { font-size: 0.8125rem; }

/* ---------- history ---------- */
.history { display: flex; flex-direction: column; gap: 6px; }
.day { margin-top: 12px; }
.rows { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; }
.row {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  background: none; border: 0; border-bottom: 1px solid var(--line); padding: 10px 0; cursor: pointer; color: var(--ink); font: inherit;
}
.row img, .row .noimg { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex: none; background: var(--neutral-bg); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-time { font-weight: 500; font-size: 1.0625rem; }
.row-sub { color: var(--muted); font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st { font-size: 0.75rem; font-weight: 600; flex: none; }
.st.good { color: var(--good); } .st.warn { color: var(--warn); } .st.bad { color: var(--bad); }
.tag { display: inline-block; font: 600 0.6875rem/1 var(--font-sans); text-transform: uppercase; letter-spacing: 0.08em; padding: 4px 7px; border-radius: 6px; }
.tag-in { background: var(--good-bg); color: var(--good); }
.tag-out { background: var(--neutral-bg); color: var(--ink); }
.empty { color: var(--muted); padding-block: 24px; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar-inner {
  max-width: 520px; margin: 0 auto; height: var(--tabbar-h);
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px));
}
.tab {
  border: 0; background: none; cursor: pointer; color: var(--muted);
  font: 500 0.75rem var(--font-sans); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.tab[aria-current="page"] { color: var(--accent); }

/* ---------- sheets ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; overflow-y: auto; }
/* The camera sheet is always dark so the preview reads well. */
.sheet-cam {
  --cam-bg: #0B100E; --cam-ink: #F1F5F2; --cam-muted: #A5B2AB; --cam-accent: #4CBF8B;
  background: var(--cam-bg); color: var(--cam-ink);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.cam-head { width: 100%; max-width: 480px; display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 1.0625rem; }
.btn-on-dark { background: rgba(255,255,255,.12); color: var(--cam-ink); }
.cam { position: relative; width: 100%; max-width: 420px; aspect-ratio: 3 / 4; max-height: 62dvh; border-radius: 20px; overflow: hidden; background: #000; }
.cam video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.cam-mask { position: absolute; inset: 0; width: 100%; height: 100%; }
.cam-mask path:first-child { fill: rgba(11,16,14,.62); }
.cam-oval { fill: none; stroke: var(--cam-accent); stroke-width: 3; stroke-dasharray: 8 7; }
.cam-steps { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; }
.cam-steps li { font-size: 0.8125rem; padding: 5px 12px; border-radius: 999px; background: rgba(255,255,255,.08); color: var(--cam-muted); }
.cam-steps li[data-state="now"] { background: var(--cam-accent); color: #06140E; font-weight: 600; }
.cam-steps li[data-state="done"] { color: var(--cam-accent); }
.cam-msg { font-size: 1.25rem; font-weight: 600; text-align: center; min-height: 1.6em; }
.cam-gps { color: var(--cam-muted); font-size: 0.8125rem; min-height: 1.2em; }

.sheet-result {
  background: var(--bg); display: flex; flex-direction: column; gap: 20px;
  padding: calc(24px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.result, .result-actions { width: 100%; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.result-actions { gap: 10px; margin-top: auto; }
.result-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font: 700 1.5rem var(--font-sans); }
.result-icon.good { background: var(--good-bg); color: var(--good); }
.result-icon.bad { background: var(--bad-bg); color: var(--bad); }
.result-icon.info { background: var(--neutral-bg); color: var(--ink); }
.result-title { font-size: 1.5rem; }
.result-text { color: var(--muted); }
.result-head { display: flex; gap: 16px; align-items: center; }
.result-photo { width: 92px; height: 92px; object-fit: cover; border-radius: 16px; flex: none; }
.result-time { font-size: 2.25rem; font-weight: 500; letter-spacing: -0.03em; line-height: 1.1; margin-top: 6px; }
.result-verdict { font-weight: 600; font-size: 1.0625rem; padding: 12px 14px; border-radius: 12px; }
.result-verdict.good { background: var(--good-bg); color: var(--good); }
.result-verdict.warn { background: var(--warn-bg); color: var(--warn); }
.flags { display: flex; flex-wrap: wrap; gap: 6px; }
.flags-h { width: 100%; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

@media (max-width: 380px) {
  .kv > div { grid-template-columns: 1fr; gap: 2px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.maplink { display: inline-block; margin-top: 4px; color: var(--accent); font-weight: 600; font-size: 0.875rem; }
