:root {
  --cream: #F8F2E1; --cream-2: #F1E9D3; --ocre: #D1B740; --ocre-dark: #8f7420; --charcoal: #36353A; --white: #fff;
  --line: rgba(54, 53, 58, .14); --muted: rgba(54, 53, 58, .65); --danger: #a33a2e; --ok: #3c5c33; --ok-bg: rgba(158, 203, 137, .35);
  --allergen: #7a4636; --allergen-bg: rgba(207, 170, 155, .4);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --cream: #221F17; --cream-2: #2A261C; --white: #2E2A20; --charcoal: #F2EDE0; --line: rgba(242, 237, 224, .16); --muted: rgba(242, 237, 224, .65);
    --danger: #f08a7c; --ok: #b9e0a8; --allergen: #f0c2b2; --ocre-dark: #d9bf5a; color-scheme: dark; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--cream); color: var(--charcoal); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ocre-dark); outline-offset: 2px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* Mise en page : en-tête, menu à gauche, contenu */
.shell { display: grid; grid-template-columns: 250px 1fr; grid-template-rows: auto 1fr; min-height: 100vh; }
header.top { grid-column: 1 / -1; position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: #36353A; color: #F8F2E1; }
header.top h1 { margin: 0; font-size: 1.05rem; }
header.top .who { margin-left: auto; font-size: .85rem; opacity: .8; }
.burger { display: none; border: 1px solid rgba(255, 255, 255, .4); background: transparent; color: #F8F2E1; border-radius: 8px; padding: 4px 10px; font-size: 1.1rem; }
aside.side { background: var(--white); border-right: 1px solid var(--line); padding: 14px 10px 40px; position: sticky; top: 49px; align-self: start; height: calc(100vh - 49px); overflow-y: auto; }
.side-link, .side-title { display: flex; align-items: center; gap: 10px; padding: 9px 10px; font-weight: 600; color: var(--charcoal); text-decoration: none; border-radius: 10px; }
.side-link:hover { background: var(--cream-2); }
.side-title { margin-top: 10px; }
.side .ic { width: 20px; text-align: center; }
.side-item { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px 7px 40px; font-size: .9rem; color: var(--charcoal); text-decoration: none; border-radius: 8px; }
a.side-item:hover { background: var(--cream-2); }
.side-item.on { background: var(--cream-2); font-weight: 700; box-shadow: inset 3px 0 0 var(--ocre); }
.side-item.soon { color: var(--muted); cursor: default; }
.side-item.soon small { font-size: .68rem; border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; }
main { padding: 18px 20px 80px; min-width: 0; max-width: 1250px; width: 100%; }
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .burger { display: inline-block; }
  aside.side { display: none; position: fixed; z-index: 25; top: 49px; left: 0; width: 280px; max-width: 85vw; box-shadow: 4px 0 24px rgba(0, 0, 0, .25); }
  aside.side.open { display: block; }
  main { padding: 14px 12px 80px; }
}

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .grow { flex: 1; min-width: 180px; }
input[type=text], input[type=search], input[type=email], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--white);
}
.toolbar input, .toolbar select { width: auto; }
.toolbar input.grow { width: auto; flex: 1; }
textarea { min-height: 70px; resize: vertical; }

