:root {
  --fond: #f5f3ef;
  --carte: #ffffff;
  --texte: #1f1d1a;
  --discret: #6b665e;
  --trait: #dcd7ce;
  --accent: #6d2b45;
  --accent-clair: #f3e6eb;
  --succes: #1e6b45;
  --succes-fond: #e6f3ec;
  --erreur: #9b1c1c;
  --erreur-fond: #fbeaea;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.bandeau {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding: 14px 24px;
  background: var(--accent);
  color: #fff;
}
.marque { color: #fff; text-decoration: none; font-weight: 600; }
.marque span { font-weight: 400; opacity: .8; margin-left: 8px; }
.bandeau nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; }
.bandeau nav a { color: #fff; text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
.bandeau nav a.actif, .bandeau nav a:hover { border-bottom-color: #fff; }
.bandeau form { margin: 0; }
button.lien { background: none; border: 0; padding: 0; color: #fff; font: inherit; opacity: .85; cursor: pointer; }
button.lien:hover { opacity: 1; text-decoration: underline; }

main { max-width: 1280px; margin: 0 auto; padding: 24px 16px 48px; }

.carte {
  background: var(--carte);
  border: 1px solid var(--trait);
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 20px;
}
.carte.etroite { max-width: 380px; margin: 48px auto; }
.carte.alerte { border-color: var(--erreur); }

h1 { font-size: 1.4rem; margin: 0 0 6px; }
h2 { font-size: 1.1rem; margin: 0 0 14px; }
.aide { color: var(--discret); margin: 0 0 18px; }

.grille { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 20px; margin-top: 16px; }
.large { grid-column: 1 / -1; }
.champ { min-width: 0; }

label { display: block; font-weight: 600; margin-bottom: 4px; }
small { display: block; color: var(--discret); margin-top: 4px; font-size: .85rem; }

input, select {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid #b9b2a6;
  border-radius: 6px;
}
input:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent-clair);
  outline-offset: 1px;
  border-color: var(--accent);
}
#code_barre { font-size: 1.25rem; letter-spacing: .04em; font-variant-numeric: tabular-nums; }

.code-ligne { display: flex; flex-wrap: wrap; gap: 8px; }
.code-ligne input { flex: 1 1 240px; min-width: 0; }
.code-ligne button { flex: 0 0 auto; }
.scanner { margin-top: 12px; max-width: 520px; }
#scanner-video { width: 100%; background: #000; border-radius: 8px; overflow: hidden; }
#scanner-video video { display: block; width: 100%; }
.scanner button { margin-top: 8px; }
.scanner-etat { margin: 8px 0 0; color: var(--discret); min-height: 1.5em; }
.scanner-etat:empty { display: none; }

.taille { display: flex; gap: 8px; }
.taille input { flex: 1 1 auto; min-width: 0; }
.taille select { flex: 0 0 110px; }

.carte.etroite label { margin-top: 14px; }
.carte.etroite button { margin-top: 20px; width: 100%; }

button, .bouton {
  display: inline-block;
  padding: 10px 16px;
  font: inherit;
  color: var(--texte);
  background: #fff;
  border: 1px solid #b9b2a6;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
}
button:hover, .bouton:hover { background: #f1eee8; }
button.principal { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.principal:hover { background: #561f35; }
button.danger { color: var(--erreur); border-color: var(--erreur); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.message { padding: 12px 16px; border-radius: 8px; margin: 0 0 16px; border: 1px solid; }
.message.succes { background: var(--succes-fond); color: var(--succes); border-color: #b5d9c5; }
.message.erreur { background: var(--erreur-fond); color: var(--erreur); border-color: #ebc0c0; }
.message.info { background: #eef1f6; color: #2c3e5c; border-color: #c9d3e3; }

.entete-liste { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.compte { color: var(--discret); font-weight: 400; font-size: 1rem; margin-left: 6px; }
.recherche { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.recherche input { flex: 1 1 260px; }

.defilement { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--trait); vertical-align: top; }
th { color: var(--discret); font-weight: 600; white-space: nowrap; }
td.code { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.discret { color: var(--discret); font-size: .85rem; white-space: nowrap; }
td a { color: var(--accent); }
.actions-ligne { min-width: 90px; }
.actions-ligne details { margin-top: 4px; }
.actions-ligne summary { cursor: pointer; color: var(--erreur); }
.actions-ligne details form { margin-top: 6px; }

.pastille { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .85rem; white-space: nowrap; }
.pastille.oui { background: var(--succes-fond); color: var(--succes); }
.pastille.non { background: #f1eee8; color: var(--discret); }
.pastille.modifie { background: #eef1f6; color: #2c3e5c; }
.pastille.supprime { background: var(--erreur-fond); color: var(--erreur); }

.fiche { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0 0 16px; }
.fiche dt { color: var(--discret); }
.fiche dd { margin: 0; }

.chiffres { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 0 20px; }
.chiffres div { border: 1px solid var(--trait); border-radius: 8px; padding: 12px 14px; }
.chiffres dt { color: var(--discret); font-size: .85rem; }
.chiffres dd { margin: 2px 0 0; font-size: 1.3rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.chiffres dd small { display: inline; font-size: .8rem; font-weight: 400; }
table.chiffre td, table.chiffre th { vertical-align: middle; }
th.nb, td.nb { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
th a { color: inherit; text-decoration: none; border-bottom: 1px dotted currentColor; }
th a.tri-actif { color: var(--accent); border-bottom-style: solid; }
td.jauge { white-space: nowrap; min-width: 200px; }
td.jauge span { font-variant-numeric: tabular-nums; }
td.jauge small { display: inline; }
progress { width: 90px; height: 10px; margin-right: 8px; vertical-align: middle; border: 0; border-radius: 5px; background: #ebe7df; overflow: hidden; }
progress::-webkit-progress-bar { background: #ebe7df; border-radius: 5px; }
progress::-webkit-progress-value { background: var(--succes); border-radius: 5px; }
progress::-moz-progress-bar { background: var(--succes); border-radius: 5px; }
progress.moyen::-webkit-progress-value { background: #b7791f; }
progress.moyen::-moz-progress-bar { background: #b7791f; }
progress.bas::-webkit-progress-value { background: var(--erreur); }
progress.bas::-moz-progress-bar { background: var(--erreur); }
progress.part::-webkit-progress-value { background: var(--accent); }
progress.part::-moz-progress-bar { background: var(--accent); }
td.alerte-forte { color: var(--erreur); font-weight: 600; }
td.alerte-moyenne { color: #8a5a12; font-weight: 600; }
.chiffres dd.petit { font-size: 1.05rem; letter-spacing: .02em; }
.discret-inline { color: var(--discret); }
.recherche input[list] { flex: 0 1 220px; }
details.retrait summary { cursor: pointer; color: var(--erreur); }
details.retrait form { margin-top: 6px; }
tr.ajout td { background: var(--succes-fond); }
tfoot th { border-top: 2px solid var(--texte); border-bottom: 0; color: var(--texte); font-size: 1.05rem; }
.comparaison { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 16px 0 20px; }
.comparaison > div { border: 1px solid var(--trait); border-radius: 8px; padding: 16px; }
.comparaison h2 { color: var(--discret); font-size: .9rem; font-weight: 600; margin-bottom: 8px; }
.fenetre-produit { font-weight: 600; margin: 0 0 12px; }
.resume { margin: 16px 0 20px; padding-left: 20px; }
.resume li { margin-bottom: 4px; }
.resume .code, .fenetre .code { font-variant-numeric: tabular-nums; }

.voile { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(31, 29, 26, .55); }
.fenetre { width: 100%; max-width: 460px; background: var(--carte); border-radius: 10px; border-top: 6px solid var(--erreur); padding: 24px; box-shadow: 0 12px 40px rgba(0, 0, 0, .3); }
.fenetre h2 { color: var(--erreur); }
.fenetre p { margin: 0 0 12px; }
.fenetre .actions { margin-top: 20px; }
.bouton.principal-lien { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.note { margin: 14px 0 0; font-size: .9rem; }
.retour { margin: 0 0 8px; }
.retour a { color: var(--accent); }

.pagination { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.vide { color: var(--discret); }
.invisible { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 720px) {
  .grille { grid-template-columns: 1fr; }
  .comparaison { grid-template-columns: 1fr; }
  .carte { padding: 18px; }
}

/* Suivi SEO */
.hausse { color: var(--succes); font-weight: 600; white-space: nowrap; }
.baisse { color: var(--erreur); font-weight: 600; white-space: nowrap; }
.filtres { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.bouton.choisi { background: var(--accent); border-color: var(--accent); color: #fff; }
.courbe { margin: 0 0 20px; }
.courbe svg { width: 100%; max-width: 640px; height: auto; display: block; }
.courbe .repere { stroke: var(--trait); stroke-width: 1; }
.courbe .trace { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.courbe figcaption { color: var(--discret); font-size: .85rem; margin-top: 6px; }
details > summary { cursor: pointer; color: var(--accent); margin-bottom: 8px; }
td form { margin: 0; }
