:root {
  --navy: #101a35;
  --ink: #172341;
  --muted: #52617b;
  --bg: #edf1f8;
  --surface: #fff;
  --line: #dce4f1;
  --accent: #344fe0;
  --accent-dark: #233bbc;
  --accent-soft: #e9eeff;
  --pending: #845010;
  --pending-soft: #fff0d5;
  --complete: #086048;
  --complete-soft: #d9f8ed;
  --unlisted: #5c3ca9;
  --unlisted-soft: #efe6ff;
  --missing: #a42b3f;
  --missing-soft: #fce7ed;
  --shadow: 0 8px 25px #192c5b0c;
  --radius: 19px;
}

* { box-sizing: border-box; }
html {
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
}
body { min-width: 0; margin: 0; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .64; }
.hidden { display: none !important; }
h1, h2, p { margin: 0; }
h1, h2 { letter-spacing: -.035em; line-height: 1.12; }
h2 { font-size: 1.2rem; }
.muted, .message { color: var(--muted); }
.message:empty, .tag:empty, .error:empty { display: none; }
.error, #inspection-message { color: var(--missing); }
.app { min-height: 100dvh; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

.masthead {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--navy);
  color: #fff;
  border-bottom: 1px solid #243454;
  padding-top: env(safe-area-inset-top);
}
.topbar {
  max-width: 1120px;
  min-height: 76px;
  margin-inline: auto;
  padding: 12px clamp(12px, 3vw, 28px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand-logo {
  display: block;
  position: relative;
  flex: none;
  overflow: hidden;
  width: 62px;
  height: 51px;
  border-radius: 11px;
  background: #fff;
  border: 1px solid #dce4f1;
}
.brand-logo img { position: absolute; top: -3px; left: 4px; width: auto; height: 50px; }
.brand h1 { font-size: 1.4rem; font-weight: 850; }
.eyebrow {
  color: #a9c4ff;
  font-size: .75rem;
  font-weight: 750;
  letter-spacing: .07em;
  margin-bottom: 2px;
  text-transform: uppercase;
}
.header-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.header-actions .text-button { color: #d7e3ff; min-height: 32px; }
.pill {
  display: inline-flex;
  white-space: nowrap;
  font-size: .81rem;
  font-weight: 750;
  line-height: 1.25;
  background: #253651;
  color: #e1eaff;
  border-radius: 100px;
  padding: 7px 10px;
}
.pill.demo { background: #3d3042; color: #ffe0ae; }
.pill.online { background: #163d3f; color: #9bf1ce; }

nav {
  position: fixed;
  z-index: 6;
  inset: auto 0 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  padding: 7px 10px calc(7px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 -7px 28px #192c5b0b;
}
nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 52px;
  padding: 5px 9px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 750;
}
nav button.active { background: var(--accent-soft); color: var(--accent-dark); }
.nav-icon { font-size: 1.26rem; line-height: 1; }

main {
  max-width: 1120px;
  margin-inline: auto;
  padding: clamp(14px, 3vw, 30px) clamp(12px, 3vw, 28px) 12px;
}
.view { display: none; }
.view.active { display: block; }
.overview {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: clamp(16px, 3.5vw, 32px);
  margin-bottom: 15px;
  border-radius: var(--radius);
  background: linear-gradient(122deg, #142349 18%, #202c64 65%, #3749a6 100%);
  color: white;
  box-shadow: 0 9px 23px #18285c24;
}
.overview::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: repeating-linear-gradient(128deg, transparent 0 31px, #9bb6fc16 32px 33px, transparent 34px 51px);
  mask-image: linear-gradient(90deg, transparent 45%, #000 95%);
}
.day-heading h2 { font-size: clamp(1.65rem, 4.5vw, 2.7rem); font-weight: 850; }
.day-heading .muted { margin-top: 5px; color: #dce5ff; font-size: .94rem; }
.date-heading { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; }
.date-field { width: min(100%, 210px); }
.date-field label { color: #e5ecff; margin-bottom: 4px; }
.date-field input { text-align: start; }
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(6px, 2vw, 14px);
  margin-top: clamp(13px, 3vw, 21px);
}
.stat {
  display: flex;
  min-height: 88px;
  flex-direction: column-reverse;
  justify-content: center;
  align-items: flex-start;
  gap: 4px;
  padding: clamp(7px, 2.3vw, 17px);
  border-radius: 13px;
  font-variant-numeric: tabular-nums;
}
.stat.pending { background: var(--pending-soft); color: var(--pending); }
.stat.complete { background: var(--complete-soft); color: var(--complete); }
.stat.unlisted { background: var(--unlisted-soft); color: var(--unlisted); }
.stat strong {
  font-size: clamp(1.45rem, 4.6vw, 2.4rem);
  font-weight: 850;
  line-height: 1;
  letter-spacing: -.04em;
}
.stat span { font-size: .875rem; font-weight: 710; line-height: 1.2; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.today-content, .result-groups { display: grid; gap: 14px; align-items: start; }
.keys-results { margin: 14px 0; grid-template-columns: minmax(0, 1fr); }
#keys-reset + .message { margin-top: 8px; }
.scan-box, .queue-panel, .result-section, .stack { padding: clamp(13px, 2.5vw, 21px); }
.scan-box label { font-size: 1rem; line-height: 1.3; }
.scan-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 10px;
}
.scan-box .message, .queue-panel .message, #report-message, #inventory-message { margin-top: 8px; }
.section-heading, .result-section h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.result-section h2 { margin-bottom: 11px; }
.search { margin: 11px 0; }
label { display: block; font-size: .9rem; font-weight: 720; }
input, textarea {
  width: 100%;
  min-width: 0;
  min-height: 45px;
  padding: 10px 12px;
  border: 1px solid #cbd5e7;
  border-radius: 11px;
  background: #fafbff;
  color: var(--ink);
}
input::placeholder, textarea::placeholder { color: #596783; opacity: 1; }
input:focus, textarea:focus {
  border-color: var(--accent);
  outline: 2px solid #4368f24b;
  outline-offset: 1px;
}
textarea { resize: vertical; }
#scan-input { font-weight: 730; text-transform: uppercase; }
#scan-input::placeholder { font-weight: 500; text-transform: none; }
.primary, .secondary, .text-button {
  min-height: 44px;
  padding: 8px 13px;
  border: 0;
  border-radius: 11px;
  font-size: .9rem;
  font-weight: 750;
  line-height: 1.2;
}
.primary { background: var(--accent); color: white; }
.primary:hover, .primary:active { background: var(--accent-dark); }
.secondary { background: var(--accent-soft); color: var(--accent-dark); }
.secondary:hover { background: #dbe5ff; }
.text-button { background: transparent; color: var(--accent-dark); }
.text-button:hover { text-decoration: underline; }
button:focus-visible { outline: 2px solid #6989fa; outline-offset: 3px; }
.sync-message { padding: 10px 12px; margin-bottom: 12px; background: var(--pending-soft); border-radius: 12px; color: var(--pending); }

.list { display: grid; gap: 8px; }
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  min-height: 61px;
  padding: 10px 11px;
  background: #f7f9fe;
  border: 1px solid #e4ebf6;
  border-radius: 12px;
}
.vehicle > div { min-width: 0; }
.vehicle strong, .vehicle-details { overflow-wrap: anywhere; }
.vehicle-details {
  display: block;
  color: var(--muted);
  font-size: .875rem;
  line-height: 1.45;
}
.vehicle button { flex: 0 0 auto; }
.tag {
  flex: none;
  padding: 3px 9px;
  border-radius: 100px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: .875rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.tag.ok, .completed-results .section-total { background: var(--complete-soft); color: var(--complete); }
.tag.warn, .unchecked-results .section-total, .progress-results .section-total { background: var(--pending-soft); color: var(--pending); }
.tag.missing { background: var(--missing-soft); color: var(--missing); }
.tag.unanswered { background: var(--bg); color: var(--muted); }
#today-unlisted .section-total, .unlisted-results .section-total {
  background: var(--unlisted-soft);
  color: var(--unlisted);
}
.empty-state {
  padding: 16px 10px;
  text-align: center;
  color: var(--muted);
  background: #f7f9fe;
  border: 1px dashed #bbc8e1;
  border-radius: 12px;
}
#report-message { margin-bottom: 11px; }
.vehicle.inspected { display: block; }
.inspection-summary {
  display: grid;
  gap: 5px;
  margin: 10px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.inspection-summary > div { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.inspection-summary dt { font-size: .875rem; line-height: 1.3; }
.inspection-summary dd { margin: 0; min-width: 44px; text-align: center; }
.inspection-result-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; gap: 4px; }
.report-details { margin-bottom: 14px; }
.report-details summary { cursor: pointer; font-size: 1.12rem; font-weight: 800; }
.report-details summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.report-details summary .tag { margin-inline-start: 8px; }
.report-details .muted { margin: 8px 0 12px; }
#today-checked-list { margin-top: 10px; }
.in-progress-panel { margin-bottom: 14px; }
.inspection-help { margin-top: 8px; font-size: .9rem; }
.action-reports { margin-bottom: 18px; }
.action-reports > .muted { margin: 5px 0 12px; }
.report-rows, .export-report { margin-top: 10px; }
.issue-row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.stack { display: grid; gap: 16px; max-width: 740px; }
.stack .message, .stack input[type=file], .stack textarea { margin-top: 6px; }
input[type=file]::file-selector-button {
  margin-inline-end: 8px;
  padding: 5px 9px;
  border: 0;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font: inherit;
  cursor: pointer;
}
.unlisted-entry { display: grid; gap: 9px; border-top: 1px solid var(--line); padding-top: 12px; }
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; background: var(--navy); }
.login-card { width: min(100%, 440px); padding: 26px; display: grid; gap: 12px; }
.login-card .brand-logo { width: 115px; height: 87px; }
.login-card .brand-logo img { top: -6px; left: 6px; height: 88px; }
.login-card h1 { font-size: 2rem; }
.login-card .eyebrow { color: var(--accent-dark); }
.login-card label input { margin-top: 4px; }

#inspection {
  width: min(100% - 20px, 476px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 1px solid #aebddc;
  border-radius: var(--radius);
  color: var(--ink);
  box-shadow: 0 22px 72px #07133560;
}
#inspection::backdrop { background: #0c1638b3; }
.inspection-heading {
  padding: 16px clamp(14px, 4vw, 22px);
  background: linear-gradient(122deg, #162549, #31479b);
  color: #fff;
}
#inspection-vehicle {
  margin-top: 5px;
  color: #e0eaff;
  font-size: .9rem;
  overflow-wrap: anywhere;
}
.inspection-body { padding: 4px clamp(14px, 4vw, 22px) 12px; }
.inspection-question { border: 0; border-bottom: 1px solid var(--line); margin: 0; min-inline-size: 0; padding: 0 0 8px; }
.inspection-question legend { font-weight: 710; line-height: 1.25; padding: 9px 0 5px; }
.inspection-options, .inspection-actions { display: flex; gap: 8px; }
.inspection-options label { position: relative; flex: 1; }
.inspection-options label:last-child { flex: 1.55; }
.inspection-options input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.inspection-options span {
  display: grid;
  place-items: center;
  min-height: 44px;
  border-radius: 10px;
  background: var(--bg);
  border: 2px solid transparent;
}
.inspection-options input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.inspection-options input[value="yes"]:checked + span { background: var(--complete-soft); border-color: var(--complete); color: var(--complete); }
.inspection-options input[value="no"]:checked + span { background: var(--missing-soft); border-color: var(--missing); color: var(--missing); }
.inspection-options input[value="unanswered"]:checked + span { background: var(--pending-soft); border-color: var(--pending); color: var(--pending); }
.order-option { display: none; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; }
.inspection-question:has(input[value="no"]:checked) .order-option { display: inline-flex; }
.order-option input { width: 18px; height: 18px; margin: 0; padding: 0; accent-color: var(--accent); }
.inspection-actions {
  position: sticky;
  bottom: 0;
  justify-content: end;
  flex-wrap: wrap;
  padding: 10px clamp(14px, 4vw, 22px);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
#inspection-note-field, #inspection-message { margin-top: 8px; }

@media (min-width: 740px) {
  .app { padding-bottom: 28px; }
  nav {
    position: static;
    display: flex;
    padding: 5px;
    border: 1px solid #34456c;
    border-radius: 14px;
    background: #1b294c;
    box-shadow: none;
  }
  nav button { flex-direction: row; gap: 8px; min-height: 40px; padding-inline: 14px; color: #d9e3ff; }
  nav button.active { background: #344c90; color: #fff; }
  .header-actions { flex-direction: row; align-items: center; }
  .today-content { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .queue-panel { grid-area: 1 / 1 / 3 / 2; }
  .scan-box { grid-area: 1 / 2; }
  #today-unlisted { grid-area: 2 / 2; }
  .result-groups { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #photo-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #today-checked-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-rows { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #photo-list .empty-state, .report-rows .empty-state { grid-column: 1 / -1; }
  .overview { margin-bottom: 18px; }
}
