/* =========================================================================
   Flux — plateforme de comptage des visiteurs uniques
   Palette inspirée du bleu Majorelle et du safran, sur un fond froid et calme.
   ========================================================================= */

:root {
  --encre: #1A1C2B;
  --encre-2: #4A4E66;
  --gris: #6E7290;
  --ligne: #E2E4EE;
  --ligne-forte: #CDD0DE;
  --papier: #F2F3F8;
  --blanc: #FFFFFF;
  --majorelle: #4A3FD0;
  --majorelle-clair: #ECEAFD;
  --majorelle-nuit: #221D63;
  --safran: #EAA21C;
  --safran-clair: #FDF3DE;
  --menthe: #12865F;
  --menthe-clair: #E1F4EC;
  --grenade: #C4304B;
  --grenade-clair: #FBE7EB;

  --police: "Schibsted Grotesk", "Segoe UI", system-ui, -apple-system, sans-serif;
  --r-panneau: 16px;
  --r-ctrl: 10px;
  --nav-l: 248px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--police);
  font-size: 15px;
  line-height: 1.5;
  color: var(--encre);
  background: var(--papier);
}
.odometre, .detail dd, td.num, .chiffre-fort { font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2.5px solid var(--majorelle); outline-offset: 2px; border-radius: 6px; }
.ico { width: 20px; height: 20px; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Structure ---------- */
.app { display: grid; grid-template-columns: var(--nav-l) 1fr; min-height: 100vh; }

.nav {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--majorelle-nuit);
  color: #D9D7F5;
  padding: 22px 14px 14px;
}
.marque { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 0 10px 26px; color: var(--blanc); }
.marque span { font-size: 22px; font-weight: 800; letter-spacing: -0.03em; }
.marque-sombre { color: var(--majorelle-nuit); padding: 0 0 28px; }
.logo { width: 26px; height: 30px; }

.nav nav { display: flex; flex-direction: column; gap: 2px; }
.nav nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-ctrl);
  text-decoration: none; font-weight: 500; color: #C9C6EE;
}
.nav nav a:hover { background: rgba(255,255,255,.06); color: var(--blanc); }
.nav nav a.actif { background: var(--blanc); color: var(--majorelle-nuit); font-weight: 600; }
.nav nav a.actif .ico { color: var(--majorelle); }

