:root {
    --primary: #6d28d9;
    --primary-light: #7c3aed;
    --primary-dark: #5b21b6;
    --sidebar-bg: #1e1b4b;
    --sidebar-text: #c4b5fd;
    --sidebar-active: #6d28d9;
    --body-bg: #f5f3ff;
    --card-bg: #ffffff;
    --text-dark: #1e1b4b;
    --text-muted: #6b7280;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
}

* { box-sizing: border-box; }

body {
    background: var(--body-bg);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-dark);
    margin: 0;
}

/* SIDEBAR */
#sidebar {
    width: 260px;
    min-height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0; left: 0;
    z-index: 1000;
    transition: width 0.3s ease;
    display: flex;
    flex-direction: column;
}

#sidebar.collapsed { width: 72px; }

.sidebar-logo {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo .logo-icon {
    width: 40px; height: 40px;
    background: var(--primary);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.sidebar-logo .logo-text {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s;
}

#sidebar.collapsed .logo-text { opacity: 0; width: 0; }

.sidebar-section-title {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.2px;
    color: rgba(196,181,253,0.5);
    text-transform: uppercase;
    padding: 20px 20px 8px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s;
}

#sidebar.collapsed .sidebar-section-title { opacity: 0; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    border-radius: 8px;
    margin: 2px 10px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav a i {
    font-size: 18px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.sidebar-nav a:hover {
    background: rgba(109,40,217,0.3);
    color: #fff;
}

.sidebar-nav a.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(109,40,217,0.4);
}

.sidebar-nav a .nav-label {
    transition: opacity 0.2s;
}

#sidebar.collapsed .sidebar-nav a .nav-label { opacity: 0; width: 0; overflow: hidden; }

.sidebar-badge {
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 99px;
    margin-left: auto;
    flex-shrink: 0;
}

#sidebar.collapsed .sidebar-badge { display: none; }

.sidebar-footer {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
    overflow: hidden;
}

.sidebar-user:hover { background: rgba(255,255,255,0.08); }

.sidebar-user .avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.sidebar-user .user-info { overflow: hidden; transition: opacity 0.2s; }
.sidebar-user .user-name { color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; }
.sidebar-user .user-role { color: var(--sidebar-text); font-size: 11px; white-space: nowrap; }
#sidebar.collapsed .sidebar-user .user-info { opacity: 0; width: 0; }

/* MAIN CONTENT */
#main-content {
    margin-left: 260px;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

#main-content.expanded { margin-left: 72px; }

/* TOPBAR */
.topbar {
    background: #fff;
    padding: 16px 28px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid #ede9fe;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

.topbar-breadcrumb {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-btn {
    width: 38px; height: 38px;
    border-radius: 10px;
    border: 1px solid #ede9fe;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.topbar-btn:hover { background: var(--body-bg); color: var(--primary); }

.notification-dot {
    position: absolute;
    top: 6px; right: 6px;
    width: 8px; height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid #fff;
}

#toggle-sidebar {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-dark);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.2s;
}
#toggle-sidebar:hover { background: var(--body-bg); }

/* CONTENT AREA */
.content-area {
    padding: 28px;
}

/* KPI CARDS */
.kpi-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid #ede9fe;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(109,40,217,0.12);
}

.kpi-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    margin-bottom: 16px;
}

.kpi-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-dark);
    line-height: 1;
    margin-bottom: 4px;
}

.kpi-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.kpi-change {
    font-size: 12px;
    font-weight: 600;
    margin-top: 8px;
}

.kpi-change.up { color: var(--success); }
.kpi-change.down { color: var(--danger); }

.kpi-decoration {
    position: absolute;
    bottom: -20px; right: -20px;
    width: 100px; height: 100px;
    border-radius: 50%;
    opacity: 0.06;
}

/* CARDS */
.dc-card {
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid #ede9fe;
    overflow: hidden;
}

