/* ============================================================================
        V4
   MOBILE.CSS — Feuille de style mobile unique
   Remplace mobile-improvements.css + mobile-patch.css

   Chargement dans index.html (après style.css) :
     <link rel="stylesheet" href="mobile.css">

   Sections :
     0.  Variables & reset global
     1.  En-tête (h1, h2)
     2.  Onglets des mois — 1 ligne, 6 colonnes
     3.  Toolbar — ligne unique scrollable
     4.  Conteneur #content
     5.  Tableau — cellules, colonnes, en-têtes sticky
     6.  Colonne grade (sticky gauche)
     7.  Colonne nom (sticky)
     8.  Coin supérieur gauche
     9.  Inputs — ergonomie tactile
     10. Séparateurs & lignes compteurs
     11. Modals — slide-up mobile
     12. Menu contextuel
     13. Bannière PWA
     14. Vue annuelle
     15. Divers (badges, alertes, accessibilité)
     16. Corrections bsnap (mode bloc)
============================================================================ */

/* ============================================================================
   📱 AMÉLIORATIONS MOBILES — À AJOUTER APRÈS style.css
   Cible : smartphones < 768px
   Compatible avec le style.css existant (ne le remplace pas, le complète)
============================================================================ */

/* =========================================================
   0. VARIABLES MOBILES ENRICHIES
   ========================================================= */
@media (max-width: 768px) {
    :root {
        --namew: 100px;
        --gradew: 30px;
        --cell-h: 42px;        /* Hauteur tactile confortable */
        --tab-radius: 10px;
        --toolbar-bg: #1e293b;
        --toolbar-h: 56px;
        --accent: #f6d365;
        --accent-dark: #c89a00;
        --text-light: #f1f5f9;
        --shadow-sm: 0 1px 4px rgba(0,0,0,0.15);
        --shadow-md: 0 4px 16px rgba(0,0,0,0.2);
    }

    /* Calcul des largeurs selon le mode */
    body                  { --colw-mobile: calc((100vw - var(--namew) - var(--gradew)) / 5); }
    body.show-repos-cols  { --colw-mobile: calc((100vw - var(--namew) - var(--gradew)) / 7); }
}

/* =========================================================
   1. RESET GLOBAL MOBILE
   ========================================================= */
@media (max-width: 768px) {
    html, body {
        overscroll-behavior-x: none;   /* Empêche le geste "retour" du navigateur */
        touch-action: pan-y;           /* Scroll vertical libre, horizontal contrôlé */
        -webkit-tap-highlight-color: rgba(0,0,0,0); /* Supprime le flash bleu au tap */
    }

    body {
        margin: 0 !important;
        padding: 0 !important;
        padding-bottom: calc(var(--toolbar-h) + env(safe-area-inset-bottom, 8px)) !important;
        background: #f0f2f5;
        font-size: 11px !important;
    }
}

/* =========================================================
   2. EN-TÊTE (H1 + H2)
   ========================================================= */
@media (max-width: 768px) {
    h1 {
        font-size: 15px !important;
        padding: 10px 8px 2px !important;
        margin: 0 !important;
        letter-spacing: 0.3px;
        color: #1e293b;
    }

    h2 {
        font-size: 11px !important;
        margin: 0 0 6px !important;
        color: #64748b;
    }
}

/* =========================================================
   3. ONGLETS DES MOIS — Design pill moderne
   ========================================================= */
