/* Deadset Fleet. One file, no framework, no web fonts, no animation.
   Rules this file follows:
   - Palette is fixed by the brief. Green is the single accent; yellow, orange
     and red appear only as meaning (info, nudge, hard stop), never decoration.
   - Shape lock: 4px radius on everything; pills only for status badges.
   - Yellow and orange never carry text on their own (they fail AA on white):
     they are borders and tints, text stays dark grey.
   - Input outlines are #7F8C8D (3.4:1) not #ECF0F1: a 1.2:1 outline cannot be
     seen in sunlight. #ECF0F1 is kept for dividers and card borders.
   - 8px spacing unit. Mobile first; tables become cards under 768px. */

:root {
  --color-green: #1B7A4B;
  --color-yellow: #F0C005;
  --color-orange: #E2670A;
  --color-red: #C0261A;
  --color-white: #FFFFFF;
  --color-dark: #0B0F14;
  --color-light: #E5E7EB;
  --color-muted: #4B5563;
  --color-row: #F3F4F6;
  --color-input: #6B7280;
  --tint-green: #E8F4EC;
  --tint-yellow: #FDF5CC;
  --tint-orange: #FCEADB;
  --tint-red: #F9E3E0;
  --u: 8px;
  --radius: 4px;
  --font: "Montserrat", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  --font-field: var(--font);
  --mono: "Liberation Mono", "Courier New", monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
img { max-width: 100%; height: auto; }
::selection { background: var(--color-dark); color: var(--color-white); }
body {
  margin: 0;
  background: var(--color-white);
  color: var(--color-dark);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}
/* Operator screens keep the Module 1 floor: 18px text, 48px targets. */
body.fleet--op { font-size: 18px; }
@media (min-width: 1024px) { body.fleet--admin { font-size: 14px; } }

h1, h2, h3 { font-weight: 600; line-height: 1.25; margin: 0 0 var(--u); text-wrap: balance; }
h1 { font-size: 24px; }
h2 { font-size: 18px; margin-top: calc(var(--u) * 3); }
h3 { font-size: 16px; margin-top: calc(var(--u) * 2); }
p { margin: 0 0 var(--u); max-width: 65ch; }
a { color: var(--color-dark); text-underline-offset: 3px; }
code, .mono { font-family: var(--mono); font-size: 14px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--color-dark); outline-offset: 2px; }

/* ---- layout ---- */
.page { max-width: 720px; margin: 0 auto; padding: calc(var(--u) * 2); }
.fleet--op h1, .fleet--op .section-head { font-family: var(--font-field); }
.fleet--op h1 { font-size: 28px; font-weight: 800; letter-spacing: .01em; }
.fleet--op .section-head { font-weight: 700; }
.stack > * + * { margin-top: var(--u); }
.grid { display: grid; gap: var(--u); }
.grid > * { min-width: 0; }
.grid--2col { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.flex { display: flex; gap: var(--u); }
.flex--between { justify-content: space-between; align-items: center; }
.flex--center { justify-content: center; align-items: center; }
.flex--wrap { flex-wrap: wrap; }

.shell { padding: calc(var(--u) * 2); }
.side { margin-bottom: calc(var(--u) * 2); }
.side a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 calc(var(--u) * 1.5); color: var(--color-dark); text-decoration: none; }
.bar__who a { display: inline-flex; align-items: center; min-height: 44px; }
.side a[aria-current="page"] { font-weight: 700; color: var(--color-dark); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px; }
@media (min-width: 1024px) {
  .shell { display: grid; grid-template-columns: 192px minmax(0, 1fr); gap: calc(var(--u) * 3); padding: calc(var(--u) * 3); }
  .side { margin: 0; }
  .side a { display: block; padding: var(--u) 0; }
}

.jump { margin: calc(var(--u) * 2) 0 0; }
.jump a, .link-block { display: inline-flex; align-items: center; min-height: 44px; padding-right: calc(var(--u) * 2); }
.link-block { padding-right: 0; }

/* ---- text helpers ---- */
.text-muted { color: var(--color-muted); }
.text-bold { font-weight: 600; }
.text-center { text-align: center; }
.text-small { font-size: max(.875em, 13px); }
.mt-8 { margin-top: var(--u); } .mt-16 { margin-top: calc(var(--u) * 2); } .mt-24 { margin-top: calc(var(--u) * 3); }
.mb-0 { margin-bottom: 0; }
.p-16 { padding: calc(var(--u) * 2); }
.nowrap { white-space: nowrap; }
.rel { display: block; color: var(--color-muted); font-size: max(.875em, 13px); }

