/* ==========================================================================
   MadaMoov — feuille de style
   Sobre et lisible : palette neutre + une couleur d'accent, bordures fines,
   chiffres alignés, contraste élevé (lecture en plein soleil), zones tactiles
   de 48 px. Thème clair / sombre par variables CSS.

   1. Variables (clair, sombre)       8. Tableaux
   2. Base                            9. Indicateurs (tableau de bord) et filtres
   3. Gabarit : sidebar et contenu   10. Listes, historique, récapitulatifs
   4. En-têtes de page               11. Écrans chauffeur
   5. Boutons                        12. Fiche voyage (admin)
   6. Formulaires                    13. Connexion et erreurs
   7. Messages, badges, cartes       14. Utilitaires
   ========================================================================== */

/* 1. Variables ============================================================ */

:root {
    color-scheme: light;

    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-muted: #f1f3f6;
    --surface-hover: #eef1f5;
    --border: #e1e4e9;
    --border-strong: #c7cdd5;

    --text: #15181d;
    --text-muted: #4f5866;
    --text-subtle: #6a7381;

    --accent: #1f4e8c;
    --accent-hover: #183f72;
    --accent-text: #1f4e8c;
    --accent-soft: #e7eef8;
    --on-accent: #ffffff;

    --success: #1d7349;
    --success-soft: #e5f3eb;
    --warning: #8a5000;
    --warning-soft: #fbf0dc;
    --warning-border: #e3ad55;
    --danger: #b3261e;
    --danger-soft: #fbe9e8;
    --on-danger: #ffffff;
    --success-border: #a8d5bc;
    --danger-border: #efb4af;
    --accent-border: #b7cbe6;

    --sidebar-bg: #ffffff;
    --sidebar-text: #3b4350;
    --overlay: rgb(15 20 28 / 0.45);
    --shadow-overlay: 0 16px 40px rgb(15 20 28 / 0.18);
    --focus-ring: 0 0 0 3px rgb(31 78 140 / 0.3);

    --radius-sm: 6px;
    --radius: 8px;
    --tap: 48px;
    --sidebar-w: 256px;
    --topbar-h: 56px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Sombre : choisi explicitement, ou réglage du système si aucun choix n'est mémorisé. */
:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0e1116;
    --surface: #161a21;
    --surface-muted: #1b2029;
    --surface-hover: #1f2530;
    --border: #272e39;
    --border-strong: #38414d;

    --text: #e8ebef;
    --text-muted: #a5aebb;
    --text-subtle: #8a93a0;

    --accent: #3a6cb2;
    --accent-hover: #4a7cc3;
    --accent-text: #8fb6ec;
    --accent-soft: rgb(88 140 212 / 0.16);
    --on-accent: #ffffff;

    --success: #5fc592;
    --success-soft: rgb(62 170 112 / 0.15);
    --warning: #f0b45c;
    --warning-soft: rgb(240 172 72 / 0.13);
    --warning-border: #8a6327;
    --danger: #f27d74;
    --danger-soft: rgb(232 92 82 / 0.15);
    --on-danger: #1a0907;
    --success-border: rgb(95 197 146 / 0.35);
    --danger-border: rgb(242 125 116 / 0.35);
    --accent-border: rgb(143 182 236 / 0.3);

    --sidebar-bg: #12161c;
    --sidebar-text: #b9c1cc;
    --overlay: rgb(0 0 0 / 0.6);
    --shadow-overlay: 0 16px 40px rgb(0 0 0 / 0.55);
    --focus-ring: 0 0 0 3px rgb(143 182 236 / 0.35);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        --bg: #0e1116;
        --surface: #161a21;
        --surface-muted: #1b2029;
        --surface-hover: #1f2530;
        --border: #272e39;
        --border-strong: #38414d;

        --text: #e8ebef;
        --text-muted: #a5aebb;
        --text-subtle: #8a93a0;

        --accent: #3a6cb2;
        --accent-hover: #4a7cc3;
        --accent-text: #8fb6ec;
        --accent-soft: rgb(88 140 212 / 0.16);
        --on-accent: #ffffff;

        --success: #5fc592;
        --success-soft: rgb(62 170 112 / 0.15);
        --warning: #f0b45c;
        --warning-soft: rgb(240 172 72 / 0.13);
        --warning-border: #8a6327;
        --danger: #f27d74;
        --danger-soft: rgb(232 92 82 / 0.15);
        --on-danger: #1a0907;
        --success-border: rgb(95 197 146 / 0.35);
        --danger-border: rgb(242 125 116 / 0.35);
        --accent-border: rgb(143 182 236 / 0.3);

        --sidebar-bg: #12161c;
        --sidebar-text: #b9c1cc;
        --overlay: rgb(0 0 0 / 0.6);
        --shadow-overlay: 0 16px 40px rgb(0 0 0 / 0.55);
        --focus-ring: 0 0 0 3px rgb(143 182 236 / 0.35);
    }
}