.dc-card-header {
    padding: 20px 24px;
    border-bottom: 1px solid #f3f0ff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dc-card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

.dc-card-body { padding: 24px; }

/* BANNER PREMIUM */
.premium-banner {
    background: linear-gradient(135deg, #6d28d9 0%, #4f46e5 100%);
    border-radius: 16px;
    padding: 20px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    margin-bottom: 24px;
}

.premium-banner h6 { margin: 0 0 4px; font-size: 12px; opacity: 0.8; }
.premium-banner h5 { margin: 0; font-size: 16px; font-weight: 700; }

/* ALERT BANNERS */
.alert-warning-caçamba {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
}

/* STATUS BADGES */
.badge-alocada { background: #dbeafe; color: #1d4ed8; }
.badge-retirada { background: #d1fae5; color: #065f46; }
.badge-cancelada { background: #fee2e2; color: #991b1b; }
.badge-disponivel { background: #d1fae5; color: #065f46; }
.badge-manutencao { background: #fee2e2; color: #991b1b; }
.badge-pendente { background: #fef3c7; color: #92400e; }

.status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.dot-alocada { background: #3b82f6; }
.dot-retirada { background: #10b981; }
.dot-cancelada { background: #ef4444; }
.dot-disponivel { background: #10b981; }
.dot-manutencao { background: #f59e0b; }

/* TABLES */
.dc-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.dc-table th {
    background: #f5f3ff;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #ede9fe;
}
.dc-table td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid #f5f3ff;
    vertical-align: middle;
}
.dc-table tr:last-child td { border-bottom: none; }
.dc-table tr:hover td { background: #faf5ff; }

/* FORMS */
.form-label { font-size: 13px; font-weight: 600; color: var(--text-dark); margin-bottom: 6px; }
.form-control, .form-select {
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(109,40,217,0.12);
    outline: none;
}

/* BUTTONS */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    border-radius: 10px;
    font-weight: 600;
    padding: 10px 20px;
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-outline-primary {
    border-color: var(--primary);
    color: var(--primary);
    border-radius: 10px;
    font-weight: 600;
}
.btn-outline-primary:hover { background: var(--primary); }

.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }

/* MAP */
#map-container { border-radius: 16px; overflow: hidden; border: 1px solid #ede9fe; }
#map { height: 500px; width: 100%; }

/* CHARTS */
.chart-container { position: relative; height: 280px; }

/* LOGIN PAGE */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4c1d95 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: #fff;
    border-radius: 24px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.3);
}

.login-logo {
    width: 60px; height: 60px;
    background: var(--primary);
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px;
    margin: 0 auto 24px;
}

/* ALERT DIAS */
.dias-alerta {
    background: #fff7ed;
    border: 1px solid #fb923c;
    color: #9a3412;
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* NOTA FISCAL */
.nf-sim { background: #d1fae5; color: #065f46; border-radius: 8px; padding: 3px 10px; font-size: 12px; font-weight: 600; }
.nf-nao { background: #f3f4f6; color: #6b7280; border-radius: 8px; padding: 3px 10px; font-size: 12px; font-weight: 600; }

/* RESPONSIVE */
@media (max-width: 768px) {
    #sidebar { width: 72px; }
    #sidebar .logo-text, #sidebar .nav-label, #sidebar .sidebar-section-title,
    #sidebar .user-info, #sidebar .sidebar-badge { display: none; }
    #main-content { margin-left: 72px; }
    .content-area { padding: 16px; }
}

/* Leaflet popup custom */
.leaflet-popup-content-wrapper {
    border-radius: 12px !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15) !important;
}

.map-popup h6 { margin: 0 0 6px; font-weight: 700; color: var(--text-dark); }
.map-popup p { margin: 0; font-size: 13px; color: var(--text-muted); }
.map-popup .badge { font-size: 11px; }

/* Financial chart bars custom */
.bar-receita { fill: var(--success); }
.bar-despesa { fill: var(--danger); }
