:root {
  --fond: #f4f6f9;
  --carte: #ffffff;
  --texte: #1c2430;
  --muet: #667085;
  --ligne: #dfe4ea;
  --bleu: #1f4e8c;
  --bleu-clair: #e8eef6;
  --vert: #1f8a4c;
  --vert-clair: #dff3e4;
  --rouge: #c0392b;
  --rouge-clair: #fbe0e0;
  --jaune: #a86b00;
  --jaune-clair: #fff1cc;
  --rayon: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--texte);
  font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fond); }
a { color: var(--bleu); }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 24px 0 10px; }
.muet { color: var(--muet); }
.petit { font-size: .85rem; }
.erreur { color: var(--rouge); }
.chargement { padding: 40px; text-align: center; color: var(--muet); }

/* barre du haut */
.barre { background: var(--bleu); color: #fff; display: flex; align-items: center; gap: 16px; padding: 0 20px; height: 54px; position: sticky; top: 0; z-index: 20; }
.marque { color: #fff; text-decoration: none; font-size: 1.1rem; font-weight: 400; white-space: nowrap; }
.barre nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; }
.barre nav a { color: #dce6f3; text-decoration: none; padding: 7px 11px; border-radius: 7px; white-space: nowrap; }
.barre nav a:hover, .barre nav a.actif { background: rgba(255,255,255,.15); color: #fff; }
.barre nav a.discret { opacity: .75; }

main { max-width: 1400px; margin: 0 auto; padding: 20px; }

/* boutons et champs */
.btn { appearance: none; border: 1px solid var(--ligne); background: #fff; color: var(--texte); border-radius: 8px; padding: 8px 13px; font: inherit; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: #b9c3cf; background: #fafbfc; }
.btn.primaire { background: var(--bleu); border-color: var(--bleu); color: #fff; }
.btn.primaire:hover { background: #193f72; }
.btn.danger { color: var(--rouge); }
.btn.petit { padding: 4px 9px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid var(--ligne); border-radius: 7px; background: #fff; color: var(--texte); min-width: 0; }
textarea { width: 100%; min-height: 60px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; color: var(--muet); }
label > input, label > select, label > textarea { color: var(--texte); font-size: .95rem; }
.grille-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.grille-form .large { grid-column: 1 / -1; }
.case { flex-direction: row; align-items: center; gap: 8px; color: var(--texte); }

.carte { background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 16px; }
.outils { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.entete-page { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; margin-bottom: 16px; }
.fil { font-size: .88rem; margin-bottom: 6px; }
.fil a { text-decoration: none; }

/* semestres */
.semestres { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pastille { border: 1px solid var(--ligne); background: #fff; border-radius: 999px; padding: 6px 13px; cursor: pointer; font: inherit; }
.pastille.actif { background: var(--bleu); color: #fff; border-color: var(--bleu); }

/* cartes de classe */
.classes { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-top: 16px; }
.classe { display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit; border-top: 4px solid var(--bleu); }
.classe:hover { box-shadow: 0 4px 14px rgba(20,40,80,.08); }
.classe h3 { margin: 0; font-size: 1.15rem; }
.etiquette { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--bleu-clair); color: var(--bleu); }
.chiffres { display: flex; gap: 18px; }
.chiffres b { display: block; font-size: 1.3rem; }
.chiffres span { font-size: .8rem; color: var(--muet); }
.barre-prog { height: 6px; background: var(--ligne); border-radius: 3px; overflow: hidden; }
.barre-prog i { display: block; height: 100%; background: var(--vert); }
.vide { text-align: center; padding: 40px 20px; color: var(--muet); }

/* onglets */
.onglets { display: flex; gap: 2px; border-bottom: 1px solid var(--ligne); margin: 8px 0 16px; overflow-x: auto; }
.onglets a { padding: 9px 14px; text-decoration: none; color: var(--muet); border-bottom: 3px solid transparent; white-space: nowrap; }
.onglets a.actif { color: var(--bleu); border-color: var(--bleu); font-weight: 600; }

/* tableaux */
.defile { overflow: auto; background: #fff; border: 1px solid var(--ligne); border-radius: var(--rayon); max-height: calc(100vh - 230px); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 7px 9px; border-bottom: 1px solid var(--ligne); text-align: left; vertical-align: middle; }
th { background: #f7f9fb; font-size: .82rem; color: var(--muet); font-weight: 600; position: sticky; top: 0; z-index: 2; }
tr.abandon td { color: #9aa3ae; }
tr.abandon td.nom { text-decoration: line-through; }
td.nom { white-space: nowrap; }
td.nom a { color: inherit; text-decoration: none; font-weight: 600; }
td.nom a:hover { color: var(--bleu); }
.resume { max-width: 280px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.num { text-align: center; font-variant-numeric: tabular-nums; }

/* grille de présences */
.presences th.seance { text-align: center; min-width: 52px; cursor: default; }
.presences th.seance.annulee { text-decoration: line-through; opacity: .6; }
.presences th.seance.aujourdhui { background: #fff6d6; }
.presences .col-nom { position: sticky; left: 0; background: #fff; z-index: 1; }
.presences th.col-nom { z-index: 3; background: #f7f9fb; }
.cellule { text-align: center; padding: 3px; cursor: pointer; user-select: none; border-left: 1px solid #eef1f4; }
.cellule span { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 30px; border-radius: 6px; font-weight: 700; position: relative; }
.cellule:hover span { outline: 2px solid var(--bleu-clair); }
.cellule.annulee { background: repeating-linear-gradient(45deg, #fafafa, #fafafa 5px, #f0f0f0 5px, #f0f0f0 10px); cursor: default; }
.st-P { background: var(--vert-clair); color: var(--vert); }
.st-A { background: var(--rouge-clair); color: var(--rouge); }
.st-J { background: var(--jaune-clair); color: var(--jaune); }
.cellule .note { position: absolute; top: -3px; right: -4px; font-size: .62rem; background: var(--bleu); color: #fff; border-radius: 4px; padding: 0 3px; font-weight: 600; max-width: 34px; overflow: hidden; white-space: nowrap; }
.legende { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; font-size: .85rem; color: var(--muet); margin-bottom: 10px; }
.legende span.st-P, .legende span.st-A, .legende span.st-J { padding: 1px 7px; border-radius: 5px; font-weight: 700; }
tfoot td { font-weight: 600; background: #f7f9fb; position: sticky; bottom: 0; }

/* appel */
.appel-tete { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.appel-tete select { font-size: 1rem; }
.compteurs { display: flex; gap: 8px; flex-wrap: wrap; }
.compteurs span { padding: 4px 10px; border-radius: 999px; font-weight: 600; font-size: .9rem; }
.appel { display: flex; flex-direction: column; gap: 6px; }
.eleve { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; background: #fff; border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 10px 12px; }
.eleve .qui b { font-size: 1.02rem; }
.eleve .qui .muet { font-size: .82rem; }
.choix { display: flex; gap: 6px; }
.choix button { width: 52px; height: 44px; border-radius: 9px; border: 1px solid var(--ligne); background: #fff; font: inherit; font-weight: 700; cursor: pointer; color: var(--muet); }
.choix button.on.P { background: var(--vert); border-color: var(--vert); color: #fff; }
.choix button.on.A { background: var(--rouge); border-color: var(--rouge); color: #fff; }
.choix button.on.J { background: var(--jaune); border-color: var(--jaune); color: #fff; }
.eleve input.note-eleve { grid-column: 1 / -1; font-size: .88rem; padding: 5px 8px; }
.eleve.P { border-left: 5px solid var(--vert); }
.eleve.A { border-left: 5px solid var(--rouge); }
.eleve.J { border-left: 5px solid var(--jaune); }
.amenag { color: var(--jaune); font-weight: 600; font-size: .8rem; }

/* dialogues */
dialog { border: none; border-radius: 14px; padding: 0; width: min(680px, calc(100vw - 24px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15,25,40,.45); }
dialog form { padding: 20px; display: flex; flex-direction: column; gap: 14px; max-height: calc(100vh - 40px); overflow: auto; }
dialog h2 { margin: 0; }
dialog .pied { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(30px); background: #1c2430; color: #fff; padding: 10px 16px; border-radius: 9px; opacity: 0; transition: .25s; pointer-events: none; z-index: 100; max-width: calc(100vw - 32px); }
#toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.erreur { background: var(--rouge); }

/* connexion */
.page-connexion { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.connexion { width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; }
.connexion h1 { color: var(--bleu); font-weight: 400; }

/* impression */
.impression { display: none; }
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { background: #fff; }
  .barre, .ecran, #toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .impression { display: block; }
  .impression h1 { font-size: 15pt; }
  .impression table { font-size: 9pt; }
  .impression th, .impression td { border: 1px solid #999; padding: 3px 5px; position: static; color: #000; background: #fff; }
  .impression td.m { text-align: center; width: 13mm; height: 7mm; }
}

@media (max-width: 640px) {
  main { padding: 14px 12px; }
  .barre { padding: 0 12px; gap: 8px; }
  .barre nav a { padding: 7px 8px; }
  .barre nav a.discret { display: none; }
  h1 { font-size: 1.25rem; }
  .defile { max-height: calc(100vh - 200px); }
}
