:root {
  --fond: #f5f6f8; --carte: #fff; --texte: #1d2330; --doux: #667085; --bord: #d9dde3;
  --accent: #1f5fa8; --ok: #2e7d32; --ko: #c62828; --alerte: #b26a00;
  font-family: system-ui, "Segoe UI", Roboto, sans-serif; font-size: 15px; color: var(--texte);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fond); }
a { color: var(--accent); }

.entete { display: flex; align-items: center; gap: 2rem; padding: .6rem 1.2rem; background: var(--accent); color: #fff; }
.entete h1 { font-size: 1.1rem; margin: 0; font-weight: 600; }
#onglets button { background: none; border: 0; color: #fff; opacity: .75; }
#onglets button.actif, #onglets button:hover { opacity: 1; background: rgba(255, 255, 255, .18); }
#bandeau-erreur { background: var(--ko); color: #fff; padding: .5rem 1.2rem; }
main { padding: 1rem 1.2rem; max-width: 1400px; margin: 0 auto; }

button, .bouton { font: inherit; font-size: .9rem; padding: .3rem .7rem; border: 1px solid var(--bord);
  background: var(--carte); border-radius: 4px; cursor: pointer; color: inherit; text-decoration: none; }
button:hover, .bouton:hover { border-color: var(--accent); }
button.actif { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--ko); border-color: var(--ko); align-self: flex-start; }
input, textarea, select { font: inherit; font-size: .9rem; padding: .25rem .4rem; border: 1px solid var(--bord);
  border-radius: 4px; background: #fff; color: inherit; }
textarea { width: 100%; resize: vertical; }
label { display: block; margin: .4rem 0; }
label > input[type=text], label > textarea { display: block; width: 100%; margin-top: .2rem; }
label.en-ligne { display: inline-flex; align-items: center; gap: .4rem; margin: 0; }
.case { display: inline-flex; align-items: center; gap: .25rem; margin: .15rem .7rem .15rem 0; white-space: nowrap; }

.barre { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .8rem 0; }
.espace { flex: 1; }
.info { background: #eef4fb; border-left: 3px solid var(--accent); padding: .5rem .8rem; }
.resume { display: flex; flex-wrap: wrap; gap: 1.5rem; background: var(--carte); border: 1px solid var(--bord);
  border-radius: 6px; padding: .7rem 1rem; }

table { border-collapse: collapse; width: 100%; background: var(--carte); }
th, td { border-bottom: 1px solid var(--bord); padding: .35rem .5rem; text-align: left; vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .02em; color: var(--doux); font-weight: 600; }
th.triable { cursor: pointer; user-select: none; }
table.classe tbody tr { cursor: pointer; }
table.classe tbody tr:hover { background: #f0f4fa; }
tr.en-alerte td:first-child { box-shadow: inset 3px 0 var(--alerte); }
.sans-sujet { color: var(--ko); font-weight: 600; }
.etiquette { font-size: .75rem; background: #eceef1; border-radius: 3px; padding: 0 .3rem; color: var(--doux); }
.pastille { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; border: 1px solid var(--doux); margin-right: 2px; }
.pastille.ok { background: var(--ok); border-color: var(--ok); }
.sep { display: inline-block; width: .5rem; }
.presence { display: inline-block; width: 1.3rem; text-align: center; font-size: .8rem; font-weight: 600; }
.presence.present, td.present { color: var(--ok); }
.presence.absent, td.absent { color: var(--ko); }
.presence.vide { color: var(--bord); }
td.observation { max-width: 22rem; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.date { color: var(--doux); font-size: .8rem; }
.alerte { color: var(--alerte); font-size: 1.1rem; }

td.saisie input { width: 100%; }
.presence-choix { white-space: nowrap; }
.presence-choix button { padding: .2rem .55rem; }
.presence-choix button.actif.present { background: var(--ok); border-color: var(--ok); }
.presence-choix button.actif.absent { background: var(--ko); border-color: var(--ko); }

fieldset { border: 1px solid var(--bord); border-radius: 4px; margin: 0; }
legend { font-size: .8rem; color: var(--doux); }

.fiche h2 { margin: .2rem 0; }
.sous-titre { color: var(--doux); margin-top: 0; }
.alertes { color: var(--alerte); padding-left: 0; list-style: none; }
.bloc { background: var(--carte); border: 1px solid var(--bord); border-radius: 6px; padding: .8rem 1rem; margin: 1rem 0; }
.bloc h3 { margin: .2rem 0 .5rem; font-size: 1rem; }
.deux-colonnes { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.note-grille { font-weight: normal; color: var(--doux); font-size: .9rem; margin-left: .5rem; }
.grille tr.capacite th { background: #f0f2f5; text-transform: none; letter-spacing: 0; color: var(--texte); font-size: .85rem; }
.grille td.libelle { font-size: .88rem; }
.grille .id { color: var(--doux); font-size: .75rem; margin-right: .2rem; }
.grille td.poids { color: var(--doux); font-size: .8rem; text-align: right; width: 2.5rem; }
.grille td.niveaux { white-space: nowrap; width: 12rem; }
.niveau { padding: .15rem .45rem; font-size: .8rem; }

@page { size: A4 portrait; margin: 12mm; }
@page paysage { size: A4 landscape; margin: 10mm; }
@media print {
  :root { font-size: 9.5pt; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  body[data-vue="classe"] main { page: paysage; }
  .entete, #bandeau-erreur, .barre, .info, .ecran { display: none !important; }
  .bloc { border: 0; padding: 0; margin: .6rem 0; }
  .resume { border: 0; padding: 0; }
  th, td { padding: .12rem .3rem; }
  table.classe tr, .grille tr { break-inside: avoid; }
  .grille h3 { break-after: avoid; }
  input, textarea, select { border: 0; padding: 0; background: none; }
  textarea { resize: none; }
  .grille table { table-layout: fixed; }
  .grille td.libelle { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .grille col.c-poids { width: 2rem; }
  .grille col.c-niveaux { width: 3rem; }
  .niveau { display: none; }
  .niveau.actif { display: inline-block; background: none !important; color: var(--texte); border: 1px solid var(--texte); }
  td.observation { max-width: 16rem; }
}

/* ---------- Spécifique E32 ---------- */
input.court { width: 10rem; }
.aide { color: var(--doux); font-size: .82rem; margin: .3rem 0; }
.aide-ligne { display: block; color: var(--doux); font-size: .76rem; }
.cases { display: flex; flex-wrap: wrap; }
.valide { color: var(--ok); font-weight: 700; }
td.support { max-width: 18rem; font-size: .88rem; }
td.binome { white-space: nowrap; font-size: .88rem; }
.choix { width: 1.6rem; text-align: center; cursor: pointer; }
.choix input { pointer-events: none; }  /* le clic est traité par la cellule */
body[data-vue="fiches"] .fiche + .fiche { margin-top: 2rem; padding-top: 1rem; border-top: 3px solid var(--bord, #ccc); }
@media print {
  body[data-vue="fiches"] .fiche + .fiche { break-before: page; margin-top: 0; padding-top: 0; border-top: 0; }
}
td.taux { white-space: nowrap; font-size: .85rem; }

/* Parties du dossier (tableau Classe) */
.partie { display: inline-block; min-width: 1.35rem; text-align: center; font-size: .75rem; font-weight: 600;
  border: 1px solid var(--bord); border-radius: 3px; margin-right: 2px; color: var(--doux); background: #fff; }
.partie.partiel { background: #fdf1d8; border-color: #e0b85c; color: var(--texte); }
.partie.complet { background: #e3ecf8; border-color: #8fb1dd; color: var(--texte); }
.partie.valide { background: var(--ok); border-color: var(--ok); color: #fff; }

/* Puces des sous-parties (onglet Séance) */
td.puces { white-space: normal; }
.groupe-puces { display: inline-block; margin-right: .5rem; white-space: nowrap; }
.puce { font-size: .72rem; padding: .05rem .28rem; margin: 1px; border-radius: 3px; color: var(--doux); }
.puce.redige { background: var(--accent); border-color: var(--accent); color: #fff; }
td.parties, td.oral { white-space: nowrap; }
.puce.valide { background: var(--ok); border-color: var(--ok); color: #fff; }
span.puce { border: 1px solid; }

/* Dossier technique (fiche élève) */
.dossier table { table-layout: fixed; }
.dossier col.c-id { width: 2.8rem; }
.dossier col.c-etat { width: 15rem; }
.dossier td.id { color: var(--doux); font-size: .85rem; }
.dossier td.etats { white-space: nowrap; text-align: right; }
.etat { padding: .15rem .45rem; font-size: .8rem; }
.etat.actif.etat-afaire { background: #9aa3b0; border-color: #9aa3b0; }
.etat.actif.etat-redige { background: var(--accent); border-color: var(--accent); }
.etat.actif.etat-valide { background: var(--ok); border-color: var(--ok); }
.dossier tr.etat-valide td.libelle { color: var(--ok); }

/* Bilans */
.grille col.c-niveaux { width: 9.5rem; }
.grille td.niveaux { width: auto; text-align: center; }
.grille td.niveaux.attendu { background: #eef4fb; }
.grille thead th { text-align: center; text-transform: none; }
.taux-bilan { display: block; color: var(--texte); font-size: .9rem; }
.niveau.actif.niv-0 { background: #c62828; border-color: #c62828; }
.niveau.actif.niv-1 { background: #ef6c00; border-color: #ef6c00; }
.niveau.actif.niv-2 { background: #2e7d32; border-color: #2e7d32; }
.niveau.actif.niv-3 { background: #1b5e20; border-color: #1b5e20; }
.trois-colonnes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
table.etapes input[type=date] { width: 10rem; }

@media (max-width: 800px) {
  .deux-colonnes, .trois-colonnes { grid-template-columns: 1fr; }
  .entete { flex-wrap: wrap; gap: .5rem; }
  table.classe { display: block; overflow-x: auto; }
}

@media print {
  .aide-ligne, .aide { display: none; }
  .etat { display: none; }
  .etat.actif { display: inline-block; background: none !important; color: var(--texte); border: 1px solid var(--texte); }
  .dossier col.c-etat { width: 5rem; }
  .grille col.c-niveaux { width: 4rem; }
  .dossier tr, .grille tr { break-inside: avoid; }
}

/* Utilisateur connecté et déconnexion (masqués à l'impression avec .entete) */
#utilisateur { font-size: .9rem; }
.entete button[data-action="deconnexion"] { background: none; border-color: rgba(255, 255, 255, .6); color: #fff; }
.entete button[data-action="deconnexion"]:hover { background: rgba(255, 255, 255, .18); }

/* Page de connexion */
.page-connexion { max-width: 24rem; margin: 3rem auto; padding: 0 1.2rem; }
.page-connexion h1 { font-size: 1.3rem; }
.page-connexion form { display: grid; gap: .8rem; }
.page-connexion label { display: grid; gap: .25rem; }
.page-connexion input { font: inherit; padding: .4rem .5rem; border: 1px solid var(--bord); border-radius: 4px; }
#erreur-connexion { color: var(--ko); margin-top: .8rem; min-height: 1.2em; }
