/* CarsRefer - Noen Maprang Hospital 
   Design System & Styling
   Medical Fleet & Referral Dispatch Style - Purple & Pink Theme
*/

@import url('https://fonts.googleapis.com/css2?family=Prompt:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=Inter:wght@400;500;600;700&display=swap');

@font-face {
  font-family: 'TH Sarabun New';
  src: url('/fonts/th-sarabun-new/regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'TH Sarabun New';
  src: url('/fonts/th-sarabun-new/bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-main: 'Prompt', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Inter', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  
  /* Color Palette - Elegant Purple & Vibrant Pink */
  --bg-primary: #0d0b1a;
  --bg-secondary: #161228;
  --bg-card: rgba(26, 20, 48, 0.78);
  --bg-card-hover: rgba(38, 28, 70, 0.88);
  --bg-input: #120e24;
  --border-color: rgba(236, 72, 153, 0.15);
  --border-focus: #a855f7;
  
  --text-main: #f8fafc;
  --text-muted: #c4b5fd;
  --text-subtle: #8b7fa8;
  
  /* Primary & Accent: Purple & Pink */
  --primary: #9333ea;
  --primary-hover: #7e22ce;
  --primary-glow: rgba(147, 51, 234, 0.35);
  
  --pink: #ec4899;
  --pink-hover: #db2777;
  --pink-glow: rgba(236, 72, 153, 0.35);
  --primary-gradient: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
  --primary-gradient-hover: linear-gradient(135deg, #7c3aed 0%, #db2777 100%);
  
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.3);
  --warning: #f59e0b;
  --warning-glow: rgba(245, 158, 11, 0.3);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.4);
  --info: #06b6d4;
  
  /* Triage Colors */
  --triage-red: #ef4444;
  --triage-pink: #ec4899;
  --triage-yellow: #f59e0b;
  --triage-green: #10b981;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.25);
  --shadow-md: 0 8px 24px rgba(139, 92, 246, 0.12);
  --shadow-lg: 0 16px 36px rgba(139, 92, 246, 0.18);
  
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(147, 51, 234, 0.16) 0px, transparent 55%),
    radial-gradient(at 100% 0%, rgba(236, 72, 153, 0.14) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(168, 85, 247, 0.10) 0px, transparent 60%);
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: #3b2857;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #6b21a8;
}

