:root {
    --primary: #667eea;
    --primary-hover: #5a67d8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray: #6b7280;
    --light: #f3f4f6;
    --border: #e5e7eb;
    --bg-app: #f9fafb;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto', Arial, sans-serif;
    background-color: var(--bg-app);
    color: #1f2937;
    height: 100vh;
    overflow: hidden;
}

/* ==========================================
   NAVIGATION
   ========================================== */
.app-nav {
    background: white;
    border-bottom: 2px solid var(--border);
    display: flex;
    padding: 0 20px;
    gap: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.nav-item {
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    color: var(--gray);
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.nav-item:hover {
    background: #f3f4f6;
    color: var(--primary);
}

.nav-item.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 700;
}

/* ==========================================
   PAGE STRUCTURE
   ========================================== */
.page-header {
    margin-bottom: 30px;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 5px;
}

.page-subtitle {
    color: var(--gray);
    font-size: 14px;
}

/* ==========================================
   CARDS
   ========================================== */
.chart-card {
    background: white;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.chart-title {
    font-size: 16px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
}

.chart-title i {
    margin-right: 8px;
}

.card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

/* ==========================================
   KPI GRID
   ========================================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.kpi-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.kpi-label {
    font-size: 12px;
    color: var(--gray);
    text-transform: uppercase;
    margin-bottom: 8px;
    font-weight: 600;
}

.kpi-value {
    font-size: 32px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 8px;
}

.kpi-change {
    font-size: 13px;
    font-weight: 600;
}

.kpi-change.positive {
    color: var(--success);
}

.kpi-change.negative {
    color: var(--danger);
}

/* ==========================================
   STATS GRID
   ========================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
}

.stat-card {
    background: white;
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    gap: 12px;
    align-items: center;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.green { background: #d1fae5; color: #10b981; }
.stat-icon.amber { background: #fef3c7; color: #f59e0b; }
.stat-icon.red { background: #fee2e2; color: #ef4444; }

.stat-info h3 {
    font-size: 24px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 2px;
}

.stat-info p {
    font-size: 12px;
    color: var(--gray);
    font-weight: 500;
}

/* ==========================================
   CHARTS & GRAPHIQUES
   ========================================== */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 20px;
    height: 160px;
    padding: 0;
    position: relative;
}

.bar-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.bar {
    width: 100%;
    max-width: 35px;
    border-radius: 4px 4px 0 0;
    transition: all 0.3s;
    position: relative;
}

.bar:hover {
    opacity: 0.8;
    transform: translateY(-2px);
}

.bar.ca {
    background: var(--primary);
}

.bar.budget {
    background: #cbd5e1;
}

.bar-label {
    font-size: 11px;
    color: var(--gray);
    font-weight: 600;
    text-align: center;
    margin-top: 4px;
}

/* Tooltip on hover */
.bar[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    margin-bottom: 5px;
    z-index: 10;
}

/* ==========================================
   FUNNEL
   ========================================== */
.funnel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.funnel-item {
    text-align: center;
}

.funnel-value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 5px;
}

.funnel-label {
    font-size: 13px;
    color: var(--gray);
    margin-bottom: 10px;
    font-weight: 600;
}

.funnel-bar {
    width: 100%;
    height: 10px;
    background: #e5e7eb;
    border-radius: 5px;
    overflow: hidden;
}

.funnel-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 1s;
}

/* ==========================================
   ALERTS
   ========================================== */
.alert-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.alert-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: 6px;
    border-left: 4px solid;
}

.alert-item[data-type] {
    transition: all 0.2s;
}

.alert-item[data-type]:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.alert-item.critical {
    background: #fee2e2;
    border-left-color: #ef4444;
}

.alert-item.warning {
    background: #fef3c7;
    border-left-color: #f59e0b;
}

.alert-item.info {
    background: #dbeafe;
    border-left-color: #3b82f6;
}

.alert-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.alert-icon.critical {
    background: #ef4444;
    color: white;
}

.alert-icon.warning {
    background: #f59e0b;
    color: white;
}

.alert-icon.info {
    background: #3b82f6;
    color: white;
}

