/* bddstock.clinilac.com — feuille de style terrain.
   Concue pour une main, un pouce, une reserve mal eclairee.
   Palette Clinilac : menthe #B2EBC9, emeraude #4C9A84, taupe #A7A194,
   creme #F6F3E7, sable #DAC78F. */

:root {
  --menthe:   #B2EBC9;
  --emeraude: #4C9A84;
  --emeraude-fonce: #2F6B5A;
  --taupe:    #A7A194;
  --creme:    #F6F3E7;
  --sable:    #DAC78F;

  --encre:    #1E2A26;
  --gris:     #6B7573;
  --bord:     #DCD8CC;
  --fond:     #FFFFFF;

  --alerte:   #C4562E;
  --attention:#D08A2E;
  --succes:   #3E8E5F;

  /* Code couleur de provenance (5 etats) */
  --prov-non-verifie: #9AA3A0;   /* gris   : vient de l'Excel */
  --prov-deux:        #2F6FB5;   /* bleu   : 2 sources concordantes */
  --prov-une:         #8FB6DE;   /* bleu clair : 1 source, a confirmer */
  --prov-manuel:      #3E8E5F;   /* vert   : saisi a la main */
  --prov-conflit:     #D08A2E;   /* orange : contradiction */

  --rayon: 12px;
  --touche: 52px;                /* hauteur minimale d'une cible tactile */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: Afacad, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  color: var(--encre);
  background: var(--creme);
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { font-weight: 600; line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
a { color: var(--emeraude-fonce); }

/* ---------- Ossature ---------- */
.bandeau {
  position: sticky; top: 0; z-index: 40;
  background: var(--emeraude); color: #fff;
  padding: .5rem .9rem;
  display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.bandeau a { color: #fff; text-decoration: none; }
.bandeau .marque { font-weight: 700; font-size: 1.05rem; letter-spacing: .01em; }
.bandeau .titre { font-weight: 600; flex: 1; font-size: 1.05rem; }
.bandeau .compteur { font-size: .85rem; opacity: .9; }
.bandeau-fin { margin-left: auto; font-size: .85rem; opacity: .92; }

/* Menu : bandeau deroule sur grand ecran (Surface), replie sur telephone */
.burger {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; font-size: 1.3rem; line-height: 1;
  background: transparent; border: 1px solid rgba(255,255,255,.45);
  border-radius: 9px; color: #fff; cursor: pointer; font-family: inherit;
}
.menu { display: none; gap: .2rem; }
.menu.ouvert {
  display: flex; flex-direction: column;
  flex-basis: 100%; margin-top: .4rem;
}
.menu a {
  padding: .55rem .8rem; border-radius: 9px;
  font-size: .95rem; font-weight: 500; white-space: nowrap;
}
.menu a.actif { background: rgba(255,255,255,.22); font-weight: 600; }

@media (min-width: 720px) {
  .burger { display: none; }
  .menu { display: flex !important; flex-direction: row; flex-basis: auto; margin: 0; }
  .menu a:hover { background: rgba(255,255,255,.15); }
  .bandeau { padding: .55rem 1.2rem; }
}

main { padding: .9rem; max-width: 780px; margin: 0 auto; }
@media (min-width: 1000px) { main { max-width: 1040px; } }
.carte {
  background: var(--fond); border: 1px solid var(--bord);
  border-radius: var(--rayon); padding: .9rem; margin-bottom: .8rem;
}
.carte h2 { margin-bottom: .6rem; }
.muted { color: var(--gris); font-size: .9rem; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: var(--touche); padding: .6rem 1rem;
  border: 1px solid var(--bord); border-radius: var(--rayon);
  background: var(--fond); color: var(--encre);
  font-size: 1rem; font-family: inherit; font-weight: 500;
  cursor: pointer; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primaire { background: var(--emeraude); border-color: var(--emeraude); color: #fff; }
.btn-large { width: 100%; min-height: 62px; font-size: 1.1rem; }
.btn-danger { border-color: var(--alerte); color: var(--alerte); }
.btn:disabled { opacity: .45; }

/* ---------- Selecteur de niveau (toujours visible) ---------- */
.niveaux {
  position: sticky; top: 48px; z-index: 35;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  background: var(--creme); padding: .5rem 0;
}
.niveaux button {
  min-height: var(--touche);
  border: 2px solid var(--bord); border-radius: 10px;
  background: var(--fond); color: var(--gris);
  font-size: .82rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .02em; font-family: inherit; cursor: pointer;
  padding: .3rem .1rem; line-height: 1.1;
}
.niveaux button[aria-pressed="true"] {
  background: var(--emeraude); border-color: var(--emeraude-fonce); color: #fff;
}
.niveaux button[data-niveau="a_trier"][aria-pressed="true"] {
  background: var(--sable); border-color: #B9A268; color: #3A2F14;
}

/* Rappel du niveau en cours, en grand, sur l'apercu camera */
.niveau-actuel {
  text-align: center; font-size: 1.35rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  padding: .5rem; border-radius: 10px; margin-bottom: .6rem;
  background: var(--emeraude); color: #fff;
}
.niveau-actuel.a_trier { background: var(--sable); color: #3A2F14; }

/* ---------- Consignes de prise de vue ---------- */
.consignes {
  background: var(--menthe); border-radius: 10px;
  padding: .55rem .8rem; margin-bottom: .7rem;
  font-size: .88rem; color: var(--emeraude-fonce);
}
.consignes ul { margin: .2rem 0 0; padding-left: 1.1rem; }
.consignes li { margin: .1rem 0; }

/* ---------- Galerie de rafale ---------- */
.rafale { display: flex; gap: .45rem; overflow-x: auto; padding: .3rem 0 .5rem; }
.rafale figure {
  margin: 0; position: relative; flex: 0 0 auto;
  width: 84px; height: 84px; border-radius: 10px; overflow: hidden;
  border: 3px solid var(--bord); background: var(--creme);
}
.rafale img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rafale figure[data-niveau="surcarton"] { border-color: #7E57C2; }
.rafale figure[data-niveau="carton"]    { border-color: var(--emeraude); }
.rafale figure[data-niveau="unite"]     { border-color: #2F6FB5; }
.rafale figure[data-niveau="etagere"]   { border-color: var(--taupe); }
.rafale figure[data-niveau="a_trier"]   { border-color: var(--sable); }
.rafale figcaption {
  position: absolute; bottom: 0; left: 0; right: 0;
  font-size: .58rem; text-transform: uppercase; text-align: center;
  background: rgba(0,0,0,.6); color: #fff; padding: 1px 0;
}
.rafale .envoi { position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(255,255,255,.75); font-size: .7rem; }

/* ---------- Candidats d'identification ---------- */
.candidat {
  display: block; width: 100%; text-align: left;
  border: 1px solid var(--bord); border-left: 5px solid var(--taupe);
  border-radius: 10px; background: var(--fond);
  padding: .65rem .8rem; margin-bottom: .45rem;
  font-family: inherit; font-size: 1rem; cursor: pointer;
}
.candidat strong { display: block; }
.candidat .meta { font-size: .82rem; color: var(--gris); }
.candidat[data-confiance="haute"] { border-left-color: var(--succes); }
.candidat[data-confiance="moyenne"] { border-left-color: var(--sable); }
.candidat[data-confiance="basse"] { border-left-color: var(--taupe); }
.badge {
  display: inline-block; font-size: .72rem; font-weight: 600;
  padding: .1rem .45rem; border-radius: 20px;
  background: var(--creme); color: var(--gris); border: 1px solid var(--bord);
}

/* ---------- Lecture de l'etiquette ---------- */
.lu { background: var(--creme); border-radius: 10px; padding: .6rem .8rem; margin-bottom: .7rem; }
.lu dl { display: grid; grid-template-columns: auto 1fr; gap: .15rem .6rem; margin: 0; font-size: .9rem; }
.lu dt { color: var(--gris); }
.lu dd { margin: 0; font-weight: 500; }

/* ---------- Saisie des quantites ---------- */
.compteur-ligne {
  display: grid; grid-template-columns: 1fr auto auto auto;
  align-items: center; gap: .5rem; margin-bottom: .55rem;
}
.compteur-ligne label { font-weight: 500; }
.compteur-ligne .sous { display: block; font-size: .78rem; color: var(--gris); font-weight: 400; }
.compteur-ligne input[type="number"] {
  width: 76px; height: var(--touche); text-align: center;
  font-size: 1.25rem; font-family: inherit; font-weight: 600;
  border: 1px solid var(--bord); border-radius: 10px; background: var(--fond);
}
.pas {
  width: var(--touche); height: var(--touche);
  font-size: 1.4rem; line-height: 1; font-family: inherit;
  border: 1px solid var(--bord); border-radius: 10px;
  background: var(--fond); cursor: pointer;
}

.total {
  background: var(--emeraude-fonce); color: #fff;
  border-radius: var(--rayon); padding: .8rem; text-align: center; margin: .7rem 0;
}
.total .chiffre { font-size: 2rem; font-weight: 700; line-height: 1; }
.total .detail { font-size: .8rem; opacity: .9; margin-top: .3rem; }
.total.doute { background: var(--attention); }

/* ---------- Drapeaux ---------- */
.drapeaux { display: grid; grid-template-columns: repeat(2, 1fr); gap: .45rem; }
.drapeau {
  display: flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: var(--touche); border: 2px solid var(--bord); border-radius: 10px;
  background: var(--fond); font-size: .92rem; font-family: inherit; cursor: pointer;
}
.drapeau[aria-pressed="true"] { background: var(--alerte); border-color: var(--alerte); color: #fff; }
.drapeau[data-drapeau="pas_vu"][aria-pressed="true"] { background: var(--taupe); border-color: var(--taupe); }

/* ---------- Provenance : le code couleur ---------- */
.prov { border-left: 4px solid var(--prov-non-verifie); padding-left: .55rem; }
.prov[data-etat="deux_sources"] { border-left-color: var(--prov-deux); }
.prov[data-etat="une_source"]   { border-left-color: var(--prov-une); }
.prov[data-etat="manuel"]       { border-left-color: var(--prov-manuel); }
.prov[data-etat="conflit"]      { border-left-color: var(--prov-conflit); background: #FDF4E6; }
.prov .origine { font-size: .74rem; color: var(--gris); }

/* ---------- Divers ---------- */
.alerte-ecart {
  background: #FDF4E6; border: 1px solid var(--attention);
  border-radius: 10px; padding: .55rem .8rem; margin: .5rem 0;
  font-size: .9rem; color: #7A4E12;
}
.messages { margin-bottom: .8rem; }
.message { padding: .6rem .8rem; border-radius: 10px; margin-bottom: .4rem; }
.message.erreur { background: #FBE9E3; color: #7A2E12; }
.message.info { background: var(--menthe); color: var(--emeraude-fonce); }

input[type="text"], input[type="password"], input[type="date"], input[type="search"], select, textarea {
  width: 100%; min-height: var(--touche); padding: .5rem .7rem;
  font-size: 1rem; font-family: inherit;
  border: 1px solid var(--bord); border-radius: 10px; background: var(--fond);
}
.barre-actions {
  position: sticky; bottom: 0; background: var(--creme);
  padding: .6rem 0; display: grid; grid-template-columns: 1fr 1fr; gap: .5rem;
  border-top: 1px solid var(--bord);
}
.pied { text-align: center; font-size: .78rem; color: var(--gris); padding: 1rem 0 2rem; }
.rien { text-align: center; color: var(--gris); padding: 1.4rem 0; }

/* ---------- Camera integree (Surface et iPhone) ---------- */
.camera { margin: .6rem 0; }
.camera video {
  width: 100%; max-height: 46vh; background: #000;
  border-radius: var(--rayon); display: block;
}
.camera-actions { display: grid; grid-template-columns: 2fr 1fr; gap: .5rem; margin-top: .5rem; }
.declencheur { min-height: 62px; font-size: 1.1rem; }

/* ---------- Liste des produits ---------- */
.filtres {
  display: grid; grid-template-columns: 1fr; gap: .5rem; margin-bottom: .7rem;
}
@media (min-width: 720px) { .filtres { grid-template-columns: 2fr 1fr auto; align-items: end; } }

.tableau { width: 100%; overflow-x: auto; }
table.produits { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.produits th, table.produits td {
  text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--bord);
  vertical-align: top;
}
table.produits th {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .03em;
  color: var(--gris); font-weight: 600; white-space: nowrap;
}
table.produits tbody tr:hover { background: var(--creme); }
table.produits td a { color: var(--encre); text-decoration: none; font-weight: 500; }
table.produits td a:hover { text-decoration: underline; }
table.produits .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pastille {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: var(--bord); vertical-align: middle;
}
.pastille.compte { background: var(--succes); }
.pastille.partiel { background: var(--sable); }
.resume-chiffres {
  display: flex; gap: 1.2rem; flex-wrap: wrap; margin-bottom: .7rem;
  font-size: .9rem; color: var(--gris);
}
.resume-chiffres strong { color: var(--encre); font-size: 1.15rem; }

/* ---------- Fiche article : structure complete, champs vides compris ---------- */
.champ {
  display: grid; grid-template-columns: 1fr; gap: .1rem;
  padding: .45rem 0 .45rem .6rem;
  border-bottom: 1px solid var(--bord);
  border-left: 4px solid transparent;
}
@media (min-width: 620px) {
  .champ { grid-template-columns: 230px 1fr; gap: .6rem; align-items: baseline; }
}
.champ:last-child { border-bottom: none; }
.champ-libelle { color: var(--gris); font-size: .88rem; }
.champ-valeur { font-weight: 500; }
.champ.vide .champ-valeur { font-weight: 400; }
.non-renseigne { color: var(--taupe); font-style: italic; font-size: .9rem; }
.champ-note { display: block; color: var(--gris); font-size: .8rem; font-weight: 400; }
.champ-origine {
  display: inline-block; margin-left: .4rem;
  font-size: .74rem; color: var(--gris); font-weight: 400;
}
/* Le code couleur de provenance, applique au liseré gauche */
.champ[data-etat="non_verifie"]  { border-left-color: var(--prov-non-verifie); }
.champ[data-etat="deux_sources"] { border-left-color: var(--prov-deux); }
.champ[data-etat="une_source"]   { border-left-color: var(--prov-une); }
.champ[data-etat="manuel"]       { border-left-color: var(--prov-manuel); }
.champ[data-etat="conflit"]      { border-left-color: var(--prov-conflit); background: #FDF4E6; }

.niveau-fiche {
  border: 1px solid var(--bord); border-radius: 10px;
  padding: .5rem .7rem; margin-bottom: .6rem;
}
.niveau-fiche.absent { opacity: .62; border-style: dashed; }
.niveau-titre {
  font-weight: 600; margin-bottom: .3rem;
  display: flex; align-items: center; gap: .5rem;
}
.sous-titre { font-size: .95rem; margin: .8rem 0 .4rem; color: var(--gris); }

/* ---------- Galerie de photos ---------- */
.galerie {
  display: grid; gap: .5rem;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.vignette {
  display: block; position: relative; border-radius: 10px; overflow: hidden;
  border: 3px solid var(--bord); background: var(--creme); text-decoration: none;
}
.vignette img { width: 100%; height: 140px; object-fit: cover; display: block; }
.vignette-info {
  display: block; padding: .25rem .4rem; font-size: .72rem;
  color: var(--gris); background: var(--fond);
}
.vignette[data-niveau="surcarton"] { border-color: #7E57C2; }
.vignette[data-niveau="carton"]    { border-color: var(--emeraude); }
.vignette[data-niveau="unite"]     { border-color: #2F6FB5; }
.vignette[data-niveau="etagere"]   { border-color: var(--taupe); }
.vignette[data-niveau="a_trier"]   { border-color: var(--sable); }
