:root {
  --navy: #002c5f; --blue: #007fa8; --sky: #e8f3fa; --bg: #f2f4f7; --card: #fff; --text: #111827; --muted: #6b7280;
  --ok: #0f7b3e; --warn: #a15c00; --err: #b42318; --radius: 16px; --tap: 56px;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); }
body.noscroll { overflow: hidden; }
.hidden { display: none !important; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + var(--safe-top)) 16px 10px; background: var(--navy); color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 8px; }
.title { font-weight: 700; font-size: 18px; }
.sub { font-size: 13px; opacity: .8; }
main { max-width: 640px; margin: 0 auto; padding: 12px 12px calc(28px + var(--safe-bottom)); }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: 0 1px 3px rgba(16,24,40,.08); }
h2 { font-size: 20px; margin: 0 0 12px; }
h3 { font-size: 18px; margin: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 20px 4px 4px; }
.section-head h2 { margin: 0; }
.count { font-size: 14px; font-weight: 600; color: var(--muted); background: #e5e7eb; border-radius: 999px; padding: 2px 10px; margin-left: 6px; vertical-align: middle; }
.opt { font-size: 13px; font-weight: 500; color: var(--muted); }
.hint { color: var(--muted); font-size: 15px; margin: 6px 4px 10px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.trade { border-left: 5px solid var(--blue); }
#soldCard { border-left: 5px solid var(--navy); }

.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 15px; font-weight: 600; margin-bottom: 6px; color: #374151; }
input[type=text], input[type=email], input[type=password] {
  width: 100%; min-height: var(--tap); font-size: 18px; padding: 12px 14px; border: 2px solid #d0d5dd; border-radius: 12px; background: #fff; color: var(--text); outline: none; -webkit-appearance: none; appearance: none; }
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,127,168,.15); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .06em; text-transform: uppercase; font-size: 19px !important; }
input.invalid { border-color: var(--err); }
.vin-row { display: flex; gap: 8px; }
.grow { flex: 1; }
.vin-row .field { margin-bottom: 4px; }
.vin-status { min-height: 22px; font-size: 14px; margin: 0 2px 10px; font-weight: 600; }
.vin-status.ok { color: var(--ok); } .vin-status.warn { color: var(--warn); } .vin-status.error { color: var(--err); } .vin-status.busy { color: var(--blue); }

button, .file-btn, .btn-ghost { font: inherit; cursor: pointer; border: 0; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; text-align: center; text-decoration: none; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.big { min-height: var(--tap); width: 100%; padding: 12px 16px; font-size: 18px; font-weight: 650; margin: 6px 0; }
.small { min-height: 44px; padding: 8px 14px; font-size: 15px; font-weight: 600; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:active { background: #001d40; }
.btn-secondary { background: var(--sky); color: var(--navy); border: 2px solid #b9d9ec; }
.btn-secondary:active { background: #d4e9f5; }
.btn-ghost { background: transparent; color: inherit; border: 2px solid rgba(255,255,255,.5); }
main .btn-ghost { color: var(--navy); border-color: #b9d9ec; }
.btn-danger { background: #fdecea; color: var(--err); border: 2px solid #f6c7c1; }
.btn-light { background: rgba(255,255,255,.92); color: #111; }
.btn-link { background: none; color: var(--blue); font-size: 14px; font-weight: 600; min-height: 40px; padding: 4px; width: 100%; }
button:disabled { opacity: .6; }
.btn-row { display: flex; gap: 8px; }
.btn-row > * { flex: 1; }
.scan-row { margin-bottom: 8px; }

.photos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 8px 0 14px; }
.photo-label { font-size: 15px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.photo-box { position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3; border: 2px dashed #98a2b3; border-radius: 14px; background: #f9fafb; overflow: hidden; cursor: pointer; }
.photo-box .ph { text-align: center; color: var(--muted); font-weight: 600; font-size: 16px; line-height: 1.6; }
.photo-box img { width: 100%; height: 100%; object-fit: contain; }
.photo-slot.has .photo-box { background: #1d2939; }
.photo-slot.has .photo-box { border: 2px solid var(--ok); }
.photo-slot.busy .photo-box::after { content: "Processing…"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.8); font-weight: 600; color: var(--blue); }

.checklist ul { list-style: none; padding: 0; margin: 0 0 14px; }
.checklist li { padding: 10px 12px 10px 38px; border-radius: 10px; background: #f9fafb; margin-bottom: 6px; font-size: 15px; position: relative; overflow-wrap: anywhere; }
.checklist li::before { position: absolute; left: 12px; top: 10px; }
.checklist li.done::before { content: "✅"; } .checklist li.todo::before { content: "⬜"; }
.status { padding: 12px 14px; border-radius: 12px; margin-top: 10px; font-size: 16px; }
.status.ok { background: #e7f6ec; color: var(--ok); } .status.err { background: #fdecea; color: var(--err); } .status.busy { background: var(--sky); color: var(--navy); }
.foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 18px; }

.toast { position: fixed; left: 50%; bottom: calc(20px + var(--safe-bottom)); transform: translateX(-50%); z-index: 50; background: #111827; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 16px; max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.25); }

.scanner { position: fixed; inset: 0; z-index: 100; background: #000; display: flex; flex-direction: column; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; left: 7%; right: 7%; top: 16%; height: 42%; border: 3px solid rgba(255,255,255,.9); border-radius: 14px; box-shadow: 0 0 0 9999px rgba(0,0,0,.45); overflow: hidden; }
.scan-line { position: absolute; left: 0; right: 0; height: 2px; background: #ff3b30; top: 50%; box-shadow: 0 0 8px #ff3b30; animation: scan 1.8s ease-in-out infinite alternate; }
@keyframes scan { from { top: 10%; } to { top: 90%; } }
.scan-ui { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 16px calc(20px + var(--safe-bottom)); color: #fff; text-align: center; }
.scan-ui p { font-size: 17px; font-weight: 600; text-shadow: 0 1px 3px #000; }
@media (min-width: 700px) { main { padding-top: 20px; } }
.mono::placeholder { text-transform: none; letter-spacing: normal; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 17px; }
.vin-status:empty { min-height: 6px; margin-bottom: 6px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.secondary-mailto { flex-direction: column; font-size: 15px !important; font-weight: 600 !important; }
.secondary-mailto small { font-weight: 500; color: var(--err); margin-top: 2px; }
.check { display: flex; align-items: flex-start; gap: 12px; min-height: 48px; padding: 10px 4px; font-size: 15px; font-weight: 600; color: #374151; }
.check input { width: 24px; height: 24px; flex: none; margin: 0; accent-color: var(--navy); }
.check small { display: block; font-weight: 500; color: var(--muted); }
.m365 { border: 2px solid #e4e7ec; border-radius: 14px; padding: 10px 12px; margin: 0 0 14px; background: #fafbfc; }
.m365-row { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.m365-from { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 16px; }
.m365-from .lbl { color: var(--muted); font-weight: 600; margin-right: 4px; }
.btn-ms { background: #2f2f2f; color: #fff; }
.btn-ms:active { background: #111; }
.btn-link.inline { width: auto; min-height: 44px; padding: 4px 8px; font-size: 15px; }
.subject-preview { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; flex: 1; min-width: 0; }
.subject-preview b { color: var(--text); }
.consent { margin-top: 6px; }
.field-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.field-head label { font-size: 15px; font-weight: 600; color: #374151; }
.subject-row { display: flex; align-items: center; gap: 10px; margin: -6px 2px 12px; }
.btn-copy { min-height: 44px; min-width: 64px; padding: 6px 14px; font-size: 15px; font-weight: 650; background: var(--sky); color: var(--navy); border: 2px solid #b9d9ec; border-radius: 12px; }
.btn-copy:active { background: #d4e9f5; }
.btn-copy.done { background: #e7f6ec; border-color: #a6dcb8; color: var(--ok); }
.cropper { position: fixed; inset: 0; z-index: 110; background: #0b0f14; color: #fff; display: flex; flex-direction: column; padding: calc(10px + var(--safe-top)) 12px calc(12px + var(--safe-bottom)); }
.crop-title { margin: 4px 4px 10px; font-size: 16px; text-align: center; }
.crop-stage { position: relative; flex: 1; min-height: 200px; overflow: hidden; touch-action: none; }
.crop-stage img { position: absolute; user-select: none; -webkit-user-select: none; pointer-events: none; }
.crop-box { position: absolute; border: 3px solid #ffcc00; box-shadow: 0 0 0 9999px rgba(0,0,0,.55); touch-action: none; cursor: move; }
.crop-box .h { position: absolute; width: 44px; height: 44px; touch-action: none; }
.crop-box .h::after { content: ""; position: absolute; width: 18px; height: 18px; background: #ffcc00; border-radius: 4px; }
.crop-box .nw { left: -22px; top: -22px; cursor: nwse-resize; } .crop-box .nw::after { left: 13px; top: 13px; }
.crop-box .ne { right: -22px; top: -22px; cursor: nesw-resize; } .crop-box .ne::after { right: 13px; top: 13px; }
.crop-box .sw { left: -22px; bottom: -22px; cursor: nesw-resize; } .crop-box .sw::after { left: 13px; bottom: 13px; }
.crop-box .se { right: -22px; bottom: -22px; cursor: nwse-resize; } .crop-box .se::after { right: 13px; bottom: 13px; }
.crop-actions { display: flex; gap: 10px; margin-top: 12px; } .crop-actions > * { flex: 1; }
.crop-reset { color: #9cd3f0; }
.crop-links { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0 6px; }
.crop-links .btn-link { width: auto; min-height: 36px; padding: 2px 6px; font-size: 15px; }
.crop-badge { font-size: 12px; color: var(--ok); font-weight: 600; }
.crop-badge:empty { display: none; }
.small-row { margin-top: 4px; }

/* required fields */
.req { color: var(--err); font-weight: 700; }
input.missing { border-color: var(--err); background: #fff5f5; box-shadow: 0 0 0 3px rgba(217, 45, 32, 0.15); }
.checklist li.missing-info { background: #fff5f5; }

.scan-tip { position: absolute; left: 0; right: 0; bottom: 6px; text-align: center; color: #fff; font-size: 13px; font-weight: 600; text-shadow: 0 1px 3px #000; opacity: .85; }
.scanner.got .scan-frame { border-color: #34c759; box-shadow: 0 0 0 9999px rgba(0,0,0,.45), 0 0 0 4px #34c759; }
#scanType, #scanCapture, #scanPhoto { margin-top: 8px; }