/* Header & Navigation */
.header-bar {
  background: rgba(11, 19, 32, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1.5rem;
}

.header-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.brand-badge {
  font-size: 0.65rem;
  background: rgba(37, 99, 235, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(96, 165, 250, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* View Mode Switcher */
.view-switcher {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 3px;
  gap: 4px;
}

.view-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.45rem 1rem;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.view-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.view-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* Header Live Status */
.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.active-driver-badge {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  font-size: 0.8rem;
}

.driver-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 rgba(16, 185, 129, 0.5);
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Main Container */
.main-content {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem;
  width: 100%;
  flex: 1;
}

/* Page Views */
.view-section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Glass Card */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

/* Stat Grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  background: rgba(255, 255, 255, 0.05);
}

.stat-icon.blue { background: rgba(37, 99, 235, 0.15); color: #60a5fa; }
.stat-icon.green { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.stat-icon.orange { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.stat-icon.red { background: rgba(239, 68, 68, 0.15); color: #f87171; }

.stat-info .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-info .value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

/* Driver Cockpit Layout */
.cockpit-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.5rem;
}

@media (max-width: 1024px) {
  .cockpit-grid {
    grid-template-columns: 1fr;
  }
}

/* Driver Profile Card */
.driver-card {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.driver-profile-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
}

.driver-avatar {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #1e293b, #334155);
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  border: 2px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.driver-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 4px;
}

.status-on-duty {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-en-route {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
  animation: pulse-orange 1.5s infinite;
}

@keyframes pulse-orange {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.status-off-duty {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

/* Forms and Inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-control, .form-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 0.9rem;
  transition: var(--transition);
}

.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

.checkbox-group {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.checkbox-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--success);
  cursor: pointer;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary-gradient);
  color: #fff;
  box-shadow: 0 4px 14px var(--pink-glow);
}
.btn-primary:hover {
  background: var(--primary-gradient-hover);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, var(--success), #059669);
  color: #fff;
  box-shadow: 0 4px 14px var(--success-glow);
}
.btn-success:hover {
  background: linear-gradient(135deg, #34d399, var(--success));
  transform: translateY(-1px);
}

.btn-warning {
  background: linear-gradient(135deg, var(--warning), #d97706);
  color: #111827;
  box-shadow: 0 4px 14px var(--warning-glow);
}
.btn-warning:hover {
  background: linear-gradient(135deg, #fbbf24, var(--warning));
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #b91c1c);
  color: #fff;
  box-shadow: 0 4px 14px var(--danger-glow);
}
.btn-danger:hover {
  background: linear-gradient(135deg, #f87171, var(--danger));
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-large {
  padding: 0.85rem 1.75rem;
  font-size: 1.05rem;
  border-radius: var(--radius-lg);
}

.btn-block {
  width: 100%;
}

/* Mission Control Card (พลขับ) */
.mission-card-active {
  border: 2px solid rgba(239, 68, 68, 0.4);
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.08) 0%, rgba(18, 30, 52, 0.85) 100%);
  position: relative;
}

.mission-urgent-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
}

.triage-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.triage-red { background: rgba(239, 68, 68, 0.25); color: #fca5a5; border: 1px solid #ef4444; }
.triage-pink { background: rgba(236, 72, 153, 0.25); color: #fbcfe8; border: 1px solid #ec4899; }
.triage-yellow { background: rgba(245, 158, 11, 0.25); color: #fde68a; border: 1px solid #f59e0b; }
.triage-green { background: rgba(16, 185, 129, 0.25); color: #a7f3d0; border: 1px solid #10b981; }

/* Stepper Workflow */
.timeline-stepper {
  display: flex;
  justify-content: space-between;
  position: relative;
  margin: 2rem 0;
}

.timeline-stepper::before {
  content: '';
  position: absolute;
  top: 18px;
  left: 30px;
  right: 30px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  z-index: 1;
}

.step-item {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
  flex: 1;
}

.step-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: var(--transition);
}

.step-item.completed .step-circle {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.step-item.current .step-circle {
  background: var(--warning);
  border-color: var(--warning);
  color: #111827;
  box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.25);
  animation: pulse-step 2s infinite;
}

@keyframes pulse-step {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.step-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  max-width: 90px;
}

.step-item.completed .step-title,
.step-item.current .step-title {
  color: var(--text-main);
}

.step-time {
  font-size: 0.7rem;
  color: var(--text-subtle);
  font-family: var(--font-mono);
}

/* Fleet Cards (Center View) */
.fleet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.vehicle-card {
  border-left: 4px solid var(--border-color);
  transition: var(--transition);
}

.vehicle-card.ready { border-left-color: var(--success); }
.vehicle-card.en_route { border-left-color: var(--warning); }
.vehicle-card.on_duty { border-left-color: var(--primary); }
.vehicle-card.maintenance { border-left-color: var(--danger); }

.vehicle-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.vehicle-code {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.vehicle-plate {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-ready { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-en_route { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-on_duty { background: rgba(37, 99, 235, 0.15); color: #60a5fa; }
.badge-maintenance { background: rgba(239, 68, 68, 0.15); color: #f87171; }

.vehicle-specs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  font-size: 0.8rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.65rem;
  border-radius: var(--radius-sm);
  margin: 0.75rem 0;
}

.spec-item span:first-child {
  color: var(--text-subtle);
  display: block;
  font-size: 0.7rem;
}

.vehicle-driver {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  padding-top: 0.75rem;
  margin-top: 0.5rem;
}

/* Modal Styling */
.modal-overlay, .modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.active, .modal.active {
  display: flex;
  animation: modalIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-box, .modal-content {
  background: #111e33;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.2);
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.close-btn:hover { color: var(--text-main); }

/* Mission Table */
.data-table-container {
  overflow-x: auto;
  margin-top: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.data-table th {
  background: rgba(0, 0, 0, 0.3);
  padding: 0.85rem 1rem;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  background: #1e293b;
  color: #fff;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  border-left: 4px solid var(--primary);
  animation: slideInRight 0.3s ease;
  font-size: 0.85rem;
}

.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.error { border-left-color: var(--danger); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Print Sheet Styling */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .header-bar, .view-switcher, .btn, .modal-footer, .header-actions, .dashboard-filter-bar {
    display: none !important;
  }
  .print-area, .printable-report-section {
    display: block !important;
    padding: 0 !important;
    color: #000 !important;
  }
  .glass-card {
    background: #fff !important;
    color: #000 !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
  }
}

/* =========================================================
   DRIVER AVATAR & PHOTO UPLOAD STYLES
   ========================================================= */
.driver-avatar {
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.driver-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
  display: block;
}

.driver-avatar-thumb {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.08);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  overflow: hidden;
  vertical-align: middle;
  flex-shrink: 0;
}

.driver-avatar-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
}

.driver-avatar-lg {
  width: 68px;
  height: 68px;
  min-width: 68px;
  border-radius: 0;
  border: 2px solid rgba(96, 165, 250, 0.4);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

.photo-upload-box {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
}

.photo-preview-circle {
  width: 64px;
  height: 64px;
  min-width: 64px;
  border-radius: 0;
  background: #1e293b;
  border: 2px solid #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  overflow: hidden;
  flex-shrink: 0;
}

.photo-preview-circle img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Fleet Driver Avatar */
.driver-avatar-fleet {
  width: 46px;
  height: 46px;
  min-width: 46px;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid #34d399;
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 1.35rem;
  flex-shrink: 0;
  transition: transform 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
}
.driver-avatar-fleet:hover {
  transform: scale(1.08);
}
.driver-avatar-fleet img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
  display: block;
}
.driver-avatar-fleet.inactive {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: none;
  background: rgba(255, 255, 255, 0.04);
  cursor: default;
}

/* Live Verification Photo Box in Vehicle Cards */
.vehicle-live-photo-box {
  margin-top: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}
.vehicle-live-photo-box:hover {
  background: rgba(15, 23, 42, 0.9);
  border-color: rgba(52, 211, 153, 0.7);
  box-shadow: 0 4px 14px rgba(52, 211, 153, 0.2);
  transform: translateY(-1px);
}
.vehicle-live-photo-thumb-wrap {
  width: 52px;
  height: 52px;
  min-width: 52px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1.5px solid #34d399;
  position: relative;
  background: #000;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
.vehicle-live-photo-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.vehicle-live-photo-zoom-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.65rem;
  padding: 1px 3px;
  border-radius: 3px;
  line-height: 1;
}
.vehicle-live-photo-info {
  flex: 1;
  min-width: 0;
}
.vehicle-live-photo-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: #34d399;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vehicle-live-photo-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.vehicle-live-photo-hint {
  font-size: 0.68rem;
  color: #93c5fd;
  margin-top: 3px;
}

/* Dispatch Center: Driver Duty Roster Cards */
.dispatch-drivers-section {
  margin-bottom: 2rem;
}
.dispatch-drivers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.dispatch-driver-card {
  background: rgba(30, 41, 59, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}
.dispatch-driver-card:hover {
  transform: translateY(-2px);
  background: rgba(30, 41, 59, 0.85);
  border-color: rgba(96, 165, 250, 0.35);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}
.dispatch-driver-photo {
  width: 52px;
  height: 52px;
  min-width: 52px;
  border-radius: 0;
  border: 2px solid #3b82f6;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  font-size: 1.6rem;
  flex-shrink: 0;
}
.dispatch-driver-photo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
  display: block;
}
.dispatch-driver-card.on-duty .dispatch-driver-photo {
  border-color: #34d399;
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.4);
  flex-shrink: 0;
}
.dispatch-driver-card.on-mission .dispatch-driver-photo {
  border-color: #fbbf24;
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.4);
  flex-shrink: 0;
}
.dispatch-driver-card.standby .dispatch-driver-photo {
  border-color: rgba(148, 163, 184, 0.5);
  flex-shrink: 0;
}
.dispatch-driver-info {
  flex: 1;
  min-width: 0;
}
.dispatch-driver-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dispatch-driver-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 2px;
}
.dispatch-driver-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 9999px;
  margin-top: 4px;
}
.status-badge-onduty {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.status-badge-mission {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.status-badge-standby {
  background: rgba(148, 163, 184, 0.12);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.2);
}
.dispatch-driver-phone-btn {
  color: #93c5fd;
  text-decoration: none;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 4px;
  transition: color 0.15s ease;
}
.dispatch-driver-phone-btn:hover {
  color: #60a5fa;
  text-decoration: underline;
}

/* Active Mission Driver Cell */
.mission-driver-cell {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* =========================================================
   EMS BADGES & TAGS
   ========================================================= */
.badge-ems {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
}

.badge-refer {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.4);
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
}

.badge-ems {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
}

.badge-mobile {
  background: rgba(168, 85, 247, 0.18);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, 0.4);
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
}

.badge-staff {
  background: rgba(6, 182, 212, 0.18);
  color: #67e8f9;
  border: 1px solid rgba(6, 182, 212, 0.4);
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
}

.badge-lab {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.4);
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
}

/* Mission Type Selector Cards */
.mission-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.5rem;
  margin-top: 0.35rem;
}
.mission-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 0.4rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  position: relative;
  user-select: none;
}
.mission-type-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.mission-type-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
}
.mission-type-card.selected {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.15);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.25);
}
.mission-type-card.selected[data-type="ems"] {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.15);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.25);
}
.mission-type-card.selected[data-type="mobile_unit"] {
  border-color: #a855f7;
  background: rgba(168, 85, 247, 0.15);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.25);
}
.mission-type-card.selected[data-type="staff_transport"] {
  border-color: #06b6d4;
  background: rgba(6, 182, 212, 0.15);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.25);
}
.mission-type-card.selected[data-type="lab_transport"] {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.15);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.25);
}
.mtc-icon {
  font-size: 1.4rem;
  margin-bottom: 0.2rem;
}
.mtc-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #e2e8f0;
  line-height: 1.2;
}

