:root {
  --encre: #14181d;
  --encre-doux: #55605c;
  --papier: #f1f3f1;
  --surface: #ffffff;
  --trait: #d4dad5;
  --atelier: #1f6b4a;
  --atelier-clair: #e6f0ea;
  --alerte: #a83b2a;
  --ambre: #8a5b0f;
  --rayon: 4px;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--encre);
  background: var(--papier);
  font-variant-numeric: tabular-nums;
}

a { color: var(--atelier); }
a:hover { color: #14523a; }

:focus-visible {
  outline: 2px solid var(--atelier);
  outline-offset: 2px;
}

/* ---------- Structure ---------- */

.bandeau {
  background: var(--encre);
  color: #eef2ef;
}

.bandeau .interieur {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1.25rem;
}

.bandeau .marque-app {
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #fff;
  text-decoration: none;
  margin-right: auto;
}

.bandeau nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: baseline;
}

.bandeau nav a {
  color: #c9d4cd;
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
}

.bandeau nav a:hover { color: #fff; }
.bandeau nav a.actif { color: #fff; border-bottom-color: var(--atelier); }

.bandeau form { display: inline; }

.bandeau .lien-bouton {
  background: none;
  border: 0;
  color: #c9d4cd;
  font: inherit;
  cursor: pointer;
  padding: 0;
}
.bandeau .lien-bouton:hover { color: #fff; }

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 0.25rem;
}

h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
}

.sous-titre { color: var(--encre-doux); margin: 0 0 1.5rem; }

.entete-page {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.bloc {
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  padding: 1.25rem;
}

.bloc + .bloc { margin-top: 1rem; }

.colonnes {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: 1rem;
  align-items: start;
}

@media (max-width: 820px) {
  .colonnes { grid-template-columns: 1fr; }
}

/* ---------- Référence : le motif « étiquette » ---------- */

.reference {
  font-family: var(--mono);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  background: #fff;
  border: 1px dashed var(--encre-doux);
  border-radius: 3px;
  padding: 0.1rem 0.4rem;
  white-space: nowrap;
  text-decoration: none;
  color: var(--encre);
  display: inline-block;
}

a.reference:hover { border-style: solid; border-color: var(--atelier); color: var(--atelier); }

.reference-grande { font-size: 1.35rem; padding: 0.35rem 0.7rem; letter-spacing: 0.08em; }

/* ---------- États ---------- */

.etat {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.pastille {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--encre-doux);
  flex: none;
}

.pastille.fonctionne { background: var(--atelier); }
.pastille.abime { background: #b98a1e; }
.pastille.tres-abime { background: var(--ambre); }
.pastille.en-panne { background: var(--alerte); }

.usage-neuf { color: var(--atelier); font-weight: 600; }
.usage-occasion { color: var(--encre-doux); }

/* ---------- Tableaux ---------- */

table.liste {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
}

table.liste th,
table.liste td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--trait);
  vertical-align: middle;
}

table.liste thead th {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--encre-doux);
  background: #f7f9f7;
}

