:root {
  --navy: #2a2f50;
  --navy-dark: #1a1d33;
  --navy-darker: #12141f;
  /* Flat navy theme — no gradients, no cyan, per the uncle's request. --primary-gradient
     keeps its name (used throughout as a `background` value) but is now a plain solid
     color, not an actual gradient — that was the simplest way to make every button/card
     that referenced it go flat without touching each rule individually. */
  --primary: #2a2f50;
  --primary-dark: #1a1d33;
  --primary-light: #e8eaf0;
  --primary-gradient: #2a2f50;
  --steel: #5b7bb8;
  --red: #c0392b;
  --green: #1e9e5a;
  --amber: #d6901e;
  --purple-drop: #8b3fd6;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #101828;
  --text-mute: #667085;
  --border: #e4e7ec;
  --radius: 16px;
}

* { box-sizing: border-box; }

.icon { width: 20px; height: 20px; display: inline-block; vertical-align: middle; flex-shrink: 0; }
.icon-btn .icon { width: 17px; height: 17px; }
.mode-icon .icon { width: 26px; height: 26px; }
.entry-defect-flag .icon { width: 14px; height: 14px; margin-right: 3px; margin-bottom: 2px; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

#app { min-height: 100%; }

.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

/* ---------- iOS/Android safe-area status bar strip ---------- */
/* On phones with a notch/dynamic island, the OS status bar (clock, battery, signal) floats
   on top of the page content unless we reserve real space for it. This fixed strip gives it
   a branded navy backdrop instead of colliding with whatever's underneath. */
body::before {
  content: '';
  position: fixed; top: 0; left: 0; right: 0;
  height: env(safe-area-inset-top);
  background: var(--navy);
  z-index: 999;
}

/* ---------- phone shell (driver screens) ---------- */
.phone-shell {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  padding: max(20px, calc(env(safe-area-inset-top) + 12px)) 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.phone-shell.dark { background: #0b0f1a; color: #fff; }

.brand-block { text-align: center; margin-top: 40px; }
.brand-mark {
  width: 64px; height: 64px; border-radius: 18px;
  background: var(--navy);
  box-shadow: 0 6px 16px rgba(42,47,80,0.32);
  color: #fff; font-weight: 800; font-size: 19px; font-style: italic;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px; letter-spacing: 0.5px;
}
.brand-block h1 { font-size: 22px; margin: 0 0 4px; }
.brand-block .sub { color: var(--text-mute); margin: 0; font-size: 14px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 2px rgba(16,24,40,0.04), 0 1px 3px rgba(16,24,40,0.06);
}

.demo-note {
  font-size: 12.5px;
  color: var(--text-mute);
  background: var(--primary-light);
  border: 1px solid #ded2f9;
  padding: 10px 12px;
  border-radius: 10px;
  margin: 0 0 16px;
  line-height: 1.4;
}

.auth-tabs { display: flex; gap: 8px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.auth-tab {
  flex: 1; padding: 10px; border: none; background: transparent; font-weight: 700; font-size: 14px;
  color: var(--text-mute); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.auth-tab.active { color: var(--navy); border-bottom-color: var(--primary); }

.remember-me-row {
  display: flex; align-items: center; gap: 8px; margin-top: 14px;
  font-size: 13.5px; font-weight: 600; color: var(--text-mute); cursor: pointer; user-select: none;
}
.remember-me-row input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

.field-error {
  color: var(--red); font-size: 12.5px; font-weight: 600; margin: 10px 0 0;
}
.field-hint {
  color: var(--text-mute); font-size: 12px; margin: 10px 0 0; line-height: 1.5;
}

.role-toggle { display: flex; gap: 8px; margin-bottom: 16px; }
.role-btn {
  flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; font-weight: 600; font-size: 13.5px; color: var(--text-mute);
  cursor: pointer;
}
.role-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-mute); margin: 12px 0 6px; }
.field-optional { font-weight: 400; text-transform: none; letter-spacing: 0; }
.field {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border);
  font-size: 15px; background: #fff; color: var(--text);
}
.field:disabled { color: var(--text-mute); background: #f2f4f7; }
.field-inline { width: auto; padding: 8px 10px; font-size: 13.5px; }

.password-field { position: relative; }
.password-field .field { padding-right: 42px; }
.password-toggle-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  border: none; background: transparent; color: var(--text-mute); cursor: pointer;
  padding: 8px; display: flex; align-items: center; justify-content: center; border-radius: 8px;
}
.password-toggle-btn:hover { background: #f2f4f7; color: var(--text); }
.password-toggle-btn .icon { width: 19px; height: 19px; }

.btn {
  border: none; border-radius: 14px; padding: 14px 18px; font-size: 15px; font-weight: 700;
  cursor: pointer; text-align: center; transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
}
.btn-block { width: 100%; margin-top: 14px; }
.btn-primary { background: var(--primary-gradient); color: #fff; box-shadow: 0 4px 14px rgba(91,63,214,0.3); }
.btn-primary:active { filter: brightness(0.92); transform: scale(0.97); }
.btn-secondary { background: #eef1f6; color: var(--navy); box-shadow: 0 1px 3px rgba(16,24,40,0.06); }
.btn-secondary:active { transform: scale(0.97); background: #e4e8f0; }
.btn-outline-light { background: transparent; color: #fff; border: 1.5px solid rgba(255,255,255,0.6); }
.btn-outline-light:active { transform: scale(0.97); background: rgba(255,255,255,0.08); }
.btn-link { background: transparent; color: var(--primary); font-weight: 600; }
.btn:disabled { transform: none !important; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- top bar ---------- */
.top-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top-bar.dark { color: #fff; }
.hello { font-size: 18px; font-weight: 700; }
.hello-sub { font-size: 13px; color: var(--text-mute); }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; font-size: 16px; cursor: pointer; color: var(--text);
  display: flex; align-items: center; justify-content: center;
}
.icon-btn.light { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.2); color: #fff; }

.logout-btn {
  display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px;
  border-radius: 10px; border: 1px solid var(--border); background: #fff;
  font-size: 13px; font-weight: 700; color: var(--text-mute); cursor: pointer; white-space: nowrap;
}
.logout-btn:hover { background: #fdf3f2; border-color: #f3c9c4; color: var(--red); }
.logout-btn .icon { width: 16px; height: 16px; }
.icon-btn.light.active { background: #f5b93f; border-color: #f5b93f; color: #1a1d33; }

/* ---------- home mode grid ---------- */
.pending-upload-banner {
  display: flex; align-items: center; gap: 12px; background: #fff7e6; border: 1px solid #f5d99b;
  border-radius: 14px; padding: 14px 16px; margin-top: 14px; color: var(--amber-dark, #b45309);
}
.pending-upload-banner .icon { width: 22px; height: 22px; flex-shrink: 0; }
.pending-upload-text { flex: 1; min-width: 0; }
.pending-upload-text > div:first-child { font-weight: 700; font-size: 14px; color: var(--text); }
.pending-upload-sub { font-size: 12px; color: var(--text-mute); margin-top: 2px; }
.pending-upload-banner .btn { margin-top: 0; padding: 9px 14px; font-size: 13px; flex-shrink: 0; }

.mode-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 4px; }
.mode-card {
  display: flex; align-items: center; gap: 14px;
  border: none; border-radius: var(--radius);
  padding: 18px; text-align: left; cursor: pointer; color: #fff;
  box-shadow: 0 6px 16px rgba(16,24,40,0.14);
  transition: transform 0.1s ease;
}
.mode-card:active { filter: brightness(0.94); transform: scale(0.99); }
.mode-card[data-type="PTI"],
.mode-card[data-type="HOOK"],
.mode-card[data-type="DROP"] { background: var(--navy); }
.mode-icon {
  width: 44px; height: 44px; flex-shrink: 0; color: #fff;
  background: rgba(255,255,255,0.22); border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.mode-icon .icon { width: 23px; height: 23px; }
.mode-title { font-size: 21px; font-weight: 800; color: #fff; }
.mode-sub { font-size: 12.5px; color: rgba(255,255,255,0.85); }

/* ---------- QR scan ---------- */
.scan-frame {
  position: relative; border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 3/4; background: #000; flex-shrink: 0;
}
.scan-frame video { width: 100%; height: 100%; object-fit: cover; }
.scan-reticle {
  position: absolute; inset: 15%; border: 3px solid rgba(255,255,255,0.85);
  border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,0.35);
  pointer-events: none;
}
.scan-hint {
  position: absolute; bottom: 14px; left: 0; right: 0; text-align: center;
  color: #fff; font-size: 13px; padding: 0 20px;
}
.manual-entry { margin-top: 0; }
.manual-row { display: flex; gap: 8px; margin-top: 6px; }
.manual-row .field { flex: 1; }

/* ---------- recording/review screen ---------- */
/* Recording itself now happens in the phone's real Camera app (handed off via the hidden
   file input below) — this screen only shows once that video comes back, for review and
   tap-to-flag. That's what fixed the "plays a few seconds then errors" video corruption:
   the browser's own MediaRecorder API writes broken duration metadata into whatever it
   records; the real Camera app doesn't have that bug at all. */
#recorder-review .review-video-wrap { position: relative; margin-top: 4px; }
#recorder-review video {
  width: 100%; border-radius: 14px; background: #000; display: block; max-height: 50vh;
}
.review-tap-overlay { position: absolute; inset: 0; cursor: crosshair; border-radius: 14px; }
.review-arm-hint {
  text-align: center; font-size: 13px; font-weight: 700; color: var(--primary-dark);
  background: var(--primary-light); border-radius: 10px; padding: 8px 12px; margin-top: 10px;
}
#btn-flag-defect.active { background: var(--red); color: #fff; }

.marker-dot {
  position: absolute; width: 70px; height: 70px; margin-left: -35px; margin-top: -35px;
  border: 7px solid var(--red); border-radius: 50%;
  background: rgba(224,51,47,0.18);
  animation: markerPulse 0.5s ease-out forwards;
  pointer-events: none;
}
@keyframes markerPulse {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(3.8); opacity: 0; }
}

.record-location {
  color: var(--text-mute); font-size: 12px; margin-top: 10px;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.record-location .icon { width: 13px; height: 13px; }

.defect-count {
  color: #fff; font-size: 13px; background: var(--red); padding: 6px 14px; border-radius: 999px;
  display: block; width: fit-content; margin: 10px auto;
}

.min-warning { color: var(--red); font-size: 13px; text-align: center; margin: 10px 0; font-weight: 600; }

/* ---------- uploading screen ---------- */
.upload-status-block { text-align: center; margin-top: 80px; }
.upload-icon {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 20px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-light); color: var(--primary);
}
.upload-icon .upload-spinner-icon { width: 30px; height: 30px; animation: spin 0.9s linear infinite; }
.upload-icon.success { background: #e4f7ec; color: var(--green); }
.upload-icon.error { background: #fbeae8; color: var(--red); }
.upload-status-block h2 { font-size: 21px; margin: 0 0 6px; }
.upload-sub { font-size: 13.5px; color: var(--text-mute); margin: 0 0 28px; padding: 0 12px; line-height: 1.5; }

.upload-progress-wrap { max-width: 320px; margin: 0 auto; }
.upload-progress-bar { height: 10px; border-radius: 999px; background: var(--border); overflow: hidden; }
.upload-progress-fill { height: 100%; width: 0%; background: var(--primary-gradient); border-radius: 999px; transition: width 0.2s ease; }
.upload-progress-meta { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-mute); margin-top: 8px; font-weight: 600; }

#upload-error-actions, #btn-upload-done { max-width: 320px; margin-left: auto; margin-right: auto; }
.upload-error-detail {
  font-size: 12px; font-family: ui-monospace, monospace; color: var(--text-mute); background: #f2f4f7;
  border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; text-align: left; word-break: break-word;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- entry list ---------- */
.entry-list { display: flex; flex-direction: column; gap: 10px; }
.entry-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; cursor: pointer;
}
.entry-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.entry-type {
  font-size: 11px; font-weight: 800; letter-spacing: 0.5px; padding: 3px 9px; border-radius: 999px; color: #fff;
}
.entry-type.PTI { background: var(--green); }
.entry-type.HOOK { background: var(--amber); }
.entry-type.DROP { background: var(--purple-drop); }
.entry-unit { font-weight: 700; font-size: 14.5px; }
.entry-meta { font-size: 12.5px; color: var(--text-mute); margin-top: 6px; display: flex; gap: 12px; flex-wrap: wrap; }
.entry-driver { font-size: 12.5px; color: var(--navy); font-weight: 600; }
.entry-defect-flag { color: var(--red); font-weight: 700; }
.entry-video-hint {
  display: inline-flex; align-items: center; gap: 4px; color: var(--primary-dark); font-weight: 700;
}
.entry-video-hint .icon { width: 14px; height: 14px; }
.entry-details { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); display: none; }
.entry-detail-row { font-size: 12.5px; color: var(--text-mute); margin-bottom: 4px; }
.entry-detail-row a { color: var(--primary); font-weight: 600; }
.entry-card.open .entry-details { display: block; }
.entry-photos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.entry-photos img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 2px solid var(--red); cursor: pointer; }

.entry-video-wrap { margin-top: 10px; }
.entry-video-wrap video { width: 100%; border-radius: 10px; background: #000; display: block; max-height: 360px; }
.entry-video-loading {
  height: 140px; border-radius: 10px; background: #f2f4f7; color: var(--text-mute);
  display: flex; align-items: center; justify-content: center; font-size: 13.5px; font-weight: 600;
}
/* Custom video controls — replaces native <video controls> entirely. iOS Safari's own
   ±15s skip buttons turned out to be unreliable specifically with blob-sourced video
   (resetting to 0:00), which we have no control over since that's Apple's own player UI.
   This is a small player we fully own instead, so seeking always behaves consistently. */
.cvp-controls {
  display: flex; align-items: center; gap: 6px; margin-top: 8px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 6px 10px;
}
.cvp-btn {
  border: none; background: transparent; color: var(--navy); cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  padding: 6px; border-radius: 8px;
}
.cvp-btn:hover { background: var(--primary-light); }
.cvp-btn .icon { width: 20px; height: 20px; }
.cvp-skip { font-size: 11px; font-weight: 800; padding: 6px 5px; white-space: nowrap; }
.cvp-seekwrap { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; }
.cvp-seek { flex: 1; width: 100%; accent-color: var(--primary); cursor: pointer; min-width: 0; }
.cvp-ticks { position: absolute; left: 0; right: 0; top: 0; bottom: 0; pointer-events: none; }
.cvp-ticks span { position: absolute; top: 50%; width: 4px; height: 18px; margin-left: -2px; margin-top: -9px; background: var(--red); border-radius: 2px; box-shadow: 0 0 0 1.5px #fff; }
/* live recorder: full-screen camera with controls on top of it */
.live-full { position: fixed; inset: 0; z-index: 60; background: #000; color: #fff; }
.live-video-wrap { position: absolute; inset: 0; background: #000; overflow: hidden; }
#live-video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; transform-origin: center center; }
#live-canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.live-full .review-tap-overlay { border-radius: 0; }
.live-cam-frame { position: absolute; z-index: 1; box-sizing: border-box; border: 2px solid rgba(255,255,255,0.45); pointer-events: none; display: none; }
.mode-section-title { font-size: 13px; font-weight: 800; letter-spacing: 0.08em; color: var(--text-mute); margin: 10px 2px 0; text-transform: uppercase; }
.mode-section-title:first-child { margin-top: 0; }
.live-close {
  position: absolute; z-index: 3; top: calc(env(safe-area-inset-top, 0px) + 12px); right: 14px;
  width: 40px; height: 40px; border-radius: 50%; border: none; background: rgba(0,0,0,0.55); color: #fff;
  font-size: 26px; line-height: 1; cursor: pointer; padding: 0 0 3px;
}
.live-cam-info {
  position: absolute; z-index: 2; top: calc(env(safe-area-inset-top, 0px) + 62px); left: 50%; transform: translateX(-50%);
  font-size: 11px; color: #fff; margin: 0; background: rgba(0,0,0,0.45); border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
.live-cam-info:empty { display: none; }
.live-cam-info.video-info-low { color: #ffb74d; }
.live-arm-hint {
  position: absolute; z-index: 3; left: 14px; right: 14px; top: calc(env(safe-area-inset-top, 0px) + 84px); margin: 0;
  background: rgba(255,255,255,0.92);
}
.live-bottom {
  position: absolute; z-index: 3; left: 0; right: 0; bottom: 0; text-align: center;
  padding: 30px 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  background: linear-gradient(to top, rgba(0,0,0,0.72), rgba(0,0,0,0));
}
.live-full .live-record-label, .live-full .live-torch-hint { color: rgba(255,255,255,0.85); }
.live-full .live-side-btn { background: rgba(255,255,255,0.16); color: #fff; border-color: rgba(255,255,255,0.28); }
.live-full .live-side-btn.active { background: var(--red); border-color: var(--red); }
.live-full #btn-torch.active { background: #f0b429; color: #1a1d33; border-color: #f0b429; }
.live-warning {
  position: absolute; z-index: 4; left: 14px; right: 14px; top: calc(env(safe-area-inset-top, 0px) + 84px);
  background: #e0332f; color: #fff; border-radius: 12px; padding: 10px 14px; font-size: 13.5px; font-weight: 700; text-align: center;
}
.video-warning { background: #fdeaea; border: 1px solid #e0332f; color: #b3261e; border-radius: 12px; padding: 10px 12px; margin: 8px 0; font-size: 13.5px; font-weight: 700; text-align: center; }
.live-arm-hint, .live-warning, .live-cam-info, .rec-badge { pointer-events: none; }
.live-side-spacer { width: 64px; height: 64px; flex-shrink: 0; }
.live-fallback { background: none; border: none; color: rgba(255,255,255,0.8); text-decoration: underline; font-size: 13px; margin-top: 6px; cursor: pointer; }
.live-full .live-processing {
  position: absolute; inset: 0; z-index: 5; background: rgba(0,0,0,0.78); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.live-full .live-spinner { border-color: rgba(255,255,255,0.25); border-top-color: #fff; }
.rec-badge {
  position: absolute; top: calc(env(safe-area-inset-top, 0px) + 14px); left: 14px; z-index: 4; align-items: center; gap: 8px;
  background: rgba(0,0,0,0.65); color: #fff; border-radius: 999px; padding: 8px 16px; font-weight: 800; font-size: 20px;
  font-variant-numeric: tabular-nums;
}
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #ff3b30; animation: recBlink 1s infinite; }
@keyframes recBlink { 50% { opacity: 0.25; } }
.live-controls { display: flex; align-items: center; justify-content: center; gap: 28px; margin: 16px 0 6px; }
.rec-btn {
  width: 76px; height: 76px; border-radius: 50%; border: 4px solid var(--navy); background: #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; flex-shrink: 0;
}
.rec-btn-inner { width: 54px; height: 54px; border-radius: 50%; background: #e0332f; transition: all 0.15s; }
.rec-btn.recording .rec-btn-inner { width: 28px; height: 28px; border-radius: 6px; }
.rec-btn:disabled { opacity: 0.5; }
.live-side-btn {
  width: 64px; height: 64px; border-radius: 16px; border: 1px solid var(--border); background: var(--card); color: var(--navy);
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11.5px; font-weight: 700; cursor: pointer; padding: 0;
}
.live-side-btn .icon { width: 22px; height: 22px; }
.live-side-btn:disabled { opacity: 0.4; cursor: default; }
.live-side-btn.active { background: var(--red); color: #fff; border-color: var(--red); }
#btn-torch.active { background: #f0b429; color: #1a1d33; border-color: #f0b429; }
.live-record-label { text-align: center; font-size: 12.5px; color: var(--text-mute); margin-bottom: 6px; }
.live-torch-hint { text-align: center; font-size: 12px; color: var(--text-mute); margin: 4px 0; }
.live-defect-count:empty { display: none; }
.live-processing { text-align: center; padding: 26px 0 10px; font-weight: 700; color: var(--navy); }
.live-spinner {
  width: 34px; height: 34px; margin: 0 auto 12px; border: 4px solid #dfe3ee; border-top-color: var(--navy);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}

.rec-diag { margin: 8px 0; font-size: 12px; color: var(--text-mute); }
.rec-diag summary { cursor: pointer; font-weight: 700; text-align: center; }
.rec-diag-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.rec-diag-btns .btn { flex: 1; padding: 9px 6px; font-size: 13px; }
.rec-diag-btns .btn.active { background: var(--navy); color: #fff; }
.rec-diag pre { white-space: pre-wrap; word-break: break-word; background: #f2f4f8; border-radius: 8px; padding: 8px; font-size: 11px; line-height: 1.4; color: #333; }
.video-info { font-size: 12px; color: var(--text-mute); text-align: center; margin: 6px 0 2px; }
.video-info:empty { display: none; }
.video-info-low { color: #b45309; font-weight: 700; }
.mark-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0; }
.mark-chips:empty { display: none; }
.mark-chips-label { font-size: 12.5px; font-weight: 700; color: var(--red); margin-right: 2px; }
.mark-chip { display: inline-flex; align-items: center; background: #fbeae8; border: 1px solid var(--red); border-radius: 999px; overflow: hidden; }
.mark-chip button { border: none; background: transparent; color: var(--red); font-weight: 800; font-size: 13px; padding: 5px 10px; cursor: pointer; }
.mark-chip .mark-chip-x { padding: 5px 9px 5px 2px; font-size: 16px; line-height: 1; }
.cvp-time { font-size: 11px; color: var(--text-mute); font-variant-numeric: tabular-nums; white-space: nowrap; flex-shrink: 0; }

.entry-video-actions { display: flex; gap: 8px; margin-top: 8px; }
.entry-download-btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: #fff;
  color: var(--text); font-size: 12.5px; font-weight: 600; padding: 7px 12px; border-radius: 8px; cursor: pointer;
}
.entry-download-btn:hover { background: var(--primary-light); }
.entry-download-btn .icon { width: 14px; height: 14px; }
.entry-download-btn:disabled { opacity: 0.6; cursor: default; }

.entry-delete-btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid #f3c9c4; background: #fdf3f2;
  color: var(--red); font-size: 12.5px; font-weight: 700; padding: 8px 12px; border-radius: 8px; cursor: pointer;
  margin-top: 12px;
}
.entry-delete-btn:hover { background: #fbe4e1; }
.entry-delete-btn:disabled { opacity: 0.6; cursor: default; }
.entry-delete-btn .icon { width: 14px; height: 14px; }

.lightbox {
  display: none; position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,0.9);
  align-items: center; justify-content: center; padding: 24px;
}
.lightbox.show { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; object-fit: contain; }
.lightbox-close {
  position: absolute; top: max(16px, env(safe-area-inset-top)); right: 16px; z-index: 5;
  width: 40px; height: 40px; border-radius: 50%; border: none; background: rgba(255,255,255,0.15); color: #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.empty-state { text-align: center; color: var(--text-mute); padding: 60px 20px; font-size: 14px; }

/* ---------- fleet manager dashboard (desktop-first) ---------- */
.dashboard { max-width: 1080px; margin: 0 auto; padding: max(28px, calc(env(safe-area-inset-top) + 16px)) 28px 60px; }
.dash-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.dash-title { font-size: 22px; font-weight: 800; }
.dash-sub { font-size: 13.5px; color: var(--text-mute); }

.dash-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px;
  text-align: left; cursor: pointer; transition: transform 0.12s ease, border-color 0.12s ease;
}
.stat-card:hover { border-color: var(--primary); }
.stat-card:active { transform: scale(0.97); }
.stat-card.active { border-color: var(--red); background: #fbeae8; }
.stat-num { font-size: 24px; font-weight: 800; }
.stat-label { font-size: 12px; color: var(--text-mute); margin-top: 2px; }

.dash-filters { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.filter-group { display: flex; gap: 6px; background: #eef1f6; padding: 4px; border-radius: 10px; flex-wrap: wrap; }
.date-picker-input { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; border: none; }
.chip { border: none; background: transparent; padding: 7px 13px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--text-mute); cursor: pointer; }
.chip.active { background: #fff; color: var(--navy); box-shadow: 0 1px 2px rgba(16,24,40,0.08); }

/* A real, normally-rendered <input type="date"> styled to match the other chips — no
   opacity/overlay tricks. Those caused a real iOS Safari bug (native picker getting stuck
   open), so the reliable fix is to stop fighting the browser's own rendering of it. */
.date-input-chip {
  -webkit-appearance: none; appearance: none;
  font-family: inherit; color-scheme: light;
}
.date-input-chip.active { background: #fff; color: var(--navy); box-shadow: 0 1px 2px rgba(16,24,40,0.08); }

.dash-list .entry-card { max-width: none; }
.dash-list .entry-details .entry-photos img { width: 96px; height: 96px; }

.dash-header-right { display: flex; align-items: center; gap: 12px; }
.fleet-code-chip {
  font-size: 12.5px; color: var(--text-mute); background: #fff; border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 999px;
}
.fleet-code-chip strong { color: var(--navy); letter-spacing: 0.5px; }

.dash-tabs { display: flex; gap: 8px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.dash-tab {
  padding: 10px 4px; margin-right: 20px; border: none; background: transparent; font-weight: 700; font-size: 14.5px;
  color: var(--text-mute); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.dash-tab.active { color: var(--navy); border-bottom-color: var(--primary); }

.dash-panel { display: none; }
.dash-panel.active { display: block; }

.unit-add-card { max-width: 420px; margin-bottom: 20px; }

.kind-badge {
  font-size: 11px; font-weight: 800; letter-spacing: 0.5px; padding: 3px 9px; border-radius: 999px; color: #fff;
}
.kind-badge.truck { background: var(--navy); }
.kind-badge.trailer { background: var(--steel); }

.unit-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.unit-row-left { display: flex; align-items: center; gap: 12px; }
.unit-row-left .kind-badge { margin-bottom: 4px; display: inline-block; }
.unit-qr-thumb {
  width: 56px; height: 56px; flex-shrink: 0; border: 1px solid var(--border); border-radius: 8px;
  display: flex; align-items: center; justify-content: center; overflow: hidden; background: #fff;
}
.unit-qr-thumb canvas, .unit-qr-thumb img { width: 100%; height: 100%; }
.unit-row-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.unit-icon-btn {
  border: none; background: transparent; color: var(--text-mute); cursor: pointer; padding: 8px;
  display: flex; align-items: center; justify-content: center; border-radius: 8px;
}
.unit-icon-btn:hover { background: #f2f4f7; }
.unit-download-btn:hover { color: var(--primary); }
.unit-remove-btn:hover { color: var(--red); }
.unit-icon-btn .icon { width: 17px; height: 17px; }

.driver-row { display: flex; align-items: center; gap: 12px; cursor: default; }
.driver-avatar {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%;
  background: var(--primary-gradient); color: #fff; font-weight: 800; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.driver-row-info { flex: 1; min-width: 0; }
.driver-row .entry-meta { margin-top: 3px; }
.pti-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 8px; vertical-align: middle; flex-shrink: 0; }
.pti-green { background: #22a45d; }
.pti-yellow { background: #f0b429; }
.pti-red { background: #e0392b; }
.pti-unit { margin-left: 8px; font-size: 12.5px; font-weight: 700; color: var(--navy); background: #eef0f6; border-radius: 6px; padding: 2px 7px; vertical-align: middle; }
.pti-status { font-size: 13px; font-weight: 600; margin-top: 3px; }
.pti-status-green { color: #1b7f47; }
.pti-status-yellow { color: #9a6b00; }
.pti-status-red { color: #c0291d; }
.driver-assigned { font-size: 12.5px; color: var(--primary-dark); font-weight: 600; margin-top: 4px; }
.driver-row.driver-row-editing { align-items: flex-start; }

.driver-menu-wrap { position: relative; flex-shrink: 0; }
.driver-menu {
  display: none; position: absolute; top: calc(100% + 4px); right: 0; z-index: 20;
  background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  box-shadow: 0 8px 20px rgba(16,24,40,0.14); min-width: 120px;
}
.driver-menu.show { display: block; }
.driver-menu-item {
  display: block; width: 100%; text-align: left; padding: 10px 14px; border: none; background: none;
  font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer;
}
.driver-menu-item:hover { background: var(--primary-light); }
.driver-menu-item.danger { color: var(--red); }
.driver-menu-item.danger:hover { background: #fbeae8; }

.driver-edit-form { display: flex; flex-direction: column; gap: 8px; }
.driver-edit-form .field { padding: 9px 12px; font-size: 14px; }
.driver-edit-actions { display: flex; gap: 8px; margin-top: 2px; }
.driver-edit-actions .btn { flex: 1; margin-top: 0; padding: 9px; font-size: 13.5px; }

.combo { position: relative; flex: 1; min-width: 150px; }
.combo-input { width: 100%; }
.combo-list {
  display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
  background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 20px rgba(16,24,40,0.12);
  max-height: 220px; overflow-y: auto;
}
.combo-list.show { display: block; }
.combo-option { padding: 9px 14px; font-size: 13.5px; cursor: pointer; color: var(--text); }
.combo-option:hover, .combo-option.active { background: var(--primary-light); }
.combo-option.combo-all { color: var(--text-mute); font-style: italic; border-bottom: 1px solid var(--border); }
.combo-option.combo-empty { color: var(--text-mute); font-style: italic; cursor: default; }
.combo-option.combo-empty:hover { background: none; }

@media (max-width: 720px) {
  .dashboard { padding: max(18px, calc(env(safe-area-inset-top) + 16px)) 14px 50px; }
  .dash-header { flex-wrap: wrap; }
  .dash-header-right { width: 100%; justify-content: space-between; }
}

.driver-edit-label { display: block; font-size: 11.5px; font-weight: 700; color: var(--text-mute); margin: 8px 2px 3px; }
.driver-edit-pwrow { display: flex; gap: 8px; align-items: center; }
.driver-edit-pwrow .field { flex: 1; min-width: 0; }
.driver-edit-pwrow .btn { flex-shrink: 0; padding: 10px 12px; }

.driver-edit-msg { margin: 8px 0 0; padding: 8px 10px; border-radius: 10px; font-size: 13px; font-weight: 700; }
.driver-edit-msg.error { background: #fdeaea; color: #b3261e; border: 1px solid #e0332f; }
.driver-done-title { font-size: 16px; font-weight: 800; margin-bottom: 8px; }
.driver-done-box { background: var(--primary-light); border-radius: 10px; padding: 10px 12px; font-size: 15px; line-height: 1.6; word-break: break-all; }
.driver-done-ok { color: #1b7f3b; font-weight: 700; font-size: 13.5px; margin-top: 8px; }
.driver-done-bad { color: #b3261e; font-weight: 700; font-size: 13.5px; margin-top: 8px; }
.driver-done-note { font-size: 12.5px; color: var(--text-mute); margin-top: 8px; }

/* time flags are not shown any more (the marked pictures are what matters) */
#mark-chips, #defect-count-wrap, .mark-chips-mgr { display: none !important; }

.drivers-search { margin: 0 0 12px; }
.drivers-search .field { margin: 0; }

/* Fleet managers / Drivers "on record" bars */
.people-bar {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: var(--primary-light); color: var(--text, #111); border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px; padding: 13px 14px; margin: 0 0 10px; font: inherit; font-weight: 800; font-size: 15px;
  cursor: pointer; text-align: left;
}
.people-bar .people-bar-title { flex: 1; }
.people-bar .people-bar-count {
  background: var(--primary, #1d4ed8); color: #fff; border-radius: 999px;
  min-width: 26px; padding: 2px 9px; text-align: center; font-size: 13px; font-weight: 800;
}
.people-bar .people-bar-chev { width: 20px; height: 20px; transition: transform .18s ease; }
.people-bar.open .people-bar-chev { transform: rotate(180deg); }
.people-body { margin: 0 0 14px; }

/* the camera view is locked to Wide: no switch button */
#btn-live-fit { display: none !important; }
