/* HV Safety design system. Paper, ink, one hi-vis accent. State is carried by rails and chips,
   never by decoration. Phone first (a tech outdoors, one hand); the admin screens widen. */
:root {
  color-scheme: light dark;
  --paper: #f4f3ef;
  --card: #ffffff;
  --ink: #17191b;
  --muted: #5f6368;
  --line: #d8d6cf;
  --line-strong: #b9b6ad;
  --accent: #e4571b;
  --accent-ink: #ffffff;
  --accent-soft: #fdeee6;
  --ok: #1f7a4d;
  --ok-soft: #e4f3ea;
  --fail: #b3261e;
  --fail-soft: #fbe9e7;
  --warn-soft: #fff4d6;
  --focus: #1a5fb4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(23, 25, 27, 0.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121415;
    --card: #1b1e20;
    --ink: #ebe9e3;
    --muted: #a3a7ab;
    --line: #2f3336;
    --line-strong: #4a4f54;
    --accent: #ff7a3d;
    --accent-ink: #1b0d05;
    --accent-soft: #3a2015;
    --ok: #5fc48f;
    --ok-soft: #173125;
    --fail: #f08a82;
    --fail-soft: #3b1c19;
    --warn-soft: #3a3014;
    --focus: #7fb2ff;
    --shadow: none;
  }
  /* The logo files are ink on transparent; in the dark theme they become paper on transparent. */
  .brand img, .lockup { filter: invert(1); }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.45 -apple-system, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 600; }
p { margin: 0 0 12px; max-width: 70ch; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* Bar and page */
.bar {
  position: sticky; top: 0; z-index: 2;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
  padding-top: env(safe-area-inset-top, 0px);
}
.bar-row { display: flex; align-items: center; gap: 14px; min-height: 56px; max-width: 1160px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; font-size: 17px; }
.brand img { width: 30px; height: auto; display: block; }
.bar nav { display: flex; gap: 2px; margin-left: auto; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.bar nav::-webkit-scrollbar { display: none; }
.bar nav a { padding: 8px 10px; border-radius: 8px; text-decoration: none; font-size: 15px; white-space: nowrap; color: var(--muted); }
.bar nav a[aria-current="page"] { color: var(--ink); background: var(--paper); font-weight: 600; }
.bar form { margin: 0; }
.bar form button { width: auto; min-height: 36px; margin: 0; padding: 0 12px; background: transparent; color: var(--muted); border: 1px solid var(--line); font-size: 14px; }
.page { max-width: 1160px; margin: 0 auto; padding: 20px 16px calc(32px + env(safe-area-inset-bottom, 0px)); }
.page.narrow { max-width: 600px; }
.page-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; margin-bottom: 18px; }
.page-head .who { color: var(--muted); font-size: 15px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 18px; }
.actions form { margin: 0; }

/* Controls */
label { display: block; font-weight: 600; margin: 14px 0 6px; }
label .hint { display: block; font-weight: 400; color: var(--muted); font-size: 14px; }
input:not([type="checkbox"]):not([type="radio"]), textarea, select {
  width: 100%; font: inherit; padding: 12px 14px; min-height: 50px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--card); color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px; margin-top: 16px; padding: 0 20px;
  font: inherit; font-weight: 600; border: 0; border-radius: 10px; cursor: pointer; text-decoration: none;
  background: var(--accent); color: var(--accent-ink);
}
button.quiet, .button.quiet { background: var(--card); color: var(--ink); border: 1px solid var(--line-strong); }
button.danger { background: var(--fail); color: #fff; }
button.inline, .button.inline { width: auto; margin: 0; min-height: 44px; }
.actions button, .actions .button { width: auto; margin: 0; min-height: 44px; }
td button { width: auto; margin: 0; min-height: 36px; padding: 0 12px; font-size: 14px; }
fieldset { border: 0; margin: 18px 0 0; padding: 0; min-width: 0; }
legend { font-weight: 700; padding: 0; margin-bottom: 8px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }

/* Cards, sections, notices */
section { margin: 0 0 18px; padding: 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
section > h2 { margin-bottom: 10px; }
.notice { background: var(--warn-soft); border-radius: 8px; padding: 12px 14px; margin: 0 0 16px; }
.notice.ok { background: var(--ok-soft); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; }
@media (max-width: 480px) { .kv { grid-template-columns: 1fr; } .kv dt { margin-top: 6px; } }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 34px; font-weight: 700; letter-spacing: 0.14em; margin: 8px 0 14px; }

/* Chips and tiles */
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 13px; font-weight: 600; line-height: 1.5; background: var(--paper); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.chip.open { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.fail { background: var(--fail-soft); color: var(--fail); border-color: transparent; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 0 0 18px; }
.tile { padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.tile b { display: block; font-size: 30px; font-weight: 700; line-height: 1.1; }
.tile span { color: var(--muted); font-size: 14px; }
.tile.accent b { color: var(--accent); }
.tile.ok b { color: var(--ok); }

/* Tables */
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 0 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 600; color: var(--muted); font-size: 14px; }
tr:last-child td { border-bottom: 0; }
td form { margin: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--paper) 60%, transparent); }

