/* Couleurs et arrondis, inspirés de la capture de référence */
:root {
  --fond: #e9e9ec;
  --surface: #ffffff;
  --surface-2: #f4f4f6;
  --encre: #121214;
  --texte: #3a3a40;
  --discret: #8a8a92;
  --trait: #e7e7ec;
  --ombre: 0 1px 2px rgba(16,16,20,.04), 0 8px 24px rgba(16,16,20,.05);

  /* pastilles pastel */
  --vert-fond: #e3f5d8;   --vert: #3f7a22;
  --bleu-fond: #dcecfb;   --bleu: #2563a8;
  --rose-fond: #fbe0ef;   --rose: #b4357a;
  --violet-fond: #ebe4fd; --violet: #6a43d6;
  --gris-fond: #ececf0;   --gris: #5d5d66;

  --point-violet: #7c5cff;
  --point-rose: #e55bb4;
  --point-bleu: #3d8bfd;
  --point-orange: #f08c2e;

  --r-grand: 22px;
  --r-moyen: 14px;
  --r-pilule: 999px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--fond);
  color: var(--texte);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { font: inherit; cursor: pointer; }

/* Pas d'impression de l'outil */
@media print { body { display: none !important; } }

/* ---------- Page de connexion ---------- */
.page-connexion { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.connexion { width: 100%; max-width: 380px; padding: 32px 28px; }
.connexion .logo { margin-bottom: 18px; }
.connexion h1 { font-size: 24px; }
.connexion form { display: flex; flex-direction: column; gap: 14px; margin-top: 22px; }
.connexion label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; color: var(--encre); font-size: 13px; }
.connexion input {
  height: 44px; border: 1px solid var(--trait); background: var(--surface-2); border-radius: 12px;
  padding: 0 14px; font: inherit; font-size: 15px; color: var(--encre); outline: 0; transition: border-color .2s, box-shadow .2s;
}
.connexion input:focus { border-color: var(--encre); box-shadow: 0 0 0 3px rgba(18,18,20,.08); background: #fff; }
.connexion input[name="code"] { letter-spacing: 4px; font-variant-numeric: tabular-nums; font-size: 18px; }
.connexion small { color: var(--discret); font-weight: 400; font-size: 12px; }
.connexion .bouton-noir { margin-top: 6px; height: 46px; }
.info, .erreur { border-radius: 12px; padding: 10px 14px; margin: 16px 0 0; font-size: 13px; }
.info { background: var(--bleu-fond); color: var(--bleu); }
.erreur { background: var(--rose-fond); color: var(--rose); }
.lien-sortie { text-decoration: none; cursor: pointer; }
.lien-sortie:hover { background: var(--encre); color: #fff; }
a.rail-btn { text-decoration: none; }

/* ---------- Mise en page ---------- */
.app { display: flex; min-height: 100vh; padding: 14px; gap: 14px; }

.rail {
  width: 64px; flex: none;
  background: var(--surface); border-radius: var(--r-grand); box-shadow: var(--ombre);
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px 0;
  position: sticky; top: 14px; height: calc(100vh - 28px);
}
.logo {
  width: 36px; height: 36px; border-radius: 11px; background: var(--encre); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; letter-spacing: .5px; margin-bottom: 14px;
}
.rail-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: var(--discret);
  display: grid; place-items: center; transition: background .2s, color .2s;
}
.rail-btn:hover { background: var(--surface-2); color: var(--encre); }
.rail-btn.actif { background: var(--encre); color: #fff; }
.rail-bas { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 12px; }

.contenu { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; }

/* ---------- 1. Bandeau ---------- */
.bandeau { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 6px 4px 0; }
h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.6px; color: var(--encre); }
h2 { margin: 0; font-size: 15px; font-weight: 600; color: var(--encre); letter-spacing: -.2px; }
.sous-titre { margin: 2px 0 0; color: var(--discret); font-size: 13px; }
.bandeau-droite { display: flex; gap: 8px; flex-wrap: wrap; }
.pastille {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px;
  background: var(--surface); border-radius: var(--r-pilule); box-shadow: var(--ombre);
  font-weight: 500; color: var(--texte); font-size: 13px;
}
.pastille svg { width: 16px; height: 16px; color: var(--discret); }
.pastille.fictif { background: var(--encre); color: #fff; }

/* ---------- 2. Recherche ---------- */
.recherche {
  display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 18px;
  background: var(--surface); border-radius: var(--r-pilule); box-shadow: var(--ombre);
  transition: box-shadow .2s;
}
.recherche:focus-within { box-shadow: 0 0 0 2px var(--encre), var(--ombre); }
.recherche svg { color: var(--discret); }
.recherche input { flex: 1; border: 0; outline: 0; background: transparent; font: inherit; font-size: 15px; color: var(--encre); }
.recherche input::placeholder { color: var(--discret); }

/* ---------- 3. Compteurs ---------- */
.compteurs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.compteur {
  text-align: left; border: 0; background: var(--surface); border-radius: var(--r-grand); box-shadow: var(--ombre);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; color: var(--texte);
  transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s;
  outline: 2px solid transparent;
}
.compteur:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(16,16,20,.05), 0 14px 32px rgba(16,16,20,.08); }
.compteur.actif { outline-color: var(--encre); }
.compteur-tete { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--encre); }
.point { width: 8px; height: 8px; border-radius: 50%; }
.compteur-icone { margin-left: auto; width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; color: var(--encre); }
.compteur-chiffre { font-size: 38px; font-weight: 700; letter-spacing: -1.5px; color: var(--encre); line-height: 1; font-variant-numeric: tabular-nums; }
.compteur-qui { font-size: 12px; color: var(--discret); }
.barre { height: 6px; border-radius: var(--r-pilule); background: var(--surface-2); overflow: hidden; }
.barre span { display: block; height: 100%; border-radius: inherit; background: var(--encre); width: 0; transition: width 1s cubic-bezier(.2,.8,.2,1) .3s; }