/* ---- status badge ---- */
.badge {
  display: inline-block; padding: 2px var(--u); border-radius: 999px; border: 1px solid transparent;
  font-size: max(.875em, 13px); font-weight: 600; line-height: 1.5; white-space: nowrap;
}
.badge--available { background: var(--color-green); color: var(--color-white); }
.badge--critical { background: var(--color-red); color: var(--color-white); }
.badge--warning, .badge--unavailable { background: var(--tint-orange); border-color: var(--color-orange); color: var(--color-dark); }
.badge--info { background: var(--tint-yellow); border-color: var(--color-yellow); color: var(--color-dark); }
.badge--neutral { background: var(--color-light); border-color: var(--color-input); color: var(--color-dark); }

/* ---- alert ---- */
.alert {
  padding: calc(var(--u) * 2); border: 1px solid var(--a, var(--color-dark)); border-radius: var(--radius);
  background: var(--bg, var(--color-light)); margin: 0 0 var(--u);
}
.alert > :last-child { margin-bottom: 0; }
.alert--success { --a: var(--color-green); --bg: var(--tint-green); }
.alert--warning { --a: var(--color-orange); --bg: var(--tint-orange); border-width: 2px; }
.alert--critical { --a: var(--color-red); --bg: var(--tint-red); border-width: 2px; }
.alert--info { --a: var(--color-yellow); --bg: var(--tint-yellow); border-width: 2px; }
.alert > summary { display: flex; align-items: center; min-height: 48px; cursor: pointer; font-weight: 600; }
.alert[open] > summary { margin-bottom: 4px; }
.hard-stop { background: var(--color-red); color: var(--color-white); padding: calc(var(--u) * 3) calc(var(--u) * 2); border-radius: var(--radius); }
.hard-stop h1, .hard-stop__title { font-family: var(--font-field); font-size: 34px; font-weight: 800; letter-spacing: .02em; line-height: 1.15; margin: 0 0 var(--u); }
.hard-stop a { color: var(--color-white); }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px;
  padding: var(--u) calc(var(--u) * 2); border-radius: var(--radius); border: 1px solid var(--color-dark);
  background: var(--color-white); color: var(--color-dark); font: inherit; font-size: 16px; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn--primary { background: var(--color-dark); border-color: var(--color-dark); color: var(--color-white); }
.btn--secondary { background: var(--color-white); color: var(--color-dark); }
/* A long label (the pack page's download buttons) must wrap on a phone, not push the page wider than the screen. */
@media (max-width: 480px) {
  .btn { white-space: normal; text-align: center; max-width: 100%; }
}
.btn--danger { background: var(--color-red); border-color: var(--color-red); color: var(--color-white); }
.btn--block { display: flex; width: 100%; }
.btn--small { min-height: 32px; padding: 2px var(--u); font-size: 14px; }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }
.btn:active { transform: translateY(1px); }
@media (hover: hover) { .btn:hover { filter: brightness(.9); } }
.actions { display: flex; flex-wrap: wrap; gap: var(--u); }
.actions form { margin: 0; }

/* ---- forms ---- */
label, .label { display: block; font-weight: 600; margin: 0 0 4px; }
.req { font-weight: 400; color: var(--color-muted); }
.hint { color: var(--color-muted); font-size: max(.875em, 13px); margin: 0 0 var(--u); }
.input, select.input, textarea.input {
  display: block; width: 100%; min-height: 48px; padding: var(--u); font: inherit; font-size: 16px;
  color: var(--color-dark); background: var(--color-white); border: 1px solid var(--color-input); border-radius: var(--radius);
}
textarea.input { min-height: 96px; }
.input { caret-color: var(--color-dark); }
.input:focus { border: 2px solid var(--color-dark); padding: 7px; }
.input--mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.input--error, .input--error:focus { border-color: var(--color-red); }
.field { margin: 0 0 calc(var(--u) * 2); }
.field-error { color: var(--color-red); font-weight: 600; margin: 4px 0 0; }
.error-summary { border: 2px solid var(--color-red); padding: calc(var(--u) * 2); margin: 0 0 calc(var(--u) * 2); border-radius: var(--radius); }
.error-summary h2 { margin-top: 0; color: var(--color-red); }