/* 2. Base ================================================================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

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

/* Jeu d'icônes (layouts/_icons.php) : présent dans la page, jamais visible. Pas d'attribut style
   en ligne : la politique de sécurité (CSP) n'autorise que cette feuille de style. */
.icon-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* hidden doit toujours l'emporter, même sur un composant en display: flex (ex. .alert). */
[hidden] {
    display: none !important;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
    margin: 0;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

h2 {
    font-size: 1.05rem;
    font-weight: 650;
}

p {
    margin: 0;
}

a {
    color: var(--accent-text);
    text-underline-offset: 2px;
}

:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 1rem;
    z-index: 100;
    padding: 0.5rem 1rem;
    color: var(--on-accent);
    background: var(--accent);
    border-radius: var(--radius-sm);
}

.skip-link:focus {
    top: 1rem;
}

/* 3. Gabarit : sidebar et contenu ========================================= */

/* La sidebar reste fixe pendant le défilement de la page ; si elle est plus haute que
   l'écran, seule sa liste de rubriques défile, sans entraîner la page. */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-w);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--topbar-h);
    padding: 0 1rem 0 1.25rem;
    border-bottom: 1px solid var(--border);
}

.brand {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.brand span {
    color: var(--accent-text);
}

.sidebar-nav {
    flex: 1;
    min-height: 0; /* sans cela, la liste ne peut pas rétrécir ni défiler et le bas du menu sort de l'écran */
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.5rem 0.75rem 0.75rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.sidebar-head,
.sidebar-foot {
    flex-shrink: 0;
}

.sidebar-nav ul {
    display: grid;
    gap: 2px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.nav-group {
    padding: 0.85rem 0.75rem 0.3rem;
    font-size: 0.72rem;
    font-weight: 650;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    min-height: 40px;
    padding: 0.45rem 0.75rem;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--sidebar-text);
    text-align: left;
    text-decoration: none;
    background: none;
    border: 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.nav-link:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.nav-link.is-active {
    font-weight: 650;
    color: var(--accent-text);
    background: var(--accent-soft);
}

.nav-link .icon {
    color: currentColor;
    opacity: 0.85;
}

.nav-badge {
    min-width: 1.4rem;
    padding: 0 0.4rem;
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.4rem;
    color: var(--on-accent);
    text-align: center;
    background: var(--accent);
    border-radius: 999px;
}

/* Pastille d'alerte (ex. colis non récupérés depuis trop longtemps). */
.nav-badge-warning {
    color: var(--bg);
    background: var(--warning);
}

.sidebar-foot {
    display: grid;
    gap: 0.35rem;
    padding: 0.6rem 0.75rem 0.75rem;
    border-top: 1px solid var(--border);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.25rem 0 0.25rem 0.5rem;
}

.logout-form {
    margin-left: auto;
}

.foot-actions {
    display: flex;
    gap: 0.35rem;
}

.foot-link {
    display: inline-flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-width: 0;
    min-height: 36px;
    padding: 0.35rem 0.4rem;
    overflow: hidden;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--sidebar-text);
    white-space: nowrap;
    text-decoration: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.foot-link:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.foot-link.is-active {
    color: var(--accent-text);
    background: var(--accent-soft);
    border-color: var(--accent-border);
}

.foot-link .icon {
    width: 16px;
    height: 16px;
}

.avatar {
    display: grid;
    flex-shrink: 0;
    place-items: center;
    width: 36px;
    height: 36px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-text);
    background: var(--accent-soft);
    border-radius: 50%;
}

.user-chip-text {
    display: grid;
    min-width: 0;
    line-height: 1.3;
}

.user-chip-text strong {
    overflow: hidden;
    font-size: 0.9rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-chip-text small {
    font-size: 0.8rem;
    color: var(--text-subtle);
}

/* Icône du bouton de thème : lune en clair, soleil en sombre. */
.theme-icon-light {
    display: none;
}

:root[data-theme="dark"] .theme-icon-dark {
    display: none;
}

:root[data-theme="dark"] .theme-icon-light {
    display: inline-flex;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-icon-dark {
        display: none;
    }

    :root:not([data-theme="light"]) .theme-icon-light {
        display: inline-flex;
    }
}

.theme-icon-dark,
.theme-icon-light {
    align-items: center;
}

.theme-icon-dark {
    display: inline-flex;
}

.shell-body {
    min-height: 100vh;
    margin-left: var(--sidebar-w);
}

.topbar {
    display: none;
}

.content {
    max-width: 1200px;
    padding: 2rem 2rem 4rem;
    margin: 0 auto;
}

/* Colonne étroite (écrans chauffeur), centrée dans l'espace à droite de la sidebar. */
.content-narrow {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
    max-width: 720px;
}

.content > .alert {
    margin-bottom: 1.25rem;
}

.content-narrow > .alert {
    margin-bottom: 0;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    color: var(--text-muted);
    background: none;
    border: 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.icon-btn:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.icon-btn .icon {
    width: 22px;
    height: 22px;
}

.sidebar-close,
.sidebar-backdrop {
    display: none;
}

/* Téléphone et tablette : la sidebar devient un menu coulissant. */
@media (max-width: 1023px) {
    .sidebar {
        box-shadow: var(--shadow-overlay);
        transform: translateX(-105%);
        transition: transform 0.2s ease;
    }

    .sidebar:target,
    .menu-open .sidebar {
        transform: none;
    }

    /* Menu ouvert : la page derrière ne défile plus. */
    body.menu-open {
        overflow: hidden;
    }

    .sidebar-close {
        display: inline-grid;
    }

    /* Au doigt : zones d'appui plus hautes qu'à la souris. */
    .nav-link,
    .foot-link {
        min-height: 44px;
    }

    .sidebar:target ~ .sidebar-backdrop,
    .menu-open .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 30;
        display: block;
        background: var(--overlay);
    }

    .shell-body {
        margin-left: 0;
    }

    .topbar {
        position: sticky;
        top: 0;
        z-index: 20;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        height: var(--topbar-h);
        padding: 0 0.5rem;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
    }

    .topbar-title {
        flex: 1;
        overflow: hidden;
        font-weight: 650;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .brand-small {
        padding-right: 0.5rem;
        font-size: 1rem;
    }

    .content {
        padding: 1.25rem 1rem 3rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar {
        transition: none;
    }
}

/* 4. En-têtes de page ====================================================== */

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    margin-bottom: 1.5rem;
}

.page-header > div {
    display: grid;
    gap: 0.25rem;
}

.page-header > .header-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Grande section d'une page admin (ex. « À contrôler ») : titre, texte, tableau, actions. */
.page-section {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
}

.page-section > .section-head {
    flex-wrap: wrap;
    margin-bottom: 0;
}

.page-section + .page-section {
    margin-top: 2.25rem;
}

/* Titre de section au fil de la page (ex. « Historique » sous un formulaire). */
.content:not(.content-narrow) > h2 {
    margin: 2rem 0 0.75rem;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
}

.back-link:hover {
    color: var(--accent-text);
}

.back-link .icon {
    width: 16px;
    height: 16px;
}

/* Écrans chauffeur (colonne étroite en grille) : l'écart de la grille complète la marge. */
.content-narrow > .page-header {
    margin-bottom: 0.5rem;
}

/* 5. Boutons =============================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.55rem 1.1rem;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.12s, border-color 0.12s;
}

.btn-primary {
    color: var(--on-accent);
    background: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    color: var(--text);
    background: var(--surface);
    border-color: var(--border-strong);
}

.btn-secondary:hover {
    background: var(--surface-hover);
}

.btn-danger {
    color: var(--on-danger);
    background: var(--danger);
}

.btn-link {
    min-height: 36px;
    padding: 0.25rem 0;
    font-weight: 600;
    color: var(--accent-text);
    background: none;
    border: 0;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-small {
    min-height: 36px;
    padding: 0.3rem 0.75rem;
    font-size: 0.875rem;
}

.btn-large {
    min-height: 54px;
    font-size: 1.05rem;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.form-inline-end {
    text-align: center;
}

/* 6. Formulaires =========================================================== */

.form {
    display: grid;
    gap: 1.1rem;
}

.form-narrow {
    max-width: 560px;
}

/* Dans un formulaire, l'écart de la grille suffit sous le titre. */
.form > h2 {
    margin-bottom: 0;
}

.field {
    display: grid;
    gap: 0.4rem;
    min-width: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.field small {
    font-size: 0.85rem;
    font-weight: 400;
}

/* Un fieldset ne rétrécit pas sous son contenu par défaut : le champ fichier natif
   ferait déborder le formulaire sur téléphone. */
fieldset {
    min-width: 0;
    padding: 0;
    margin: 0;
    border: 0;
}

legend {
    padding: 0;
}

.field input,
.field select,
.field textarea,
.inline-form input {
    width: 100%;
    min-width: 0;
    min-height: var(--tap);
    padding: 0.65rem 0.8rem;
    font: inherit;
    font-size: 1rem; /* 16 px : évite le zoom automatique sur iPhone */
    font-weight: 400;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    transition: border-color 0.12s, box-shadow 0.12s;
}

/* Un texte indicatif ne doit jamais ressembler à une valeur saisie : plus pâle et en italique.
   Règle de l'application : pas d'exemple chiffré en placeholder, il passe en aide sous le champ. */
.field input::placeholder,
.field textarea::placeholder,
.inline-form input::placeholder {
    font-style: italic;
    color: var(--text-subtle);
    opacity: 0.7;
}

.field input:hover,
.field select:hover,
.field textarea:hover {
    border-color: var(--text-subtle);
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.inline-form input:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Champ en erreur : le message .field-error suit immédiatement le champ. */
.field input:has(+ .field-error),
.field select:has(+ .field-error) {
    border-color: var(--danger);
}

.field-error {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
    font-weight: 600 !important;
    color: var(--danger);
}

.field-static {
    font-weight: 400;
    color: var(--text-muted);
}

/* Envoi de photo (photo_input()) : zone en français à la place du champ natif, dont le texte
   suit la langue du navigateur. Le vrai champ, transparent, couvre toute la zone. */
.file-picker {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 56px;
    padding: 0.45rem;
    background: var(--surface-muted);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
}

.field .file-picker input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
    cursor: pointer;
    opacity: 0;
}

.file-picker:hover {
    border-color: var(--text-subtle);
}

.file-picker:focus-within {
    border-color: var(--accent);
    box-shadow: var(--focus-ring);
}

.file-picker-btn {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    gap: 0.45rem;
    min-height: 40px;
    padding: 0.45rem 0.9rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--on-accent);
    background: var(--accent);
    border-radius: var(--radius-sm);
}

.file-picker-btn .icon {
    width: 18px;
    height: 18px;
}

.file-picker-name {
    min-width: 0;
    overflow: hidden;
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Photo choisie : la zone passe au vert, le nom du fichier s'affiche (app.js). */
.file-picker.has-file {
    background: var(--success-soft);
    border-style: solid;
    border-color: var(--success-border);
}

.file-picker.has-file .file-picker-name {
    font-weight: 600;
    color: var(--success);
}

.file-picker:has(+ .field-error) {
    border-color: var(--danger);
}

.choice-group {
    display: grid;
    gap: 0.5rem;
}

.choice-group legend {
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.choice-group > .field {
    margin-top: 0.25rem;
}

.choice {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 56px;
    padding: 0.6rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    cursor: pointer;
}

.choice:hover {
    border-color: var(--text-subtle);
}

.choice:has(input:checked) {
    background: var(--accent-soft);
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.choice input,
.checkbox input {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
    accent-color: var(--accent);
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: var(--tap);
    font-size: 0.95rem;
}

/* Vérification du compteur (app.js) : avertissement neutre, le chauffeur corrige ou confirme. */
.km-warning {
    display: grid;
    gap: 0.6rem;
    padding: 0.9rem 1rem;
    font-size: 0.95rem;
    color: var(--text);
    background: var(--warning-soft);
    border: 1px solid var(--warning-border);
    border-radius: var(--radius);
}

.km-warning-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 700;
    color: var(--warning);
}

.km-warning-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.5rem;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-top: 0.25rem;
}

.inline-form {
    display: flex;
    gap: 0.4rem;
}

.inline-form input {
    width: 10rem;
    min-height: 36px;
    padding: 0.35rem 0.6rem;
    font-size: 0.9rem;
}

/* Dans un tableau, motif et bouton empilés : la colonne reste étroite. */
.table .inline-form {
    flex-direction: column;
    align-items: stretch;
    width: 10rem;
}

/* Formulaires repliables (« + Ajouter un colis »…) */
.add-form > summary,
.pickup > summary {
    list-style: none;
}

.add-form > summary::-webkit-details-marker,
.pickup > summary::-webkit-details-marker,
details.card > summary::-webkit-details-marker {
    display: none;
}

/* Bouton qui ouvre un formulaire (« + Ajouter un colis », « Remis au destinataire »…) : une fois
   ouvert, il ne doit plus ressembler à une action posée au milieu du contenu. Il devient un
   « ✕ Fermer » discret à droite ; le seul bouton d'action est celui qui valide le formulaire. */
details:not([open]) > summary .when-open,
details[open] > summary .when-closed {
    display: none;
}

.when-open {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.when-open .icon {
    width: 16px;
    height: 16px;
}

.add-form[open] > summary,
.pickup[open] > summary {
    justify-content: flex-end;
    width: 100%;
    min-height: 36px;
    padding: 0;
    font-size: 0.875rem;
    color: var(--text-muted);
    background: none;
    border-color: transparent;
}

.add-form[open] > summary:hover,
.pickup[open] > summary:hover {
    color: var(--text);
}

.add-form[open] > summary {
    margin-bottom: 0.5rem;
}

.add-form > p {
    margin-bottom: 1rem;
}

/* 7. Messages, badges, cartes ============================================= */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.8rem 1rem;
    font-size: 0.95rem;
    font-weight: 500;
    border: 1px solid;
    border-radius: var(--radius);
}

.alert .icon {
    margin-top: 1px;
}

.alert-success {
    color: var(--success);
    background: var(--success-soft);
    border-color: var(--success-border);
}

.alert-error {
    color: var(--danger);
    background: var(--danger-soft);
    border-color: var(--danger-border);
}

.alert-info {
    color: var(--accent-text);
    background: var(--accent-soft);
    border-color: var(--accent-border);
}

/* À traiter (ex. colis non récupérés) : signalement, jamais une erreur. */
.alert-warning {
    color: var(--warning);
    background: var(--warning-soft);
    border-color: var(--warning-border);
}

.badge .icon {
    width: 13px;
    height: 13px;
}

.alert a {
    margin-left: 0.25rem;
    font-weight: 650;
    color: inherit;
}

.info-box {
    padding: 0.8rem 1rem;
    font-size: 0.95rem;
    color: var(--text-muted);
    background: var(--surface-muted);
    border-radius: var(--radius);
}

/* Points à vérifier : signalement neutre, jamais une accusation. */
.flags {
    padding: 0.9rem 1rem;
    margin-bottom: 1.25rem;
    color: var(--warning);
    background: var(--warning-soft);
    border: 1px solid var(--warning-border);
    border-radius: var(--radius);
}

.flags ul {
    padding-left: 1.2rem;
    margin: 0.35rem 0 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.1rem 0.55rem;
    font-size: 0.78rem;
    font-weight: 650;
    line-height: 1.45;
    white-space: nowrap;
    border: 1px solid transparent;
    border-radius: 999px;
}

.badge-success {
    color: var(--success);
    background: var(--success-soft);
}

.badge-warning {
    color: var(--warning);
    background: var(--warning-soft);
}

.badge-danger {
    color: var(--danger);
    background: var(--danger-soft);
}

.badge-info {
    color: var(--accent-text);
    background: var(--accent-soft);
}

.badge-muted {
    color: var(--text-muted);
    background: var(--surface-muted);
    border-color: var(--border);
}

.badge-large {
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
}

.card,
.section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.card {
    padding: 1.25rem;
}

.section {
    padding: 1.1rem 1rem;
    /* Les ancres (#places, #colis…) ne passent pas sous les barres collantes. */
    scroll-margin-top: 7.5rem;
}

.card > h2,
.section > h2 {
    margin-bottom: 0.9rem;
}

/* Texte d'introduction d'une section suivi de son contenu */
.section > p + *,
.card > p + * {
    margin-top: 0.9rem;
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.9rem;
}

.counter {
    font-size: 1.1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.section-close {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

details.card > summary {
    display: flex;
    align-items: center;
    min-height: 28px;
    font-weight: 650;
    list-style: none;
    cursor: pointer;
}

details.card[open] > summary {
    margin-bottom: 1rem;
}

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

/* 8. Tableaux ============================================================== */

.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.table {
    width: 100%;
    font-size: 0.9rem;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.7rem 0.9rem;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-size: 0.75rem;
    font-weight: 650;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--surface-muted);
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table tbody tr:hover td {
    background: var(--surface-hover);
}

.table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.table .actions {
    text-align: right;
}

.table td.wrap {
    min-width: 220px;
    white-space: normal;
}

.table td a {
    font-weight: 600;
    text-decoration: none;
}

.table td a:hover {
    text-decoration: underline;
}

.row-inactive td {
    color: var(--text-subtle);
}

.row-deleted td {
    color: var(--text-subtle);
    text-decoration: line-through;
}

.row-deleted td strong,
.row-deleted td .badge {
    display: inline-block;
    color: var(--danger);
    text-decoration: none;
}

.cell-check {
    font-weight: 700;
    color: var(--warning);
    background: var(--warning-soft);
}

.flag-list {
    padding-left: 1.1rem;
    margin: 0;
    font-weight: 600;
    color: var(--warning);
}

.batch-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 0.9rem 0 2rem;
}

.receipt-thumb img {
    display: block;
    width: 52px;
    height: 52px;
    object-fit: cover;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

/* 9. Indicateurs et filtres =============================================== */

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.filters .field {
    flex: 1 1 150px;
}

.filters .field input,
.filters .field select {
    min-height: 42px;
    padding: 0.45rem 0.65rem;
    font-size: 0.95rem;
}

.filters-actions {
    display: flex;
    gap: 0.5rem;
}

.filters-actions .btn {
    min-height: 42px;
}

/* Recherche par numéro ou par colis : la période n'est pas appliquée, on le dit. */
.filters-note {
    display: flex;
    flex-basis: 100%;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--accent-text);
}

.filters-note .icon {
    width: 16px;
    height: 16px;
}

.kpi-group {
    margin-top: 1.75rem;
}

.kpi-group h2 {
    margin-bottom: 0.75rem;
    font-size: 0.78rem;
    font-weight: 650;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 0.75rem;
}

.kpi {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

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

.kpi-value {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.kpi-note {
    font-size: 0.82rem;
    color: var(--text-subtle);
}

/* Tuile cliquable (ex. totaux des dépôts : filtre sur le statut). */
a.kpi {
    color: var(--text);
    text-decoration: none;
}

a.kpi:hover {
    border-color: var(--border-strong);
}

/* Tuile du filtre actif : fond légèrement marqué, sans liseré de couleur. */
a.kpi.is-selected {
    background: var(--surface-hover);
    border-color: var(--border-strong);
}

/* Dépôt à confirmer dans l'historique : confirmer, ou motif + rejeter. */
.deposit-actions {
    display: grid;
    gap: 0.4rem;
    width: 12rem;
    margin-top: 0.5rem;
}

.deposit-actions .btn {
    width: 100%;
}

.deposit-actions .inline-form {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
}

.deposit-actions .inline-form input {
    width: 100%;
}

.deposit-totals,
.statement-totals {
    margin-bottom: 1rem;
}

.kpi-check {
    background: var(--warning-soft);
    border-color: var(--warning-border);
}

.kpi-check .kpi-note,
.kpi-check .kpi-label {
    color: var(--warning);
}

/* Tarification : ce qui est en vigueur à gauche, le formulaire de changement à droite. */
.tariff-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
    gap: 1rem;
    align-items: start;
}

@media (max-width: 1100px) {
    .tariff-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

.tariff-current {
    margin: 0 0 0.75rem;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.tariff-current .muted {
    font-size: 1rem;
    font-weight: 400;
}

/* 10. Listes, historique, récapitulatifs ================================== */

.item-list {
    display: grid;
    padding: 0;
    margin: 0;
    list-style: none;
}

.item-list li {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem 0.75rem;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--border);
}

.item-list li:first-child {
    padding-top: 0;
}

/* Liste en fin de carte : pas de trait de séparation orphelin sous le dernier élément. */
.item-list:last-child > li:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

/* Colis remis : le constat et son annulation, à la place du bouton de remise. */
.pickup-done {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem 0.75rem;
}

.item-main,
.item-side {
    display: grid;
    align-content: start;
    gap: 0.15rem;
}

/* Informations à gauche (prennent la place disponible), montant et actions toujours à droite. */
.item-main {
    flex: 1 1 0;
    min-width: 0;
}

/* Badge long (ex. « Remis à … le … ») : il peut passer sur deux lignes, en rectangle arrondi
   plutôt qu'en pilule déformée. */
.item-main .badge,
.pickup-done .badge {
    white-space: normal;
    border-radius: var(--radius-sm);
}

.item-main .muted {
    font-size: 0.85rem;
}

.item-main .badge {
    justify-self: start;
    margin-top: 0.25rem;
}

.item-side {
    justify-items: end;
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.item-full {
    flex-basis: 100%;
}

/* Destinataire d'un colis : libellé à gauche, valeur à droite du libellé. */
/* Libellés et valeurs en deux colonnes : la valeur reste à côté de son libellé,
   quelle que soit la largeur prise par le montant et l'action à droite. */
.recipient {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0.1rem 0.75rem;
    margin: 0.25rem 0;
    font-size: 0.92rem;
}

.recipient > div {
    display: contents;
}

.recipient dt {
    color: var(--text-subtle);
}

.recipient dd {
    min-width: 0;
    margin: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

/* Téléphone du destinataire : un appui lance l'appel. */
.phone-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    justify-self: start;
    min-height: 32px;
    font-weight: 600;
    text-decoration: none;
}

.phone-link .icon {
    width: 16px;
    height: 16px;
}

.item-total {
    padding-top: 0.75rem;
    text-align: right;
}

.trip-list {
    display: grid;
    gap: 0.5rem;
    padding: 0;
    margin: 0;
    list-style: none;
}

.trip-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 64px;
    padding: 0.75rem 1rem;
    color: var(--text);
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.trip-list a:hover {
    border-color: var(--border-strong);
}

.trip-list-main {
    display: grid;
    gap: 0.1rem;
}

.trip-list-main .muted {
    font-size: 0.85rem;
}

.summary {
    margin: 0;
}

.summary > div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.summary dt {
    color: var(--text-muted);
}

.summary dd {
    margin: 0;
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.summary-total dt,
.summary-total dd {
    font-weight: 700;
    color: var(--text);
}

.summary-balance {
    font-size: 1.15rem;
    border-bottom: 0 !important;
}

.summary-check {
    padding-inline: 0.6rem !important;
    color: var(--warning);
    background: var(--warning-soft);
    border-radius: var(--radius-sm);
}

.summary-check dt,
.summary-check dd {
    color: var(--warning);
}

.summary-note {
    margin-top: 0.6rem;
    font-size: 0.82rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1rem;
    margin: 0;
}

.info-grid dt {
    font-size: 0.8rem;
    color: var(--text-subtle);
}

.info-grid dd {
    margin: 0;
    font-weight: 600;
}

.history {
    display: grid;
    gap: 0.9rem;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
    list-style: none;
}

.history li {
    display: grid;
    gap: 0.1rem;
    padding-left: 0.9rem;
    border-left: 2px solid var(--border);
}

.history time {
    font-size: 0.78rem;
    color: var(--text-subtle);
    font-variant-numeric: tabular-nums;
}

.recap {
    display: grid;
    gap: 0.35rem;
    padding-left: 1.2rem;
    margin: 0 0 0.75rem;
}

/* 11. Écrans chauffeur ===================================================== */

.current-trip {
    display: grid;
    gap: 0.4rem;
    padding: 1.1rem;
    color: var(--text);
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.current-trip-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-text);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.current-trip strong {
    font-size: 1.35rem;
    font-variant-numeric: tabular-nums;
}

.current-trip .btn {
    margin-top: 0.5rem;
}

.content-narrow > h2 {
    margin: 0.75rem 0 -0.25rem;
}

/* Accueil chauffeur : ce qui reste à faire, en deux tuiles côte à côte. */
.todo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.todo-grid .btn {
    margin-top: auto;
}

.todo-grid .kpi-note {
    flex-grow: 1;
}

/* Historique de l'accueil : onglets Voyages / Dépôts, une liste paginée à la fois.
   (.history est la frise de l'historique d'un voyage côté admin.) */
.home-history {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
    margin-top: 0.75rem;
    scroll-margin-top: calc(var(--topbar-h) + 0.5rem);
}

.tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0.25rem;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.tab {
    display: inline-flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 42px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-sm);
}

.tab:hover {
    color: var(--text);
}

.tab.is-active {
    color: var(--text);
    background: var(--surface);
    box-shadow: 0 0 0 1px var(--border-strong);
}

.tab-count {
    min-width: 1.5rem;
    padding: 0 0.4rem;
    font-size: 0.78rem;
    line-height: 1.4rem;
    text-align: center;
    background: var(--surface-hover);
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
}

.tab.is-active .tab-count {
    color: var(--accent-text);
    background: var(--accent-soft);
}

/* Ligne de liste non cliquable (dépôts), même gabarit que les voyages. */
.trip-list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 64px;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* Menu d'étapes collant (fiche voyage en cours) */
.step-nav {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.35rem;
    padding: 0.4rem 0;
    background: var(--bg);
}

.step-nav a {
    display: grid;
    justify-items: center;
    gap: 0.1rem;
    min-height: var(--tap);
    padding: 0.35rem 0.15rem;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-muted);
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.step-nav b {
    font-size: 0.95rem;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.step-nav .is-done b {
    color: var(--success);
}

.step-nav .is-todo {
    border-color: var(--warning-border);
}

.step-nav .is-todo b {
    color: var(--warning);
}

@media (max-width: 1023px) {
    .step-nav {
        top: var(--topbar-h);
    }
}

/* Grille des places */
.seat-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
    margin-bottom: 0.9rem;
    font-size: 0.85rem;
}

.seat-swatch {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
}

.seat-swatch.is-taken {
    background: var(--accent);
    border-color: var(--accent);
}

.seat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem;
}

.seat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 64px;
    padding: 0.25rem;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
}

.seat:hover:not(:disabled) {
    border-color: var(--accent);
}

.seat-number {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.1;
}

.seat-state {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-subtle);
}

.seat.is-taken {
    color: var(--on-accent);
    background: var(--accent);
    border-color: var(--accent);
}

.seat.is-taken .seat-state {
    color: var(--on-accent);
    opacity: 0.9;
}

.seat.is-taken .seat-state::before {
    content: "✓ ";
}

.seat.is-pending {
    opacity: 0.5;
}

.seat:disabled,
.seat-grid-readonly .seat {
    cursor: default;
}

.seat-grid-readonly .seat {
    min-height: 54px;
}

.seat-error {
    grid-column: 1 / -1;
    margin-top: 0.5rem;
}

/* Barre « Montant à verser » fixée en bas pendant le voyage */
.due-bar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: var(--sidebar-w);
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    /* Alignée sur la colonne du contenu (720 px dont 2rem de marge, centrée à droite de la sidebar).
       Barre fixe : 100 % = largeur de l'écran, sidebar comprise. */
    padding: 0.7rem max(2rem, calc((100% - var(--sidebar-w) - 720px) / 2 + 2rem));
    padding-bottom: calc(0.7rem + env(safe-area-inset-bottom));
    color: var(--text);
    text-decoration: none;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 16px rgb(15 20 28 / 0.08);
}

.due-bar > span {
    font-weight: 600;
    color: var(--text-muted);
}

.due-bar small {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-subtle);
}

.due-bar strong {
    font-size: 1.35rem;
    color: var(--accent-text);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.due-bar-spacer {
    height: 4rem;
}

@media (max-width: 1023px) {
    .due-bar {
        left: 0;
        padding-right: 1rem;
        padding-left: 1rem;
    }
}

/* Photos (document de gare, compteurs) */
.photo-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.75rem;
    padding: 0;
    margin: 0 0 1rem;
    list-style: none;
}

.photo-list li {
    display: grid;
    align-content: start;
    gap: 0.35rem;
    font-size: 0.85rem;
}

.photo-list img {
    display: block;
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.photo-list .is-deleted img {
    opacity: 0.4;
}

.photo-list .is-deleted strong {
    color: var(--danger);
}

/* Remise au destinataire : bouton sous les informations du colis, pleine largeur dans la liste. */
.pickup[open] > summary {
    margin-bottom: 0.25rem;
}

/* Même bouton « Remis au destinataire » sur l'accueil et sur la fiche du voyage. */
.pickup > summary {
    width: 100%;
}

/* Admin : classer « non récupéré » depuis un tableau (formulaire replié, colonne étroite). */
.unclaimed-admin > summary {
    list-style: none;
    cursor: pointer;
}

.unclaimed-admin > summary::-webkit-details-marker {
    display: none;
}

.unclaimed-admin[open] > summary {
    margin-bottom: 0.4rem;
}

.unclaimed-admin .form {
    gap: 0.5rem;
    width: 13rem;
}

/* « Non récupéré ? » : choix secondaire, discret sous le bouton de remise. */
.unclaimed-form {
    margin-top: 0.25rem;
}

.unclaimed-form > summary.btn-link {
    min-height: 36px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.unclaimed-form .choice {
    min-height: 48px;
}

/* 12. Fiche voyage (admin) ================================================= */

.trip-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

/* min-width: 0 : un tableau large défile dans son cadre au lieu d'élargir la colonne. */
.trip-main,
.trip-side {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
    min-width: 0;
}

@media (max-width: 1100px) {
    .trip-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* 13. Connexion et erreurs ================================================= */

/* Photo du minibus en fond, sous un voile sombre qui garde le formulaire lisible
   (plafonniers très lumineux). Même rendu en thème clair et sombre. */
.auth-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 1.5rem 1rem;
    background:
        linear-gradient(rgb(7 9 26 / 0.55), rgb(7 9 26 / 0.8)),
        #0b0e1f url("../img/connexion.jpg") center / cover no-repeat;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 2rem 1.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 20px 50px rgb(0 0 0 / 0.45);
}

.auth-card h1 {
    margin-bottom: 1.25rem;
    font-size: 1.25rem;
}

.auth-card > .alert {
    margin-bottom: 1rem;
}

.auth-brand {
    display: block;
    margin-bottom: 1.75rem;
    font-size: 1.5rem;
}

.error-code {
    margin: 0.5rem 0 1rem;
    font-size: 3rem;
    font-weight: 700;
    color: var(--text-subtle);
    font-variant-numeric: tabular-nums;
}

.auth-card .error-code + p {
    margin-bottom: 1.25rem;
}

/* 14. Utilitaires =========================================================== */

.muted {
    color: var(--text-muted);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Admin sur téléphone : indicateurs en deux colonnes pour limiter le défilement. */
@media (max-width: 720px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.5rem;
    }

    .kpi {
        padding: 0.8rem;
    }

    .kpi-value {
        font-size: 1.15rem;
    }

    .page-header {
        margin-bottom: 1rem;
    }
}

/* Pagination des listes */
.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    padding: 0.75rem 0 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.pagination-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pagination-current {
    font-variant-numeric: tabular-nums;
}
