:root {
    --bg: #0f172a;
    --card: #1e293b;
    --input: #334155;
    --accent: #6366f1;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #fbbf24;
    --text: #f1f5f9;
    --text-dim: #94a3b8;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body { 
    background-color: var(--bg); 
    color: var(--text); 
    font-family: 'Inter', sans-serif; 
    padding: 20px;
}

/* --- TABLEAU --- */
.main-table-container { 
    background: var(--card); 
    border-radius: 12px; 
    padding: 15px; 
    overflow-x: auto !important; 
}

table { 
    width: 100% !important; 
    border-collapse: separate !important; 
    border-spacing: 0 10px !important; 
    table-layout: auto !important; 
}

th {
    color: var(--text-dim); 
    font-size: 10px; 
    font-weight: 800; 
    padding: 12px; 
    text-transform: uppercase; 
    text-align: center;
}

tr.data-row { background: rgba(255,255,255,0.03); }

/* --- STYLE GÉNÉRAL DES TD --- */
td {
    padding: 15px 12px !important; 
    font-size: 13px !important; 
    text-align: center !important; 
    vertical-align: middle !important;
    color: var(--text) !important;
    white-space: normal !important; 
    text-overflow: clip !important; 
    overflow: visible !important; 
    word-break: break-word !important; 
}

/* --- FIX PRÉCIS POUR LES COLONNES --- */

/* 1. Protéger les colonnes "Date" (Prise en compte, Factu, Envoi) */
/* On cible les colonnes 1, 6 et 7 */
td:nth-child(1), th:nth-child(1),
td:nth-child(6), th:nth-child(6),
td:nth-child(7), th:nth-child(7) {
    width: 110px !important;
    min-width: 110px !important;
    white-space: nowrap !important; /* On empêche la date de se couper en deux */
}

/* 2. Protéger la colonne Statut */
td:nth-child(8), th:nth-child(8) {
    width: 140px !important;
    min-width: 140px !important;
}

/* 3. Colonnes de texte (Site, Coord, Objet, Comm) */
/* On les laisse respirer et on leur permet de prendre la place restante */
td:nth-child(2), td:nth-child(3), td:nth-child(4), td:nth-child(5) {
    min-width: 150px !important;
}

/* --- LE RESTE DU STYLE --- */
.tabs-container { display: flex; gap: 10px; }
.tab-btn {
    background: var(--card); color: var(--text-dim); border: 1px solid #475569;
    padding: 10px 25px; border-radius: 8px 8px 0 0; cursor: pointer; text-decoration: none;
}
.tab-btn.active { background: var(--accent); color: white; }

.form-header {
    background: var(--card); padding: 25px; border-radius: 0 12px 12px 12px;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px; margin-bottom: 30px; border: 1px solid #334155;
}
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-group label { font-size: 10px; color: var(--text-dim); font-weight: 800; }
.input-group input, .input-group select { background: var(--input); border: 1px solid #475569; color: white; padding: 12px; border-radius: 8px; }

.add-btn { grid-column: 1 / -1; background: var(--accent); color: white; border: none; padding: 16px; border-radius: 8px; font-weight: 700; cursor: pointer; }

.btn-container { display: flex; gap: 10px; justify-content: center; align-items: center; }
.btn-action {
    width: 36px; height: 36px; border-radius: 50%; border: none;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; background: rgba(255, 255, 255, 0.05); transition: 0.3s;
}
.btn-action.edit { color: var(--warning); }
.btn-action.delete { color: var(--danger); }

/* On s'assure que le badge reste propre à l'intérieur du TD */
.badge { 
    display: inline-block; 
    padding: 6px 12px; 
    border-radius: 8px; 
    font-size: 11px; 
    font-weight: 800; 
    text-transform: uppercase;
    white-space: nowrap !important; /* Pas de retour à la ligne dans le badge */
}

.badge-status { background: rgba(16, 185, 129, 0.15); color: var(--success); border: 1px solid var(--success); }
.badge-final-wait { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid #60a5fa; }

.modal {
    display: none;             /* Caché par défaut */
    position: fixed !important; /* Fixé par rapport à l'écran, pas à la page */
    z-index: 9999 !important;   /* Par-dessus tout le reste */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8) !important; /* Fond noir transparent */
    backdrop-filter: blur(4px); /* Flou d'arrière-plan */
}

.modal-content {
    background-color: var(--card);
    margin: 5% auto;           /* Centré verticalement et horizontalement */
    padding: 25px;
    border: 1px solid var(--accent);
    width: 90%;
    max-width: 600px;
    border-radius: 15px;
    position: relative;        /* Pour placer la croix de fermeture */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.close {
    position: absolute;
    right: 20px;
    top: 10px;
    color: var(--text-dim);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: white;
}