/* Prix marchés — lisible en plein soleil, une main, réseau faible.
   Couleur : bissap (hibiscus) pour l'action ; vert feuille = fait ; ambre = à vérifier. */
@font-face { font-family: 'Atkinson'; src: url('/fonts/atkinson-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Atkinson'; src: url('/fonts/atkinson-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Bricolage'; src: url('/fonts/bricolage.woff2') format('woff2'); font-weight: 200 800; font-display: swap; }

:root {
  --bissap: #7a1438;
  --bissap-fonce: #5c0e2a;
  --feuille: #1d6b45;
  --feuille-clair: #e3f1e9;
  --ambre: #8a4b00;
  --ambre-clair: #fcefd9;
  --rouge: #a3231a;
  --encre: #1c1b1d;
  --encre-douce: #5b5a5f;
  --fond: #f5f6f4;
  --papier: #ffffff;
  --trait: #d9dad6;
  --corps: 'Atkinson', system-ui, sans-serif;
  --titre: 'Bricolage', 'Atkinson', system-ui, sans-serif;
  --haut-barre: 56px;
  --bas-barre: 60px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--encre);
  font: 400 1.0625rem/1.45 var(--corps);
  padding-bottom: calc(var(--bas-barre) + env(safe-area-inset-bottom));
}
body.fige { overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--bissap); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---- barre du haut */
.haut {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: .75rem;
  min-height: var(--haut-barre); padding: .5rem 1rem; padding-top: calc(.5rem + env(safe-area-inset-top));
  background: var(--bissap); color: #fff;
}
.haut h1 { flex: 1; margin: 0; font: 700 1.25rem/1.2 var(--titre); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.retour { font-size: 2rem; line-height: 1; text-decoration: none; padding: 0 .5rem .2rem 0; min-width: 44px; min-height: 44px; display: grid; place-items: center; }
.pastille { font-size: .875rem; font-weight: 700; padding: .25rem .7rem; border-radius: 999px; text-decoration: none; background: rgba(255,255,255,.16); white-space: nowrap; }
.quitter { font: inherit; font-size: .875rem; font-weight: 700; color: #fff; background: transparent; border: 1px solid rgba(255,255,255,.5); border-radius: 999px; padding: .25rem .7rem; min-height: 32px; cursor: pointer; }
.pastille.hors { background: var(--ambre-clair); color: var(--ambre); }
.pastille.attente { background: #fff; color: var(--bissap); }

/* ---- navigation du bas */
.bas {
  position: fixed; inset: auto 0 0 0; z-index: 5; display: flex; background: var(--papier); border-top: 1px solid var(--trait);
  padding-bottom: env(safe-area-inset-bottom);
}
.bas a { flex: 1; min-height: var(--bas-barre); display: grid; place-items: center; text-decoration: none; font-weight: 700; color: var(--encre-douce); font-size: .9375rem; }
.bas a[aria-current="page"] { color: var(--bissap); box-shadow: inset 0 3px 0 var(--bissap); }

main { padding: 1rem; max-width: 40rem; margin: 0 auto; }
.maj { text-align: center; color: var(--encre-douce); font-size: .8125rem; margin: .5rem 1rem 1rem; }
.sous-titre { margin: 0 0 .75rem; color: var(--encre-douce); }

/* ---- listes */
.liste { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.commande {
  display: grid; grid-template-columns: 1fr auto; gap: .1rem .75rem; padding: .9rem 1rem; min-height: 64px;
  background: var(--papier); border: 1px solid var(--trait); border-radius: 10px; text-decoration: none;
}
.commande .client { font: 700 1.125rem/1.25 var(--titre); }
.commande .ref { color: var(--encre-douce); font-size: .9375rem; grid-row: 2; }
.commande .avance { grid-row: 1 / 3; grid-column: 2; align-self: center; font-weight: 700; color: var(--ambre); }
.commande .avance.fini { color: var(--feuille); }

.ligne { background: var(--papier); border: 1px solid var(--trait); border-left: 6px solid var(--trait); border-radius: 10px; overflow: hidden; }
.ligne.partiel { border-left-color: #d98a1f; }
.ligne.complet { border-left-color: var(--feuille); }
.ligne-bouton {
  display: grid; width: 100%; gap: .1rem; text-align: left; background: none; border: 0; padding: .85rem 1rem; min-height: 64px; cursor: pointer;
}
.ligne .nom { font-weight: 700; }
.ligne .quantite { font: 600 1.0625rem/1.3 var(--titre); }
.ligne.complet .quantite { color: var(--feuille); }
.ligne .indice, .indice { color: var(--encre-douce); font-size: .9375rem; }
.achats { list-style: none; margin: 0; padding: 0 1rem .75rem; display: grid; gap: .25rem; font-size: .9375rem; color: var(--encre-douce); }
.achats li { display: grid; grid-template-columns: 1fr auto; gap: 0 .5rem; border-top: 1px dashed var(--trait); padding-top: .25rem; }
.achats .marque { grid-column: 2; grid-row: 1 / 3; align-self: center; font-weight: 700; font-size: .8125rem; }
.achats .s2 .marque { color: var(--feuille); }
.achats .s-1 .marque { color: var(--ambre); }
.achats .s3 { text-decoration: line-through; }

.vide { text-align: center; padding: 3rem 1rem; color: var(--encre-douce); }
.vide p { margin: .25rem 0; } .vide strong { color: var(--encre); font-family: var(--titre); font-size: 1.25rem; }

/* ---- boutons et champs */
.primaire, .secondaire {
  min-height: 52px; padding: 0 1.25rem; border-radius: 10px; font-weight: 700; cursor: pointer; border: 2px solid var(--bissap);
}
.primaire { background: var(--bissap); color: #fff; width: 100%; margin-top: 1rem; }
.primaire:active { background: var(--bissap-fonce); }
.secondaire { background: var(--papier); color: var(--bissap); }
.secondaire:disabled { opacity: .5; }
.lien { background: none; border: 0; color: var(--bissap); text-decoration: underline; font-weight: 400; padding: .5rem; min-height: 44px; cursor: pointer; }
.lien.fort { font-weight: 700; }
.erreur { color: var(--rouge); font-weight: 700; margin: .5rem 0; }
.alerte { background: var(--ambre-clair); color: var(--ambre); border-left: 5px solid #d98a1f; padding: .6rem .8rem; border-radius: 6px; font-weight: 700; margin: .75rem 0 0; }

input[type=text], input[type=password], input[type=search], input:not([type]), textarea {
  width: 100%; min-height: 52px; padding: .5rem .75rem; border: 2px solid var(--trait); border-radius: 10px; background: #fff; font-size: 1.125rem;
}
input:focus, textarea:focus { border-color: var(--bissap); outline: none; }

/* ---- connexion */
.connexion { padding-top: 18vh; }
.connexion h1 { margin: 0; font: 800 2.5rem/1 var(--titre); color: var(--bissap); }
.connexion .sous { margin: .25rem 0 2rem; color: var(--encre-douce); }
.connexion label { display: grid; gap: .25rem; font-weight: 700; margin-bottom: 1rem; }

/* ---- feuille de saisie */
.calque { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; }
.calque.haut2 { z-index: 30; }
.voile { position: absolute; inset: 0; background: rgba(28,27,29,.5); }
.feuille {
  position: relative; width: 100%; max-width: 40rem; margin: 0 auto; max-height: 94dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--fond); border-radius: 18px 18px 0 0; padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
}
.feuille header { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.feuille h2 { margin: 0; font: 700 1.25rem/1.2 var(--titre); }
.feuille header p { margin: .15rem 0 0; color: var(--encre-douce); font-size: .9375rem; }
.fermer { flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--papier); font-size: 1.5rem; cursor: pointer; }
fieldset { border: 0; padding: 0; margin: 0 0 .9rem; }
legend, .etiquette { font-weight: 700; font-size: .9375rem; color: var(--encre-douce); padding: 0; margin-bottom: .25rem; display: block; }

.choix { display: flex; flex-wrap: wrap; gap: .5rem; }
.choix label { flex: 1 1 0; min-width: 6.5rem; }
.choix input { position: absolute; opacity: 0; pointer-events: none; }
.choix span {
  display: grid; place-items: center; min-height: 52px; padding: 0 .75rem; text-align: center; font-weight: 700;
  background: var(--papier); border: 2px solid var(--trait); border-radius: 10px; cursor: pointer;
}
.choix input:checked + span { background: var(--bissap); border-color: var(--bissap); color: #fff; }
.choix input:focus-visible + span { outline: 3px solid var(--bissap); outline-offset: 2px; }

.champ { margin-bottom: .9rem; }
.selecteur {
  width: 100%; min-height: 52px; text-align: left; padding: 0 .9rem; background: var(--papier); border: 2px solid var(--trait);
  border-radius: 10px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
}
.selecteur::after { content: '›'; font-size: 1.5rem; color: var(--encre-douce); }

.grille { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.grille label { display: grid; gap: .25rem; font-weight: 700; font-size: .9375rem; color: var(--encre-douce); position: relative; }
.grille label.large { grid-column: 1 / -1; }
.grille input { padding-right: 3.2rem; font: 700 1.375rem/1 var(--titre); color: var(--encre); }
.grille small { position: absolute; right: .75rem; bottom: 1rem; font-weight: 400; color: var(--encre-douce); }

/* L'élément marquant : le prix au kg se calcule pendant la saisie et reste visible en haut de la feuille. */
.lecture {
  position: sticky; top: 0; z-index: 2; display: grid; margin: 0 0 1rem; padding: .5rem 1rem .75rem;
  background: var(--papier); border: 2px solid var(--bissap); border-radius: 12px; box-shadow: 0 8px 10px -6px rgba(28,27,29,.25);
}
.lecture .chiffre { font: 800 3rem/1.05 var(--titre); color: var(--bissap); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.lecture .detail { color: var(--encre-douce); font-size: .9375rem; }
.lecture.vide { border-color: var(--trait); }
.lecture.a-verifier { border-color: #d98a1f; }
.lecture .alerte { margin: .5rem 0 0; }
.lecture.vide .chiffre { color: var(--trait); }

details { margin-top: .75rem; }

/* Le bouton d'enregistrement reste visible pendant que l'on défile la feuille. */
.feuille > .primaire {
  position: sticky; bottom: calc(-1rem - env(safe-area-inset-bottom)); margin-bottom: calc(-1rem - env(safe-area-inset-bottom));
  box-shadow: 0 -14px 12px -4px var(--fond); outline-offset: 3px;
}
summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 700; color: var(--bissap); }

.choix-liste { list-style: none; margin: .75rem 0; padding: 0; display: grid; gap: .4rem; }
.choix-liste button { width: 100%; min-height: 52px; text-align: left; padding: 0 1rem; background: var(--papier); border: 2px solid var(--trait); border-radius: 10px; font-weight: 700; cursor: pointer; }

/* ---- À envoyer et validation */
.envoi li, .valid li { background: var(--papier); border: 1px solid var(--trait); border-left: 6px solid #d98a1f; border-radius: 10px; padding: .75rem 1rem; display: grid; gap: .2rem; }
.envoi li div:first-child, 
.valid li div:first-child { display: flex; justify-content: space-between; gap: .5rem; }
.envoi .s-refuse { border-left-color: var(--rouge); }
.actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .4rem; }
.actions .primaire { width: auto; margin: 0; }

/* ---- messages */
.toast {
  position: fixed; left: 1rem; right: 1rem; bottom: calc(var(--bas-barre) + 1rem + env(safe-area-inset-bottom)); z-index: 40;
  max-width: 36rem; margin: 0 auto; padding: .8rem 1rem; border-radius: 10px; background: var(--encre); color: #fff; font-weight: 700;
}
.toast.ok { background: var(--feuille); }
.toast.erreur { background: var(--rouge); }

@media (prefers-reduced-motion: no-preference) {
  .feuille { animation: monter .18s ease-out; }
  @keyframes monter { from { transform: translateY(24px); opacity: .6; } }
}
@media (min-width: 640px) {
  .calque { align-items: center; }
  .feuille { border-radius: 18px; }
}

.valid .resultat { font-size: 1.0625rem; }
.valid .resultat strong { font-family: var(--titre); color: var(--bissap); }
