:root {
  --char: #121518;
  --green: #76c146;
  --green-bg: #eef7e6;
  --bg: #f3f3f1;
  --grey: #6b6b6b;
  --line: #e2e2de;
  --amber: #b7791f;
  --amber-bg: #fdf3e1;
  --red: #c0392b;
  --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: "Fira Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--char); font-size: 16px; line-height: 1.45;
  display: flex; flex-direction: column; min-height: 100vh;
}
a { color: inherit; }
img { max-width: 100%; }
.muted { color: var(--grey); }
.small { font-size: .82rem; }

/* En-tête */
.top { background: #fff; border-bottom: 3px solid var(--green); }
.top-in { max-width: 1240px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 20px; }
.brand img { height: 56px; display: block; }
.partner { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.partner span { font-size: .68rem; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--grey); }
.partner img { height: 30px; }
.topnav { display: flex; gap: 14px; font-size: .88rem; flex-wrap: wrap; justify-content: flex-end; }
.topnav a { text-decoration: none; font-weight: 500; }
.topnav a.muted { color: var(--grey); }

.wrap { max-width: 1240px; width: 100%; margin: 0 auto; padding: 24px 20px 40px; flex: 1; }

/* Pied de page */
.foot { background: var(--char); color: #fff; border-top: 2px solid var(--green); font-size: .82rem; }
.foot-in { max-width: 1240px; margin: 0 auto; padding: 12px 20px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.foot b { margin-right: 6px; }

/* Bandeau titre */
.hero { background: var(--char); color: #fff; border-radius: var(--radius); padding: 28px 32px; margin-bottom: 20px; border-left: 6px solid var(--green); }
.kicker { color: var(--green); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; font-size: .78rem; margin: 0; }
.hero h1 { font-weight: 900; font-size: clamp(2rem, 5vw, 3rem); margin: 2px 0 6px; }
.hero .sub { margin: 0; color: #d6d6d6; font-weight: 300; }
.hero .sub b { color: #fff; font-weight: 500; }

/* Choix du magasin (administrateur) */
.store-pick { margin: 0 0 12px; font-weight: 600; font-size: .9rem; }
.store-pick select, .form select { font: inherit; font-weight: 400; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-left: 6px; }
.form select { display: block; width: 100%; margin: 4px 0 0; }

/* Recherche et filtres */
.tools { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; margin-bottom: 8px; }
.tools input[type=search] { flex: 1 1 320px; font: inherit; padding: 12px 16px; border-radius: 999px; border: 1px solid var(--line); background: #fff; }
.tools input[type=search]:focus { outline: 2px solid var(--green); border-color: var(--green); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.filters-label { font-size: .85rem; font-weight: 600; margin-right: 2px; }
.fchip input { position: absolute; opacity: 0; pointer-events: none; }
.fchip span { display: inline-block; padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: .85rem; cursor: pointer; user-select: none; }
.fchip input:checked + span { background: var(--char); color: #fff; border-color: var(--char); }
.fchip input:focus-visible + span { outline: 2px solid var(--green); }
.hint { font-size: .82rem; color: var(--amber); margin: 4px 0 0; }

/* Catégories */
.cats { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
.cat { font: inherit; font-weight: 600; font-size: .9rem; padding: 7px 16px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.cat.is-on { background: var(--green); border-color: var(--green); }

/* Listes (allergènes, valeurs nutritionnelles) */
.list-add { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; background: #fff; padding: 16px 20px 4px; border-radius: var(--radius); box-shadow: 1.5px 2px 0 #e4e4e0; margin: 16px 0 18px; }
.list-add .grow { flex: 1 1 240px; }
.list-add .w-sm { width: 110px; }
.list-add .btn, .list-add .check { margin-bottom: 12px; }
input.mini { font: inherit; font-size: .88rem; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; width: 80px; }
input.mini.wide { width: 100%; max-width: 280px; }

/* Grille d'articles */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; margin-top: 16px; }
.pcard { background: #fff; border-radius: var(--radius); text-decoration: none; box-shadow: 1.5px 2px 0 #e4e4e0; display: flex; flex-direction: column; transition: transform .12s ease, box-shadow .12s ease; }
.pcard:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.pcard[hidden] { display: none; }
.pimg { height: 220px; display: flex; align-items: center; justify-content: center; padding: 14px; overflow: hidden; }
.pimg img { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
.pbody { padding: 10px 16px 16px; border-top: 1px solid var(--line); flex: 1; }
.num { font-size: .75rem; color: var(--grey); font-weight: 500; }
.pbody h2 { font-size: 1.1rem; margin: 2px 0 8px; padding-left: 10px; border-left: 4px solid var(--green); }
.empty { text-align: center; color: var(--grey); padding: 40px 0; }

/* Pastilles */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; padding: 3px 11px; border-radius: 999px; border: 1px solid var(--green); background: var(--green-bg); font-weight: 600; font-size: .85rem; }
.chip-sm { font-size: .72rem; padding: 2px 8px; }
.chip-warn { border-color: var(--amber); background: var(--amber-bg); color: var(--amber); }
.chip-none { border-color: var(--line); background: #fafafa; color: var(--grey); font-weight: 500; }

/* Fiche produit : navigation précédent / suivant */
.fiche-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.fiche-nav .back { margin: 0; }
.pager { display: flex; align-items: center; gap: 8px; }
.pager-btn { display: inline-flex; align-items: center; gap: 8px; max-width: 240px; padding: 7px 14px; background: #fff; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; font-weight: 600; font-size: .88rem; }
.pager-btn:hover { border-color: var(--green); background: var(--green-bg); }
.pager-btn > span[aria-hidden] { font-size: 1.4rem; line-height: 1; color: var(--green); }
.pager-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager-count { font-size: .8rem; color: var(--grey); min-width: 52px; text-align: center; }
.fiche { position: relative; }
.side-arrow { position: absolute; top: 160px; width: 46px; height: 46px; border-radius: 50%; background: var(--char); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 2rem; line-height: 1; text-decoration: none; padding-bottom: 4px; box-shadow: 0 4px 12px rgba(0,0,0,.18); transition: background .15s, transform .15s; z-index: 1; }
.side-arrow:hover { background: var(--green); color: var(--char); transform: scale(1.06); }
.side-prev { left: -18px; }
.side-next { right: -18px; }

/* Fiche produit */
.back { margin: 0 0 14px; font-size: .9rem; }
.back a { color: var(--grey); }
.fiche { background: #fff; border-radius: var(--radius); box-shadow: 1.5px 2px 0 #e4e4e0; padding: 28px; }
.fiche-top { display: grid; grid-template-columns: minmax(200px, 340px) 1fr; gap: 28px; align-items: center; }
.fiche-img { height: 320px; display: flex; align-items: center; justify-content: center; }
.fiche-img img { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
.fiche-head h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin: 2px 0 6px; }
.bar { display: block; width: 46px; height: 4px; background: var(--green); margin-bottom: 12px; }
.mix { color: var(--grey); margin: 0 0 4px; font-size: .92rem; }
.label { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; margin: 18px 0 8px; padding-left: 10px; border-left: 3px solid var(--green); }
.fiche-sec { border-top: 1px solid var(--line); margin-top: 24px; padding-top: 4px; }
.fiche-sec p { margin: 6px 0; }
.traces { color: var(--grey); font-size: .9rem; }
.note { color: var(--amber); font-weight: 500; font-size: .92rem; }
.nut-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.nut { width: 100%; max-width: 560px; border-collapse: collapse; font-size: .95rem; }
.nut th, .nut td { padding: 7px 12px; text-align: left; font-weight: 400; }
.nut td { text-align: right; font-weight: 600; }
.nut tr:nth-child(odd) { background: #f6f6f4; }
.nut tr.sub th { padding-left: 28px; color: var(--grey); font-weight: 300; }
.nut tr.sub td { color: var(--grey); font-weight: 300; }
.nut-empty { background: #f6f6f4; border-radius: 8px; text-align: center; color: var(--grey); padding: 28px; font-weight: 300; }

/* Messages */
.flash { padding: 10px 14px; border-radius: 8px; margin: 0 0 14px; font-size: .92rem; }
.flash-ok { background: var(--green-bg); border: 1px solid var(--green); }
.flash-warn { background: var(--amber-bg); border: 1px solid var(--amber); color: #7a4f10; }
.flash-err { background: #fdecea; border: 1px solid var(--red); color: var(--red); }

/* Boutons */
.btn { display: inline-block; background: var(--green); color: var(--char); border: 0; border-radius: 999px; padding: 10px 20px; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn:hover { filter: brightness(.95); }
.btn-ghost { background: #fff; border: 1px solid var(--line); font-weight: 500; }
.btn-danger { background: #fff; color: var(--red); border: 1px solid #f1c4bf; font-weight: 500; }
.btn-sm { padding: 5px 12px; font-size: .82rem; }
form.inline { display: inline; }

/* Formulaires */
.panel { background: #fff; border-radius: var(--radius); padding: 28px; box-shadow: 1.5px 2px 0 #e4e4e0; }
.narrow { max-width: 520px; margin: 20px auto; }
.form label { display: block; font-weight: 500; font-size: .9rem; margin-bottom: 12px; }
.form input:not([type=checkbox]):not([type=file]), .form textarea {
  display: block; width: 100%; font: inherit; font-weight: 400; margin-top: 4px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.form input:focus, .form textarea:focus { outline: 2px solid var(--green); border-color: var(--green); }
.form input[type=file] { display: block; margin-top: 6px; }
.form .check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.form .check.warn { color: var(--amber); }
.edit-form fieldset { background: #fff; border: 0; border-radius: var(--radius); padding: 20px 24px 10px; margin: 0 0 18px; box-shadow: 1.5px 2px 0 #e4e4e0; }
.edit-form fieldset > :not(legend) { clear: both; }
.edit-form legend { float: left; width: 100%; font-weight: 700; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; padding-left: 10px; border-left: 3px solid var(--green); margin-bottom: 14px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.row .grow { flex: 1 1 260px; }
.row .w-sm { width: 110px; }
.row .w-md { width: 220px; }
.row .check { margin-bottom: 22px; }
.photo-row { align-items: center; }
.photo-prev { width: 150px; height: 120px; object-fit: contain; background: #fafafa; border-radius: 8px; border: 1px solid var(--line); }
.al-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px 18px; clear: both; }
.al-item { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.al-item .check { margin: 0 0 4px; }
.al-item input:not([type=checkbox]) { margin-top: 2px !important; padding: 5px 8px !important; font-size: .85rem !important; }
.nut-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0 16px; clear: both; }
.form-actions { display: flex; gap: 10px; }

/* Administration */
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.admin-head h1 { margin: 0; }
.admin-head + .admin-table, .admin-head + .flash, .user-form + .admin-table { margin-top: 22px; }
.admin-head + .user-form { margin-top: 22px; }
.admin-head p { margin: 4px 0 0; }
.admin-search { font: inherit; width: 100%; max-width: 420px; padding: 9px 14px; border: 1px solid var(--line); border-radius: 999px; margin: 18px 0 12px; }
.admin-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: 1.5px 2px 0 #e4e4e0; font-size: .9rem; }
.admin-table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--grey); padding: 10px; border-bottom: 1px solid var(--line); }
.admin-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table tr.is-off td { opacity: .55; }
.admin-table tr.is-off td:has(.switch) { opacity: 1; }
.switch { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; padding: 2px 0; font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; color: var(--grey); }
.switch .knob { position: relative; width: 38px; height: 22px; border-radius: 999px; background: #cfcfca; transition: background .15s; flex: none; }
.switch .knob::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch[aria-checked="true"] { color: var(--char); }
.switch[aria-checked="true"] .knob { background: var(--green); }
.switch[aria-checked="true"] .knob::after { transform: translateX(16px); }
.switch:focus-visible .knob { outline: 2px solid var(--char); outline-offset: 2px; }
.switch:disabled { opacity: .6; cursor: wait; }
.admin-table .actions { white-space: nowrap; text-align: right; }
.thumb { width: 54px; height: 44px; object-fit: contain; }
.tag { font-size: .75rem; padding: 2px 8px; border-radius: 999px; background: #eee; }
.tag-on { background: var(--green-bg); }

@media (max-width: 760px) {
  .top-in { flex-wrap: wrap; }
  .topnav { width: 100%; justify-content: flex-start; }
  .partner span { display: none; }
  .brand img { height: 42px; }
  .partner img { height: 22px; }
  .fiche { padding: 18px; }
  .side-arrow { display: none; }
  .pager-name { display: none; }
  .pager-btn { padding: 6px 14px; }
  .fiche-top { grid-template-columns: 1fr; }
  .fiche-img { height: 240px; }
  .pimg { height: 180px; }
  .admin-table thead { display: none; }
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; }
  .admin-table tr { padding: 8px 0; }
  .admin-table .actions { text-align: left; white-space: normal; }
}

/* Assortiment */
.assort-bar { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--bg); padding: 10px 0; }
.assort-bar .admin-search { margin: 0; flex: 1 1 260px; }
.assort-cat { font-size: 1rem; margin: 18px 0 8px; padding-left: 10px; border-left: 4px solid var(--green); }
.assort-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.form .assort-item { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 0; cursor: pointer; font-weight: 400; }
.assort-item[hidden] { display: none !important; }
.assort-item:has(input:checked) { border-color: var(--green); background: var(--green-bg); }
.assort-item input { width: 18px; height: 18px; accent-color: var(--green); flex: none; }
.assort-item img { width: 46px; height: 38px; object-fit: contain; flex: none; }
.assort-item > span { flex: 1; line-height: 1.25; }
.assort-item a { color: var(--grey); text-decoration: none; }
.role-admin { background: var(--char); color: #fff; }
.role-manager { background: var(--green-bg); }
.user-form { max-width: 820px; }

/* Commandes */
.order-cta { margin: 0 0 14px; }
.order-layout { display: grid; grid-template-columns: 1fr 340px; gap: 22px; align-items: start; }
.order-side { position: sticky; top: 12px; }
.order-side fieldset { margin: 0; }
.btn-block { display: block; width: 100%; text-align: center; padding: 12px; font-size: 1rem; }
.order-list { display: grid; gap: 8px; }
.order-line { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.order-line[hidden] { display: none; }
.order-line.has-qty { border-color: var(--green); background: var(--green-bg); }
.order-line img { width: 52px; height: 42px; object-fit: contain; flex: none; }
.ol-name { flex: 1; line-height: 1.25; }
.stepper { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.stepper button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: #fff; font-size: 1.2rem; font-weight: 700; cursor: pointer; line-height: 1; }
.stepper button:hover { border-color: var(--green); }
.form .stepper input[type=number] { width: 62px; flex: none; text-align: center; margin: 0; padding: 6px 4px; font-weight: 700; }
.tag-err { background: #fdecea; color: var(--red); }
.order-table td { text-align: right; font-weight: 700; width: 70px; }
.order-table th { font-weight: 400; }
.order-table tfoot td, .order-table tfoot th { border-top: 2px solid var(--line); font-weight: 700; background: #fff; }
.resend-form { margin-top: 18px; }
@media (max-width: 900px) {
  .order-layout { grid-template-columns: 1fr; }
  .order-side { position: static; }
}
@media print {
  .top, .foot, .no-print { display: none !important; }
  body { background: #fff; }
  .fiche { box-shadow: none; padding: 0; }
}

.extra-line .extra-tag { width: 52px; height: 42px; flex: none; display: flex; align-items: center; justify-content: center; border: 2px dashed var(--line); border-radius: 8px; color: var(--grey); font-size: 1.3rem; font-weight: 700; }
.form .extra-line .extra-name { flex: 1; margin: 0; min-width: 0; }
.extra-del { width: 30px; height: 30px; flex: none; border: 0; background: none; color: var(--grey); font-size: 1.4rem; cursor: pointer; border-radius: 50%; }
.extra-del:hover { background: #fdecea; color: var(--red); }
@media (max-width: 760px) {
  .extra-line { flex-wrap: wrap; }
  .extra-line .extra-tag { display: none; }
  .form .extra-line .extra-name { flex: 1 1 100%; }
}

/* Destinataires par magasin */
.recipient-add { margin-top: 14px; }
.store-checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.store-details summary { cursor: pointer; color: var(--char); }
.store-details[open] summary { margin-bottom: 6px; font-weight: 600; }
.store-details .store-checks { flex-direction: column; gap: 4px; }
.store-details .check { display: flex; align-items: center; gap: 6px; font-size: .85rem; }
select.mini-select { font: inherit; font-size: .88rem; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; max-width: 100%; }

/* Espace avant le bouton final de l'assortiment */
.assort > .form-actions { margin-top: 24px; }

/* Partenaire boulangerie par magasin */
.partner-preview { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: #fff; border-radius: var(--radius); padding: 14px 18px; margin: 14px 0 18px; box-shadow: 1.5px 2px 0 #e4e4e0; }
.partner-box { display: flex; align-items: center; gap: 10px; border: 1px dashed var(--line); border-radius: 8px; padding: 8px 14px; }
.partner-box span { font-size: .68rem; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--grey); }
.partner-box img { height: 34px; max-width: 220px; object-fit: contain; }
.partner-mini { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.partner-mini img { height: 24px; max-width: 90px; object-fit: contain; }
.partner img { max-width: 240px; object-fit: contain; }

/* Prix par magasin (assortiment) + tarif */
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.assort-item > .price-field { flex: none; display: inline-flex; align-items: center; gap: 3px; }
.form .assort-item .price-field input { width: 64px; margin: 0; height: auto; padding: 5px 6px; border: 1px solid var(--line); border-radius: 6px; text-align: right; font: inherit; font-size: .9rem; accent-color: initial; }
.assort-item .price-field input:focus { outline: 2px solid var(--green); border-color: var(--green); }
.assort-item .price-field span { color: var(--muted, #6b6b6b); font-size: .9rem; }
.price-tag { display: inline-block; font-weight: 800; color: var(--char, #121518); background: var(--green-bg, #eef7e6); border: 1px solid var(--green); border-radius: 999px; padding: 2px 10px; }
.pcard .price-tag { margin: 4px 0 2px; font-size: .9rem; }
.tarif-link { margin: 0 0 10px; text-align: right; }