.mission-tag-ems {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(245, 158, 11, 0.2));
  border-left: 4px solid #f59e0b !important;
}

/* =========================================================
   DASHBOARD & CUMULATIVE REPORTS STYLES
   ========================================================= */
.dashboard-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-pill-group {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.filter-pill {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.4rem 0.9rem;
  border-radius: 7px;
  font-size: 0.8rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.filter-pill:hover {
  color: var(--text-main);
}

.filter-pill.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.filter-pill-ems.active {
  background: #f59e0b;
  color: #000;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

.filter-pill-refer.active {
  background: #3b82f6;
  color: #fff;
}

/* Dashboard KPI Card Extensions */
.stat-kpi-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Timeline Trend Visual Chart */
.trend-chart-card {
  margin-bottom: 1.5rem;
}

.trend-bars-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 180px;
  padding: 1.5rem 0.5rem 0.5rem 0.5rem;
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
}

.trend-column {
  flex: 1;
  min-width: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  gap: 4px;
}

.trend-bar-stack {
  width: 24px;
  display: flex;
  flex-direction: column-reverse;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px 4px 0 0;
  overflow: hidden;
  position: relative;
  transition: height 0.4s ease;
}

.bar-segment-refer {
  background: linear-gradient(180deg, #3b82f6, #1d4ed8);
  width: 100%;
  transition: height 0.3s ease;
}

.bar-segment-ems {
  background: linear-gradient(180deg, #fbbf24, #d97706);
  width: 100%;
  transition: height 0.3s ease;
}

.bar-segment-mobile {
  background: linear-gradient(180deg, #a855f7, #7e22ce);
  width: 100%;
  transition: height 0.3s ease;
}

.bar-segment-staff {
  background: linear-gradient(180deg, #06b6d4, #0e7490);
  width: 100%;
  transition: height 0.3s ease;
}

.bar-segment-lab {
  background: linear-gradient(180deg, #10b981, #047857);
  width: 100%;
  transition: height 0.3s ease;
}

.trend-col-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-family: var(--font-mono);
}

.trend-col-val {
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  font-family: var(--font-mono);
}

/* Progress bar inside tables */
.mini-progress-track {
  width: 100%;
  max-width: 110px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}

.mini-progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #3b82f6, #06b6d4);
}

.mini-progress-fill.green {
  background: linear-gradient(90deg, #10b981, #34d399);
}

.mini-progress-fill.amber {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

/* ============================================== */
/* 11. LOGIN OVERLAY & PIN KEYPAD STYLES         */
/* ============================================== */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 12, 22, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.3s ease;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(18, 30, 52, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6), 0 0 40px rgba(37, 99, 235, 0.2);
  border-radius: var(--radius-xl);
  padding: 2rem 1.75rem;
}

.login-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-mode-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  gap: 4px;
}

.login-tab-btn {
  flex: 1;
  padding: 0.6rem 0.5rem;
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.login-tab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.pin-display-container {
  text-align: center;
  margin-bottom: 1.5rem;
}

.pin-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  margin-bottom: 0.5rem;
}

.pin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.pin-dot.filled {
  background: #3b82f6;
  border-color: #60a5fa;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.6);
  transform: scale(1.15);
}

.pin-error {
  color: #f87171;
  font-size: 0.82rem;
  margin-top: 0.5rem;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  max-width: 280px;
  margin: 0 auto;
}

.pin-btn {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 600;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pin-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.04);
}

.pin-btn:active {
  background: var(--primary);
  transform: scale(0.95);
}

.pin-btn-clear {
  font-size: 1.1rem;
  color: #f87171;
}

.pin-btn-back {
  font-size: 1.2rem;
  color: #94a3b8;
}

/* Mobile Menu Hamburger Button */
.mobile-menu-btn {
  display: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: #fff;
  font-size: 1.3rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  line-height: 1;
}

/* GPS and Map link badges */
.gps-tag-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  background: rgba(37, 99, 235, 0.15);
  border: 1px solid rgba(37, 99, 235, 0.35);
  color: #93c5fd;
  text-decoration: none;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  transition: var(--transition);
}

.gps-tag-link:hover {
  background: rgba(37, 99, 235, 0.35);
  color: #fff;
  border-color: #60a5fa;
}

/* ============================================== */
/* 12. RESPONSIVE MEDIA QUERIES (TABLET & MOBILE) */
/* ============================================== */

/* Base styles for mobile elements */
.mobile-bottom-nav {
  display: none;
}

.modal-drag-handle {
  display: none;
}

.depart-mileage-row {
  display: flex;
  gap: 0.75rem;
}

/* ==============================================
   TABLET & DOWN (max-width: 1024px)
   ============================================== */
@media (max-width: 1024px) {
  .mobile-menu-btn {
    display: inline-flex;
  }

  .header-bar .view-switcher {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(11, 19, 32, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    flex-direction: column;
    gap: 0.5rem;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.6);
    z-index: 1000;
  }

  .header-bar .view-switcher.mobile-open {
    display: flex;
    animation: fadeIn 0.2s ease;
  }

  .view-switcher .view-btn {
    width: 100%;
    justify-content: flex-start;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
  }

  .main-content {
    padding: 1rem 1rem 3rem 1rem;
  }

  .data-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .data-table th, .data-table td {
    padding: 0.65rem 0.75rem;
    font-size: 0.82rem;
  }

  /* Prevent auto-zoom on iOS & provide touch-friendly fields */
  input[type="text"],
  input[type="number"],
  input[type="password"],
  input[type="email"],
  select,
  textarea,
  .form-control,
  .form-select {
    font-size: 16px !important;
    min-height: 46px;
    border-radius: var(--radius-sm);
  }
}

/* ==============================================
   TABLET VIEW (768px to 1024px: iPad, Android Tabs)
   ============================================== */
@media (min-width: 768px) and (max-width: 1024px) {
  .cockpit-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .fleet-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .dispatch-drivers-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.85rem;
  }

  /* Tablet Modal: Elegant centered card (NOT stretched bottom sheet) */
  .modal-overlay, .modal {
    padding: 1.5rem;
    align-items: center;
    justify-content: center;
  }

  .modal-box, .modal-content {
    width: 100% !important;
    max-width: 640px !important;
    max-height: 88vh !important;
    border-radius: var(--radius-xl) !important;
    margin: auto !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
  }

  .modal-body {
    padding: 1.5rem;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-footer {
    padding: 1rem 1.5rem;
    display: flex;
    gap: 0.75rem;
  }
}

/* ==============================================
   SMARTPHONE / MOBILE PHONE (< 768px: iOS / Android)
   ============================================== */
@media (max-width: 767px) {
  .brand-subtitle {
    display: none;
  }

  .brand-logo img {
    width: 38px !important;
    height: 38px !important;
  }

  .brand-logo h1 {
    font-size: 1.05rem !important;
  }

  /* Hide QR modal button on mobile header (user is already on phone) */
  #btn-header-mobile {
    display: none !important;
  }

  /* Cockpit Layout for Mobile: Prioritize Mission Panel */
  .cockpit-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 1rem;
  }

  #cockpit-mission-panel {
    order: 1;
  }

  .driver-card {
    order: 2;
  }

  /* Depart Action: Stacks vertically for thumb-friendly interaction */
  .depart-mileage-row {
    flex-direction: column !important;
    gap: 0.65rem !important;
  }

  .depart-mileage-row input {
    max-width: 100% !important;
    width: 100% !important;
    min-height: 48px;
    font-size: 1.1rem !important;
    font-weight: 700;
    text-align: center;
  }

  .depart-mileage-row button {
    width: 100% !important;
    min-height: 50px;
    font-size: 0.95rem;
    white-space: normal;
    line-height: 1.35;
  }

  /* Collapse multi-column form grids to single column on mobile */
  div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  /* Mobile App Bottom Navigation Bar */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 58px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(11, 19, 32, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.6);
    z-index: 990;
    justify-content: space-around;
    align-items: center;
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 6px 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    user-select: none;
    position: relative;
    height: 100%;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-nav-item .mob-nav-icon {
    font-size: 1.35rem;
    line-height: 1.1;
    transition: transform 0.2s ease;
  }

  .mobile-nav-item .mob-nav-label {
    font-size: 0.65rem;
    font-weight: 600;
    margin-top: 2px;
    letter-spacing: 0.2px;
    transition: color 0.2s ease;
  }

  .mobile-nav-item.active {
    color: #60a5fa;
  }

  .mobile-nav-item.active .mob-nav-icon {
    transform: translateY(-2px) scale(1.12);
    filter: drop-shadow(0 2px 8px rgba(59, 130, 246, 0.6));
  }

  .mobile-nav-item.active .mob-nav-label {
    color: #93c5fd;
    font-weight: 700;
  }

  .mobile-nav-item.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    border-radius: 0 0 4px 4px;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.8);
  }

  /* Padding bottom on main content to avoid bottom nav overlay */
  .main-content {
    padding: 0.75rem 0.65rem calc(72px + env(safe-area-inset-bottom, 0px)) 0.65rem !important;
  }

  .app-footer {
    margin-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    padding: 0.85rem 1rem !important;
  }

  /* Modern Mobile Modal Bottom Sheet */
  .modal-overlay, .modal {
    padding: 0;
    align-items: flex-end;
    justify-content: center;
  }

  .modal-box, .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92vh !important;
    border-radius: 20px 20px 0 0 !important;
    margin: 0 !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
    animation: modalSlideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes modalSlideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }

  .modal-drag-handle {
    display: block;
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.28);
    border-radius: 4px;
    margin: 8px auto 2px auto;
  }

  .modal-header {
    padding: 0.85rem 1.15rem;
    position: sticky;
    top: 0;
    background: #111e33;
    z-index: 10;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  .modal-body {
    padding: 1.15rem 1rem;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-footer {
    padding: 0.85rem 1rem calc(0.85rem + env(safe-area-inset-bottom, 0px)) 1rem;
    position: sticky;
    bottom: 0;
    background: #0d1728;
    z-index: 10;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 0.6rem;
  }

  .modal-footer .btn {
    flex: 1;
    min-height: 48px;
    font-size: 0.95rem;
    justify-content: center;
  }

  .cockpit-actions .btn, .cockpit-step-actions .btn {
    min-height: 48px;
    font-size: 0.95rem;
  }

  /* Fleet and Driver cards on mobile */
  .fleet-grid {
    grid-template-columns: 1fr !important;
    gap: 0.85rem;
  }

  .dispatch-drivers-grid {
    grid-template-columns: 1fr !important;
    gap: 0.75rem;
  }

  .stat-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
  }

  .stat-card {
    padding: 0.85rem 0.75rem;
    gap: 0.65rem;
  }

  .stat-icon {
    width: 42px;
    height: 42px;
    font-size: 1.25rem;
    min-width: 42px;
  }

  .stat-info .value {
    font-size: 1.2rem;
  }

  .stat-info .label {
    font-size: 0.72rem;
  }
}

