/* Purple and Pink presentation layer - Modern, refined medical fleet design */
@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');

@media screen {
  :root {
    color-scheme: light;
    --font-main: 'Prompt', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Inter', 'SFMono-Regular', Consolas, Menlo, monospace;
    --bg-primary: #f8f6fc;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-card-hover: #fdf8fd;
    --bg-input: #fbf9fd;
    --border-color: #e5def0;
    --border-focus: #a855f7;
    --text-main: #1e1329;
    --text-muted: #5d4f70;
    --text-subtle: #847599;
    --primary: #9333ea;
    --primary-hover: #7e22ce;
    --primary-glow: rgba(147, 51, 234, 0.25);
    --pink: #ec4899;
    --pink-hover: #db2777;
    --pink-glow: rgba(236, 72, 153, 0.25);
    --primary-gradient: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
    --primary-gradient-hover: linear-gradient(135deg, #7c3aed 0%, #db2777 100%);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 26px;
    --shadow-sm: 0 2px 8px rgba(139, 92, 246, 0.05);
    --shadow-md: 0 8px 24px rgba(139, 92, 246, 0.08);
    --shadow-lg: 0 20px 60px rgba(139, 92, 246, 0.12);
  }
  body {
    background: radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.09) 0px, transparent 55%),
                radial-gradient(at 100% 0%, rgba(236, 72, 153, 0.08) 0px, transparent 50%),
                radial-gradient(at 50% 100%, rgba(217, 70, 239, 0.05) 0px, transparent 60%),
                var(--bg-primary);
    background-attachment: fixed;
    font-family: var(--font-main);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.01em;
  }
  body.modal-open { overflow: hidden; }
  button, input, select, textarea { font-family: var(--font-main); }
  button, a, input, select, textarea { touch-action: manipulation; }
  :focus-visible { outline: 3px solid #a855f7; outline-offset: 3px; }
  .header-bar {
    background: rgba(255, 255, 255, 0.90);
    border-bottom: 1px solid rgba(236, 72, 153, 0.16);
    backdrop-filter: saturate(180%) blur(24px);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    padding-top: max(.9rem, env(safe-area-inset-top));
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.04);
  }
  .header-container { flex-wrap: wrap; }
  .brand-text h1 { letter-spacing: -0.02em; font-family: var(--font-main); font-weight: 700; }
  .brand-badge {
    background: linear-gradient(135deg, #9333ea, #ec4899) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 8px !important;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(236, 72, 153, 0.35);
  }
  .main-content { padding-top: 2rem; }
  .glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-color: rgba(147, 51, 234, 0.12);
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-lg);
  }
  .view-switcher, .login-mode-tabs {
    background: #f0e8f6;
    border: 1px solid rgba(236, 72, 153, 0.15);
    padding: 4px;
    border-radius: 14px;
  }
  .view-btn, .login-tab-btn {
    min-height: 42px;
    color: #5d4f70;
    border-radius: 10px;
    font-family: var(--font-main);
    font-weight: 500;
    transition: all 0.2s ease;
  }
  .view-btn.active, .login-tab-btn.active {
    background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(236, 72, 153, 0.35) !important;
    font-weight: 600;
  }
  .view-btn:hover, .login-tab-btn:hover {
    background: rgba(255, 255, 255, 0.7);
    color: #7e22ce;
  }
  .active-driver-badge {
    background: #ffffff;
    border: 1px solid rgba(236, 72, 153, 0.25);
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.06);
    color: #4a385c;
  }
  .stat-card {
    padding: 1.25rem 1.4rem;
    align-items: center;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(147, 51, 234, 0.12);
    box-shadow: var(--shadow-sm);
    border-radius: 18px;
    transition: all 0.25s ease;
  }
  .stat-card:hover {
    border-color: rgba(236, 72, 153, 0.3);
    box-shadow: 0 8px 26px rgba(236, 72, 153, 0.10);
    transform: translateY(-2px);
  }
  .stat-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    font-size: 1.5rem;
  }
  .stat-info .value {
    font-family: var(--font-main);
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    margin-top: .15rem;
    color: #1e1329;
  }
  .stat-info .label {
    letter-spacing: 0;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.82rem;
  }
  .btn {
    min-height: 42px;
    border-radius: 12px;
    font-family: var(--font-main);
    font-weight: 600;
    transition: all 0.2s ease;
  }
  .btn-primary {
    background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%) !important;
    color: #ffffff !important;
    border: none !important;
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.28) !important;
  }
  .btn-primary:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #db2777 100%) !important;
    box-shadow: 0 6px 20px rgba(236, 72, 153, 0.38) !important;
    transform: translateY(-1px);
  }
  .btn-success { background: #10b981; color: #fff; }
  .btn-danger { background: #ef4444; color: #fff; }
  .btn-outline {
    background: #ffffff;
    border: 1px solid #dcd3e7;
    color: #4a3b5c;
  }
  .btn-outline:hover {
    background: #fdf7fc;
    border-color: #c084fc;
    color: #7e22ce;
  }
  .form-control, .form-select {
    background: #ffffff;
    color: #1e1329;
    border: 1px solid #dcd3e7;
    min-height: 44px;
    border-radius: 12px;
    font-family: var(--font-main);
    transition: all 0.2s ease;
  }
  .form-control::placeholder { color: #847599; opacity: 1; }
  .form-control:focus, .form-select:focus {
    background: #ffffff;
    border-color: #a855f7;
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.18);
  }
  .form-label { font-weight: 600; color: #433352; font-family: var(--font-main); }
  option { background: #fff; color: #1e1329; }
  .data-table-container {
    border: 1px solid #e5def0;
    border-radius: 16px;
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
  }
  .data-table th {
    background: #f6f1fa;
    color: #433352;
    font-weight: 600;
    font-family: var(--font-main);
  }
  .data-table td { border-color: #ede7f4; font-family: var(--font-main); }
  .data-table tbody tr:hover { background: #fdf8fc; }
  .modal-overlay, .modal { background: rgba(28, 18, 40, 0.45); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
  .modal-box, .modal-content {
    background: #ffffff;
    border: 1px solid rgba(236, 72, 153, 0.18);
    box-shadow: var(--shadow-lg);
    border-radius: 24px;
    max-height: 90dvh;
  }
  .modal-header { background: #ffffff; border-bottom: 1px solid #f0eaf6; }
  .modal-footer { background: #faf8fc; border-top: 1px solid #f0eaf6; flex-wrap: wrap; }
  .close-btn, .modal-close {
    width: 36px; height: 36px; flex-shrink: 0; border: 0; border-radius: 50%;
    background: #f3ecf8; color: #5d4f70; font-size: 1.4rem;
  }
  .close-btn:hover, .modal-close:hover { background: #ede0f4; color: #7e22ce; }
  .modal-drag-handle { background: #dcd3e7; }
  .login-overlay {
    background: radial-gradient(ellipse at 20% 10%, #f3e8ff 0, transparent 60%),
                radial-gradient(ellipse at 85% 90%, #fdf2f8 0, transparent 55%),
                #f8f6fc;
    overflow-y: auto; padding: 2rem 1rem; align-items: flex-start;
  }
  .login-card {
    max-width: 460px; margin: auto; flex-shrink: 0;
    background: rgba(255, 255, 255, 0.95);
    padding: 2.2rem;
    border: 1px solid rgba(236, 72, 153, 0.22);
    border-radius: 28px;
    box-shadow: 0 20px 70px rgba(139, 92, 246, 0.12);
  }
  .login-header h2 { color: #1e1329 !important; letter-spacing: -0.02em !important; font-family: var(--font-main); }
  .login-header > div > div { background: #fff !important; box-shadow: 0 6px 22px rgba(147, 51, 234, 0.12) !important; }
  .login-help { font-size: .8rem; color: var(--text-muted); margin-top: 6px; }
  .login-tab-btn { font-size: .85rem; white-space: nowrap; gap: .25rem; }
  .pin-btn { background: #f7f3fb; color: #1e1329; border: 0; border-radius: 18px; box-shadow: none; font-family: var(--font-main); font-weight: 600; }
  .pin-btn:hover { background: #fdf2f8; color: #7e22ce; }
  .pin-dot { background: #e5def0; border-color: #d1c5e2; }
  .pin-dot.filled {
    background: linear-gradient(135deg, #8b5cf6, #ec4899);
    border-color: #ec4899;
    box-shadow: 0 0 10px rgba(236, 72, 153, 0.4);
  }
  .photo-capture-box { background: #faf6fc; border-color: #c084fc; box-shadow: none; }
  .photo-capture-box:hover { background: #fdf4ff; }
  .pcb-preview { background: #f7f2fa; border-color: #d1c5e2; }
  .pcb-preview:hover { background: #fdf2f8; }
  .pcb-title, .pcb-gps-badge, .gps-tag-link { color: #7e22ce; }
  .pcb-subtext { color: #5d4f70; }
  .pcb-icon { filter: none; }
  .pcb-gps-badge { background: #f5f0fa; }
  .mobile-bottom-nav {
    background: rgba(255, 255, 255, 0.92);
    border-top: 1px solid rgba(236, 72, 153, 0.15);
    backdrop-filter: saturate(180%) blur(24px);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    box-shadow: 0 -3px 20px rgba(139, 92, 246, 0.05);
  }
  .mobile-nav-item { color: #5d4f70; font-family: var(--font-main); font-size: 0.78rem; }
  .mobile-nav-item.active { color: #9333ea; background: transparent; font-weight: 600; }
  .mobile-nav-item.active .mob-nav-icon { background: #f5f0fa; border-radius: 12px; }
  /* Inline color adaptations */
  [style*="color: #fff"], [style*="color:#fff"], [style*="color: #f1f5f9"], [style*="color: #e2e8f0"], [style*="color: #cbd5e1"] { color: #1e1329 !important; }
  [style*="color: #93c5fd"], [style*="color:#93c5fd"], [style*="color: #60a5fa"], [style*="color:#60a5fa"], [style*="color: #38bdf8"], [style*="color: #7dd3fc"] { color: #7e22ce !important; }
  [style*="color: #34d399"], [style*="color:#34d399"], [style*="color: #6ee7b7"] { color: #059669 !important; }
  [style*="color: #fbbf24"], [style*="color:#fbbf24"], [style*="color: #fcd34d"] { color: #d97706 !important; }
  [style*="color: #f87171"], [style*="color:#f87171"], [style*="color: #fca5a5"] { color: #dc2626 !important; }
  [style*="color: #a78bfa"], [style*="color: #c4b5fd"] { color: #9333ea !important; }
  [style*="background: rgba(15, 23, 42"], [style*="background: rgba(0,0,0"], [style*="background: rgba(0, 0, 0"], [style*="background: #0f172a"], [style*="background: #111e33"] { background: #f7f3fb !important; }
  [style*="background: rgba(30, 58, 138"] { background: #fdf4ff !important; border-color: #f0abfc !important; }
  .btn-primary, .btn-success, .btn-danger, .pcb-btn-camera { color: #fff !important; }
  #modal-live-camera { background: rgba(18, 10, 28, 0.96) !important; color: #fff; }
  #modal-live-camera [style*="color: #fff"] { color: #fff !important; }
  ::-webkit-scrollbar-thumb { background: #d8cde3; }
}
@media screen and (max-width: 767px) {
  .main-content { padding: 1.1rem 1rem calc(100px + env(safe-area-inset-bottom)); }
  .header-bar { padding-inline: 1rem; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
  .stat-card { flex-direction: column; padding: 1rem; gap: .7rem; }
  .stat-info .value { font-size: 1.7rem; }
  .login-card { padding: 1.6rem 1.15rem; border-radius: 26px; }
  .login-tab-btn { padding-inline: .3rem; font-size: .72rem; }
  .form-control, .form-select, input, select, textarea { font-size: 16px; }
  .modal-box, .modal-content { border-radius: 26px 26px 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); }
  .modal-header, .modal-body { padding: 1.1rem; }
  .mobile-bottom-nav { padding-bottom: max(.45rem, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media screen {
  .brand-badge { background: #f3e5f5 !important; color: #751d8c; }
  .status-off-duty, .pcb-subtext { color: #49494f; }
  .status-on-duty, .triage-green { color: #137b45; }
  .status-en-route, .triage-yellow { color: #915100; }
  .triage-red { color: #bf2420; }
  .triage-pink { color: #b02167; }
  [style*="color: #f8fafc"], [style*="color:#f8fafc"] { color: #30303a !important; }
  [style*="color: #94a3b8"], [style*="color:#94a3b8"], [style*="color: #9ca3af"] { color: #49494f !important; }
  .checkbox-group { background: #f3f3f4; }
  .mobile-menu-btn { background: #e9e9ef; color: #1c1c1e; }
}
@media screen and (max-width: 767px) {
  .mobile-bottom-nav { height: calc(62px + env(safe-area-inset-bottom)); }
}
@media screen {
  .vehicle-specs, .timeline-photos-section { background: #f3f3f4; }
  .dispatch-driver-card { background: #fff; border-color: var(--border-color); box-shadow: var(--shadow-sm); }
  .dispatch-driver-card:hover { background: #faf5fc; box-shadow: var(--shadow-md); }
  .dispatch-driver-name { color: #1c1c1e; }
  .vehicle-live-photo-box, .vehicle-live-photo-box:hover { background: #f0f8f4; border-color: #c9e4d5; box-shadow: none; }
  .vehicle-live-photo-title { color: #137b45; }
  .vehicle-live-photo-hint, .dispatch-driver-phone-btn, .timeline-photos-title { color: #751d8c; }
  .badge-ready, .status-badge-onduty { color: #137b45; background: #e9f6ee; }
  .badge-en_route, .status-badge-onmission { color: #915100; background: #fff3df; }
  .badge-on_duty { color: #751d8c; background: #f3e5f5; }
  .badge-maintenance { color: #bf2420; background: #ffedec; }
  .mission-photo-pill, .mission-photo-pill:hover { background: #f3e5f5; color: #751d8c; }
  .mission-photo-pill.pill-green, .mission-photo-pill.pill-green:hover { background: #e9f6ee; color: #137b45; }
  .vehicle-live-photo-thumb-wrap { background: #e2e9e6; box-shadow: none; }
  .fleet-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
}
/* Saving feedback remains visible above every dialog, including the camera. */
.toast-container { z-index: 20000; max-width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toast { white-space: normal; overflow-wrap: anywhere; }
.form-feedback { padding: 12px 14px; margin: 12px 0; border: 1px solid #f0b7b3; border-radius: 12px; background: #fff0ee; color: #9d241e; font-size: .9rem; line-height: 1.6; overflow-wrap: anywhere; }
.form-feedback[hidden] { display: none; }
button:disabled { cursor: wait; opacity: .6; }
@media (max-width: 767px) { .toast-container { bottom: calc(80px + env(safe-area-inset-bottom)); right: 16px; } }

/* Responsive layout: keep navigation, content and dialogs within the viewport. */
@media screen {
  .header-container > *, .header-actions, .brand-text,
  .cockpit-grid > *, .stat-grid > *, .fleet-grid > *,
  .form-group, .modal-body { min-width: 0; }
  .header-actions { flex-wrap: wrap; justify-content: flex-end; gap: .5rem; }
  .brand-text h1 { flex-wrap: wrap; }
  .btn { white-space: normal; overflow-wrap: anywhere; }
  .form-control, .form-select { max-width: 100%; }
  .data-table-container { max-width: 100%; }
  .dashboard-filter-bar, .filter-group, .filter-pill-group { min-width: 0; max-width: 100%; }
  .filter-pill-group { flex-wrap: wrap; }
  .modal-header, .modal-footer { flex-shrink: 0; }
  .modal-header { gap: .75rem; }
  .modal-header h3 { overflow-wrap: anywhere; }
  .modal-box > form, .modal-content > form {
    display: flex; flex-direction: column; min-height: 0; overflow-y: auto;
  }
  .login-overlay { padding-bottom: max(1.5rem, env(safe-area-inset-bottom)); }
  .login-mode-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .login-tab-btn { white-space: normal; line-height: 1.5; }
  .admin-navigation .btn { flex: 0 1 auto; }
}
@media screen and (min-width: 1025px) {
  .header-container { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .75rem 1.5rem; }
  .header-actions { grid-column: 2; grid-row: 1; }
  .header-bar .view-switcher { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .view-switcher .view-btn { flex: 1; justify-content: center; }
  .cockpit-grid { grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); }
}
@media screen and (max-width: 1024px) {
  .header-bar .view-switcher {
    background: #f8f9fc; border-radius: 0 0 18px 18px;
    box-shadow: 0 12px 24px rgba(28,28,30,.12);
    max-height: 70dvh; overflow-y: auto;
  }
  .modal-box, .modal-content { max-height: 90dvh !important; }
}
@media screen and (max-width: 767px) {
  .header-container { gap: .65rem; }
  .header-container > :first-child { flex: 1 1 220px; }
  .header-actions { margin-left: auto; }
  .main-content { padding-inline: .75rem; }
  .glass-card { padding: 1rem; }
  .login-card { padding: 1.35rem 1rem; }
  .admin-navigation { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .admin-navigation .btn { justify-content: flex-start; text-align: left; font-size: .8rem; }
  #view-driver > .glass-card > :first-child { flex-wrap: wrap; width: 100%; }
  #driver-selector { min-width: 0 !important; width: 100% !important; }
  #shift-info-box > div { gap: .75rem; flex-wrap: wrap; }
  #archive-search, #admin-missions-search { width: 100% !important; }
  .modal-box, .modal-content { max-height: 92dvh !important; }
}

/* Driver portraits: a lightly raised square frame, with the whole photo visible. */
@media screen {
  .driver-avatar, .driver-avatar-thumb, .driver-avatar-lg,
  .driver-avatar-fleet, .dispatch-driver-photo, .photo-preview-circle {
    box-sizing: border-box;
    padding: 3px;
    border-width: 1px;
    border-style: solid;
    border-color: #cdd8e6;
    border-radius: 9px;
    background: linear-gradient(145deg, #ffffff, #e8eef6);
    box-shadow: 0 3px 7px rgba(32, 55, 85, .12),
                0 1px 2px rgba(32, 55, 85, .08),
                inset 0 1px 0 rgba(255, 255, 255, .95);
    flex-shrink: 0;
  }
  .driver-avatar img, .driver-avatar-thumb img, .driver-avatar-lg img,
  .driver-avatar-fleet img, .dispatch-driver-photo img, .photo-preview-circle img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    border-radius: 0;
    background: #f7f9fc;
  }
  .driver-avatar, .driver-avatar-lg { width: 72px; height: 72px; min-width: 72px; }
  .driver-avatar-thumb { width: 40px; height: 40px; min-width: 40px; padding: 2px; border-radius: 7px; }
  .driver-avatar-fleet { width: 52px; height: 52px; min-width: 52px; border-color: #85bca1; }
  .dispatch-driver-photo { width: 64px; height: 64px; min-width: 64px; }
  .photo-preview-circle { width: 80px; height: 80px; min-width: 80px; }
  .dispatch-driver-card.on-duty .dispatch-driver-photo { border-color: #85bca1; }
  .dispatch-driver-card.on-mission .dispatch-driver-photo { border-color: #d5b077; }
  .dispatch-driver-card.standby .dispatch-driver-photo { border-color: #cdd8e6; }
  .dispatch-driver-card.on-duty .dispatch-driver-photo,
  .dispatch-driver-card.on-mission .dispatch-driver-photo {
    box-shadow: 0 3px 7px rgba(32, 55, 85, .12),
                0 1px 2px rgba(32, 55, 85, .08),
                inset 0 1px 0 rgba(255, 255, 255, .95);
  }
  .driver-avatar-fleet.inactive { background: #eef1f5; border-color: #dce2ea; box-shadow: none; }
  .driver-avatar-fleet:hover { transform: none; box-shadow: 0 4px 10px rgba(32, 55, 85, .18); }
  .driver-avatar-fleet.inactive:hover { box-shadow: none; }
  .driver-profile-header > :last-child { min-width: 0; overflow-wrap: anywhere; }
}
@media screen and (max-width: 767px) {
  .driver-avatar, .driver-avatar-lg { width: 64px; height: 64px; min-width: 64px; }
  .dispatch-driver-photo { width: 60px; height: 60px; min-width: 60px; }
  .photo-upload-box { flex-wrap: wrap; }
  .photo-upload-box > :last-child { min-width: 0; max-width: 100%; }
}

.vehicle-directory-name, .vehicle-admin-actions { display: flex; align-items: center; gap: .6rem; }
.vehicle-admin-actions { flex-wrap: wrap; }
.vehicle-photo-thumb, .vehicle-photo-card { padding: 3px; border: 1px solid #d7e0eb; border-radius: 10px; background: #f3f6fa; cursor: pointer; overflow: hidden; }
.vehicle-photo-thumb { width: 76px; height: 56px; flex-shrink: 0; }
.vehicle-photo-card { display: block; width: 100%; height: 160px; margin-bottom: 1rem; }
.vehicle-photo-thumb img, .vehicle-photo-card img { width: 100%; height: 100%; display: block; object-fit: contain; }
.vehicle-photo-editor { display: grid; gap: .6rem; margin-bottom: 1.25rem; }
.vehicle-photo-editor img { width: 100%; height: 160px; object-fit: contain; border: 1px solid #d7e0eb; border-radius: 12px; background: #f3f6fa; }
.vehicle-photo-editor img[hidden] { display: none; }
.vehicle-photo-editor .btn { justify-self: start; }

/* Active dispatch cards: a moving border, without obscuring card controls. */
@property --fleet-light-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}
@keyframes fleet-edge-travel { to { --fleet-light-angle: 360deg; } }
@keyframes fleet-status-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(204, 100, 0, .3); }
  50% { opacity: .55; box-shadow: 0 0 0 5px rgba(204, 100, 0, 0); }
}
@media screen {
  .vehicle-card.fleet-operating { position: relative; border-left-color: #d17b0d; }
  .vehicle-card.fleet-operating::before {
    content: ''; position: absolute; inset: 0; padding: 3px; border-radius: inherit;
    background: conic-gradient(from var(--fleet-light-angle), #f0cf97 0deg, #f0cf97 235deg, #ed970e 275deg, #ff0000 315deg, #f0cf97 360deg);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    pointer-events: none;
    animation: fleet-edge-travel 4s linear infinite;
  }
  .fleet-operation-badge { display: inline-flex; align-items: center; gap: 6px; white-space: normal; background: #fff2db; color: #8a4b05; max-width: 160px; }
  .fleet-operation-dot { width: 8px; height: 8px; border-radius: 50%; background: #bd6200; flex-shrink: 0; animation: fleet-status-pulse 2.4s ease-in-out infinite; }
}
@media (prefers-reduced-motion: reduce) {
  .vehicle-card.fleet-operating::before, .fleet-operation-dot { animation: none !important; }
}

.fleet-shared-drivers { margin-top: .8rem; padding: .65rem; border-radius: 10px; background: #f3e5f5; color: #641978; font-size: .8rem; overflow-wrap: anywhere; }

/* Keep long coordinates, names and vehicle details inside their cards. */
@media screen {
  .vehicle-card { min-width: 0; overflow-wrap: anywhere; }
  .vehicle-header { flex-wrap: wrap; gap: .5rem; }
  .vehicle-header > div { flex: 1 1 140px; min-width: 0; }
  .vehicle-header .badge { max-width: 100%; white-space: normal; }
  .vehicle-specs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .spec-item, .vehicle-driver > *, .vehicle-live-photo-meta > * { min-width: 0; max-width: 100%; }
  .vehicle-live-photo-box { flex-wrap: wrap; }
  .vehicle-live-photo-info { flex: 1 1 150px; }
  .vehicle-live-photo-title { white-space: normal; overflow: visible; text-overflow: clip; }
  .vehicle-live-photo-meta { align-items: flex-start; }
  .vehicle-live-photo-meta > span { overflow-wrap: anywhere; }
}

/* Prominent, full-width phone request action for touch screens. */
/* Prominent, full-width phone request action for touch screens. */
.btn.phone-dispatch-cta {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 72px;
  padding: 16px 20px; border: none; border-radius: 18px;
  background: linear-gradient(135deg, #9333ea 0%, #ec4899 100%); color: #fff;
  box-shadow: 0 8px 24px rgba(147, 51, 234, .28), 0 2px 6px rgba(236, 72, 153, .2);
  white-space: normal; text-align: left; cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.phone-dispatch-icon { width: 32px; height: 32px; flex-shrink: 0; }
.phone-dispatch-copy { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.phone-dispatch-copy strong { font-size: 1.05rem; font-weight: 600; line-height: 1.4; color: #fff; }
.phone-dispatch-copy small { font-size: 0.85rem; font-weight: 400; line-height: 1.4; color: rgba(255, 255, 255, 0.9); }
.phone-dispatch-arrow { font-size: 26px; line-height: 1; color: #fff; }
.btn.phone-dispatch-cta:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(147, 51, 234, .38); color: #fff; }
.btn.phone-dispatch-cta:active { transform: translateY(1px); box-shadow: 0 4px 12px rgba(147, 51, 234, .25); }
.btn.phone-dispatch-cta:focus-visible { outline: 3px solid #ec4899; outline-offset: 4px; }

/* Clean, crisp typography and modern boundaries */
@media screen {
  html { font-size: 16px; }
  body { line-height: 1.55; }
  .header-bar, .mobile-bottom-nav { background: rgba(255, 255, 255, 0.92); }
  .glass-card { border-color: rgba(226, 217, 243, 0.9); }
  .brand-icon { background: linear-gradient(135deg, #9333ea, #ec4899); box-shadow: 0 4px 14px rgba(236, 72, 153, 0.3); }
  .brand-text h1, .login-header h2 { letter-spacing: -0.01em; }
  .view-btn.active, .login-tab-btn.active { 
    background: linear-gradient(135deg, #9333ea, #ec4899); 
    color: #fff; 
    box-shadow: 0 4px 14px rgba(147, 51, 234, 0.28); 
  }
  .view-btn, .login-tab-btn, .btn, .filter-pill, .pcb-btn-camera { min-height: 44px; font-size: 0.92rem; }
  .btn-outline { border-color: #d1c4e9; color: #6b21a8; }
  .btn-outline:hover { background: #faf5ff; border-color: #9333ea; }
  .form-control, .form-select { min-height: 46px; font-size: 0.95rem; border-color: #dcd6e8; background: #fff; border-radius: 12px; }
  .form-control:focus, .form-select:focus { border-color: #9333ea; box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.15); }
  .form-label { font-size: 0.92rem; font-weight: 500; color: #3b2a50; margin-bottom: 6px; }
  .form-control:disabled, .form-select:disabled { background: #f5f2fa; color: #7e738c; }
  input[type="checkbox"], input[type="radio"] { accent-color: #9333ea; width: 18px; height: 18px; }
  .close-btn, .modal-close, .mobile-menu-btn { min-width: 44px; min-height: 44px; }
  .data-table th, .data-table td { font-size: 0.88rem; padding: 0.75rem 0.9rem; }
  .data-table th { background: #fbf9fd; color: #4a3861; font-weight: 600; border-bottom: 2px solid #ede7f6; }
  .data-table td { border-color: #f3eef8; }
  .badge { font-size: 0.8rem; font-weight: 500; }
  .mobile-bottom-nav { height: auto; min-height: 68px; }
  .mobile-nav-item { min-height: 52px; line-height: 1.35; font-size: 0.8rem; }
  .pcb-btn-camera { 
    background: linear-gradient(135deg, #9333ea, #ec4899); 
    box-shadow: 0 4px 14px rgba(236, 72, 153, 0.35); 
    color: #fff;
  }
  .pcb-btn-camera:hover { opacity: 0.95; transform: translateY(-1px); }
  .btn.phone-dispatch-cta { 
    background: linear-gradient(135deg, #9333ea, #ec4899); 
    border: none; 
    box-shadow: 0 8px 24px rgba(147, 51, 234, .25); 
  }
  .mission-type-card { border: 1.5px solid #e5daf5; background: #fff; border-radius: 16px; transition: all 0.2s ease; }
  .mission-type-card .mtc-title { color: #2c1a40; font-weight: 600; line-height: 1.4; }
  .mission-type-card.selected[data-type] { 
    border-color: #9333ea; 
    background: #faf5ff; 
    box-shadow: 0 4px 16px rgba(147, 51, 234, 0.12), inset 0 0 0 1px #9333ea; 
  }
  .mission-type-card:focus-within { outline: 3px solid rgba(147, 51, 234, 0.4); outline-offset: 2px; }
  .filter-pill { color: #594770; border-color: #e2d9f3; font-weight: 500; border-radius: 20px; }
  .filter-pill.active { 
    background: linear-gradient(135deg, #9333ea, #ec4899); 
    color: #fff; 
    border-color: transparent; 
    box-shadow: 0 3px 10px rgba(147, 51, 234, 0.25);
  }
  .badge-refer, .badge-mobile { color: #7e22ce; background: #faf5ff; border: 1px solid #e9d5ff; }
  .badge-ems { color: #c2410c; background: #fff7ed; border: 1px solid #ffedd5; }
  .badge-staff { color: #0284c7; background: #f0f9ff; border: 1px solid #e0f2fe; }
  .badge-lab { color: #059669; background: #ecfdf5; border: 1px solid #d1fae5; }
  .badge-on_duty { color: #059669; background: #ecfdf5; border: 1px solid #a7f3d0; }
  .badge-on_mission { color: #d97706; background: #fffbeb; border: 1px solid #fde68a; }
  .badge-ready { color: #4f46e5; background: #eef2ff; border: 1px solid #c7d2fe; }
  .badge-maintenance { color: #dc2626; background: #fef2f2; border: 1px solid #fecaca; }
}

@media screen and (max-width: 767px) {
  .login-card { max-width: 100%; }
  .login-tab-btn { font-size: 0.85rem; }
  .admin-navigation .btn { font-size: 0.88rem; }
  .mission-type-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main-content { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
}

@media screen {
  input.form-control, select.form-select, textarea.form-control { font-size: 0.95rem !important; }
  #form-phone-dispatch .btn[type="submit"] { 
    background: linear-gradient(135deg, #9333ea, #ec4899); 
    color: #fff; 
    border: none;
    box-shadow: 0 4px 14px rgba(147, 51, 234, 0.3);
  }
  #form-phone-dispatch .btn[type="submit"]:hover { 
    opacity: 0.95;
    box-shadow: 0 6px 18px rgba(147, 51, 234, 0.4);
  }
}
@media screen and (max-width: 767px) {
  .modal-body form .modal-footer { position: static; flex-wrap: wrap; }
  .modal-footer .btn { flex: 1 1 100%; width: 100%; }
}


/* Slow status pulse keeps the label readable throughout the animation. */
@keyframes mission-badge-blink {
  0%, 100% { background-color: #f3e5f5; box-shadow: 0 0 0 0 rgba(142, 36, 170, 0); }
  50% { background-color: #dfb9e8; box-shadow: 0 0 0 3px rgba(142, 36, 170, .3); }
}
@media screen {
  .fleet-operation-badge, .status-badge-mission, .mission-status-active {
    color: #58166a !important;
    background-color: #f3e5f5;
    animation: mission-badge-blink 2s ease-in-out infinite;
  }
}
@media (prefers-reduced-motion: reduce) {
  .fleet-operation-badge, .status-badge-mission, .mission-status-active { animation: none !important; }
}
