/* Les Érudits — feuille de style principale.
   Les couleurs --primaire, --secondaire, --accent et --fond sont injectées depuis les Paramètres. */
:root {
  --primaire: #1F3A5F;
  --secondaire: #C9A227;
  --accent: #2E8B57;
  --fond: #F5F7FA;
  --surface: #ffffff;
  --texte: #1c2533;
  --texte-2: #5b6778;
  --bord: #dde3ea;
  --bord-fort: #c3ccd7;
  --danger: #b3261e;
  --avert: #9a6700;
  --rayon: 10px;
  --ombre: 0 1px 2px rgba(16, 32, 56, .06), 0 2px 8px rgba(16, 32, 56, .05);
  --sidebar: 250px;
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--fond);
  color: var(--texte);
  line-height: 1.45;
}
a { color: var(--primaire); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: 1.55rem; color: var(--primaire); }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
small, .discret { color: var(--texte-2); }
.centre { text-align: center; }
.droite { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 1rem; }
.cache { display: none !important; }

/* ------------------------------------------------------------------ Mise en page */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  background: var(--primaire);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex; gap: .7rem; align-items: center;
  padding: 1.1rem 1rem; color: #fff; text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}
.brand .logo { flex: 0 0 auto; border-radius: 50%; background: #fff; }
.brand-nom { font-size: .78rem; font-weight: 700; letter-spacing: .02em; line-height: 1.25; }
.nav { display: flex; flex-direction: column; padding: .6rem; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .75rem; border-radius: 8px;
  color: rgba(255, 255, 255, .82); text-decoration: none; font-size: .93rem;
}
.nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav a.actif { background: rgba(255, 255, 255, .12); color: #fff; box-shadow: inset 3px 0 0 var(--secondaire); }
.nav a.actif .icone { color: var(--secondaire); }
.sidebar-pied { padding: .8rem 1rem; font-size: .75rem; color: rgba(255, 255, 255, .55); border-top: 1px solid rgba(255, 255, 255, .12); }

.principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .6rem 1.5rem; background: var(--surface);
  border-bottom: 1px solid var(--bord); position: sticky; top: 0; z-index: 10;
}
.burger { display: none; border: 0; background: none; font-size: 1.4rem; cursor: pointer; color: var(--primaire); }
.annee-switch { display: flex; align-items: center; gap: .5rem; }
.annee-switch label { font-size: .8rem; color: var(--texte-2); }
.annee-switch select { width: auto; padding: .3rem .5rem; font-weight: 600; }
.pastille {
  background: color-mix(in srgb, var(--secondaire) 18%, white);
  color: #5c4a07; border: 1px solid color-mix(in srgb, var(--secondaire) 45%, white);
  padding: .2rem .65rem; border-radius: 999px; font-size: .82rem; font-weight: 600;
}
.topbar-droite { margin-left: auto; display: flex; align-items: center; gap: .8rem; }
.utilisateur { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--texte); }
.utilisateur small { display: block; font-size: .75rem; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primaire); color: var(--secondaire); font-weight: 700; font-size: .8rem;
}
.bandeau-archive { background: #fff7db; border-bottom: 1px solid #f0dc9a; padding: .5rem 1.5rem; font-size: .9rem; }
.contenu { padding: 1.5rem; max-width: 1400px; width: 100%; }

.entete-page { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.entete-page h1 { margin: 0; }
.entete-page p { margin: .25rem 0 0; color: var(--texte-2); }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ Cartes */
.carte {
  background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon);
  box-shadow: var(--ombre); padding: 1.2rem; margin-bottom: 1.2rem;
}
.carte > h2:first-child { margin-top: 0; }
.carte-centre { max-width: 560px; margin: 3rem auto; text-align: center; }
.carte-titre { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .8rem; flex-wrap: wrap; }
.carte-titre h2 { margin: 0; }
.grille-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; }
.grille-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.2rem; }
.grille-2 > .carte, .grille-3 > .carte { margin-bottom: 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.kpi {
  background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon);
  box-shadow: var(--ombre); padding: 1rem 1.1rem; border-top: 3px solid var(--primaire);
}
.kpi.or { border-top-color: var(--secondaire); }
.kpi.vert { border-top-color: var(--accent); }
.kpi-label { font-size: .82rem; color: var(--texte-2); }
.kpi-valeur { font-size: 1.8rem; font-weight: 700; color: var(--primaire); line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-detail { font-size: .8rem; color: var(--texte-2); }

/* ------------------------------------------------------------------ Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem .95rem; border-radius: 8px; border: 1px solid var(--bord-fort);
  background: var(--surface); color: var(--texte); font: inherit; font-size: .92rem;
  font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--primaire); }
.btn-primaire { background: var(--primaire); border-color: var(--primaire); color: #fff; }
.btn-primaire:hover { filter: brightness(1.12); }
.btn-or { background: var(--secondaire); border-color: var(--secondaire); color: #231c02; }
.btn-vert { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, white); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-petit { padding: .25rem .55rem; font-size: .82rem; }
.btn-bloc { width: 100%; }
.btn-lien { border: 0; background: none; color: var(--primaire); padding: .3rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }
details.inline { display: inline-block; }
details.inline > summary { list-style: none; }
details.inline > summary::-webkit-details-marker { display: none; }

/* ------------------------------------------------------------------ Formulaires */
label { display: block; font-size: .85rem; font-weight: 600; color: var(--texte-2); margin-bottom: .8rem; }
input, select, textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .5rem .6rem;
  border: 1px solid var(--bord-fort); border-radius: 7px; font: inherit; font-size: .95rem;
  color: var(--texte); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primaire) 35%, transparent); border-color: var(--primaire); }
