/* ========================================
   🔥 PATCH GRAPHIQUE - À AJOUTER EN HAUT DE DASHBOARD.CSS
   Résout le problème du graphique minuscule
   ======================================== */

/* Section graphique */
.chart-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    padding: 24px;
    display: flex;
    flex-direction: column;
    min-height: 600px;
}

/* Header de section */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

/* Container du graphique - CRITIQUE */
.chart-wrapper {
    flex: 1;
    min-height: 400px;
    height: 400px;
    position: relative;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
    max-height: 400px;
}

/* Section données */
.data-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    padding: 24px;
    display: flex;
    flex-direction: column;
    min-height: 600px;
}

/* Welcome section (pas de voiture) */
.welcome-section {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 500px;
    padding: 40px;
}

.welcome-content {
    text-align: center;
    max-width: 500px;
}

.welcome-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.welcome-text {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    line-height: 1.6;
}

.btn-primary-large {
    display: inline-block;
    padding: 16px 32px;
    background: linear-gradient(90deg, var(--primary), var(--primary-hover));
    color: white;
    text-decoration: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    transition: var(--transition);
}

.btn-primary-large:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* ========================================
   FIN DU PATCH
   Le reste de votre CSS continue normalement ci-dessous
   ======================================== */

/* ========================================
   DASHBOARD - KM TRACKER v2.0
   ======================================== */

/* Container principal */
.dashboard-container {
    display: grid;
    grid-template-columns: 1fr 1fr; /* 50/50 strict */
    gap: 24px;
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%; /* Forcer 100% de largeur */
}

.left-panel,
.right-panel {
    min-width: 0; /* Empêcher le débordement */
    width: 100%; /* Forcer 100% dans sa colonne */
}

/* ========================================
   PANEL GAUCHE - GRAPHIQUE
   ======================================== */

.left-panel {
    background: var(--card-background, white);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.panel-header {
    margin-bottom: 24px;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.header-info h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary, #1f2937);
}

/* Badge type de contrat */
.tracking-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: help;
}

.tracking-badge.loa {
    background: #dbeafe;
    color: #1e40af;
}

.tracking-badge.insurance {
    background: #fef3c7;
    color: #92400e;
}

/* Stats mini */
.stats-mini {
    display: flex;
    gap: 16px;
}

.stat-mini {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary, #6b7280);
    font-weight: 500;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary, #1f2937);
}

.stat-value.positive {
    color: #22c55e;
}

.stat-value.negative {
    color: var(--danger);
}

/* Container du graphique */
.chart-container {
    flex: 1;
    min-height: 400px;
    position: relative;
}

/* ========================================
   PANEL DROIT - TABLEAU
   ======================================== */

.right-panel {
    background: var(--card-background, white);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 24px;
    display: flex;
    flex-direction: column;
}

/* Contrôles en haut */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.controls-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.controls-right {
    display: flex;
    gap: 12px;
}

/* Sélecteur d'année */
.year-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.year-selector label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary, #6b7280);
}