/* Tech: month header, progress and sheet cards */
.month { margin: 0 0 16px; }
.month h1 { font-size: 24px; }
.month p { margin: 4px 0 0; color: var(--muted); }
.progress { display: flex; gap: 4px; margin: 14px 0 20px; }
.progress i { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.progress i.done { background: var(--ok); }
.sheet { display: block; position: relative; margin: 0 0 12px; padding: 18px 18px 18px 22px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.sheet::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--accent); }
.sheet.done::before { background: var(--ok); }
.sheet.off::before { background: var(--line-strong); }
.sheet h2 { font-size: 19px; }
.sheet .meta { color: var(--muted); font-size: 15px; margin: 4px 0 0; }
.sheet .button { margin-top: 14px; }
.empty { text-align: center; padding: 36px 18px; }
.empty h2 { font-size: 22px; margin-bottom: 6px; }
.empty .mark { width: 52px; height: 52px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: inline-flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; margin-bottom: 12px; }

/* Filling a sheet: one tappable row per line */
.line { display: flex; align-items: center; gap: 14px; margin: 0; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); font-weight: 500; cursor: pointer; }
.line + .line, .line + fieldset.line, fieldset.line + .line { margin-top: 10px; }
.line .text { flex: 1; min-width: 0; }
.line input[type="checkbox"] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.line .box { flex: none; width: 30px; height: 30px; border: 2px solid var(--line-strong); border-radius: 8px; background: var(--paper); position: relative; }
.line input:checked ~ .box { background: var(--ok); border-color: var(--ok); }
.line input:checked ~ .box::after { content: ""; position: absolute; left: 10px; top: 4px; width: 7px; height: 14px; border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg); }
.line input:focus-visible ~ .box { outline: 3px solid var(--focus); outline-offset: 2px; }
fieldset.line { flex-direction: column; align-items: stretch; cursor: default; }
fieldset.line legend { float: left; width: 100%; margin: 0 0 10px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg label { margin: 0; font-weight: 600; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 50px; border: 2px solid var(--line-strong); border-radius: 8px; background: var(--paper); cursor: pointer; }
.seg input:checked + span { color: #fff; }
.seg input[value="pass"]:checked + span { background: var(--ok); border-color: var(--ok); }
.seg input[value="fail"]:checked + span { background: var(--fail); border-color: var(--fail); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.line.text-line { flex-direction: column; align-items: stretch; cursor: default; }
.line.text-line label { margin: 0 0 6px; }
.signoff { margin-top: 22px; padding: 18px; background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius); }
.signoff h2 { margin-bottom: 4px; }
.confirm { display: flex; gap: 12px; align-items: flex-start; font-weight: 500; margin: 14px 0 0; }
.confirm input { width: 26px; height: 26px; margin: 2px 0 0; flex: none; accent-color: var(--ok); }
.answers { margin: 0; }
.answers .row { display: flex; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.answers .row:last-child { border-bottom: 0; }
.answers dt { font-weight: 500; }
.answers dd { margin: 0; text-align: right; flex: none; }

/* Sign-in */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login .card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px 24px; box-shadow: var(--shadow); }
.login .lockup { display: block; width: 180px; margin: 0 auto 10px; }
.login h1 { text-align: center; font-size: 20px; margin-bottom: 20px; }
.login form + form { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 6px; }
.login .or { text-align: center; color: var(--muted); font-size: 14px; margin: 18px 0 0; }

/* Sheet editor */
.editor-line { display: grid; grid-template-columns: 1fr 150px auto auto; gap: 10px; align-items: end; padding: 12px 0; border-bottom: 1px solid var(--line); }
.editor-line label { margin: 0; }
.editor-line .move { display: flex; gap: 6px; }
.editor-line .move button, .editor-line .remove { width: auto; min-height: 44px; margin: 0; padding: 0 12px; background: var(--card); color: var(--ink); border: 1px solid var(--line-strong); font-size: 14px; }
@media (max-width: 640px) { .editor-line { grid-template-columns: 1fr 1fr; } }

@media (prefers-reduced-motion: no-preference) {
  .sheet, .line, button { transition: background-color 120ms ease, border-color 120ms ease; }
}
@media (min-width: 720px) {
  body { font-size: 16px; }
  h1 { font-size: 30px; }
}

.mt { margin-top: 12px; }
.search { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search input { min-width: 240px; width: auto; flex: 1; }
.check-inline { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-weight: 500; }
.check-inline input { width: 24px; height: 24px; accent-color: var(--ok); }
ol, ul { padding-left: 22px; } li { margin: 0 0 8px; }
details summary { cursor: pointer; font-weight: 600; }
button[disabled] { opacity: 0.5; cursor: default; }

label > input[type="checkbox"] { width: 22px; height: 22px; margin: 0 10px 0 0; vertical-align: -5px; accent-color: var(--ok); }
fieldset legend + label { margin-top: 6px; }
fieldset label { margin: 12px 0 0; }
