:root {
  --bleu: #2f6fed;
  --bleu-clair: #f5f7fb;
  --rouge: #d9363e;
  --rouge-clair: #fdecea;
  --vert: #2e9e5b;
  --gris-texte: #666;
  --gris-bordure: #ddd;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #222;
  background: #fff;
}

a {
  color: var(--bleu);
  text-decoration: none;
}

/* En-tête / navigation */
#entete {
  border-bottom: 1px solid var(--gris-bordure);
}
.entete-conteneur {
  max-width: 1000px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.entete-marque {
  font-weight: 700;
  font-size: 18px;
}
.entete-nav {
  display: flex;
  gap: 18px;
  flex: 1;
}
.entete-nav a {
  color: #444;
  font-weight: 600;
  font-size: 14px;
}
.entete-nav a:hover {
  color: var(--bleu);
}
.entete-utilisateur {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
  color: var(--gris-texte);
}

/* Layout général */
.page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}
.page-etroite {
  max-width: 480px;
  margin: 60px auto;
  padding: 0 24px;
}

h1 {
  font-size: 26px;
  margin: 0 0 6px;
}
h2 {
  font-size: 19px;
  margin: 28px 0 14px;
}
.sous-titre {
  color: var(--gris-texte);
  margin: 0 0 20px;
}

/* Formulaires */
.champ {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--gris-bordure);
  border-radius: var(--radius);
  font-size: 15px;
  margin-bottom: 12px;
}
textarea.champ {
  resize: vertical;
  min-height: 70px;
  font-family: inherit;
}
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

/* Boutons */
.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  border-radius: var(--radius);
  border: none;
  background: var(--bleu);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.bouton:disabled {
  opacity: 0.6;
  cursor: default;
}
.bouton-secondaire {
  background: #fff;
  color: var(--bleu);
  border: 1px solid var(--bleu);
}
.bouton-danger {
  background: #fff;
  color: var(--rouge);
  border: 1px solid var(--rouge);
}
.bouton-texte {
  background: none;
  border: none;
  color: var(--bleu);
  font-size: 14px;
  cursor: pointer;
  padding: 0;
}
.bouton-petit {
  padding: 6px 10px;
  font-size: 13px;
}
.bouton-icone {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
}