input[type=checkbox], input[type=radio] { display: inline-block; width: auto; margin: 0 .4rem 0 0; vertical-align: middle; }
input[type=color] { height: 40px; padding: 2px; }
label.case { display: flex; align-items: center; font-weight: 500; color: var(--texte); }
.champs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 1rem; }
.champs .large { grid-column: 1 / -1; }
.requis::after { content: " *"; color: var(--danger); }
fieldset { border: 1px solid var(--bord); border-radius: var(--rayon); padding: 1rem 1.2rem .4rem; margin: 0 0 1rem; }
legend { font-weight: 700; color: var(--primaire); padding: 0 .4rem; }
.filtres { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.filtres label { margin: 0; min-width: 140px; }
.filtres .recherche { flex: 1; min-width: 200px; }
.erreurs { margin: 0 0 1rem; padding-left: 1.2rem; }

/* ------------------------------------------------------------------ Alertes & badges */
.alerte { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; font-size: .92rem; }
.alerte-succes { background: #e8f5ee; border-color: #b5dcc6; color: #19512f; }
.alerte-erreur { background: #fdecea; border-color: #f3c1bc; color: #7d1a14; }
.alerte-info { background: #eaf1f9; border-color: #c4d6ea; color: #1a3b62; }
.alerte-avert { background: #fff7db; border-color: #f0dc9a; color: #5c4506; }
.badge {
  display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 700;
  background: #eef1f5; color: var(--texte-2); white-space: nowrap;
}
.badge-vert { background: #e3f3ea; color: #1d6340; }
.badge-or { background: #fbf1d2; color: #6f5705; }
.badge-bleu { background: #e4ecf6; color: var(--primaire); }
.badge-rouge { background: #fbe4e2; color: #8c1d16; }

/* ------------------------------------------------------------------ Tableaux */
.table-conteneur { overflow-x: auto; border: 1px solid var(--bord); border-radius: var(--rayon); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .55rem .7rem; text-align: left; border-bottom: 1px solid var(--bord); vertical-align: middle; }
thead th {
  background: #f3f6f9; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em;
  color: var(--texte-2); position: sticky; top: 0; z-index: 1;
}
tbody tr:hover { background: #fafbfd; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions-cell { text-align: right; white-space: nowrap; }
.table-compacte th, .table-compacte td { padding: .35rem .5rem; }
tfoot td { font-weight: 700; background: #f8fafc; }
.photo-mini { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: #e8edf3; display: inline-block; vertical-align: middle; }
.initiales { display: inline-grid; place-items: center; font-size: .72rem; font-weight: 700; color: var(--primaire); }

.pagination { display: flex; gap: .3rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.pagination a, .pagination span { padding: .3rem .65rem; border: 1px solid var(--bord); border-radius: 6px; text-decoration: none; background: #fff; }
.pagination .courant { background: var(--primaire); color: #fff; border-color: var(--primaire); }

/* ------------------------------------------------------------------ Onglets */
.onglets { display: flex; gap: .25rem; border-bottom: 2px solid var(--bord); margin-bottom: 1.2rem; flex-wrap: wrap; }
.onglets a { padding: .55rem .9rem; text-decoration: none; color: var(--texte-2); font-weight: 600; font-size: .9rem; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.onglets a.actif { color: var(--primaire); border-bottom-color: var(--secondaire); }
.onglets-secondaires { border-bottom-width: 1px; margin-top: -.6rem; background: #fff; border-radius: 8px 8px 0 0; padding: 0 .4rem; }
.onglets-secondaires a { font-size: .85rem; padding: .45rem .8rem; }
.liste-cases { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .3rem .8rem; margin-bottom: .8rem; }
.liste-cases label { margin: 0; }

/* ------------------------------------------------------------------ Fiche élève */
.fiche { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.2rem; margin: 0; }
.fiche dt { color: var(--texte-2); font-size: .85rem; }
.fiche dd { margin: 0; font-weight: 600; }
.fiche-entete { display: flex; gap: 1.2rem; align-items: center; }
.photo-grande { width: 110px; height: 132px; object-fit: cover; border-radius: 8px; border: 1px solid var(--bord); background: #eef2f6; }
.photo-vide { display: grid; place-items: center; color: var(--texte-2); font-size: 2rem; font-weight: 700; }

/* ------------------------------------------------------------------ Assistant d'inscription */
.etapes { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; counter-reset: etape; }
.etapes button {
  border: 1px solid var(--bord); background: #fff; border-radius: 999px; padding: .35rem .8rem .35rem .4rem;
  font: inherit; font-size: .85rem; color: var(--texte-2); cursor: pointer; display: flex; align-items: center; gap: .4rem;
}
.etapes button::before {
  counter-increment: etape; content: counter(etape); width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; background: #eef1f5; font-weight: 700; font-size: .75rem;
}
.etapes button.actif { border-color: var(--primaire); color: var(--primaire); font-weight: 700; }
.etapes button.actif::before { background: var(--primaire); color: #fff; }
.assistant [data-etape] { display: block; }
.assistant.js [data-etape]:not(.visible) { display: none; }
.assistant-nav { display: flex; justify-content: space-between; gap: .5rem; }

/* ------------------------------------------------------------------ Saisie des notes */
.grille-saisie td { padding: .3rem .6rem; }
.grille-saisie input.note {
  width: 90px; margin: 0; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; padding: .35rem;
}
.grille-saisie input.note.erreur { border-color: var(--danger); background: #fdecea; }
.grille-saisie input.note.ok { border-color: var(--accent); }
.etat { font-size: .78rem; min-width: 80px; display: inline-block; }
.etat.ok { color: var(--accent); }
.etat.erreur { color: var(--danger); }
.etat.encours { color: var(--texte-2); }
.legende { font-size: .82rem; color: var(--texte-2); }
kbd { background: #eef1f5; border: 1px solid var(--bord-fort); border-radius: 4px; padding: 0 .3rem; font-size: .78rem; }

/* ------------------------------------------------------------------ Barres de progression */
.progression { background: #edf1f5; border-radius: 999px; height: 8px; overflow: hidden; min-width: 80px; }
.progression > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.progression.moyen > span { background: var(--secondaire); }
.progression.faible > span { background: #c9523f; }

/* ------------------------------------------------------------------ Graphiques */
.graphique { position: relative; height: 280px; }
.graphique-haut { height: 360px; }

/* ------------------------------------------------------------------ Connexion */
.public { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; flex-direction: column;
  background: linear-gradient(180deg, var(--primaire) 0 46%, var(--fond) 46%); }
.public > .alerte { width: 100%; max-width: 400px; }
.connexion { width: 100%; max-width: 400px; }
.connexion-marque { text-align: center; color: #fff; margin-bottom: 1.2rem; }
.connexion-marque .logo { border-radius: 50%; background: #fff; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); }
.connexion-marque h1 { color: #fff; font-size: 1.1rem; margin: .7rem 0 .2rem; letter-spacing: .02em; overflow-wrap: anywhere; }
.connexion-marque p { margin: 0; color: var(--secondaire); font-weight: 600; font-size: .9rem; }
.connexion-form { padding: 1.6rem; }
.connexion-form h2 { color: var(--primaire); }

/* ------------------------------------------------------------------ Aperçu PDF */
.apercu-pdf { width: 100%; height: 80vh; border: 1px solid var(--bord); border-radius: var(--rayon); background: #525659; }

/* ------------------------------------------------------------------ Responsive (tablette) */
@media (max-width: 1100px) {
  .grille-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.ouverte { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
  .burger { display: block; }
  .grille-2, .grille-3 { grid-template-columns: 1fr; }
  .contenu { padding: 1rem; }
  .topbar { padding: .5rem 1rem; }
  .utilisateur small { display: none; }
}
@media (max-width: 560px) {
  .annee-switch label { display: none; }
  .fiche { grid-template-columns: 1fr; }
  .fiche-entete { flex-direction: column; align-items: flex-start; }
}
@media print {
  .sidebar, .topbar, .actions, .filtres, .onglets { display: none !important; }
  .contenu { padding: 0; }
  .carte { box-shadow: none; }
}