.btn { border: 1px solid var(--line); background: var(--white); border-radius: 10px; padding: 8px 14px; font-weight: 600; }
.btn.primary { background: var(--ocre); border-color: var(--ocre); color: #36353A; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.chip { border: 1px solid var(--line); background: var(--white); border-radius: 999px; padding: 5px 12px; font-size: .85rem; }
.chip.on { background: var(--charcoal); color: var(--cream); border-color: var(--charcoal); }

.card { background: var(--white); border-radius: 14px; overflow: auto; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr.row { cursor: pointer; }
tr.row:hover { background: var(--cream-2); }
tr.archived td { opacity: .5; }
td.num, th.num { text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.count { color: var(--muted); font-size: .85rem; margin: 8px 2px; }
.badge { display: inline-block; font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: var(--allergen-bg); color: var(--allergen); margin: 1px 2px 1px 0; }
.star { border: 0; background: none; font-size: 1.1rem; color: var(--muted); padding: 0 4px; }
.star.on { color: var(--ocre); }

.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; overflow: auto; z-index: 50; }
.modal { background: var(--cream); border-radius: 16px; width: min(720px, 100%); padding: 20px; box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
.modal h2 { margin: 0 0 14px; font-size: 1.15rem; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (max-width: 600px) { .grid { grid-template-columns: 1fr; } }
.grid .full { grid-column: 1 / -1; }
label.field { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); }
label.field > :not(span) { margin-top: 4px; font-weight: 400; color: var(--charcoal); }
.allergens { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.allergens label { display: inline-flex; gap: 6px; align-items: center; background: var(--white); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: .85rem; font-weight: 400; color: var(--charcoal); }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.actions .left { margin-right: auto; display: flex; gap: 8px; }
.err { color: var(--danger); font-size: .88rem; min-height: 1.2em; margin-top: 10px; }
.denied { max-width: 520px; margin: 80px auto; padding: 0 16px; text-align: center; }


/* Pages et fiches */
.page-title { margin: 0 0 12px; font-size: 1.3rem; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.crumb { margin: 0 0 6px; font-size: .82rem; color: var(--muted); }
.crumb a { color: inherit; }
.pill { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--cream-2); border: 1px solid var(--line); }
.pill.big { font-size: .8rem; }
.card.pad { padding: 16px 18px; margin-bottom: 16px; overflow: visible; }
.card-title { margin: 0 0 12px; font-size: .95rem; }
.kvgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 36px; margin: 0; }
@media (max-width: 1050px) { .kvgrid { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: minmax(130px, 190px) 1fr; gap: 10px; padding: 5px 0; font-size: .92rem; }
.kv dt { font-weight: 700; } .kv dd { margin: 0; word-break: break-word; }
.state { white-space: nowrap; font-size: .75rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.state.ok { background: #5bd47a; color: #0e3b1b; } .state.off { background: var(--allergen-bg); color: var(--allergen); }
.tabbar { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabbar button { border: 0; background: none; padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabbar button.on { color: var(--charcoal); border-bottom-color: var(--ocre); }
.tabpanel { overflow-x: auto; }
.modal.wide { width: min(980px, 100%); }
h3.sect, .sect-head h3 { margin: 18px 0 8px; font-size: .95rem; }
.sect-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; }
.links { display: grid; gap: 8px; margin-top: 4px; }
.link-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding-bottom: 6px; border-bottom: 1px dashed var(--line); }
.link-row > * { flex: 1 1 96px; min-width: 0; }
.link-row > select:first-child { flex: 2 1 180px; }
.link-row > .pr, .link-row > button { flex: 0 0 auto; }
.link-row .pr { font-size: .8rem; white-space: nowrap; display: flex; gap: 4px; align-items: center; }
.link-row input, .link-row select { padding: 6px 8px; }
label.field.check { display: flex; align-items: center; gap: 8px; align-self: end; padding-bottom: 8px; color: var(--charcoal); }
label.field.check input { width: auto; margin: 0; }

/* Recettes */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.ok-tick { color: #2e8b4a; font-weight: 700; }
.warn { color: #b25a00; font-size: .85rem; }
.kind { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; color: #fff; }
.kind.recipe { background: #2e8b4a; } .kind.ingredient { background: #d9822b; } .kind.big { font-size: .8rem; margin-left: 4px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.split { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }
.split .card.pad { margin-bottom: 16px; }
@media (max-width: 1050px) { .split { grid-template-columns: 1fr; } }
.bignums { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 14px; }
.bignums div { display: grid; text-align: center; min-width: 90px; }
.bignums strong { font-size: 1.15rem; } .bignums small { color: var(--muted); }
.prose { white-space: pre-wrap; line-height: 1.5; }
textarea.tall { min-height: 150px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.items { display: grid; gap: 6px; margin: 8px 0; }
.item-row { display: grid; grid-template-columns: auto 1fr 90px 130px auto auto auto; gap: 6px; align-items: center; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.item-row .item-name { overflow-wrap: anywhere; }
.item-row input, .item-row select { padding: 6px 8px; }
@media (max-width: 700px) { .item-row { grid-template-columns: auto 1fr 80px; } .item-row select { grid-column: 2 / 4; } }
.found { display: grid; gap: 2px; margin-top: 4px; }
.found-item { display: flex; gap: 8px; align-items: center; text-align: left; border: 1px solid var(--line); background: var(--white); border-radius: 8px; padding: 6px 10px; }
.found-item:hover { background: var(--cream-2); } .found-item small { color: var(--muted); margin-left: auto; }

/* Impression : seule la fiche de production est imprimée */
#print-area { display: none; }
@media print {
  body { background: #fff; color: #000; }
  #app { display: none !important; }
  #print-area { display: block; font-family: system-ui, sans-serif; padding: 8mm; }
  #print-area h1 { margin: 0 0 4px; } #print-area h2 { font-size: 1.05rem; margin: 18px 0 6px; border-bottom: 1px solid #000; }
  #print-area table { width: 100%; border-collapse: collapse; } #print-area th, #print-area td { border-bottom: 1px solid #bbb; padding: 5px 6px; text-align: left; }
  #print-area .num { text-align: right; } #print-area .allerg { font-weight: 700; } #print-area .foot { margin-top: 24px; font-size: .8rem; color: #555; }
}

/* Production et étiquettes */
.dlc { display: inline-block; font-size: .8rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.dlc.ok { background: rgba(158, 203, 137, .45); color: #2f5b27; } .dlc.bientot { background: #fff1c2; color: #7a5a00; }
.dlc.aujourdhui { background: #ffd9a8; color: #8a3f00; } .dlc.expire { background: #f6c3bc; color: #8a1d12; } .dlc.done { background: var(--cream-2); color: var(--muted); font-weight: 600; }
.small { font-size: .78rem; }
.actions-cell { white-space: nowrap; text-align: right; }
.actions-cell > * { margin-left: 6px; }
.row-actions { display: inline-flex; gap: 6px; }
.tiles { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.tile { display: grid; min-width: 150px; padding: 12px 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--white); }
.tile strong { font-size: 1.6rem; } .tile span { color: var(--muted); font-size: .85rem; }
.tile.expire { border-color: #e59a90; } .tile.aujourdhui { border-color: #e8b27a; } .tile.bientot { border-color: #e6cf7a; }
.chosen { margin: 6px 0 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.lbl-preview { display: flex; justify-content: center; padding: 10px; margin-bottom: 12px; background: var(--cream-2); border-radius: 12px; }
.lbl { width: 62mm; min-height: 36mm; padding: 2.2mm; border: 1px dashed #777; background: #fff; color: #000; font-family: system-ui, sans-serif; font-size: 8.5pt; line-height: 1.25; display: grid; align-content: space-between; gap: 1mm; }
.lbl-title { font-weight: 800; font-size: 11pt; line-height: 1.1; } .lbl-dlc { font-weight: 800; font-size: 12pt; }
.lbl-all { font-weight: 700; } .lbl-foot { font-size: 7.5pt; color: #333; }
@media print {
  #print-area.print-labels { padding: 0; }
  #print-area.print-labels .lbl { border: 0; width: auto; min-height: 0; break-inside: avoid; }
  #print-area.print-labels.single .lbl { page-break-after: always; width: 100%; }
  #print-area.print-labels.single .lbl:last-child { page-break-after: auto; }
  #print-area.print-labels.sheet { display: grid; grid-template-columns: repeat(3, 63mm); gap: 0; }
  #print-area.print-labels.sheet .lbl { width: 63mm; height: 38mm; border: 1px dashed #aaa; overflow: hidden; }
}

/* Menu foncé à gauche */
aside.side { background: #2f2e33; border-right: 0; color: #f3ecd9; }
.side-logo { display: block; background: #fff; border-radius: 14px; padding: 8px 10px; margin: 2px 4px 14px; }
.side-logo img { display: block; width: 100%; height: auto; }
.side-link, .side-title { color: #f3ecd9; }
.side-link:hover, a.side-item:hover { background: rgba(255, 255, 255, .08); }
.side-title { font-size: .95rem; opacity: .95; }
.side-item { color: #d9d2bf; }
.side-item.on { background: rgba(209, 183, 64, .2); color: #fff; box-shadow: inset 3px 0 0 var(--ocre); }
.side-item.soon { color: #8f8a7d; }
@media (max-width: 800px) { aside.side { top: 49px; } }

/* Tableau de bord : cartes colorées par domaine */
.hub-section { margin: 22px 0 8px; }
.hub-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.hub-ico { width: 40px; height: 40px; display: grid; place-items: center; font-size: 1.4rem; background: var(--white); border: 1px solid var(--line); border-radius: 12px; }
.hub-head h3 { margin: 0; font-size: 1.05rem; } .hub-head p { margin: 2px 0 0; color: var(--muted); font-size: .88rem; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.tile-card { position: relative; display: grid; justify-items: center; gap: 4px; text-align: center; padding: 22px 14px 18px; border-radius: 18px; border: 1px solid transparent; text-decoration: none; color: #2b2a2e; transition: transform .12s ease, box-shadow .12s ease; }
.tile-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0, 0, 0, .12); }
.tile-card strong { font-size: 1.02rem; } .tile-card small { color: rgba(43, 42, 46, .72); font-size: .82rem; line-height: 1.35; }
.tile-icon { font-size: 2.3rem; line-height: 1; margin-bottom: 6px; }
.tile-count { position: absolute; top: 10px; right: 12px; min-width: 26px; padding: 1px 8px; border-radius: 999px; background: rgba(255, 255, 255, .85); font-size: .8rem; font-weight: 700; }
.t-sun { background: #fbf1c9; border-color: #ecd98a; } .t-leaf { background: #e4f1da; border-color: #b9d8a5; } .t-sky { background: #e2ebf7; border-color: #b6cbe6; }
.t-peach { background: #fde6d3; border-color: #efbf98; } .t-lilac { background: #ebe3f6; border-color: #cbbbe6; } .t-rose { background: #f9dfe3; border-color: #e8b4bd; }
.t-mint { background: #dff4ec; border-color: #a9dcc8; } .t-red { background: #fbd9d3; border-color: #e59a90; }
.tile-card.alert .tile-count { background: #c0392b; color: #fff; }
@media (prefers-color-scheme: dark) { .tile-card { color: #2b2a2e; } }
.banner { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-radius: 14px; text-decoration: none; margin-bottom: 8px; border: 1px solid transparent; }
.banner .go { margin-left: auto; font-weight: 700; }
.banner.danger { background: #fbd9d3; border-color: #e59a90; color: #6e1a10; } .banner.warn { background: #fff1c2; border-color: #e6cf7a; color: #6b4e00; }
.banner.ok { background: #e4f1da; border-color: #b9d8a5; color: #2f5b27; }
