/* Variables & Reset */
    :root { --p: #002e5b; --s: #c00000; --bg: #f4f7f6; }
    body { font-family: 'Segoe UI', Tahoma, sans-serif; margin: 0; background: var(--bg); color: #333; overflow-x: hidden; padding-top: calc(var(--header-height, 56px) + 48px); } /* header + nav */

    /* Layout */
    .header { background: var(--p); color: white; padding: 12px 20px; display: flex; justify-content: space-between; align-items: center; position: fixed; top: 0; left: 0; right: 0; z-index: 1000; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
    .nav    { display: flex; background: #fff; border-bottom: 2px solid #ddd; padding: 0 20px; position: fixed; top: var(--header-height, 56px); left: 0; right: 0; z-index: 999; box-shadow: 0 2px 4px rgba(0,0,0,0.06); min-height: 48px; overflow-x: auto; scroll-behavior: smooth; scrollbar-width: none; -webkit-overflow-scrolling: touch; white-space: nowrap; }
    .nav div { padding: 15px 25px; cursor: pointer; font-weight: bold; color: #555; transition: 0.3s; display: inline-flex; align-items: center; white-space: nowrap; flex-shrink: 0; }
    .nav::-webkit-scrollbar { display: none; }
    .nav div.active { color: var(--s); border-bottom: 3px solid var(--s); }
    .content { padding: 15px; max-width: 100%; margin: auto; box-sizing: border-box; overflow-x: hidden; }

    /* Onglets */
    .tab { display: none; }
    .tab.active { display: block !important; animation: fadeIn 0.3s; }
    @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

    /* Composants */
    .card { background: white; padding: 20px; border-radius: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); margin-bottom: 20px; box-sizing: border-box; max-width: 100%; }
    .btn  { background: var(--p); color: white; border: none; padding: 10px 18px; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 14px; transition: 0.2s; }
    .btn:hover    { background: #004080; }
    .btn-red      { background: var(--s); }
    .btn-green    { background: #28a745; }
    .btn-yellow   { background: #ffc107; color: #333; }
    .btn-gray     { background: #6c757d; }
    .btn-sm       { padding: 6px 12px; font-size: 12px; }
    input, select { padding: 8px; border: 1px solid #ccc; border-radius: 5px; }

    /* Droits par rôle */
    .role-user  .admin-chef-only  { display: none !important; }
    .role-user  .admin-only-block { display: none !important; }
    .role-chef  .admin-only-block { display: none !important; }
    .role-chef  .user-only-msg    { display: none !important; }
    .role-admin .user-only-msg    { display: none !important; }

    /* Tableaux */
    .clean-table { width: 100%; border-collapse: collapse; margin-top: 15px; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
    .clean-table thead { background: var(--p); color: white; }
    .clean-table th, .clean-table td { padding: 12px 15px; text-align: left; border-bottom: 1px solid #eee; font-size: 13px; }
    .clean-table tbody tr:nth-child(even) { background-color: #f8fbfd; }
    .clean-table tbody tr:hover { background-color: #eef2f5; }
    table.data-table { width: 100%; border-collapse: collapse; margin-top: 15px; }
    table.data-table th, table.data-table td { border: 1px solid #ddd; padding: 8px; text-align: left; }
    table.data-table th { background: #f4f4f4; }

    /* KPI / Trimestres */
    .kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 25px; }
    .kpi-box  { padding: 20px; border-radius: 8px; text-align: center; box-shadow: 0 2px 5px rgba(0,0,0,0.05); border: 1px solid #eee; }
    .kpi-title { font-size: 13px; font-weight: bold; text-transform: uppercase; color: #555; margin-bottom: 10px; }
    .kpi-val   { font-size: 2.2em; font-weight: bold; }
    .kpi-sub   { font-size: 12px; color: #888; margin-top: 5px; }

    /* Planning (grille) */
    .grid-container    { width: 100%; overflow-x: auto; max-height: 70vh; border: 1px solid #ddd; border-radius: 8px; }
    .planning-table    { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 2000px; }
    .planning-table th, .planning-table td { border-right: 1px solid #ddd; border-bottom: 1px solid #ddd; padding: 6px; text-align: center; min-width: 95px; position: relative; }
    .planning-table td:first-child, .planning-table th:first-child { position: sticky; left: 0; background: #fff; z-index: 3; width: 180px; min-width: 180px; text-align: left; box-shadow: 2px 0 5px rgba(0,0,0,0.05); }
    .planning-table thead th { background: var(--p); color: white; position: sticky; top: 0; z-index: 4; font-size: 13px; vertical-align: bottom; }
    .planning-table thead th:first-child { z-index: 5; }
    .planning-table thead th.bg-weekend  { background: #001a33; }
    .planning-table thead th.bg-ferie    { background: #a00000; }
    .planning-table tbody td.td-weekend  { background: #f0f4f8; }
    .planning-table tbody td.td-ferie    { background: #fde8e8; }
    .planning-table .trame-box           { display: none; font-size: 11px; padding-bottom: 6px; margin-bottom: 6px; border-bottom: 1px dashed rgba(255,255,255,0.3); white-space: nowrap; line-height: 1.4; min-height: 20px; }
    .planning-table.show-trames .trame-box { display: block; }
    .planning-table.show-trames thead th   { background: #001f3f; }
    .cell-select   { width: 100%; font-size: 13px; padding: 4px; font-weight: 500; border-radius: 4px; border: 1px solid #ccc; }
    .cell-readonly { font-size: 13px; font-weight: bold; cursor: pointer; color: var(--p); padding: 5px; border-radius: 4px; display: inline-block; width: 100%; box-sizing: border-box; }
    .cell-readonly:hover { background: #e9ecef; }
    .modified-cell { background-color: #fff3cd !important; border: 1px solid #ffeeba !important; }
    .warning-icon  { position: absolute; top: 2px; right: 2px; color: #c00000; font-size: 16px; cursor: help; z-index: 10; display: none; background: #fff; border-radius: 50%; padding: 0 2px; box-shadow: 0 0 3px rgba(0,0,0,0.2); }
    .demande-icon  { position: absolute; bottom: 2px; left: 4px; font-size: 16px; z-index: 10; cursor: pointer; background: #fff; border-radius: 50%; padding: 1px; box-shadow: 0 0 3px rgba(0,0,0,0.3); }
    .act-required  { animation: pulse 1.5s infinite; font-size: 18px; }
    @keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.2); } }
    #monPlanningBody.hide-past .past-date { display: none; }
    .past-date { opacity: 0.5; }

    /* Admin */
    .admin-menu { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; }
    .admin-logo { background: white; border: 2px solid #ddd; border-radius: 12px; width: 200px; padding: 30px 15px; text-align: center; cursor: pointer; transition: 0.3s; }
    .admin-logo:hover { border-color: var(--p); transform: translateY(-5px); }
    .admin-logo i { font-size: 40px; display: block; margin-bottom: 15px; }
    .admin-section { display: none; }

    /* Loader */
    #globalLoader { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.85); z-index: 99999; flex-direction: column; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
    .spinner { width: 50px; height: 50px; border: 5px solid #f3f3f3; border-top: 5px solid var(--p); border-radius: 50%; animation: spin 1s linear infinite; }
    @keyframes spin { to { transform: rotate(360deg); } }

    /* Toasts */
    .toast-container { position: fixed; top: 80px; right: 20px; z-index: 10000; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
    .toast { background: #fff3cd; border-left: 5px solid #c00000; color: #856404; padding: 15px 20px; border-radius: 4px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); font-size: 13px; max-width: 350px; animation: slideIn 0.3s forwards; pointer-events: auto; }
    @keyframes slideIn { from { transform: translateX(120%); } to { transform: translateX(0); } }

    /* Modals */
    .custom-modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,46,91,0.7); z-index: 10005; backdrop-filter: blur(4px); align-items: center; justify-content: center; }
    .custom-modal-box     { background: white; width: 450px; max-width: 95vw; max-height: 90vh; padding: 30px; border-radius: 12px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,0.3); animation: scaleIn 0.2s ease-out; display: flex; flex-direction: column; }
    .custom-modal-text    { overflow-y: auto; flex: 1; min-height: 0; }
    .custom-modal-title   { font-size: 1.4em; font-weight: bold; color: var(--p); margin-top: 0; margin-bottom: 15px; }
    .custom-modal-text    { font-size: 15px; color: #555; margin-bottom: 25px; line-height: 1.5; }
    .custom-modal-buttons { display: flex; justify-content: center; gap: 15px; }
    @keyframes scaleIn    { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

    /* Badges */
    .badge          { padding: 4px 8px; border-radius: 4px; font-size: 11px; font-weight: bold; color: white; display: inline-block; }
    .badge-attente  { background: #f0ad4e; color: #333; }
    .badge-valide   { background: #28a745; }
    .badge-refuse   { background: #dc3545; }
    .badge-icomet   { background: #6f42c1; }
    .nav-badge      { background: #e74c3c; color: white; font-size: 11px; font-weight: bold; padding: 2px 6px; border-radius: 10px; margin-left: 6px; display: none; vertical-align: middle; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }


    /* RESPONSIVE MOBILE */
    @media (max-width: 768px) {

      /* ── HEADER ── */
      .header { padding: 6px 10px; flex-wrap: wrap; gap: 4px; }
      .header > div:first-child { font-size: 1em; font-weight: bold; width: 100%; }
      .header > div:last-child { display: flex; align-items: center; gap: 5px; width: 100%; justify-content: flex-end; }
      /* --header-height calculé par JS */
      #userInfo { font-size: 11px; }
      #userRoleBadge { font-size: 10px !important; padding: 2px 6px !important; }
      .header .btn { padding: 5px 10px !important; font-size: 11px !important; }

      /* ── NAV ── */
      .nav { overflow-x: auto; padding: 0; white-space: nowrap; display: block; }
      .nav div { display: inline-block; padding: 10px 14px; font-size: 12px; }

      /* ── CONTENT ── */
      .content { padding: 8px; }
      .card { padding: 12px; border-radius: 8px; }

      /* ── LOGIN ── */
      #loginScreen { margin-top: 5vh; padding: 0 15px; }
      #loginScreen .card { width: 100% !important; box-sizing: border-box; }

      /* ── MON ESPACE - HEADER ── */
      #tabPerso > div:first-child { flex-direction: column !important; align-items: stretch !important; gap: 8px !important; border-bottom: 2px solid #eee; padding-bottom: 12px; margin-bottom: 15px; }
      #tabPerso > div:first-child h2 { font-size: 1em; margin: 0; }
      #tabPerso > div:first-child > div { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
      #tabPerso > div:first-child input[type="date"] { font-size: 11px; padding: 5px; flex: 1; min-width: 110px; }
      #tabPerso > div:first-child label { font-size: 11px; }
      #tabPerso > div:first-child .btn { padding: 7px 10px; font-size: 12px; }

      /* ── KPI 2 colonnes ── */
      .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 15px; }
      .kpi-box { padding: 10px 6px; }
      .kpi-title { font-size: 9px; margin-bottom: 5px; letter-spacing: 0; }
      .kpi-val { font-size: 1.5em; }
      .kpi-sub { font-size: 9px; line-height: 1.3; }

      /* ── TRIMESTRES 2 colonnes ── */
      #trimestresContainer { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }
      #trimestresContainer .kpi-box { padding: 10px 8px; }
      #trimestresContainer .kpi-val { font-size: 1.2em; }
      #trimestresContainer .kpi-sub { font-size: 10px; }

      /* ── TABLEAUX GÉNÉRAUX ── */
      .clean-table { font-size: 11px; }
      .clean-table th, .clean-table td { padding: 7px 5px; font-size: 11px; }

      /* ── MON ÉQUIPE - tableau scroll horizontal ── */
      #tabEquipe { overflow-x: hidden; }
      #tableEquipe { font-size: 10px; }
      #tableEquipe thead th, #tableEquipe tbody td { padding: 5px 3px; font-size: 10px; white-space: nowrap; }
      /* Rendre le tableau de l'équipe scrollable */
      #tabEquipe .card > div:last-of-type,
      #tableEquipe { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
      /* Filtres équipe sur mobile */
      #tabEquipe > div:nth-child(3) { flex-wrap: wrap; gap: 6px; padding: 8px; }
      #tabEquipe > div:nth-child(3) label { font-size: 11px; }
      #tabEquipe > div:nth-child(3) input, #tabEquipe > div:nth-child(3) select { font-size: 11px; padding: 5px; }
      #equipeYear { width: 65px !important; }
      .admin-only-block select#equipeGrpFilter { max-width: 120px; }

      /* ── PLANNING - toolbar compacte ── */
      #planWorkspace > div:first-child { flex-direction: column; gap: 8px; padding: 10px; }
      #planWorkspace > div:first-child > div:first-child { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; width: 100%; }
      #planWorkspace > div:first-child > div:last-child { display: flex; gap: 6px; width: 100%; }
      #planWorkspace > div:first-child > div:last-child .btn { flex: 1; padding: 8px 5px; font-size: 11px; }
      #planWorkspace > div:first-child .btn-sm { padding: 6px 8px; font-size: 11px; }
      #lblMoisActif { font-size: 12px; padding: 6px 10px; }
      /* Sélects groupe/niveau plus compacts */
      #grpFilter, #nivFilter { height: 45px; font-size: 11px; }
      #empSearch { width: 90px !important; font-size: 11px; }
      #btnToggleTrame { font-size: 11px; padding: 6px 8px; }
      /* Grille planning scroll */
      .grid-container { max-height: 55vh; }
      .planning-table th, .planning-table td { min-width: 70px; padding: 4px; font-size: 11px; }
      .planning-table td:first-child, .planning-table th:first-child { min-width: 130px; width: 130px; font-size: 11px; }
      .cell-select { font-size: 11px; padding: 2px; }
      .cell-readonly { font-size: 11px; padding: 3px; }

      /* ── ADMIN ── */
      .admin-menu { gap: 10px; justify-content: flex-start; }
      .admin-logo { width: calc(50% - 10px); padding: 15px 8px; }
      .admin-logo i { font-size: 28px; margin-bottom: 8px; }
      .admin-logo h3 { font-size: 13px; margin: 0 0 4px; }
      .admin-logo p { font-size: 10px; margin: 0; }

      /* Table admin avec scroll horizontal */
      .data-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; font-size: 11px; }
      .data-table th, .data-table td { padding: 6px 5px; font-size: 11px; white-space: nowrap; }

      /* Formulaire admin personnel */
      #secPersonnel > div:nth-child(3) > div:first-child { flex-wrap: wrap; gap: 6px; }
      #secPersonnel > div:nth-child(3) > div:first-child input,
      #secPersonnel > div:nth-child(3) > div:first-child select { font-size: 12px; padding: 6px; }
      #newNom { min-width: 100% !important; }
      #secPersonnel > div:nth-child(3) > div:last-child { flex-wrap: wrap; gap: 6px; }
      #secPersonnel > div:nth-child(3) > div:last-child input,
      #secPersonnel > div:nth-child(3) > div:last-child select { font-size: 12px; width: calc(50% - 5px) !important; }
      #btnSaveUser { width: 100% !important; margin-top: 4px; }

      /* ── MODALS ── */
      .custom-modal-box { width: 95% !important; max-width: 95% !important; padding: 18px 12px; }
      .custom-modal-title { font-size: 1.1em; }
      .custom-modal-text { font-size: 13px; }
      .custom-modal-buttons { flex-wrap: wrap; gap: 8px; }
      .custom-modal-buttons .btn { flex: 1; min-width: 80px; padding: 8px 10px; font-size: 12px; }

      /* ── TOAST SSE ── */
      #toastSSE { white-space: normal !important; width: 90%; text-align: center; font-size: 12px; }
    }

    /* Très petits écrans (< 400px) */
    @media (max-width: 400px) {
      .kpi-grid { grid-template-columns: 1fr 1fr; }
      #trimestresContainer { grid-template-columns: 1fr 1fr !important; }
      .nav div { padding: 8px 10px; font-size: 11px; }
      .header > div:first-child { font-size: 0.85em; }
    }

    /* PRÉSENCE EN TEMPS RÉEL (style Excel 365) */
    @keyframes presencePop {
      0%   { transform: scale(0); opacity: 0; }
      60%  { transform: scale(1.2); }
      100% { transform: scale(1); opacity: 1; }
    }
    [id^="presence_"] { pointer-events: none; user-select: none; }

/* FIXES GLOBAUX */
body { overflow-x: hidden; }
#appScreen { max-width: 100vw; overflow-x: hidden; }
.tab, .card { box-sizing: border-box; width: 100%; }
#planWorkspace, #planStartBox { width: 100%; box-sizing: border-box; }
#moisGrid { max-width: 100% !important; }

/* RESPONSIVE — MOBILE (< 768px) */
@media (max-width: 768px) {

  /* Header 2 lignes sur mobile */
  .header {
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 5px;
    top: 0;
  }

  .header > div:first-child {
    font-size: 1em;
    width: 100%;
    margin-bottom: 2px;
  }
  .header > div:last-child {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: nowrap;
  }
  #userInfo      { font-size: 12px; }
  #userRoleBadge { font-size: 10px !important; padding: 2px 5px !important; }
  .header .btn   { padding: 5px 8px !important; font-size: 11px !important; }

  /* Nav : top géré par JS via --header-height */
  .nav { overflow-x: auto; white-space: nowrap; display: block; padding: 0; }
  .nav div { display: inline-flex !important; padding: 10px 14px; font-size: 12px; }

  /* Content */
  .content { padding: 8px; }
  .card    { padding: 14px; border-radius: 8px; }

  /* ── KPI — 2 colonnes ── */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
    margin-bottom: 15px;
  }
  .kpi-box   { padding: 10px 8px; }
  .kpi-title { font-size: 9px; letter-spacing: 0; margin-bottom: 6px; }
  .kpi-val   { font-size: 1.4em; }
  .kpi-sub   { font-size: 9px; line-height: 1.3; }

  /* ── Trimestres — 2 colonnes ── */
  #trimestresContainer {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
  }
  #trimestresContainer .kpi-box { padding: 10px 6px; }
  #trimestresContainer .kpi-val { font-size: 1.2em; }

  /* ── Tableau demandes — épuré, moins de colonnes ── */
  #bodyMesDemandes th:nth-child(1),
  #bodyMesDemandes td:nth-child(1) { display: none; } /* Cacher "Créé le" */
  .clean-table { font-size: 11px; }
  .clean-table th, .clean-table td { padding: 7px 5px; font-size: 11px; }

  /* ── Tableau Mon Équipe — scroll + épuré ── */
  #tabEquipe .card:has(#tableEquipe) { overflow-x: auto; padding: 10px 8px; }
  #tableEquipe { display: block; overflow-x: auto; font-size: 10px; -webkit-overflow-scrolling: touch; }
  #tableEquipe th, #tableEquipe td { padding: 5px 4px; white-space: nowrap; font-size: 10px; }
  /* Cacher colonnes moins importantes sur mobile */
  #tableEquipe th:nth-child(1), #tableEquipe td:nth-child(1) { display: none; } /* Mat */
  #tableEquipe th:nth-child(3), #tableEquipe td:nth-child(3) { display: none; } /* Grp */
  #tableEquipe th:nth-child(4), #tableEquipe td:nth-child(4) { display: none; } /* Niv */

  /* ── Sélecteur de mois — 3 colonnes nettes ── */
  #moisGrid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px !important;
    max-width: 100% !important;
  }
  #moisGrid > div { padding: 10px 4px !important; font-size: 12px !important; }

  /* ── Planning grille ── */
  .grid-container { max-height: 55vh; }
  .planning-table th, .planning-table td { min-width: 75px; font-size: 11px; padding: 4px 3px; }
  .planning-table td:first-child, .planning-table th:first-child { min-width: 120px; width: 120px; font-size: 11px; }
  .cell-select   { font-size: 11px; padding: 2px; }
  .cell-readonly { font-size: 11px; }

  /* ── Planning toolbar ── */
  #planWorkspace > div:first-child {
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
  }

  /* Fix bandeau bleu : le mois actif reste compact, ne prend pas toute la largeur */
  #lblMoisActif {
    align-self: flex-start !important;
    flex-shrink: 0 !important;
    max-width: fit-content;
  }

  /* Les boutons de la toolbar s'affichent en ligne sur mobile */
  #planWorkspace > div:first-child > div:first-child {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    align-items: center !important;
  }

  /* Seulement les boutons action (pas les selects ni le label mois) passent en 100% */
  #planWorkspace > div:first-child > div:first-child > .btn {
    flex: 1 1 auto;
    min-width: 120px;
    text-align: center;
  }

  /* Les selects de filtre gardent une taille raisonnable */
  #grpFilter, #nivFilter, #trameFilter {
    width: 100% !important;
    height: 40px !important;
    font-size: 12px;
  }

  /* ── Admin — icônes 2 par ligne ── */
  .admin-menu { gap: 10px; justify-content: flex-start; }
  .admin-logo { width: calc(50% - 8px); min-width: 0; padding: 15px 8px; }
  .admin-logo i { font-size: 28px; margin-bottom: 8px; }
  .admin-logo h3 { font-size: 12px; margin: 0 0 3px; }
  .admin-logo p  { font-size: 10px; margin: 0; display: none; }

  /* Admin tableaux scroll */
  .data-table { display: block; overflow-x: auto; font-size: 11px; -webkit-overflow-scrolling: touch; }
  .data-table th, .data-table td { padding: 6px 5px; font-size: 11px; white-space: nowrap; }

  /* ── Dashboard admin stats — 2 colonnes ── */
  #adminStats { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; padding: 10px !important; }
  #adminStats .kpi-box { padding: 10px 6px; }

  /* ── Modals ── */
  .custom-modal-box { width: 95% !important; max-width: 95% !important; padding: 18px 14px; }
  .custom-modal-buttons { flex-wrap: wrap; gap: 8px; }
  .custom-modal-buttons .btn { flex: 1; min-width: 80px; font-size: 12px; padding: 8px 10px; }

  /* Toast SSE */
  #toastSSE { white-space: normal !important; width: 85%; text-align: center; font-size: 12px; bottom: 15px; }
}

/* Très petits écrans */
@media (max-width: 400px) {
  .kpi-grid, #trimestresContainer { grid-template-columns: 1fr 1fr !important; }
  #moisGrid { grid-template-columns: repeat(2, 1fr) !important; }
  .nav div  { padding: 8px 10px; font-size: 11px; }
}


/* FIXES MOBILE — Tableaux Mon Équipe */
@media (max-width: 768px) {

  /* ── Tableau Demandes à valider ── */
  /* Scroll horizontal — rien ne se coupe */
  #tabEquipe .card { overflow-x: auto !important; padding: 10px !important; }

  /* Wrapper scroll pour le tableau demandes chef */
  #bodyDemandesChef { display: block; }
  .table-demandes-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }

  /* Colonnes demandes — taille minimale lisible */
  #tabEquipe table thead th,
  #tabEquipe table tbody td {
    white-space: nowrap;
    font-size: 11px !important;
    padding: 6px 6px !important;
  }

  /* ── Tableau synthèse équipe ── */
  #tableEquipe {
    display: block !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    font-size: 11px;
  }
  #tableEquipe th, #tableEquipe td {
    white-space: nowrap;
    font-size: 10px !important;
    padding: 5px 4px !important;
  }

  /* Nom en sticky à gauche dans tableau équipe */
  #tableEquipe th:nth-child(2),
  #tableEquipe td:nth-child(2) {
    position: sticky;
    left: 0;
    background: white;
    z-index: 2;
    box-shadow: 2px 0 4px rgba(0,0,0,0.08);
    font-weight: bold;
  }
  #tableEquipe thead th:nth-child(2) {
    background: var(--p);
    color: white;
  }

  /* Cacher Mat. sur mobile pour gagner de la place */
  #tableEquipe th:nth-child(1),
  #tableEquipe td:nth-child(1) { display: none; }

  /* ── Nav — scroll horizontal sans couper ── */
  .nav {
    overflow-x: auto !important;
    white-space: nowrap !important;
    display: block !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
  }
  .nav::-webkit-scrollbar { display: none; } /* Chrome/Safari */
  .nav div { display: inline-block !important; padding: 10px 12px !important; font-size: 12px !important; }

  /* ── Filtres équipe — colonne ── */
  #tabEquipe > .card > div[style*="flex"] {
    flex-direction: column !important;
    gap: 8px !important;
    align-items: stretch !important;
  }

  /* Groupe + Rechercher sur mobile */
  #equipeGrpFilter, #equipeNameFilter {
    width: 100% !important;
    box-sizing: border-box;
    font-size: 13px;
    padding: 8px;
  }

  /* Année + Calculer */
  #equipeYear { width: 70px !important; }
}
/* Wrapper scroll pour les tableaux mobiles */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }
/* ── MODE COMPACT PLANNING (mobile) ── */
.mode-compact #planningTable th,
.mode-compact #planningTable td,
table.compact-table th,
table.compact-table td {
  padding: 2px 3px !important;
  font-size: 10px !important;
  min-width: 28px !important;
}
.mode-compact #planningTable .cell-select,
table.compact-table .cell-select {
  font-size: 9px !important;
  padding: 0 !important;
  width: 100% !important;
}
.mode-compact #planningTable input[type="checkbox"],
table.compact-table input[type="checkbox"] { display: none !important; }
.mode-compact #planningTable label,
table.compact-table label { display: none !important; }
.mode-compact #planningTable .warning-icon,
table.compact-table .warning-icon { display: none !important; }
.mode-compact #btnModeCompact { background: var(--p) !important; color: white !important; }

@media (max-width: 768px) {
  #planWorkspace { overflow-x: auto; }
  #planningTable { min-width: 600px; }
  .mode-compact #planningTable { min-width: unset; }
}

/* ── MODE MULTI-SÉLECTION PLANNING ── */
.mode-multiselect #planningTable td {
  cursor: crosshair !important;
}
.mode-multiselect #planningTable td:hover {
  outline: 2px dashed #6f42c1 !important;
  outline-offset: -2px;
  background: rgba(111,66,193,0.05) !important;
}
/* PAGE PERSO - Cartes KPI cliquables */
.perso-card {
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(0,0,0,0.05); /* Safari iOS */
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
.perso-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.12) !important;
}
.perso-card.active {
  outline: 3px solid var(--p);
  outline-offset: 2px;
  transform: translateY(-2px);
}
.perso-section {
  animation: fadeIn 0.2s ease;
}
@media (max-width: 600px) {
  #tabPerso > div:nth-child(2) {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-5px); }
  80%       { transform: translateX(5px); }
}