/* Safety Copilot app. Same colour tokens as the site (assets/css/theme.css), built for phones. */
@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/InterVariable-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --brand-50: #ecf9f9;
  --brand-100: #d2f1f1;
  --brand-400: #5cbfbf;
  --brand-600: #2a8585;
  --brand-700: #1f6868;
  --brand-800: #154a4a;
  --ink: #0b1220;
  --ink-muted: #3f4a5c;
  --ink-faint: #64748b;
  --surface: #ffffff;
  --surface-2: #fafaf7;
  --surface-3: #f1f3f5;
  --border: rgba(11, 18, 32, 0.1);
  --border-strong: rgba(11, 18, 32, 0.2);
  --accent: var(--brand-600);
  --accent-ink: #ffffff;
  --accent-soft: var(--brand-50);
  --pass: #15803d;
  --pass-soft: #e8f6ec;
  --fail: #b91c1c;
  --fail-soft: #fdecec;
  --na: #64748b;
  --na-soft: #eef1f5;
  --attention: #92400e;
  --attention-soft: #fef6e7;
  --radius: 12px;
  --font: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f4f6fa;
    --ink-muted: #b4bfcf;
    --ink-faint: #94a3b8;
    --surface: #0f1722;
    --surface-2: #0a1018;
    --surface-3: #18222f;
    --border: rgba(244, 246, 250, 0.1);
    --border-strong: rgba(244, 246, 250, 0.2);
    --accent: var(--brand-400);
    --accent-ink: #062020;
    --accent-soft: rgba(92, 191, 191, 0.14);
    --pass: #4ade80;
    --pass-soft: rgba(74, 222, 128, 0.12);
    --fail: #f87171;
    --fail-soft: rgba(248, 113, 113, 0.13);
    --na: #a0aec0;
    --na-soft: rgba(160, 174, 192, 0.14);
    --attention: #fbbf24;
    --attention-soft: rgba(251, 191, 36, 0.12);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface-2);
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.5rem; letter-spacing: -0.01em; }
h2 { font-size: 1.125rem; margin-top: 1.5rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.75rem; }
form { margin-bottom: 1rem; }
.loading { padding: 2rem 1rem; text-align: center; color: var(--ink-faint); }

#app { max-width: 720px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }

/* Top bar */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 0.5rem;
  margin: 0 -16px 1rem; padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.bar-title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-back { text-decoration: none; font-size: 1.5rem; line-height: 1; padding: 0.25rem 0.5rem 0.25rem 0; color: var(--ink); }
.bar-status { font-size: 0.8125rem; color: var(--ink-faint); white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 0.5rem; text-decoration: none; color: var(--ink); font-weight: 700; }
.brand img { height: 26px; width: auto; }
@media screen and (prefers-color-scheme: dark) { .brand img, .report-head img { filter: invert(1) hue-rotate(180deg); } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 44px; padding: 0.6rem 1rem; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-danger { color: var(--fail); border-color: var(--fail); }
.btn-small { min-height: 36px; padding: 0.35rem 0.75rem; font-size: 0.875rem; }
.btn-block { display: flex; width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0; }
.link-btn { background: none; border: 0; padding: 0.25rem 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }

/* Cards and lists */
.card {
  display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.875rem 1rem; margin-bottom: 0.625rem; color: var(--ink); text-decoration: none;
}
a.card:active { background: var(--surface-3); }
.card-title { font-weight: 600; }
.card-meta { font-size: 0.875rem; color: var(--ink-faint); }
.muted { color: var(--ink-faint); }
.small { font-size: 0.875rem; }
.hero { padding: 1rem 0 0.5rem; }
.hero p { color: var(--ink-muted); }
.empty { padding: 1rem; border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--ink-faint); text-align: center; }
.chip {
  display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 999px;
  background: var(--surface-3); color: var(--ink-muted); margin-right: 0.25rem;
}
.chip-checklist { background: var(--accent-soft); color: var(--accent); }
.chip-talk { background: var(--attention-soft); color: var(--attention); }
.chip-open { background: var(--fail-soft); color: var(--fail); }
.chip-closed { background: var(--pass-soft); color: var(--pass); }
.chips { display: flex; gap: 0.5rem; overflow-x: auto; margin: 0.5rem 0 0.75rem; }
.chips button {
  flex: none; min-height: 36px; padding: 0.3rem 0.85rem; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 0.875rem; cursor: pointer;
}
.chips button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Forms */
label.field { display: block; margin-bottom: 0.875rem; font-weight: 600; font-size: 0.9375rem; }
label.field span.hint { display: block; font-weight: 400; color: var(--ink-faint); font-size: 0.8125rem; }
input[type="text"], input[type="search"], input[type="date"], textarea {
  display: block; width: 100%; margin-top: 0.3rem; padding: 0.65rem 0.75rem; min-height: 44px;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 400;
}
textarea { min-height: 72px; resize: vertical; }
input:focus-visible, textarea:focus-visible, .btn:focus-visible, .seg button:focus-visible { outline: 3px solid var(--brand-400); outline-offset: 2px; }

