/* Dashboard Arcadi — charte reprise de site/assets/styles.css.
   Mêmes couleurs, mêmes polices, même vocabulaire de composants.
   L'échelle, en revanche, est resserrée : un site marketing respire, un tableau
   de bord doit faire tenir des chiffres côte à côte sans défilement permanent. */

:root {
  /* Palette du site vitrine, à l'identique. */
  --bg: #ffffff;
  --bg-soft: #f7f8f7;
  --bg-tint: #edf2f0;
  --brand: #023530;
  --brand-700: #04443b;
  --brand-500: #0b6355;
  --brand-300: #8fb0a8;
  --brand-100: #d6e3df;
  --ink: #0b1614;
  --ink-2: #3b4744;
  --ink-3: #6e7c78;
  --ink-inv: #f3f6f4;
  --line: #e5e8e6;
  --line-2: #d2d8d5;

  /* Ajout propre au dashboard : le site est monochrome, un tableau de bord doit
     pouvoir signaler une dégradation. Terracotta plutôt que rouge vif, pour
     rester dans l'accord chromatique du vert profond. */
  --alerte: #a8432c;
  --alerte-soft: #fbeeea;
  --alerte-line: #f0d5cd;

  --r: 12px;
  --r-sm: 8px;
  --r-lg: 20px;
  /* Largeur utile. Le site vitrine se cale sur 1120 px, une mesure de lecture ;
     un tableau de bord n'a pas la même contrainte — il doit faire tenir un
     comparatif de douze lignes et quatre indicateurs de front. À 1180 px, un
     écran de 1920 laissait 370 px de vide de chaque côté. Le plafond reste
     nécessaire : au-delà, les phrases des retours à traiter s'étireraient sur
     toute la largeur et deviendraient pénibles à lire. */
  --max: 1600px;
  --shadow-sm: 0 1px 2px rgba(11, 22, 20, .04);
  --shadow: 0 1px 3px rgba(11, 22, 20, .05), 0 12px 32px -12px rgba(11, 22, 20, .10);
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-soft);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: "Geist", "Inter", -apple-system, sans-serif;
  font-weight: 600;
  letter-spacing: -.022em;
  margin: 0;
}
h1 { font-size: 25px; }
h2 { font-size: 17px; }
h3 { font-size: 14.5px; }

a { color: var(--brand-500); }

.num {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

.eyebrow {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.muet { color: var(--ink-3); }
.petit { font-size: 13px; }

/* --- Connexion ------------------------------------------------------------ */

#connexion {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 520px at 50% -8%, var(--bg-tint), transparent 70%),
    var(--bg-soft);
}
.carte-connexion {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 34px 32px 30px;
  width: min(400px, 100%);
}
.carte-connexion .marque { display: flex; align-items: center; gap: 11px; margin-bottom: 6px; }
.carte-connexion .marque svg { width: 32px; height: 32px; color: var(--brand); }
.carte-connexion .marque b {
  font-family: "Geist", sans-serif; font-weight: 600; font-size: 21px;
  letter-spacing: -.03em; color: var(--brand);
}

label { display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-2); margin: 15px 0 5px; }