/* prestart check card: question on top, answers below, tier as a 4px left border */
.check {
  --tier: var(--color-green);
  border: 1px solid var(--color-light); border-left: 4px solid var(--tier); border-radius: var(--radius);
  padding: calc(var(--u) * 2); margin: 0 0 var(--u); min-width: 0;
}
.check--green { --tier: var(--color-green); }
.check--yellow { --tier: var(--color-yellow); }
.check--orange { --tier: var(--color-orange); }
.check--red { --tier: var(--color-red); background: var(--tint-red); }
.check legend { display: table; max-width: 100%; white-space: normal; font-weight: 600; padding: 0; margin-bottom: 4px; }
.check__help { color: var(--color-muted); font-size: max(.875em, 13px); margin: 0 0 var(--u); }
.choices { display: flex; flex-wrap: wrap; gap: calc(var(--u) * 1.5); }
.choice {
  display: flex; align-items: center; gap: 6px; flex: 1 1 88px; min-height: 48px; padding: 0 8px;
  margin: 0; font-weight: 600; font-size: 16px; border: 1px solid var(--color-input); border-radius: var(--radius); cursor: pointer;
  background: var(--color-white);
}
.choice input { width: 22px; height: 22px; margin: 0; accent-color: var(--color-dark); flex: none; }
.choice:has(input:checked), .choice.is-checked { background: var(--color-dark); border-color: var(--color-dark); color: var(--color-white); }
.check--red .choice:has(input:checked), .check--red .choice.is-checked { background: var(--color-red); border-color: var(--color-red); }
.check--orange .choice:has(input:checked), .check--orange .choice.is-checked { background: var(--color-dark); }
#q17 { border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-top-color: var(--color-dark); border-right-color: var(--color-dark); border-bottom-color: var(--color-dark); }
.sig { margin-top: calc(var(--u) * 2); }
.sig summary { min-height: 48px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }
.sig canvas { width: 100%; max-width: 400px; height: 200px; background: var(--color-white); border: 1px solid var(--color-input); border-radius: var(--radius); touch-action: none; display: block; margin-bottom: var(--u); }
.stamp { border: 2px solid var(--color-dark); border-radius: var(--radius); padding: calc(var(--u) * 2); }
.stamp dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 4px calc(var(--u) * 2); }
.stamp dt { color: var(--color-muted); }
.stamp dd { margin: 0; font-weight: 600; }
.stamp__ref { font-family: var(--mono); font-size: 24px; font-weight: 700; margin: 0 0 var(--u); }

.section-head { font-size: 18px; margin: calc(var(--u) * 4) 0 var(--u); }
.section-head:first-child { margin-top: calc(var(--u) * 2); }
.section-head__count { font-weight: 400; font-size: 14px; color: var(--color-muted); }

/* ---- tile (dashboard) ---- */
.tile { border: 1px solid var(--color-light); border-radius: var(--radius); padding: calc(var(--u) * 2); }
.tile--unavailable { border: 2px solid var(--color-red); }
.tile--warning { border: 2px solid var(--color-orange); }
.tile h2, .tile h3 { margin-top: 0; font-size: 16px; }
.tile a { display: inline-flex; align-items: center; min-height: 44px; }
.tile details > summary { cursor: pointer; font-weight: 600; min-height: 32px; }

/* summary strip: plain figures, no cards, so the numbers breathe */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: var(--u); border-top: 1px solid var(--color-light); border-bottom: 1px solid var(--color-light); padding: calc(var(--u) * 2) 0; margin: 0 0 calc(var(--u) * 2); }
.stats__n { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stats__n--bad { color: var(--color-red); }
.stats__n--warn { color: var(--color-dark); border-bottom: 3px solid var(--color-orange); display: inline-block; }
.stats__l { color: var(--color-muted); font-size: max(.875em, 13px); }

/* ---- table ---- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 600; font-size: 14px; padding: var(--u) 12px; border-bottom: 1px solid var(--color-light); white-space: nowrap; }
.table th a { color: inherit; text-decoration: none; }
.table th[aria-sort="ascending"] a::after { content: " \2191"; }
.table th[aria-sort="descending"] a::after { content: " \2193"; }
.table td { font-size: 14px; padding: var(--u) 12px; vertical-align: top; }
.table tbody tr:nth-child(even) { background: var(--color-row); }
.table td.actions-col { text-align: right; }
@media (max-width: 767px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr, .table tbody tr:nth-child(even) { background: var(--color-white); border: 1px solid var(--color-light); border-radius: var(--radius); margin-bottom: var(--u); padding: var(--u); }
  .table td { display: flex; justify-content: space-between; gap: calc(var(--u) * 2); padding: 4px 0; text-align: right; }
  .table td::before { content: attr(data-label); font-weight: 600; color: var(--color-muted); text-align: left; }
  .table td { flex-wrap: wrap; min-width: 0; overflow-wrap: anywhere; }
  .table td .choice { width: auto; min-width: 0; flex: 0 1 auto; }
  .table td.col-low { display: none; }
  .table td.actions-col { justify-content: flex-start; text-align: left; }
  .table td.actions-col::before { content: none; }
  /* phone: every control reaches 44px */
  .btn--small { min-height: 44px; padding: 4px 12px; }
  .side a, .bar a { display: inline-flex; align-items: center; min-height: 44px; }
  details > summary, .tile details > summary { min-height: 44px; display: flex; align-items: center; }
  .table td a:not(.btn) { display: inline-flex; align-items: center; min-height: 44px; }
}

