body { font-family: system-ui, sans-serif; margin: 0; }
body > header { background: #1f2937; color: #fff; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
main { padding: 16px; max-width: 28rem; }
.stack { display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-weight: 600; }
input { font: inherit; padding: 12px; border: 1px solid #9ca3af; border-radius: 6px; }
button { font: inherit; padding: 12px 16px; border-radius: 6px; border: 0; background: #2563eb; color: #fff; cursor: pointer; }
body > header button { background: #374151; padding: 8px 12px; }
form.inline { display: flex; gap: 8px; align-items: center; margin: 0; }
.error { color: #b91c1c; }
select, textarea { font: inherit; padding: 12px; border: 1px solid #9ca3af; border-radius: 6px; }
fieldset { display: grid; gap: 12px; border: 1px solid #d1d5db; border-radius: 6px; padding: 12px; }
.vin-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.hint { color: #4b5563; margin: 0; font-size: 0.9rem; }
.warning { color: #92400e; background: #fef3c7; padding: 8px 12px; border-radius: 6px; }
.notice { background: #dcfce7; color: #166534; padding: 8px 12px; border-radius: 6px; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 600; }
a.button { display: inline-block; background: #2563eb; color: #fff; padding: 12px 16px; border-radius: 6px; text-decoration: none; }
.actions { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
#scanner video { width: 100%; max-height: 50vh; background: #000; border-radius: 6px; }

/* ---- board ---- */
main.wide { max-width: none; }
.toolbar { display: flex; gap: 16px; align-items: end; justify-content: space-between; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters input[type=search] { min-width: 14rem; }
.summary { margin: 8px 0 12px; }
.red-text { color: #b91c1c; }
.yellow-text { color: #92400e; }
.tabs { display: none; gap: 6px; overflow-x: auto; padding-bottom: 8px; position: sticky; top: 0; background: #fff; }
.tab { background: #e5e7eb; color: #111827; white-space: nowrap; padding: 10px 14px; }
.tab.current { background: #1f2937; color: #fff; }
.count { display: inline-block; min-width: 1.4em; text-align: center; background: rgba(0,0,0,.12); border-radius: 999px; padding: 0 6px; font-size: .85em; }
.board { display: flex; gap: 12px; align-items: flex-start; overflow-x: auto; padding-bottom: 16px; }
.col { flex: 0 0 15.5rem; background: #f3f4f6; border-radius: 8px; padding: 8px; min-height: 8rem; }
.col.over { outline: 3px dashed #2563eb; }
.col h2 { font-size: 1rem; margin: 4px 4px 8px; display: flex; justify-content: space-between; align-items: center; }
.card { background: #fff; border-radius: 6px; border: 1px solid #d1d5db; border-left: 6px solid #9ca3af; padding: 8px 10px; margin-bottom: 8px; }
.card[draggable=true] { cursor: grab; }
.card.dragging { opacity: .5; }
.card.ok { border-left-color: #16a34a; }
.card.yellow { border-left-color: #eab308; background: #fefce8; }
.card.red { border-left-color: #dc2626; background: #fef2f2; }
.card h3 { font-size: .95rem; margin: 0 0 4px; }
.card p { margin: 2px 0; font-size: .85rem; }
.ids { color: #4b5563; }
.badge { font-size: .7rem; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: #e5e7eb; color: #111827; vertical-align: middle; }
.badge.red { background: #dc2626; color: #fff; }
.badge.yellow { background: #eab308; color: #111827; }
.empty { color: #6b7280; font-size: .85rem; text-align: center; }
.move { margin-top: 6px; display: grid; gap: 6px; }
.move button { padding: 8px 10px; font-size: .85rem; width: 100%; }
.move summary { cursor: pointer; font-size: .85rem; color: #2563eb; padding: 6px 0; }
.move details form { display: flex; gap: 6px; }
.move select { flex: 1; padding: 8px; }
@media (max-width: 700px) {
  main { padding: 12px; }
  .tabs { display: flex; }
  .board.tabbed { display: block; overflow: visible; }
  .board.tabbed .col { display: none; flex: none; }
  .board.tabbed .col.current { display: block; }
  .move button, .move summary, .move select { min-height: 44px; }
  .card h3 { font-size: 1.05rem; }
  .card p { font-size: .95rem; }
}

/* ---- car detail ---- */
.error-box { background: #fee2e2; color: #991b1b; padding: 8px 12px; border-radius: 6px; }
main.detail { max-width: 40rem; }
main.detail section { margin-top: 24px; }
main.detail h2 { font-size: 1.1rem; display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.car-head { border-left: 6px solid #16a34a; padding-left: 12px; }
.car-head.yellow { border-left-color: #eab308; }
.car-head.red { border-left-color: #dc2626; }
.car-head h1 { margin: 0 0 4px; font-size: 1.4rem; }
.move-bar { display: grid; gap: 8px; margin-top: 8px; }
.move-bar .row { display: flex; gap: 8px; }
.move-bar select { flex: 1; }
button.secondary { background: #e5e7eb; color: #111827; }
button.danger { background: #b91c1c; }
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.totals div { background: #f3f4f6; border-radius: 6px; padding: 8px 10px; }
.totals .grand { background: #1f2937; color: #fff; }
.totals dt { font-size: .8rem; opacity: .8; }
.totals dd { margin: 0; font-weight: 700; font-size: 1.05rem; }
.items { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.items li { border: 1px solid #d1d5db; border-radius: 6px; padding: 8px 10px; }
.items li.done .item-desc { text-decoration: line-through; color: #6b7280; }
.item-main { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; }
.item-actions { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; margin-top: 6px; }
.item-actions details { flex: 1 1 100%; }
.item-actions summary, .specs ~ details summary, details > summary { cursor: pointer; color: #2563eb; padding: 6px 0; }
.item-actions details .stack { margin: 8px 0; }
.add-item { margin-top: 12px; padding: 12px; background: #f9fafb; border-radius: 6px; }
.add-item h3 { margin: 0; font-size: 1rem; }
.timeline { padding-left: 1.2rem; margin: 0; display: grid; gap: 4px; }
.note { border-bottom: 1px solid #e5e7eb; padding: 8px 0; }
.note-text { white-space: pre-wrap; margin: 2px 0; }
.specs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 0 0 8px; }
.specs div { background: #f3f4f6; border-radius: 6px; padding: 6px 10px; }
.specs dt { font-size: .75rem; color: #4b5563; }
.specs dd { margin: 0; font-weight: 600; }
.card h3 a { color: inherit; text-decoration: none; }
.card h3 a:hover { text-decoration: underline; }
textarea { width: 100%; box-sizing: border-box; }
.danger-link { margin-top: 32px; font-size: .9rem; }
.danger-link a { color: #b91c1c; }

/* ---- settings ---- */
.topnav { display: flex; gap: 16px; }
.topnav a { color: #fff; text-decoration: none; padding: 8px 0; }
.topnav a:hover { text-decoration: underline; }
.subnav { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.wrap { overflow-wrap: anywhere; }
.cards { list-style: none; padding: 0; display: grid; gap: 8px; }
.cards a { display: grid; gap: 2px; padding: 12px; border: 1px solid #d1d5db; border-radius: 8px; text-decoration: none; color: inherit; }
.cards a:hover { background: #f3f4f6; }
.cards span { color: #4b5563; font-size: .9rem; }
.stage-list { list-style: none; padding: 0; display: grid; gap: 12px; }
.stage-list > li { border: 1px solid #d1d5db; border-radius: 8px; padding: 10px 12px; }
.stage-list > li.hidden-stage { opacity: .65; background: #f3f4f6; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.row-actions form { margin: 0; }
.row-actions button { padding: 8px 12px; }

.email-preview { width: 100%; height: 70vh; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; }
button[disabled] { opacity: .5; cursor: not-allowed; }

/* ---- reports ---- */
main.reports { max-width: 52rem; }
.report-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.report-head h2 { margin: 0; }
a.csv { font-size: .9rem; }
.table-wrap { overflow-x: auto; margin: 8px 0; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid #e5e7eb; white-space: nowrap; }
th { background: #f3f4f6; font-size: .8rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.slowest td { background: #fefce8; }
tr.over td { background: #fef2f2; }

/* ---- phone polish ---- */
html { -webkit-text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; }
/* No 300ms double-tap delay, and no accidental zoom when a field takes focus on iPhone (needs 16px). */
a, button, summary, label, select, input { touch-action: manipulation; }
input, select, textarea, button { font-size: 16px; }
/* Thumb-sized targets (44px is the usual minimum). */
button, select, input:not([type=checkbox]):not([type=radio]) { min-height: 44px; box-sizing: border-box; }
input[type=checkbox], input[type=radio] { width: 22px; height: 22px; flex: none; }
label.check { min-height: 44px; }
summary { min-height: 44px; display: flex; align-items: center; }
.topnav a, .subnav a { display: inline-flex; align-items: center; min-height: 44px; }
.tab { min-height: 44px; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
summary:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
/* Space for the notch and the home bar when installed full screen. */
body > header { padding-top: max(12px, env(safe-area-inset-top)); padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right)); }
main { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(24px, env(safe-area-inset-bottom)); }
.install ul { padding-left: 1.2rem; }
@media (max-width: 700px) {
  .card .move button, .row-actions button, .add-item button, .stack > button { min-height: 48px; }
  table a { display: inline-block; padding: 8px 0; }
  .topnav { gap: 4px 16px; flex-wrap: wrap; }
}

/* ---- help ---- */
main.help section { margin-top: 24px; }
main.help li { margin: 6px 0; line-height: 1.45; }

/* ---- photos ---- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.button-like { box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 18px; border-radius: 6px; background: #2563eb; color: #fff; font-weight: 600; cursor: pointer; text-align: center; }
.button-like:focus-within { outline: 3px solid #93c5fd; outline-offset: 2px; }
.slots { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 10px; }
.slot { display: grid; grid-template-columns: 96px 1fr; gap: 10px; align-items: center; border: 1px solid #d1d5db; border-radius: 8px; padding: 8px; }
.slot.done { border-color: #86efac; background: #f0fdf4; }
.slot .thumb { width: 96px; height: 72px; background: #e5e7eb; border-radius: 6px; overflow: hidden; display: grid; place-items: center; }
.slot .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slot .placeholder { color: #6b7280; font-weight: 700; font-size: 1.2rem; }
.slot .info { display: grid; gap: 2px; min-width: 0; }
.slot .status { font-size: .85rem; min-height: 1.1em; }
.slot .status.ok { color: #166534; }
.slot .status.wait { color: #92400e; }
.slot .status.error { color: #b91c1c; font-weight: 600; }
.slot-actions { grid-column: 1 / -1; min-width: 0; }
.slot-actions .button-like, .slot-actions button { width: 100%; }
.progress { font-weight: 700; position: sticky; top: 0; background: #fff; padding: 6px 0; margin: 0; z-index: 2; }
.photo-grid { list-style: none; padding: 0; margin: 0 0 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.photo-grid img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; display: block; background: #e5e7eb; }
.done-row { margin: 24px 0; }
@media (min-width: 700px) {
  .slot { grid-template-columns: 96px 1fr auto; }
  .slot-actions { grid-column: auto; }
  .slot-actions .button-like, .slot-actions button { width: auto; }
}

/* ---- listing ---- */
.badge.green { background: #16a34a; color: #fff; }
.copy-source { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }
.sticky-actions { position: sticky; bottom: 0; background: #fff; padding: 10px 0; border-top: 1px solid #e5e7eb; z-index: 3; }
button.go-live { background: #16a34a; }
.listing-form h2 { margin-top: 8px; }
a.button.small { display: block; text-align: center; padding: 8px 10px; font-size: .85rem; margin-top: 6px; min-height: 44px; box-sizing: border-box; line-height: 28px; }
.photos-line { color: #4b5563; }