@media (max-width: 768px) {
    .tabs {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 5px !important;
        padding: 6px 8px 4px !important;
        margin-bottom: 6px !important;
        background: #fff;
        border-bottom: 1px solid #e2e8f0;
        position: sticky;
        top: 0;
        z-index: 200;
        box-shadow: var(--shadow-sm);
    }

    .tab {
        padding: 9px 2px !important;
        font-size: 11px !important;
        font-weight: 600 !important;
        text-align: center !important;
        border-radius: var(--tab-radius) !important;
        border: 1px solid #cbd5e1 !important;
        background: #f8fafc !important;
        color: #475569 !important;
        cursor: pointer;
        transition: background 0.15s, color 0.15s, transform 0.1s;
        min-height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .tab:active {
        transform: scale(0.95);
    }

    .tab.active {
        background: var(--accent) !important;
        border-color: var(--accent-dark) !important;
        color: #1e293b !important;
        font-weight: 700 !important;
        box-shadow: 0 2px 6px rgba(230, 165, 0, 0.35);
    }
}

/* =========================================================
   4. TOOLBAR STICKY EN BAS (barre d'outils fixe)
   ========================================================= */
@media (max-width: 768px) {

    /* Déplace la toolbar en bas fixe */
    .toolbar {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1000 !important;
        margin: 0 !important;
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)) !important;
        background: var(--toolbar-bg) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        box-shadow: 0 -2px 12px rgba(0,0,0,0.25) !important;
        border-top: 1px solid #334155;
    }

    /* Boutons de la toolbar — cibles tactiles larges */
    .toolbar button {
        padding: 8px 12px !important;
        font-size: 12px !important;
        border-radius: 8px !important;
        border: 1px solid #475569 !important;
        background: #334155 !important;
        color: var(--text-light) !important;
        cursor: pointer;
        min-height: 38px;
        min-width: 38px;
        white-space: nowrap;
        display: inline-flex;
        align-items: center;
        gap: 4px;
        transition: background 0.15s;
        -webkit-tap-highlight-color: transparent;
    }

    .toolbar button:active {
        background: #475569 !important;
    }

    /* Bouton déconnexion = toujours rouge discret */
    .toolbar button.logout {
        background: #7f1d1d !important;
        border-color: #991b1b !important;
    }

    /* Bouton "togglé" (ex: Afficher repos) = accentué */
    .toolbar button.active,
    .toolbar button[data-active="true"] {
        background: var(--accent-dark) !important;
        color: #1e293b !important;
        border-color: var(--accent) !important;
        font-weight: 700;
    }
}

/* =========================================================
   5. CONTENEUR DE DÉFILEMENT — Défilement horizontal fluide
   ========================================================= */
@media (max-width: 768px) {
    #content {
        display: block !important;
        width: 100vw !important;
        max-width: 100vw !important;
        overflow-x: auto !important;
        overflow-y: auto !important;
        height: auto !important;
        max-height: calc(100svh - 110px) !important; /* 110px ≈ tabs + header + toolbar */
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;

        /* Scroll snap par blocs de semaine */
        scroll-snap-type: x proximity !important; /* "proximity" = moins agressif que "mandatory" */
        scroll-behavior: smooth;
        scroll-padding-left: calc(var(--namew) + var(--gradew)) !important;

        padding: 0 !important;
        box-sizing: border-box !important;
        margin: 0 !important;
    }
}

/* =========================================================
   6. TABLEAU — Taille des cellules & colonnes fixes
   ========================================================= */
@media (max-width: 768px) {
    table {
        font-size: 11px !important;
        width: max-content !important;
        min-width: 100vw !important;
        table-layout: fixed !important;
        border-collapse: separate !important;
        border-spacing: 0 !important;
    }

    /* Colonnes de jours : largeur calculée dynamiquement */
    col:not(.gradecell):not(.namecell),
    td:not(.gradecell):not(.namecell),
    th:not(.gradecell):not(.namecell) {
        width: var(--colw-mobile) !important;
        min-width: var(--colw-mobile) !important;
        max-width: var(--colw-mobile) !important;
        box-sizing: border-box !important;
    }

    /* Toutes les cellules */
    td, th {
        height: var(--cell-h) !important;
        text-align: center !important;
        vertical-align: middle !important;
        padding: 0 !important;
        overflow: hidden !important;
        white-space: nowrap !important;
        border-bottom: 1px solid #d1d5db !important;
        border-right: 1px solid #d1d5db !important;
    }

    /* Weekend & repos : couleur subtile */
    th.col-repos, td.col-repos {
        background: #f8fafc !important;
        color: #94a3b8 !important;
    }
}

/* =========================================================
   7. EN-TÊTE DU TABLEAU — Sticky en haut
   ========================================================= */
@media (max-width: 768px) {
    thead th, thead td {
        position: sticky !important;
        top: 0 !important;
        z-index: 30 !important;
        background-color: #fff !important;
        border-bottom: 2px solid #cbd5e1 !important;
        font-size: 10px !important;
    }

    /* Cycle unlocked reste vert en sticky */
    thead th.cycle-unlocked {
        background-color: #10b981 !important;
        color: #fff !important;
    }
}