/* ---- timeline (audit trail) ---- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { margin: 0 0 var(--u); padding: var(--u) calc(var(--u) * 1.5); border: 1px solid var(--color-light); border-radius: var(--radius); }
.timeline .who { font-weight: 600; }

/* ---- modal (native dialog; the only place absolute positioning is used, by the UA) ---- */
dialog.modal { border: 0; border-radius: var(--radius); padding: calc(var(--u) * 2); width: calc(100% - 32px); max-width: 480px; color: var(--color-dark); }
dialog.modal::backdrop { background: rgba(44, 62, 80, .6); }
dialog.modal form { margin: 0; }
.modal__close { float: right; min-height: 32px; min-width: 32px; padding: 0 var(--u); }
.modal .btn--block { margin: calc(var(--u) * 2) 0 0; border-radius: var(--radius); }

/* ---- states ---- */
.empty { text-align: center; padding: calc(var(--u) * 4) calc(var(--u) * 2); color: var(--color-muted); }
.loading { color: var(--color-muted); }

/* ---- breakpoints ---- */
@media (max-width: 480px) { .check { padding: 12px; } }
@media (min-width: 768px) { .page { padding: calc(var(--u) * 3); } }
@media (min-width: 1024px) {
  .btn { min-height: 32px; font-size: 14px; }
  body.fleet--op .btn { min-height: 48px; font-size: 18px; }
  .input, select.input, textarea.input { min-height: 32px; font-size: 14px; }
}
@media print { .side, .bar, .actions { display: none; } }

/* ---- bulk defect actions ---- */
.pick { display: inline-flex; align-items: center; gap: var(--u); min-height: 44px; min-width: 44px; cursor: pointer; font-weight: 600; }
.pick input { width: 24px; height: 24px; margin: 0; accent-color: var(--color-dark); }
.pick[hidden], .bulk-bar [hidden] { display: none; }
.table .select-col { width: 1%; white-space: nowrap; }
.bulk-bar { margin-top: calc(var(--u) * 2); padding: calc(var(--u) * 2); border: 1px solid var(--color-light); border-radius: var(--radius); }
.bulk-bar h2, .bulk-bar h3 { margin-top: 0; }
@media (max-width: 767px) {
  .bulk-bar .btn { width: 100%; }
  .table td a:not(.btn) { padding: 12px 0; }
}

/* ---- printable QR label cards (field register: charcoal caption band, plant ID first) ---- */
.label-card { border: 2px solid var(--color-dark); border-radius: var(--radius); overflow: hidden; background: var(--color-white); }
.label-card__head { background: var(--color-dark); color: var(--color-white); padding: var(--u) calc(var(--u) * 2); }
.label-card__head h2 { margin: 0; font-family: var(--font-field); font-weight: 800; font-size: 22px; letter-spacing: .06em; }
.label-card__body { padding: calc(var(--u) * 2); }
.label-card__plant { margin: 0 0 4px; font-family: var(--font-field); font-weight: 800; font-size: 36px; line-height: 1.1; }
.label-card__what { color: var(--color-muted); }
.label-card__foot { margin-top: var(--u); padding-top: var(--u); border-top: 1px solid var(--color-light); }
@media print {
  .no-print { display: none; }
  .label-card { break-inside: avoid; }
  .shell { display: block; padding: 0; }
}
.notes-list { overflow-wrap: anywhere; }