/* ==============================================
   EXTRA SMALL SCREENS (< 480px)
   ============================================== */
@media (max-width: 480px) {
  .header-actions {
    gap: 0.35rem;
  }

  #header-driver-status {
    display: none;
  }

  /* Stepper Timeline on narrow screens */
  .timeline-stepper {
    margin: 1.25rem 0;
  }

  .timeline-stepper::before {
    top: 15px;
    left: 15px;
    right: 15px;
    height: 3px;
  }

  .step-circle {
    width: 30px;
    height: 30px;
    font-size: 0.75rem;
  }

  .step-title {
    font-size: 0.68rem;
    line-height: 1.15;
  }

  .step-time {
    font-size: 0.62rem;
  }

  /* Login card on narrow phones */
  .login-card {
    padding: 1.5rem 1.1rem;
    border-radius: var(--radius-lg);
  }

  .login-header h2 {
    font-size: 1.15rem !important;
  }

  .login-tab-btn {
    font-size: 0.78rem;
    padding: 0.5rem 0.35rem;
  }

  .trend-bar-stack {
    width: 14px;
  }
}

/* ============================================== */
/* 13. PRINT MEDIA STYLES (@media print)         */
/* ============================================== */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }

  .header-bar,
  .login-overlay,
  .btn,
  button,
  .dashboard-filter-bar,
  .toast-container,
  .modal-close,
  .modal-footer {
    display: none !important;
  }

  .main-content {
    padding: 0 !important;
  }

  .glass-card {
    background: #fff !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    color: #000 !important;
    padding: 1rem !important;
    margin-bottom: 1.5rem !important;
    page-break-inside: avoid;
  }

  .data-table {
    border-collapse: collapse;
    width: 100% !important;
    color: #000 !important;
  }

  .data-table th,
  .data-table td {
    border: 1px solid #ddd !important;
    color: #000 !important;
    padding: 8px 10px !important;
  }

  .data-table th {
    background: #f3f4f6 !important;
    color: #111827 !important;
  }

  h1, h2, h3, h4, strong {
    color: #000 !important;
  }

  .triage-tag, .badge-ems, .badge-refer {
    border: 1px solid #000 !important;
    color: #000 !important;
    background: #fff !important;
  }
}