/* =========================================================
   8. COLONNE GRADE — Sticky à gauche
   ========================================================= */
@media (max-width: 768px) {
    .gradecell,
    td.gradecell,
    th.gradecell {
        position: sticky !important;
        left: 0 !important;
        z-index: 20 !important;
        background-color: #f1f5f9 !important;
        width: var(--gradew) !important;
        min-width: var(--gradew) !important;
        max-width: var(--gradew) !important;
        font-size: 9px !important;
        font-weight: 700;
        color: #64748b;
        border-right: 1px solid #cbd5e1 !important;
    }

    thead .gradecell {
        z-index: 9999 !important;
        background-color: #fff !important;
    }
}

/* =========================================================
   9. COLONNE NOM — Sticky à gauche (après grade)
   ========================================================= */
@media (max-width: 768px) {
    .namecell,
    td.namecell,
    th.namecell {
        position: sticky !important;
        left: var(--gradew) !important;
        z-index: 15 !important;
        background-color: #fff !important;
        width: var(--namew) !important;
        min-width: var(--namew) !important;
        max-width: var(--namew) !important;
        text-align: left !important;
        padding: 2px 4px !important;
        font-size: 10.5px !important;
        font-weight: 700;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        border-right: 2px solid #94a3b8 !important;

        /* Ombre de séparation */
        box-shadow: 3px 0 6px -2px rgba(0,0,0,0.12);
    }

    thead .namecell {
        z-index: 9998 !important;
        background-color: #fff !important;
    }

    /* Ligne surlignée (agent connecté) */
    .highlight-row .namecell {
        background: var(--highlight-bg) !important;
    }
}

/* =========================================================
   10. BOUCLIER COIN SUPÉRIEUR GAUCHE
   ========================================================= */
@media (max-width: 768px) {
    thead tr:first-child th:first-child,
    thead tr:first-child td:first-child {
        position: sticky !important;
        top: 0 !important;
        left: 0 !important;
        z-index: 10000 !important;
        background: #fff !important;
    }
}

/* =========================================================
   11. INPUTS — Ergonomie tactile
   ========================================================= */
@media (max-width: 768px) {
    td input.oneinput {
        width: 100% !important;
        height: 100% !important;
        box-sizing: border-box !important;
        padding: 0 1px !important;
        margin: 0 !important;
        border: none !important;
        outline: none !important;
        text-align: center !important;
        font-size: 10px !important;
        font-weight: 700 !important;
        background: transparent !important;
        color: #111 !important;
        -webkit-text-fill-color: #111 !important;
        /* Zone de tap plus grande que l'input lui-même */
        cursor: pointer;
        caret-color: #2563eb;
    }

    /* Feedback visuel au focus (très important sur mobile) */
    td input.oneinput:focus {
        background: rgba(37, 99, 235, 0.08) !important;
        outline: none !important;
        box-shadow: inset 0 0 0 2px #3b82f6 !important;
        z-index: 5;
        position: relative;
    }

    /* Case sélectionnée (multi-sélection) */
    .selected-cell {
        background-color: #eff6ff !important;
        outline: 2px solid #3b82f6 !important;
        outline-offset: -2px;
        z-index: 10;
    }

    /* Case vacance */
    td.vac-cell input,
    td.vac-cell input.oneinput {
        color: #1e3a5f !important;
        -webkit-text-fill-color: #1e3a5f !important;
        font-weight: 700 !important;
    }

    /* Masque la roue déroulante native */
    input.oneinput::-webkit-calendar-picker-indicator { display: none !important; }
    input[type="text"]::-webkit-inner-spin-button { display: none !important; }
}

/* =========================================================
   12. SNAP DE DÉFILEMENT PAR SEMAINE
   ========================================================= */
@media (max-width: 768px) {
    thead tr .namecell + th,
    thead tr .block-sep + th {
        scroll-snap-align: start !important;
        scroll-snap-stop: always !important;
    }
}

/* =========================================================
   13. SÉPARATEURS DE SEMAINE — Plus visibles
   ========================================================= */