/* ---------- 4 et 5 ---------- */
.bas { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 14px; align-items: start; }
.carte { background: var(--surface); border-radius: var(--r-grand); box-shadow: var(--ombre); }

.liste { padding: 18px 12px 12px; position: sticky; top: 14px; max-height: calc(100vh - 28px); display: flex; flex-direction: column; }
.liste-tete { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 12px; }
.nombre { font-weight: 600; color: var(--discret); font-variant-numeric: tabular-nums; }
.filtre-actif {
  margin: 0 8px 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--surface-2); border-radius: var(--r-moyen); padding: 8px 10px 8px 14px; font-size: 13px;
}
.filtre-actif button { border: 0; background: var(--surface); border-radius: var(--r-pilule); padding: 4px 10px; font-size: 12px; font-weight: 500; }
.liste-items { list-style: none; margin: 0; padding: 0; overflow-y: auto; user-select: none; -webkit-user-select: none; }
.ligne {
  display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: var(--r-moyen);
  cursor: pointer; transition: background .15s;
  animation: monte .4s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i, 0) * 25ms);
}
.ligne:hover { background: var(--surface-2); }
.ligne.choisie { background: var(--encre); color: #fff; }
.ligne.choisie .ligne-sous { color: #b9b9c2; }
.ligne-texte { flex: 1; min-width: 0; }
.ligne-nom { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ligne-sous { font-size: 12px; color: var(--discret); }
.vide { padding: 30px 10px; text-align: center; color: var(--discret); }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 600; font-size: 12px; color: var(--encre); background: var(--surface-2);
}
.avatar.petit { width: 36px; height: 36px; background: var(--violet-fond); color: var(--violet); }
.avatar.grand { width: 64px; height: 64px; font-size: 20px; }
.av-0 { background: var(--vert-fond); color: var(--vert); }
.av-1 { background: var(--bleu-fond); color: var(--bleu); }
.av-2 { background: var(--rose-fond); color: var(--rose); }
.av-3 { background: var(--violet-fond); color: var(--violet); }

.etiquette {
  display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: var(--r-pilule);
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
}
.e-vert { background: var(--vert-fond); color: var(--vert); }
.e-bleu { background: var(--bleu-fond); color: var(--bleu); }
.e-rose { background: var(--rose-fond); color: var(--rose); }
.e-violet { background: var(--violet-fond); color: var(--violet); }
.e-gris { background: var(--gris-fond); color: var(--gris); }

/* Fiche */
.fiche { padding: 22px; min-height: 420px; }
.fiche-vide { height: 380px; display: grid; place-items: center; text-align: center; color: var(--discret); }
.fiche-vide svg { width: 40px; height: 40px; stroke-width: 1.3; margin-bottom: 10px; }
.fiche-tete { display: flex; align-items: center; gap: 16px; padding-bottom: 18px; border-bottom: 1px solid var(--trait); margin-bottom: 18px; }
.fiche-tete h2 { font-size: 22px; letter-spacing: -.5px; }
.fiche-tete .etiquettes { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.fiche-num { margin-left: auto; text-align: right; }
.fiche-num small { display: block; color: var(--discret); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
.fiche-num strong { font-size: 22px; color: var(--encre); letter-spacing: -.5px; font-variant-numeric: tabular-nums; }

.grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 14px; }
.insecable, dd a[href^="tel:"] { white-space: nowrap; }
.bloc {
  background: var(--surface-2); border-radius: var(--r-moyen); padding: 16px;
  animation: monte .45s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i, 0) * 60ms);
}
.bloc.large { grid-column: 1 / -1; }
.bloc-titre { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--encre); margin-bottom: 12px; }
.bloc-titre svg { width: 16px; height: 16px; color: var(--discret); }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 7px 16px; margin: 0; }
dt { color: var(--discret); }
dd { margin: 0; color: var(--encre); font-weight: 500; overflow-wrap: anywhere; }
dd a { color: inherit; text-decoration: none; border-bottom: 1px solid var(--trait); }
dd a:hover { border-color: var(--encre); }
.manque { color: var(--discret); font-weight: 400; }
.texte-email { color: var(--rose); font-weight: 500; }

