/* Mise en page adaptée à l'écran (chargée après les autres feuilles)
 *  - téléphone (< 760 px) : une colonne, onglets en haut (rien ne change)
 *  - tablette / petit écran (≥ 760 px) : cartes sur deux colonnes, onglets en haut
 *  - ordinateur (≥ 1100 px) : menu des onglets à gauche, contenu en grille
 * Chaque onglet (.panel) est une grille ; ce qui doit prendre toute la largeur porte la classe .wide (ou est un
 * titre, une introduction, une erreur, une barre de filtres). Les cartes d'une même rangée gardent leur hauteur
 * propre (align-items: start) : rien ne saute quand une carte s'ouvre. */

@media (min-width: 760px) {
  main { max-width: 1280px; padding: 32px 28px 64px; }
  header { margin-bottom: 28px; }
  h1 { font-size: 1.4rem; }
  #login { max-width: 420px; margin: 48px auto 0; }

  .panel, #stats-content, #profiles {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start;
  }
  .panel > *, #stats-content > *, #profiles > * { margin: 0; min-width: 0; }
  .panel > .intro, .panel > h2, .panel > .error, .panel > .filters, .panel > .wide, .panel > .group,
  .panel > #stats-content, .panel > #profiles, #stats-content > .tiles, #stats-content > .wide,
  #stats-content > .intro, #stats-content > .error, #profiles > .muted, #profiles > .error { grid-column: 1 / -1; }
  .panel > h2 { margin: 16px 0 -4px; }
  .panel > .intro { max-width: 80ch; }
  .panel > .error:empty { display: none; }

  /* Enfants : chaque bloc (titre + carte) est une cellule de la grille */
  .section > h2 { margin: 0 0 12px; }
  .section > .card { margin: 0; }
  #tab-enfants h2:first-of-type { margin-top: 0; }

  /* Accès Internet : gestion groupée et Wi-Fi côte à côte, puis le planning, puis les profils */
  #tab-acces > #group, #tab-acces > #wifi-card { order: 1; grid-column: auto; }
  #tab-acces > #schedule { order: 2; grid-column: 1 / -1; }
  #tab-acces > h2, #tab-acces > #profiles, #tab-acces > #profiles-error { order: 3; }
  #tab-acces > #new-profile { order: 4; }

  /* Listes de profils et réglages : la grille des services prend la place disponible */
  .tiles { gap: 12px; }
  .log li { grid-template-columns: 64px 1fr auto; }
}

@media (min-width: 1100px) {
  main { padding: 36px 32px 72px; }
  #app { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 36px; align-items: start; }
  #app[hidden] { display: none !important; }

  /* Menu latéral */
  .tabs { position: sticky; top: 24px; flex-direction: column; gap: 2px; margin: 0; border-bottom: 0; overflow: visible; }
  .tabs button { display: flex; align-items: center; justify-content: space-between; text-align: left; border-bottom: 0;
    border-radius: 10px; padding: 10px 14px; border: 1px solid transparent; }
  .tabs button:hover { color: var(--text); background: var(--card); }
  .tabs button[aria-selected=true] { color: var(--text); background: var(--card); border-color: var(--border); }
  .tabs .tag { margin-left: 8px; }

  .panel, #profiles { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }
  #stats-content { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 22px 24px; }
}

@media (min-width: 1500px) {
  main { max-width: 1440px; }
}