@media (max-width: 768px) {
    .block-sep,
    td.block-sep,
    th.block-sep {
        border-right: 2px solid #475569 !important;
    }

    /* Ligne de séparation entre groupes */
    .grade-sep td {
        height: 3px !important;
        background: #94a3b8 !important;
    }

    .header-sep td {
        height: 6px !important;
        background: transparent !important;
        border: none !important;
    }
}

/* =========================================================
   14. LIGNES COMPTEURS — Fond distinct
   ========================================================= */
@media (max-width: 768px) {
    .count-row td,
    .countcell {
        background: #f0f4f8 !important;
        font-weight: 700 !important;
        font-size: 10px !important;
        color: #334155;
    }

    .admin-row {
        background-color: #fffbeb !important;
    }

    .admin-input-cell input {
        font-size: 10px !important;
    }
}

/* =========================================================
   15. MODALS — Plein écran sur mobile
   ========================================================= */
@media (max-width: 768px) {
    #optsModal,
    .modal {
        align-items: flex-end !important; /* Slide depuis le bas */
    }

    #optsEditor,
    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 16px 16px 0 0 !important;
        max-height: 85vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        padding: 16px !important;
        box-shadow: var(--shadow-md) !important;
    }

    .modal-header {
        border-radius: 14px 14px 0 0 !important;
        padding: 14px 16px !important;
        font-size: 14px !important;
    }

    .modal-body {
        padding: 14px !important;
    }

    /* Poignée de fermeture visuelle */
    #optsEditor::before,
    .modal-content::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: #cbd5e1;
        border-radius: 2px;
        margin: 0 auto 12px;
    }
}

/* =========================================================
   16. MENU CONTEXTUEL CLIC DROIT (Ve) — Adapté au touch
   ========================================================= */
@media (max-width: 768px) {
    #ve-context-menu {
        font-size: 15px !important;
        min-width: 160px !important;
        border-radius: 12px !important;
        box-shadow: var(--shadow-md) !important;
        border: none !important;
        padding: 6px 0 !important;
    }

    .ve-option {
        padding: 13px 20px !important;  /* Grande zone de tap */
        font-size: 14px !important;
    }
}

/* =========================================================
   17. BANNIÈRE PWA — Affinée
   ========================================================= */
@media (max-width: 768px) {
    #pwa-install-banner {
        bottom: calc(var(--toolbar-h) + env(safe-area-inset-bottom, 0px)) !important;
        padding: 12px 16px !important;
        border-radius: 12px 12px 0 0 !important;
    }

    #pwa-install-btn {
        border-radius: 10px !important;
        font-size: 15px !important;
    }
}

/* =========================================================
   18. ANALYSE NUITS — Plein écran mobile
   ========================================================= */
@media (max-width: 768px) {
    .nights-modal-content {
        width: 100% !important;
        height: 95% !important;
        margin: 5vh 0 0 !important;
        border-radius: 16px 16px 0 0 !important;
    }

    .n-name { width: 110px !important; padding-left: 8px !important; }
    .n-total { left: 110px !important; }
    .n-cell { width: 30px !important; height: 36px !important; font-size: 11px !important; }
}

/* =========================================================
   19. BARRE DE PROGRESSION (Remplissage auto)
   ========================================================= */
@media (max-width: 768px) {
    .ics-progress-container {
        width: 85% !important;
    }
}

/* =========================================================
   20. ICÔNES & SVG dans le tableau
   ========================================================= */
@media (max-width: 768px) {
    table i, table img, table span, table svg {
        position: relative !important;
        z-index: 1 !important;
        max-width: 100%;
        pointer-events: none;
    }

    /* Cadenas */
    .lock-toggle-btn {
        font-size: 14px !important;
        min-width: 20px;
        min-height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* =========================================================
   21. VUE ANNUELLE — Responsive
   ========================================================= */
@media (max-width: 768px) {
    #modal-annual-view .annual-grid {
        grid-template-columns: repeat(2, 1fr) !important; /* 2 colonnes au lieu de 6 */
        gap: 8px !important;
    }

    #modal-annual-view .annual-month-box {
        min-width: unset !important;
        padding: 8px !important;
    }

    #modal-annual-view .annual-month-title {
        font-size: 12px !important;
    }

    #modal-annual-view .annual-day-row {
        padding: 3px 4px !important;
        font-size: 11px !important;
    }
}

