:root {
  --jaune: #FFC800; --noir: #111111; --gris: #F4F4F2; --gris2: #E4E4E0; --gris3: #6B6B66;
  --blanc: #FFFFFF; --wa: #25D366; --rouge: #D93025; --orange: #E8710A;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--blanc); color: var(--noir); font-size: 16px; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* En-tête */
#entete { position: sticky; top: 0; z-index: 10; background: var(--noir); color: var(--blanc); display: grid;
  grid-template-columns: auto auto 1fr auto; align-items: center; gap: 10px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); min-height: 60px; }
#logo { height: 34px; background: var(--blanc); border-radius: 8px; padding: 2px 6px; }
#titre { margin: 0; font-size: 19px; font-weight: 800; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge-pro { background: var(--jaune); color: var(--noir); font-weight: 800; font-size: 13px; padding: 4px 10px; border-radius: 999px; }
.retour { width: 44px; height: 44px; border-radius: 50%; background: var(--jaune); border: 2px solid var(--noir); box-shadow: 0 0 0 2px var(--jaune);
  color: var(--noir); font-size: 24px; font-weight: 800; line-height: 1; cursor: pointer; padding: 0; }
.bandeau-reseau { background: var(--orange); color: var(--blanc); text-align: center; padding: 8px 16px; font-size: 14px; font-weight: 600; }

main { padding: 16px 16px 110px; max-width: 640px; margin: 0 auto; }

/* Barre du bas */
#barre { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; background: var(--noir); display: grid; grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom); }
#barre button { background: none; border: 0; color: #CFCFCA; min-height: 60px; font-size: 12px; font-weight: 600; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; cursor: pointer; }
#barre button span { font-size: 22px; }
#barre button.actif { color: var(--jaune); }

/* Boutons */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; border-radius: 14px; border: 2px solid var(--noir);
  font-weight: 700; font-size: 16px; text-decoration: none; cursor: pointer; padding: 10px 16px; margin: 10px 0; text-align: center; }
