/* ── Reset & base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: var(--primary); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 0.95rem; }

/* ── Theme variables ───────────────────────────────────────────── */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #6366f1;
  --purple: #8b5cf6;

  --sidebar-w: 230px;
  --topbar-h: 56px;

  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --sidebar-bg: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-hover: #334155;
  --sidebar-active: #3b82f6;
  --sidebar-active-bg: rgba(59,130,246,0.15);

  --topbar-bg: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --radius: 8px;
  --radius-lg: 12px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #162032;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  --topbar-bg: #1e293b;
  --primary-light: rgba(59,130,246,0.2);
}

/* ── Login page ────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
}
.login-brand { text-align: center; margin-bottom: 2rem; }
.login-brand h1 { font-size: 1.6rem; color: var(--primary); font-weight: 800; letter-spacing: -0.5px; }
.login-brand p { color: var(--text-muted); font-size: 0.875rem; margin-top: 4px; }

/* ── App shell ─────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }
.hidden { display: none !important; }

/* ── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}
.sidebar-brand {
  padding: 1.2rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-brand .logo { font-size: 1.3rem; font-weight: 800; color: #3b82f6; }
.sidebar-brand .tagline { font-size: 0.7rem; color: var(--sidebar-text); }
.sidebar-nav { flex: 1; padding: 0.75rem 0; overflow-y: auto; }
.nav-section { padding: 0.5rem 0.75rem 0.25rem; font-size: 0.65rem; text-transform: uppercase; letter-spacing: .8px; color: #475569; font-weight: 600; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.6rem 1rem;
  color: var(--sidebar-text);
  border-radius: 6px;
  margin: 1px 8px;
  font-size: 0.875rem;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-link.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); font-weight: 600; }
.nav-icon { width: 18px; text-align: center; opacity: .8; }
.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: 0.8rem;
}
.sidebar-user { color: #e2e8f0; font-weight: 600; font-size: 0.875rem; }
.sidebar-role { color: var(--sidebar-text); font-size: 0.75rem; margin-top: 2px; }
.btn-logout {
  display: block;
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.4rem;
  background: rgba(255,255,255,.06);
  color: var(--sidebar-text);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 5px;
  font-size: 0.8rem;
  transition: background .15s;
}
.btn-logout:hover { background: rgba(239,68,68,.2); color: #fca5a5; }

/* ── Main area ─────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.topbar-hamburger { display: none; background: none; border: none; color: var(--text); font-size: 1.2rem; }
.topbar-title { flex: 1; font-weight: 700; font-size: 1rem; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 0.5rem; }
.btn-theme {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: all .15s;
}
.btn-theme:hover { background: var(--surface2); }

/* ── Content ───────────────────────────────────────────────────── */
.content { padding: 1.5rem; flex: 1; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.75rem; }
.page-title { font-size: 1.35rem; font-weight: 700; color: var(--text); }
.page-subtitle { color: var(--text-muted); font-size: 0.875rem; margin-top: 2px; }

/* ── Cards ─────────────────────────────────────────────────────── */
.card { background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border); padding: 1.25rem; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.card-title { font-size: 0.925rem; font-weight: 700; color: var(--text); }

/* ── Stat cards ────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.stat-card.accent-blue { border-left: 3px solid var(--primary); }
.stat-card.accent-green { border-left: 3px solid var(--success); }
.stat-card.accent-orange { border-left: 3px solid var(--warning); }
.stat-card.accent-red { border-left: 3px solid var(--danger); }
.stat-card.accent-purple { border-left: 3px solid var(--purple); }
.stat-icon { font-size: 1.4rem; }
.stat-value { font-size: 1.75rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); }
.clickable { cursor: pointer; transition: transform .08s ease, box-shadow .12s ease; }
.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow, 0 4px 12px rgba(0,0,0,.08)); }
.clickable:active { transform: translateY(0); }

/* ── Earnings / statement graph ────────────────────────────────── */
.earn-graph { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding: 0.5rem 0; overflow-x: auto; }
.earn-bar-wrap { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; flex: 1 0 38px; height: 100%; }
.earn-bar { width: 70%; min-height: 2px; background: var(--primary); border-radius: 4px 4px 0 0; transition: height .2s ease; }
.earn-bar.is-selected { background: var(--success); }
.earn-bar-val { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 2px; }
.earn-bar-lbl { font-size: 0.65rem; color: var(--text-muted); margin-top: 4px; white-space: nowrap; }