/* =========================================================
   22. SÉPARATION REPOS MASQUÉS vs AFFICHÉS
   ========================================================= */
@media (max-width: 768px) {
    /* Mode repos masqués : tableau 100% de l'écran */
    body:not(.show-repos-cols) table {
        width: 100% !important;
        min-width: 100vw !important;
    }

    body:not(.show-repos-cols) td:not(.gradecell):not(.namecell),
    body:not(.show-repos-cols) th:not(.gradecell):not(.namecell) {
        width: var(--colw-mobile) !important;
        min-width: var(--colw-mobile) !important;
        max-width: var(--colw-mobile) !important;
    }

    /* Mode repos affichés : défilement horizontal autorisé */
    body.show-repos-cols table {
        width: max-content !important;
        min-width: 100vw !important;
    }

    body.show-repos-cols td:not(.gradecell):not(.namecell),
    body.show-repos-cols th:not(.gradecell):not(.namecell) {
        width: var(--colw-mobile) !important;
        min-width: var(--colw-mobile) !important;
        max-width: var(--colw-mobile) !important;
        padding: 0 !important;
    }
}

/* =========================================================
   23. ALERTES COULEURS — Plus lisibles (mobile)
   ========================================================= */
@media (max-width: 768px) {
    .alerte-rouge {
        color: #dc2626 !important;
        font-size: 11px !important;
    }

    .alerte-orange {
        color: #d97706 !important;
        font-size: 11px !important;
    }
}

/* =========================================================
   24. BADGE +Rs — Position corrigée sur mobile
   ========================================================= */
@media (max-width: 768px) {
    td.rs-earned-cell::after {
        font-size: 7px !important;
        top: -1px !important;
        right: 0 !important;
        line-height: 1;
    }
}

/* =========================================================
   25. MICRO-INTERACTIONS & RETOURS TACTILES
   ========================================================= */
@media (max-width: 768px) {
    /* Légère animation sur les lignes au tap */
    tbody tr:active td {
        background-color: rgba(0, 0, 0, 0.04) !important;
    }

    /* Effet tap sur les onglets */
    .tab:active {
        opacity: 0.8;
        transform: scale(0.96);
        transition: transform 0.08s ease;
    }

    /* Scrollbar ultra-fine sur Android (WebKit) */
    #content::-webkit-scrollbar {
        height: 3px;
        width: 3px;
    }

    #content::-webkit-scrollbar-track {
        background: transparent;
    }

    #content::-webkit-scrollbar-thumb {
        background: #94a3b8;
        border-radius: 2px;
    }
}

/* =========================================================
   26. INDICATEUR DE DÉFILEMENT HORIZONTAL
   Petit gradient sur le bord droit pour signaler qu'on peut scroller
   ========================================================= */
@media (max-width: 768px) {
    #content {
        /* Dégradé droit subtil indiquant le scroll possible */
        background:
            linear-gradient(to right, white 30%, rgba(255,255,255,0)) left center /  20px 100% no-repeat,
            linear-gradient(to left,  white 30%, rgba(255,255,255,0)) right center / 20px 100% no-repeat;
        background-attachment: local, local;
    }
}

/* =========================================================
   27. ACCESSIBILITÉ — Focus visible sur mobile
   ========================================================= */
@media (max-width: 768px) {
    /* On conserve le focus pour la navigation clavier (accessibilité) */
    :focus-visible {
        outline: 2px solid #3b82f6;
        outline-offset: 1px;
    }

    /* Mais on le masque au tap (déjà géré par box-shadow) */
    :focus:not(:focus-visible) {
        outline: none;
    }
}


/* ============================================================================
   CORRECTIFS SPÉCIFIQUES (ex mobile-patch.css)
============================================================================ */