table.liste tbody tr:last-child td { border-bottom: 0; }
table.liste tbody tr:hover { background: #f7f9f7; }

td.nombre, th.nombre { text-align: right; font-variant-numeric: tabular-nums; }

.produit-nom { font-weight: 600; }
.produit-marque { color: var(--encre-doux); }

@media (max-width: 720px) {
  table.liste, table.liste tbody, table.liste tr, table.liste td { display: block; width: 100%; }
  table.liste thead { display: none; }
  table.liste tr {
    border-bottom: 1px solid var(--trait);
    padding: 0.75rem 0.25rem;
  }
  table.liste td { border: 0; padding: 0.15rem 0.5rem; }
  table.liste td[data-libelle]::before {
    content: attr(data-libelle) " ";
    color: var(--encre-doux);
    font-size: 0.85rem;
    margin-right: 0.35rem;
  }
  td.nombre { text-align: left; }
}

/* ---------- Formulaires ---------- */

.champs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.champ { display: flex; flex-direction: column; gap: 0.3rem; }
.champ.large { grid-column: 1 / -1; }

label { font-size: 0.9rem; color: var(--encre-doux); }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea {
  font: inherit;
  color: var(--encre);
  background: #fff;
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  padding: 0.5rem 0.6rem;
  width: 100%;
  min-height: 2.5rem;
}

textarea { min-height: 5rem; resize: vertical; }

input:focus, select:focus, textarea:focus {
  border-color: var(--atelier);
  outline: 2px solid var(--atelier-clair);
  outline-offset: 0;
}

.aide { font-size: 0.85rem; color: var(--encre-doux); }
.erreur-champ { font-size: 0.85rem; color: var(--alerte); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-top: 1.25rem;
}

button, .bouton {
  font: inherit;
  font-weight: 500;
  border-radius: var(--rayon);
  border: 1px solid var(--encre);
  background: var(--encre);
  color: #fff;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  min-height: 2.5rem;
}

button:hover, .bouton:hover { background: #000; color: #fff; }

.bouton.secondaire, button.secondaire {
  background: #fff;
  color: var(--encre);
  border-color: var(--trait);
}
.bouton.secondaire:hover, button.secondaire:hover { background: #f2f5f2; color: var(--encre); }

.bouton.danger, button.danger {
  background: #fff;
  color: var(--alerte);
  border-color: #e2c3bd;
}
.bouton.danger:hover, button.danger:hover { background: var(--alerte); color: #fff; }

.bouton.compact, button.compact { padding: 0.25rem 0.6rem; min-height: 2rem; font-size: 0.9rem; }

/* ---------- Recherche et filtres ---------- */

.recherche {
  display: grid;
  grid-template-columns: minmax(200px, 2fr) repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 1.25rem;
}

.recherche .actions { margin-top: 0; }

/* ---------- Messages ---------- */

.message, .avertissement {
  border-radius: var(--rayon);
  padding: 0.7rem 0.9rem;
  margin-bottom: 1rem;
  border: 1px solid;
}

.message { background: var(--atelier-clair); border-color: #bcd8c8; color: #14523a; }
.avertissement { background: #fbeeeb; border-color: #eccec7; color: var(--alerte); }

.vide {
  background: var(--surface);
  border: 1px dashed var(--trait);
  border-radius: var(--rayon);
  padding: 2.5rem 1.25rem;
  text-align: center;
  color: var(--encre-doux);
}

/* ---------- Fiche ---------- */

.fiche-entete {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
}

dl.details { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1.25rem; }
dl.details dt { color: var(--encre-doux); }
dl.details dd { margin: 0; }

.compteur {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.compteur .valeur {
  font-size: 2rem;
  font-weight: 600;
  min-width: 2.5rem;
  text-align: center;
}

.qr-bloc { text-align: center; }
.qr-bloc img { width: 100%; max-width: 240px; height: auto; image-rendering: pixelated; }

.historique { list-style: none; margin: 0; padding: 0; }
.historique li {
  display: flex;
  gap: 0.75rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--trait);
  font-size: 0.92rem;
}
.historique li:last-child { border-bottom: 0; }
.historique .delta { font-family: var(--mono); min-width: 3rem; }
.historique .delta.positif { color: var(--atelier); }
.historique .delta.negatif { color: var(--alerte); }
.historique .quand { color: var(--encre-doux); margin-left: auto; white-space: nowrap; }

.pagination {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
  color: var(--encre-doux);
}

.liens-prix { list-style: none; padding: 0; margin: 0.5rem 0 0; display: flex; flex-wrap: wrap; gap: 0.75rem; }
.liens-prix a { font-size: 0.92rem; }

/* ---------- Connexion ---------- */

.connexion {
  max-width: 380px;
  margin: 12vh auto;
  padding: 0 1rem;
}


/* ---------- Étiquettes imprimables ----------
   Dimensions en millimètres : ce qui est à l'écran sort à l'identique sur le papier.
   Rouleau thermique 80 mm = 72 mm imprimables, 203 dpi = 8 points/mm.
   Le QR est demandé à 240 px et posé sur 30 mm : un point d'image = un point d'impression. */

.planche-thermique { display: block; }

.planche-thermique .etiquette {
  width: 72mm;
  margin: 0 0 4mm;
  border: 0;
  background: #fff;
  color: #000;
  display: flex;
  align-items: center;
  break-inside: avoid;
}

.planche-a4 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72mm, 1fr));
  gap: 4mm;
}

.planche-a4 .etiquette {
  border: 1px dashed #666;
  border-radius: 2px;
  padding: 3mm;
  background: #fff;
  color: #000;
  break-inside: avoid;
}

.etiquette-haut {
  display: flex;
  align-items: center;
  flex-grow: 1;
}

.etiquette img {
  width: 25mm;
  height: 25mm;
  flex: none;
  image-rendering: pixelated;
}

.planche-a4 .etiquette img { width: 24mm; height: 24mm; }

.etiquette { min-width: 0; }

.infos {
  min-width: 0;
  padding-right: 3px;
  flex-grow: 1;
}

.etiquette .nom {
  font-size: 4mm;
  line-height: 1.2;
  font-weight: 700;
}

.etiquette .meta {
  font-size: 3.2mm;
  line-height: 1.35;
  color: #000;
}

.etiquette .prix {
  font-size: 6mm;
  font-weight: 700;
  line-height: 1.2;
  margin-top: 1mm;
}

.etiquette {
  font-family: var(--mono);
  font-size: 5.5mm;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-top: 2mm;
  text-align: center;
}

.etiquette-qr {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ref {
  font-family: var(--mono);
  font-size: 3.5mm;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: center;
}

@media print {
  body { background: #fff; color: #000; }
  .bandeau, .sans-impression { display: none !important; }
  main { padding: 0; margin: 0; max-width: none; }
  /* Le thermique n'a pas de niveaux de gris : tout en noir franc, sans trait de coupe. */
  .planche-thermique .etiquette { border-bottom: 1px solid black; margin: 0; padding: 0;height: 50mm !important;max-height: 50mm !important; min-height: 50mm !important;}
  .etiquette, .etiquette * { color: #000; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Autocomplétion ---------- */

.champ-auto { position: relative; }

.suggestions {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  box-shadow: 0 6px 16px rgba(20, 24, 29, 0.12);
  max-height: 15rem;
  overflow-y: auto;
}

.suggestions li {
  padding: 0.4rem 0.6rem;
  cursor: pointer;
}

.suggestions li:hover,
.suggestions li.active {
  background: var(--atelier-clair);
  color: #14523a;
}

input[readonly] { background: #f4f6f4; color: var(--encre-doux); }
