:root {
  --blue: #2e9cdf;
  --blue-dark: #1b7fbf;
  --blue-ink: #0d3b5c;
  --sun: #ffd400;
  --ink: #111827;
  --text: #3d444e;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #ffffff;
  --bg-soft: #eef5fb;
  --ok: #059669;
  --ok-bg: #d1fae5;
  --future: #d97706;
  --future-bg: #fef3c7;
  --immediate: #e11d48;
  --immediate-bg: #ffe4e6;
  --na: #6b7280;
  --na-bg: #f3f4f6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 14px rgba(16,24,40,.06);
  --font: "Helvetica Neue", Helvetica, Arial, "Liberation Sans", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--text); background: var(--bg-soft);
  font-size: 16px; line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3 { color: var(--ink); margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
a { color: var(--blue-dark); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.pad { padding: 2rem 1rem; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .03em; }
[hidden] { display: none !important; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 3px solid var(--sun);
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .5rem .75rem; padding-top: max(.5rem, env(safe-area-inset-top));
}
.brand img { height: 30px; width: auto; display: block; max-width: 58vw; }
.nav { display: flex; gap: .25rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.nav a, .nav button {
  font: inherit; font-size: .85rem; font-weight: 600; color: var(--blue-ink); text-decoration: none;
  background: none; border: 0; padding: .45rem .55rem; border-radius: 8px; cursor: pointer;
}
.nav a.active { background: var(--bg-soft); color: var(--blue-dark); }
@media (max-width: 639px) {
  .top { flex-wrap: wrap; padding-bottom: .25rem; }
  .brand img { height: 26px; }
  .nav { width: 100%; justify-content: space-between; flex-wrap: nowrap; border-top: 1px solid var(--line); padding-top: .2rem; }
  .nav a, .nav button { padding: .45rem .5rem; }
  .nav button { margin-left: auto; color: var(--muted); }
}

.wrap { max-width: 760px; margin: 0 auto; padding: 1rem .75rem 7rem; }

/* Cards & forms */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem; }
.card.narrow { max-width: 420px; margin: 1.5rem auto; }
label { display: block; font-weight: 600; color: var(--ink); font-size: .9rem; margin: .75rem 0 .3rem; }
input, select, textarea {
  font: inherit; font-size: 16px; width: 100%; padding: .7rem .75rem; border: 1.5px solid #cbd5e1;
  border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(46,156,223,.2); }
textarea { min-height: 70px; resize: vertical; }
.vin-input { font-size: 1.25rem; text-transform: uppercase; letter-spacing: .08em; font-family: ui-monospace, Menlo, Consolas, monospace; }
.hint { font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.err { color: var(--immediate); font-weight: 600; font-size: .9rem; margin: .5rem 0 0; }
.warn { background: var(--future-bg); color: #92400e; border-radius: 8px; padding: .6rem .75rem; font-size: .9rem; margin-top: .75rem; }
.info { background: var(--bg-soft); color: var(--blue-ink); border-radius: 8px; padding: .6rem .75rem; font-size: .9rem; margin-top: .75rem; }
.row { display: flex; gap: .5rem; align-items: center; }
.row > * { flex: 1; }
.search { display: flex; flex-wrap: wrap; gap: .5rem; }
.search input { flex: 1 1 100%; }
.search select { flex: 1; width: auto; }
.search .btn { flex: none; min-height: 46px; padding: 0 1.1rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .75rem; }

.btn {
  font: inherit; font-weight: 700; font-size: 1rem; border: 0; border-radius: 10px; cursor: pointer;
  padding: .85rem 1.1rem; background: var(--blue); color: #fff; width: 100%; margin-top: 1rem;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; text-decoration: none;
  min-height: 48px;
}
.btn:hover { background: var(--blue-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--blue-dark); border: 1.5px solid var(--blue); }
.btn.ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--line); }
.btn.danger { background: var(--immediate); }
.btn.sm { width: auto; padding: .45rem .75rem; min-height: 36px; font-size: .85rem; margin-top: 0; }
.btn.go { background: var(--ok); }

/* Vehicle */
.vehicle { display: flex; gap: .75rem; align-items: flex-start; }
.vehicle .ymm { font-size: 1.15rem; font-weight: 700; color: var(--ink); }
.vehicle .sub { color: var(--muted); font-size: .9rem; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; }
.chip { background: var(--bg-soft); color: var(--blue-ink); font-size: .78rem; font-weight: 600; padding: .2rem .55rem; border-radius: 999px; }

/* Section jump bar */
.jump {
  display: flex; gap: .4rem; overflow-x: auto; scrollbar-width: none;
  position: sticky; top: var(--header-h, 60px); z-index: 10;
  background: var(--bg-soft); margin: 0 -.75rem .75rem; padding: .5rem .75rem;
}
.jump.stuck { box-shadow: 0 4px 10px -6px rgba(16,24,40,.25); }
.jump::-webkit-scrollbar { display: none; }
.jump button {
  font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent;
  flex: none; text-decoration: none; font-size: .8rem; font-weight: 700; color: var(--blue-ink);
  background: #fff; border: 1.5px solid var(--line); padding: .35rem .65rem; border-radius: 999px;
}
.jump button.done { border-color: var(--ok); color: var(--ok); }
.jump button.current { background: var(--blue); border-color: var(--blue); color: #fff; }

/* Checklist */
.section { padding: 0; overflow: hidden; scroll-margin-top: 70px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .8rem 1rem; border-bottom: 1px solid var(--line); background: #fbfdff;
}
.section-head h2 { margin: 0; font-size: 1.05rem; }
.section-head .count { font-size: .8rem; color: var(--muted); font-weight: 600; }
.item { padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item-name { font-weight: 700; color: var(--ink); margin-bottom: .5rem; display: flex; justify-content: space-between; gap: .5rem; }
.item-name .add-note { font: inherit; font-size: .8rem; font-weight: 600; background: none; border: 0; color: var(--blue-dark); cursor: pointer; padding: 0; }
.item-prompt { font-size: .8rem; font-weight: 700; color: var(--blue-dark); margin: -.3rem 0 .5rem; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .35rem; }
.seg button {
  font: inherit; font-size: .85rem; font-weight: 700; min-height: 46px; border-radius: 8px; cursor: pointer;
  border: 1.5px solid var(--line); background: #fff; color: var(--muted); padding: .25rem;
  line-height: 1.15; -webkit-tap-highlight-color: transparent;
}
.seg button[data-s="ok"][aria-pressed="true"]        { background: var(--ok); border-color: var(--ok); color: #fff; }
.seg button[data-s="future"][aria-pressed="true"]    { background: var(--future); border-color: var(--future); color: #fff; }
.seg button[data-s="immediate"][aria-pressed="true"] { background: var(--immediate); border-color: var(--immediate); color: #fff; }
.seg button[data-s="na"][aria-pressed="true"]        { background: var(--na); border-color: var(--na); color: #fff; }
.item .note { margin-top: .5rem; }
.item.needs-note textarea { border-color: var(--immediate); background: #fff7f8; }
.item.needs-note .note-hint { color: var(--immediate); }
.note-hint { font-size: .78rem; color: var(--muted); margin-top: .2rem; }
.item.missing { background: #fff7f8; }

/* Sticky bottom bar */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: #fff; border-top: 1px solid var(--line);
  box-shadow: 0 -4px 14px rgba(16,24,40,.06); padding: .6rem .75rem; padding-bottom: max(.6rem, env(safe-area-inset-bottom));
}
.bottombar .inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: .75rem; }
.progress { flex: 1; }
.progress .label { font-size: .8rem; font-weight: 700; color: var(--ink); display: flex; justify-content: space-between; }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: .3rem; }
.bar i { display: block; height: 100%; background: var(--ok); width: 0; transition: width .2s; }
.bottombar .btn { width: auto; margin: 0; padding: .7rem 1.1rem; }

/* Summary tiles */
.tiles { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .4rem; margin: .75rem 0; }
.tile { border-radius: 8px; padding: .5rem .25rem; text-align: center; }
.tile b { display: block; font-size: 1.35rem; line-height: 1.1; }
.tile span { display: block; font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; line-height: 1.2; }
.tile.ok { background: var(--ok-bg); color: var(--ok); }
.tile.future { background: var(--future-bg); color: #b45309; }
.tile.immediate { background: var(--immediate-bg); color: var(--immediate); }
.tile.na { background: var(--na-bg); color: var(--na); }

.flag { border-left: 4px solid var(--future); padding: .4rem .6rem; margin: .4rem 0; background: #fffdf5; border-radius: 0 6px 6px 0; }
.flag.immediate { border-color: var(--immediate); background: #fff8f9; }
.flag b { color: var(--ink); }
.flag .what { font-size: .75rem; font-weight: 700; text-transform: uppercase; }
.flag.future .what { color: #b45309; }
.flag.immediate .what { color: var(--immediate); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list a.rowlink { display: block; padding: .75rem 0; text-decoration: none; color: inherit; }
.list .t { font-weight: 700; color: var(--ink); }
.list .m { font-size: .82rem; color: var(--muted); }
.dots { display: inline-flex; gap: .3rem; font-size: .78rem; font-weight: 700; margin-left: .35rem; }
.dots .d-future { color: #b45309; } .dots .d-immediate { color: var(--immediate); }

.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: .15rem .5rem; border-radius: 999px; vertical-align: middle; }
.badge.sent { background: var(--ok-bg); color: var(--ok); }
.badge.failed { background: var(--immediate-bg); color: var(--immediate); }
.badge.pending, .badge.not_configured { background: var(--future-bg); color: #b45309; }
.badge.inactive { background: var(--na-bg); color: var(--na); }
.badge.admin { background: var(--bg-soft); color: var(--blue-dark); }

/* Report (detail view) */
.report-item { display: grid; grid-template-columns: auto 1fr; gap: .1rem .6rem; padding: .45rem 0; border-bottom: 1px dashed var(--line); }
.report-item:last-child { border-bottom: 0; }
.pill { font-size: .7rem; font-weight: 800; padding: .2rem .45rem; border-radius: 6px; width: 92px; text-align: center; align-self: start; text-transform: uppercase; line-height: 1.2; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.future { background: var(--future-bg); color: #b45309; }
.pill.immediate { background: var(--immediate-bg); color: var(--immediate); }
.pill.na { background: var(--na-bg); color: var(--na); }
.report-item .n { font-weight: 600; color: var(--ink); }
.report-item .note { grid-column: 2; font-size: .9rem; color: var(--text); }
dl.meta { display: grid; grid-template-columns: auto 1fr; gap: .25rem .75rem; margin: 0; font-size: .9rem; }
dl.meta dt { color: var(--muted); }
dl.meta dd { margin: 0; color: var(--ink); font-weight: 600; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 90px; z-index: 50; background: var(--ink); color: #fff;
  padding: .7rem 1rem; border-radius: 10px; font-weight: 600; font-size: .9rem; box-shadow: var(--shadow); max-width: 90vw;
}
.toast.bad { background: var(--immediate); }

.done-hero { text-align: center; padding: 1.5rem 1rem; }
.done-hero .check { width: 64px; height: 64px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 2rem; display: inline-flex; align-items: center; justify-content: center; }

@media (min-width: 640px) {
  .brand img { height: 36px; }
  .wrap { padding-top: 1.5rem; }
  .seg button { font-size: .9rem; }
}

@media print {
  body { background: #fff; }
  .top, .nav, .bottombar, .no-print, .toast { display: none !important; }
  .wrap { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid var(--line); break-inside: avoid; }
  .print-logo { display: block !important; height: 34px; margin-bottom: .5rem; }
}
.print-logo { display: none; }