/* ============================================== */
/* 13. PHOTO CAPTURE & LIVE CAMERA WIDGET         */
/* ============================================== */
.photo-capture-box {
  background: rgba(15, 23, 42, 0.75);
  border: 2px dashed rgba(59, 130, 246, 0.45);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  text-align: center;
  transition: var(--transition);
  margin-top: 0.6rem;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}
.photo-capture-box:hover {
  border-color: #60a5fa;
  background: rgba(15, 23, 42, 0.9);
}
.photo-capture-box.has-photo {
  border-style: solid;
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.08);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.15);
}

.pcb-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.76rem;
  font-weight: 700;
  margin-bottom: 0.65rem;
}
.photo-capture-box.has-photo .pcb-header-badge {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.35);
  color: #34d399;
}

.pcb-preview {
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.3);
  transition: var(--transition);
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.pcb-preview:hover {
  background: rgba(0, 0, 0, 0.45);
  border-color: rgba(96, 165, 250, 0.3);
}

.pcb-icon {
  font-size: 2.6rem;
  margin-bottom: 0.35rem;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,0.5));
}
.pcb-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #60a5fa;
  margin-bottom: 0.2rem;
}
.pcb-subtext {
  font-size: 0.75rem;
  color: #94a3b8;
  max-width: 90%;
  line-height: 1.4;
}

.pcb-gps-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: #93c5fd;
  background: rgba(30, 58, 138, 0.35);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 8px;
  padding: 5px 12px;
  margin: 0.75rem auto;
  max-width: 100%;
}

.pcb-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.6rem;
}

.pcb-btn-camera {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
  transition: var(--transition);
  min-height: 48px;
  width: 100%;
}
.pcb-btn-camera:hover {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.6);
  transform: translateY(-1px);
}
.pcb-btn-camera:active {
  transform: translateY(1px);
}

.photo-capture-box.has-photo .pcb-btn-camera {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.35);
}
.photo-capture-box.has-photo .pcb-btn-camera:hover {
  background: linear-gradient(135deg, #10b981, #059669);
}

.pcb-footer-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  padding: 0 4px;
}
.pcb-btn-demo {
  background: none;
  border: none;
  color: #64748b;
  font-size: 0.72rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}
.pcb-btn-demo:hover {
  color: #94a3b8;
}

/* ============================================== */
/* 14. LIVE CAMERA VIEWFINDER (FULLSCREEN & POPUP)*/
/* ============================================== */
.live-camera-container {
  width: 100%;
  max-width: 520px;
  background: #000;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px rgba(0,0,0,0.9);
  border: 1px solid rgba(255,255,255,0.15);
  position: relative;
}

@media (max-width: 640px) {
  .live-camera-container {
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
}

.live-cam-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.2rem;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(10px);
  z-index: 10;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.live-cam-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.live-cam-dot {
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  animation: liveCamPulse 1.2s infinite ease-in-out;
}

@keyframes liveCamPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.8); }
}

.live-cam-info {
  text-align: center;
}

#live-cam-clock {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  color: #f1f5f9;
}

.live-cam-close {
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  font-size: 1.5rem;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.2s;
}
.live-cam-close:hover {
  background: rgba(239, 68, 68, 0.6);
}

.live-cam-viewport {
  position: relative;
  width: 100%;
  height: 380px;
  background: #050505;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 640px) {
  .live-cam-viewport {
    flex: 1;
    height: auto;
  }
}

