:root {
  --vert: #1f7a4d;
  --vert-pale: #e6f3ec;
  --rouge: #c8372d;
  --texte: #1d2320;
  --gris: #6b736f;
  --fond: #f7f8f6;
  --carte: #fff;
  --bord: #e2e6e3;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--texte);
  background: var(--fond);
}
* { box-sizing: border-box; }
body { margin: 0; }
main { max-width: 1100px; margin: 0 auto; padding: 1rem; }

.entete {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .8rem 1.2rem; background: var(--vert); color: #fff;
}
.marque { font-size: 1.25rem; }
.cp { display: flex; align-items: center; gap: .4rem; }
.cp label { font-size: .85rem; opacity: .9; }
.cp input { width: 7.5rem; text-transform: uppercase; }

input, select, button {
  font: inherit; padding: .5rem .7rem; border-radius: 8px; border: 1px solid var(--bord);
}
button { background: var(--texte); color: #fff; border: none; cursor: pointer; font-weight: 600; }
.entete button { background: #fff; color: var(--vert); }

.bandeau { background: #fff4d6; padding: .5rem 1.2rem; font-size: .9rem; }

.recherche form { display: flex; gap: .5rem; }
.recherche #q { flex: 1; font-size: 1.1rem; padding: .75rem 1rem; }
.filtres { display: flex; flex-wrap: wrap; gap: 1rem; margin: .8rem 0; font-size: .9rem; color: var(--gris); }
.filtres label { display: flex; align-items: center; gap: .4rem; }

.meilleur {
  background: var(--vert-pale); border: 2px solid var(--vert); border-radius: 12px;
  padding: .9rem 1.1rem; margin: 1rem 0;
}
.meilleur strong { color: var(--vert); }

.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: .7rem; }

/* Carte compacte : hauteur fixe, nom sur 2 lignes, description dans une bulle au survol */
.carte {
  position: relative; background: var(--carte); border: 1px solid var(--bord); border-radius: 12px;
  display: flex; flex-direction: column; cursor: pointer; height: 262px;
  transition: transform .12s ease, box-shadow .12s ease;
}
.carte:hover, .carte:focus-visible { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.08); z-index: 3; outline: none; }
.carte .image { height: 96px; display: grid; place-items: center; padding: .5rem; border-radius: 12px 12px 0 0; background: #fff; }
.carte .image img { max-width: 100%; max-height: 86px; object-fit: contain; }
.carte .image.sans-image::before { content: '🛒'; font-size: 2rem; opacity: .25; }
.carte .corps { padding: .45rem .65rem .6rem; display: flex; flex-direction: column; gap: .2rem; flex: 1; min-height: 0; }
.enseigne { font-size: .68rem; font-weight: 700; text-transform: uppercase; color: var(--vert); letter-spacing: .03em; }
.nom {
  font-size: .86rem; margin: 0; line-height: 1.25; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.5em;
}
.prix { display: flex; align-items: baseline; gap: .4rem; margin-top: auto; flex-wrap: wrap; }
.actuel { font-size: 1.08rem; font-weight: 800; }
.avant { color: var(--gris); font-size: .78rem; }
.unitaire { font-size: .74rem; color: var(--texte); background: var(--fond); padding: .1rem .35rem; border-radius: 6px; width: fit-content; }
.source { font-size: .66rem; color: var(--gris); }
.carte.top { outline: 3px solid var(--vert); }
.carte.web { border-color: #c9d8f0; }
.carte.web .source { color: #2b5ea7; font-weight: 600; }

.badge-rabais {
  position: absolute; top: .45rem; left: .45rem; z-index: 1;
  background: var(--rouge); color: #fff; font-size: .72rem; font-weight: 800; padding: .1rem .4rem; border-radius: 6px;
}
.badge-rabais[hidden] { display: none; }
.carte .ajouter {
  position: absolute; top: .4rem; right: .4rem; z-index: 1; width: 2rem; height: 2rem; padding: 0;
  border-radius: 50%; font-size: 1.2rem; line-height: 1; background: var(--vert); color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.carte .ajouter.dedans { background: #fff; color: var(--vert); border: 2px solid var(--vert); font-size: 1rem; }

/* Bulle de description */
.bulle {
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%) translateY(4px);
  width: min(300px, 80vw); padding: .6rem .75rem; border-radius: 10px; background: var(--texte); color: #fff;
  font-size: .78rem; line-height: 1.4; box-shadow: 0 8px 24px rgba(0,0,0,.2);
  display: -webkit-box; -webkit-line-clamp: 8; -webkit-box-orient: vertical; overflow: hidden;
  opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .15s ease .35s, transform .15s ease .35s;
}
.bulle::after {
  content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 7px solid transparent; border-top-color: var(--texte);
}
.carte:hover .bulle { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
@media (hover: none) { .bulle { display: none; } }

/* Catégories de l'accueil */
.categories { display: flex; gap: .5rem; overflow-x: auto; padding: .8rem 0 .3rem; scrollbar-width: thin; }
.categories button {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: .2rem; min-width: 92px;
  background: var(--carte); color: var(--texte); border: 1px solid var(--bord); border-radius: 12px; padding: .55rem .6rem;
  font-size: .78rem; font-weight: 600;
}
.categories button .emoji { font-size: 1.5rem; }
.categories button:hover { border-color: var(--vert); }
.categories button.actif { background: var(--vert-pale); border-color: var(--vert); color: var(--vert); }
.titre-resultats { font-size: 1.2rem; margin: 1rem 0 .6rem; }
.alertes { background: #fff4d6; border-radius: 10px; padding: .5rem .8rem; margin: .6rem 0; font-size: .85rem; }
.alertes[hidden] { display: none; }
.meilleur { cursor: pointer; }
.marque { color: #fff; text-decoration: none; }

/* Fiche produit */
.fiche {
  width: min(760px, 94vw); max-height: 90vh; border: none; border-radius: 16px; padding: 1.4rem 1.5rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); color: var(--texte);
}
.fiche::backdrop { background: rgba(20, 28, 24, .55); }
.fiche .fermer { position: absolute; top: .7rem; right: .7rem; }
.fiche-haut { display: grid; grid-template-columns: 180px 1fr; gap: 1.2rem; align-items: start; }
.fiche-haut img { width: 100%; max-height: 180px; object-fit: contain; }
.fiche-sans-image { height: 150px; display: grid; place-items: center; font-size: 3rem; background: var(--fond); border-radius: 12px; }
.fiche-infos { display: flex; flex-direction: column; gap: .35rem; }
.fiche-infos h2 { margin: 0; font-size: 1.25rem; line-height: 1.3; padding-right: 2rem; }
.fiche-infos .actuel { font-size: 1.6rem; }
.fiche-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .4rem; }
.principal { background: var(--vert); }
.bouton-lien { padding: .5rem .8rem; border: 1px solid var(--bord); border-radius: 8px; color: var(--texte); text-decoration: none; font-weight: 600; }
.fiche-desc { font-size: .88rem; color: var(--gris); line-height: 1.5; max-height: 7.5em; overflow-y: auto; }
.fiche h3 { margin: 1.2rem 0 .6rem; }
.verdict { display: flex; flex-direction: column; gap: .15rem; padding: .8rem 1rem; border-radius: 12px; background: var(--fond); margin-bottom: .7rem; }
.verdict strong { font-size: 1.15rem; }
.verdict.bon { background: var(--vert-pale); color: var(--vert); }
.verdict.mauvais { background: #fde9e7; color: var(--rouge); }
.verdict small { color: var(--gris); }
.tableau-comparaison { width: 100%; border-collapse: collapse; font-size: .86rem; }
.tableau-comparaison th { text-align: left; color: var(--gris); font-weight: 600; font-size: .75rem; padding: .3rem .4rem; border-bottom: 1px solid var(--bord); }
.tableau-comparaison td { padding: .45rem .4rem; border-bottom: 1px solid var(--bord); vertical-align: top; }
.tableau-comparaison td small { color: var(--gris); }
.tableau-comparaison tr.courant { background: var(--vert-pale); }
.tableau-comparaison .moins { color: var(--vert); font-weight: 700; }
.tableau-comparaison .plus { color: var(--rouge); font-weight: 700; }
.lien-fiche { color: var(--texte); font-weight: 600; text-decoration: none; }
.lien-fiche:hover { text-decoration: underline; }
@media (max-width: 560px) { .fiche-haut { grid-template-columns: 1fr; } }

.circulaires { margin-top: 2.5rem; }
.puces { display: flex; flex-wrap: wrap; gap: .5rem; }
.puces button { background: var(--carte); color: var(--texte); border: 1px solid var(--bord); }
.puces button.actif { background: var(--vert); color: #fff; border-color: var(--vert); }
.groupe h3 { margin: 1.5rem 0 .6rem; font-size: 1.1rem; }
.vide { color: var(--gris); }


/* --- Bouton et panneau de la liste -------------------------------------- */
.entete { position: sticky; top: 0; z-index: 5; }
.bouton-liste { background: #fff; color: var(--vert); margin-left: auto; }
#compteur-liste { background: var(--vert); color: #fff; border-radius: 999px; padding: 0 .45rem; margin-left: .25rem; font-size: .85rem; }

.panneau-liste {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); z-index: 10;
  background: var(--fond); border-left: 1px solid var(--bord); box-shadow: -8px 0 30px rgba(0,0,0,.12);
  overflow-y: auto; padding: 1rem 1.1rem 2rem;
}
.panneau-liste[hidden] { display: none; }
.panneau-entete { display: flex; justify-content: space-between; align-items: center; }
.panneau-entete h2 { margin: 0; font-size: 1.2rem; }
.fermer { background: transparent; color: var(--texte); font-size: 1.1rem; }
.magasin { background: var(--carte); border: 1px solid var(--bord); border-radius: 12px; padding: .7rem .8rem; margin: .9rem 0; }
.magasin h3 { margin: 0 0 .5rem; display: flex; justify-content: space-between; font-size: 1.05rem; }
.sous-total { color: var(--vert); }
.ligne { display: grid; grid-template-columns: 1fr auto auto auto; gap: .5rem; align-items: center; padding: .45rem 0; border-top: 1px solid var(--bord); }
.ligne-nom { display: flex; flex-direction: column; font-size: .9rem; }
.ligne-nom small { color: var(--gris); font-size: .75rem; }
.qte { font-size: .75rem; color: var(--gris); white-space: nowrap; }
.qte input { width: 4.2rem; padding: .3rem .4rem; }
.cout { font-weight: 700; min-width: 4.5rem; text-align: right; }
.retirer { background: transparent; color: var(--gris); padding: .2rem .4rem; }
.comparatif { font-size: .75rem; color: var(--gris); padding: 0 0 .3rem; display: flex; flex-wrap: wrap; gap: .3rem .6rem; }
.comparatif span { background: var(--fond); border-radius: 6px; padding: 0 .35rem; }
.suggestion { font-size: .8rem; background: #fff7e0; border-radius: 8px; padding: .4rem .55rem; margin-bottom: .4rem; }
.suggestion button { font-size: .75rem; padding: .2rem .5rem; margin-left: .3rem; }
.total { display: flex; justify-content: space-between; font-size: 1.2rem; padding: .6rem .2rem; border-top: 2px solid var(--texte); margin-top: .6rem; }
.note { font-size: .75rem; color: var(--gris); margin: .2rem 0 .6rem; }
.optimiser { width: 100%; background: var(--vert); margin-bottom: .6rem; }
.panneau-actions { display: flex; gap: .5rem; margin-top: .5rem; }
.secondaire { background: transparent; color: var(--texte); border: 1px solid var(--bord); }

@media print {
  body > *:not(#panneau-liste) { display: none !important; }
  .panneau-liste { position: static; width: auto; box-shadow: none; border: none; display: block !important; }
  .panneau-actions, .fermer, .retirer, .suggestion, .optimiser, .comparatif { display: none !important; }
  .qte input { border: none; width: 3rem; }
}
