/* Affichage petits écrans (téléphone) — même site, même code : seules ces règles s'appliquent sous 768 px. */
@media (max-width: 767px) {
  /* 1. En-tête compact */
  .dsn-sticky-toolbar { padding: 8px 12px !important; position: relative !important; }
  .dsn-sticky-toolbar h1 { font-size: 17px !important; line-height: 1.25 !important; white-space: normal !important; }
  .dsn-sticky-toolbar h1 + * { display: none !important; }            /* sous-titre (liste des sections) */
  /* 2. Période et filtres repliés derrière un bouton */
  .dsn-sticky-toolbar .no-export.rounded-xl[data-export-ignore="true"] { display: none !important; }
  .dsn-sticky-toolbar.dsn-mf-ouvert .no-export.rounded-xl[data-export-ignore="true"] { display: block !important; }
  .dsn-mf-bouton { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 7px 12px; border-radius: 999px;
    border: 1px solid #c7d2fe; background: #eef2ff; color: #3730a3; font: 600 13px system-ui, sans-serif; }
  /* 3. Grille : marges réduites, chiffres clés en premier, une carte par ligne */
  .dsn-dashboard-grid { gap: 10px !important; }
  .dsn-dashboard-grid > [data-dsn-type="kpi"] { order: -1; min-height: 0 !important; height: auto !important; }
  .dsn-dashboard-grid > [data-dsn-type="kpi"] .h-full { height: auto !important; }
  .dsn-dashboard-grid > [data-dsn-type="kpi"] [data-dsn-defil] { overflow: visible !important; flex: none !important; }
  .dsn-dashboard-grid > [data-dsn-type="chart"], .dsn-dashboard-grid > [data-dsn-type="special"] { min-height: 240px !important; }
  [data-theme-scope="dashboard"] .flex-1.p-6 { padding: 10px !important; }
  /* 4. Tableaux : défilement horizontal propre dans leur carte */
  .dsn-dashboard-grid table { font-size: 12px; }
  .dsn-dashboard-grid table th:first-child, .dsn-dashboard-grid table td:first-child { position: sticky; left: 0; background: #fff; z-index: 1; }
  /* 5. Un seul bouton d'aide : on masque les boutons flottants redondants */
  [aria-label="Votre avis"], [aria-label="Installer l'application mobile"], #dsn-help-fab,
  [aria-label^="Ouvrir DSN Copilot"], [data-testid="lina-expliquer"], #dsn-tour-toast { display: none !important; }
  [data-testid="formatrice-bouton"] { bottom: 14px !important; right: 14px !important; padding: 8px 14px !important; font-size: 13px !important; }
  [aria-label="Centre de notifications"] { top: 8px !important; right: 8px !important; width: 34px !important; height: 34px !important; }
}

/* Finitions toutes tailles d'écran (cLOCAL512) — sans toucher aux pages. */
/* Accueil (ordinateur) : chaque chiffre clé tient sur une ligne (« 24 modules » ne se coupe plus). */
@media (min-width: 768px) {
  div[style*="grid-template-columns: repeat(4, 1fr)"][style*="margin-top: 44px"] {
    grid-template-columns: repeat(4, max-content) !important; column-gap: 44px !important;
  }
  div[style*="grid-template-columns: repeat(4, 1fr)"][style*="margin-top: 44px"] > div > div:first-child { white-space: nowrap; }
}
/* Connexion : les 3 cartes du panneau sombre étaient blanches sur blanc (illisibles) -> verre sombre lisible. */
.glass.rounded-lg.p-5:has(> h3.text-white) {
  background: rgba(255, 255, 255, 0.08) !important; border: 1px solid rgba(255, 255, 255, 0.16) !important;
  backdrop-filter: blur(6px); box-shadow: none !important; transition: background-color .2s ease, transform .2s ease;
}
.glass.rounded-lg.p-5:has(> h3.text-white):hover { background: rgba(255, 255, 255, 0.13) !important; transform: translateY(-1px); }
.glass.rounded-lg.p-5:has(> h3.text-white) p { color: rgba(226, 232, 240, 0.85) !important; }
/* Connexion : le carré du logo était vide -> initiale « D » comme sur l'accueil. */
.w-12.h-12.rounded-lg.bg-gradient-to-br.from-accent.to-accent2:empty { display: flex; align-items: center; justify-content: center; }
.w-12.h-12.rounded-lg.bg-gradient-to-br.from-accent.to-accent2:empty::after { content: "D"; color: #fff; font: 800 22px Inter, system-ui, sans-serif; }

/* Finitions accueil (cLOCAL515). */
/* 1. Aperçu « Masse salariale — 12 derniers mois » : l'animation de pousse des barres repartait à zéro
      à chaque rafraîchissement de l'aperçu -> graphique toujours vide. Barres affichées d'emblée, survol discret. */
[data-landing-rev] .lp-bar { animation: none !important; transform: none !important; transition: opacity .2s ease, filter .2s ease; }
[data-landing-rev] .lp-bar:hover { opacity: 1 !important; filter: brightness(1.15); }
/* 2. Bandeau « Conçu pour la conformité » : tient sur une ligne sur grand écran (le dernier badge passait seul à la ligne). */
@media (min-width: 1280px) {
  [data-landing-rev] .lp-trust { max-width: 1240px !important; gap: 28px !important; flex-wrap: nowrap !important; }
  [data-landing-rev] .lp-trust > * { white-space: nowrap; }
}
/* 3. Accessibilité : avec « réduire les animations » ou à l'impression, les blocs de l'accueil s'affichent
      tout de suite (ils restaient invisibles tant qu'on n'avait pas fait défiler jusqu'à eux). */
@media (prefers-reduced-motion: reduce), print {
  [data-landing-rev] div[style*="translateY(24px)"] { opacity: 1 !important; transform: none !important; transition: none !important; }
}

/* ===== Téléphone, lot 2 (cLOCAL512, demande Chairman 29/11) : même site, mêmes pages — seulement sous 768 px ===== */
@media (max-width: 767px) {
  /* A. Panneau de détail (toucher un chiffre) : plein écran du téléphone, lisible et facile à parcourir */
  aside[role="dialog"][style*="position: fixed"] { width: 100vw !important; max-width: 100vw !important; left: 0 !important; right: 0 !important;
    border-left: 0 !important; box-shadow: none !important; }
  aside[role="dialog"][style*="position: fixed"] > div[style*="col-resize"],
  aside[role="dialog"] header button[title="Agrandir en plein écran"],
  aside[role="dialog"] header button[title="Agrandir en plein écran"] + button { display: none !important; }
  aside[role="dialog"] header .rounded-full { white-space: nowrap; }
  aside[role="dialog"] > .overflow-auto { overflow-x: hidden !important; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  aside[role="dialog"] footer button { min-height: 40px; padding-left: 14px !important; padding-right: 14px !important; font-size: 13px !important; }
  /* B. En-tête des tableaux de bord : une seule ligne d'actions utiles (personnalisation et thème restent sur ordinateur) */
  .dsn-sticky-toolbar button[title^="Passer en mode personnalisation"], .dsn-sticky-toolbar button[title^="Thème"] { display: none !important; }
  .dsn-sticky-toolbar .no-export.flex-wrap.justify-end { justify-content: flex-start !important; padding-right: 0 !important; margin-top: 6px; }
  .dsn-entete-restitution { font-size: 11px !important; padding: 6px 10px !important; }
  .dsn-entete-restitution > span:nth-child(n+3) { display: none !important; }
  [data-theme-scope="dashboard"] .flex-1.p-6, .flex-1.p-6 { padding-bottom: 96px !important; }
  /* C. Bouton d'aide : pastille ronde qui ne cache plus les chiffres */
  button.fixed.bottom-24.right-5.rounded-full { bottom: 14px !important; right: 12px !important; width: 46px; height: 46px; padding: 0 !important;
    font-size: 0 !important; display: flex; align-items: center; justify-content: center; }
  button.fixed.bottom-24.right-5.rounded-full::after { content: "?"; font-size: 20px; font-weight: 800; line-height: 1; }
  main, #root > div { padding-bottom: env(safe-area-inset-bottom); }
  /* D. Cartes : l'icône « agrandir » chevauchait les titres (la carte occupe déjà toute la largeur) */
  button[aria-label="Agrandir le widget"] { display: none !important; }
  /* E. Titres et en-têtes des pages : taille téléphone, retour à la ligne propre */
  h1.text-3xl, h1.text-4xl { font-size: 22px !important; line-height: 1.25 !important; }
  .flex.items-center.gap-4:has(h1) { flex-wrap: wrap; gap: 8px !important; }
  .flex.items-center:has(> select) { flex-wrap: wrap; row-gap: 6px; }
  .flex.items-center.gap-4:has(select) { flex-wrap: wrap; }
  /* F. Onglets : défilement horizontal au doigt au lieu de sortir de l'écran */
  .flex.gap-4.border-b:has(> button), .flex.border-b:has(> button + button + button) { overflow-x: auto; flex-wrap: nowrap !important; scrollbar-width: none; gap: 4px !important; }
  .flex.gap-4.border-b:has(> button) > button, .flex.border-b:has(> button + button + button) > button { flex: 0 0 auto; padding-left: 12px !important; padding-right: 12px !important; white-space: nowrap; }
  /* G. Tableaux trop larges : enveloppe à défilement horizontal (posée par dsn_mobile.js) */
  .dsn-m-defile { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  .dsn-m-defile > table { min-width: max-content; }
  /* H. Zones tactiles confortables */
  .dsn-sticky-toolbar button, select { min-height: 34px; }
  /* I. Cartes avec boutons CSV / XLSX : le titre garde sa place, les boutons passent dessous si besoin */
  .px-4.pt-3.pb-2.flex.items-start.justify-between.gap-2.border-b { flex-wrap: wrap; padding-right: 36px !important; }
  /* J. Grilles de raccourcis à 3 ou 4 colonnes : une colonne (ou deux) lisible au lieu de mots coupés */
  div.grid[style*="repeat(3, minmax(0px, 1fr))"], div.grid[style*="repeat(3, 1fr)"]:not([style*="margin-top: 44px"]) { grid-template-columns: 1fr !important; }
  div.grid[style*="repeat(4, minmax(0px, 1fr))"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}

/* Ordinateur (cLOCAL514) — les boutons flottants ne recouvrent plus le contenu. */
@media (min-width: 1024px) {
  /* La colonne de boutons d'aide à droite (avis, aide, application) masquait le bord droit des cartes : marge réservée. */
  [data-theme-scope="dashboard"] > div > .flex-1.p-6,
  [data-theme-scope="dashboard"] .flex-1.p-6:has(> .dsn-dashboard-grid) { padding-right: 76px !important; }
  /* « Première visite ? » se posait sur les boutons « Expliquer » / « Aide » : la bulle remonte au-dessus d'eux. */
  #dsn-tour-toast { bottom: 152px !important; animation: dsnToastIn .32s cubic-bezier(.22, 1, .36, 1) both; }
}
@keyframes dsnToastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { #dsn-tour-toast { animation: none !important; } }

/* Finitions (cLOCAL516) : cartes « Ce qui change / Ce qui va arriver / Si je n'agis pas » — la dernière carte
   passait sous les icônes d'agrandissement et d'aide du bloc (titre et « voir plus » recouverts). */
@media (min-width: 768px) {
  .pvb-c110__grid > .pvb-c110__card:last-child .pvb-c110__head { padding-right: 84px; }
}