#live-camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.live-cam-reticle {
  position: absolute;
  top: 12%;
  left: 10%;
  right: 10%;
  bottom: 12%;
  pointer-events: none;
}

.live-cam-reticle .corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: rgba(96, 165, 250, 0.85);
  border-style: solid;
}
.live-cam-reticle .top-left { top: 0; left: 0; border-width: 3px 0 0 3px; border-top-left-radius: 6px; }
.live-cam-reticle .top-right { top: 0; right: 0; border-width: 3px 3px 0 0; border-top-right-radius: 6px; }
.live-cam-reticle .bottom-left { bottom: 0; left: 0; border-width: 0 0 3px 3px; border-bottom-left-radius: 6px; }
.live-cam-reticle .bottom-right { bottom: 0; right: 0; border-width: 0 3px 3px 0; border-bottom-right-radius: 6px; }

.live-cam-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  transform: translate(-50%, -50%);
}
.live-cam-crosshair::before, .live-cam-crosshair::after {
  content: '';
  position: absolute;
  background: rgba(255,255,255,0.4);
}
.live-cam-crosshair::before { top: 9px; left: 0; width: 20px; height: 2px; }
.live-cam-crosshair::after { top: 0; left: 9px; width: 2px; height: 20px; }

.live-cam-guide {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
}
.live-cam-guide span {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  color: #f1f5f9;
  font-size: 0.78rem;
  padding: 4px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.15);
}

.live-cam-flash {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease-out;
}
.live-cam-flash.flash-active {
  opacity: 0.92;
  transition: none;
}

.live-cam-controls {
  padding: 1.25rem 1.5rem;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: space-around;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
}

.live-cam-tool-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: #e2e8f0;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.2s;
  gap: 2px;
}
.live-cam-tool-btn:hover {
  background: rgba(255,255,255,0.18);
  transform: scale(1.05);
}

.live-cam-shutter {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: transparent;
  border: 4px solid #fff;
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(255,255,255,0.4);
  transition: 0.15s;
}
.live-cam-shutter:hover {
  transform: scale(1.06);
  box-shadow: 0 0 25px rgba(59, 130, 246, 0.6);
}
.live-cam-shutter:active {
  transform: scale(0.92);
}
.shutter-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #ef4444;
  transition: 0.15s;
}
.live-cam-shutter:hover .shutter-inner {
  background: #dc2626;
}

/* Nurse Escort Toggle Cards */
.nurse-option-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: all 0.2s ease;
}
.nurse-option-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
}
.nurse-option-card.selected.yes {
  border-color: rgba(16, 185, 129, 0.6);
  background: rgba(16, 185, 129, 0.12);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
}
.nurse-option-card.selected.no {
  border-color: rgba(239, 68, 68, 0.6);
  background: rgba(239, 68, 68, 0.12);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.15);
}

/* ==========================================
   Status Proof Photos & Evidence Badges
   ========================================== */
.mission-photo-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 3px 7px 3px 4px;
  background: rgba(30, 58, 138, 0.4);
  border: 1px solid rgba(96, 165, 250, 0.4);
  border-radius: 20px;
  font-size: 0.72rem;
  color: #93c5fd;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  text-decoration: none;
  vertical-align: middle;
}
.mission-photo-pill:hover {
  background: rgba(30, 58, 138, 0.8);
  border-color: #60a5fa;
  box-shadow: 0 0 8px rgba(96, 165, 250, 0.3);
  transform: translateY(-1px);
}
.mission-photo-pill img {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #60a5fa;
}
.mission-photo-pill.pill-green {
  background: rgba(6, 78, 59, 0.4);
  border-color: rgba(52, 211, 153, 0.4);
  color: #6ee7b7;
}
.mission-photo-pill.pill-green:hover {
  background: rgba(6, 78, 59, 0.8);
  border-color: #34d399;
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.3);
}
.mission-photo-pill.pill-green img {
  border-color: #34d399;
}

/* Timeline Modal: Stage Proof Photos Grid */
.timeline-photos-section {
  margin: 1.25rem 0 1rem 0;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
}
.timeline-photos-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #93c5fd;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.timeline-photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
}
.timeline-photo-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  transition: all 0.2s ease;
}
.timeline-photo-card.has-photo:hover {
  border-color: rgba(96, 165, 250, 0.6);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.timeline-photo-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 600;
}
.timeline-photo-card-thumb {
  width: 100%;
  height: 120px;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
}
.timeline-photo-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}
.timeline-photo-card-thumb:hover img {
  transform: scale(1.05);
}
.timeline-photo-card-thumb .zoom-icon {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
}
.timeline-photo-card-thumb.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-subtle);
  font-size: 0.78rem;
  cursor: default;
  border-style: dashed;
}
.timeline-photo-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.timeline-gps-link {
  color: #34d399;
  text-decoration: underline;
  font-size: 0.7rem;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}

/* Driver Cockpit Proof Photo Banner */
.cockpit-proof-banner {
  background: rgba(30, 58, 138, 0.3);
  border: 1px solid rgba(96, 165, 250, 0.4);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}
.cockpit-proof-banner:hover {
  background: rgba(30, 58, 138, 0.5);
  border-color: #60a5fa;
}
.cockpit-proof-thumb {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #60a5fa;
  background: #000;
}
.cockpit-proof-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Print Refer Sheet Photos Section */
.refer-sheet-photos-box {
  border: 1px solid #999;
  padding: 10px;
  margin-bottom: 14px;
  border-radius: 4px;
  background: #fafafa;
}
.refer-sheet-photos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
}
.refer-sheet-photo-item {
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 6px;
  background: #fff;
  text-align: center;
}
.refer-sheet-photo-item img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 3px;
  display: block;
}
.refer-sheet-photo-caption {
  font-size: 0.75rem;
  color: #333;
  margin-top: 4px;
  font-weight: 600;
}

