/* ATRA driver daily check — built for one hand, a phone, a yard at night.
   Big touch targets, high contrast, state carried by words as well as colour. */

:root {
  --ink: #0d2b31;
  --ink-soft: #4f6469;
  --paper: #eef3f3;
  --card: #ffffff;
  --line: #d3dede;
  --navy: #12343b;
  --teal: #0f6c72;
  --teal-dark: #0b555a;
  --teal-soft: #e3f0f0;
  --ok: #24693f;
  --ok-soft: #eaf5ee;
  --danger: #b0212a;
  --danger-dark: #8c1a21;
  --danger-soft: #fdf0f1;
  --warn: #8f5600;
  --warn-soft: #fdf6ea;
  --radius: 14px;
  --tap: 52px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--teal); }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }

h1 { font-size: 24px; margin: 0 0 8px; line-height: 1.2; }
h2 { font-size: 19px; margin: 0 0 10px; }
h3 { font-size: 17px; margin: 0; }

/* ---------- Shell ---------- */

.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--navy); color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.bar__brand { font-weight: 700; letter-spacing: 0.02em; }
.bar__brand span { color: #7fcdd2; font-weight: 400; }
.bar .link-btn { color: #cfe4e5; }

.wrap { max-width: 640px; margin: 0 auto; padding: 16px 16px 48px; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 14px;
}
.panel--tight { padding: 12px 16px; }
.panel--warn { border-left: 6px solid var(--warn); background: var(--warn-soft); }
.panel--ok { border-left: 6px solid var(--ok); background: var(--ok-soft); }

.muted, .hint { color: var(--ink-soft); }
.hint { font-size: 15px; margin: 6px 0 14px; }
.footer-link { text-align: center; margin-top: 24px; }

.notice { padding: 12px 14px; border-radius: 10px; border-left: 5px solid; margin: 0 0 14px; }
.notice--error { background: var(--danger-soft); border-color: var(--danger); }
.notice--ok { background: var(--ok-soft); border-color: var(--ok); }

/* ---------- Forms and buttons ---------- */

.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; margin-bottom: 14px; }
.field small { font-weight: 400; color: var(--ink-soft); }
.field input, .field textarea {
  font: inherit; font-weight: 400;
  min-height: var(--tap);
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
.field input:focus, .field textarea:focus { border-color: var(--teal); outline: none; }
.field--inline { margin: 0 0 10px; }
.field-label { font-weight: 600; margin: 16px 0 6px; }

.plate {
  font-family: "Charles Wright", "UKNumberPlate", "Arial Narrow", Arial, sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
input.plate { font-size: 24px; text-align: center; background: #fff7c2; border-color: #d8c763; }
.plate--show {
  font-size: 30px; text-align: center; margin: 0 0 12px;
  background: #fff7c2; border: 2px solid #d8c763; border-radius: 8px; padding: 8px;
}
.plate--small { font-size: 20px; margin: 0; }
.plus { color: var(--ink-soft); }

.btn {
  font: inherit; font-weight: 700;
  min-height: var(--tap);
  padding: 12px 18px;
  border-radius: 12px;
  border: 2px solid var(--teal);
  background: var(--teal);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
  touch-action: manipulation;
}
.btn:active { background: var(--teal-dark); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn--block { width: 100%; margin-top: 6px; }
.btn--quiet { background: #fff; color: var(--teal); }
.btn--ok { background: var(--ok); border-color: var(--ok); }
.btn--defect { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn--submit { margin-top: 18px; }
.link-btn {
  font: inherit; background: none; border: 0; padding: 8px 0; color: var(--teal);
  text-decoration: underline; cursor: pointer; min-height: 40px;
}
.link-btn--danger { color: var(--danger); }

.row { display: flex; gap: 10px; flex-wrap: wrap; }

.choices { border: 0; padding: 0; margin: 0 0 14px; display: grid; gap: 10px; }
.choices legend { font-weight: 600; margin-bottom: 8px; }
.choice {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--tap); padding: 10px 14px;
  border: 2px solid var(--line); border-radius: 12px; background: #fff; font-weight: 600;
}
.choice:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); }
.choice input, .check-line input, .severity input { width: 24px; height: 24px; flex: none; accent-color: var(--teal); }
.check-line { display: flex; gap: 12px; align-items: flex-start; margin: 4px 0 12px; }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin: 0; }
.facts dt { color: var(--ink-soft); font-size: 14px; }
.facts dd { margin: 0; font-weight: 600; }

/* ---------- Check screens ---------- */

.sticky-status {
  position: sticky; top: calc(48px + env(safe-area-inset-top)); z-index: 10;
  background: var(--navy); color: #fff;
  border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; font-size: 15px;
}
.sticky-status__top, .sticky-status__bottom { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.sticky-status__bottom { margin-top: 6px; color: #cfe4e5; font-size: 14px; }
.plate--tiny { font-size: 15px; letter-spacing: 0.06em; }
.progress { height: 6px; background: rgba(255, 255, 255, 0.18); border-radius: 999px; margin-top: 8px; overflow: hidden; }
.progress__bar { display: block; height: 100%; width: 0; background: #7fcdd2; border-radius: 999px; }

.steps { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; margin-bottom: 4px; scrollbar-width: none; }
.steps::-webkit-scrollbar { display: none; }
.steps__chip {
  flex: none; font: inherit; font-size: 14px; font-weight: 600;
  padding: 8px 12px; border-radius: 999px; border: 2px solid var(--line);
  background: #fff; color: var(--ink-soft); white-space: nowrap; cursor: pointer;
}
.steps__chip.is-done { border-color: var(--ok); color: var(--ok); }
.steps__chip.is-done::before { content: "✓ "; }
.steps__chip.is-current { background: var(--navy); border-color: var(--navy); color: #fff; }

.step__title { font-size: 22px; margin: 6px 0 2px; }
.step__help { margin: 0 0 10px; color: var(--ink-soft); font-size: 14px; }

.rows { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); border-left: 5px solid transparent; }
.row:last-child { border-bottom: 0; }
.row__label {
  flex: 1; min-width: 0; min-height: 58px; padding: 10px 12px;
  font: inherit; text-align: left; background: none; border: 0; color: var(--ink); cursor: pointer;
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
}
.row__name { font-weight: 600; line-height: 1.25; }
.row__meta { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--ink-soft); min-height: 0; }
.row__meta:empty { display: none; }
.row__state { font-weight: 700; }
.row__tick {
  flex: none; width: 64px; font: inherit; font-size: 26px; font-weight: 700;
  border: 0; border-left: 1px solid var(--line); background: #fff; color: var(--ok); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation;
}
.row__tick { position: relative; }
.row:not(.row--done) .row__tick { color: transparent; }
.row:not(.row--done) .row__tick::after {
  content: ""; width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--ok);
  position: absolute;
}
.row__tick--open { color: var(--teal) !important; font-size: 30px; }
.row__tick--open::after { display: none; }
.row--done .row__tick--open { color: transparent !important; font-size: 0; }
.row--done .row__tick--open::before { content: "✓"; position: static; color: #fff; font-size: 26px; }
.row__tick:active { background: var(--ok-soft); }

.row--done { border-left-color: var(--ok); }
.row--done .row__state { color: var(--ok); }
.row--done .row__tick { background: var(--ok); color: #fff; }
.row--defect, .row--damage, .row--unsealed { border-left-color: var(--danger); background: var(--danger-soft); }
.row--defect .row__state, .row--damage .row__state, .row--unsealed .row__state { color: var(--danger); }
.row--defect .row__tick, .row--damage .row__tick, .row--unsealed .row__tick { background: var(--danger); color: #fff; font-size: 0; }
.row--defect .row__tick::before, .row--damage .row__tick::before, .row--unsealed .row__tick::before {
  content: "!"; position: static; font-size: 28px;
}
.row--advisory { border-left-color: var(--warn); background: var(--warn-soft); }
.row--advisory .row__state { color: var(--warn); }
.row--advisory .row__tick { background: var(--warn); color: #fff; font-size: 0; }
.row--advisory .row__tick::before { content: "i"; position: static; font-size: 26px; font-style: italic; }
.row__cam { font-size: 14px; }
.row__state:empty { display: none; }

.step-nav { display: flex; justify-content: space-between; gap: 10px; margin: 16px 0 8px; }
.step-nav .btn { min-width: 120px; }
.btn--ready { box-shadow: 0 0 0 4px rgba(15, 108, 114, 0.25); }

.row-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-btns--3 { grid-template-columns: 1fr 1fr 1fr; }
.btn--defect-solid { background: var(--danger); border-color: var(--danger); color: #fff; }

.tag {
  display: inline-block; font-size: 13px; font-weight: 600;
  padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink-soft);
}
.tag--danger { color: var(--danger); border-color: #efc3c6; background: var(--danger-soft); }

.severity { border: 0; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.severity legend { font-weight: 600; margin-bottom: 6px; }
.severity label { display: flex; gap: 10px; align-items: center; min-height: 48px; padding: 4px 10px; border: 2px solid var(--line); border-radius: 10px; }
.severity label:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); }
.danger-note { background: var(--danger-soft); border-left: 4px solid var(--danger); padding: 10px 12px; border-radius: 8px; }

/* ---------- Item sheet ---------- */

.sheet {
  width: 100%; max-width: 640px; margin: auto auto 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
  border: 0; border-radius: 18px 18px 0 0; background: #fff; color: var(--ink);
  max-height: 92dvh; overflow-y: auto;
}
.sheet::backdrop { background: rgba(13, 43, 49, 0.55); }
.sheet__title { font-size: 20px; margin: 0 0 6px; }
.sheet__hint { margin: 0 0 8px; color: var(--ink-soft); }
.sheet__tags { margin: 0 0 14px; display: flex; gap: 6px; flex-wrap: wrap; }
.sheet__tags:empty { display: none; }
#sheet-close { margin-top: 12px; }
.sheet__kind { font-weight: 700; color: var(--danger); margin: 4px 0 10px; }

.photo-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 14px; }
.photo-slot {
  position: relative; aspect-ratio: 1; padding: 6px; overflow: hidden;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--ink-soft);
  border: 2px dashed var(--line); border-radius: 12px; background: var(--paper); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
.photo-slot small { font-weight: 400; display: block; }
.photo-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-slot.has-photo { border-style: solid; border-color: var(--ok); }
.photo-slot.has-photo span { position: relative; background: rgba(13, 43, 49, 0.7); color: #fff; padding: 2px 8px; border-radius: 999px; font-size: 12px; margin-top: auto; }
.btn--clear { background: #fff; color: var(--danger); border-color: var(--danger); margin-top: 8px; }

.signature {
  width: 100%; height: 180px;
  border: 2px dashed var(--line); border-radius: 12px; background: #fff;
  touch-action: none;
}
.cancel-form { text-align: center; margin-top: 18px; }

/* ---------- Stop screen ---------- */

.stop-card {
  background: var(--danger); color: #fff;
  border-radius: var(--radius); padding: 22px 18px; margin-bottom: 14px;
}
.stop-card h1 { font-size: 30px; letter-spacing: 0.04em; }
.stop-card__big { font-size: 22px; font-weight: 800; line-height: 1.25; }
.page-stop .bar { background: var(--danger-dark); }

/* ---------- Camera ---------- */

.camera {
  width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh;
  margin: 0; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  border: 0; background: #000; color: #fff;
}
.camera::backdrop { background: #000; }
.camera[open] { display: flex; flex-direction: column; }
.camera__frame { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.camera__frame video, .camera__frame img { width: 100%; height: 100%; object-fit: contain; }
.camera__label { text-align: center; margin: 8px 16px; font-weight: 600; }
.camera .notice { margin: 8px 16px; color: var(--ink); }
.camera__buttons { display: flex; gap: 10px; padding: 10px 16px 16px; }
.camera__buttons .btn { flex: 1; }

.busy {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(13, 43, 49, 0.55); color: #fff; font-weight: 700; font-size: 20px;
}
.busy[hidden], [hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
.check-line--confirm { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
input.pin { font-size: 28px; letter-spacing: 0.5em; text-align: center; }
a.choice--link { justify-content: space-between; color: var(--ink); text-decoration: none; }
.choice__go { font-size: 26px; color: var(--teal); }

/* --- Incidents --------------------------------------------------------- */
.bar { gap: 10px; }
.bar__incident {
  margin-left: auto; padding: 6px 10px; border-radius: 8px;
  background: var(--danger); color: #fff; font-weight: 700; font-size: 14px; text-decoration: none;
}
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:active { background: var(--danger-dark); }
.panel--danger { border-left: 6px solid var(--danger); background: var(--danger-soft); }
.safety { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.safety li { padding-left: 28px; position: relative; }
.safety li::before { content: "!"; position: absolute; left: 0; top: 0; width: 20px; height: 20px; border-radius: 50%;
  background: var(--danger); color: #fff; font-weight: 700; font-size: 13px; text-align: center; line-height: 20px; }
.media-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.media-buttons .btn { margin: 0; }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 8px; padding: 0; list-style: none; }
.media-grid li { aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--line); position: relative; }
.media-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-grid .media__busy { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(13, 43, 49, 0.55); color: #fff; font-weight: 700; font-size: 14px; }
.video-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.video-list li { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; }
.video-list .video__bar { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.video-list .video__bar span { display: block; height: 100%; width: 0; background: var(--teal); }
.video-list .video__row { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.yes-no { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 14px; border: 0; padding: 0; }
.yes-no legend { font-weight: 600; margin-bottom: 8px; }
.party { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: #fff; }
.party h3 { margin-bottom: 10px; }
.field select { font: inherit; padding: 12px; border: 2px solid var(--line); border-radius: 10px; background: #fff; }
.save-state { font-size: 14px; color: var(--ink-soft); text-align: center; margin: 6px 0 0; min-height: 1.2em; }
.missing { margin: 0 0 12px; padding-left: 20px; color: var(--danger); }
.outcome { text-align: center; padding: 26px 16px; border-radius: var(--radius); margin-bottom: 14px; color: #fff; }
.outcome h1 { font-size: 28px; margin-bottom: 10px; }
.outcome--continue { background: var(--ok); }
.outcome--return_to_yard { background: #b86e00; }
.outcome--recovery { background: var(--danger); }
.outcome--waiting { background: var(--navy); }
