/* SafeTrack shared theme. Clients are re-branded by changing the variables in :root only. */
  :root {
    --brand: #c2410c; --ink: #1c1917; --muted: #57534e; --line: #e7e5e4;
    --bg: #fafaf9; --card: #fff; --ok: #15803d; --bad: #b91c1c; --warn: #b45309;
  }
  * { box-sizing: border-box; }
  body { margin: 0; font: 16px/1.45 system-ui, -apple-system, Segoe UI, sans-serif; color: var(--ink); background: var(--bg); }
  header { background: var(--ink); color: #fff; padding: 12px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
  header b { font-size: 18px; } header .sp { flex: 1; }
  .pill { font-size: 13px; padding: 3px 10px; border-radius: 99px; background: #44403c; }
  .pill.off { background: var(--bad); } .pill.on { background: var(--ok); }
  main { max-width: 760px; margin: 0 auto; padding: 16px; }
  .card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
  select, input[type=text], input[type=number], input[type=date], input[type=time], textarea {
    width: 100%; font: inherit; padding: 10px; border: 1px solid #d6d3d1; border-radius: 8px; background: #fff; }
  button { font: inherit; cursor: pointer; }
  .btn { background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: 12px 18px; font-weight: 600; }
  .btn.ghost { background: transparent; color: var(--ink); border: 1px solid #d6d3d1; }
  .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

  /* form engine classes */
  .st-title { margin: 0 0 8px; }
  .st-section { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 12px; }
  .st-section h3 { margin: 4px 0 8px; font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
  .st-field { margin: 12px 0; }
  .st-label { display: block; font-weight: 600; margin-bottom: 4px; }
  .st-req { color: var(--bad); }
  .st-help { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
  .st-info { background: #fff7ed; border-left: 4px solid var(--brand); padding: 8px 12px; border-radius: 4px; font-size: 14px; }
  .st-seg { display: inline-flex; border: 1px solid #d6d3d1; border-radius: 8px; overflow: hidden; }
  .st-seg button { background: #fff; border: 0; padding: 10px 16px; min-width: 56px; border-right: 1px solid #d6d3d1; }
  .st-seg button:last-child { border-right: 0; }
  .st-seg button.on { background: var(--ink); color: #fff; }
  .st-seg button.pass.on { background: var(--ok); } .st-seg button.fail.on { background: var(--bad); }
  .st-check-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); }
  .st-check-row .st-comment { grid-column: 1 / -1; }
  .st-comment { margin-top: 6px; }
  .st-chips { display: flex; flex-wrap: wrap; gap: 6px; }
  .st-chip { border: 1px solid #d6d3d1; border-radius: 99px; padding: 6px 12px; background: #fff; }
  .st-reading-row { display: flex; gap: 8px; align-items: center; } .st-reading-row input { max-width: 160px; }
  .st-unit { color: var(--muted); font-size: 14px; }
  .st-out input[type=number] { border-color: var(--warn); background: #fffbeb; }
  .st-thumbs { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
  .st-thumb { position: relative; } .st-thumb img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; }
  .st-thumb button { position: absolute; top: -6px; right: -6px; border-radius: 99px; border: 0; background: var(--bad); color: #fff; width: 22px; height: 22px; }
  .st-error { color: var(--bad); font-size: 13px; margin-top: 4px; }
  .st-invalid > .st-label, .st-invalid > .st-label + * { outline-color: var(--bad); }
  .st-invalid { border-left: 3px solid var(--bad); padding-left: 8px; }

  #sigCanvas { width: 100%; height: 160px; border: 1px dashed #a8a29e; border-radius: 8px; background: #fff; }
  .sig-list { list-style: none; padding: 0; margin: 8px 0 0; }
  .sig-list li { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
  .sig-list img { height: 36px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
  .outbox { font-size: 14px; }
  .outbox li { margin: 4px 0; }
  .tag { font-size: 12px; padding: 1px 8px; border-radius: 99px; color: #fff; }
  .tag.pending { background: var(--warn); } .tag.sent { background: var(--ok); } .tag.dead { background: var(--bad); }
  pre { background: #1c1917; color: #e7e5e4; padding: 12px; border-radius: 8px; overflow: auto; font-size: 12px; max-height: 320px; }
  #toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; display: none; }

/* roster pickers + signature panel */
.st-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.st-row > input, .st-row > select { flex: 1; min-width: 140px; }
.st-search { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid #d6d3d1; border-radius: 8px; margin-bottom: 6px; }
.st-chip.on { background: #fff7ed; border-color: var(--brand); }
.st-sig-canvas, #sigCanvas { width: 100%; height: 160px; border: 1px dashed #a8a29e; border-radius: 8px; background: #fff; display: block; }
[hidden] { display: none !important; }

/* ---- Contrast: never let the browser pick button/text colours ----
   iOS Safari paints <button> text blue by default; on green or red that is unreadable.
   Every button gets an explicit colour, and filled states use white on a dark fill. */
button, select, input, textarea { color: var(--ink); }
.btn { color: #fff; }
.btn.ghost { color: var(--ink); background: #fff; }
.st-seg button { color: var(--ink); background: #fff; font-weight: 700; }
.st-seg button.on,
.st-seg button.pass.on,
.st-seg button.fail.on { color: #fff; }
.st-seg button.pass.on { background: #166534; }   /* dark green, white text: 7:1 contrast */
.st-seg button.fail.on { background: #991b1b; }   /* dark red */
.pill { color: #fff; }
.pill.on { background: #166534; }
.pill.off { background: #991b1b; }
#updatePill { background: #fff; color: var(--ink); font-weight: 700; }
.tag.sent { background: #166534; } .tag.pending { background: #92400e; } .tag.dead { background: #991b1b; }
.st-chip { color: var(--ink); }
a { color: #9a3412; }