.nav-pied { margin-top: auto; display: flex; align-items: center; gap: 6px; border-top: 1px solid rgba(255,255,255,.1); padding-top: 14px; }
.profil { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: var(--r-ctrl); text-decoration: none; }
.profil:hover, .profil.actif { background: rgba(255,255,255,.08); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--safran); color: var(--majorelle-nuit); font-weight: 700; font-size: 13px; flex: none; }
.profil-txt { min-width: 0; display: flex; flex-direction: column; }
.profil-txt strong { color: var(--blanc); font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profil-txt small { color: #A9A5DC; font-size: 12px; }
.sortie { display: grid; place-items: center; width: 38px; height: 38px; border-radius: var(--r-ctrl); color: #C9C6EE; }
.sortie:hover { background: rgba(255,255,255,.08); color: var(--blanc); }

.contenu { min-width: 0; padding: 26px 34px 48px; }
.entete { display: flex; align-items: center; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.entete h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.025em; }
.perimetre { margin: 2px 0 0; color: var(--gris); font-size: 14px; }
.entete-droite { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn-icone.burger { display: none; }
.voile { display: none; }

/* ---------- Contrôles ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--r-ctrl);
  border: 1px solid var(--ligne-forte); background: var(--blanc);
  font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--encre-2); }
.btn-principal { background: var(--majorelle); border-color: var(--majorelle); color: var(--blanc); }
.btn-principal:hover { background: #3C32B8; border-color: #3C32B8; }
.btn-danger { background: var(--grenade); border-color: var(--grenade); color: var(--blanc); }
.btn-danger:hover { background: #A82840; border-color: #A82840; }
.btn-large { height: 48px; width: 100%; font-size: 15px; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-icone {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 0; background: transparent; border-radius: var(--r-ctrl); cursor: pointer; color: var(--encre-2);
}
.btn-icone:hover { background: var(--papier); color: var(--encre); }
.btn-icone.danger:hover { background: var(--grenade-clair); color: var(--grenade); }

.select, .recherche input, .champ input, .champ select {
  height: 40px; border: 1px solid var(--ligne-forte); border-radius: var(--r-ctrl);
  background: var(--blanc); padding: 0 12px; min-width: 0;
}
.select { padding-right: 34px; appearance: none; cursor: pointer;
  background: var(--blanc) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%234A4E66' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 12px center; }
.recherche { position: relative; }
.recherche .ico { position: absolute; left: 11px; top: 10px; color: var(--gris); width: 18px; height: 18px; }
.recherche input { padding-left: 36px; width: 240px; }
.champ { display: flex; flex-direction: column; gap: 6px; }
.champ > span { font-size: 13px; font-weight: 600; color: var(--encre-2); }
.champ input, .champ select { height: 44px; width: 100%; }
.champ select { appearance: none; padding-right: 34px;
  background: var(--blanc) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%234A4E66' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 12px center; }
.champ small { color: var(--gris); font-size: 12.5px; }
.champ input:focus, .champ select:focus, .select:focus, .recherche input:focus { outline: none; border-color: var(--majorelle); box-shadow: 0 0 0 3px var(--majorelle-clair); }
.case { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }
.case input { width: 18px; height: 18px; accent-color: var(--majorelle); }
.alerte { margin: 0; padding: 11px 14px; border-radius: var(--r-ctrl); background: var(--grenade-clair); color: #8E1D33; font-size: 14px; }

/* ---------- Panneaux ---------- */
.panneau { background: var(--blanc); border: 1px solid var(--ligne); border-radius: var(--r-panneau); padding: 22px 24px; min-width: 0; }
.panneau-tete { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.panneau-tete h2 { font-size: 17px; font-weight: 700; }
.panneau-tete p { margin: 0; color: var(--gris); font-size: 13.5px; }
.legende { display: flex; gap: 16px; font-size: 13px; color: var(--encre-2); }
.legende i { display: inline-block; width: 18px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

/* ---------- Tableau de bord ---------- */
.direct { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--encre-2); padding: 0 4px; }
.direct::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--menthe); box-shadow: 0 0 0 0 rgba(18,134,95,.5); animation: pouls 2s infinite; }
.direct.erreur::before { background: var(--grenade); animation: none; }

.tableau { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }

/* Le bandeau principal : le compteur, seul élément expressif de l'interface. */
.compteur {
  grid-column: 1 / -1;
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 32px;
  background: var(--majorelle); color: var(--blanc);
  border-radius: 22px; padding: 30px 34px;
}
.compteur::after {
  /* Arc outrepassé en filigrane : la porte d'entrée du magasin. */
  content: ""; position: absolute; right: -40px; bottom: -120px; width: 360px; height: 420px;
  border: 46px solid rgba(255,255,255,.06); border-bottom: 0; border-radius: 180px 180px 0 0;
  pointer-events: none;
}
.compteur-principal { position: relative; z-index: 1; }
.compteur-libelle { margin: 0 0 6px; font-size: 16px; font-weight: 500; color: #DAD6FF; }
.odometre {
  display: flex; align-items: flex-end;
  font-size: clamp(64px, 9vw, 124px); font-weight: 800; line-height: 1;
  letter-spacing: -0.045em; height: 1em; overflow: hidden;
}
.odometre .chiffre { display: inline-block; height: 1em; overflow: hidden; }
.odometre .rouleau { display: flex; flex-direction: column; transition: transform .9s cubic-bezier(.2,.8,.2,1); }
.odometre .rouleau span { height: 1em; line-height: 1; }
.odometre .sep { width: .22em; }
.comparaison { margin: 18px 0 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 15px; color: #E7E4FF; }
.tendance { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; font-weight: 700; font-size: 14px; background: var(--safran); color: var(--majorelle-nuit); }
.tendance.baisse { background: #FFD5DD; color: #7A1328; }
.tendance.neutre { background: rgba(255,255,255,.18); color: var(--blanc); }

.compteur-details { position: relative; z-index: 1; display: flex; flex-direction: column; justify-content: center; }
.detail { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid rgba(255,255,255,.16); }
.detail:last-child { border-bottom: 0; }
.detail dt { color: #DAD6FF; font-size: 14.5px; }
.detail dd { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.detail dd small { font-size: 14px; font-weight: 500; color: #C7C2FA; margin-left: 2px; }

.graphe { position: relative; height: 280px; }
.graphe-court { height: 280px; }

/* Tableau des magasins */
.table-conteneur { overflow-x: auto; margin: 0 -24px -22px; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th { text-align: left; font-weight: 600; font-size: 13px; color: var(--gris); padding: 10px 14px; border-bottom: 1px solid var(--ligne); white-space: nowrap; }
td { padding: 13px 14px; border-bottom: 1px solid var(--ligne); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { padding-left: 24px; }
th:last-child, td:last-child { padding-right: 24px; }
th.num, td.num { text-align: right; }
tbody tr:hover { background: #FAFAFD; }
.nom-cell strong { display: block; font-weight: 600; }
.nom-cell small { color: var(--gris); font-size: 13px; }
.chiffre-fort { font-weight: 700; font-size: 16px; }
.var-hausse { color: var(--menthe); font-weight: 600; }
.var-baisse { color: var(--grenade); font-weight: 600; }
.var-neutre { color: var(--gris); }
.part { display: flex; align-items: center; gap: 10px; min-width: 140px; }
.part-barre { flex: 1; height: 6px; border-radius: 3px; background: var(--papier); overflow: hidden; }
.part-barre span { display: block; height: 100%; background: var(--majorelle); border-radius: 3px; }
.part em { font-style: normal; color: var(--encre-2); font-size: 13px; min-width: 38px; text-align: right; }
.actions { display: flex; justify-content: flex-end; gap: 2px; }
.vide { text-align: center; color: var(--gris); padding: 42px 20px !important; }

.statut { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; padding: 4px 10px 4px 9px; border-radius: 999px; white-space: nowrap; }
.statut::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.statut.en_ligne { background: var(--menthe-clair); color: var(--menthe); }
.statut.hors_ligne { background: var(--grenade-clair); color: var(--grenade); }
.statut.ferme, .statut.inactif { background: var(--papier); color: var(--gris); }
.etiquette { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 6px; background: var(--papier); color: var(--encre-2); white-space: nowrap; }
.etiquette.violet { background: var(--majorelle-clair); color: var(--majorelle); }
.etiquette.safran { background: var(--safran-clair); color: #8A5A00; }
.etiquette.vert { background: var(--menthe-clair); color: var(--menthe); }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }

.barre-outils { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.barre-outils .compte { color: var(--gris); font-size: 14px; margin-right: auto; }

/* ---------- Fenêtre modale ---------- */
dialog {
  border: 0; padding: 0; border-radius: 18px; width: min(540px, calc(100vw - 32px));
  box-shadow: 0 24px 60px -12px rgba(26,28,43,.35); color: var(--encre);
}
dialog::backdrop { background: rgba(26,28,43,.45); }
dialog[open] { animation: entree .22s cubic-bezier(.2,.8,.2,1); }
.modale { padding: 26px 28px 24px; display: flex; flex-direction: column; gap: 16px; }
.modale h2 { font-size: 20px; font-weight: 700; }
.modale p { margin: 0; color: var(--encre-2); }
.grille-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modale-pied { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.cle-api { display: flex; gap: 8px; align-items: center; background: var(--papier); border-radius: var(--r-ctrl); padding: 10px 12px; }
.cle-api code { flex: 1; word-break: break-all; font-size: 12.5px; }

/* ---------- Notifications ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--encre); color: var(--blanc); padding: 12px 16px; border-radius: 12px; font-size: 14px; max-width: 360px; animation: entree .25s ease-out; }
.toast.erreur { background: var(--grenade); }

/* ---------- Page de connexion ---------- */
.page-login { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; background: var(--blanc); }
.login-visuel { position: relative; overflow: hidden; background: var(--majorelle); display: flex; align-items: flex-end; padding: 56px; }
.arches { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center; gap: 4%; padding: 0 8%; }
.arches span { flex: 1; height: 72%; border: 28px solid rgba(255,255,255,.1); border-bottom: 0; border-radius: 999px 999px 0 0; }
.arches span:nth-child(2) { height: 86%; border-color: var(--safran); opacity: .9; }
.login-accroche { position: relative; margin: 0; color: var(--blanc); font-size: clamp(30px, 3.4vw, 46px); font-weight: 800; line-height: 1.08; letter-spacing: -0.035em; text-shadow: 0 2px 24px rgba(34,29,99,.35); }
.login-form { display: grid; place-items: center; padding: 40px 24px; }
.carte-login { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 18px; }
.carte-login h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; }
.carte-login .aide { margin: -10px 0 4px; color: var(--gris); }

/* ---------- Page compte ---------- */
.formulaire-page { max-width: 560px; display: flex; flex-direction: column; gap: 16px; }
.formulaire-page h2 { font-size: 17px; margin-top: 8px; }

/* ---------- Animations ---------- */
@keyframes pouls { 0% { box-shadow: 0 0 0 0 rgba(18,134,95,.45); } 70% { box-shadow: 0 0 0 8px rgba(18,134,95,0); } 100% { box-shadow: 0 0 0 0 rgba(18,134,95,0); } }
@keyframes entree { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Adaptation aux écrans ---------- */
@media (max-width: 1180px) {
  .tableau { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .compteur { grid-template-columns: 1fr; gap: 12px; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .nav { position: fixed; z-index: 50; left: 0; width: var(--nav-l); transform: translateX(-100%); transition: transform .25s ease; }
  .nav.ouvert { transform: none; }
  .voile.ouvert { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(26,28,43,.4); }
  .btn-icone.burger { display: inline-grid; }
  .contenu { padding: 18px 16px 40px; }
  .entete-droite { margin-left: 0; width: 100%; }
  .recherche input { width: 100%; }
  .recherche { flex: 1; }
  .page-login { grid-template-columns: 1fr; }
  .login-visuel { min-height: 220px; padding: 28px; }
  .compteur { padding: 24px 22px; border-radius: 18px; }
  .grille-2 { grid-template-columns: 1fr; }
}
