* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #0f172a;
    --bg-light: #1e293b;
    --card: #1e293b;
    --card-hover: #334155;
    --text: #f1f5f9;
    --text-light: #94a3b8;
    --border: #334155;
    --sidebar-bg: #0f172a;
    --input-bg: #0f172a;
    --glow: rgba(99, 102, 241, 0.3);
}

body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
.page { display: none; }
.page.active { display: block; }

/* LOGIN */
.login-container {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: var(--bg); position: relative; overflow: hidden;
}
.login-bg-shapes { position: absolute; inset: 0; pointer-events: none; }
.shape {
    position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.15;
}
.shape-1 { width: 400px; height: 400px; background: var(--primary); top: -100px; right: -100px; }
.shape-2 { width: 300px; height: 300px; background: #06b6d4; bottom: -50px; left: -50px; }
.shape-3 { width: 250px; height: 250px; background: #8b5cf6; top: 50%; left: 50%; transform: translate(-50%, -50%); }

.login-card {
    background: var(--card); border-radius: 24px; padding: 48px; width: 100%; max-width: 440px;
    box-shadow: 0 0 60px rgba(99,102,241,0.08); border: 1px solid var(--border);
    position: relative; z-index: 1; backdrop-filter: blur(20px);
}
.login-header { text-align: center; margin-bottom: 36px; }
.logo-icon {
    width: 72px; height: 72px; border-radius: 20px; margin: 0 auto 20px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 32px var(--glow);
}
.logo-icon i { font-size: 32px; color: white; }
.login-header h1 { font-size: 32px; font-weight: 800; background: linear-gradient(135deg, var(--primary-light), #c084fc); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.login-header p { color: var(--text-light); font-size: 14px; margin-top: 4px; }

/* FORMS */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-light); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input, .form-group select {
    width: 100%; padding: 12px 16px; background: var(--input-bg); border: 1px solid var(--border);
    border-radius: 12px; font-size: 14px; color: var(--text); font-family: inherit; transition: all 0.3s;
}
.form-group input:focus, .form-group select:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--glow);
}
.form-group input::placeholder { color: #475569; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row .full-width { grid-column: 1 / -1; }
.form-card { background: var(--card); border-radius: 16px; padding: 32px; border: 1px solid var(--border); }
.form-section-title {
    font-size: 14px; font-weight: 700; color: var(--primary-light); margin: 24px 0 16px;
    padding-bottom: 8px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px;
}
.form-section-title:first-child { margin-top: 0; }

/* BUTTONS */
.btn {
    display: inline-flex; align-items: center; gap: 8px; padding: 11px 22px;
    border: none; border-radius: 12px; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.3s; font-family: inherit;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), #8b5cf6); color: white; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 24px var(--glow); }
.btn-glow { box-shadow: 0 4px 16px var(--glow); }
.btn-glow:hover { box-shadow: 0 8px 32px var(--glow); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-full { width: 100%; justify-content: center; padding: 14px; }
.btn-sm { padding: 7px 14px; font-size: 12px; border-radius: 8px; }
.btn-logout { background: transparent; color: var(--text-light); border: 1px solid var(--border); width: 100%; justify-content: center; border-radius: 10px; padding: 10px; margin-top: 8px; }
.btn-logout:hover { background: rgba(239,68,68,0.1); color: var(--danger); border-color: var(--danger); }

/* DASHBOARD */
#dashboard-page { display: none; min-height: 100vh; }
#dashboard-page.active { display: flex; }

/* SIDEBAR */
.sidebar {
    width: 260px; background: var(--sidebar-bg); display: flex; flex-direction: column;
    position: fixed; height: 100vh; z-index: 100; border-right: 1px solid var(--border);
}
.sidebar-header { padding: 24px; display: flex; align-items: center; gap: 14px; }
.sidebar-logo {
    width: 40px; height: 40px; border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 12px var(--glow);
}
.sidebar-logo i { color: white; font-size: 18px; }
.sidebar-brand { font-size: 22px; font-weight: 800; background: linear-gradient(135deg, var(--primary-light), #c084fc); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.sidebar-menu { list-style: none; padding: 8px 12px; flex: 1; }
.sidebar-menu li {
    padding: 12px 16px; display: flex; align-items: center; gap: 12px; cursor: pointer;
    transition: all 0.2s; font-size: 14px; border-radius: 10px; margin-bottom: 4px; color: var(--text-light);
}
.sidebar-menu li:hover { background: var(--card-hover); color: var(--text); }
.sidebar-menu li.active { background: linear-gradient(135deg, var(--primary), #8b5cf6); color: white; box-shadow: 0 4px 12px var(--glow); }
.sidebar-menu li i { width: 20px; text-align: center; font-size: 15px; }
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }
.admin-badge { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-light); padding: 8px; }
.admin-badge i { color: var(--primary-light); }

/* MAIN CONTENT */
.main-content { margin-left: 260px; flex: 1; min-height: 100vh; }
.top-bar {
    background: var(--bg-light); padding: 16px 32px; display: flex; align-items: center;
    justify-content: space-between; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50; backdrop-filter: blur(12px);
}
.top-bar-left { display: flex; align-items: center; gap: 16px; }
.top-bar h2 { font-size: 20px; font-weight: 700; }
.mobile-menu-btn { display: none; background: none; border: none; color: var(--text); font-size: 20px; cursor: pointer; }
.top-bar-right { display: flex; align-items: center; gap: 16px; }
.admin-info { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-light); }

/* SECTIONS */
.section { display: none; padding: 32px; }
.section.active { display: block; }
.section-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.section-header h3 { font-size: 22px; font-weight: 700; }
.section-subtitle { font-size: 13px; color: var(--text-light); margin-top: 4px; }

/* STATS */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 28px; }
.stat-card {
    background: var(--card); border-radius: 16px; padding: 24px; display: flex;
    align-items: center; gap: 20px; border: 1px solid var(--border); transition: all 0.3s;
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--primary); }
.stat-icon { width: 56px; height: 56px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.stat-blue .stat-icon { background: rgba(99,102,241,0.15); color: var(--primary-light); }
.stat-green .stat-icon { background: rgba(16,185,129,0.15); color: var(--success); }
.stat-amber .stat-icon { background: rgba(245,158,11,0.15); color: var(--warning); }
.stat-purple .stat-icon { background: rgba(168,85,247,0.15); color: #a855f7; }
.stat-number { display: block; font-size: 28px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 13px; color: var(--text-light); margin-top: 4px; display: block; }

/* CARDS */
.card { background: var(--card); border-radius: 16px; border: 1px solid var(--border); overflow: hidden; }
.card-header { padding: 20px 24px; border-bottom: 1px solid var(--border); }
.card-header h3 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.card-header h3 i { color: var(--primary-light); }
.card-body { padding: 20px 24px; }
.empty-text { color: var(--text-light); font-size: 13px; }

/* TABLE */
.table-container { background: var(--card); border-radius: 16px; overflow: hidden; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 18px; text-align: left; font-size: 13px; }
th { background: var(--bg); font-weight: 600; color: var(--text-light); text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; }
td { border-top: 1px solid var(--border); }
tr:hover td { background: var(--card-hover); }
.status-badge { padding: 5px 12px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.status-active { background: rgba(16,185,129,0.15); color: var(--success); }
.status-inactive { background: rgba(239,68,68,0.15); color: var(--danger); }

/* ERROR & TOAST */
.error-message { color: var(--danger); font-size: 13px; margin-top: 12px; text-align: center; min-height: 20px; }
.toast {
    position: fixed; top: 24px; right: 24px; padding: 14px 24px; border-radius: 12px;
    color: white; font-size: 14px; z-index: 9999; animation: slideIn 0.3s ease;
    backdrop-filter: blur(12px); box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.toast-success { background: rgba(16,185,129,0.9); }
.toast-error { background: rgba(239,68,68,0.9); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* SIDEBAR OVERLAY (mobile) */
.sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    z-index: 99; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    opacity: 0; transition: opacity 0.3s;
}
.sidebar-overlay.active { display: block; opacity: 1; }

/* TABLE RESPONSIVE WRAPPER */
.table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ===== RESPONSIVE ===== */

/* Large tablets & small desktops */
@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
}

/* Tablets (portrait) & car monitors */
@media (max-width: 1024px) {
    .sidebar {
        width: 260px; transform: translateX(-100%); transition: transform 0.3s ease;
        box-shadow: none;
    }
    .sidebar.sidebar-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.4);
    }
    .main-content { margin-left: 0; }
    .mobile-menu-btn { display: block; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
    .top-bar { padding: 14px 20px; }
    .section { padding: 20px; }
    .section-header { flex-direction: column; gap: 12px; }
    .section-header .btn { align-self: flex-start; }
    th, td { padding: 12px 14px; font-size: 12px; }
}

/* Large phones (landscape) & small tablets */
@media (max-width: 768px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .stat-card { padding: 16px; gap: 14px; }
    .stat-icon { width: 44px; height: 44px; font-size: 18px; }
    .stat-number { font-size: 22px; }
    .stat-label { font-size: 12px; }
    .form-row { grid-template-columns: 1fr; gap: 12px; }
    .form-card { padding: 20px; }
    .form-section-title { font-size: 13px; margin: 18px 0 12px; }
    .login-card { padding: 32px 24px; margin: 16px; max-width: 100%; }
    .login-header h1 { font-size: 26px; }
    .logo-icon { width: 60px; height: 60px; border-radius: 16px; }
    .logo-icon i { font-size: 26px; }
    .top-bar h2 { font-size: 17px; }
    .section { padding: 16px; }
    .section-header h3 { font-size: 18px; }
    .card-header { padding: 14px 18px; }
    .card-body { padding: 14px 18px; }
    /* Table: min-width so it scrolls horizontally */
    table { min-width: 600px; }
    th, td { padding: 10px 12px; font-size: 12px; white-space: nowrap; }
    /* Bigger touch targets */
    .btn { padding: 12px 20px; font-size: 14px; min-height: 44px; }
    .btn-sm { padding: 9px 16px; font-size: 12px; min-height: 38px; }
    .form-group input, .form-group select { padding: 14px 16px; font-size: 15px; min-height: 48px; }
    .sidebar-menu li { padding: 14px 16px; font-size: 15px; }
}

/* Small phones (portrait) */
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; gap: 10px; }
    .stat-card { padding: 14px 16px; }
    .login-card { padding: 28px 20px; margin: 12px; border-radius: 20px; }
    .login-header h1 { font-size: 24px; }
    .login-header p { font-size: 13px; }
    .top-bar { padding: 10px 14px; }
    .top-bar h2 { font-size: 16px; }
    .section { padding: 12px; }
    .section-header h3 { font-size: 16px; }
    .form-card { padding: 16px; border-radius: 12px; }
    .table-container { border-radius: 12px; }
    .toast { left: 12px; right: 12px; top: 12px; text-align: center; }
    .admin-info span { display: none; }
}

/* Very small screens (old phones, tiny car screens) */
@media (max-width: 360px) {
    .login-card { padding: 24px 16px; margin: 8px; }
    .login-header h1 { font-size: 22px; }
    .logo-icon { width: 52px; height: 52px; }
    .section { padding: 10px; }
    .sidebar { width: 240px; }
}

/* Landscape mode (car monitors, phones in landscape) */
@media (max-height: 500px) and (orientation: landscape) {
    .login-container { padding: 12px; }
    .login-card { padding: 20px 24px; max-width: 400px; }
    .login-header { margin-bottom: 16px; }
    .login-header h1 { font-size: 22px; }
    .logo-icon { width: 48px; height: 48px; margin-bottom: 12px; }
    .form-group { margin-bottom: 10px; }
    .form-group input { padding: 10px 14px; min-height: 40px; }
    .btn-full { padding: 10px; }
    .shape { display: none; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 10px; }
    .stat-card { padding: 12px; }
    .stat-icon { width: 36px; height: 36px; font-size: 15px; }
    .stat-number { font-size: 18px; }
    .stat-label { font-size: 11px; }
    .sidebar-menu li { padding: 10px 16px; font-size: 13px; }
    .section { padding: 12px; }
    .top-bar { padding: 8px 16px; }
    .top-bar h2 { font-size: 15px; }
}

/* Car dashboard: landscape, medium height (7-12" screens) */
@media (min-width: 600px) and (max-width: 1100px) and (orientation: landscape) {
    .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; }
    .stat-card { padding: 16px; }
    .form-row { grid-template-columns: 1fr 1fr; }
    .btn { min-height: 44px; }
    .form-group input, .form-group select { min-height: 44px; }
}

/* Print */
@media print {
    .sidebar, .top-bar, .mobile-menu-btn, .btn { display: none !important; }
    .main-content { margin-left: 0 !important; }
    body { background: white; color: black; }
}