/* ── Tables ────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th {
  background: var(--surface2);
  padding: 0.7rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
.text-mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.82rem; }

/* ── Status badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
  white-space: nowrap;
}
.badge::before { content: '●'; font-size: 0.6rem; }
.badge-created    { background: #e2e8f0; color: #475569; }
.badge-picked-up  { background: #dbeafe; color: #1d4ed8; }
.badge-in-hub     { background: #ede9fe; color: #6d28d9; }
.badge-outbound   { background: #cffafe; color: #0e7490; }
.badge-inbound    { background: #e0e7ff; color: #3730a3; }
.badge-out-for-delivery { background: #fef3c7; color: #b45309; }
.badge-delivered  { background: #d1fae5; color: #065f46; }
.badge-failed     { background: #fee2e2; color: #991b1b; }
.badge-return     { background: #ffedd5; color: #9a3412; }
.badge-admin  { background: #fee2e2; color: #991b1b; }
.badge-agent  { background: #dbeafe; color: #1d4ed8; }
.badge-driver { background: #d1fae5; color: #065f46; }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.5rem 1rem;
  border-radius: 7px;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  transition: all .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: #f59e0b; color: white; }
.btn-warning:hover { background: #d97706; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--surface2); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-ghost { background: none; border: none; color: var(--text-muted); padding: 0.3rem 0.5rem; }
.btn-ghost:hover { color: var(--text); background: var(--surface2); }

/* ── Forms ─────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.span-2 { grid-column: span 2; }
.form-group.span-full { grid-column: 1 / -1; }
label { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .3px; }
.label-required::after { content: ' *'; color: var(--danger); }
input[type="text"], input[type="number"], input[type="password"], input[type="email"],
input[type="tel"], select, textarea {
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
textarea { resize: vertical; min-height: 80px; }
.field-note { font-size: 0.75rem; color: var(--text-muted); }
.form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; flex-wrap: wrap; }

/* ── Filter bar ────────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; align-items: center; }
.filter-bar input, .filter-bar select { min-width: 140px; flex: 1; max-width: 220px; }

/* ── Timeline ──────────────────────────────────────────────────── */
.timeline { list-style: none; position: relative; padding-left: 1.5rem; }
.timeline::before { content: ''; position: absolute; left: 0.4rem; top: 0; bottom: 0; width: 2px; background: var(--border); border-radius: 2px; }
.timeline-item { position: relative; padding-bottom: 1.25rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -1.18rem;
  top: 4px;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--text-muted);
}
.timeline-dot.active { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.timeline-dot.delivered { background: var(--success); }
.timeline-dot.failed { background: var(--danger); }
.timeline-status { font-size: 0.875rem; font-weight: 700; color: var(--text); }
.timeline-meta { font-size: 0.775rem; color: var(--text-muted); margin-top: 2px; }
.timeline-notes { font-size: 0.8rem; color: var(--text-muted); margin-top: 3px; font-style: italic; }

/* ── Modal ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-weight: 700; font-size: 1rem; }
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}
.btn-close { background: none; border: none; font-size: 1.1rem; color: var(--text-muted); line-height: 1; }
.btn-close:hover { color: var(--text); }

/* ── Toast ─────────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 300; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
  background: #1e293b;
  color: #f1f5f9;
  padding: 0.8rem 1.2rem;
  border-radius: 8px;
  font-size: 0.875rem;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: slideIn .2s ease;
  min-width: 240px;
  max-width: 360px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--primary); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Order detail layout ───────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 1.25rem; }
.detail-section { margin-bottom: 1.25rem; }
.detail-row { display: flex; justify-content: space-between; padding: 0.55rem 0; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.detail-row:last-child { border-bottom: none; }
.detail-key { color: var(--text-muted); }
.detail-value { font-weight: 600; color: var(--text); text-align: right; max-width: 60%; word-break: break-word; }
.tracking-big { font-size: 1.5rem; font-weight: 800; font-family: 'SF Mono', monospace; letter-spacing: 1px; color: var(--primary); }

/* ── Wallet balance ────────────────────────────────────────────── */
.wallet-balance-card {
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  color: white;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.wallet-balance-label { font-size: 0.8rem; opacity: .8; text-transform: uppercase; letter-spacing: .5px; }
.wallet-balance-amount { font-size: 2.5rem; font-weight: 800; margin: 0.25rem 0; }
.wallet-balance-sub { font-size: 0.8rem; opacity: .75; }

/* ── POD image ─────────────────────────────────────────────────── */
.pod-image { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--border); margin-top: 0.5rem; }
.pod-section { background: var(--surface2); border: 1px dashed var(--border); border-radius: var(--radius); padding: 1rem; text-align: center; }
.pod-gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.75rem; }
.pod-thumb { margin: 0; text-align: center; }
.pod-thumb .pod-image { margin-top: 0; }
.pod-thumb figcaption { margin-top: 0.25rem; }

