:root {
    --bg-app: #f8fafc;
    --bg-card: #ffffff;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 4px 6px -1px rgb(0 0 0 / 0.05);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.08);
    --radius: 12px;
    --font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-family);
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.6;
}

.card {
    background: var(--bg-card);
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.btn {
    border-radius: var(--radius);
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-warning { background: var(--warning); color: #fff; }

.form-control, .form-select {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
    background: #fff;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    background: #fff;
}

.table { border-radius: var(--radius); overflow: hidden; }
.table thead { background: var(--primary); color: white; }
.table tbody tr:hover { background: rgba(59, 130, 246, 0.04); }
.table-hover tbody tr:hover { transform: scale(1.005); }

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { opacity: 0.95; box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

.alert-pulse { animation: pulse 2s infinite; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.5s ease forwards; }

@keyframes slideDown { from { opacity: 0; transform: translateY(-20px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.slide-down { animation: slideDown 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

@keyframes radarPulse {
    0% { transform: scale(0.95); opacity: 0.7; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.7; }
}

.radar-pulse { animation: radarPulse 2s ease-in-out infinite; }

@keyframes refreshFlash {
    0% { opacity: 0; transform: translateY(-10px); }
    20% { opacity: 1; transform: translateY(0); }
    80% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-10px); }
}

.refresh-indicator {
    position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1000;
    background: rgba(255,255,255,0.9); backdrop-filter: blur(8px);
    padding: 6px 16px; border-radius: 20px; font-size: 0.8rem; color: var(--text-muted);
    opacity: 0; pointer-events: none;
    box-shadow: var(--shadow-sm);
}
.refresh-indicator.active { animation: refreshFlash 2s ease; }

.badge { border-radius: 8px; padding: 0.35rem 0.7rem; font-weight: 600; letter-spacing: 0.02em; }

.modal-content { border-radius: var(--radius); border: none; box-shadow: var(--shadow-md); }
.modal-header { border-bottom: 1px solid var(--border); }
.modal-footer { border-top: 1px solid var(--border); }

.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 260px; background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: #e2e8f0; padding: 1.5rem 0; z-index: 1030; display: flex; flex-direction: column;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    transition: transform 0.3s ease;
}
.sidebar .brand {
    font-size: 1.3rem; font-weight: 700; color: #fff; padding: 0 1.5rem 1.5rem; display: flex; align-items: center; gap: 0.6rem;
}
.sidebar .nav-link {
    color: #94a3b8; padding: 0.85rem 1.5rem; display: flex; align-items: center; gap: 0.75rem;
    transition: all 0.2s ease; text-decoration: none; font-weight: 500; font-size: 0.95rem;
}
.sidebar .nav-link:hover, .sidebar .nav-link.active { color: #fff; background: rgba(255,255,255,0.06); border-right: 3px solid var(--primary); }
.sidebar .nav-link i { width: 20px; text-align: center; font-size: 1rem; }

.main-content { margin-left: 260px; padding: 2rem; min-height: 100vh; }

.mobile-header {
    display: none; position: fixed; top: 0; left: 0; right: 0; height: 56px; background: #0f172a;
    color: #fff; z-index: 1020; padding: 0 1rem; align-items: center; justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.mobile-header .brand { font-weight: 700; font-size: 1.1rem; }
.mobile-header .hamburger { background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; padding: 0.5rem; }

.sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1025; opacity: 0; transition: opacity 0.3s ease;
}
.sidebar-overlay.active { display: block; opacity: 1; }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); width: 260px; top: 0; bottom: 0; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 1rem; padding-top: 4rem; }
    .mobile-header { display: flex; }
    .sidebar-overlay.active { display: block; }
}

@media (max-width: 768px) {
    .sidebar { width: 100%; bottom: auto; height: auto; padding: 0.5rem; flex-direction: row; align-items: center; justify-content: space-between; overflow-x: auto; transform: translateX(-100%) !important; }
    .sidebar.open { transform: translateX(0) !important; }
    .sidebar .brand { padding: 0 0.75rem 0 0; font-size: 1rem; }
    .sidebar .nav { flex-direction: row; gap: 0.25rem; }
    .sidebar .nav-link { padding: 0.5rem 0.75rem; font-size: 0.8rem; border-right: none !important; border-bottom: 3px solid transparent; white-space: nowrap; }
    .sidebar .nav-link:hover, .sidebar .nav-link.active { border-bottom: 3px solid var(--primary); border-right: none; }
    .sidebar .mt-auto { display: none; }
    .main-content { margin-left: 0; padding: 1rem; }
}

#map { border-radius: var(--radius); z-index: 1; }

.leaflet-popup-content-wrapper { border-radius: var(--radius); box-shadow: var(--shadow-md); }

.filter-panel {
    position: absolute; top: 12px; right: 12px; z-index: 1000;
    background: rgba(255,255,255,0.85); backdrop-filter: blur(8px);
    padding: 1rem; border-radius: var(--radius); box-shadow: var(--shadow-sm);
    min-width: 220px;
}

.vehicle-card {
    background: var(--bg-card); border-radius: var(--radius); padding: 1.25rem;
    box-shadow: var(--shadow-sm); transition: all 0.3s ease; border: 1px solid transparent;
}
.vehicle-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--primary); }

.mobile-gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.mobile-card {
    background: rgba(255,255,255,0.95); backdrop-filter: blur(20px);
    border-radius: 24px; box-shadow: var(--shadow-md);
}

.tracking-active { color: var(--success); }
.tracking-active .icon { animation: radarPulse 2s ease-in-out infinite; display: inline-block; }

.alert { border-radius: var(--radius); border: none; }

.text-sm { font-size: 0.875rem; }
.fw-medium { font-weight: 500; }
.fw-semibold { font-weight: 600; }

input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: 0.6;
    cursor: pointer;
}