input, select {
  width: 100%;
  padding: 10px 12px;
  font: inherit; font-size: 14.5px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--brand-300);
  box-shadow: 0 0 0 3px var(--brand-100);
}
select { cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px;
  font: inherit; font-size: 14px; font-weight: 500;
  border: 1px solid transparent; border-radius: var(--r-sm);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-primaire { background: var(--brand); color: #fff; }
.btn-primaire:hover { background: var(--brand-700); }
.btn-primaire:disabled { opacity: .55; cursor: default; }
.btn-bloc { width: 100%; padding: 11px 16px; font-size: 14.5px; margin-top: 22px; }
.btn-discret { background: transparent; color: var(--ink-2); border-color: var(--line-2); }
.btn-discret:hover { background: var(--bg-soft); color: var(--ink); }
.btn-mini { padding: 5px 10px; font-size: 12.5px; }

.message { margin-top: 14px; padding: 10px 12px; border-radius: var(--r-sm); font-size: 13.5px; display: none; }
.message.erreur { display: block; background: var(--alerte-soft); color: var(--alerte); border: 1px solid var(--alerte-line); }

/* --- Ossature ------------------------------------------------------------- */

#application[hidden] { display: none; }

.bandeau {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.bandeau-inner {
  max-width: var(--max); margin: 0 auto; padding: 0 24px;
  height: 58px; display: flex; align-items: center; gap: 13px;
}
.marque-bandeau { display: flex; align-items: center; gap: 9px; }
.marque-bandeau svg { width: 24px; height: 24px; color: var(--brand); }
.marque-bandeau b {
  font-family: "Geist", sans-serif; font-weight: 600; font-size: 16.5px;
  letter-spacing: -.03em; color: var(--brand);
}
.separateur { width: 1px; height: 20px; background: var(--line-2); }
.nom-entreprise { font-weight: 500; font-size: 14.5px; color: var(--ink-2); }
.bandeau-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.bandeau-actions select { width: auto; padding: 6px 10px; font-size: 13.5px; }
.email { font-size: 13px; color: var(--ink-3); }

/* --- Ossature à deux colonnes ---------------------------------------------
   La barre latérale porte le périmètre — tout le réseau, ou un établissement.
   C'est la correction d'une erreur de conception initiale : un établissement
   n'est pas une page, c'est un filtre. Le traiter comme une page obligeait à
   revenir en arrière et à parcourir un tableau pour passer d'un site au
   suivant. Ici, la liste reste visible et un clic suffit — elle fait en même
   temps office de comparatif permanent. */

.cadre {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  gap: 30px;
}

.laterale {
  position: sticky;
  top: 58px;
  align-self: start;
  max-height: calc(100dvh - 58px);
  overflow-y: auto;
  padding: 26px 0 40px;
}
.laterale .titre {
  display: block;
  margin: 22px 0 8px 10px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 10px; margin-bottom: 2px;
  background: none; border: none; border-radius: var(--r-sm);
  font: inherit; font-size: 14px; text-align: left; color: var(--ink-2);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--bg-tint); color: var(--ink); }
.nav-item.actif { background: var(--brand); color: #fff; }
.nav-item .nom {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-item .note-mini {
  font-family: "IBM Plex Mono", monospace; font-size: 12px;
  font-variant-numeric: tabular-nums; color: var(--ink-3);
}
.nav-item.actif .note-mini { color: var(--brand-300); }
/* Pastille toujours présente, même vide : sans elle les noms se décaleraient
   d'un établissement à l'autre selon qu'il est en alerte ou non. */
.nav-item .pastille { width: 6px; height: 6px; border-radius: 50%; flex: none; background: transparent; }
.nav-item .pastille.alerte { background: var(--alerte); }
.nav-item.actif .pastille.alerte { background: #e8a08e; }

main { padding: 26px 0 72px; min-width: 0; }

@media (max-width: 1023px) {
  /* Sous cette largeur, la barre latérale mangerait la place du contenu :
     le périmètre passe dans le sélecteur de l'en-tête. */
  .laterale { display: none; }
  .cadre { grid-template-columns: minmax(0, 1fr); }
  main { padding: 22px 0 60px; }
}
.perimetre-etroit { display: none; max-width: 190px; }
@media (max-width: 1023px) { .perimetre-etroit { display: block; } }
@media (min-width: 1024px) { .retour { display: none; } }

.entete { margin-bottom: 20px; }
.entete h1 { margin-top: 3px; }
.entete .sous { color: var(--ink-3); font-size: 14px; margin-top: 4px; }
.retour {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; padding: 0; margin-bottom: 12px;
  font: inherit; font-size: 13.5px; color: var(--ink-3); cursor: pointer;
}
.retour:hover { color: var(--brand-500); }

/* --- Cartes et grilles ----------------------------------------------------- */

.carte {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.carte-tete { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.carte-tete .muet { font-size: 13px; }

.grille { display: grid; gap: 16px; margin-bottom: 16px; }
.grille-2 { grid-template-columns: 1fr 1fr; }
.grille-4 { grid-template-columns: repeat(4, 1fr); }
.grille > .carte { margin-bottom: 0; }
@media (max-width: 900px) {
  .grille-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
  .grille-2, .grille-4 { grid-template-columns: 1fr; }
  .bandeau-inner { padding: 0 16px; }
  main { padding: 20px 16px 60px; }
  /* L'en-tête déborderait : on garde le strict nécessaire. Le nom de
     l'entreprise reste lisible dans le titre de la vue direction, et le mark
     suffit à identifier le produit sans le mot « Arcadi ». */
  .email, .separateur, .nom-entreprise, .marque-bandeau b { display: none; }
  .bandeau-actions { gap: 6px; }
  .bandeau-actions select { padding: 6px 6px; font-size: 12.5px; }
  .perimetre-etroit { max-width: 132px; }
}

/* --- Indicateurs ----------------------------------------------------------- */

.kpi { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); padding: 15px 17px; }
.kpi .eyebrow { display: block; margin-bottom: 8px; }
.kpi .valeur {
  font-family: "Geist", sans-serif; font-size: 27px; font-weight: 600;
  letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums;
}
.kpi .valeur small { font-size: 15px; font-weight: 500; color: var(--ink-3); letter-spacing: 0; }
.kpi .detail { font-size: 12.5px; color: var(--ink-3); margin-top: 5px; }
.kpi.accent { background: var(--brand); border-color: var(--brand); }
.kpi.accent .eyebrow, .kpi.accent .detail { color: var(--brand-300); }
.kpi.accent .valeur { color: #fff; }
.kpi.accent .valeur small { color: var(--brand-300); }

/* --- Alertes --------------------------------------------------------------- */

.alerte-ligne {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--alerte-soft); border: 1px solid var(--alerte-line);
  border-radius: var(--r-sm); padding: 12px 15px; margin-bottom: 8px;
  font: inherit; color: inherit; cursor: pointer;
  transition: border-color .15s;
}
.alerte-ligne:last-child { margin-bottom: 0; }
.alerte-ligne:hover { border-color: var(--alerte); }
.alerte-ligne .pastille { width: 7px; height: 7px; border-radius: 50%; background: var(--alerte); flex: none; }
.alerte-ligne .nom { font-weight: 500; }
.alerte-ligne .chiffres {
  margin-left: auto; white-space: nowrap; color: var(--alerte);
  font-family: "IBM Plex Mono", monospace; font-size: 13px;
}

/* --- Tableau --------------------------------------------------------------- */

.tableau-defilant { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 7px 10px; white-space: nowrap;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px; font-weight: 500; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-3);
  border-bottom: 1px solid var(--line);
}
td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 14px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; transition: background .12s; }
tbody tr:hover { background: var(--bg-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.nom-magasin { font-weight: 500; }
.ville { color: var(--ink-3); font-size: 12.5px; }

/* --- Note de sentiment ------------------------------------------------------ */

.note {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; padding: 3px 9px; border-radius: 20px;
  font-family: "IBM Plex Mono", monospace; font-size: 13px; font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.note-1, .note-2 { background: var(--alerte-soft); color: var(--alerte); }
.note-3 { background: var(--bg-tint); color: var(--brand-700); }
.note-4, .note-5 { background: var(--brand-100); color: var(--brand); }
.note-masque { background: var(--bg-soft); color: var(--ink-3); font-size: 12px; }

/* --- Thèmes ----------------------------------------------------------------- */

.chip {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 20px; margin: 2px 4px 2px 0;
  background: var(--bg-tint); color: var(--brand-700);
  font-size: 12.5px; white-space: nowrap;
}
.chip-neutre { background: var(--bg-soft); color: var(--ink-3); border: 1px solid var(--line); }

.theme { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.theme:last-child { border-bottom: none; }

/* Sur une carte pleine largeur, une liste en une colonne laisse près de 800 px
   entre le nom d'un sujet et sa jauge : l'œil doit traverser la carte pour
   associer les deux. On la répartit en colonnes dès que la place le permet. */
.liste-colonnes { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); column-gap: 40px; }
.liste-colonnes .theme:last-child { border-bottom: 1px solid var(--line); }
.theme .tag { font-weight: 500; }
.theme .droite { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.jauge { width: 88px; height: 5px; border-radius: 3px; background: var(--bg-tint); overflow: hidden; flex: none; }
.jauge i { display: block; height: 100%; background: var(--brand-500); border-radius: 3px; }
.compteur {
  font-family: "IBM Plex Mono", monospace; font-size: 13px;
  color: var(--ink-2); min-width: 26px; text-align: right;
}
.variation { font-family: "IBM Plex Mono", monospace; font-size: 12px; min-width: 30px; text-align: right; }
.variation.hausse { color: var(--alerte); }
.variation.baisse { color: var(--brand-500); }
.variation.stable { color: var(--ink-3); }

/* --- Répartition par pôle ---------------------------------------------------- */

.repartition { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--bg-tint); }
.repartition i { display: block; height: 100%; }
.legende { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 13px; }
.legende span { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); }
.legende i { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.legende b { font-family: "IBM Plex Mono", monospace; font-weight: 500; color: var(--ink-3); }

/* --- Retours à traiter -------------------------------------------------------- */

.retour-item { display: flex; gap: 13px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.retour-item:last-child { border-bottom: none; }
.retour-item .corps { flex: 1; min-width: 0; }
.retour-item .resume { margin-bottom: 6px; }
.retour-item .meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.retour-item .date {
  font-family: "IBM Plex Mono", monospace; font-size: 11.5px; color: var(--ink-3);
}

/* --- Graphique ----------------------------------------------------------------- */

/* height: auto — la hauteur suit le viewBox (900×200), donc la largeur de la
   carte, sans jamais déformer le tracé ni les étiquettes. */
.graphique { width: 100%; height: auto; display: block; }
.graphique .axe { stroke: var(--line); stroke-width: 1; }
.graphique .aire { fill: var(--brand-100); opacity: .5; }
.graphique .ligne { fill: none; stroke: var(--brand-500); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.graphique .point { fill: var(--bg); stroke: var(--brand-500); stroke-width: 2; }
.graphique .volume { fill: var(--brand-300); opacity: .3; }
.graphique text {
  font-family: "IBM Plex Mono", monospace; font-size: 9.5px; fill: var(--ink-3);
}
/* Le SVG est mis à l'échelle par sa largeur : sur mobile, le viewBox de 900
   unités est réduit d'environ deux tiers et les étiquettes deviendraient
   illisibles. On les agrandit en unités du viewBox pour compenser. */
@media (max-width: 620px) {
  .graphique text { font-size: 21px; }
  .graphique .ligne { stroke-width: 4; }
  .graphique .point { r: 6; stroke-width: 4; }
  .graphique .axe { stroke-width: 2; }
}

/* --- États et notes ------------------------------------------------------------ */

.vide { text-align: center; padding: 34px 20px; }
.vide p { color: var(--ink-3); max-width: 460px; margin: 6px auto 0; }

/* --- Infobulles -----------------------------------------------------------
   Ce que le produit garantit — seuil d'anonymat, exclusion des signalements
   sensibles, mode de calcul du moral — était auparavant écrit en toutes
   lettres sous chaque bloc. C'était de la documentation posée dans l'outil :
   juste, mais illisible pour un directeur d'exploitation. L'explication vit
   désormais au contact du chiffre qu'elle concerne, et seulement à la demande.

   Ni survol seul (inutilisable au doigt) ni clic seul : `focus-within` couvre
   les deux, une tape sur mobile donnant le focus à l'élément. */

.aide {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; margin-left: 2px; vertical-align: middle;
  border: 1px solid var(--line-2); border-radius: 50%;
  background: var(--bg); color: var(--ink-3);
  font-family: "Inter", sans-serif; font-size: 10px; font-weight: 500;
  letter-spacing: 0; text-transform: none; cursor: help;
}
.aide:hover, .aide.ouverte { border-color: var(--brand-300); color: var(--brand-500); }
.aide:focus { outline: none; }
.aide:focus-visible { outline: 2px solid var(--brand-300); outline-offset: 2px; }
/* Sur la carte d'accent, un fond blanc ferait une pastille pleine. */
.kpi.accent .aide { background: transparent; border-color: rgba(255, 255, 255, .3); color: var(--brand-300); }
.kpi.accent .aide:hover, .kpi.accent .aide.ouverte { border-color: var(--ink-inv); color: var(--ink-inv); }
.aide .bulle {
  position: absolute; z-index: 30;
  top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 240px;
  padding: 10px 12px; border-radius: var(--r-sm);
  background: var(--ink); color: var(--ink-inv);
  font-size: 12.5px; font-weight: 400; line-height: 1.45; text-align: left;
  text-transform: none; letter-spacing: 0;
  opacity: 0; visibility: hidden; transition: opacity .12s;
  pointer-events: none;
}
/* La bascule au clic est la seule qui marche partout : sur écran tactile il n'y
   a pas de survol, et `:focus-within` ne se perd pas toujours au tap suivant —
   l'infobulle restait ouverte sans moyen de la refermer. Le survol est donc
   réservé aux pointeurs qui en ont un, faute de quoi il resterait « collé »
   après un tap. */
.aide.ouverte .bulle { opacity: 1; visibility: visible; }
@media (hover: hover) {
  .aide:hover .bulle { opacity: 1; visibility: visible; }
}
.aide:focus-visible .bulle { opacity: 1; visibility: visible; }
/* Près du bord droit, une bulle centrée déborderait de la page. */
.aide.fin .bulle { left: auto; right: -6px; transform: none; }

.chargement { padding: 48px; text-align: center; color: var(--ink-3); font-size: 14px; }

/* --- Affiches QR ---------------------------------------------------------------- */

.affiche { display: flex; align-items: center; gap: 18px; }
.affiche .qr { width: 116px; height: 116px; flex: none; }
.affiche .qr svg { width: 100%; height: 100%; display: block; }
.affiche .lien {
  font-family: "IBM Plex Mono", monospace; font-size: 12.5px;
  color: var(--brand-700); word-break: break-all; margin: 8px 0 12px;
}
