:root {
  --bleu: #185FA5;
  --bleu-clair: #E6F1FB;
  --texte: #2C2C2A;
  --gris: #5F5E5A;
  --bord: rgba(0,0,0,.12);
  --fond: #F7F6F2;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--texte); background: var(--fond); line-height: 1.5;
}
a { color: var(--bleu); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: .2rem 0 .6rem; }
h2 { font-size: 1.15rem; margin: 1.2rem 0 .5rem; }

/* Barre de navigation */
.barre {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bleu); color: #fff; padding: .6rem 1rem; flex-wrap: wrap; gap: .5rem;
}
.barre .logo { color: #fff; font-weight: 600; font-size: 1.05rem; }
.barre nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.barre nav a { color: #fff; }
.barre .qui { font-size: .85rem; opacity: .9; }
.barre .deco { background: rgba(255,255,255,.18); padding: .3rem .7rem; border-radius: 6px; }

.contenu { max-width: 1200px; margin: 0 auto; padding: 1rem; }

/* Connexion */
.carte-connexion {
  max-width: 360px; margin: 8vh auto; background: #fff; padding: 2rem;
  border-radius: 14px; box-shadow: 0 4px 24px rgba(0,0,0,.08); text-align: center;
}
.carte-connexion h1 { font-size: 1.4rem; }
.carte-connexion .sous-titre { color: var(--gris); margin-top: -.4rem; }
.carte-connexion form { display: flex; flex-direction: column; gap: .9rem; margin-top: 1.2rem; text-align: left; }
.carte-connexion label { font-size: .85rem; color: var(--gris); display: flex; flex-direction: column; gap: .25rem; }
.alerte { background: #FCEBEB; color: #A32D2D; padding: .5rem; border-radius: 8px; font-size: .9rem; }

input, select, textarea, button {
  font: inherit; padding: .55rem .6rem; border: 1px solid var(--bord);
  border-radius: 8px; background: #fff; width: 100%;
}
button {
  background: var(--bleu); color: #fff; border: none; cursor: pointer; font-weight: 600;
  width: auto; padding: .6rem 1.1rem;
}
button:hover:not(:disabled) { background: #134c84; }
button:disabled { opacity: .45; cursor: not-allowed; }

/* Cartes formation */
.liste-cartes { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin-top: 1rem; }
.carte-formation {
  background: #fff; border: 1px solid var(--bord); border-radius: 12px; padding: 1rem;
  display: block; color: var(--texte); transition: box-shadow .15s;
}
.carte-formation:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); text-decoration: none; }
.carte-formation.statique:hover { box-shadow: none; }
.carte-formation h2 { margin: 0 0 .3rem; font-size: 1.1rem; color: var(--bleu); }
.carte-formation p { margin: .2rem 0 .6rem; font-size: .9rem; color: var(--gris); }

.badge { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.badge-valide { background: #EAF3DE; color: #3B6D11; }
.badge-encours { background: #FAEEDA; color: #854F0B; }

/* Sélecteur encadrant */
.selecteur { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; background: #fff; padding: 1rem; border-radius: 12px; border: 1px solid var(--bord); }
.selecteur label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--gris); flex: 1; min-width: 160px; }

/* En-tête grille */
.entete-grille { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 1rem; }
.formation-nom { color: var(--gris); margin: 0; }
.actions-entete { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.bouton-lien { background: #fff; border: 1px solid var(--bord); padding: .45rem .8rem; border-radius: 8px; color: var(--bleu); }
.inline-form { margin: 0; }
.inline-form select { width: auto; }

/* Légende */
.legende { display: flex; gap: .6rem; flex-wrap: wrap; margin: 1rem 0; }
.puce { font-size: .8rem; padding: .25rem .6rem; border-radius: 999px; color: #fff; background: var(--c); }

/* Bloc ajout plongée */
.bloc-plongee { margin: .5rem 0 1rem; background: #fff; border: 1px solid var(--bord); border-radius: 10px; padding: .6rem 1rem; }
.bloc-plongee summary { cursor: pointer; font-weight: 600; color: var(--bleu); }
.form-plongee { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; margin-top: .8rem; }
.form-plongee label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--gris); flex: 1; min-width: 150px; }

/* Tableau / grille */
.tableau-defilant { overflow-x: auto; border: 1px solid var(--bord); border-radius: 12px; background: #fff; }
table.grille { border-collapse: collapse; width: 100%; font-size: .85rem; }
table.grille th, table.grille td { border: 1px solid var(--bord); padding: .35rem .45rem; vertical-align: top; }
.col-item { min-width: 230px; max-width: 280px; position: sticky; left: 0; background: #fff; z-index: 2; }
.col-plongee { min-width: 130px; text-align: center; background: var(--bleu-clair); }
.col-plongee .num { font-weight: 700; }
.col-plongee .date { font-size: .75rem; color: var(--gris); }
.ligne-commentaires th.col-plongee { background: #fbf9f3; font-weight: 400; }
.form-comm { margin: 0; }
.form-comm textarea { font-size: .75rem; resize: vertical; }
.comm-lecture { font-size: .75rem; color: var(--gris); white-space: normal; }

.ligne-competence td { background: var(--bleu); color: #fff; font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; position: sticky; left: 0; }

.item-tete { display: flex; align-items: center; gap: .4rem; }
.code { font-weight: 700; color: var(--bleu); }
.imp { display: inline-flex; align-items: center; justify-content: center; width: 1.3rem; height: 1.3rem; border-radius: 50%; font-size: .72rem; font-weight: 700; color: #fff; }
.imp-1 { background: #E24B4A; } .imp-2 { background: #D85A30; } .imp-3 { background: #EF9F27; } .imp-4 { background: #639922; } .imp-5 { background: #888780; }
.item-tech { font-size: .8rem; color: var(--texte); margin-top: .15rem; }
.item-rem { font-size: .72rem; color: var(--gris); font-style: italic; }

.cellule { text-align: center; }
.sel-statut {
  width: 100%; min-width: 110px; border: 2px solid var(--c); border-radius: 6px;
  background: var(--c); color: #fff; font-size: .72rem; font-weight: 600; padding: .3rem;
  cursor: pointer;
}
.sel-statut option { background: #fff; color: var(--texte); }
.sel-statut.enregistre { opacity: .5; }
.sel-statut.ok { outline: 3px solid #639922; }
.sel-statut.erreur { outline: 3px solid #E24B4A; }
.pastille { display: inline-block; padding: .25rem .5rem; border-radius: 6px; background: var(--c); color: #fff; font-size: .72rem; font-weight: 600; }

/* Admin */
.grille-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.bloc-admin { background: #fff; border: 1px solid var(--bord); border-radius: 12px; padding: 1rem; }
.bloc-admin form { display: flex; flex-direction: column; gap: .6rem; }
.bloc-admin label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--gris); }
.tableau-hist { background: #fff; }
.tableau-hist th { background: var(--bleu-clair); position: static; }
.info { background: #EAF3DE; color: #3B6D11; padding: .5rem .8rem; border-radius: 8px; }
.vide { color: var(--gris); font-style: italic; }

.carte-formulaire {
  max-width: 420px; margin: 2rem auto; background: #fff; padding: 1.6rem;
  border-radius: 14px; border: 1px solid var(--bord);
}
.carte-formulaire form { display: flex; flex-direction: column; gap: .9rem; margin-top: 1rem; }
.carte-formulaire label { font-size: .85rem; color: var(--gris); display: flex; flex-direction: column; gap: .25rem; }
.oubli { margin-top: 1.2rem; font-size: .82rem; color: var(--gris); text-align: center; }
.aide { font-size: .8rem; color: var(--gris); margin: 0 0 .5rem; }

/* Mobile */
@media (max-width: 640px) {
  .col-item { min-width: 160px; max-width: 200px; }
  .col-plongee { min-width: 110px; }
  h1 { font-size: 1.25rem; }
}

/* --- Ajouts : droit de validation, items, synthèse --- */

.checkbox-ligne { flex-direction: row !important; align-items: center; gap: .5rem; }
.checkbox-ligne input { width: auto; }

.bascule { width: auto; padding: .25rem .7rem; border-radius: 999px; font-size: .8rem; font-weight: 600; border: none; cursor: pointer; }
.bascule-on { background: #EAF3DE; color: #3B6D11; }
.bascule-off { background: #EFEDE7; color: #6b6a64; }
.gris { color: var(--gris); }

.bouton-secondaire { background: #fff; color: var(--bleu); border: 1px solid var(--bord); }
.bouton-secondaire:hover { background: var(--bleu-clair); }

/* Formulaire item */
.form-item { display: flex; gap: .8rem; flex-wrap: wrap; align-items: flex-end; margin-top: .8rem; }
.form-item label { display: flex; flex-direction: column; gap: .25rem; font-size: .8rem; color: var(--gris); flex: 1; min-width: 120px; }
.form-item label.large { flex: 2 1 100%; }

/* Edition item repliable */
.item-edit { width: 100%; }
.item-edit summary { cursor: pointer; padding: .5rem .6rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.item-edit summary:hover { background: var(--bleu-clair); }
.resume-comp { font-size: .72rem; color: var(--gris); text-transform: uppercase; letter-spacing: .02em; }
.resume-tech { font-size: .85rem; }
.item-edit-corps { padding: .6rem; display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; border-top: 1px solid var(--bord); }
.ligne-archivee { opacity: .55; }
.aide { font-size: .82rem; color: var(--gris); font-style: italic; margin-top: .6rem; }

/* Synthèse */
.bloc-synthese { background: #fff; border: 1px solid var(--bord); border-radius: 12px; padding: 1rem 1.2rem; margin: 1rem 0; }
.synthese-tete { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.synthese-tete h2 { margin: 0; font-size: 1rem; flex: 1 1 240px; text-transform: uppercase; letter-spacing: .02em; color: var(--bleu); }
.barre-progression { flex: 1 1 160px; height: 12px; background: #EFEDE7; border-radius: 999px; overflow: hidden; min-width: 120px; }
.barre-remplie { height: 100%; background: #639922; border-radius: 999px; transition: width .3s; }
.compteur { font-size: .85rem; color: var(--gris); font-weight: 600; }
.puces-recap { display: flex; gap: .5rem; flex-wrap: wrap; margin: .7rem 0; }
.liste-items { list-style: none; padding: 0; margin: .5rem 0 0; }
.liste-items li { display: flex; align-items: center; gap: .6rem; padding: .35rem 0; border-top: 1px solid var(--bord); flex-wrap: wrap; }
.liste-items .item-tech { flex: 1; min-width: 140px; }
.alerte-faute { color: #B23B3A; font-size: .78rem; font-weight: 600; }

/* --- Actions admin : suppression / archivage --- */
.actions-cellule { display: flex; gap: .4rem; flex-wrap: wrap; }
.bouton-danger { width: auto; padding: .35rem .7rem; background: #fff; color: #B23B3A; border: 1px solid #E0B4B3; border-radius: 8px; font-size: .8rem; cursor: pointer; font-weight: 600; }
.bouton-danger:hover { background: #FCEBEB; }
.actions-cellule .bouton-secondaire { padding: .35rem .7rem; font-size: .8rem; }

/* --- Journal des plongées --- */
.puce-eleve { display: inline-block; background: var(--bleu-clair); color: var(--bleu); border-radius: 999px; padding: .15rem .55rem; font-size: .78rem; margin: .1rem .15rem .1rem 0; }

/* --- Feuille de présence --- */
.liste-presence { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .5rem; margin: 1rem 0; }
.case-presence { display: flex; align-items: center; gap: .6rem; background: #fff; border: 1px solid var(--bord); border-radius: 10px; padding: .6rem .8rem; cursor: pointer; }
.case-presence:hover { background: var(--bleu-clair); }
.case-presence input { width: auto; }
.nom-presence { flex: 1; }
.badge-inscrit { font-size: .72rem; background: #EAF3DE; color: #3B6D11; border-radius: 999px; padding: .15rem .5rem; }
.barre-actions { display: flex; gap: .8rem; align-items: center; margin-top: 1rem; }
.lien-presence { display: inline-block; font-size: .68rem; margin-top: .2rem; color: var(--bleu); text-decoration: underline; }

/* --- Onglets de filtre (journal) --- */
.onglets-filtre { display: flex; gap: .5rem; margin: .5rem 0 1rem; }
.onglet { padding: .45rem .9rem; border-radius: 8px; border: 1px solid var(--bord); background: #fff; color: var(--bleu); }
.onglet:hover { background: var(--bleu-clair); text-decoration: none; }
.onglet-actif { background: var(--bleu); color: #fff; border-color: var(--bleu); }
.onglet-actif:hover { background: var(--bleu); color: #fff; }

/* --- Badge encadrant désigné (feuille de présence) --- */
.badge-encadrant { font-size: .72rem; background: #E8EEF6; color: #1B4F8A; border-radius: 999px; padding: .15rem .5rem; margin-left: .3rem; }

/* --- Bouton commentaire d'évaluation --- */
.btn-comm { width: auto; background: transparent; border: none; cursor: pointer; font-size: .85rem; opacity: .35; padding: .1rem .2rem; margin-top: .15rem; }
.btn-comm:hover { opacity: .8; }
.btn-comm.a-comm { opacity: 1; color: #D85A30; }

/* --- Synthèse rapide (3 colonnes) --- */
.colonnes-rapide { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin-top: 1rem; }
.col-rapide { background: #fff; border: 1px solid var(--bord); border-radius: 12px; padding: 1rem; border-top: 4px solid var(--bord); }
.col-rapide h2 { font-size: 1rem; margin: 0 0 .6rem; }
.col-rapide ul { list-style: none; padding: 0; margin: 0; }
.col-rapide li { padding: .35rem 0; border-top: 1px solid var(--bord); font-size: .9rem; }
.col-acquis { border-top-color: #639922; }
.col-encours { border-top-color: #EF9F27; }
.col-travailler { border-top-color: #D85A30; }

/* --- Bouton supprimer plongée (en-tête de colonne grille) --- */
.form-suppr-plongee { display: inline; margin: 0; }
.btn-suppr-plongee { width: auto; background: transparent; border: none; cursor: pointer; font-size: .8rem; opacity: .4; padding: .1rem; margin-top: .1rem; }
.btn-suppr-plongee:hover { opacity: 1; }