/* Cartes / listes */
.carte {
  background: var(--bleu-clair);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 10px;
}
.carte-retard {
  background: var(--rouge-clair);
}
.carte-cliquable {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.carte-cliquable:hover {
  filter: brightness(0.97);
}
.ligne-entete-carte {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.carte-titre {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}
.carte-detail {
  font-size: 13px;
  color: var(--gris-texte);
  margin: 4px 0 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--vert);
  white-space: nowrap;
}
.badge-rouge {
  background: var(--rouge);
}
.badge-gris {
  background: #999;
}

.erreur {
  color: var(--rouge);
  font-size: 14px;
  margin: 0 0 12px;
}
.texte-vide {
  color: var(--gris-texte);
  text-align: center;
  padding: 24px 0;
}
.chargement {
  text-align: center;
  color: var(--gris-texte);
  padding: 40px 0;
}

.actions-ligne {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.actions-icones {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.fil-ariane {
  font-size: 13px;
  color: var(--gris-texte);
  margin-bottom: 16px;
}

.formulaire {
  background: var(--bleu-clair);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 18px;
}
.formulaire h3 {
  margin: 0 0 14px;
  font-size: 15px;
}

.code-invitation {
  background: var(--bleu-clair);
  border-radius: 14px;
  padding: 20px;
  text-align: center;
  margin-bottom: 24px;
}
.code-invitation .code {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 6px;
  color: var(--bleu);
  margin: 10px 0;
}

.grille-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.stat {
  background: var(--bleu-clair);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}
.stat .valeur {
  font-size: 26px;
  font-weight: 700;
  color: var(--bleu);
}
.stat .libelle {
  font-size: 12px;
  color: var(--gris-texte);
  margin-top: 4px;
}

/* Boîte de dialogue (duplication) */
.dialogue { border: none; border-radius: 14px; padding: 20px; width: min(420px, 92vw); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25); }
.dialogue::backdrop { background: rgba(0, 0, 0, 0.4); }
.dialogue h3 { margin: 0 0 4px; }

/* Photos / vidéos */
.grille-medias { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.media { position: relative; width: 120px; height: 90px; border-radius: 8px; overflow: hidden; background: #000; }
.media img, .media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-supprimer { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border: none; border-radius: 50%;
  background: rgba(0, 0, 0, 0.6); color: #fff; cursor: pointer; font-size: 12px; line-height: 1; }
.ajout-media { margin-top: 10px; cursor: pointer; }

/* Graphiques */
.graphique { width: 100%; height: auto; display: block; }
.barres { display: flex; align-items: flex-end; gap: 8px; height: 150px; }
.barre-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.barre { width: 70%; background: var(--bleu); border-radius: 4px; }
.barre-valeur { font-size: 11px; font-weight: 700; height: 16px; }
.barre-libelle { font-size: 11px; color: var(--gris-texte); margin-top: 4px; }
.puces { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.puce { display: inline-flex; align-items: center; gap: 8px; background: #e8eefc; border-radius: 16px; padding: 5px 12px; font-size: 13px; font-weight: 600; }
.puce-faite { background: #dff3e6; }
.puce-retard { background: #fbdcdc; }
.puce button { border: none; background: none; cursor: pointer; color: #888; padding: 0; font-size: 12px; }
.jours-semaine { display: flex; gap: 6px; margin-bottom: 12px; }
.jour-chip { width: 36px; height: 36px; border-radius: 50%; border: none; background: #e5e9f2; font-weight: 700; cursor: pointer; }
.jour-chip.actif { background: var(--bleu); color: #fff; }

/* Messagerie */
.page-large { max-width: 1000px; }
.messagerie { display: flex; gap: 16px; align-items: stretch; height: min(70vh, 640px); }
.conversations { width: 260px; flex-shrink: 0; overflow-y: auto; border: 1px solid var(--gris-bordure); border-radius: var(--radius); }
.conversation { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; width: 100%; text-align: left; padding: 12px 14px;
  border: none; border-bottom: 1px solid #eee; background: #fff; cursor: pointer; font: inherit; }
.conversation:hover { background: var(--bleu-clair); }
.conversation-active { background: #e8eefc; }
.conversation-nom { font-weight: 700; flex: 1; }
.conversation-apercu { width: 100%; font-size: 13px; color: var(--gris-texte); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fil { flex: 1; min-width: 0; display: flex; flex-direction: column; border: 1px solid var(--gris-bordure); border-radius: var(--radius); padding: 12px; }
.fil[hidden] { display: none; }
.fil-vide { align-items: center; justify-content: center; }
.fil-entete { font-weight: 700; padding: 0 4px 10px; border-bottom: 1px solid #eee; }
.fil-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 12px 4px; }
.bulle { max-width: 75%; border-radius: 14px; padding: 8px 12px; }
.bulle-moi { align-self: flex-end; background: var(--bleu); color: #fff; border-bottom-right-radius: 4px; }
.bulle-autre { align-self: flex-start; background: #f0f1f4; border-bottom-left-radius: 4px; }
.bulle-texte { white-space: pre-wrap; overflow-wrap: anywhere; }
.bulle-heure { font-size: 10px; opacity: 0.7; margin-top: 4px; text-align: right; }
.message-media { display: block; max-width: 100%; max-height: 260px; border-radius: 10px; margin-bottom: 4px; }
.fil-saisie { display: flex; gap: 8px; align-items: flex-end; margin-top: 8px; }
.fil-saisie .champ { flex: 1; resize: none; max-height: 120px; margin: 0; }
.fil-saisie label { cursor: pointer; margin: 0; }
@media (max-width: 720px) {
  .messagerie { flex-direction: column; height: auto; }
  .conversations { width: 100%; max-height: 180px; }
  .fil { height: 60vh; }
}

/* Pied de page (liens légaux) */
.pied { text-align: center; padding: 28px 16px; font-size: 12px; color: var(--gris-texte); }
.pied a { color: var(--gris-texte); text-decoration: underline; margin: 0 8px; }
.page-legale { max-width: 720px; }
.page-legale h2 { margin-top: 28px; }
.page-legale p, .page-legale li { line-height: 1.6; color: #333; }
.a-completer { background: #fff3cd; padding: 0 4px; border-radius: 3px; }
.zone-danger { border: 1px solid #f0c4c4; background: var(--rouge-clair); border-radius: var(--radius); padding: 16px; margin-top: 24px; }

/* Visionneuse photo/vidéo */
.cliquable { cursor: zoom-in; }
.media-agrandir { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border: none; border-radius: 6px;
  background: rgba(0, 0, 0, 0.6); color: #fff; cursor: zoom-in; font-size: 15px; line-height: 1; padding: 0; }
.message-cadre { position: relative; display: inline-block; max-width: 100%; }
.message-cadre .message-media { margin-bottom: 4px; }
.visionneuse { padding: 0; border: none; background: transparent; max-width: 96vw; max-height: 96vh; overflow: visible; }
.visionneuse::backdrop { background: rgba(0, 0, 0, 0.85); }
.visionneuse img, .visionneuse video { display: block; max-width: 96vw; max-height: 90vh; margin: 0 auto; border-radius: 8px; }
.visionneuse-fermer { position: fixed; top: 14px; right: 18px; z-index: 1; width: 38px; height: 38px; border: none; border-radius: 50%;
  background: rgba(255, 255, 255, 0.2); color: #fff; font-size: 18px; cursor: pointer; }