/* ---- operator flow: quiet, quick, fewer boxes ---- */
.fleet--op .check { border-width: 0 0 0 4px; border-left-style: solid; padding: 8px 0 8px 12px; margin: 0 0 12px; }
.fleet--op .check legend { font-size: 18px; line-height: 1.3; }
.fleet--op .choices { gap: 8px; }
.fleet--op .choice { flex: 1 1 calc(33.333% - 6px); min-width: 0; min-height: 48px; font-size: 16px; font-weight: 600; justify-content: center; }
.fleet--op .choice input { width: 20px; height: 20px; }
.fleet--op #q17 { border-width: 0 0 0 4px; border-left-color: var(--tier); }
.fleet--op .check--red { background: var(--tint-red); padding-right: 12px; }
.fleet--op .identity { display: grid; gap: 12px; margin: 0 0 16px; }
.fleet--op .identity .field { margin: 0; }
.fleet--op .reminders { margin: 0 0 16px; }
.fleet--op .reminders summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.fleet--op .signoff { border-left-color: var(--color-dark); padding-bottom: 0; }
.fleet--op .confirm-line { font-size: 32px; line-height: 1.15; margin: 8px 0 0; }
.fleet--op .confirm-ref { font-size: 18px; margin-bottom: 8px; }

/* optional operator Light/Dark switch (admin turns it on); muted, small, below the content */
.theme-switch { text-align: center; color: var(--steel-600, #4B5563); margin: 24px 16px; }
.theme-switch a[aria-current="true"] { font-weight: 700; text-decoration: none; }

/* settings groups and large radio/checkbox rows */
.settings-group { border: 0; padding: 0; margin: 0 0 calc(var(--u) * 3); }
.settings-group legend { font-size: 20px; font-weight: 700; padding: 0; margin-bottom: var(--u); }
.choice-row { display: flex; align-items: center; gap: 12px; min-height: 44px; font-weight: 600; cursor: pointer; }
.choice-row input { width: 24px; height: 24px; margin: 0; flex: none; accent-color: var(--color-dark); }

/* operator and console disclosure rows reach 44px */
.fleet details > summary { min-height: 44px; display: flex; align-items: center; }
.table td a:not(.btn), .page a.link-block { min-height: 44px; }
.table td a:not(.btn) { display: inline-flex; align-items: center; }
.table th a { display: inline-flex; align-items: center; min-height: 32px; }

/* ---- audit page ---- */
.audit-hash { overflow-wrap: anywhere; }
.audit-go { display: flex; gap: var(--u); align-items: flex-end; flex-wrap: wrap; }
.audit-changes { margin: 0; padding-left: 16px; }
.audit-pager { align-items: center; margin-top: calc(var(--u) * 2); }
.audit-page { color: var(--color-muted); }
@media (max-width: 767px) { .audit-changes { padding-left: 0; list-style: none; text-align: right; } }

/* Scan choice screen (/m/{token}): two big targets. Orange only where something needs attention. */
.scan-choice { display: flex; flex-direction: column; gap: calc(var(--u) * 2); margin: calc(var(--u) * 3) 0; }
.scan-choice__btn { display: flex; flex-direction: column; justify-content: center; gap: 4px; min-height: 96px; padding: calc(var(--u) * 2) calc(var(--u) * 3);
  border: 2px solid var(--color-dark); border-radius: var(--radius); background: var(--color-dark); color: var(--color-white); text-decoration: none; font-weight: 700; font-size: 22px; line-height: 1.2; }
.scan-choice__btn span { font-size: 15px; font-weight: 500; }
.scan-choice__btn--alt { background: var(--color-white); color: var(--color-dark); }
.scan-choice__btn--attention { border-color: var(--color-orange); border-width: 5px; }
.scan-choice__btn:focus-visible { outline: 3px solid var(--color-orange); outline-offset: 2px; }
.scan-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Share and Download pair (records PDF). */
.share-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
.share-row .btn { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; }
.share-note { min-height: 1.4em; margin: 0; font-weight: 600; }

/* training register: the Renew and Edit disclosures inside tables meet the 44px touch target */
.training-details > summary { display: inline-flex; align-items: center; min-height: 44px; cursor: pointer; font-weight: 600; }
.training-details form { margin-top: var(--u); }

/* visually hidden but read by screen readers (table captions): the public pages load fleet.css but not account.css or start.css,
   so a caption marked sr-only was showing as text in the stacked phone layout */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* a heading's hyphenated word (a model such as PC138US-11) stays on one line */
.nb { white-space: nowrap; }

/* touch screens: plain text links need a 44px tap target */
@media (pointer: coarse) {
  .help-link a, .doc-links li > a, p.text-small > a { display: inline-flex; align-items: center; min-height: 44px; }
}