@media (max-width: 768px) {

  /* ══════════════════════════════════════════════════════════
     1. TOOLBAR — UNE SEULE LIGNE SCROLLABLE
     Remplace le flex-wrap: wrap par nowrap + scroll horizontal
  ══════════════════════════════════════════════════════════ */

  .toolbar {
    /* Position fixe en bas — reprise depuis mobile-improvements.css */
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1000 !important;

    /* UNE SEULE LIGNE */
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;           /* ← clé : interdit le retour à la ligne */
    align-items: center !important;
    gap: 6px !important;

    /* Scroll horizontal quand les boutons débordent */
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;                  /* Firefox */

    /* Hauteur fixe et padding confortable */
    height: auto !important;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)) !important;

    /* Look */
    background: #1e293b !important;
    border-top: 1px solid #334155;
    box-shadow: 0 -2px 12px rgba(0,0,0,.3) !important;
  }

  /* Masque la scrollbar webkit (Chrome/Safari) */
  .toolbar::-webkit-scrollbar { display: none; }

  /* Boutons de la toolbar — compacts, hauteur fixe, non rétrécissables */
  .toolbar button {
    flex-shrink: 0 !important;             /* ← empêche l'écrasement */
    white-space: nowrap !important;
    padding: 7px 11px !important;
    font-size: 11.5px !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    border: 1px solid #475569 !important;
    background: #334155 !important;
    color: #f1f5f9 !important;
    cursor: pointer;
    min-height: 34px;
    line-height: 1.2;
    transition: background .15s;
    -webkit-tap-highlight-color: transparent;
  }

  .toolbar button:active { background: #475569 !important; }

  /* Boutons spéciaux — couleurs préservées */
  .toolbar button[onclick*="logout"],
  .toolbar button[onclick*="Déconnexion"] {
    background: #7f1d1d !important;
    border-color: #991b1b !important;
  }

  .toolbar button[onclick*="Abonnement"],
  #btn-Abonnement {
    background: #6d28d9 !important;
    border-color: #7c3aed !important;
    color: white !important;
  }

  .toolbar button[onclick*="toggleColonnesRepos"],
  #btn-toggle-repos {
    background: #6d28d9 !important;
    border-color: #7c3aed !important;
    color: white !important;
  }

  .toolbar button[onclick*="togglePersonalView"],
  #btn-personal-view {
    background: #1d4ed8 !important;
    border-color: #2563eb !important;
    color: white !important;
  }

  /* Bouton historique (icône seule) — carré */
  #btn-historique {
    padding: 7px 8px !important;
    font-size: 14px !important;
  }

  /* Indicateur de scroll : petit dégradé à droite signalant qu'on peut scroller */
  .toolbar::after {
    content: '';
    position: sticky;
    right: 0;
    top: 0;
    bottom: 0;
    width: 24px;
    flex-shrink: 0;
    background: linear-gradient(to right, transparent, #1e293b);
    pointer-events: none;
  }

  /* Espace réservé en bas pour la toolbar (évite que le contenu passe dessous) */
  body {
    padding-bottom: calc(52px + env(safe-area-inset-bottom, 0px)) !important;
  }


  /* ══════════════════════════════════════════════════════════
     2. COLONNES DE CYCLE ÉLARGIES en mode bloc
     Quand bsnap-active est présent, les colonnes visibles
     se partagent tout l'espace disponible.
  ══════════════════════════════════════════════════════════ */

  /* Le tableau occupe 100% et répartit l'espace */
  body.bsnap-active table {
    width: 100% !important;
    min-width: unset !important;
    table-layout: fixed !important;
  }

  /* Neutralise les largeurs fixées par <col> et CSS global */
  body.bsnap-active col {
    width: auto !important;
    min-width: unset !important;
    max-width: unset !important;
  }

  /* Colonnes sticky : tailles fixes préservées */
  body.bsnap-active col.gradecell {
    width: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
  }

  body.bsnap-active col.namecell {
    width: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
  }

  /* Cellules visibles : auto-width, texte centré, grande hauteur tactile */
  body.bsnap-active td:not([style*="display: none"]):not(.gradecell):not(.namecell),
  body.bsnap-active th:not([style*="display: none"]):not(.gradecell):not(.namecell) {
    width: auto !important;
    min-width: unset !important;
    max-width: unset !important;
    font-size: 13px !important;   /* Texte légèrement plus grand car moins de colonnes */
  }

  /* Inputs dans les colonnes élargies */
  body.bsnap-active td input.oneinput {
    font-size: 12px !important;
    font-weight: 700 !important;
  }

  /* Nom de l'agent : léger rétrécissement pour gagner de la place */
  body.bsnap-active td.namecell,
  body.bsnap-active th.namecell {
    width: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
    font-size: 10px !important;
  }

  body.bsnap-active td.gradecell,
  body.bsnap-active th.gradecell {
    width: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
  }

  /* Pas de scroll horizontal en mode bloc */
  body.bsnap-active #content {
    overflow-x: hidden !important;
  }
}

