/* SMP App styles. Colours follow the logo (black, white, grey); the accent can be switched per phone. */
:root {
  --bg: #f2f2f1; --surface: #ffffff; --surface-2: #f7f7f6; --ink: #121212; --muted: #625f5b; --line: #dcdbd8;
  --rule: #8c8c8c; --bar: #0b0b0b; --on-bar: #ffffff;
  --accent: #121212; --accent-ink: #ffffff; --accent-soft: #e8e8e6;
  --ok: #2c7a4b; --ok-soft: #dcefe3; --warn: #93600f; --warn-soft: #f6ead4; --bad: #b03636;
  --logo-inv: 1; --logo-blend: multiply;
  --display: "Montserrat", "Helvetica Neue", Arial, sans-serif;
  --body: "Barlow", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0b; --surface: #171717; --surface-2: #1f1f1f; --ink: #f1f1f1; --muted: #a3a3a3; --line: #2e2e2e;
    --bar: #000000; --accent: #f1f1f1; --accent-ink: #0b0b0b; --accent-soft: #262626;
    --ok: #6fc490; --ok-soft: #173325; --warn: #e0ad5a; --warn-soft: #3a2c14; --bad: #ec7d7d;
    --logo-inv: 0; --logo-blend: screen; color-scheme: dark;
  }
}
:root[data-scheme="hivis"] { --accent: #d9530a; --accent-ink: #ffffff; --accent-soft: #fde5d6; }
:root[data-scheme="water"] { --accent: #1663a8; --accent-ink: #ffffff; --accent-soft: #dceaf7; }
:root[data-scheme="green"] { --accent: #1d7a45; --accent-ink: #ffffff; --accent-soft: #dcefe3; }
@media (prefers-color-scheme: dark) {
  :root[data-scheme="hivis"] { --accent: #ff7a2e; --accent-ink: #1a0a00; --accent-soft: #3a1d0c; }
  :root[data-scheme="water"] { --accent: #5aa9ec; --accent-ink: #04121f; --accent-soft: #10273a; }
  :root[data-scheme="green"] { --accent: #4cc47f; --accent-ink: #04170c; --accent-soft: #123323; }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.app { max-width: 460px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
@media (min-width: 520px) { .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }

.bar { position: sticky; top: 0; z-index: 5; background: var(--bar); color: var(--on-bar); display: flex; align-items: center; gap: 10px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px; min-height: 58px; border-bottom: 3px solid var(--rule); }
.bar-logo { height: 21px; width: auto; mix-blend-mode: screen; display: block; }
.bar-title { font-family: var(--display); font-weight: 700; font-size: 17px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { background: none; border: 0; color: var(--on-bar); font-size: 28px; line-height: 1; padding: 0 6px 2px 0; }
.me { margin-left: auto; width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(255,255,255,.4); background: none; color: var(--on-bar); font-weight: 700; font-size: 14px; }

main { flex: 1; padding: 18px 16px 24px; display: flex; flex-direction: column; gap: 18px; }

.tabs { position: sticky; bottom: 0; z-index: 5; background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding-bottom: env(safe-area-inset-bottom, 0px); }
.tabs button { background: none; border: 0; padding: 9px 2px 10px; font-size: 12px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 3px; position: relative; }
.tabs svg { width: 22px; height: 22px; }
.tabs button[aria-current="page"] { color: var(--ink); }
.tabs button[aria-current="page"]::before { content: ""; position: absolute; top: -1px; left: 25%; right: 25%; height: 3px; background: var(--accent); border-radius: 0 0 3px 3px; }

h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; text-wrap: balance; }
h1 { font-size: 26px; line-height: 1.12; letter-spacing: -.01em; }
h2 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
p { margin: 0; }
.eyebrow { font-size: 12.5px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.center { text-align: center; }
.link { background: none; border: 0; padding: 4px 0; color: var(--ink); font-weight: 600; font-size: 14px; text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }

/* PIN screens */
.pinscreen { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 16px; padding-top: 10px; }
.brand-full { width: min(240px, 70%); height: auto; filter: invert(var(--logo-inv)); mix-blend-mode: var(--logo-blend); display: block; }
.dots { display: flex; gap: 14px; }
.dots span { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--muted); }
.dots span.on { background: var(--accent); border-color: var(--accent); }
.pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 12px; }
.pad button { height: 64px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); font-size: 26px; font-weight: 600; }
.pad button:active { background: var(--accent-soft); }
.pad .blank { visibility: hidden; }
.err { color: var(--bad); font-size: 14px; font-weight: 600; min-height: 1.4em; }

/* Building blocks */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 6px; min-height: 100px; }
.tile .t { font-family: var(--display); font-weight: 700; font-size: 16px; line-height: 1.15; }
.tile .d { font-size: 13px; color: var(--muted); }
.tile svg { width: 24px; height: 24px; color: var(--accent); }
.tile.hero { grid-column: 1 / -1; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); min-height: 0; flex-direction: row; align-items: center; gap: 14px; }
.tile.hero svg { color: var(--accent-ink); width: 32px; height: 32px; flex: none; }
.tile.hero .d { color: inherit; opacity: .8; }
.tile.hero .t { font-size: 19px; }
.tile.soon { opacity: .6; }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 13px 14px; background: none; border: 0; border-top: 1px solid var(--line); text-align: left; }
.row:first-child { border-top: 0; }
.row .main { flex: 1; min-width: 0; }
.row .name { font-weight: 600; }
.row .sub { font-size: 13.5px; color: var(--muted); overflow-wrap: anywhere; }
.row .chev { color: var(--muted); font-size: 20px; }

.pill { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.grey { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill.bad { background: var(--surface-2); color: var(--bad); border: 1px solid var(--bad); }

.card { border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.note { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .lbl { font-weight: 600; font-size: 15px; }
.inp { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 11px 12px; font-size: 16px; }
textarea.inp { min-height: 120px; resize: vertical; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.check { display: flex; gap: 10px; align-items: center; font-size: 15px; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }
.btn { border: 0; border-radius: 12px; padding: 14px; font-weight: 700; font-size: 16px; background: var(--accent); color: var(--accent-ink); width: 100%; }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.bad { background: var(--surface); color: var(--bad); border: 1px solid var(--bad); }
.btnrow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.linkbox { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; overflow-wrap: anywhere; user-select: all; }

.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.sw { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); padding: 0; }
.sw[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 3px var(--bg) inset; }

.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14.5px; z-index: 20; max-width: calc(100% - 32px); width: max-content; text-align: center; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Category colours: one per kind of form, readable in light and dark */
:root { --c-time: #1f8a4c; --c-report: #1d63b0; --c-swms: #d0690a; --c-proc: #0d7f86; --c-return: #6b4bb8; --c-admin: #b3365f; --c-stop: #c0392b; }
@media (prefers-color-scheme: dark) { :root { --c-time: #4cc47f; --c-report: #5aa2ec; --c-swms: #ff9a3d; --c-proc: #3fc6cc; --c-return: #a98bf0; --c-admin: #f07aa0; --c-stop: #f0716a; } }
.tile.cat { border-color: color-mix(in srgb, var(--cat) 40%, var(--line)); background: color-mix(in srgb, var(--cat) 9%, var(--surface)); }
.tile.cat svg { color: var(--cat); }
.tile.cat.hero { background: var(--cat); border-color: var(--cat); color: #fff; }
.tile.cat.hero svg { color: #fff; }

/* Sign in / sign out */
.clock { border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; border: 2px solid var(--c-time); background: color-mix(in srgb, var(--c-time) 8%, var(--surface)); }
.clock.on { border-color: var(--c-stop); background: color-mix(in srgb, var(--c-stop) 7%, var(--surface)); }
.clock .where { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.clock .where b { font-family: var(--display); font-size: 16px; }
.elapsed { font-family: var(--display); font-weight: 700; font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bigbtn { border: 0; border-radius: 14px; padding: 18px; font-family: var(--display); font-weight: 700; font-size: 24px; letter-spacing: .06em; text-transform: uppercase; color: #fff; background: var(--c-time); width: 100%; }
.bigbtn.stop { background: var(--c-stop); }
.bigbtn.small { font-size: 17px; padding: 13px; }
.jobcard { border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.jobcard.on { border: 2px solid var(--c-stop); }
.jobcard .top { display: flex; justify-content: space-between; gap: 10px; }
.maps { display: inline-flex; gap: 6px; align-items: center; color: var(--ink); font-weight: 600; font-size: 14px; }
.maps svg { width: 18px; height: 18px; }
.tline { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14.5px; font-variant-numeric: tabular-nums; }
.tline:first-child { border-top: 0; }
.callout { border-left: 4px solid var(--c-stop); background: var(--surface-2); padding: 10px 12px; border-radius: 0 10px 10px 0; font-size: 14.5px; display: flex; flex-direction: column; gap: 8px; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline .inp { width: auto; flex: 1; min-width: 120px; }
.mini { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 13px; font-weight: 600; font-size: 14.5px; }
.mini.go { background: var(--c-time); border-color: var(--c-time); color: #fff; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 14px; font-weight: 600; }
.chips button[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.hours { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.hours table { border-collapse: collapse; width: 100%; min-width: 460px; font-variant-numeric: tabular-nums; }
.hours th, .hours td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; font-size: 14px; vertical-align: top; }
.hours th:first-child, .hours td:first-child { text-align: left; }
.hours th { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.hours .flag { color: var(--warn); font-weight: 700; }
.datenav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.datenav b { font-family: var(--display); }
.testbanner { border: 1px dashed var(--warn); color: var(--warn); border-radius: 10px; padding: 8px 12px; font-size: 13.5px; font-weight: 600; }

/* Signatures and SWMS */
.sig { position: relative; border: 1px solid var(--line); border-radius: 12px; background: #fff; height: 150px; touch-action: none; }
.sig canvas { width: 100%; height: 100%; display: block; }
.sig .hint { position: absolute; left: 14px; bottom: 10px; font-size: 13px; color: #777; pointer-events: none; }
.sig .clr { position: absolute; right: 8px; top: 8px; border: 1px solid #ddd; background: #f6f6f6; color: #222; border-radius: 8px; font-size: 13px; padding: 3px 9px; }
.sec { font-family: var(--display); font-weight: 700; font-size: 15px; padding-top: 10px; border-top: 2px solid var(--rule); }

/* Photo thumbnails on forms */
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.thumbs:empty { display: none; }
.thumb { position: relative; border-radius: 10px; overflow: hidden; background: var(--surface-2); aspect-ratio: 1; max-width: 100%; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb span { position: absolute; left: 0; right: 0; bottom: 0; font-size: 11px; font-weight: 600; padding: 3px 5px; background: rgba(10,10,10,.75); color: #fff; font-variant-numeric: tabular-nums; }
.thumb button { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(10,10,10,.75); color: #fff; font-size: 16px; line-height: 1; }

/* Talk button and Claude buttons */
.micbtn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 12px; padding: 12px 16px; font-weight: 700; font-size: 15px; }
.micbtn svg { width: 20px; height: 20px; }
.micbtn.on { background: var(--c-stop); border-color: var(--c-stop); color: #fff; animation: micpulse 1.2s ease-in-out infinite; }
@keyframes micpulse { 50% { opacity: .7; } }
@media (prefers-reduced-motion: reduce) { .micbtn.on { animation: none; } }
.mini.ai { border-color: var(--c-report); color: var(--c-report); }
.mini:disabled, .btn:disabled { opacity: .6; }
.mic-hint { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.mic-hint svg { width: 18px; height: 18px; flex: none; }