/* ── Driver action grid (mobile-app style) ─────────────────────── */
.driver-action-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
.da-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.3rem;
  padding: 1rem 0.5rem; min-height: 84px;
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 0.85rem; font-weight: 600; text-align: center; cursor: pointer;
  transition: all .15s;
}
.da-btn:hover { border-color: var(--primary); background: var(--surface); transform: translateY(-1px); }
.da-btn .da-ico { font-size: 1.6rem; line-height: 1; }
.da-btn.warn { border-color: #f59e0b; }
.da-btn.warn:hover { background: #fffbeb; }
.da-btn.danger { border-color: var(--danger); }
.da-btn.danger:hover { background: #fef2f2; }

/* ── Contact links (driver listings) ───────────────────────────── */
.contact-link { color: var(--primary); font-weight: 600; text-decoration: none; }
.contact-link:hover { text-decoration: underline; }
.contact-link.wa { color: #16a34a; }
.contact-link.map { color: #2563eb; }

/* ── Weight-approval photo gallery ─────────────────────────────── */
.wa-gallery { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; margin-top: 0.75rem; }
.wa-photo { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; text-decoration: none; color: var(--text-muted); font-size: 0.75rem; }
.wa-photo img { width: 100%; height: 90px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); }
.wa-photo.empty { justify-content: center; height: 90px; border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface2); }
.wa-photo.empty small { opacity: .6; }
@media (max-width: 600px) { .wa-gallery { grid-template-columns: repeat(2, 1fr); } }

/* ── Empty state ───────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.empty-title { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 0.25rem; }

/* ── Loading ───────────────────────────────────────────────────── */
.loading { display: flex; align-items: center; justify-content: center; padding: 3rem; color: var(--text-muted); gap: 0.5rem; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Misc ──────────────────────────────────────────────────────── */
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-muted   { color: var(--text-muted) !important; }
.text-small   { font-size: 0.8rem; }
.text-right    { text-align: right !important; }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.gap-2 { gap: 0.5rem; }
.alert { padding: 0.75rem 1rem; border-radius: var(--radius); font-size: 0.875rem; margin-bottom: 1rem; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: var(--primary-light); color: var(--primary); border: 1px solid #bfdbfe; }
.divider { height: 1px; background: var(--border); margin: 1rem 0; }
.zone-tag { display: inline-block; background: var(--primary-light); color: var(--primary); border-radius: 4px; padding: 2px 7px; font-size: 0.75rem; font-weight: 600; margin: 2px; }

/* ── Customer badge ────────────────────────────────────────────── */
.badge-customer { background: #fef3c7; color: #b45309; }

/* ── Volume warning banners ────────────────────────────────────── */
.vol-warn  { background: #fefce8; color: #854d0e; border: 1px solid #fde047; border-radius: var(--radius); padding: .7rem 1rem; font-size: .875rem; margin-bottom: 1rem; display: flex; align-items: flex-start; gap: .5rem; }
.vol-alert { background: #fff7ed; color: #9a3412; border: 1px solid #fb923c; border-radius: var(--radius); padding: .7rem 1rem; font-size: .875rem; margin-bottom: 1rem; display: flex; align-items: flex-start; gap: .5rem; }
.vol-block { background: #fef2f2; color: #991b1b; border: 1px solid #f87171; border-radius: var(--radius); padding: .7rem 1rem; font-size: .875rem; margin-bottom: 1rem; display: flex; align-items: flex-start; gap: .5rem; }
.vol-icon  { font-size: 1rem; flex-shrink: 0; margin-top: .05rem; }

/* ── Register link on login ────────────────────────────────────── */
.login-switch { text-align: center; margin-top: 1.1rem; font-size: .82rem; color: var(--text-muted); }
.login-switch a { color: var(--primary); font-weight: 600; cursor: pointer; }

/* ── Alert info (used on register form) ────────────────────────── */
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-230px); width: 230px; --sidebar-w: 230px; box-shadow: var(--shadow-md); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .topbar-hamburger { display: flex; }
  .detail-grid { grid-template-columns: 1fr; }
  .content { padding: 1rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-group.span-2 { grid-column: span 1; }
  .filter-bar input, .filter-bar select { max-width: 100%; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ─── V1 Scan-driven driver flow ─────────────────────────────────── */
.dh-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.dh-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 1.1rem 0.5rem; border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); cursor: pointer; text-align: center;
  font-size: 0.82rem; font-weight: 600; transition: transform .08s, border-color .12s, background .12s;
}
.dh-tile:hover { border-color: var(--primary); background: var(--surface); transform: translateY(-1px); }
.dh-tile .dh-ico { font-size: 1.9rem; line-height: 1; }
.dh-tile.alt { border-style: dashed; }
@media (max-width: 480px) { .dh-grid { grid-template-columns: repeat(2, 1fr); } }

.scan-wrap { max-width: 560px; margin: 0 auto; }
.scan-reader {
  width: 100%; border-radius: var(--radius-lg); overflow: hidden;
  background: #000; min-height: 220px;
}
.scan-reader video { width: 100% !important; height: auto !important; display: block; }
.scan-cam-msg { color: var(--danger); font-size: 0.85rem; text-align: center; margin-top: 0.5rem; min-height: 1.1em; }
.scan-total {
  text-align: center; font-size: 1.2rem; font-weight: 800; margin: 1rem 0;
  color: var(--primary); letter-spacing: .5px;
}
.scan-total #scan-count {
  display: inline-block; min-width: 2.2rem; padding: 0.15rem 0.7rem; margin-left: .4rem;
  background: var(--primary); color: #fff; border-radius: 30px; font-size: 1.15rem;
}
.scan-total.pulse { animation: scanPulse .4s ease; }
@keyframes scanPulse { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
.scan-hub { display: flex; align-items: center; gap: 0.5rem; margin: 0.75rem 0 0.25rem; }
.scan-hub label { font-weight: 700; font-size: 0.9rem; color: var(--text-muted); white-space: nowrap; }
.scan-hub select { flex: 1; padding: 0.5rem; border-radius: 8px; border: 1px solid var(--border, #ccc); }
.scan-manual { display: flex; gap: 0.5rem; }
.scan-manual input { flex: 1; text-transform: uppercase; }
.pickup-confirm { margin: 0.75rem 0; }
.pickup-confirm .btn-block { width: 100%; padding: 0.9rem; font-size: 1.05rem; font-weight: 700; }
.btn-block { display: block; width: 100%; }
.scan-log { list-style: none; padding: 0; margin: 0; max-height: 260px; overflow-y: auto; }
.scan-log-empty { color: var(--text-muted); font-size: 0.85rem; padding: 0.5rem 0; }
.scan-log-item {
  display: flex; justify-content: space-between; gap: 0.75rem; align-items: baseline;
  padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: 0.85rem;
}
.scan-log-item:last-child { border-bottom: none; }
.scan-log-item .sl-tn { font-family: 'SF Mono','Fira Code',monospace; font-weight: 700; }
.scan-log-item.ok .sl-note { color: var(--success, #059669); }
.scan-log-item.err .sl-note { color: var(--danger); }

.driver-home-links { display: flex; flex-direction: column; gap: 0.5rem; }
.driver-home-links .dhl {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.75rem 0.9rem; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-weight: 600; font-size: 0.9rem; text-decoration: none;
}
.driver-home-links .dhl:hover { border-color: var(--primary); background: var(--surface); }
.driver-home-links .dhl span { font-size: 1.2rem; }

/* ─── V6 Driver transit-flow buckets ─────────────────────────────── */
.flow-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.flow-cell {
  display: block; padding: 0.85rem 0.7rem; border: 1px solid var(--border);
  border-left: 3px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); text-decoration: none;
  transition: transform .08s, border-color .12s, background .12s;
}
a.flow-cell:hover { background: var(--surface); transform: translateY(-1px); }
.flow-cell .flow-num { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.flow-cell .flow-lbl { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); margin-top: 0.2rem; }
.flow-cell.accent-slate  { border-left-color: #64748b; }
.flow-cell.accent-blue   { border-left-color: var(--primary); }
.flow-cell.accent-amber  { border-left-color: #d97706; }
.flow-cell.accent-purple { border-left-color: var(--purple, #8b5cf6); }
.flow-cell.accent-orange { border-left-color: var(--warning); }
.flow-cell.accent-green  { border-left-color: var(--success); }
@media (max-width: 480px) { .flow-grid { grid-template-columns: repeat(2, 1fr); } }