/* Per-driver mission distribution, using the dashboard's filtered counts. */
.driver-pies-section { margin-bottom: 1.5rem; padding: 1.5rem; }
.driver-pies-section h3 { font-size: 1.05rem; }
.driver-pies-description { color: var(--text-muted); font-size: .85rem; margin: .5rem 0 1rem; }
.driver-pies-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 1rem; }
.driver-pie-card { min-width: 0; border: 1px solid var(--border-color, rgba(148,163,184,.25)); border-radius: 14px; padding: 1rem; break-inside: avoid; }
.driver-pie-card h4 { font-size: 1rem; overflow-wrap: anywhere; }
.driver-pie-total { color: var(--text-muted); font-size: .85rem; margin-top: .25rem; }
.driver-pie { display: block; width: 160px; max-width: 100%; margin: .75rem auto; }
.driver-pie-legend { list-style: none; padding: 0; margin: 0; font-size: .85rem; }
.driver-pie-legend li { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .25rem .5rem; margin-top: .4rem; }
.driver-pie-label { display: inline-flex; align-items: center; gap: .4rem; }
.driver-pie-swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.driver-pie-legend small { color: var(--text-muted); }
@media print {
  .driver-pies-section { page-break-inside: auto; }
  .driver-pies-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .driver-pie-card { color: #000; }
  .driver-pie, .driver-pie-swatch { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .driver-pies-description, .driver-pie-total, .driver-pie-legend small { color: #444; }
}

.driver-pie-header { display: flex; align-items: flex-start; justify-content: space-between; gap: .65rem; }
.driver-pie-heading { min-width: 0; flex: 1; }
.driver-pie-header .driver-pie-avatar { width: 56px; height: 64px; flex: 0 0 56px; border-radius: 8px; font-size: 1.8rem; }
.driver-pie-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: center top; }

.duty-roster-section { padding: 1.25rem; margin-bottom: 1.5rem; }
.duty-roster-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.duty-roster-header h3 { font-size: 1.1rem; }
#duty-roster-count { color: var(--text-muted); font-size: .85rem; }
.duty-roster-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)); gap: 1rem; }
.duty-roster-card { display: flex; align-items: flex-start; gap: .8rem; border: 1px solid var(--border-color); border-radius: 14px; padding: 1rem; box-shadow: var(--shadow-sm); }
.duty-roster-card .driver-avatar-thumb { flex-shrink: 0; width: 52px; height: 62px; }
.duty-roster-info { min-width: 0; overflow-wrap: anywhere; }
.duty-roster-info h4 { font-size: .95rem; }
.duty-roster-info p { color: var(--text-muted); font-size: .8rem; margin: .3rem 0; }
.duty-roster-info .badge { white-space: normal; }
.duty-roster-mission { border-top: 1px solid var(--border-color); padding-top: .4rem; }

.cool-radio { display: flex; align-items: center; flex-wrap: wrap; gap: .8rem 1rem; padding: .85rem 1rem; margin-bottom: 1.25rem; }
.cool-radio-heading { display: flex; align-items: center; gap: .65rem; }
.cool-radio-heading > span { font-size: 1.7rem; }
.cool-radio-heading strong { font-size: .9rem; }
.cool-radio-heading p { color: var(--text-muted); font-size: .75rem; margin-top: .2rem; }
.cool-radio audio { width: 300px; max-width: 100%; height: 40px; }
.cool-radio-link { color: var(--primary); font-size: .8rem; text-decoration: underline; }
@media (max-width: 600px) { .cool-radio audio { width: 100%; flex-basis: 100%; } }
@media print { .cool-radio { display: none !important; } }