/* Checklist items */
.meta-card { font-size: 0.9375rem; }
.meta-card dl { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.75rem; margin: 0; }
.meta-card dt { color: var(--ink-faint); }
.meta-card dd { margin: 0; overflow-wrap: anywhere; }
/* Progress meter along the bottom edge of the top bar */
.bar-meter { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--surface-3); }
.bar-meter span { display: block; height: 100%; background: var(--accent); width: 0; transition: width 0.2s; }
.section-title { margin-top: 1.25rem; }
.item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.875rem; margin-bottom: 0.625rem; }
.item[data-r="pass"] { border-left: 4px solid var(--pass); }
.item[data-r="fail"] { border-left: 4px solid var(--fail); }
.item[data-r="na"] { border-left: 4px solid var(--na); }
.item-text { margin: 0 0 0.25rem; }
.ref { display: block; font-size: 0.8125rem; color: var(--ink-faint); margin-bottom: 0.5rem; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; margin: 0.5rem 0; }
.seg button {
  min-height: 44px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
.seg button[data-v="pass"][aria-pressed="true"] { background: var(--pass); border-color: var(--pass); color: #fff; }
.seg button[data-v="fail"][aria-pressed="true"] { background: var(--fail); border-color: var(--fail); color: #fff; }
.seg button[data-v="na"][aria-pressed="true"] { background: var(--na); border-color: var(--na); color: #fff; }
@media (prefers-color-scheme: dark) {
  .seg button[aria-pressed="true"] { color: #0a1018 !important; }
}
.item-tools { display: flex; gap: 1rem; }
.defect { margin-top: 0.75rem; padding: 0.75rem; border-radius: 10px; background: var(--fail-soft); }
.defect h3 { color: var(--fail); font-size: 0.9375rem; }
.defect .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.photos { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.photo { position: relative; }
.photo img { display: block; width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.photo-missing { display: flex; align-items: center; justify-content: center; width: 96px; height: 96px; padding: 0.4rem; border-radius: 8px; border: 1px dashed var(--border-strong); font-size: 0.75rem; text-align: center; color: var(--ink-faint); }
.photo button {
  position: absolute; top: -8px; right: -8px; width: 28px; height: 28px; border-radius: 50%;
  border: 0; background: var(--ink); color: var(--surface); font-size: 1rem; line-height: 1; cursor: pointer;
}
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Toolbox talk */
.talk-list { list-style: none; padding: 0; margin: 0; }
.talk-list li { margin-bottom: 0.5rem; }
.talk-list button {
  display: flex; gap: 0.75rem; width: 100%; text-align: left; align-items: flex-start;
  padding: 0.75rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
  color: var(--ink); font: inherit; cursor: pointer;
}
.talk-list .tick {
  flex: none; width: 24px; height: 24px; border-radius: 6px; border: 2px solid var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.875rem; font-weight: 700;
}
.talk-list button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.talk-list button[aria-pressed="true"] .tick { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.why { background: var(--attention-soft); border-radius: var(--radius); padding: 0.875rem 1rem; }
.attendee { display: flex; align-items: center; gap: 0.75rem; }
.attendee img.sig-img { height: 44px; width: auto; max-width: 40%; background: #fff; border-radius: 6px; border: 1px solid var(--border); }
.attendee .who { flex: 1; min-width: 0; }

/* Signature pad: always white, like paper */
.sig-wrap { margin: 0.3rem 0 0.75rem; }
.sig {
  display: block; width: 100%; height: 160px; background: #fff; border: 1px dashed #94a3b8; border-radius: 10px;
  touch-action: none; cursor: crosshair;
}
.sig-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.8125rem; color: var(--ink-faint); margin-top: 0.25rem; }

/* Sticky bottom action */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border);
}
.dock-inner { max-width: 688px; margin: 0 auto; display: flex; gap: 0.5rem; }
.dock-inner .btn { flex: 1; }

/* Report */
.report-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.75rem; }
.report-head img { height: 30px; width: auto; }
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; margin: 0.75rem 0; }
.summary div { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 0.5rem; text-align: center; }
.summary strong { display: block; font-size: 1.25rem; }
.summary .s-pass strong { color: var(--pass); }
.summary .s-fail strong { color: var(--fail); }
.result { display: inline-block; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; padding: 0.1rem 0.45rem; border-radius: 6px; margin-right: 0.4rem; }
.result-pass { background: var(--pass-soft); color: var(--pass); }
.result-fail { background: var(--fail-soft); color: var(--fail); }
.result-na { background: var(--na-soft); color: var(--na); }
.result-none { background: var(--surface-3); color: var(--ink-faint); }
.r-item { padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.r-item:last-child { border-bottom: 0; }
.signed-box { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.signed-box img { height: 70px; width: auto; background: #fff; border: 1px solid var(--border); border-radius: 8px; }
.fingerprint { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.8125rem; overflow-wrap: anywhere; }
table.att { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
table.att th, table.att td { text-align: left; padding: 0.4rem 0.3rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.att img { height: 40px; width: auto; background: #fff; }
.event { font-size: 0.9375rem; padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.how summary { font-weight: 600; cursor: pointer; }
.how ul, .card ul.small { margin: 0.5rem 0 0; padding-left: 1.25rem; }
.danger { margin-top: 2.5rem; padding-top: 0.5rem; border-top: 1px solid var(--border); }
.danger .btn { margin-bottom: 1rem; }
.foot { margin-top: 2rem; font-size: 0.875rem; color: var(--ink-faint); text-align: center; }
.foot a { color: var(--ink-faint); }
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 10;
  background: var(--ink); color: var(--surface); padding: 0.5rem 1rem; border-radius: 999px; font-size: 0.875rem;
}

@media print {
  /* Paper is always light, whatever the phone's theme. */
  :root {
    --ink: #000; --ink-muted: #333; --ink-faint: #555;
    --surface: #fff; --surface-2: #fff; --surface-3: #f1f3f5;
    --border: #ccc; --border-strong: #999;
    --accent: #1f6868; --accent-soft: #ecf9f9;
    --pass: #15803d; --pass-soft: #e8f6ec; --fail: #b91c1c; --fail-soft: #fdecec;
    --na: #64748b; --na-soft: #eef1f5; --attention: #92400e; --attention-soft: #fef6e7;
    color-scheme: light;
  }
  body { background: #fff; color: #000; font-size: 11pt; }
  #app { max-width: none; padding: 0; }
  .bar, .dock, .no-print, .toast { display: none !important; }
  .card, .item, .summary div { border-color: #ccc; break-inside: avoid; }
  .r-item, .event, table.att tr { break-inside: avoid; }
  h1, h2, h3 { break-after: avoid; page-break-after: avoid; }
  .keep, .signed-box, .summary, .meta-card { break-inside: avoid; page-break-inside: avoid; }
  .photo img { width: 140px; height: 140px; }
  a { color: #000; text-decoration: none; }
  .brand img, .report-head img { filter: none !important; }
}
