/* ============================================================
   EVIATRANS — design system 2026
   ============================================================ */
:root {
    --bg: #f4f6fc;
    --surface: #ffffff;
    --surface-2: #f6f8fd;
    --border: #ebedf5;
    --border-strong: #dde1ec;
    --ink: #0b1220;
    --ink-soft: #3a4252;
    --muted: #7b87a0;
    --accent: #4f46e5;
    --accent-2: #7c75f5;
    --accent-ink: #ffffff;
    --accent-soft: #eef0ff;
    --grad: linear-gradient(135deg, #6366f1 0%, #4f46e5 55%, #7c3aed 100%);
    --green: #16a34a; --green-bg: #dcfce7;
    --red: #e5384f; --red-bg: #ffe4e7;
    --amber: #d97706; --amber-bg: #fef3c7;
    --blue: #2563eb; --blue-bg: #e3e9ff;
    --radius: 18px;
    --radius-sm: 12px;
    --radius-xs: 9px;
    --shadow-sm: 0 1px 2px rgba(11,18,32,.04), 0 2px 6px rgba(11,18,32,.05);
    --shadow: 0 8px 28px rgba(11,18,32,.08);
    --shadow-lg: 0 24px 60px rgba(11,18,32,.18);
    --ring: 0 0 0 3px rgba(124,117,245,.32);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: "Inter", "SF Pro Text", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(900px 480px at 100% -5%, rgba(124,117,245,.10), transparent 60%),
        radial-gradient(700px 420px at -10% 8%, rgba(99,102,241,.08), transparent 55%),
        var(--bg);
    background-attachment: fixed;
    font-size: 14px;
    line-height: 1.55;
    letter-spacing: -.005em;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3 { font-weight: 800; }

a { color: var(--accent); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--accent-2); }

h1, h2, h3 { color: var(--ink); letter-spacing: -.01em; }

::selection { background: rgba(99,102,241,.2); }

/* Scrollbars discrets */
* { scrollbar-width: thin; scrollbar-color: #c3cad8 transparent; }
*::-webkit-scrollbar { height: 10px; width: 10px; }
*::-webkit-scrollbar-thumb { background: #c8cfdd; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }

.app { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
    width: 248px; flex: none;
    background: linear-gradient(180deg, #0c1426 0%, #111b31 60%, #0e1830 100%);
    color: #b9c3d6;
    display: flex; flex-direction: column;
    padding: 20px 14px;
    position: sticky; top: 0; height: 100vh;
    border-right: 1px solid #1c2740;
}
.brand {
    margin: 2px 4px 22px;
    display: flex; align-items: center; justify-content: center;
    background: #fff; border-radius: 14px; padding: 12px 14px;
    box-shadow: 0 6px 18px rgba(0,0,0,.22);
}
.brand img { height: 46px; width: auto; max-width: 100%; display: block; }
.nav { list-style: none; margin: 0; padding: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.nav li.sep { height: 1px; background: #202c46; margin: 12px 12px; }
.nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: var(--radius-sm);
    color: #aab4c8; font-weight: 500;
    transition: background .15s ease, color .15s ease;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active {
    background: linear-gradient(90deg, rgba(124,117,245,.34), rgba(124,117,245,.10));
    color: #fff; box-shadow: inset 3px 0 0 var(--accent-2), 0 6px 18px rgba(99,102,241,.22);
}

.user-box { padding: 14px 12px 4px; border-top: 1px solid #202c46; margin-top: 12px; }
.user-name { color: #fff; font-weight: 600; }
.user-role {
    color: #93a0b8; font-size: 11px; margin: 2px 0 10px;
    text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
}
.logout { color: #93a0b8; font-size: 13px; font-weight: 500; }
.logout:hover { color: #fff; }

/* ---- Main ---- */
.main { flex: 1; padding: 30px 38px; max-width: 1320px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 28px; font-weight: 800; margin: 0; letter-spacing: -.025em; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 16px; border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink-soft);
    cursor: pointer; font-size: 14px; font-weight: 600; line-height: 1;
    transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .05s ease;
    box-shadow: var(--shadow-sm);
}
.btn:hover { border-color: #b9c1d2; background: #fff; }
.btn:active { transform: translateY(1px); }
.dispatch-legende { display: flex; flex-wrap: wrap; gap: 14px; margin: 0 0 12px; font-size: 12px; color: #475569; }
.dispatch-legende span { display: inline-flex; align-items: center; gap: 6px; }
.dispatch-legende i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.dispatch-legende .legende-edit { color: var(--accent, #4f46e5); font-weight: 600; }

.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary {
    background: var(--grad); background-size: 140% 140%; color: var(--accent-ink);
    border-color: transparent; box-shadow: 0 6px 18px rgba(79,70,229,.32);
}
.btn-primary:hover { background-position: 100% 100%; box-shadow: 0 8px 24px rgba(79,70,229,.42); transform: translateY(-1px); }
.opt-input { padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-xs); font: inherit; min-width: 220px; }
.opt-input:focus { outline: none; box-shadow: var(--ring); border-color: var(--accent-2); }
.btn-danger { color: var(--red); border-color: #f4c9d1; background: #fff; }
.btn-danger:hover { background: var(--red-bg); border-color: #f0a9b6; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: var(--radius-xs); }
/* Bouton « Nouvelle commande » du Dispatch : indigo plein, « + » en pastille, survol sobre. */
.btn-nouvelle {
    display: inline-flex; align-items: center; gap: 9px;
    padding: 10px 18px 10px 13px; border: none; border-radius: 11px;
    background: var(--accent); color: #fff; font-size: 14px; font-weight: 600; line-height: 1;
    cursor: pointer; box-shadow: 0 2px 6px rgba(79,70,229,.28);
    transition: background .15s ease, box-shadow .15s ease, transform .08s ease;
}
.btn-nouvelle:hover { background: #4338ca; box-shadow: 0 6px 18px rgba(79,70,229,.34); transform: translateY(-1px); }
.btn-nouvelle:active { transform: translateY(0); box-shadow: 0 2px 6px rgba(79,70,229,.28); }
.btn-nouvelle:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft), 0 6px 18px rgba(79,70,229,.34); }
.btn-nouvelle-plus {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border-radius: 50%;
    background: rgba(255,255,255,.22); font-size: 17px; font-weight: 700;
}
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; box-shadow: none; filter: grayscale(.3); }
.btn-primary:disabled, .btn-primary[disabled] { background: #b9bdf0; }

/* ---- Toolbar ---- */
.toolbar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=search], .toolbar select {
    padding: 9px 13px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); font-size: 14px; color: var(--ink); transition: box-shadow .15s, border-color .15s;
}
.toolbar input[type=search] { min-width: 260px; }
.toolbar input[type=search]:focus, .toolbar select:focus { outline: none; border-color: var(--accent-2); box-shadow: var(--ring); }
.toolbar-field { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.toolbar-field input[type=date] {
    padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); font-size: 14px; color: var(--ink);
}
.toolbar-check { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; color: var(--ink); cursor: pointer; user-select: none; }
.toolbar-check input { width: 16px; height: 16px; }

/* ---- Cards ---- */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px;
    box-shadow: var(--shadow-sm); transition: box-shadow .18s ease, transform .12s ease, border-color .18s;
}
.card:hover { box-shadow: var(--shadow); transform: translateY(-1px); border-color: var(--border-strong); }
.card .meta { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.card .line1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card .line2 { color: var(--muted); font-size: 13px; }
.card .ref { font-weight: 700; color: var(--ink); }
.card .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* ---- Missions terminées (appli conducteur) : masquées par défaut, réaffichables ---- */
.show-done-input { position: absolute; opacity: 0; width: 0; height: 0; }
.show-done-label {
    display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
    margin-bottom: 14px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface); color: var(--muted); font-size: 14px; box-shadow: var(--shadow-sm);
}
.show-done-label::before { content: '☐'; font-size: 16px; }
.show-done-input:checked ~ .show-done-label { color: var(--ink); border-color: var(--border-strong); }
.show-done-input:checked ~ .show-done-label::before { content: '☑'; }
.show-done-input:focus-visible ~ .show-done-label { outline: 2px solid var(--accent); outline-offset: 2px; }
.card--terminee { display: none; }
.show-done-input:checked ~ .list .card--terminee { display: flex; }

/* ---- Listes en grille de tuiles (2026) ---- */
.list { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 16px; }
.list .card {
    position: relative;
    flex-direction: column; align-items: stretch; justify-content: flex-start;
    gap: 14px; padding: 18px;
}
.list .card .meta { gap: 7px; flex: 1; }
.list .card .line1 { padding-right: 38px; } /* réserve la place de l'œil en haut à droite */
.list .card .line1 .ref { font-size: 16px; }

/* Œil « voir dans le Dispatch » — bouton rond en haut à droite de la carte. */
.card-eye {
    position: absolute; top: 12px; right: 12px; z-index: 2;
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--surface); color: var(--accent); border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: background .15s, color .15s, transform .12s ease, box-shadow .15s, border-color .15s;
}
.card-eye svg { display: block; }
.card-eye:hover {
    background: var(--accent); color: #fff; border-color: var(--accent);
    transform: translateY(-1px) scale(1.06); box-shadow: var(--shadow);
}
.card-eye:active { transform: scale(.96); }
.list .card .actions {
    justify-content: flex-start; margin-top: auto;
    border-top: 1px solid var(--border); padding-top: 14px;
}
.list .card .actions form { display: inline-flex; }

/* ---- Badges ---- */
.badge {
    display: inline-flex; align-items: center; padding: 4px 11px; border-radius: 999px;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    border: 1px solid transparent;
}
.badge-encours   { background: var(--blue-bg); color: #3730a3; }
.badge-programme { background: #eef1f6; color: #475569; }
.badge-valide    { background: var(--blue-bg); color: var(--blue); }
.badge-livre     { background: var(--green-bg); color: #166534; }
.badge-finalisee { background: var(--green-bg); color: #166534; }
.badge-annulee   { background: var(--red-bg); color: #be123c; }

/* ---- Forms ---- */
.form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px; max-width: 760px; box-shadow: var(--shadow-sm); }
.form h3 { margin: 6px 0 14px; font-size: 15px; }
.form hr { border: none; border-top: 1px solid var(--border); margin: 22px 0; }
.form .row { margin-bottom: 17px; }
.form label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; color: var(--ink-soft); }
.form .req::after { content: " *"; color: var(--red); }
.form input[type=text], .form input[type=email], .form input[type=password],
.form input[type=number], .form input[type=date], .form select, .form textarea {
    width: 100%; padding: 10px 13px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    font-size: 14px; background: var(--surface); color: var(--ink); font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--accent-2); box-shadow: var(--ring); }
.form textarea { min-height: 96px; resize: vertical; }
.form .toggle { display: flex; align-items: center; gap: 9px; font-weight: 500; }
.form .toggle input { width: auto; accent-color: var(--accent); width: 17px; height: 17px; }
.form .toggle label { margin: 0; font-weight: 500; color: var(--ink); }
.form .actions { display: flex; gap: 10px; margin-top: 8px; }
.form .help { color: var(--muted); font-size: 12px; margin-top: 4px; }
.field-error, .form .help.error { color: var(--red); font-size: 13px; margin-top: 4px; }
.form .field-error { display: inline-block; margin-left: 6px; }

/* ---- Flash ---- */
.flash { padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-weight: 500; border: 1px solid transparent; }
.flash-success { background: var(--green-bg); color: #166534; border-color: #bbf7d0; }
.flash-error { background: var(--red-bg); color: #be123c; border-color: #fecdd3; }
.flash-notice { background: var(--surface-2); color: var(--ink-soft); border-color: var(--border); }

.empty { color: var(--muted); padding: 48px; text-align: center; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); }

/* ---- Login ---- */
.login-wrap {
    display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px;
    background: radial-gradient(1200px 600px at 20% -10%, #2a2f6e 0%, transparent 55%),
                radial-gradient(900px 500px at 110% 110%, #3b2f74 0%, transparent 50%),
                linear-gradient(135deg, #0c1426, #131b33);
}
.login-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 22px;
    padding: 38px 34px; width: 380px; box-shadow: var(--shadow-lg);
}
.login-card h1 { font-size: 24px; margin: 0 0 22px; text-align: center; font-weight: 800; }
.login-logo { display: block; margin: 4px auto 24px; width: 168px; max-width: 70%; height: auto; }
.login-card .form { border: none; padding: 0; box-shadow: none; max-width: none; background: transparent; }
.login-card .btn-primary { width: 100%; padding: 11px; }

/* Connexion rapide */
.quick-login { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.quick-login-title { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 11px; text-align: center; font-weight: 700; }
.quick-login-buttons { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.quick-login-buttons .btn { justify-content: center; }

/* ---- Chart (chantier) ---- */
.chart { display: flex; gap: 16px; align-items: flex-end; padding: 14px 0; min-height: 170px; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 5px; text-decoration: none; color: inherit; cursor: pointer; }
a.bar-col:hover .bar { filter: brightness(1.08); box-shadow: 0 3px 12px rgba(79, 70, 229, .4); }
a.bar-col:hover .bar-lbl { color: var(--ink); }
.bar { width: 36px; background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-radius: 7px 7px 3px 3px; min-height: 4px; box-shadow: 0 2px 8px rgba(79,70,229,.25); }
.bar-val { font-weight: 700; font-size: 12px; }
.bar-lbl { font-size: 11px; color: var(--muted); }

/* ---- Admin index ---- */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.admin-tile {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow-sm);
    text-decoration: none; color: inherit;
    transition: box-shadow .18s ease, transform .14s ease, border-color .18s ease;
}
.admin-tile:hover { box-shadow: var(--shadow); transform: translateY(-3px); border-color: var(--border-strong); }
.admin-ico {
    width: 46px; height: 46px; border-radius: 13px; margin-bottom: 6px;
    display: inline-flex; align-items: center; justify-content: center; font-size: 22px;
    color: #fff; box-shadow: 0 8px 18px rgba(11,18,32,.16);
}
.admin-tile h3 { margin: 0; font-size: 16px; color: var(--ink); }
.admin-desc { margin: 0; flex: 1; color: var(--muted); font-size: 13px; line-height: 1.45; }
.admin-open { margin-top: 10px; font-weight: 600; font-size: 13px; color: var(--accent); display: inline-flex; align-items: center; gap: 6px; }
.admin-open i { font-style: normal; transition: transform .14s ease; }
.admin-tile:hover .admin-open i { transform: translateX(4px); }

/* ---- Tables ---- */
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
table.grid th, table.grid td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); }
table.grid th { background: var(--surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; }
table.grid tbody tr { transition: background .12s; }
table.grid tbody tr:hover { background: var(--surface-2); }
table.grid tr:last-child td { border-bottom: none; }
/* Ligne d'un compte désactivé : grisée, dernière colonne « Statut » en rouge. */
table.grid tbody tr.row-inactive { opacity: .6; background: var(--surface-2); }
table.grid tbody tr.row-inactive td:nth-last-child(2) { color: var(--danger, #dc2626); font-weight: 600; }

/* ---- Dispatch ---- */
.dispatch-daynav { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; box-shadow: var(--shadow-sm); }
.dispatch-daynav strong { font-size: 15px; }
.dispatch-daynav .line2 { color: var(--muted); font-size: 12.5px; margin-left: auto; }

/* Champ-date (flatpickr) du Dispatch */
.datenav-input {
    cursor: pointer; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    padding: 8px 14px 8px 38px; font: inherit; font-weight: 700; color: var(--ink); min-width: 210px;
    text-transform: capitalize;
    background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234f46e5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E") no-repeat 13px center;
}
.datenav-input:hover { border-color: var(--accent-2); background-color: var(--accent-soft); }
.datenav-input:focus { outline: none; box-shadow: var(--ring); border-color: var(--accent-2); }

/* Thème flatpickr accordé à l'accent indigo */
.flatpickr-calendar { border-radius: 14px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); font-family: inherit; }
.flatpickr-day.selected, .flatpickr-day.selected:hover { background: var(--accent); border-color: var(--accent); }
.flatpickr-day.today { border-color: var(--accent-2); }
.flatpickr-day:hover { background: var(--accent-soft); border-color: var(--accent-soft); }
.flatpickr-months .flatpickr-month, .flatpickr-current-month, .flatpickr-weekday { color: var(--ink); fill: var(--ink); }
.flatpickr-monthDropdown-months, .numInputWrapper { color: var(--ink); }
.col-head { padding: 12px 14px; font-weight: 700; font-size: 13px; }

.gantt-wrap { display: flex; gap: 16px; align-items: flex-start; }
/* « À programmer » : barre horizontale en haut du dispatch (cartes en ligne, défilables). */
.dispatch-pool { display: flex; align-items: center; gap: 12px; width: 100%; box-sizing: border-box; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; box-shadow: var(--shadow-sm); margin-bottom: 14px; }
.dispatch-pool .col-head { flex: none; padding: 0; white-space: nowrap; }
.pool-cards { display: flex; gap: 8px; overflow-x: auto; flex: 1; min-width: 0; padding: 2px; }
.pool-cards .tour-card { flex: 0 0 auto; width: 190px; margin-bottom: 0; }
.pool-cards .line2 { white-space: nowrap; }
.gantt { flex: 1; overflow: auto; max-height: calc(100vh - 200px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.gantt-head, .gantt-row { display: grid; }
/* En-tête figé en haut */
.gantt-head { background: var(--surface-2); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.gantt-cellhead { padding: 8px 2px; font-size: 11px; color: var(--muted); grid-row: 1; text-align: center; }
.gantt-cellhead.pleine { font-weight: 700; color: var(--ink-soft); border-left: 1px solid var(--border); }
/* Première colonne (chauffeurs) figée à gauche */
.gantt-rowhead { padding: 8px 12px; font-size: 14px; font-weight: 600; border-left: 1px solid var(--border); grid-column: 1; position: sticky; left: 0; z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.gantt-head .gantt-rowhead { z-index: 6; }
.gantt-row { border-top: 1px solid var(--border); min-height: 72px; position: relative; }
.gantt-row:hover { background: rgba(99,102,241,.02); }
.gantt-rowhead { background: var(--surface-2); cursor: grab; }
.rh-name { display: flex; align-items: flex-start; gap: 6px; min-width: 0; }
.rh-grip { color: var(--muted); line-height: 1.3; }
.rh-ident { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.rh-ident > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rh-prenom { font-weight: 600; }
.rh-nom { font-weight: 600; text-transform: uppercase; }
.rh-transporteur { font-size: 11px; font-weight: 500; color: var(--muted); }
.rh-hide { border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; padding: 2px 5px; border-radius: 6px; line-height: 1; }
.rh-hide:hover { color: var(--red); background: var(--red-bg); }
.gantt-cell { border-left: 1px solid #f1f3f8; min-height: 72px; grid-row: 1; }
.gantt-cell.pleine { border-left: 1px solid var(--border); }
.gantt-cell.drop-hover { background: var(--accent-soft); outline: 2px dashed var(--accent-2); outline-offset: -2px; }

/* ---- Cartes tour/commande ---- */
.tour-card {
    background: linear-gradient(180deg, #eef1ff, #e6e9ff); border: 1px solid #cdd2fb; border-radius: var(--radius-xs);
    padding: 7px 10px; margin-bottom: 7px; cursor: grab; font-size: 11px; box-shadow: var(--shadow-sm);
    transition: box-shadow .15s, transform .1s;
}
.tour-card:hover { box-shadow: var(--shadow); }
.tour-card.placed { background: linear-gradient(180deg, #e7f8ee, #d8f3e3); border-color: #b7e6c9; margin: 4px 2px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; align-self: stretch; display: flex; align-items: center; font-size: 10px; cursor: pointer; }
.tour-card.placed > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tour-card.placed .tc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 1px; overflow: hidden; }
.tour-card.placed .tc-body > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.15; }
.tour-card.placed .tc-main { font-weight: 700; }
.tour-card.placed .tc-line { font-size: 9px; font-weight: 500; opacity: .82; }
.tour-card.dragging { opacity: .45; }
.tour-card a { color: var(--ink); font-weight: 700; }
.tour-card .tc-sub { color: var(--muted); font-weight: 500; margin-top: 2px; }
/* Surbrillance d'une commande ciblée depuis l'œil de la liste des commandes. */
.tour-card.tour-focus { outline: 3px solid #ff9800; outline-offset: 1px; z-index: 6 !important; animation: tour-focus-pulse 1s ease-in-out 3; }
@keyframes tour-focus-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(255, 152, 0, .35), var(--shadow); }
    50% { box-shadow: 0 0 0 8px rgba(255, 152, 0, .12), var(--shadow); }
}

/* Filtres actifs (chips) sur la liste des commandes. */
.filters-active { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 10px; }
.filters-active .chip { background: var(--surface-2, #eef1ff); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; color: var(--ink); }
.filters-active .chip-clear { font-size: 12px; color: var(--muted); text-decoration: none; }
.filters-active .chip-clear:hover { color: var(--ink); text-decoration: underline; }

@media (max-width: 820px) {
    .app { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; }
    .nav { flex-direction: row; flex-wrap: wrap; flex: 1; }
    .nav li.sep { display: none; }
    .user-box { border-top: none; margin: 0; padding: 0; }
    .main { padding: 20px 16px; }
}

/* ---- Poignée de redimensionnement (durée) sur le Gantt ---- */
.gantt-row .tour-card.placed { position: relative; padding-right: 14px; }
.resize-handle { position: absolute; top: 0; right: 0; width: 12px; height: 100%; cursor: ew-resize; display: flex; align-items: center; justify-content: center; }
.resize-handle::after { content: ''; width: 3px; height: 60%; border-radius: 3px; background: rgba(15,23,41,.28); }
.resize-handle:hover::after { background: var(--accent); }
/* Coupure déjeuner : créneau « en blanc » au milieu de la barre, déduit de la facturation. */
/* Barre d'outils Dispatch + pastille « Pause déjeuner » glissable */
.dispatch-tools { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.pause-chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; background: #fff; border: 1px dashed var(--border-strong); border-radius: 999px; font-size: 13px; font-weight: 700; cursor: grab; box-shadow: var(--shadow-sm); user-select: none; }
.pause-chip:hover { border-color: var(--accent-2); }
.pause-chip:active { cursor: grabbing; }
.tour-coupure { position: absolute; top: 0; bottom: 0; background: #fff; border-left: 1px dashed rgba(15,23,41,.35); border-right: 1px dashed rgba(15,23,41,.35); opacity: .95; pointer-events: none; z-index: 1; display: flex; align-items: center; justify-content: center; font-size: 8px; font-weight: 700; letter-spacing: .3px; color: rgba(15,23,41,.7); white-space: nowrap; }
/* Bande de coupure éditable (dispatch admin) : déplaçable au grab, étirable par les bords. */
.tour-coupure.editable { pointer-events: auto; cursor: grab; user-select: none; }
.tour-coupure.editable:active { cursor: grabbing; }
.coupure-handle { position: absolute; top: 0; bottom: 0; width: 7px; cursor: ew-resize; }
.coupure-handle.gauche { left: 0; }
.coupure-handle.droite { right: 0; }
.coupure-handle::after { content: ''; position: absolute; top: 22%; bottom: 22%; left: 2px; width: 3px; border-radius: 3px; background: rgba(15,23,41,.22); }
.tour-coupure.editable:hover .coupure-handle::after { background: var(--accent); }

/* Infobulle détaillée d'une barre du dispatch (attachée au body, jamais clippée). */
.tour-tip {
    position: fixed; z-index: 1000; display: none; pointer-events: none;
    background: var(--surface, #fff); color: var(--ink, #13203a);
    border: 1px solid var(--border-strong, #cbd5e1); border-radius: 10px;
    box-shadow: 0 10px 34px rgba(15, 23, 41, .20);
    padding: 10px 12px; font-size: 12px; line-height: 1.5; max-width: 380px;
}
.tour-tip-h { font-weight: 800; font-size: 13px; margin-bottom: 6px; padding-bottom: 5px; border-bottom: 1px solid var(--border, #e2e8f0); }
.tour-tip-r { display: flex; gap: 8px; }
.tour-tip-l { color: var(--muted, #64748b); min-width: 84px; font-weight: 600; }
.tour-tip-v { flex: 1; }


/* Bloc infos (lecture seule) en tête de la popup de pesée (bascule). */
.bascule-infos { background: var(--surface-2, #f4f6fb); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; margin-bottom: 12px; }
.bascule-infos .row { display: flex; gap: 8px; padding: 2px 0; }
.bascule-infos .row label { min-width: 130px; color: var(--muted); font-weight: 600; }
.bascule-infos .row span { font-weight: 600; }

/* Menu contextuel (clic droit) sur une carte du dispatch (attaché au body). */
.ctx-menu {
    position: fixed; z-index: 1001; display: none;
    background: var(--surface, #fff); border: 1px solid var(--border-strong, #cbd5e1);
    border-radius: 10px; box-shadow: 0 10px 34px rgba(15, 23, 41, .20); padding: 4px;
}
.ctx-item { display: block; width: 100%; border: none; background: transparent; text-align: left; padding: 8px 12px; font-size: 13px; font-weight: 600; color: var(--ink, #13203a); border-radius: 7px; cursor: pointer; white-space: nowrap; }
.ctx-item:hover { background: var(--accent-soft, #eef1ff); }

/* Prévisualisation de la zone de dépôt (durée du transport) sur le Gantt */
.gantt-cell.preview { background: rgba(99,102,241,.18); box-shadow: inset 0 0 0 1px var(--accent-2); }

/* Dispatch / planning : utiliser toute la largeur de l'écran */
.main:has(.gantt) { max-width: none; }

/* ---- Planning chauffeur : frise verticale mobile (cachée sur grand écran) ---- */
.planning-list { display: none; flex-direction: column; gap: 10px; }
.pl-item { display: flex; gap: 14px; align-items: stretch; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); text-decoration: none; color: var(--ink); }
.pl-item:active { background: var(--accent-soft); border-color: var(--accent-2); }
.pl-time { display: flex; flex-direction: column; justify-content: center; min-width: 62px; padding-right: 14px; border-right: 2px solid var(--accent-soft); }
.pl-time strong { font-size: 22px; line-height: 1.1; color: var(--accent); }
.pl-end { font-size: 12px; color: var(--muted); margin-top: 3px; }
.pl-body { display: flex; flex-direction: column; justify-content: center; gap: 4px; min-width: 0; }
.pl-title { font-weight: 700; font-size: 15px; line-height: 1.3; }
.pl-sub { font-size: 13px; color: var(--ink-soft); }
.pl-go { font-size: 12px; color: var(--accent); font-weight: 600; }

@media (max-width: 820px) {
    .planning-list { display: flex; }
    /* On masque uniquement le Gantt de la page planning (pas le Dispatch admin) */
    .planning-list ~ .gantt, .gantt-only { display: none; }
    /* Nav du jour plus tactile sur téléphone */
    .dispatch-daynav { flex-wrap: wrap; gap: 8px; }
    .dispatch-daynav .btn-sm { padding: 10px 14px; font-size: 14px; }
}

/* ---- Tom Select : couleurs/bords seulement (on laisse la disposition au thème par défaut) ---- */
.ts-wrapper { width: 100%; }
.ts-control { border-color: var(--border-strong); border-radius: var(--radius-sm); min-height: 42px; background: var(--surface); }
.ts-wrapper.single .ts-control { flex-wrap: nowrap; padding-top: 2px; padding-bottom: 2px; }
.ts-wrapper.single .ts-control > input { flex: 1 1 auto; min-width: 30px; }
.ts-wrapper.single .ts-control > .item { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ts-wrapper.focus .ts-control { border-color: var(--accent-2); box-shadow: var(--ring); }
.ts-dropdown { border-color: var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow); margin-top: 4px; overflow: hidden; }
.ts-dropdown .active { background: var(--accent-soft); color: var(--ink); }
.ts-dropdown .option.selected { font-weight: 600; }
.ts-wrapper.disabled .ts-control { background: var(--surface-2); }

/* ---- Modale (saisie immat au dépôt) ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,41,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--surface); border-radius: var(--radius); padding: 24px; width: 420px; max-width: 92vw; box-shadow: var(--shadow-lg); }
.modal h3 { margin: 0 0 14px; }
.modal .row { margin-bottom: 14px; }
.modal label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
.modal select { width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 14px; background: var(--surface); }
.modal .actions { display: flex; gap: 10px; margin-top: 4px; }
/* Popup large (formulaire complet) avec en-tête fixe et corps défilant */
.modal-lg { width: 760px; max-width: 94vw; max-height: 90vh; padding: 0; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; }
.modal-close { border: none; background: transparent; font-size: 18px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.modal-close:hover { color: var(--red); background: var(--red-bg); }
.modal-body { overflow-y: auto; min-height: 0; padding: 20px 24px; }
/* Dans la popup, le formulaire occupe toute la largeur disponible. */
.modal-body .form { max-width: none; border: none; padding: 0; box-shadow: none; background: transparent; }
.modal-loading { padding: 30px; text-align: center; color: var(--muted); }
/* En-tête de page avec action à droite */
.page-head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Ligne « Ajouter un chauffeur » en bas du Gantt */
.gantt-addrow { border-top: 1px solid var(--border); padding: 12px 14px; background: var(--surface-2); position: sticky; left: 0; }
.gantt-addrow form { display: flex; gap: 10px; align-items: center; }
.gantt-addrow span { font-weight: 600; color: var(--ink-soft); }
.gantt-addrow select { padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }

/* Apparition douce du contenu (2026) */
/* Fondu d'apparition. Volontairement SANS transform : une animation de
   transform sur .main > * ferait de cet élément un bloc conteneur pour les
   position:fixed (la popup .modal-overlay serait piégée au lieu de couvrir
   tout l'écran). */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.main > * { animation: fadeIn .26s ease both; }
@media (prefers-reduced-motion: reduce) { .main > * { animation: none; } }