.parts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.part { background: var(--surface); border-radius: 12px; padding: 10px 12px; }
.part small { display: block; color: var(--discret); font-size: 11px; font-weight: 600; letter-spacing: .5px; }
.part strong { font-size: 22px; color: var(--encre); letter-spacing: -.5px; font-variant-numeric: tabular-nums; }

.pieces { display: flex; flex-direction: column; gap: 8px; }
.piece { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.indivisaires { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.indivisaire {
  display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 12px; padding: 8px 10px;
  border: 0; text-align: left; color: var(--texte); transition: transform .15s;
}
.indivisaire:hover { transform: translateX(3px); }
.indivisaire .avatar { width: 30px; height: 30px; font-size: 11px; }
.indivisaire span:nth-child(2) { flex: 1; font-weight: 500; }
.indivisaire small { color: var(--discret); }

.commentaire { white-space: pre-wrap; color: var(--texte); }

/* Session expirée */
.voile { position: fixed; inset: 0; background: rgba(233,233,236,.75); backdrop-filter: blur(10px); display: grid; place-items: center; z-index: 10; padding: 16px; }
.voile[hidden] { display: none; }
.voile-boite { padding: 32px; text-align: center; max-width: 360px; }
.voile-boite svg { width: 34px; height: 34px; margin-bottom: 8px; }
.voile-boite p { color: var(--discret); }
.bouton-noir { border: 0; background: var(--encre); color: #fff; height: 42px; padding: 0 22px; border-radius: var(--r-pilule); font-weight: 500; }

/* Animations d'entrée */
@keyframes monte { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.anim { animation: monte .55s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i, 0) * 70ms); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Écrans étroits */
@media (max-width: 1200px) {
  .compteurs { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 960px) {
  .bas { grid-template-columns: 1fr; }
  .liste { position: static; max-height: 420px; }
}
@media (max-width: 700px) {
  .app { padding: 10px; gap: 10px; }
  .rail { display: none; }
  .compteurs { grid-template-columns: 1fr; }
  .grille { grid-template-columns: 1fr; }
  .fiche-num { margin-left: 0; }
  .fiche-tete { flex-wrap: wrap; }
}