/* GPS live map (js/gps-map.js) */
.gps-map-status { font-size: .8rem; color: var(--text-muted); }
.gps-map-wrap { position: relative; }
.gps-map-empty { position: absolute; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 500; width: max-content; max-width: calc(100% - 2rem); padding: .5rem .9rem; border-radius: 999px; background: rgba(13, 11, 26, .82); color: #fff; font-size: .8rem; text-align: center; }
.gps-marker { position: relative; padding: .2rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; color: #fff; border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .35); }
.gps-marker.gps-moving { background: #16a34a; }
.gps-marker.gps-stopped { background: #2563eb; }
.gps-marker.gps-offline { background: #6b7280; }
.gps-popup { font-family: var(--font-main); line-height: 1.6; }
.gps-popup a { display: inline-block; margin-top: .35rem; }
.gps-popup-btn { display: block; margin-top: .4rem; padding: .3rem .6rem; font-size: .8rem; }
.gps-admin h3 { margin-bottom: .4rem; }
.gps-admin h4 { font-size: .95rem; margin-bottom: .5rem; }
.gps-admin-note { color: var(--text-muted); font-size: .85rem; margin-bottom: .6rem; }
.gps-admin-traccar { font-size: .85rem; padding: .5rem .75rem; border-radius: 8px; margin-bottom: 1rem; }
.gps-admin-traccar.is-ok { background: rgba(16, 185, 129, .12); }
.gps-admin-traccar.is-error { background: rgba(245, 158, 11, .15); }
.gps-admin-unknown { border: 1px dashed var(--warning); border-radius: 10px; padding: .75rem; margin-bottom: 1rem; }
.gps-admin-unknown ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.gps-admin-unknown li { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: .85rem; }
.gps-admin-unknown li span { color: var(--text-muted); }
.gps-admin-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem; align-items: end; margin-bottom: 1rem; }
.gps-admin-form label { display: grid; gap: .3rem; font-size: .85rem; color: var(--text-muted); }
.gps-admin-form input:not([type=checkbox]), .gps-admin-form select { background: var(--bg-input); color: var(--text-main); border: 1px solid var(--border-color); border-radius: 8px; padding: .5rem .6rem; font: inherit; width: 100%; }
.gps-admin-form .gps-admin-check { display: flex; align-items: center; gap: .4rem; }
.gps-admin-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.gps-admin-row-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.gps-admin .data-table-container { overflow-x: auto; }
.gps-admin .data-table { min-width: 620px; }
.gps-admin-row-actions .btn { white-space: nowrap; }

/* GPS map page (#view-map) */
.gps-view-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: .75rem; margin-bottom: 1rem; }
.gps-view-header h2 { font-size: 1.4rem; font-weight: 700; }
.gps-view-layout { display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); gap: 1rem; align-items: start; }
.gps-side-column { display: grid; gap: 1rem; max-height: calc(100vh - 220px); overflow-y: auto; }
.gps-side { display: grid; gap: 1rem; }
.gps-side h3 { font-size: 1rem; font-weight: 600; margin-bottom: .5rem; }
.gps-vehicle-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.gps-vehicle { width: 100%; display: grid; gap: .15rem; text-align: left; padding: .6rem .75rem; border-radius: 10px; border: 1px solid var(--border-color); border-left-width: 5px; background: var(--bg-secondary); color: var(--text-main); font: inherit; cursor: pointer; }
.gps-vehicle:hover, .gps-vehicle:focus-visible { background: var(--bg-card-hover); }
.gps-vehicle span, .gps-vehicle small { color: var(--text-muted); font-size: .8rem; }
.gps-vehicle.gps-moving { border-left-color: #16a34a; }
.gps-vehicle.gps-stopped { border-left-color: #2563eb; }
.gps-vehicle.gps-offline { border-left-color: #6b7280; }
.gps-vehicle-empty { color: var(--text-muted); font-size: .85rem; }
.gps-track-panel { display: grid; gap: .5rem; font-size: .85rem; }
.gps-track-panel label { display: grid; gap: .25rem; color: var(--text-muted); }
.gps-track-panel select, .gps-track-panel input { background: var(--bg-input); color: var(--text-main); border: 1px solid var(--border-color); border-radius: 8px; padding: .45rem .6rem; font: inherit; width: 100%; }
.gps-track-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
#gps-map { height: calc(100vh - 220px); min-height: 420px; border-radius: var(--radius-lg, 12px); overflow: hidden; z-index: 0; }
#view-map:fullscreen { background: var(--bg-primary); padding: 1rem; overflow: auto; }
#view-map:fullscreen #gps-map { height: calc(100vh - 7rem); }
#view-map:fullscreen .gps-side-column { max-height: calc(100vh - 7rem); }
@media (max-width: 900px) {
  .gps-view-layout { grid-template-columns: minmax(0, 1fr); }
  .gps-map-wrap { order: -1; }
  .gps-side-column { max-height: none; }
  #gps-map { height: 60vh; min-height: 320px; }
}
@media print { #view-map { display: none !important; } }
.gps-view-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.gps-crew h3 { font-size: 1rem; font-weight: 600; margin-bottom: .25rem; }
.gps-crew-summary { color: var(--text-muted); font-size: .8rem; margin-bottom: .5rem; }
.gps-crew-toggle { display: flex; align-items: flex-start; gap: .4rem; font-size: .8rem; color: var(--text-muted); margin-bottom: .6rem; }
.gps-crew-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.gps-crew-item { width: 100%; display: grid; gap: .15rem; text-align: left; padding: .6rem .75rem; border-radius: 10px; border: 1px solid var(--border-color); border-left-width: 5px; background: var(--bg-secondary); color: var(--text-main); font: inherit; font-size: .85rem; cursor: pointer; }
.gps-crew-item:hover, .gps-crew-item:focus-visible { background: var(--bg-card-hover); }
.gps-crew-item small { color: var(--text-muted); font-size: .78rem; }
.gps-crew-mission { font-weight: 500; }
.gps-marker.gps-on-mission { border-width: 3px; }
.gps-marker-wrap { display: flex; flex-direction: column; align-items: center; gap: 1px; transform: translate(-50%, -60%); }
.gps-vehicle-icon { display: inline-block; width: 54px; height: 30px; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .35)); }
.gps-vehicle-icon svg { width: 100%; height: 100%; display: block; }
.gps-vehicle-icon.gps-flip svg { transform: scaleX(-1); }
.gps-legend { display: grid; gap: .25rem; padding: .4rem .6rem; border-radius: 8px; background: rgba(255, 255, 255, .92); color: #1f2937; font-size: .75rem; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.gps-legend span { display: flex; align-items: center; gap: .4rem; }
.gps-legend .gps-vehicle-icon { width: 30px; height: 17px; filter: none; }
.gps-marker.gps-overspeed { background: #dc2626; animation: gps-pulse 1s ease-in-out infinite alternate; }
@keyframes gps-pulse { from { box-shadow: 0 0 0 0 rgba(220, 38, 38, .6); } to { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); } }
@media (prefers-reduced-motion: reduce) { .gps-marker.gps-overspeed { animation: none; } }
.gps-vehicle.gps-overspeed { border-left-color: #dc2626; }
.gps-speed-form { border: 1px solid var(--border-color); border-radius: 10px; padding: .75rem; margin-bottom: 1rem; }
.gps-speed-form h4 { font-size: .95rem; margin-bottom: .5rem; }
.gps-speed-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-bottom: .4rem; }
.gps-speed-row label { display: flex; align-items: center; gap: .4rem; font-size: .85rem; }
.gps-speed-row input[type=number] { width: 5.5rem; background: var(--bg-input); color: var(--text-main); border: 1px solid var(--border-color); border-radius: 8px; padding: .4rem .5rem; font: inherit; }
.gps-hospital-pin { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 2px solid #0284c7; font-size: 14px; font-style: normal; line-height: 1; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); }
.gps-hospital-pin.gps-hospital-base { border-color: #16a34a; border-width: 3px; }
.gps-hospital-label { position: absolute; top: 28px; left: 13px; transform: translateX(-50%); white-space: nowrap; padding: 0 .35rem; border-radius: 6px; background: rgba(255, 255, 255, .92); color: #166534; font-size: .72rem; font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.gps-legend .gps-hospital-pin { width: 18px; height: 18px; font-size: 10px; border-width: 2px; }
.gps-hospital-pin.gps-hospital-target { margin: -3px; border-color: var(--target-color, #dc2626); border-width: 3px; width: 32px; height: 32px; font-size: 17px; animation: gps-target-pulse 1.6s ease-out infinite; }
@keyframes gps-target-pulse { from { box-shadow: 0 0 0 0 var(--target-color, #dc2626); } to { box-shadow: 0 0 0 12px transparent; } }
@media (prefers-reduced-motion: reduce) { .gps-hospital-pin.gps-hospital-target { animation: none; } }
.gps-crew-item .gps-crew-eta { color: var(--text-main); font-weight: 600; }
