/*
  Trois formats :
  - ordinateur (1200 px et plus) : menu fixe à gauche, tableaux ;
  - tablette (de 700 à 1199 px) : barre en haut, menu coulissant ; listes en cartes sous 900 px ;
  - téléphone (moins de 700 px) : onglets en bas, une colonne.
*/

:root {
  --encre: #1b2330;
  --encre-douce: #586273;
  --fond: #f5f4f0;
  --carte: #ffffff;
  --creme: #faf9f5;
  --filet: #dfdcd3;
  --filet-fort: #c4c0b4;
  --menu: #18202c;
  --menu-survol: #232d3c;
  --menu-actif: #2a3648;
  --menu-texte: #c9cfd9;
  --or: #9a7327;
  --or-fonce: #7d5c1c;
  --or-clair: #f6efdf;
  --or-filet: #e6d5ac;
  --vert: #24694a;
  --vert-clair: #e5f2ea;
  --rouge: #a3322b;
  --rouge-clair: #fbeceb;
  --bleu: #2b4a7a;
  --bleu-clair: #e8eef7;
  --rayon: 10px;
  --rayon-champ: 7px;
  --touche: 2.5rem;
  --barre: 3.5rem;
  --police: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

/* Un élément masqué le reste, quelle que soit sa mise en page. */
[hidden] { display: none !important; }

html { font-size: 15px; -webkit-text-size-adjust: 100%; scroll-padding-top: 1rem; }

body {
  margin: 0;
  font-family: var(--police);
  color: var(--encre);
  background: var(--fond);
  line-height: 1.45;
  overflow-wrap: break-word;
}

a { color: var(--or-fonce); text-underline-offset: 2px; }
a:hover { color: var(--encre); }

h1 { font-size: 1.6rem; line-height: 1.2; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 0 0 0.9rem; font-weight: 650; }
p { margin: 0 0 0.7rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; word-break: break-all; }
img { max-width: 100%; }

.discret { color: var(--encre-douce); font-size: 0.9rem; }
.bloc { display: block; }
.nombre { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.invisible { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.icone { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

:focus-visible { outline: 2px solid var(--or); outline-offset: 2px; }
main:focus { outline: none; }

.evitement { position: absolute; left: 0.5rem; top: -4rem; z-index: 100; background: #fff; color: var(--encre); padding: 0.6rem 1rem; border-radius: var(--rayon-champ); }
.evitement:focus { top: 0.5rem; }

/* Structure */

.barre, .onglets, .voile, .menu-fermer { display: none; }

.cadre { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }

.menu {
  background: var(--menu);
  color: var(--menu-texte);
  padding: 1.3rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.menu-tete { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }

.marque { color: #fff; text-decoration: none; font-size: 1.25rem; font-weight: 700; line-height: 1.15; padding: 0 0.5rem; }
.marque span { display: block; font-size: 0.8rem; font-weight: 400; color: #d9b971; letter-spacing: 0.04em; }
.marque:hover { color: #fff; }

.choix-boutique { padding: 0 0.4rem; }
.choix-boutique label { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.3rem; color: #8f98a6; }
.choix-boutique select, .recherche-menu input {
  width: 100%;
  min-height: var(--touche);
  background: var(--menu-survol);
  color: #fff;
  border: 1px solid #36435a;
  border-radius: var(--rayon-champ);
  padding: 0.45rem 0.6rem;
  font: inherit;
}
.recherche-menu { position: relative; padding: 0 0.4rem; }
.recherche-menu .icone { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: #8f98a6; pointer-events: none; }
.recherche-menu input { padding-left: 2.3rem; }
.recherche-menu input::placeholder { color: #8f98a6; }

.menu nav { display: flex; flex-direction: column; gap: 2px; }
.menu nav a { display: flex; align-items: center; gap: 0.7rem; color: var(--menu-texte); text-decoration: none; padding: 0.55rem 0.75rem; border-radius: var(--rayon-champ); min-height: var(--touche); }
.menu nav a:hover { background: var(--menu-survol); color: #fff; }
.menu nav a[aria-current="page"] { background: var(--menu-actif); color: #fff; font-weight: 600; }
.menu nav a.bouton { margin-bottom: 0.7rem; justify-content: center; color: #fff; }

.compte { margin-top: auto; padding: 1rem 0.5rem 0; border-top: 1px solid var(--menu-actif); font-size: 0.88rem; }
.compte p { margin-bottom: 0.5rem; }
.compte strong { color: #fff; }
.compte a, .compte .lien { color: var(--menu-texte); display: block; padding: 0.3rem 0; }
.compte a:hover, .compte .lien:hover { color: #fff; }

main { padding: 2rem 2.2rem 4rem; max-width: 1400px; width: 100%; min-width: 0; }
main.seul { max-width: none; min-height: 100vh; display: grid; place-items: center; padding: 1rem; }

.entete { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.entete > div:first-child { min-width: 0; flex: 1 1 16rem; }
.entete p { margin: 0.25rem 0 0; }
.retour { display: inline-flex; align-items: center; gap: 0.2rem; font-size: 0.9rem; text-decoration: none; margin: 0 0 0.4rem -0.3rem; }
.retour .icone { width: 1.1rem; height: 1.1rem; }

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

/* Cartes */

.carte { background: var(--carte); border: 1px solid var(--filet); border-radius: var(--rayon); padding: 1.3rem 1.4rem; margin-bottom: 1.2rem; }
.carte.sans-marge { padding: 0; overflow: hidden; }
.carte .avec-marge { padding: 1.3rem 1.4rem 0; }
.carte.etroit { max-width: 560px; }
.carte.vide { text-align: center; color: var(--encre-douce); padding: 2.5rem 1rem; }
.carte.vide p { margin: 0; }
.carte.zone-sensible { border-color: #e5c4c1; }
.carte.a-faire { border-color: var(--or-filet); background: var(--or-clair); }
.bas-de-carte { padding-bottom: 1.3rem; margin: 0; }

.repliable > summary { list-style: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.8rem; cursor: pointer; }
.repliable > summary::-webkit-details-marker { display: none; }
.repliable > summary h2 { margin: 0; }
.repliable > summary .discret { flex: 1 1 12rem; min-width: 0; }
.repliable-action { color: var(--or-fonce); font-size: 0.88rem; font-weight: 550; text-decoration: underline; text-underline-offset: 2px; }
.repliable[open] > summary { margin-bottom: 0.9rem; }
.repliable[open] > summary .discret, .repliable[open] .repliable-action { display: none; }

.connexion { width: 100%; max-width: 380px; padding: 2rem; }
.connexion h1 { margin-bottom: 1.4rem; }
.connexion h1 span { display: block; font-size: 0.85rem; font-weight: 400; color: var(--or); letter-spacing: 0.04em; margin-top: 0.2rem; }
.connexion .champ { margin-bottom: 1rem; }

.liste-simple { list-style: none; margin: 0; padding: 0; }
.liste-simple li { padding: 0.4rem 0; display: flex; gap: 0.3rem 0.8rem; flex-wrap: wrap; align-items: baseline; }

/* Chiffres clés */

.chiffres { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.chiffre { background: var(--carte); border: 1px solid var(--filet); border-radius: var(--rayon); padding: 1.1rem 1.3rem; min-width: 0; }
.chiffre .valeur { font-size: 1.7rem; font-weight: 650; margin: 0; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; white-space: nowrap; }
.chiffre .valeur a { color: inherit; text-decoration: none; }
.chiffre .valeur a:hover { color: var(--or-fonce); }
.chiffre .legende { margin: 0.1rem 0 0; color: var(--encre-douce); font-size: 0.88rem; }

.raccourcis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.raccourci { display: flex; align-items: center; gap: 0.9rem; background: var(--carte); border: 1px solid var(--filet); border-radius: var(--rayon); padding: 1rem 1.2rem; text-decoration: none; color: var(--encre); min-width: 0; }
.raccourci:hover { border-color: var(--or); color: var(--encre); }
.raccourci .icone { width: 1.6rem; height: 1.6rem; color: var(--or); }
.raccourci strong { display: block; }
.raccourci span { color: var(--encre-douce); font-size: 0.86rem; }
.raccourci.principal { background: var(--or); border-color: var(--or); color: #fff; }
.raccourci.principal .icone, .raccourci.principal span { color: #fff; }
.raccourci.principal:hover { background: var(--or-fonce); }

/* Boutons */

.bouton, button.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--touche);
  font: inherit;
  font-weight: 550;
  padding: 0.5rem 1rem;
  border-radius: var(--rayon-champ);
  border: 1px solid var(--filet-fort);
  background: #fff;
  color: var(--encre);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.bouton:hover { border-color: var(--encre-douce); color: var(--encre); }
.bouton.principal { background: var(--or); border-color: var(--or); color: #fff; }
.bouton.principal:hover { background: var(--or-fonce); border-color: var(--or-fonce); color: #fff; }
.bouton.danger { background: var(--rouge); border-color: var(--rouge); color: #fff; }
.bouton.large { width: 100%; padding: 0.7rem; }
.bouton.petit { min-height: 2rem; padding: 0.25rem 0.7rem; font-size: 0.86rem; }
.bouton[disabled], .bouton[aria-disabled="true"] { opacity: 0.6; cursor: progress; }
.bouton[aria-pressed="true"] { background: var(--or-clair); border-color: var(--or); color: var(--or-fonce); }

.lien { background: none; border: 0; padding: 0; font: inherit; color: var(--or-fonce); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; text-align: left; }
.lien.danger { color: var(--rouge); font-size: 0.85rem; }

.actions { display: flex; gap: 0.7rem; justify-content: flex-end; align-items: center; flex-wrap: wrap; margin-top: 1rem; }
.entete .actions { margin-top: 0; }
/* Un bouton seul dans son formulaire s'aligne comme les autres. */
.actions > form { display: contents; }
.actions.entre { justify-content: space-between; }
.total { margin: 0; font-size: 1.05rem; }
.court { display: none; }

.actions.barre {
  position: sticky;
  bottom: 0;
  z-index: 20;
  background: var(--fond);
  border-top: 1px solid var(--filet);
  margin: 1.2rem -0.5rem 0;
  padding: 0.8rem 0.5rem;
}

/* Formulaires */

.grille { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.9rem 1rem; margin-bottom: 0.4rem; }
.grille[hidden] { display: none; }
.grille .double { grid-column: span 2; }
.grille .triple { grid-column: span 3; }
.grille .entier { grid-column: 1 / -1; }

.champ { min-width: 0; }
.champ label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem; }
.facultatif { font-weight: 400; color: var(--encre-douce); font-size: 0.78rem; white-space: nowrap; }

.champ input:not([type="file"]):not([type="checkbox"]), .champ select, .champ textarea {
  width: 100%;
  min-height: var(--touche);
  font: inherit;
  color: var(--encre);
  background: #fff;
  border: 1px solid var(--filet-fort);
  border-radius: var(--rayon-champ);
  padding: 0.45rem 0.6rem;
}
.champ textarea { resize: vertical; min-height: 3.2rem; line-height: 1.4; }
.champ input[type="file"] { font: inherit; font-size: 0.88rem; max-width: 100%; }
.champ input:focus, .champ select:focus, .champ textarea:focus { outline: 2px solid var(--or); outline-offset: 0; border-color: var(--or); }
.champ.manquant input:not([type="file"]):not([type="checkbox"]), .champ.manquant select, .champ.manquant textarea { border-color: var(--or); background: #fffdf7; box-shadow: inset 3px 0 0 var(--or); }
.champ.en-erreur input:not([type="file"]):not([type="checkbox"]), .champ.en-erreur select, .champ.en-erreur textarea { border-color: var(--rouge); background: #fffafa; box-shadow: inset 3px 0 0 var(--rouge); }
.champ.bas { align-self: end; }

.aide { color: var(--encre-douce); font-size: 0.83rem; margin: 0.3rem 0 0.7rem; }
.erreur { color: var(--rouge); font-size: 0.83rem; margin: 0.3rem 0 0; font-weight: 550; }

.case { font-size: 0.88rem; color: var(--encre-douce); display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer; min-height: 2rem; }
.case input { width: 1.1rem; height: 1.1rem; accent-color: var(--or); }

.filtres { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.8rem 1rem; align-items: end; padding: 1rem 1.2rem; }
.filtres-plus { grid-column: 1 / -1; }
.filtres-plus > summary { cursor: pointer; color: var(--or-fonce); font-size: 0.9rem; font-weight: 550; padding: 0.3rem 0; width: fit-content; }
.filtres-plus .grille { margin-top: 0.7rem; }
.filtres.simples { grid-template-columns: repeat(2, minmax(0, 11rem)) auto auto; justify-content: start; }
/* Le choix du dépôt ouvre la recherche : c'est lui qui dit ce qu'on regarde. */
.filtres.avec-depot { grid-template-columns: minmax(13rem, 19rem) minmax(0, 1fr) auto; }
.filtres.avec-depot select { font-weight: 600; }

.article-saisi { border: 1px solid var(--filet); border-radius: var(--rayon); padding: 1rem 1.1rem 0.8rem; margin: 0 0 1rem; position: relative; background: #fcfbf8; min-width: 0; }
.article-saisi legend { font-weight: 650; padding: 0 0.4rem; }
.article-saisi .retirer { position: absolute; top: -0.1rem; right: 1rem; font-size: 0.85rem; background: #fcfbf8; padding: 0 0.4rem; }

.avertissement { background: var(--or-clair); border: 1px solid var(--or-filet); border-radius: var(--rayon); padding: 0.9rem 1.1rem; margin-bottom: 1.2rem; }
.avertissement p { margin: 0; }
.avertissement ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }

.ajout-photos { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-start; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--filet); }
.ajout-photos .champ { flex: 1 1 200px; }
.ajout-photos .champ.bas { flex: 0 0 auto; align-self: flex-end; }

.zone-fichier {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  text-align: center;
  border: 2px dashed var(--filet-fort);
  border-radius: var(--rayon);
  background: var(--creme);
  padding: 2rem 1rem;
  cursor: pointer;
  margin-bottom: 1rem;
}
.zone-fichier:hover, .zone-fichier.survol, .zone-fichier:focus-within { border-color: var(--or); background: var(--or-clair); }
.zone-fichier .icone { width: 2.2rem; height: 2.2rem; color: var(--or); }
.zone-fichier strong { font-size: 1.05rem; }
.zone-fichier span { color: var(--encre-douce); font-size: 0.9rem; }
.zone-fichier input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.zone-fichier [data-fichier-nom] { color: var(--encre); font-weight: 600; margin-top: 0.4rem; }
.zone-fichier [data-fichier-nom]:empty { display: none; }

/* Pièces cochées : la barre de transfert */

th.choix, td.choix { width: 2.4rem; }
td.choix .case > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.selection {
  position: sticky;
  bottom: 0;
  z-index: 20;
  margin: 0 0 1.2rem;
  padding: 0.8rem 1rem;
  background: var(--carte);
  border: 1px solid var(--or);
  border-radius: var(--rayon);
  box-shadow: 0 -6px 24px rgba(27, 35, 48, 0.12);
}
.selection > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 1rem; cursor: pointer; }
.selection > summary::-webkit-details-marker { display: none; }
.selection[open] > summary { cursor: default; margin-bottom: 0.6rem; }
.selection[open] > summary .bouton { display: none; }
.selection-champs { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; align-items: flex-end; }
.selection-champs .champ { flex: 1 1 13rem; }
.selection-champs .champ label { font-size: 0.8rem; }
.selection-etiquettes { margin-top: 0.6rem; padding-top: 0.6rem; border-top: 1px solid var(--filet); }

/* Messages */

.messages { margin-bottom: 1.2rem; }
.message { padding: 0.75rem 1rem; border-radius: var(--rayon-champ); margin: 0 0 0.5rem; border: 1px solid #c6d4ea; background: var(--bleu-clair); }
.message.success { background: var(--vert-clair); border-color: #b9dcc7; color: #174a33; }
.message.error { background: var(--rouge-clair); border-color: #efc5c2; color: #7c2520; }

/* Tableaux */

.defilement { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th { text-align: left; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--encre-douce); font-weight: 600; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--filet-fort); white-space: nowrap; }
th.nombre { text-align: right; }
td { padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--filet); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
table.liste th:first-child, table.liste td:first-child { padding-left: 1.2rem; }
table.liste th:last-child, table.liste td:last-child { padding-right: 1.2rem; }
table.liste tbody tr:hover { background: var(--creme); }
table.liste thead { background: var(--creme); }
table.registre { font-size: 0.86rem; }
table.registre td.principal { width: 27%; }
tr.annule td { color: #8b919b; text-decoration: line-through; text-decoration-color: #b9bdc4; }
tr.annule td a { color: inherit; }
tr.annule td .etat { text-decoration: none; display: inline-block; }

/* En tableau, le nom de la pièce garde sa place et les valeurs courtes tiennent sur une ligne. */
@media (min-width: 900px) {
  table.liste:not(.registre) td.principal { min-width: 12rem; }
  table.liste td[data-label="Métal"], table.liste td[data-label="N° de série"], table.liste td[data-label^="Date"] { white-space: nowrap; }
  /* Un intitulé long passe sur deux lignes plutôt que d'élargir sa colonne. */
  table.liste th { white-space: normal; vertical-align: bottom; line-height: 1.25; }
  table.liste th, table.liste td { padding-left: 0.55rem; padding-right: 0.55rem; }
}

/* Entre tablette et grand écran, les colonnes de confort laissent la place à l'essentiel. */
@media (min-width: 900px) and (max-width: 1439px) {
  table.liste .confort { display: none; }
}

.piece { display: flex; gap: 0.7rem; align-items: flex-start; min-width: 0; }
.piece img, .piece .sans-photo { width: 44px; height: 44px; flex: none; object-fit: cover; border-radius: 6px; border: 1px solid var(--filet); background: var(--creme); }
.piece > div { min-width: 0; }

.etat { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 0.12rem 0.6rem; border-radius: 99px; white-space: nowrap; background: #ececec; color: #5d636d; }
.etat.en_stock, .etat.complete { background: var(--vert-clair); color: var(--vert); }
.etat.sorti { background: var(--bleu-clair); color: var(--bleu); }
.etat.annule { background: #ececec; color: #5d636d; }
.etat.ecart { background: var(--rouge-clair); color: var(--rouge); }
.etat.client, .etat.a-completer { background: var(--or-clair); color: var(--or-fonce); }
.etat.depot { background: var(--menu); color: #fff; }
.pied { border-top: 1px solid var(--filet); padding-top: 0.9rem; margin-top: 0.4rem; }

.pagination { display: flex; gap: 1.2rem; justify-content: center; align-items: center; margin: 1rem 0; color: var(--encre-douce); font-size: 0.9rem; }
.pagination a { display: inline-flex; align-items: center; min-height: var(--touche); padding: 0 0.8rem; border: 1px solid var(--filet-fort); border-radius: var(--rayon-champ); background: #fff; text-decoration: none; }

/* Fiches */

.fiche { margin: 0; }
.fiche > div { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 0.8rem; padding: 0.45rem 0; border-bottom: 1px solid var(--filet); }
.fiche > div:last-child { border-bottom: 0; }
.fiche dt { color: var(--encre-douce); font-size: 0.88rem; }
.fiche dd { margin: 0; overflow-wrap: anywhere; }
.fiche.compacte > div { grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; }
.fiche.compacte dd { text-align: right; }
.notes { margin: 1rem 0 0; padding-top: 0.8rem; border-top: 1px solid var(--filet); font-size: 0.92rem; }

.photos { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.9rem; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; border: 1px solid var(--filet); display: block; }
.photos p { margin: 0.3rem 0 0; }

/* Ventes relevées dans Sellsy */

.titre-de-section { display: flex; align-items: center; gap: 0.7rem; margin: 1.6rem 0 0.8rem; font-size: 1.15rem; }
.vente-tete { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem 1rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.vente-tete h3 { margin: 0 0 0.15rem; font-size: 1rem; }
.vente-tete p { margin: 0; }
.vente-ligne { display: grid; grid-template-columns: minmax(200px, 300px) minmax(0, 1fr); background: var(--carte); border: 1px solid var(--or-filet); border-radius: var(--rayon); margin-top: 0.7rem; overflow: hidden; }
.vente-ligne .origine { background: #fcfbf8; }
.vente-choix { padding: 0.9rem 1.1rem; min-width: 0; }
.vente-choix .actions { margin-top: 0.8rem; }
.vente-raison { font-size: 0.9rem; margin: 0 0 0.7rem; }
.etapes { margin: 0 0 0.8rem; padding-left: 1.2rem; }
.etapes li { margin-bottom: 0.5rem; }

/* Reprise du stock */

.erreurs-de-reprise { list-style: none; margin: 0 0 0.6rem; padding: 0; }
.erreurs-de-reprise > li { padding: 0.55rem 0; border-bottom: 1px solid var(--filet); }
.erreurs-de-reprise > li:last-child { border-bottom: 0; }
.erreurs-de-reprise ul { margin: 0.25rem 0 0; padding-left: 1.2rem; font-size: 0.92rem; }
.chiffre .valeur.alerte { color: var(--rouge); }

/* Valeur du stock et interrupteur */

.valeur-du-stock { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem 2rem; flex-wrap: wrap; }
.valeur-du-stock > div { flex: 1 1 20rem; min-width: 0; }
.valeur-du-stock h2 { margin-bottom: 0.3rem; }
.valeur-du-stock .aide { margin-bottom: 0; }
.valeur-totale { font-size: 1.9rem; font-weight: 650; margin: 0 0 0.2rem; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.interrupteur { display: inline-flex; align-items: center; gap: 0.6rem; min-height: var(--touche); color: var(--encre); text-decoration: none; font-weight: 550; -webkit-tap-highlight-color: transparent; }
.interrupteur:hover { color: var(--encre); }
.interrupteur-piste { flex: none; width: 2.7rem; height: 1.55rem; border-radius: 99px; background: var(--filet-fort); padding: 0.16rem; transition: background 0.15s ease; }
.interrupteur-piste span { display: block; width: 1.23rem; height: 1.23rem; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.15s ease; }
.interrupteur.actif .interrupteur-piste { background: var(--vert); }
.interrupteur.actif .interrupteur-piste span { transform: translateX(1.15rem); }

.chiffres.trois { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grille.deux { grid-template-columns: repeat(2, minmax(0, 1fr)); }
tr.epuise td { color: var(--encre-douce); }

/* Courriels aux clients */

.confirmation-case { margin: 0.9rem 0 0; padding-top: 0.9rem; border-top: 1px solid var(--filet); }
.confirmation-case .case { color: var(--encre); font-size: 0.95rem; font-weight: 550; }
.apercu { margin: 0.9rem 0; }
.apercu > summary { cursor: pointer; color: var(--or-fonce); font-size: 0.9rem; font-weight: 550; width: fit-content; padding: 0.3rem 0; }
.apercu pre, .apercu-objet { background: var(--creme); border: 1px solid var(--filet); margin: 0; padding: 0.8rem 1rem; font-family: inherit; font-size: 0.92rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.apercu-objet { border-bottom: 0; border-radius: var(--rayon-champ) var(--rayon-champ) 0 0; margin-top: 0.5rem; }
.apercu pre { border-radius: 0 0 var(--rayon-champ) var(--rayon-champ); line-height: 1.5; }

/* Catalogue des modèles */

.vitrine { list-style: none; margin: 0 0 1.2rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr)); gap: 0.9rem; }
.modele { display: flex; flex-direction: column; gap: 0.1rem; height: 100%; background: var(--carte); border: 1px solid var(--filet); border-radius: var(--rayon); padding: 0.55rem 0.55rem 0.8rem; text-decoration: none; color: var(--encre); overflow-wrap: anywhere; }
.modele:hover { border-color: var(--or); color: var(--encre); }
.modele img, .modele .sans-photo { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: var(--creme); margin-bottom: 0.45rem; }
.modele .sans-photo { display: grid; place-items: center; border: 1px dashed var(--filet-fort); color: var(--encre-douce); font-size: 0.82rem; }
.modele strong { line-height: 1.25; }
.modele .etat { align-self: flex-start; margin-top: 0.35rem; }
.photo-du-modele { display: block; width: 100%; max-width: 26rem; border-radius: 6px; border: 1px solid var(--filet); margin-bottom: 0.6rem; }

.modele-associe { display: flex; gap: 1rem; align-items: center; margin-bottom: 1.1rem; padding-bottom: 1.1rem; border-bottom: 1px solid var(--filet); }
.modele-associe img { display: block; width: 7.5rem; aspect-ratio: 1; object-fit: cover; border-radius: 6px; border: 1px solid var(--filet); }
.modele-associe > div { min-width: 0; }
.modele-associe p { margin: 0 0 0.3rem; }
h3 { font-size: 0.92rem; margin: 0 0 0.7rem; font-weight: 650; }

.ecritures { list-style: none; margin: 0; padding: 0; }
.ecritures li { padding: 0.8rem 0; border-bottom: 1px solid var(--filet); }
.ecritures li:first-child { padding-top: 0; }
.ecritures li:last-child { border-bottom: 0; padding-bottom: 0; }
.ecritures p { margin: 0 0 0.3rem; }
.ecritures .quand .discret { margin-left: 0.5rem; }
.ecritures .motif { font-style: italic; }
.modifications { font-size: 0.87rem; margin-top: 0.5rem; background: var(--creme); border-radius: 6px; }
.modifications td, .modifications th { padding: 0.35rem 0.7rem; }

.anomalies { margin: 0 0 1rem; padding-left: 1.2rem; }
.anomalies li { margin-bottom: 0.3rem; }
h2.alerte { color: var(--rouge); }
h2.conforme { color: var(--vert); }

/* Pré-saisie : une ligne repliable par pièce */

.lignes-outils { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; align-items: center; justify-content: space-between; margin: 0 0 0.8rem; }
.lignes-outils p { margin: 0; }
.lignes-outils .actions { margin: 0; }
.avancement { display: flex; align-items: center; gap: 0.7rem; flex: 1 1 16rem; min-width: 0; }
.jauge { flex: 1 1 auto; max-width: 14rem; height: 0.5rem; border-radius: 99px; background: var(--filet); overflow: hidden; }
.jauge span { display: block; height: 100%; background: var(--vert); border-radius: 99px; transition: width 0.2s ease; }

.ligne { background: var(--carte); border: 1px solid var(--filet); border-radius: var(--rayon); margin-bottom: 0.6rem; }
.ligne.en-erreur { border-color: var(--rouge); }
.ligne > summary {
  list-style: none;
  display: grid;
  grid-template-columns: 2.1rem minmax(0, 1fr) minmax(0, 11rem) 6.5rem 7.2rem 1.25rem;
  grid-template-areas: "rang resume qui prix etat fleche";
  gap: 0.2rem 0.9rem;
  align-items: center;
  padding: 0.65rem 1rem;
  cursor: pointer;
  border-radius: var(--rayon);
  -webkit-tap-highlight-color: transparent;
}
.ligne > summary::-webkit-details-marker { display: none; }
.ligne > summary:hover { background: var(--creme); }
.ligne[open] > summary { background: var(--creme); border-bottom: 1px solid var(--filet); border-radius: var(--rayon) var(--rayon) 0 0; }
.ligne-rang { grid-area: rang; width: 2.1rem; height: 2.1rem; border-radius: 50%; background: var(--fond); display: grid; place-items: center; font-size: 0.85rem; font-weight: 650; font-variant-numeric: tabular-nums; }
/* La photo du modèle reconnu, à gauche du nom ; à défaut, sa place reste marquée. */
.ligne-resume { grid-area: resume; min-width: 0; display: grid; grid-template-columns: 2.6rem minmax(0, 1fr); column-gap: 0.7rem; align-items: center; }
.ligne-resume strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne-resume span { display: block; color: var(--encre-douce); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne-resume img, .ligne-resume .sans-photo { grid-row: span 2; width: 2.6rem; height: 2.6rem; object-fit: cover; border-radius: 6px; border: 1px solid var(--filet); background: var(--creme); }
.ligne-qui { grid-area: qui; min-width: 0; font-size: 0.9rem; }
.ligne-qui span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne-qui span:empty { display: none; }
.ligne-qui .discret { font-size: 0.82rem; }
.ligne-prix { grid-area: prix; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.ligne > summary .etat { grid-area: etat; justify-self: start; }
.ligne-fleche { grid-area: fleche; color: var(--encre-douce); transition: transform 0.15s ease; }
.ligne[open] .ligne-fleche { transform: rotate(90deg); }

.ligne-reglages { display: flex; flex-wrap: wrap; gap: 0.6rem 1.2rem; align-items: center; padding: 0.6rem 1.1rem; border-top: 1px solid var(--filet); background: var(--creme); border-radius: 0 0 var(--rayon) var(--rayon); font-size: 0.9rem; }
.ligne-reglages .champ { display: flex; align-items: center; gap: 0.5rem; }
.ligne-reglages .champ label { margin: 0; font-weight: 400; color: var(--encre-douce); }
.ligne-reglages .champ select { width: auto; }
.ligne-reglages .fin { margin-left: auto; }

.ligne-corps { display: grid; grid-template-columns: minmax(200px, 270px) minmax(0, 1fr); }
.ligne-corps > .ligne-champs:only-child { grid-column: 1 / -1; }
.origine { padding: 0.9rem 1.1rem; border-right: 1px solid var(--filet); background: #fcfbf8; font-size: 0.87rem; }
.origine-titre { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--encre-douce); font-weight: 600; margin: 0 0 0.4rem; }
.origine pre { margin: 0 0 0.5rem; font-family: inherit; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; }
.origine-montant { font-weight: 650; margin: 0 0 0.5rem; font-variant-numeric: tabular-nums; }
.alertes { margin: 0; padding: 0; list-style: none; }
.alertes li { background: var(--or-clair); border: 1px solid var(--or-filet); border-radius: 6px; padding: 0.35rem 0.55rem; margin-top: 0.35rem; font-size: 0.84rem; }
.ligne-champs { padding: 0.9rem 1.1rem; min-width: 0; }
.ligne-champs details { margin-top: 0.6rem; }
.ligne-champs details > summary { cursor: pointer; font-size: 0.88rem; color: var(--or-fonce); margin-bottom: 0.5rem; padding: 0.3rem 0; width: fit-content; }

.grille.serree { gap: 0.6rem 0.8rem; }
.grille.serree .champ { display: flex; flex-direction: column; }
.grille.serree .champ label { font-size: 0.8rem; }
/* Les champs d'une même rangée restent alignés, même si un libellé passe à la ligne. */
.grille.serree .champ label + * { margin-top: auto; }

/* Ligne presque complète : on ne montre que ce qui manque, le reste se lit dans le résumé. */
.essentiel-note { font-size: 0.86rem; color: var(--encre-douce); margin: 0 0 0.7rem; }
.ligne.essentiel .ligne-champs .champ:not([data-essentiel]), .ligne.essentiel .ligne-champs details { display: none; }
.ligne.essentiel .grille.serree { grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); }
.ligne.essentiel .grille.serree .champ { grid-column: auto; }

/* Une ligne hors stock n'a rien à compléter : on ne montre que la facture. */
.ligne[data-nature="SERVICE"] .ligne-champs, .ligne[data-nature="EXCLUE"] .ligne-champs { display: none; }
.ligne[data-nature="SERVICE"] .ligne-corps, .ligne[data-nature="EXCLUE"] .ligne-corps { grid-template-columns: minmax(0, 1fr); }
.ligne[data-nature="SERVICE"] .origine, .ligne[data-nature="EXCLUE"] .origine { border-right: 0; }
.ligne[data-nature="SERVICE"] .alertes, .ligne[data-nature="EXCLUE"] .alertes { display: none; }
.ligne[data-nature="SERVICE"] > summary, .ligne[data-nature="EXCLUE"] > summary, .ligne.supprimee > summary { color: var(--encre-douce); }
.ligne[data-nature="SERVICE"] .ligne-rang, .ligne[data-nature="EXCLUE"] .ligne-rang { background: transparent; border: 1px dashed var(--filet-fort); }
.ligne.supprimee .ligne-resume strong { text-decoration: line-through; }
.ligne.supprimee .ligne-corps { display: none; }
.lignes.a-completer-seulement .ligne:not([data-etat="a-completer"]) { display: none; }

/* Tablette et téléphone : barre en haut, menu coulissant */

@media (max-width: 1199px) {
  html { font-size: 16px; scroll-padding-top: calc(var(--barre) + 1rem); }

  .barre {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: calc(var(--barre) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(0.5rem, env(safe-area-inset-right)) 0 max(0.5rem, env(safe-area-inset-left));
    background: var(--menu);
    color: #fff;
  }
  .barre-bouton {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
    justify-content: center;
    padding: 0 0.6rem;
    border: 0;
    border-radius: var(--rayon-champ);
    background: transparent;
    color: #fff;
    font: inherit;
    font-weight: 550;
    text-decoration: none;
    cursor: pointer;
  }
  .barre-bouton:hover { background: var(--menu-survol); color: #fff; }
  .barre-marque { flex: 1 1 auto; min-width: 0; color: #fff; font-weight: 650; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 0.3rem; }
  .barre-marque:hover { color: #fff; }

  .cadre { display: block; min-height: 0; }
  .menu {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: min(20rem, 88vw);
    height: 100%;
    padding-top: calc(1rem + env(safe-area-inset-top));
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    transform: translateX(-102%);
    visibility: hidden;
    transition: transform 0.22s ease, visibility 0s linear 0.22s;
  }
  body.menu-ouvert .menu { transform: none; visibility: visible; transition: transform 0.22s ease, visibility 0s; box-shadow: 0 0 40px rgba(0, 0, 0, 0.35); }
  .menu-fermer { display: inline-flex; align-items: center; justify-content: center; width: 2.75rem; height: 2.75rem; border: 0; border-radius: var(--rayon-champ); background: transparent; color: #fff; cursor: pointer; }
  .menu-fermer:hover { background: var(--menu-survol); }
  .voile { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(15, 20, 28, 0.5); opacity: 0; pointer-events: none; transition: opacity 0.2s ease; }
  body.menu-ouvert .voile { opacity: 1; pointer-events: auto; }
  body.menu-ouvert { overflow: hidden; }

  main { padding: 1.5rem 1.5rem 3rem; max-width: none; }
  .bouton { min-height: 2.75rem; }
  :root { --touche: 2.75rem; }
}

@media (max-width: 1099px) {
  .chiffres { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chiffres.trois { grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); }
  .ligne-corps { grid-template-columns: minmax(0, 1fr); }
  .origine { border-right: 0; border-bottom: 1px solid var(--filet); }
  .vente-ligne { grid-template-columns: minmax(0, 1fr); }
}

/* Sous 900 px, chaque rangée de tableau devient une carte. */

@media (max-width: 899px) {
  .colonnes, .colonnes.large-etroit { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .grille { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grille .triple { grid-column: 1 / -1; }

  .carte.sans-marge { background: transparent; border: 0; border-radius: 0; overflow: visible; }
  .carte.sans-marge .avec-marge { padding: 0 0 0.7rem; }
  .carte.sans-marge .bas-de-carte { padding-bottom: 0; }
  .carte.sans-marge .defilement { overflow: visible; }

  table.liste, table.liste tbody { display: block; }
  table.liste thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.liste tbody { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: 0.8rem; }
  table.liste tr {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem 1rem;
    align-content: start;
    background: var(--carte);
    border: 1px solid var(--filet);
    border-radius: var(--rayon);
    padding: 0.9rem 1rem;
  }
  table.liste tbody tr:hover { background: var(--carte); }
  table.liste td, table.liste th:first-child, table.liste td:first-child, table.liste td:last-child { display: block; padding: 0; border: 0; text-align: left; white-space: normal; min-width: 0; }
  table.liste td::before { content: attr(data-label); display: block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--encre-douce); font-weight: 600; }
  table.liste td:not([data-label])::before { content: none; }
  /* Le nom de la pièce ouvre la carte, quel que soit son rang dans le tableau. */
  table.liste td.principal { grid-column: 1 / -1; order: -1; font-weight: 600; font-size: 1.02rem; }
  table.liste tr:has(td.coin) td.principal { padding-right: 6rem; }
  table.liste td.principal .discret { font-weight: 400; }
  table.liste td.large { grid-column: 1 / -1; }
  table.liste td.coin { position: absolute; top: 0.85rem; right: 0.9rem; }
  table.liste td[data-vide] { display: none; }
  table.liste td.choix { position: absolute; right: 0.9rem; bottom: 0.7rem; width: auto; z-index: 2; }
  table.liste td.choix:empty { display: none; }
  /* Sur une carte, « Choisir » s'affiche ; le nom de la pièce reste réservé aux lecteurs d'écran. */
  td.choix .case > span { position: static; width: auto; height: auto; clip-path: none; }
  table.liste tr:has(td.choix input) { padding-bottom: 2.9rem; }
  table.liste tr:has(td.choix input:checked) { border-color: var(--or); box-shadow: inset 0 0 0 1px var(--or); }
  /* Toute la carte mène à la fiche. */
  table.liste td.principal a::after { content: ""; position: absolute; inset: 0; border-radius: var(--rayon); }
  table.liste td:not(.principal) a, table.liste td .bouton { position: relative; z-index: 1; }
  table.registre { min-width: 0; font-size: 0.92rem; }
  table.registre td.principal { width: auto; }

  .ligne > summary {
    grid-template-columns: 2.1rem minmax(0, 1fr) auto;
    grid-template-areas: "rang resume etat" "rang qui prix";
  }
  .ligne-fleche { display: none; }
  .ligne > summary .etat { justify-self: end; }
  .ligne-qui { color: var(--encre-douce); display: flex; gap: 0.4rem; flex-wrap: wrap; }
}

/* Téléphone */

@media (max-width: 699px) {
  /* Un champ en cours de saisie ne se cache pas derrière la barre du bas. */
  html { scroll-padding-bottom: 6.5rem; }
  main { padding: 1.1rem 1rem calc(5.5rem + env(safe-area-inset-bottom)); }
  h1 { font-size: 1.4rem; }
  .barre-bouton span { display: none; }
  .carte { padding: 1.1rem 1rem; }
  .entete { margin-bottom: 1.1rem; }
  .entete .actions { width: 100%; }
  .entete > .bouton { width: 100%; }

  .onglets {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    position: fixed;
    inset: auto 0 0 0;
    z-index: 30;
    background: #fff;
    border-top: 1px solid var(--filet);
    padding: 0.25rem max(0.25rem, env(safe-area-inset-right)) calc(0.25rem + env(safe-area-inset-bottom)) max(0.25rem, env(safe-area-inset-left));
  }
  .onglets a, .onglets button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-height: 3.1rem;
    border: 0;
    border-radius: var(--rayon-champ);
    background: none;
    color: var(--encre-douce);
    font: inherit;
    font-size: 0.7rem;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .onglets [aria-current="page"] { color: var(--or-fonce); font-weight: 650; }
  .onglets .icone { width: 1.4rem; height: 1.4rem; }

  /* Un formulaire long garde ses boutons sous le pouce, à la place des onglets. */
  body.avec-actions .onglets { display: none; }
  body.avec-actions main { padding-bottom: calc(6rem + env(safe-area-inset-bottom)); }
  .actions.barre {
    position: fixed;
    inset: auto 0 0 0;
    margin: 0;
    padding: 0.6rem max(1rem, env(safe-area-inset-right)) calc(0.6rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    background: #fff;
    flex-wrap: nowrap;
  }
  .actions.barre .bouton { flex: 1 1 0; min-width: 0; padding-left: 0.5rem; padding-right: 0.5rem; }
  .actions.barre .secondaire { display: none; }
  .long { display: none; }
  .court { display: inline; }

  .selection { position: fixed; inset: auto 0 0 0; margin: 0; border-radius: 0; border-width: 1px 0 0; padding-bottom: calc(0.8rem + env(safe-area-inset-bottom)); }
  .selection-champs .champ, .selection-champs .bouton { flex: 1 1 100%; }
  body.selection-active .onglets { display: none; }
  body.selection-active main { padding-bottom: 6rem; }
  .chiffres { gap: 0.7rem; }
  .chiffre { padding: 0.9rem 1rem; }
  .chiffre .valeur { font-size: 1.35rem; }
  .raccourcis { grid-template-columns: minmax(0, 1fr); gap: 0.6rem; }

  .grille .double { grid-column: 1 / -1; }
  .grille:not(.serree) { grid-template-columns: minmax(0, 1fr); }
  .filtres, .filtres.simples, .filtres.avec-depot { grid-template-columns: minmax(0, 1fr) auto; padding: 0.9rem 1rem; }
  .filtres.avec-depot > .champ:first-child { grid-column: 1 / -1; }
  .filtres.simples .champ { grid-column: span 1; }
  .fiche:not(.compacte) > div { grid-template-columns: 7.2rem minmax(0, 1fr); gap: 0.7rem; }
  .actions:not(.barre) .bouton { flex: 1 1 auto; }
  .photos { grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 0.6rem; }
  .lignes-outils .actions { width: 100%; flex-wrap: nowrap; }
  .lignes-outils .actions .bouton { flex: 1 1 0; min-width: 0; padding-left: 0.4rem; padding-right: 0.4rem; }
  .ligne > summary { padding: 0.65rem 0.8rem; gap: 0.15rem 0.7rem; }
  /* La photo prend de la place : le nom du modèle passe à la ligne plutôt que d'être coupé. */
  .ligne-resume { column-gap: 0.55rem; }
  .ligne-resume strong { white-space: normal; line-height: 1.25; }
  .ligne-champs, .origine, .ligne-reglages { padding-left: 0.9rem; padding-right: 0.9rem; }
  .ligne-reglages .fin { margin-left: 0; }
  .pagination { gap: 0.6rem; }
  th, td { padding-left: 0.5rem; padding-right: 0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}

@media print {
  .barre, .onglets, .menu, .voile, .filtres, .actions, .pagination, .ajout-photos, .messages, .evitement { display: none !important; }
  .cadre { display: block; }
  main { padding: 0; max-width: none; }
  .carte { border: 0; padding: 0; }
  body { background: #fff; }
}