.alert-content h4 {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #111827;
}

.alert-content p {
    font-size: 13px;
    color: #4b5563;
    margin: 0;
}

/* Animation pour les alertes */
@keyframes slideInAlert {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-item {
    animation: slideInAlert 0.3s ease;
}

/* ==========================================
   TABLES
   ========================================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: #f9fafb;
}

.data-table th {
    padding: 12px;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    color: var(--gray);
    text-transform: uppercase;
    border-bottom: 2px solid var(--border);
}

.data-table td {
    padding: 12px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

.data-table tr:hover {
    background: #f9fafb;
}

/* ==========================================
   STATUS BADGES
   ========================================== */
.status {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
}

.status.nouveau { background: #dbeafe; color: #1e40af; }
.status.devis { background: #fef3c7; color: #92400e; }
.status.signe { background: #d1fae5; color: #065f46; }
.status.perdu { background: #fee2e2; color: #991b1b; }
.status.retard { background: #fee2e2; color: #991b1b; }
.status.lead { background: #e0e7ff; color: #3730a3; }
.status.etude { background: #ddd6fe; color: #5b21b6; }
.status.gagne { background: #d1fae5; color: #065f46; }
.status.chantier { background: #fef3c7; color: #92400e; }
.status.facturation { background: #dbeafe; color: #1e40af; }

/* ==========================================
   TABS
   ========================================== */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
}

.tab {
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray);
    transition: all 0.2s;
    font-family: inherit;
}

.tab:hover {
    color: var(--primary);
    background: #f9fafb;
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    animation: fadeIn 0.3s;
}

.tab-content.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ==========================================
   FILTERS
   ========================================== */
.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filters .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: white;
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ==========================================
   BUTTONS
   ========================================== */
.btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.btn-secondary {
    background: white;
    color: var(--primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: var(--primary);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn:active {
    transform: translateY(0);
}

/* ==========================================
   PERF GRID
   ========================================== */
.perf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.perf-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.perf-card h4 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 15px;
    color: var(--primary);
}

.perf-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.perf-row:last-child {
    border-bottom: none;
}

.perf-label {
    font-size: 13px;
    color: var(--gray);
}

.perf-value {
    font-size: 13px;
    font-weight: 700;
    color: #111827;
}

.perf-value.success {
    color: var(--success);
}

/* ==========================================
   PROGRESS BAR
   ========================================== */
.progress-bar {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1s;
}

.progress-fill.blue { background: #3b82f6; }
.progress-fill.green { background: #10b981; }
.progress-fill.orange { background: #f59e0b; }
.progress-fill.red { background: #ef4444; }

/* ==========================================
   FORMS
   ========================================== */
.form-group {
    margin-bottom: 15px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.form-input,
.form-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ==========================================
   ANIMATIONS
   ========================================== */
.fade-in {
    animation: fadeIn 0.3s;
}

/* ==========================================
   UTILITY
   ========================================== */
.hidden {
    display: none !important;
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .funnel-grid {
        grid-template-columns: 1fr;
    }
    
    .perf-grid {
        grid-template-columns: 1fr;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .alert-item {
        flex-direction: column;
        gap: 12px;
    }
    
    .alert-item > div:last-child {
        width: 100%;
        justify-content: flex-end;
    }
    
    .app-nav {
        overflow-x: auto;
        padding: 0 10px;
    }
    
    .nav-item {
        padding: 10px 15px;
        font-size: 13px;
        white-space: nowrap;
    }
    
    .page-title {
        font-size: 22px;
    }
    
    .bar-chart {
        gap: 10px;
    }
    
    .bar {
        max-width: 25px;
    }
    
    .bar-label {
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .kpi-value {
        font-size: 24px;
    }
    
    .funnel-value {
        font-size: 24px;
    }
    
    .stat-info h3 {
        font-size: 20px;
    }
    
    .chart-card {
        padding: 16px;
    }
    
    .data-table {
        font-size: 12px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px;
    }
}

/* ==========================================
   SCROLLBAR PERSONNALISÉE
   ========================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}