:root {
  --fond: #f6f5f3;
  --carte: #ffffff;
  --texte: #1f1b18;
  --doux: #6b645e;
  --trait: #e3dfda;
  --brun: #3b2f2a;
  --bon: #157f3b;
  --bon-fond: #e9f6ee;
  --moyen: #a85d00;
  --moyen-fond: #fdf2e2;
  --mauvais: #b42318;
  --mauvais-fond: #fdecea;
  --r: 10px;
}
* { box-sizing: border-box; }
html { overflow-x: hidden; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; overflow-x: clip; background: var(--fond); color: var(--texte);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.3px; }
h2 { font-size: 18px; margin: 0; letter-spacing: -.2px; }
a { color: inherit; }
button { font: inherit; cursor: pointer; }

/* en-tête */
.entete { background: var(--carte); border-bottom: 1px solid var(--trait); position: sticky; top: 0; z-index: 5; }
.entete-in { display: flex; align-items: center; justify-content: space-between; height: 54px; gap: 12px; }
.marque { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; text-decoration: none; white-space: nowrap; }
.etat { font-size: 13px; color: var(--doux); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.etat[data-cle="hors"] { color: var(--moyen); }

.bloc { margin: 22px 0; }
.aide { color: var(--doux); margin: 0 0 12px; }
.titre-ligne { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.carte { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--r); }

/* champs */
.champs4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.champ { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.champ > span:first-child { font-size: 13px; color: var(--doux); }
.champ-large { margin-top: 12px; }
.saisie {
  width: 100%; height: 42px; padding: 0 11px; border: 1px solid var(--trait); border-radius: 8px;
  background: #fff; color: var(--texte); font: inherit; font-size: 16px; min-width: 0;
}
textarea.saisie { height: auto; min-height: 42px; padding: 10px 11px; resize: none; line-height: 1.35; overflow: hidden; }
.saisie:focus { outline: none; border-color: #9a918a; background: #fffdfb; }
.avec-unite { position: relative; display: block; }
.avec-unite .saisie { padding-right: 26px; text-align: right; }
.avec-unite i { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--doux); font-size: 14px; pointer-events: none; }
.calcule { height: 42px; display: flex; align-items: center; font-size: 17px; }

.btn {
  height: 40px; padding: 0 16px; border: 0; border-radius: 8px; background: var(--brun); color: #fff;
  font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center;
}
.btn:hover { background: #2a211d; }

/* calculette */
.calc { padding: 16px; }
.resultat { margin-top: 16px; }
.resultat .aide { margin: 0; }
.res-grille { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.res-case { background: var(--fond); border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; justify-content: center; min-height: 74px; }
.res-lib { font-size: 13px; color: var(--doux); }
.res-val { font-size: 24px; font-weight: 700; letter-spacing: -.4px; }
.conseil { margin: 12px 0 0; }
.calc-ajout { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--trait); display: grid; gap: 10px; }
.ligne-ajout { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.ligne-ajout .btn { height: 42px; }

.bon { color: var(--bon); }
.moyen { color: var(--moyen); }
.mauvais { color: var(--mauvais); }

/* lots */
.grille-lots { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.carte-lot { display: block; padding: 14px 16px; text-decoration: none; }
.carte-lot:hover { background: #fcfbfa; }
.cl-tete { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.cl-tete b { font-size: 16px; }
.cl-tete span { color: var(--doux); font-size: 13px; white-space: nowrap; }
.cl-chiffres { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cl-chiffres div { display: flex; flex-direction: column; }
.cl-chiffres span { font-size: 12px; color: var(--doux); }
.cl-chiffres b { font-size: 16px; }

/* page lot */
.retour { display: inline-block; margin-top: 16px; color: var(--doux); text-decoration: none; }
.retour:hover { color: var(--texte); }
.titre-saisie {
  width: 100%; font: inherit; font-size: 22px; font-weight: 700; letter-spacing: -.3px; border: 1px solid transparent;
  background: transparent; padding: 4px 6px; margin: 0 0 10px -7px; border-radius: 8px; color: var(--texte);
}
.titre-saisie:hover, .titre-saisie:focus { border-color: var(--trait); background: #fff; outline: none; }
.bloc > .carte { padding: 16px; }

.resume { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; }
.r-case { padding: 10px 12px; display: flex; flex-direction: column; min-height: 76px; justify-content: center; }
.r-case span { font-size: 12px; color: var(--doux); }
.r-case b { font-size: 18px; letter-spacing: -.3px; }
.r-case small { font-size: 12px; color: var(--doux); }

/* tableau des articles */
.ligne {
  display: grid; align-items: center; gap: 10px;
  grid-template-columns: 28px minmax(200px, 1fr) 108px 108px 108px 100px 100px 90px 118px 36px;
}
.entete-table { padding: 0 12px 6px; font-size: 12px; color: var(--doux); }
.entete-table span:nth-child(n+3):nth-child(-n+8) { text-align: right; }
.entete-table span:nth-child(9) { text-align: center; }
.article { padding: 8px 12px; margin-bottom: 6px; }
.cel { min-width: 0; }
.cel .lib { display: none; }
.c-n { color: var(--doux); font-size: 13px; text-align: center; }
.c-avec, .c-max, .c-marge { text-align: right; font-variant-numeric: tabular-nums; }
.c-max .v { font-weight: 600; }
.c-marge .v { font-weight: 600; }
.c-avis { display: flex; flex-direction: column; align-items: center; text-align: center; }
.avis { display: inline-flex; align-items: center; justify-content: center; min-width: 104px; height: 28px; padding: 0 10px; border-radius: 6px; font-size: 13px; font-weight: 600; }
.avis.bon { background: var(--bon-fond); }
.avis.moyen { background: var(--moyen-fond); }
.avis.mauvais { background: var(--mauvais-fond); }
.avis.vide { color: var(--doux); }
.nego { font-size: 11.5px; color: var(--doux); margin-top: 2px; }
.nego:empty { display: none; }
.icone { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: #9a918a; border-radius: 6px; }
.icone:hover { color: var(--mauvais); background: var(--mauvais-fond); }
.c-act { display: flex; justify-content: center; }

.bas-page { margin: 30px 0 40px; text-align: center; }
.lien-suppr { border: 0; background: none; color: var(--doux); text-decoration: underline; }
.lien-suppr:hover { color: var(--mauvais); }

@media (max-width: 1180px) {
  .resume { grid-template-columns: repeat(4, 1fr); }
  .ligne { grid-template-columns: 24px minmax(160px, 1fr) 96px 96px 96px 92px 92px 84px 112px 34px; gap: 8px; }
}

/* téléphone et tablette : une carte par article */
@media (max-width: 980px) {
  .champs4 { grid-template-columns: repeat(2, 1fr); }
  .grille-lots { grid-template-columns: 1fr; }
  .entete-table { display: none; }
  .ligne.article {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas: "desc desc desc" "dem paye vente" "avec max marge" "avis avis avis";
    gap: 10px; padding: 12px; position: relative; margin-bottom: 10px;
  }
  .cel .lib { display: block; font-size: 12px; color: var(--doux); margin-bottom: 3px; }
  .c-n { display: none; }
  .c-desc { grid-area: desc; padding-right: 36px; }
  .c-demande { grid-area: dem; } .c-paye { grid-area: paye; } .c-vente { grid-area: vente; }
  .c-avec { grid-area: avec; } .c-max { grid-area: max; } .c-marge { grid-area: marge; }
  .c-avec, .c-max, .c-marge { text-align: left; background: var(--fond); border-radius: 8px; padding: 7px 10px; min-height: 52px; }
  .c-avec .v, .c-max .v, .c-marge .v { font-size: 16px; }
  .c-avis { grid-area: avis; flex-direction: row; justify-content: space-between; gap: 10px; }
  .nego { margin: 0; font-size: 13px; }
  .c-act { position: absolute; top: 6px; right: 6px; }
}
@media (max-width: 620px) {
  h1 { font-size: 20px; }
  .res-grille { grid-template-columns: 1fr; gap: 8px; }
  .res-case { min-height: 0; flex-direction: row; justify-content: space-between; align-items: center; }
  .res-val { font-size: 20px; }
  .resume { grid-template-columns: repeat(2, 1fr); }
  .ligne-ajout { grid-template-columns: 1fr; }
  .cl-chiffres b { font-size: 15px; }
  .titre-ligne .btn { padding: 0 12px; }
}
