/* Même univers que la page d'accueil : papier kraft, encre, tampon rouge. Les couleurs d'état
   (vert prêt, ambre à vérifier, rouge bloquant) restent franches pour rester lisibles. */
@font-face { font-family: 'Young Serif'; src: url('../assets/polices/young-serif-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Karla'; src: url('../assets/polices/karla-variable.woff2') format('woff2'); font-weight: 300 800; font-display: swap; }
:root {
  --fond: #EFE5D3; --carte: #FBF8F1; --encre: #26211B; --encre-2: #4A4238; --gris: #75695A; --gris-2: #A39785;
  --trait: #DDCDB2; --trait-2: #E9DECB; --tampon: #B43A23;
  --titre: 'Young Serif', Georgia, serif;
  --vert: #2F6B4F; --vert-clair: #E4EFE8; --vert-fonce: #224F3A;
  --ambre: #A86B12; --ambre-clair: #FBF0DC; --rouge: #B23A2E; --rouge-clair: #F8E4E1;
  --rayon: 3px; --ombre: 0 1px 2px rgba(31,42,36,.06), 0 4px 14px rgba(31,42,36,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Karla', 'Trebuchet MS', sans-serif; background: var(--fond) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .12 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E"); color: var(--encre); font-size: 15px; line-height: 1.45; }
a { color: var(--tampon); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-family: var(--titre); font-size: 30px; font-weight: 400; }
h2 { font-family: var(--titre); font-size: 19px; font-weight: 400; }
h3 { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--gris); }
[hidden] { display: none !important; }

/* barre du haut */
.barre { display: flex; align-items: center; gap: 28px; padding: 0 24px; height: 60px; background: var(--encre); color: #fff; position: sticky; top: 0; z-index: 20; }
.marque { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-family: var(--titre); font-size: 19px; }
.marque svg { width: 30px; height: 30px; flex: none; }
.onglets { display: flex; gap: 4px; overflow-x: auto; }
.onglets a { color: #D8CDBB; text-decoration: none; padding: 8px 14px; border-radius: 4px; white-space: nowrap; font-weight: 500; }
.onglets a:hover { color: #fff; background: rgba(255,255,255,.08); }
.onglets a.actif { color: #fff; background: rgba(255,255,255,.14); }
.avis { margin-left: auto; color: #fff; text-decoration: none; font-weight: 600; font-size: 14px; border: 1px dashed rgba(255,255,255,.5); padding: 7px 14px; white-space: nowrap; }
.avis:hover { background: rgba(255,255,255,.1); }
.installer { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; background: #CDB089; color: var(--encre); border: 0; font: inherit; font-weight: 700; font-size: 14px; padding: 7px 14px; cursor: pointer; white-space: nowrap; }
.installer svg { width: 17px; height: 17px; }
.installer:hover { background: #E9DCC3; }
.installer:not([hidden]) + .avis { margin-left: 10px; }
.etapes-install { margin: 4px 0 10px; padding-left: 22px; line-height: 1.7; }
.pied-outil { text-align: center; color: var(--gris-2); font-size: 12.5px; padding: 0 20px 28px; }
.pied-outil a { color: var(--gris); }

main { max-width: 1240px; margin: 0 auto; padding: 28px 24px 80px; }
.entete { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.entete p { margin: 6px 0 0; color: var(--gris); }

/* boutons */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1.5px solid var(--encre); background: var(--carte); padding: 9px 16px; border-radius: 2px; cursor: pointer; font-weight: 600; text-decoration: none; color: var(--encre); }
.btn:hover { border-color: var(--gris-2); }
.btn-plein { background: var(--encre); border-color: var(--encre); color: #fff; box-shadow: 3px 3px 0 var(--tampon); transition: transform .12s, box-shadow .12s; }
.btn-plein:hover { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--tampon); }
.btn-grand { padding: 12px 22px; font-size: 16px; }
.btn-petit { padding: 5px 10px; font-size: 13px; }
.btn-lien { border: none; background: none; color: var(--tampon); padding: 4px 6px; cursor: pointer; font-weight: 600; }
.btn-danger { color: var(--rouge); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* cartes et formulaires */
.carte { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 20px; box-shadow: var(--ombre); }
.carte + .carte { margin-top: 16px; }
.carte h2 { margin-bottom: 4px; }
.aide { color: var(--gris); font-size: 13.5px; margin: 2px 0 12px; }
label.champ { display: block; margin-bottom: 12px; }
label.champ > span { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 5px; }
input[type=text], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--trait); border-radius: 8px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(180,58,35,.18); border-color: var(--tampon); }
textarea { resize: vertical; min-height: 60px; }
.grand-champ { font-size: 20px; font-weight: 700; padding: 11px 13px; }
.ligne-champs { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.choix { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.choix label { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--trait); padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 14px; background: #fff; }
.choix input { accent-color: var(--encre); }
.coche { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; margin: 6px 0; }
.coche input { margin-top: 3px; accent-color: var(--encre); }

/* pastilles allergènes */
.pastilles { display: flex; flex-wrap: wrap; gap: 5px; }
.pastille { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--rouge-clair); color: var(--rouge); white-space: nowrap; }
.pastille-neutre { background: var(--trait-2); color: var(--gris); }
.pastille-ok { background: var(--vert-clair); color: var(--vert); }
.pastille-attention { background: var(--ambre-clair); color: var(--ambre); }
.bascules { display: flex; flex-wrap: wrap; gap: 6px; }
.bascule { border: 1px solid var(--trait); background: #fff; border-radius: 999px; padding: 5px 11px; font-size: 13px; cursor: pointer; }
.bascule.on { background: var(--rouge-clair); border-color: #E9B8B1; color: var(--rouge); font-weight: 600; }
.bascule.trace.on { background: var(--ambre-clair); border-color: #EBCB93; color: var(--ambre); }

/* liste des produits */
.liste-produits { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.produit { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 16px; box-shadow: var(--ombre); display: flex; flex-direction: column; gap: 10px; }
.produit-nom { font-weight: 700; font-size: 16.5px; }
.produit-meta { color: var(--gris); font-size: 13px; }
.produit-actions { display: flex; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.recherche { max-width: 360px; }
.vide { text-align: center; padding: 56px 20px; }
.vide p { color: var(--gris); max-width: 520px; margin: 10px auto 22px; }
.vide .btn + .btn { margin-left: 8px; }

/* éditeur de produit */
.editeur { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 22px; align-items: start; }
.apercu { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 14px; }
.retour { display: inline-block; margin-bottom: 10px; text-decoration: none; font-weight: 600; }
.ingr-table { width: 100%; border-collapse: collapse; }
.ingr-table th { text-align: left; font-size: 12px; color: var(--gris); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 0 8px 8px; }
.ingr-table td { padding: 10px 8px; border-top: 1px solid var(--trait-2); vertical-align: top; }
.ingr-table tr.a-verifier td { background: #FFFBF3; }
.ingr-nom { font-weight: 600; }
.ingr-source { font-size: 12px; color: var(--gris-2); margin-top: 2px; }
.ingr-etiq { margin-top: 6px; font-size: 13px; }
.ingr-etiq input { padding: 5px 8px; font-size: 13px; }
.ingr-qte { width: 128px; white-space: nowrap; }
.ingr-qte input { width: 86px; }
.ingr-qte input { text-align: right; }
.unite { color: var(--gris); font-size: 13px; }
.total { text-align: right; color: var(--gris); font-size: 13.5px; padding-top: 8px; }
.ajout-ingredient { position: relative; margin-top: 12px; }
.resultats { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--trait); border-radius: 10px; box-shadow: 0 10px 30px rgba(31,42,36,.15); max-height: 340px; overflow-y: auto; z-index: 10; }
.resultat { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--trait-2); display: flex; justify-content: space-between; gap: 10px; }
.resultat:last-child { border-bottom: none; }
.resultat:hover, .resultat.actif { background: var(--vert-clair); }
.resultat small { color: var(--gris); }
.tag { font-size: 11px; font-weight: 700; color: var(--vert); background: var(--vert-clair); padding: 1px 7px; border-radius: 999px; white-space: nowrap; align-self: center; }

.alerte { border-radius: 8px; padding: 10px 12px; font-size: 13.5px; }
.alerte-ambre { background: var(--ambre-clair); color: #6E4708; }
.alerte-rouge { background: var(--rouge-clair); color: #7B241B; }
.alerte-vert { background: var(--vert-clair); color: var(--vert-fonce); }
.alerte strong { font-weight: 700; }

/* déclaration nutritionnelle (aperçu écran) */
.nutri { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.nutri th { text-align: left; font-size: 12px; padding: 4px 0; border-bottom: 2px solid var(--encre); }
.nutri th:last-child, .nutri td:last-child { text-align: right; }
.nutri td { padding: 4px 0; border-bottom: 1px solid var(--trait-2); }
.nutri td.sous { padding-left: 14px; color: var(--encre-2); }

/* étiquette (écran et impression) : Arial, dont la hauteur d'x est connue (0,519 em) */
.etiquette { font-family: Arial, Helvetica, sans-serif; color: #000; background: #fff; overflow: hidden; line-height: 1.18; padding: 2.2mm 2.6mm; box-sizing: border-box; }
.etiquette .e-nom { font-weight: 700; font-size: 1.45em; line-height: 1.1; margin-bottom: .35em; }
.etiquette p { margin: 0 0 .32em; }
.etiquette .e-nut { width: 100%; border-collapse: collapse; margin: .15em 0 .35em; }
.etiquette .e-nut th, .etiquette .e-nut td { border-bottom: .2mm solid #000; padding: .05em 0; font-weight: 400; text-align: left; }
.etiquette .e-nut th { font-weight: 700; }
.etiquette .e-nut td:last-child, .etiquette .e-nut th:last-child { text-align: right; }
.etiquette .e-nut .sous { padding-left: .8em; }
.etiquette .e-bas { display: flex; justify-content: space-between; gap: .6em; flex-wrap: wrap; font-weight: 700; }
.etiquette .e-ent { font-size: .92em; }
.cadre-apercu { background: repeating-conic-gradient(#EFEBE3 0 25%, #F8F6F1 0 50%) 50% / 14px 14px; border-radius: 10px; padding: 18px; display: grid; place-items: center; overflow: auto; }
.cadre-apercu .etiquette { box-shadow: 0 2px 10px rgba(0,0,0,.18); }

/* fenêtre (impression, allergènes) */
.fenetre { position: fixed; inset: 0; background: rgba(20,28,24,.45); z-index: 40; display: grid; place-items: center; padding: 20px; }
.fenetre-boite { background: #fff; border-radius: 14px; width: min(860px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.fenetre-boite.etroite { width: min(520px, 100%); }
.fenetre-entete { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.fermer { border: none; background: none; font-size: 24px; cursor: pointer; color: var(--gris); line-height: 1; }
.impr-grille { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* affiche allergènes (écran) */
.affiche-table { width: 100%; border-collapse: collapse; font-size: 13.5px; background: #fff; }
.affiche-table th { font-size: 11.5px; padding: 8px 4px; border-bottom: 2px solid var(--encre); vertical-align: bottom; }
.affiche-table th.vertical { writing-mode: vertical-rl; transform: rotate(180deg); height: 130px; text-align: left; font-weight: 600; }
.affiche-table td { padding: 7px 4px; border-bottom: 1px solid var(--trait); text-align: center; }
.affiche-table td:first-child { text-align: left; font-weight: 600; }
.point { display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: var(--rouge); }
.point-trace { background: #fff; border: 2.5px solid var(--ambre); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--encre); color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0; transition: .2s; pointer-events: none; z-index: 60; }
.toast.on { opacity: 1; transform: translateX(-50%); }
/* Coordonnées de l'entreprise remplies directement à côté de l'aperçu */
.ent-express input { display: block; width: 100%; margin-top: 8px; }
.ent-express .btn { margin-top: 10px; }
/* Sur téléphone, l'aperçu passe sous la recette : un bouton pour y descendre */
.vers-apercu { display: none; }
@media (max-width: 980px) {
  .vers-apercu { display: block; position: fixed; right: 16px; bottom: 16px; z-index: 50; background: var(--encre); color: #fff; border: 0; border-radius: 8px; padding: 12px 16px; font: inherit; font-weight: 700; box-shadow: 3px 3px 0 var(--tampon); cursor: pointer; }
  .vers-apercu.cache { display: none; }
}
.bandeau { padding: 10px 24px; font-size: 14px; text-align: center; }
.bandeau-rouge { background: var(--rouge-clair); color: #7B241B; }
.bandeau-ambre { background: var(--ambre-clair); color: #6E4708; }

#zone-impression { display: none; }

@media (max-width: 980px) {
  .editeur { grid-template-columns: 1fr; }
  .apercu { position: static; }
  .impr-grille { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .barre { gap: 12px; padding: 0 12px; }
  .marque span:last-child { display: none; }
  .avis { padding: 6px 10px; font-size: 13px; }
  .installer { padding: 6px 9px; font-size: 13px; } .installer span { display: none; }
  main { padding: 18px 14px 60px; }
  .ingr-table thead { display: none; }
  .ingr-table tr { display: grid; grid-template-columns: 1fr auto; }
  .ingr-table td { border-top: none; }
  .ingr-table tr { border-top: 1px solid var(--trait-2); }
}

/* impression : seule la zone d'impression sort */
@media print {
  body { background: #fff; }
  body > *:not(#zone-impression):not(style) { display: none !important; }
  #zone-impression { display: block !important; }
  .feuille { position: relative; overflow: hidden; page-break-after: always; break-after: page; }
  .feuille:last-child { page-break-after: auto; break-after: auto; }
  .case { position: absolute; overflow: hidden; }
  /* Affiche allergènes : A4 paysage, lisible à un ou deux mètres du comptoir */
  .affiche-impr { padding: 11mm 13mm 8mm; font-family: Arial, Helvetica, sans-serif; color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .aff-tete { display: flex; justify-content: space-between; align-items: flex-end; gap: 10mm; padding-bottom: 4mm; margin-bottom: 3mm; border-bottom: .8mm solid #000; }
  .aff-sur { font-size: 10pt; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; margin-bottom: 1.5mm; }
  .aff-tete h1 { font-family: 'Young Serif', Georgia, serif; font-weight: 400; font-size: 26pt; line-height: 1.05; }
  .aff-legende { display: flex; gap: 6mm; font-size: 11pt; white-space: nowrap; }
  .aff-legende span { display: inline-flex; align-items: center; gap: 2mm; }
  .affiche-impr table { width: 100%; border-collapse: collapse; table-layout: fixed; }
  .affiche-impr col.c-prod { width: 25%; }
  .affiche-impr thead { display: table-header-group; }
  .affiche-impr th { height: 31mm; padding: 0 0 2mm; vertical-align: bottom; border-bottom: .5mm solid #000; font-size: 10.5pt; font-weight: 700; }
  .affiche-impr th span { display: inline-block; writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
  .affiche-impr th.c-prod { text-align: left; font-size: 10pt; letter-spacing: .1em; text-transform: uppercase; }
  .affiche-impr tr { break-inside: avoid; page-break-inside: avoid; }
  .affiche-impr td { height: var(--ligne); padding: 0 1mm; text-align: center; vertical-align: middle; border-bottom: .25mm solid #9a9a9a; border-left: .25mm solid #d0d0d0; }
  .affiche-impr td:first-child { text-align: left; border-left: 0; padding-left: 2mm; font-weight: 700; font-size: min(calc(var(--ligne) * .42), 5mm); line-height: 1.1; }
  .affiche-impr tbody tr:nth-child(even) td { background: #efefef; }
  .affiche-impr .point { display: inline-block; vertical-align: middle; width: calc(var(--ligne) * .42); height: calc(var(--ligne) * .42); min-width: 3.4mm; min-height: 3.4mm; border-radius: 50%; background: #000; }
  .affiche-impr .point-trace { background: #fff; border: .7mm solid #000; box-sizing: border-box; }
  .aff-legende .point { width: 4.2mm; height: 4.2mm; min-width: 0; min-height: 0; }
  .aff-pied { display: flex; justify-content: space-between; gap: 10mm; margin-top: 4mm; font-size: 9pt; line-height: 1.35; }
  .aff-pied span:last-child { white-space: nowrap; font-weight: 700; text-align: right; }
  .aff-pied small { display: block; margin-top: 1mm; font-size: 7pt; font-weight: 400; color: #777; text-align: right; }
  /* Écriteaux de vitrine : 8 par A4 portrait (105 x 74,25 mm), traits de coupe en pointillés */
  .ecr-feuille { width: 210mm; height: 297mm; display: grid; grid-template-columns: repeat(2, 105mm); grid-template-rows: repeat(4, 74.25mm); }
  .ecr { box-sizing: border-box; border: .2mm dashed #999; padding: 8mm 9mm 6mm; display: flex; flex-direction: column; font-family: Arial, Helvetica, sans-serif; color: #000; overflow: hidden; }
  .ecr-nom { font-family: 'Young Serif', Georgia, serif; font-size: 20pt; line-height: 1.1; margin-bottom: 4mm; max-height: 2.3em; overflow: hidden; }
  .ecr-all { font-size: 13pt; font-weight: 700; line-height: 1.3; }
  .ecr-all span { font-weight: 400; }
  .ecr-traces { font-size: 10pt; margin-top: 2mm; line-height: 1.3; }
  .ecr-bas { margin-top: auto; display: flex; justify-content: space-between; align-items: baseline; gap: 4mm; font-size: 8pt; color: #555; }
  .ecr-bas strong { font-size: 16pt; color: #000; }
}