.year-select {
    padding: 6px 12px;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 6px;
    background: var(--input-background, white);
    color: var(--text-primary, #1f2937);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.year-select:hover {
    border-color: var(--primary);
}

.year-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

/* Compteur d'entrées */
.entries-count {
    font-size: 14px;
    color: var(--text-secondary, #6b7280);
}

#entriesCountValue {
    font-weight: 700;
    color: var(--text-primary, #1f2937);
}

/* Bouton réinitialiser */
.btn-danger-outline {
    padding: 8px 16px;
    background: transparent;
    border: 1.5px solid var(--danger);
    color: var(--danger);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-danger-outline:hover {
    background: var(--danger);
    color: white;
}

/* ========================================
   TABLEAU
   ======================================== */

.table-wrapper {
    flex: 1;
    max-height: 760px; /* Hauteur fixe de 500px */
    overflow-y: auto;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color, #e5e7eb);
}

.km-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.km-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--table-header-bg, #f9fafb);
}

.km-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
    border-bottom: 2px solid var(--border-color, #e5e7eb);
    white-space: nowrap;
}

.km-table tbody tr {
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    transition: background 0.15s;
}

.km-table tbody tr:hover {
    background: var(--hover-bg, #f9fafb);
}

.km-table tbody tr.today-row {
    background: rgba(var(--primary-rgb), 0.05);
}

.km-table tbody tr.today-row:hover {
    background: rgba(var(--primary-rgb), 0.08);
}

.km-table td {
    padding: 12px 16px;
    color: var(--text-primary, #1f2937);
}

/* Colonne date */
.date-cell {
    font-weight: 500;
    white-space: nowrap;
}

.today-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    background: var(--primary);
    color: white;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

/* Colonne km prévu */
.predicted-cell {
    font-weight: 500;
    color: var(--primary);
}

/* Colonne km réel */
.real-cell {
    padding: 8px 16px;
}

.real-input {
    width: 100%;
    max-width: 120px;
    padding: 8px 12px;
    border: 1.5px solid var(--border-color, #e5e7eb);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary, #1f2937);
    background: var(--input-background, white);
    transition: all 0.2s;
}

.real-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.real-input::placeholder {
    color: var(--text-tertiary, #d1d5db);
}

/* Colonne écart */
.diff-cell {
    font-weight: 600;
    text-align: center;
}

.diff-cell.positive {
    color: #22c55e;
}

.diff-cell.warning {
    color: var(--warning);
}

.diff-cell.negative {
    color: var(--danger);
}

/* Message si pas de données */
.no-data-row td {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary, #6b7280);
    font-size: 15px;
}

/* ========================================
   EMPTY STATE (pas de voiture)
   ======================================== */

.empty-state-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 500px;
    padding: 40px;
    text-align: center;
}

.empty-state-icon {
    font-size: 80px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state-container h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary, #1f2937);
    margin: 0 0 12px 0;
}

.empty-state-container p {
    font-size: 16px;
    color: var(--text-secondary, #6b7280);
    margin: 0 0 24px 0;
}

.btn-add-car {
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-add-car:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
}

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 1330px) {
    .dashboard-container {
        grid-template-columns: 1fr;
    }
    
    .left-panel {
        order: 1;
        width: 100%; /* Pleine largeur */
    }
    .right-panel {
        order: 2;
        width: 100%; /* Pleine largeur */
    }
    }
}

@media (max-width: 768px) {
    .dashboard-container {
        padding: 16px;
        gap: 16px;
    }
    
    .left-panel,
    .right-panel {
        padding: 16px;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .controls-left,
    .controls-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .chart-container {
        min-height: 300px;
    }
    
    .km-table {
        font-size: 13px;
    }
    
    .km-table th,
    .km-table td {
        padding: 8px 12px;
    }
    
    .real-input {
        max-width: 100px;
        padding: 6px 10px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .header-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .stats-mini {
        flex-direction: column;
        gap: 12px;
    }
    
    .km-table th,
    .km-table td {
        padding: 6px 8px;
    }
    
    .today-badge {
        display: block;
        margin-left: 0;
        margin-top: 4px;
    }
}

/* ========================================
   THÈME SOMBRE
   ======================================== */

[data-theme="dark"] {
    --card-background: #1f2937;
    --table-header-bg: #111827;
    --border-color: #374151;
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-tertiary: #6b7280;
    --input-background: #111827;
    --hover-bg: #374151;
}

[data-theme="dark"] .tracking-badge.loa {
    background: #1e3a8a;
    color: #93c5fd;
}

[data-theme="dark"] .tracking-badge.insurance {
    background: #78350f;
    color: #fde68a;
}

[data-theme="dark"] .km-table tbody tr.today-row {
    background: rgba(var(--primary-rgb), 0.15);
}

[data-theme="dark"] .km-table tbody tr.today-row:hover {
    background: rgba(var(--primary-rgb), 0.2);
}

[data-theme="dark"] .btn-add-car {
    background: var(--primary-dark);
}

[data-theme="dark"] .btn-add-car:hover {
    background: #1d4ed8;
}/* ========================================
   DASHBOARD - KM TRACKER v2.0
   ======================================== */

/* Container principal */
.dashboard-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

/* ========================================
   PANEL GAUCHE - GRAPHIQUE
   ======================================== */

.left-panel {
    background: var(--card-background, white);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.panel-header {
    margin-bottom: 24px;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.header-info h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary, #1f2937);
}

/* Badge type de contrat */
.tracking-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: help;
}

.tracking-badge.loa {
    background: #dbeafe;
    color: #1e40af;
}

.tracking-badge.insurance {
    background: #fef3c7;
    color: #92400e;
}

/* Stats mini */
.stats-mini {
    display: flex;
    gap: 16px;
}

.stat-mini {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary, #6b7280);
    font-weight: 500;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary, #1f2937);
}

.stat-value.positive {
    color: #22c55e;
}

.stat-value.negative {
    color: var(--danger);
}

/* Container du graphique */
.chart-container {
    flex: 1;
    min-height: 400px;
    position: relative;
}

/* ========================================
   PANEL DROIT - TABLEAU
   ======================================== */

.right-panel {
    background: var(--card-background, white);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 24px;
    display: flex;
    flex-direction: column;
}

/* Contrôles en haut */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.controls-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.controls-right {
    display: flex;
    gap: 12px;
}

/* Sélecteur d'année */
.year-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.year-selector label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary, #6b7280);
}

.year-select {
    padding: 6px 12px;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 6px;
    background: var(--input-background, white);
    color: var(--text-primary, #1f2937);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.year-select:hover {
    border-color: var(--primary);
}

.year-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

/* Compteur d'entrées */
.entries-count {
    font-size: 14px;
    color: var(--text-secondary, #6b7280);
}

#entriesCountValue {
    font-weight: 700;
    color: var(--text-primary, #1f2937);
}

/* Bouton réinitialiser */
.btn-danger-outline {
    padding: 8px 16px;
    background: transparent;
    border: 1.5px solid var(--danger);
    color: var(--danger);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-danger-outline:hover {
    background: var(--danger);
    color: white;
}

/* ========================================
   TABLEAU
   ======================================== */

.table-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color, #e5e7eb);
}

.km-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.km-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--table-header-bg, #f9fafb);
}

.km-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
    border-bottom: 2px solid var(--border-color, #e5e7eb);
    white-space: nowrap;
}

.km-table tbody tr {
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    transition: background 0.15s;
}

.km-table tbody tr:hover {
    background: var(--hover-bg, #f9fafb);
}

.km-table tbody tr.today-row {
    background: rgba(var(--primary-rgb), 0.05);
}

.km-table tbody tr.today-row:hover {
    background: rgba(var(--primary-rgb), 0.08);
}

.km-table td {
    padding: 12px 16px;
    color: var(--text-primary, #1f2937);
}

/* Colonne date */
.date-cell {
    font-weight: 500;
    white-space: nowrap;
}

.today-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    background: var(--primary);
    color: white;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

/* Colonne km prévu */
.predicted-cell {
    font-weight: 500;
    color: var(--primary);
}

/* Colonne km réel */
.real-cell {
    padding: 8px 16px;
}

.real-input {
    width: 100%;
    max-width: 120px;
    padding: 8px 12px;
    border: 1.5px solid var(--border-color, #e5e7eb);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary, #1f2937);
    background: var(--input-background, white);
    transition: all 0.2s;
}

.real-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.real-input::placeholder {
    color: var(--text-tertiary, #d1d5db);
}

/* Colonne écart */
.diff-cell {
    font-weight: 600;
    text-align: center;
}

.diff-cell.positive {
    color: #22c55e;
}

.diff-cell.warning {
    color: var(--warning);
}

.diff-cell.negative {
    color: var(--danger);
}

/* Message si pas de données */
.no-data-row td {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary, #6b7280);
    font-size: 15px;
}

/* ========================================
   EMPTY STATE (pas de voiture)
   ======================================== */

.empty-state-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 500px;
    padding: 40px;
    text-align: center;
}

.empty-state-icon {
    font-size: 80px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state-container h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary, #1f2937);
    margin: 0 0 12px 0;
}

.empty-state-container p {
    font-size: 16px;
    color: var(--text-secondary, #6b7280);
    margin: 0 0 24px 0;
}

.btn-add-car {
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-add-car:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
}

/* ========================================
   ANIMATIONS
   ======================================== */



/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 1330px) {
    .dashboard-container {
        grid-template-columns: 1fr;
    .left-panel {
        order: 1;
        width: 100%;
    }
    .right-panel {
        order: 2;
        width: 100%;
    }
    .right-panel {
        order: 2;
    }
}

@media (max-width: 768px) {
    .dashboard-container {
        padding: 16px;
        gap: 16px;
    }
    
    .left-panel,
    .right-panel {
        padding: 16px;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .controls-left,
    .controls-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .chart-container {
        min-height: 300px;
    }
    
    .km-table {
        font-size: 13px;
    }
    
    .km-table th,
    .km-table td {
        padding: 8px 12px;
    }
    
    .real-input {
        max-width: 100px;
        padding: 6px 10px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .header-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .stats-mini {
        flex-direction: column;
        gap: 12px;
    }
    
    .km-table th,
    .km-table td {
        padding: 6px 8px;
    }
    
    .today-badge {
        display: block;
        margin-left: 0;
        margin-top: 4px;
    }
}

/* ========================================
   THÈME SOMBRE
   ======================================== */

[data-theme="dark"] {
    --card-background: #1f2937;
    --table-header-bg: #111827;
    --border-color: #374151;
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-tertiary: #6b7280;
    --input-background: #111827;
    --hover-bg: #374151;
}

[data-theme="dark"] .tracking-badge.loa {
    background: #1e3a8a;
    color: #93c5fd;
}

[data-theme="dark"] .tracking-badge.insurance {
    background: #78350f;
    color: #fde68a;
}

[data-theme="dark"] .km-table tbody tr.today-row {
    background: rgba(var(--primary-rgb), 0.15);
}

[data-theme="dark"] .km-table tbody tr.today-row:hover {
    background: rgba(var(--primary-rgb), 0.2);
}

[data-theme="dark"] .btn-add-car {
    background: var(--primary-dark);
}

[data-theme="dark"] .btn-add-car:hover {
    background: #1d4ed8;
}

/* ================================================
   MODAL AJOUT D'ENTRÉE MANUELLE
   ================================================ */

.add-entry-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 999999;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.add-entry-modal-overlay.active {
    display: flex;
}

.add-entry-modal {
    background: var(--bg-card, white);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    position: relative;
    animation: slideUp 0.3s ease;
}

[data-theme="dark"] .add-entry-modal {
    background: #1f2937;
    border: 1px solid #374151;
}

.modal-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    font-size: 32px;
    line-height: 1;
    color: var(--text-muted, #9ca3af);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
}

.modal-close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary, #1f2937);
}

[data-theme="dark"] .modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #f9fafb;
}

.modal-header {
    margin-bottom: 24px;
    padding-right: 40px;
}

.modal-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary, #1f2937);
    margin: 0 0 8px 0;
}

[data-theme="dark"] .modal-header h2 {
    color: #f9fafb;
}

.modal-header p {
    font-size: 14px;
    color: var(--text-secondary, #6b7280);
    margin: 0;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #1f2937);
}

[data-theme="dark"] .form-group label {
    color: #f9fafb;
}

.date-input,
.km-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary, #1f2937);
    background: var(--input-background, white);
    transition: all 0.2s;
}

[data-theme="dark"] .date-input,
[data-theme="dark"] .km-input {
    background: #111827;
    border-color: #374151;
    color: #f9fafb;
}

.date-input {
    cursor: pointer;
}

.date-input:focus,
.km-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.form-hint {
    font-size: 12px;
    color: var(--text-secondary, #6b7280);
    font-style: italic;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.btn-secondary,
.btn-primary {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 48px;
}

.btn-secondary {
    background: var(--gray-100, #f3f4f6);
    color: var(--text-primary, #1f2937);
    border: 1px solid var(--border-color, #e5e7eb);
}

[data-theme="dark"] .btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: #f9fafb;
    border-color: #374151;
}

.btn-secondary:hover {
    background: var(--gray-200, #e5e7eb);
    transform: translateY(-2px);
}

[data-theme="dark"] .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-primary {
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.4);
}

/* Bouton d'ouverture du modal (à ajouter dans les contrôles) */
.btn-add-entry {
    padding: 8px 16px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-add-entry:hover {
    background: #059669;
    box-shadow: 0 2px 8px rgba(var(--success-rgb), 0.3);
}


/* Responsive */
@media (max-width: 480px) {
    .add-entry-modal {
        padding: 24px;
        max-width: 95%;
    }
    
    .modal-header h2 {
        font-size: 20px;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .btn-secondary,
    .btn-primary {
        width: 100%;
    }
}
/* ================================================
   FIX Z-INDEX CALENDRIER MODAL
   Pour que le calendrier s'affiche AU-DESSUS du modal d'ajout
   ================================================ */

.calendar-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

.calendar-modal-overlay.active {
    display: flex;
}

/* Conteneur du modal */
.calendar-modal {
    background: var(--bg-card, white);
    border-radius: var(--radius-xl, 16px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    max-width: 90%;
    width: 400px;
    padding: 24px;
    animation: slideUp 0.3s ease-out;
    position: relative;
}

[data-theme="dark"] .calendar-modal {
    background: #1a1d23;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Bouton fermer */
.calendar-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary, #666);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.calendar-modal-close:hover {
    background: var(--gray-100, #f3f4f6);
    color: var(--text-primary, black);
}

[data-theme="dark"] .calendar-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Header du calendrier */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-right: 32px; /* Pour le bouton close */
}

.calendar-nav-btn {
    background: var(--primary, var(--primary));
    color: white;
    border: none;
    border-radius: var(--radius-md, 8px);
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    user-select: none;
}

.calendar-nav-btn:hover {
    background: var(--primary-hover, var(--primary-dark));
    transform: scale(1.05);
}

.calendar-nav-btn:active {
    transform: scale(0.95);
}

.calendar-month-year {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary, black);
    text-align: center;
    min-width: 200px;
}

/* Grille du calendrier */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin-top: 16px;
}

/* Jours de la semaine */
.calendar-weekday {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #666);
    padding: 8px 0;
    text-transform: uppercase;
}

/* Cellules des jours */
.calendar-day {
    aspect-ratio: 1;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: var(--radius-md, 8px);
    background: var(--bg-input, white);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary, black);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    min-height: 44px; /* Pour Tesla */
}

[data-theme="dark"] .calendar-day {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.calendar-day:hover {
    background: var(--primary, var(--primary));
    color: white;
    transform: scale(1.05);
    border-color: var(--primary, var(--primary));
}

.calendar-day:active {
    transform: scale(0.95);
}

/* Jour vide (avant/après le mois) */
.calendar-day.empty {
    border: none;
    background: transparent;
    cursor: default;
    pointer-events: none;
}

/* Jour d'aujourd'hui */
.calendar-day.today {
    background: var(--primary, var(--primary));
    color: white;
    font-weight: 700;
    border-color: var(--primary, var(--primary));
}

/* Jour sélectionné */
.calendar-day.selected {
    background: var(--success, var(--success));
    color: white;
    border-color: var(--success, var(--success));
    font-weight: 700;
}

.calendar-day.selected:hover {
    background: #059669;
}

/* Bouton "Aujourd'hui" */
.calendar-today-btn {
    width: 100%;
    margin-top: 16px;
    padding: 12px;
    background: var(--gray-100, #f3f4f6);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: var(--radius-md, 8px);
    color: var(--text-primary, black);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

[data-theme="dark"] .calendar-today-btn {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.calendar-today-btn:hover {
    background: var(--primary, var(--primary));
    color: white;
    border-color: var(--primary, var(--primary));
}

/* Animations */

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 480px) {
    .calendar-modal {
        width: 95%;
        padding: 20px;
    }
    
    .calendar-month-year {
        font-size: 16px;
        min-width: 160px;
    }
    
    .calendar-nav-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .calendar-day {
        font-size: 13px;
        min-height: 40px;
    }
    
    .calendar-grid {
        gap: 4px;
    }
}
/* ========================================
   RESPONSIVE MOBILE - TABLEAU OPTIMISÉ
   ======================================== */

@media (max-width: 480px) {
    /* Tableau responsive */
    .km-table {
        font-size: 12px !important;
    }
    
    .km-table th,
    .km-table td {
        padding: 8px 4px !important;
    }
        
    /* Ajuster les largeurs des colonnes restantes */
    .km-table th:first-child,
    .km-table td:first-child {
        width: 30%;
        min-width: 70px;
        font-size: 11px;
    }
    
    .km-table th:nth-child(3),
    .km-table td:nth-child(3) {
        width: 35%;
        min-width: 65px;
    }
    
    .km-table th:last-child,
    .km-table td:last-child {
        width: 25%;
        min-width: 50px;
        text-align: right;
        font-size: 11px;
    }
    
    /* Input km réel plus compact */
    .real-input {
        font-size: 13px !important;
        padding: 6px 6px !important;
        width: 100% !important;
        min-width: 55px !important;
    }
    
    /* Badge aujourd'hui plus compact */
    .today-badge {
        font-size: 9px !important;
        padding: 2px 5px !important;
        white-space: nowrap;
    }
    
    /* Wrapper du tableau */
    .table-wrapper {
        max-height: 400px !important; /* Un peu moins haut sur mobile */
    }
}