/* One sur téléphone (écrans de 760 px et moins) : menu en tiroir latéral, en-tête compact, tableaux à défilement horizontal,
   fenêtres plein écran, cibles tactiles de 44 px, champs à 16 px (pas de zoom automatique sur iPhone). Le bureau n'est pas modifié. */
@media (max-width: 760px) {
  :root { --nav-h: 0px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px); }
  html { -webkit-text-size-adjust: 100%; }
  body { font-size: 15px; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
  #shell { display: block; min-height: 100dvh; }

  /* navigation : tiroir latéral (bouton ☰ du bandeau), mêmes groupes que sur ordinateur */
  nav#nav { position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); height: 100dvh; z-index: 70; padding: calc(14px + var(--safe-t)) 0 calc(12px + var(--safe-b)); transform: translateX(-102%); transition: transform .22s ease; box-shadow: none; overflow-y: auto; }
  body.nav-open nav#nav { transform: none; box-shadow: 20px 0 50px -10px rgba(0,0,0,.6); }
  nav#nav a span, nav#nav h3, nav#nav .brand span { display: inline !important; }
  nav#nav h3 { display: block !important; }
  nav#nav a { justify-content: flex-start; padding: 11px 12px; font-size: 15px; }
  nav#nav svg { width: 20px; height: 20px; }
  .navscrim { position: fixed; inset: 0; z-index: 65; background: rgba(0,0,0,.55); backdrop-filter: blur(2px); }
  header .navbtn { display: inline-grid !important; order: 0 !important; }
  .htitle { order: 1; flex: 1 1 auto; }
  .crumb { font-size: 9.5px; }

  /* en-tête compact */
  main > header { flex-wrap: wrap; gap: 6px 8px; padding: calc(8px + var(--safe-t)) 12px 8px; }
  main > header h1 { font-size: 17px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  main > header #sub { order: 4; flex: 1 0 100%; font-size: 12px; margin-top: -4px; }
  main > header .sp, main > header .demo { display: none; }
  main > header .btn { order: 2; min-height: 40px; }
  main > header #logout { padding: 7px 10px; font-size: 12px; }
  #view { padding: 12px 12px calc(var(--nav-h) + var(--safe-b) + 22px); }
  .banner { padding: 8px 12px; }

  /* cibles tactiles et champs lisibles */
  .btn { min-height: 44px; padding: 9px 14px; }
  .btn.sm { min-height: 38px; padding: 6px 11px; }
  .iconbtn { min-width: 44px; }
  input, select, textarea { font-size: 16px; min-height: 44px; }
  input[type="checkbox"], input[type="radio"] { min-height: 0; width: 20px; height: 20px; }
  .tab { padding: 11px 14px; white-space: nowrap; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -12px; margin-right: -12px; padding: 0 12px; }
  .tabs::-webkit-scrollbar { display: none; }

  /* filtres, formulaires, grilles */
  .toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; }
  .toolbar > label:first-child, .toolbar > .row, .toolbar > .btn { grid-column: 1 / -1; }
  .toolbar label { font-size: 12px; } .toolbar .btn { width: 100%; }
  .toolbar input, .toolbar select { width: 100%; }
  .form2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
  .kpi b { font-size: 21px; } .kpi span { font-size: 12px; }
  .card { padding: 13px; }
  .grid { grid-template-columns: 1fr; }
  .cols, .split, .dash-cols { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
  .detail { position: static; }
  #map { height: 260px; }

  /* tableaux : défilement horizontal, première colonne gardée visible */
  .tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -12px; border-radius: 0; border-left: 0; border-right: 0; }
  .tablewrap table { border: 0; border-radius: 0; min-width: 640px; }
  .tablewrap td:first-child, .tablewrap th:first-child { position: sticky; left: 0; z-index: 1; background: var(--panel); box-shadow: 1px 0 0 var(--line); }
  .tablewrap th:first-child { background: var(--bg); }
  th, td { padding: 10px 10px; }

  /* fenêtres : plein écran, bouton d'action toujours accessible */
  dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; padding: 16px 14px calc(16px + var(--safe-b)); overflow-y: auto; }
  dialog .row.end { position: sticky; bottom: 0; background: var(--panel); padding: 10px 0 calc(6px + var(--safe-b)); margin-top: 12px !important; border-top: 1px solid var(--line); }
  dialog .row.end .btn { flex: 1; }
  dialog.wide { width: 100vw; }

  /* cloche, assistant : au-dessus de la barre de navigation */
  .rempop { top: calc(54px + var(--safe-t)); left: 8px; right: 8px; width: auto; max-height: calc(100dvh - var(--nav-h) - var(--safe-b) - 70px); }
  .remi { padding: 11px 6px; }
  .ai-fab { right: 14px; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); padding: 11px 16px; }
  .ai-panel { width: 100vw; bottom: 0; top: 0; padding-bottom: var(--safe-b); }
  .ai-panel header { padding-top: calc(12px + var(--safe-t)); }
  #tpanel { width: 100vw !important; }
  #sysalert { padding: 8px 12px; }

  .seg { display: flex; width: 100%; } .seg button { flex: 1; white-space: nowrap; min-height: 42px; }

  /* planning (Gantt) et cartes : on garde le défilement horizontal natif */
  .gantt-wrap, .gt-scroll, #gantt { -webkit-overflow-scrolling: touch; }
  .login-card { padding: 22px; }
}

/* iPhone / Android en mode « application » (écran d'accueil ou APK) : pas de rebond de la page, zones sûres */
@media (display-mode: standalone) and (max-width: 760px) { body { user-select: none; } input, textarea { user-select: text; } }

/* Mode intégré (ouvert dans l'application Android) : l'application fournit la navigation et l'en-tête */
html.embed nav#nav, html.embed main > header { display: none !important; }
html.embed #view { padding: 12px 12px 28px; }
html.embed .ai-fab { bottom: 16px; }
html.embed .rempop { top: 8px; }
html.embed #shell { min-height: 100vh; }@media (max-width: 760px) { main > header #logout { display: none; } nav .who .who-out { display: block; } }