.btn-jaune { background: var(--jaune); color: var(--noir); }
.btn-noir { background: var(--noir); color: var(--jaune); }
.btn-gris { background: var(--gris); color: var(--noir); border-color: var(--gris2); }
.btn-wa { background: var(--wa); color: var(--blanc); border-color: var(--wa); }
.btn-danger { background: var(--blanc); color: var(--rouge); border-color: var(--rouge); }
.btn-gros { min-height: 64px; font-size: 18px; font-weight: 800; }
.btn:disabled { opacity: .5; }
.rang { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rang .btn { margin: 0; }

/* Connexion */
.connexion { text-align: center; padding-top: 30px; }
.connexion h2 { margin: 10px 0 4px; }
.pin { font-size: 34px; letter-spacing: 12px; text-align: center; width: 100%; max-width: 280px; min-height: 64px; border: 2px solid var(--noir);
  border-radius: 14px; margin: 20px auto 6px; display: block; background: var(--gris); }
.erreur { color: var(--rouge); font-weight: 600; min-height: 22px; margin: 6px 0; }

/* Recherche et filtres */
.recherche { width: 100%; min-height: 48px; border: 2px solid var(--gris2); border-radius: 12px; padding: 10px 14px; background: var(--gris); }
.recherche:focus, .champ input:focus, .champ select:focus, .champ textarea:focus { outline: none; border-color: var(--noir); }
.puces { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.puces::-webkit-scrollbar { display: none; }
.puce { flex: 0 0 auto; min-height: 40px; padding: 8px 14px; border-radius: 999px; border: 2px solid var(--gris2); background: var(--blanc); font-weight: 600; font-size: 14px; cursor: pointer; }
.puce.actif { background: var(--noir); color: var(--jaune); border-color: var(--noir); }
.puces.etiq { flex-wrap: wrap; overflow: visible; }

/* Liste */
.liste { list-style: none; margin: 8px 0 0; padding: 0; }
.ligne { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--gris2); cursor: pointer; min-height: 64px; }
.initiales { width: 48px; height: 48px; border-radius: 50%; background: var(--jaune); color: var(--noir); display: flex; align-items: center; justify-content: center; font-weight: 800; overflow: hidden; }
.initiales img { width: 100%; height: 100%; object-fit: cover; }
.ligne .nom { font-weight: 700; }
.ligne .sous, .ligne .tel { font-size: 13px; color: var(--gris3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ligne > div { min-width: 0; }
.etiquette { font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: 8px; background: var(--gris); border: 1px solid var(--gris2); white-space: nowrap; }
.etiquette.chaud { background: var(--jaune); border-color: var(--jaune); }
.etiquette.attente { background: var(--noir); color: var(--jaune); border-color: var(--noir); }
.etiquette.brouillon { background: var(--blanc); border: 1px dashed var(--noir); }
.vide { text-align: center; color: var(--gris3); padding: 30px 0; }
.compteur { font-size: 13px; color: var(--gris3); margin-top: 6px; }

/* Scanner */
.zone-photo { display: block; border: 2px dashed var(--noir); border-radius: 16px; background: var(--gris); min-height: 150px; padding: 16px; text-align: center; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; margin: 10px 0; font-weight: 700; position: relative; overflow: hidden; }
.zone-photo img { max-width: 100%; max-height: 220px; border-radius: 10px; }
.zone-photo small { font-weight: 500; color: var(--gris3); }
.interrupteur { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--gris); border-radius: 14px; padding: 12px 14px; min-height: 56px; margin: 10px 0; }
.interrupteur input { width: 26px; height: 26px; accent-color: var(--noir); }
.aide { font-size: 14px; color: var(--gris3); }

/* Fiche à vérifier */
.bandeau-ia { background: var(--jaune); border: 2px solid var(--noir); border-radius: 12px; padding: 10px 14px; font-weight: 700; margin-bottom: 12px; }
.bandeau-ia.echec { background: var(--blanc); border-color: var(--orange); color: var(--noir); }
.vignettes { display: flex; gap: 10px; margin-bottom: 10px; }
.vignettes img { width: calc(50% - 5px); max-height: 140px; object-fit: cover; border-radius: 10px; border: 1px solid var(--gris2); cursor: zoom-in; }
.champ { display: block; margin: 10px 0; }
.champ span { display: block; font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.champ input, .champ select, .champ textarea { width: 100%; min-height: 48px; border: 2px solid var(--gris2); border-radius: 12px; padding: 10px 12px; background: var(--blanc); }
.champ textarea { min-height: 90px; resize: vertical; }
.original { font-size: 13px; color: var(--gris3); direction: rtl; text-align: right; }

/* Fiche contact */
.tete-fiche { text-align: center; padding: 8px 0 6px; }
.tete-fiche .initiales { width: 72px; height: 72px; font-size: 26px; margin: 0 auto 8px; }
.tete-fiche h2 { margin: 0; font-size: 22px; }
.tete-fiche p { margin: 4px 0; color: var(--gris3); }
.infos { background: var(--gris); border-radius: 14px; padding: 4px 14px; margin: 12px 0; }
.infos div { padding: 10px 0; border-bottom: 1px solid var(--gris2); word-break: break-word; }
.infos div:last-child { border: 0; }
.infos b { display: block; font-size: 12px; color: var(--gris3); }
.infos a { color: var(--noir); }

/* Ma carte */
.carte-visuel { background: var(--noir); color: var(--blanc); border-radius: 18px; padding: 22px; position: relative; aspect-ratio: 1.7 / 1; display: flex; flex-direction: column;
  justify-content: flex-end; box-shadow: 0 8px 24px rgba(0,0,0,.18); overflow: hidden; border-bottom: 10px solid var(--jaune); }
.carte-logo { position: absolute; top: 16px; right: 16px; height: 34px; background: var(--blanc); border-radius: 8px; padding: 2px 6px; }
.carte-nom { font-size: 24px; font-weight: 800; color: var(--jaune); }
.carte-fonction { font-size: 14px; color: #DDD; }
.carte-societe { font-size: 15px; font-weight: 700; margin-top: 2px; }
.carte-lignes { font-size: 13px; margin-top: 10px; display: grid; gap: 2px; }
.qr { display: block; width: 240px; max-width: 80%; margin: 18px auto 6px; background: var(--blanc); border: 2px solid var(--noir); border-radius: 14px; padding: 8px; }
.lien-carte { text-align: center; font-size: 13px; color: var(--gris3); word-break: break-all; }

/* Page publique */
body.publique { background: var(--gris); }
.pub { max-width: 460px; margin: 0 auto; padding: 24px 16px 40px; }

/* Toast + zoom */
#toast { position: fixed; left: 16px; right: 16px; bottom: 80px; z-index: 30; background: var(--noir); color: var(--blanc); padding: 14px 16px; border-radius: 12px; text-align: center; font-weight: 600; }
#toast.err { background: var(--rouge); }
.zoom { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; padding: 16px; }
.zoom img { max-width: 100%; max-height: 100%; }
.chargement { text-align: center; padding: 40px 0; font-weight: 700; }
.chargement::before { content: ""; display: block; width: 40px; height: 40px; margin: 0 auto 14px; border: 4px solid var(--gris2); border-top-color: var(--jaune); border-radius: 50%; animation: tourne .8s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }
