/* FleetDVI driver tablet app — large-touch, high-contrast, distinct from the portal */
:root {
  --bg: #0b1220;
  --bg-soft: #111c31;
  --card: #16233c;
  --card-2: #1c2c4a;
  --line: #27395c;
  --text: #eef3fb;
  --muted: #90a3c2;
  --accent: #38bdf8;
  --pass: #22c55e;
  --fail: #ef4444;
  --na: #64748b;
  --warn: #f59e0b;
  --radius: 18px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #14295200, #14295266), var(--bg);
  color: var(--text);
  font-size: 18px;
  overscroll-behavior: none;
}
#app { display: flex; flex-direction: column; min-height: 100vh; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; background: rgba(11, 18, 32, .85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, #0ea5e9, #2563eb); font-weight: 800; font-size: 19px; letter-spacing: 1px;
  box-shadow: 0 6px 18px #0ea5e955;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text span { font-weight: 700; font-size: 20px; }
.brand-text small { color: var(--muted); font-size: 13px; letter-spacing: .5px; }
.top-right { display: flex; align-items: center; gap: 16px; }
.clock { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 16px; text-align: right; }
.net-badge {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 700; letter-spacing: 1px; border: 1px solid var(--line);
}
.net-badge .dot { width: 10px; height: 10px; border-radius: 50%; }
.net-badge.online { color: #6ee7a0; } .net-badge.online .dot { background: var(--pass); box-shadow: 0 0 10px var(--pass); }
.net-badge.offline { color: #fca5a5; } .net-badge.offline .dot { background: var(--fail); box-shadow: 0 0 10px var(--fail); }

.screen { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 26px 22px 60px; animation: fadeUp .35s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* Home */
.home-title { text-align: center; margin: 26px 0 8px; font-size: 30px; font-weight: 800; }
.home-sub { text-align: center; color: var(--muted); margin-bottom: 34px; font-size: 18px; }
.trip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 720px) { .trip-grid { grid-template-columns: 1fr; } }
.trip-card {
  border: 2px solid var(--line); border-radius: 24px; padding: 44px 30px; text-align: center;
  background: linear-gradient(180deg, var(--card), var(--bg-soft)); cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.trip-card:active { transform: scale(.97); }
.trip-card .icon { font-size: 64px; margin-bottom: 18px; }
.trip-card h2 { font-size: 34px; letter-spacing: 1px; margin-bottom: 10px; }
.trip-card p { color: var(--muted); font-size: 17px; line-height: 1.5; }
.trip-card.pre:hover, .trip-card.pre:focus { border-color: var(--accent); box-shadow: 0 10px 40px #38bdf833; }
.trip-card.post:hover, .trip-card.post:focus { border-color: #a78bfa; box-shadow: 0 10px 40px #a78bfa33; }
.pending-note {
  margin-top: 30px; text-align: center; color: var(--warn); font-weight: 600; font-size: 16px;
  background: #f59e0b14; border: 1px solid #f59e0b44; padding: 14px; border-radius: 14px;
}

/* Cards & forms */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; }
.card h3 { font-size: 15px; letter-spacing: 2px; color: var(--muted); text-transform: uppercase; margin-bottom: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.field label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 8px; font-weight: 600; letter-spacing: .5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 16px; font-size: 19px; color: var(--text);
  background: var(--bg-soft); border: 1.5px solid var(--line); border-radius: 14px; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #38bdf822; }
.hint { color: var(--muted); font-size: 14px; margin-top: 6px; }

/* Vehicle chooser */
.veh-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.veh-tile {
  padding: 18px 10px; text-align: center; border: 2px solid var(--line); border-radius: 16px;
  background: var(--bg-soft); cursor: pointer; transition: all .12s ease;
}
.veh-tile:active { transform: scale(.96); }
.veh-tile .num { font-size: 26px; font-weight: 800; }
.veh-tile .meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.veh-tile.selected { border-color: var(--accent); background: #0ea5e91d; box-shadow: 0 0 0 3px #38bdf822; }
.veh-tile.oos { opacity: .45; border-style: dashed; }
.veh-tile .flag { font-size: 11px; font-weight: 800; letter-spacing: 1px; color: var(--fail); margin-top: 4px; }

/* Driver autocomplete */
.autocomplete { position: relative; }
.ac-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  max-height: 280px; overflow-y: auto; box-shadow: 0 18px 40px #0008;
}
.ac-item { padding: 15px 18px; font-size: 19px; cursor: pointer; border-bottom: 1px solid #ffffff0d; }
.ac-item small { color: var(--muted); margin-left: 10px; }
.ac-item:hover, .ac-item.hl { background: #38bdf81a; }

/* Inspection */
.progress-wrap { position: sticky; top: 81px; z-index: 15; background: var(--bg); padding: 10px 0 14px; }
.progress-track { height: 10px; border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--line); overflow: hidden; }
.progress-bar { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #0ea5e9, #22c55e); transition: width .3s ease; }
.progress-label { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; margin-top: 8px; font-weight: 600; }

.cat-header { display: flex; align-items: center; gap: 12px; margin: 8px 0 16px; }
.cat-step {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, #0ea5e9, #2563eb); font-weight: 800; font-size: 18px;
}
.cat-header h2 { font-size: 22px; letter-spacing: .5px; }
.cat-header small { display: block; color: var(--muted); font-weight: 500; font-size: 14px; margin-top: 2px; }

.q-item {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px 20px; margin-bottom: 12px; transition: border-color .15s ease;
}
.q-item.answered-pass { border-color: #22c55e55; }
.q-item.answered-fail { border-color: #ef444488; background: #ef44440d; }
.q-item.answered-na { border-color: #64748b66; }
.q-text { flex: 1; min-width: 0; }
.q-text .t { font-size: 19px; font-weight: 650; }
.q-text .d { color: var(--muted); font-size: 14px; margin-top: 3px; line-height: 1.4; }
.q-text .crit { display: inline-block; margin-left: 8px; font-size: 11px; font-weight: 800; letter-spacing: 1px;
  color: #fbbf24; background: #f59e0b1c; border: 1px solid #f59e0b55; padding: 2px 8px; border-radius: 999px; vertical-align: 2px; }
.q-fail-note { color: #fca5a5; font-size: 14px; margin-top: 6px; font-weight: 600; }

.seg { display: flex; gap: 8px; flex-shrink: 0; }
.seg button {
  min-width: 86px; padding: 16px 10px; font-size: 16px; font-weight: 800; letter-spacing: 1px;
  border-radius: 12px; border: 2px solid var(--line); background: var(--bg-soft); color: var(--muted);
  cursor: pointer; transition: all .12s ease;
}
.seg button:active { transform: scale(.94); }
.seg button.sel-pass { background: var(--pass); border-color: var(--pass); color: #052e13; box-shadow: 0 4px 16px #22c55e44; }
.seg button.sel-fail { background: var(--fail); border-color: var(--fail); color: #fff; box-shadow: 0 4px 16px #ef444444; }
.seg button.sel-na { background: var(--na); border-color: var(--na); color: #fff; }

/* Quantity stepper */
.qty { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.qty button {
  width: 58px; height: 58px; font-size: 30px; font-weight: 700; border-radius: 14px;
  border: 2px solid var(--line); background: var(--bg-soft); color: var(--text); cursor: pointer;
}
.qty button:active { transform: scale(.92); }
.qty .val { min-width: 72px; text-align: center; font-size: 27px; font-weight: 800; font-variant-numeric: tabular-nums; }
.qty .req { font-size: 13px; color: var(--muted); text-align: center; }
.qty.short .val { color: var(--fail); }
.qty.ok .val { color: var(--pass); }

/* Nav buttons */
.navrow { display: flex; gap: 14px; margin-top: 24px; }
.btn {
  flex: 1; padding: 20px; font-size: 20px; font-weight: 800; letter-spacing: 1px; border-radius: 16px;
  border: none; cursor: pointer; transition: transform .12s ease, filter .15s ease; text-align: center;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #0ea5e9, #2563eb); color: #fff; box-shadow: 0 8px 24px #2563eb44; }
.btn-ghost { background: var(--bg-soft); color: var(--muted); border: 2px solid var(--line); }
.btn-danger { background: var(--fail); color: #fff; }
.btn-pass { background: var(--pass); color: #052e13; }
.btn-sm { flex: 0 0 auto; padding: 12px 20px; font-size: 15px; border-radius: 12px; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: #050a14cc; backdrop-filter: blur(4px);
  display: grid; place-items: center; z-index: 50; padding: 20px; animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.modal {
  width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 22px; padding: 26px;
  animation: fadeUp .25s ease;
}
.modal h2 { font-size: 22px; margin-bottom: 4px; }
.modal .sub { color: var(--muted); margin-bottom: 20px; font-size: 15px; }
.sev-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 10px 0 18px; }
.sev-opt {
  display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--bg-soft); cursor: pointer; transition: all .12s;
}
.sev-opt .sev-dot { width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; }
.sev-opt b { font-size: 17px; display: block; }
.sev-opt small { color: var(--muted); font-size: 13px; }
.sev-opt.minor .sev-dot { background: var(--warn); }
.sev-opt.major .sev-dot { background: #f97316; }
.sev-opt.oos .sev-dot { background: var(--fail); }
.sev-opt.selected.minor { border-color: var(--warn); background: #f59e0b14; }
.sev-opt.selected.major { border-color: #f97316; background: #f9731614; }
.sev-opt.selected.oos { border-color: var(--fail); background: #ef444414; }
.sev-opt.locked { opacity: .5; pointer-events: none; }

.photo-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.photo-thumb { position: relative; width: 92px; height: 92px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb .rm {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%;
  background: #000c; color: #fff; border: none; font-size: 14px; cursor: pointer;
}
.photo-add {
  width: 92px; height: 92px; border-radius: 12px; border: 2px dashed var(--line); background: none;
  color: var(--muted); font-size: 13px; font-weight: 700; cursor: pointer; display: grid; place-items: center; text-align: center;
}

/* Review screen */
.review-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.sum-tile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; text-align: center; }
.sum-tile .n { font-size: 34px; font-weight: 800; }
.sum-tile .l { color: var(--muted); font-size: 13px; letter-spacing: 1px; font-weight: 700; margin-top: 4px; }
.sum-tile.pass .n { color: var(--pass); } .sum-tile.fail .n { color: var(--fail); } .sum-tile.na .n { color: var(--na); }

.fail-review {
  border: 1px solid #ef444455; background: #ef44440d; border-radius: 16px; padding: 16px 18px; margin-bottom: 12px;
}
.fail-review .fr-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.fail-review b { font-size: 18px; }
.sev-badge { font-size: 12px; font-weight: 800; letter-spacing: 1px; padding: 4px 12px; border-radius: 999px; }
.sev-badge.MINOR { background: #f59e0b22; color: #fbbf24; border: 1px solid #f59e0b55; }
.sev-badge.MAJOR { background: #f9731622; color: #fb923c; border: 1px solid #f9731655; }
.sev-badge.OOS { background: #ef444422; color: #f87171; border: 1px solid #ef444455; }
.fail-review p { color: var(--muted); margin-top: 6px; font-size: 15px; }

/* Signature */
.sig-wrap { background: #fff; border-radius: 16px; overflow: hidden; position: relative; touch-action: none; }
.sig-wrap canvas { display: block; width: 100%; height: 220px; }
.sig-line { position: absolute; left: 8%; right: 8%; bottom: 46px; border-bottom: 2px dashed #cbd5e1; pointer-events: none; }
.sig-hint { position: absolute; bottom: 16px; left: 0; right: 0; text-align: center; color: #94a3b8; font-size: 14px; pointer-events: none; }
.cert-box {
  display: flex; gap: 14px; align-items: flex-start; background: var(--bg-soft);
  border: 1.5px solid var(--line); border-radius: 16px; padding: 18px; cursor: pointer; margin-bottom: 18px;
}
.cert-box.checked { border-color: var(--pass); background: #22c55e10; }
.cert-check {
  width: 34px; height: 34px; border-radius: 10px; border: 2px solid var(--line); flex-shrink: 0;
  display: grid; place-items: center; font-size: 20px; color: transparent; background: var(--card);
}
.cert-box.checked .cert-check { background: var(--pass); border-color: var(--pass); color: #052e13; }

/* Result screen */
.result-screen { text-align: center; padding: 40px 0; }
.result-icon { width: 130px; height: 130px; margin: 0 auto 26px; border-radius: 50%; display: grid; place-items: center; font-size: 64px; animation: pop .45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(.3); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.result-icon.ok { background: #22c55e1e; border: 3px solid var(--pass); }
.result-icon.bad { background: #ef44441e; border: 3px solid var(--fail); }
.result-icon.wait { background: #f59e0b1e; border: 3px solid var(--warn); }
.result-screen h1 { font-size: 34px; margin-bottom: 8px; }
.result-screen .detail { color: var(--muted); font-size: 19px; line-height: 1.7; }
.result-screen .dvi-num { font-size: 22px; font-weight: 800; color: var(--accent); margin: 16px 0; letter-spacing: 1px; }

/* Toast */
#toastRoot { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 10px; width: min(480px, 92vw); }
.toast { background: var(--card-2); border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 14px; padding: 15px 18px; font-size: 16px; font-weight: 600; box-shadow: 0 12px 40px #000a; animation: fadeUp .25s ease; }
.toast.err { border-left-color: var(--fail); }
.toast.ok { border-left-color: var(--pass); }

.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--line); color: var(--muted); font-size: 14px; font-weight: 700; }
.mono { font-variant-numeric: tabular-nums; }