/* ── Desktop : annule tout ── */
@media (min-width: 769px) {
  body.bsnap-active table {
    width: 100% !important;
    table-layout: auto !important;
  }

  body.bsnap-active col,
  body.bsnap-active col.gradecell,
  body.bsnap-active col.namecell {
    width: revert !important;
    min-width: revert !important;
    max-width: revert !important;
  }

  body.bsnap-active #content {
    overflow-x: auto !important;
  }
}


/* ══════════════════════════════════════════════════════════
   ONGLETS DES MOIS — Compacts sur mobile
   (Ajout en fin de fichier)
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Onglets — 6 colonnes, 2 lignes, noms abrégés (span.month-short) */
  .tabs {
    display: grid !important;
    grid-template-columns: repeat(6, 1fr) !important;
    gap: 3px !important;
    padding: 4px 6px !important;
    margin-bottom: 0 !important;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    box-sizing: border-box;
    width: 100%;
  }

  /* Bascule : affiche l'abréviation, masque le nom long */
  .tab .month-full  { display: none !important; }
  .tab .month-short { display: inline !important; }

  .tab {
    padding: 5px 2px !important;
    font-size: 10px !important;
    font-weight: 600 !important;
    text-align: center !important;
    border-radius: 6px !important;
    border: 1px solid #e2e8f0 !important;
    background: #f8fafc !important;
    color: #475569 !important;
    cursor: pointer;
    min-height: 28px !important;
    height: 28px !important;
    line-height: 1;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background .15s;
    white-space: nowrap;
    overflow: hidden;
  }

  .tab.active {
    background: #0a1628 !important;
    border-color: #0a1628 !important;
    color: #f6c344 !important;
    font-weight: 700 !important;
  }

  .tab:active { transform: scale(.95); }
}


/* ══════════════════════════════════════════════════════════
   COULEURS CELLULES EN MODE BLOC (bsnap-on)
   Garantit que les couleurs de classes CSS (vac-cell, WE,
   highlight-row) restent visibles malgré les styles inline
   posés par mobile-block-snap.js
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Vacances scolaires / congés */
  body.bsnap-on td.vac-cell {
    background-color: var(--vac-bg) !important;
  }
  body.bsnap-on td.vac-cell input {
    background-color: transparent !important;
    color: #1e3a5f !important;
    -webkit-text-fill-color: #1e3a5f !important;
    font-weight: 700 !important;
  }

  /* Ligne surlignée (agent connecté) */
  body.bsnap-on .highlight-row td {
    background: var(--highlight-bg) !important;
  }

  /* Cellule sélectionnée */
  body.bsnap-on .selected-cell {
    background-color: #eff6ff !important;
    outline: 2px solid #3b82f6 !important;
  }

  /* Remarque */
  body.bsnap-on td.has-remark {
    background: linear-gradient(225deg, #007bff 6px, transparent 6px) !important;
  }

  /* WE : la couleur orange est inline style sur les <th> de date
     → préservée par showBlock() mais on sécurise via CSS aussi */
  body.bsnap-on thead th[style*="e67e22"],
  body.bsnap-on thead td[style*="e67e22"] {
    color: #e67e22 !important;
  }
}


/* ══════════════════════════════════════════════════════════
   DASHBOARD ANNUEL CONGÉS (personal-annual-dashboard)
   Évite le débordement horizontal en mode mobile
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  #personal-annual-dashboard {
    max-width: 100vw !important;
    overflow-x: auto !important;
    box-sizing: border-box !important;
  }

  #personal-annual-dashboard table {
    max-width: 100% !important;
    font-size: 11px !important;
  }
}
