/* Styles de l'application Intendance de camp – Patro Sainte-Suzanne */
:root {
  /* light-dark() : clair, sombre (thème du système, ou choisi avec le bouton 🌙 via data-theme) */
  color-scheme: light dark;
  --bg: light-dark(#eaf4ec, #142019);
  --card: light-dark(#fff, #1c2b21);
  --tx: light-dark(#1f2a22, #e6f0e8);
  --mu: light-dark(#5c6f62, #9bb3a2);
  --ac: light-dark(#1f7a3f, #2a8a50);
  --bd: light-dark(#c9e0cf, #2c4234);
  --grp: light-dark(#e3efe6, #264a33);
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
:root[data-theme="light"] {
  color-scheme: light;
}
:root[data-theme="dark"] {
  color-scheme: dark;
}
html {
  scroll-padding-top: env(safe-area-inset-top, 0px);
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--tx);
  font:
    16px/1.4 system-ui,
    -apple-system,
    Segoe UI,
    sans-serif;
  padding: 16px;
}
main {
  max-width: 900px;
  margin: auto;
}
h1 {
  font-size: 1.5rem;
  margin: 0 0 4px;
}
h2 {
  font-size: 1.05rem;
  margin: 0 0 10px;
}
.s {
  color: var(--mu);
  font-size: 0.88rem;
}
.card {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 12px;
  padding: 14px;
  margin: 14px 0;
}
.g {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
/* iPhone (Safari, Chrome) : un champ date a une largeur et une hauteur propres qui débordent de sa case ; une liste dans le menu latéral est écrasée quand l'écran est bas */
.g > * {
  min-width: 0;
}
input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  min-width: 0;
  max-width: 100%;
  height: 2.4rem;
  text-align: left;
}
input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
  min-height: 1.2em;
}
#drawer > * {
  flex-shrink: 0;
}
#csel {
  min-height: 2.4rem;
  line-height: normal;
}
label {
  display: block;
  font-size: 0.78rem;
  color: var(--mu);
}
input,
select,
textarea,
button {
  font: inherit;
  color: var(--tx);
  background: var(--bg);
  border: 1px solid var(--bd);
  border-radius: 8px;
  padding: 7px 9px;
  width: 100%;
  box-sizing: border-box;
}
button {
  width: auto;
  cursor: pointer;
  background: var(--ac);
  color: #fff;
  border: 0;
}
button.x {
  background: transparent;
  color: var(--mu);
  border: 1px solid var(--bd);
}
.row {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto;
  gap: 8px;
  margin-bottom: 8px;
}
#rdesc[readonly] {
  background: transparent;
  resize: none;
  cursor: default;
}
.rrow {
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
}
.rrow select,
.rrow button {
  padding: 5px 9px;
}
.rrow button {
  min-width: 38px;
  font-size: 1.1rem;
  line-height: 1.2;
}
.hd {
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  padding: 4px 6px;
  color: var(--mu);
  font-size: 1.3rem;
  line-height: 1;
}
.dcard {
  border: 1px solid var(--bd);
  border-radius: 12px;
  margin: 10px 0;
  overflow: hidden;
}
.dhd {
  background: #2a3b2f;
  color: #fff;
  font-weight: 700;
  padding: 8px 12px;
}
.zone {
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 4px 10px;
  align-items: start;
  padding: 8px 12px;
  border-left: 6px solid var(--mc);
  background: var(--mcl);
}
.zone + .zone {
  border-top: 1px solid var(--bd);
}
.zone.over {
  outline: 2px dashed var(--ac);
  outline-offset: -4px;
}
.zl {
  grid-row: 1/3;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 5px 6px;
  border-radius: 6px;
  background: var(--mc);
  color: var(--mct);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  text-align: center;
}
.zc {
  min-height: 34px;
}
.zone select {
  grid-column: 2;
  max-width: 260px;
  padding: 4px 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 8px;
  padding: 2px 4px;
  margin: 2px 4px 2px 0;
}
.chip.drag {
  opacity: 0.4;
}
.chip .x {
  padding: 2px 7px;
  border: 0;
}
.tg {
  font-size: 0.72rem;
  padding: 2px 8px;
  margin-top: 3px;
}
.tl {
  display: flex;
  gap: 6px;
  align-items: center;
}
.tl .tn {
  flex: 1;
  min-width: 0;
}
.tl button {
  padding: 4px 9px;
}
.zadd {
  padding: 8px 12px;
  border-top: 1px solid var(--bd);
}
.zadd select {
  max-width: 260px;
  padding: 4px 8px;
}
.nsl {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 6px;
}
.nsl select {
  max-width: 200px;
}
.nsl input {
  width: 180px;
}
.zdel {
  padding: 8px 12px;
  background: color-mix(in srgb, #d33 14%, var(--card));
  border-top: 1px solid var(--bd);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.zl {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.zr {
  display: flex;
  align-items: center;
}
.zl .zh {
  padding: 0 2px 0 0;
}
.zn {
  background: transparent;
  color: inherit;
  border: 0;
  padding: 0 2px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  overflow-wrap: break-word;
}
.zh,
.ih {
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  padding: 0 8px;
  font-size: 1.1rem;
  line-height: 1.2;
  opacity: 0.85;
}
#rb .ih {
  display: inline-block;
  vertical-align: middle;
  padding: 10px 4px;
}
.ibox {
  display: flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--bd);
  border-radius: 10px;
  padding: 0 6px;
  background: var(--card);
}
.ib {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 4px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  overflow-wrap: break-word;
}
#rb tr.drag {
  opacity: 0.5;
}
#rb tr.over td {
  box-shadow: inset 0 2px 0 var(--ac);
}
.zone.drag {
  opacity: 0.5;
}
.zpan {
  padding: 8px 12px;
  background: var(--card);
  border-top: 1px solid var(--bd);
  border-left: 6px solid var(--bd);
}
.zpan .zdel {
  padding: 8px 0 0;
  background: none;
  border-top: 1px solid var(--bd);
  margin-top: 6px;
}
.crow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 6px 0;
}
.crow b {
  width: 56px;
}
.sws {
  display: contents;
}
.crow input[type="color"] {
  width: 44px;
  height: 32px;
  padding: 0;
}
.sw {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--bd);
}
.sw.on {
  outline: 3px solid var(--tx);
  outline-offset: 2px;
}
.w {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th,
td {
  text-align: left;
  padding: 5px 7px;
  border-bottom: 1px solid var(--bd);
  white-space: nowrap;
}
/* Tables de saisie (recettes, catalogue, liste de courses) : toutes les colonnes tiennent dans l'écran */
table.fit {
  font-size: 0.82rem;
}
.fit th,
.fit td {
  padding: 4px 3px;
  white-space: normal;
  overflow-wrap: break-word;
}
.fit th {
  font-size: 0.72rem;
  overflow-wrap: normal;
}
.fit.rec th {
  font-size: 0.6rem;
}
.fit.rec th .s {
  font-size: 0.56rem;
}
.fit.rec th:first-child,
.fit.rec td:first-child {
  min-width: 96px;
}
/* Recettes : colonnes de taille fixe, quel que soit le nombre de sections ; le tableau défile si besoin */
table.fit.rec {
  width: max-content;
  min-width: 100%;
}
.fit.rec th:not(:first-child) {
  min-width: 64px;
  max-width: 80px;
}
.fit.rec td input[type="number"] {
  width: 64px;
  max-width: none;
}
/* Effectifs : champs alignés en bas de chaque ligne, même si un libellé passe sur deux lignes */
#cnt > div {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.fit .nw,
#list td:last-child {
  white-space: nowrap;
  overflow-wrap: normal;
}
.fit td input[type="number"] {
  width: 100%;
  max-width: 64px;
  min-width: 0;
  box-sizing: border-box;
  padding: 4px 2px;
  -moz-appearance: textfield;
  appearance: textfield;
}
.fit input[type="number"]::-webkit-inner-spin-button,
.fit input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
td input {
  width: 72px;
  padding: 4px 6px;
}
.t {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.t b {
  color: var(--ac);
}
header {
  background: var(--ac);
  color: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
header h1 {
  margin: 0;
  font-size: 1.4rem;
  color: #fff;
}
header .s {
  color: #d6ecdb;
  font-size: 0.95rem;
}
#logo {
  cursor: pointer;
  flex: none;
  height: 70px;
  min-width: 70px;
  max-width: 130px;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  box-sizing: border-box;
}
#logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
td input.nop {
  border-color: #d33;
  background: rgba(220, 50, 50, 0.15);
}
summary {
  cursor: pointer;
  font-weight: 600;
  margin: 8px 0;
}
footer {
  text-align: center;
  color: var(--mu);
  font-size: 0.85rem;
  padding: 18px 0 8px;
}
.mp {
  --mc: #1f7a3f;
  --mcl: #1f7a3f22;
  --mct: #fff;
  background: #fff;
  color: #1f2a22;
  border-radius: 12px;
  padding: 14px;
  border: 1px solid var(--bd);
  margin: 10px 0;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.mp h2 {
  font-size: 1.4rem;
  margin: 0 0 2px;
  padding-bottom: 6px;
  border-bottom: 3px solid var(--mc);
  color: #1f2a22;
}
.mp h3 {
  color: #1f2a22;
}
.mp .s {
  color: #5c6f62;
}
.mt {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  margin-top: 10px;
}
.mt th {
  background: #2a3b2f;
  color: #fff;
  text-align: left;
  padding: 8px 10px;
  white-space: normal;
}
.mt td {
  white-space: normal;
  padding: 7px 10px;
  border-bottom: 1px solid var(--mcl);
  color: #1f2a22;
  vertical-align: top;
}
.mt tr.day td {
  background: #dfe8e1;
  color: #1f2a22;
  font-weight: 700;
  border-top: 2px solid #2a3b2f;
}
.mt tr.sl td {
  background: var(--mcl);
}
.mt tr.sl td.sn {
  background: var(--mc);
  color: var(--mct);
  font-weight: 700;
  width: 84px;
}
.mt .ad {
  font-size: 0.8rem;
  color: #5c6f62;
  font-style: italic;
}
/* effectif sous le nom du repas : même couleur de texte que le nom (choisie pour contraster avec la couleur du repas) */
.mt td.sn .ad {
  color: inherit;
  font-style: normal;
  font-weight: 700;
}
.mt td.ck {
  width: 1.4em;
  text-align: center;
}
.mt tr {
  break-inside: avoid;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
:focus-visible {
  outline: 3px solid #f2a900;
  outline-offset: 2px;
}
#pv {
  display: none;
}
#warn {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 60;
  background: #8c1d18;
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}
#warn[hidden] {
  display: none;
}
#warn button {
  background: #fff;
  color: #8c1d18;
}
#warn .x {
  background: transparent;
  color: #fff;
  border-color: #fff;
}
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  margin: -16px -16px 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--bd);
}
.burger {
  background: transparent;
  color: var(--tx);
  font-size: 1.6rem;
  line-height: 1;
  padding: 2px 10px;
  border: 0;
}
#ptitle {
  font-weight: 600;
}
#scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 30;
}
body.nav #scrim {
  opacity: 1;
  pointer-events: auto;
}
#drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(300px, 85vw);
  background: var(--card);
  border-right: 1px solid var(--bd);
  z-index: 40;
  transform: translateX(-100%);
  transition: transform 0.22s;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  box-sizing: border-box;
}
body.nav #drawer {
  transform: none;
}
.dh {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.dh > div {
  min-width: 0;
}
.dt {
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1.2;
}
.dsec {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mu);
  margin: clamp(6px, 1.6vh, 18px) 6px 4px;
}
.ni {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--tx);
  border: 0;
  padding: clamp(4px, 1.1vh, 11px) 12px;
  border-radius: 10px;
  font-size: 1rem;
}
.nirow {
  display: flex;
  gap: 4px;
}
.nirow .ni:first-child {
  flex: 1;
}
#theme2 {
  width: auto;
  flex: 0 0 auto;
}
.ni.on {
  background: color-mix(in srgb, var(--ac) 16%, transparent);
  color: var(--ac);
  font-weight: 600;
}
.dfoot {
  margin: auto 6px 0;
  padding-top: 8px;
}
.dver {
  margin: 6px 6px 0;
  font-size: 0.78rem;
}
.pg {
  display: none;
}
.pg.on {
  display: block;
}
@media (min-width: 900px) {
  #drawer {
    transform: none;
  }
  #scrim {
    display: none;
  }
  .burger {
    display: none;
  }
  body {
    padding-left: 316px;
  }
  .top {
    margin: -16px -16px 10px 0;
  }
}
@media print {
  .np,
  .top,
  #drawer,
  #scrim,
  button,
  #exp,
  #rst {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
    padding: 0 !important;
  }
  .card {
    border: 0;
    margin: 8px 0;
  }
  tr {
    break-inside: avoid;
  }
  td input {
    border: 0;
    background: none;
    width: auto;
  }
  body.pr main {
    display: none !important;
  }
  body.pr #pv {
    display: block;
  }
  body.pr {
    background: #fff !important;
    color: #000 !important;
  }
  .mp {
    border: 0;
    padding: 0;
  }
}

#theme {
  margin-left: auto;
}
.secrow {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto auto auto;
  gap: 6px;
  margin-bottom: 8px;
}
.secrow button {
  padding: 7px 9px;
}
.cfglogo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.cfglogo img {
  height: 56px;
  max-width: 120px;
  object-fit: contain;
  background: #fff;
  border-radius: 10px;
  padding: 3px;
}
.filebtn {
  display: inline-block;
  width: auto;
  cursor: pointer;
  border: 1px solid var(--bd);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 1rem;
  color: var(--mu);
}
@media (max-width: 560px) {
  .secrow {
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--bd);
  }
  .secrow input:first-child {
    grid-column: 1 / -1;
  }
}

/* Tableaux longs : la ligne de titre reste visible quand on fait défiler la page (--topH : hauteur de la barre du haut, mesurée au démarrage) */
.w.st {
  overflow: visible;
}
.st th {
  position: sticky;
  top: var(--topH, 49px);
  z-index: 1;
  background: var(--card);
  box-shadow: 0 1px 0 var(--bd);
}
/* Recettes : le tableau peut défiler de côté, donc il a son propre cadre ; le titre reste en haut du cadre */
.w.sv {
  max-height: calc(100dvh - var(--topH, 49px) - 24px);
  overflow: auto;
}
.sv th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--card);
  box-shadow: 0 1px 0 var(--bd);
}
@media print {
  .w.sv {
    max-height: none;
  }
  .w.st {
    overflow: visible;
  }
}
/* Régimes sur téléphone : un bloc par régime, un seul déplié à la fois */
#dlist details.rg {
  border: 1px solid var(--bd);
  border-radius: 10px;
  padding: 0 10px;
  margin-top: 8px;
}
#dlist details.rg[open] {
  padding-bottom: 6px;
}
#dlist .rg summary {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
  font-weight: 600;
}
#dlist .rgn {
  color: var(--ac);
  white-space: nowrap;
}
#dlist .rgl {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
  padding: 5px 0;
  border-top: 1px solid var(--bd);
  font-size: 0.9rem;
}
#dlist .rgl small {
  margin-left: 6px;
  color: var(--mu);
  font-size: 0.75rem;
}
#dlist .rgl input {
  width: 76px;
  flex: none;
  text-align: center;
}
/* Ordinateur : en-têtes des recettes plus lisibles (sur téléphone, taille réduite et stable) */
@media (min-width: 900px) {
  .fit.rec th {
    font-size: 0.85rem;
  }
  .fit.rec th .s {
    font-size: 0.72rem;
  }
}
#fname {
  display: inline-block;
  max-width: 100%;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Menu : chaque jour se replie, avec son résumé « (x plats / x repas) » */
summary.dhd {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  cursor: pointer;
  list-style: none;
}
summary.dhd::-webkit-details-marker {
  display: none;
}
summary.dhd::before {
  content: "▸";
  flex: none;
}
details[open] > summary.dhd::before {
  content: "▾";
}
.dhd .dc {
  margin-left: auto;
  font-size: 0.8rem;
  font-weight: 400;
  opacity: 0.85;
  white-space: nowrap;
}
/* Menu : « Copier le menu d'un autre camp » — liste pleine largeur sur téléphone, bouton dessous */
.mcprow {
  grid-template-columns: minmax(0, 1fr);
  margin-top: 12px;
}
.mcprow select {
  width: 100%;
}
.mcprow button {
  width: 100%;
}
@media (min-width: 560px) {
  .mcprow {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .mcprow button {
    width: auto;
  }
}
/* Régimes : champ dépassant l'effectif de la section, et message d'erreur */
input.bad {
  border-color: #c0392b;
  background: light-dark(#fdecea, #3b1f1c);
  color: light-dark(#7a1f16, #f2b8b5);
}
.derr {
  margin: 6px 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: light-dark(#b3261e, #f2b8b5);
}
#dlist details.rg.bad {
  border-color: #c0392b;
}
#dlist details.rg.bad summary::after {
  content: "⚠️";
}
.ef {
  font-weight: 400;
  color: var(--mu);
  white-space: nowrap;
}
#dh .ef {
  display: block;
}
/* Liste de courses : quantités, prix et coûts alignés à droite */
th.num,
#list td:nth-child(n + 2) {
  text-align: right;
}
#list td:nth-child(2) {
  white-space: nowrap;
}
/* Catalogue de prix : seule la colonne des prix est alignée à droite */
#ct td:nth-child(3) {
  text-align: right;
}
#list td:nth-child(3) input,
#ct td:nth-child(3) input {
  display: block;
  margin-left: auto;
  text-align: right;
}

/* Recettes : saisie « X pour N personnes » */
.rtf,
.rimpr {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
}
.rtf input {
  width: 52px;
  min-width: 0;
}
.rtf button {
  flex-shrink: 0;
}
.rtf .s[data-rp] {
  flex-basis: 100%;
}
/* dans la fiche d'un ingrédient de recette : encadré, au-dessus des champs du catalogue */
.ced .rtf {
  position: sticky;
  left: 0;
  width: calc(100cqw - 16px);
  box-sizing: border-box;
  white-space: normal;
  margin: 0 0 10px;
  padding: 8px 10px;
  border: 1px solid var(--ac);
  border-radius: 8px;
  background: var(--grp);
}

/* Catalogue de prix : modification d'un ingrédient */
/* Page Recettes : la fiche reste dans la partie visible du tableau (qui défile en largeur), sans l'élargir */
.rw {
  container-type: inline-size;
}
.rw .fw {
  position: sticky;
  left: 0;
  width: calc(100cqw - 16px);
  box-sizing: border-box;
  white-space: normal;
}
.ced td {
  background: var(--grp);
}
/* panneau de modification : Nom / Unité / Prix, puis Régime / Rayon, l'info, puis les boutons */
.edg {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}
.edg .eg-nom,
.edg .eg-libelle,
.edg .eg-lien,
.edg .eg-vrac {
  grid-column: span 6;
}
.eg-vrac .vrac {
  align-items: end;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--ac);
  border-radius: 8px;
}
.fit td .edg .eg-vrac .vrac input[type="number"] {
  width: 100%;
  max-width: none;
  padding: 0 10px;
  text-align: left;
}
.eg-vrac .vrac[hidden] {
  display: none;
}
.eg-vrac .vrac .s {
  grid-column: span 2;
}
.edg .eg-uni,
.edg .eg-prix,
.edg .eg-reg,
.edg .eg-ray {
  grid-column: span 3;
}
.edg input,
.edg select {
  height: 38px;
}
.edg input {
  width: 100%;
  padding: 0 10px;
}
.ced [data-ei] {
  margin-top: 8px;
}
.eg-btn,
.dpg .row2 {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
@media (min-width: 640px) {
  .edg .eg-nom,
  .edg .eg-reg,
  .edg .eg-ray {
    grid-column: span 3;
  }
  .edg .eg-uni {
    grid-column: span 2;
  }
  .edg .eg-prix {
    grid-column: span 1;
  }
}

/* liste des rayons du catalogue : deux fois plus large (toute la largeur de la ligne) */
#crayon {
  width: 100%;
}
.promo {
  color: var(--ac);
}

/* Liste de courses groupée par rayon */
#list tr.grp td {
  background: var(--grp);
  color: var(--tx);
  padding-top: 8px;
}

/* Import d'une recette : une carte par ligne d'ingrédient */
.rimpl {
  border-top: 1px solid var(--bd);
  padding: 8px 0;
}
.rimpr select {
  width: auto;
  max-width: 100%;
}
.rimpr input[type="text"] {
  width: 220px;
  max-width: 100%;
}

/* Fenêtres du catalogue : import des prix, nouvel ingrédient, fusion */
#impdlg,
#ingdlg,
#mgdlg,
#dpdlg {
  width: min(640px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--bd);
  border-radius: 12px;
  background: var(--card);
  color: var(--tx);
  box-sizing: border-box;
}
/* fenêtre de fusion : la liste de choix est descendue d'un cran pour aérer l'écran */
#mgdlg label[for="mgb"] {
  margin-bottom: 8px;
}
#mgdlg #mgb {
  margin-bottom: 14px;
}
#mgdlg fieldset label {
  margin-bottom: 6px;
}
#mgdlg #mgp {
  margin-top: 14px;
}
#impdlg::backdrop,
#ingdlg::backdrop,
#mgdlg::backdrop,
#dpdlg::backdrop {
  background: rgba(0, 0, 0, 0.5);
}
/* Boutons Importer / Annuler : toujours visibles en bas de la fenêtre, même quand l'aperçu est long */
#impdlg {
  padding-bottom: 0;
}
#impdlg .impb {
  position: sticky;
  bottom: 0;
  margin: 10px -14px 0;
  padding: 10px 14px 14px;
  background: var(--card);
  border-top: 1px solid var(--bd);
}
#impdlg textarea,
#ingdlg input,
#ingdlg select,
#mgdlg select {
  width: 100%;
  box-sizing: border-box;
}

/* Fenêtre « Vérifier les doublons » : un bloc par groupe de doublons */
.dpg {
  border-top: 1px solid var(--bd);
  padding: 10px 0;
}

/* Aperçu détaillé de l'import de prix : ce qui change par rapport au catalogue */
#cmp .cmpc {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
}
#cmp .cmpc span {
  border: 1px solid var(--bd);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.85rem;
}
#cmp .cmpl {
  max-height: 46vh;
  overflow: auto;
  border-top: 1px solid var(--bd);
}
#cmp.seul .cmpi.egal {
  display: none;
}
#cmp .cmpi {
  padding: 8px 0;
  border-bottom: 1px solid var(--bd);
}
#cmp .cmph {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
#cmp .hausse .cmpd {
  color: #d33;
}
#cmp .baisse .cmpd {
  color: #1f7a3f;
}
#cmp .cmpi a {
  display: inline-block;
  padding: 4px 0;
}

/* Effectif réduit d'un repas */
.zp {
  font-size: 0.72rem;
  white-space: nowrap;
  opacity: 0.8;
}
.zp.red {
  font-weight: 700;
  opacity: 1;
}
.zeff {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--bd);
}
.zsec {
  display: flex;
  gap: 8px 12px;
  flex-wrap: wrap;
  flex-basis: 100%;
}
.zsec label {
  display: grid;
  gap: 2px;
  font-size: 0.8rem;
  margin: 0;
}
.zeff input {
  width: 72px;
}
.zeff select {
  max-width: 230px;
}
.zeff > .s:last-child {
  flex-basis: 100%;
}

/* Page Nouveautés : une ligne repliable par version */
.nv {
  border-top: 1px solid var(--bd);
  padding: 8px 0;
}
.nv summary {
  cursor: pointer;
  padding: 4px 0;
}
.nv ul {
  margin: 6px 0 4px;
  padding-left: 20px;
}
.nv li {
  margin: 4px 0;
}

/* Gérer les rayons */
.rayrow {
  grid-template-columns: 1fr auto;
}
@media (max-width: 560px) {
  .rayrow {
    grid-template-columns: 1fr;
  }
}
.ryx {
  margin: 0 0 8px;
  padding: 8px;
  border-radius: 8px;
  background: var(--grp);
}
.ryx select {
  width: auto;
  max-width: 100%;
}

/* Description d'une recette : lecture mise en forme (gras, souligné) et barre de mise en forme en édition */
.rdv {
  min-height: 84px;
  padding: 8px 10px;
  border: 1px solid var(--bd);
  border-radius: 8px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.rtb {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 4px 0;
}
.rtb button {
  min-width: 40px;
  white-space: nowrap;
}
.rtb .s {
  flex-basis: 100%;
}
/* les boutons G, S, I et l'aide rejoignent la rangée du bouton Aperçu */
#rfmt {
  display: contents;
}

#mprev .adb {
  padding: 0 6px;
  font-size: 0.8rem;
  margin-left: 4px;
  font-style: normal;
}

#mprev .ade {
  margin: 4px 0;
  font-style: normal;
  min-width: min(240px, 60vw);
}

#mprev .ade textarea {
  width: 100%;
  font: inherit;
  font-size: 0.85rem;
  margin-bottom: 4px;
}

#mprev .ade .x {
  font-size: 0.8rem;
  padding: 4px 8px;
}

#mprev {
  overflow-x: auto;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 6px 0;
}

.chip {
  border-radius: 999px;
  padding: 3px 11px;
  border: 1px solid var(--bd);
  background: var(--card);
  color: var(--tx);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}

.chip.on {
  background: var(--ac);
  border-color: var(--ac);
  color: #fff;
}

.chip.on .s {
  color: inherit;
}

.chip.sug {
  border-style: dashed;
}

.rtags,
.rfiltre {
  margin: 8px 0;
}

.rtags .row {
  margin-top: 6px;
}

/* Page Recettes : barre d'actions, puis une ligne par recette */
.rbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}

.rlist {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
}

.rl {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px 3px 3px;
  border: 1px solid var(--bd);
  border-radius: 10px;
  background: var(--card);
}

.rl.on {
  border-color: var(--ac);
}

.rl .rln {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  border: 0;
  background: transparent;
  color: var(--tx);
  font: inherit;
  font-weight: 600;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.rl .x {
  min-width: 38px;
  padding: 5px 9px;
  font-size: 1.05rem;
  line-height: 1.2;
}

/* Fenêtre d'édition d'une recette : Enregistrer / Annuler restent visibles en bas, même quand le tableau est long */
#rdlg {
  width: min(980px, calc(100vw - 16px));
  max-height: calc(100dvh - 16px);
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--bd);
  border-radius: 12px;
  background: var(--card);
  color: var(--tx);
  box-sizing: border-box;
}

#rdlg::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

#rdlg input#rename {
  width: 100%;
  box-sizing: border-box;
}

/* Pas de défilement propre au tableau : c'est la fenêtre qui défile */
#rdlg .w.sv {
  max-height: none;
  overflow: visible;
}

/* Lignes d'ingrédients un peu plus serrées */
#rdlg .fit.rec th,
#rdlg .fit.rec td {
  padding: 2px 3px;
  line-height: 1.15;
}

#rdlg .fit.rec td input[type="number"] {
  padding: 2px 2px;
  line-height: 1.1;
}

#rdlg .rdb {
  position: sticky;
  bottom: -14px;
  margin: 10px -14px -14px;
  padding: 10px 14px;
  background: var(--card);
  border-top: 1px solid var(--bd);
}

@media (max-width: 700px) {
  #rdlg {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
    border: 0;
  }
}

/* Aperçu de la description (gras, souligné, italique) sous le champ de saisie */
#rdv {
  margin: 2px 0 8px;
  padding: 8px 10px;
  border: 1px dashed var(--bd);
  border-radius: 8px;
  background: var(--bg);
  overflow-wrap: anywhere;
}

/* Catalogue : titre et filtre « sans prix » sur la même ligne, filtre à droite */
.chead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  margin: 14px 0 6px;
}

.chead h2 {
  margin: 0;
}

.csans {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 0.85rem;
  text-align: right;
}

.csans input {
  margin: 0;
  width: auto;
  flex: none;
}

.csans span {
  white-space: nowrap;
}

/* Les colonnes gardent leur largeur, que la liste soit filtrée ou non */
table.fit.tcat {
  table-layout: fixed;
}

.tcat th:nth-child(2),
.tcat td:nth-child(2) {
  width: 74px;
}

.tcat th:nth-child(3),
.tcat td:nth-child(3) {
  width: 84px;
}

.tcat th:nth-child(4),
.tcat td:nth-child(4) {
  width: 46px;
}

/* Page Recettes : lignes aussi serrées que celles du tableau des ingrédients */
.rlist {
  gap: 2px;
}

.rl {
  padding: 1px 4px 1px 2px;
  border-radius: 6px;
}

.rl .rln {
  padding: 5px 8px;
  font-size: 0.86rem;
  line-height: 1.2;
}

.rl .x {
  min-width: 30px;
  padding: 2px 7px;
  font-size: 0.9rem;
  line-height: 1.1;
}

/* Listes longues (Recettes, Ingrédients d'une recette) : même police que les tableaux de saisie (Régimes), lignes les plus serrées possible */
.rl .rln {
  padding: 5px 8px;
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.4;
}

#rb .ibox {
  border-radius: 8px;
  padding: 0 4px;
}

#rb .ib {
  min-height: 28px;
  padding: 2px 4px;
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.3;
}

#rb .ih {
  padding: 4px;
  font-size: 1rem;
}

#rdlg .fit.rec td input[type="number"] {
  padding: 4px 2px;
  font-size: 0.9rem;
  line-height: 1.2;
}

#rb td:last-child button.x {
  min-width: 30px;
  padding: 3px 8px;
  font-size: 0.9rem;
  line-height: 1.2;
}

/* Pied de la fenêtre de recette : les trois boutons tiennent sur une ligne, même sur téléphone */
#rdlg .rdb {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#rdlg .rdb button {
  padding: 8px 10px;
  font-size: 0.9rem;
}

/* Téléphone : rien ne doit dépasser de l'écran */
@media (max-width: 700px) {
  /* filtre « sans prix » du catalogue : le texte peut passer à la ligne */
  .csans {
    margin-left: 0;
    text-align: left;
  }

  .csans span {
    white-space: normal;
  }

  /* fiche de recette : le tableau défile de côté dans son cadre (pas la fenêtre), le nom de l'ingrédient reste visible */
  #rdlg .w.sv {
    overflow-x: auto;
    overflow-y: visible;
  }

  #rdlg .fit.rec th:first-child,
  #rdlg .fit.rec td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    min-width: 128px;
    max-width: 150px;
    background: var(--card);
  }

  #rdlg .fit.rec th:not(:first-child) {
    min-width: 58px;
    max-width: 72px;
  }

  #rdlg .fit.rec td input[type="number"] {
    width: 60px;
  }

  #rdlg .rdb button {
    padding: 8px 7px;
    font-size: 0.82rem;
  }
}

/* Zones de toucher : au moins 24 px de haut (WCAG 2.2) sans agrandir les lignes */
.rl .x {
  min-width: 34px;
  min-height: 28px;
}

.zn {
  min-height: 26px;
}

/* Fenêtres de listes modifiables (Gérer les rayons, Gérer les types) : titre et liste qui défilent, pied toujours visible */
.ldlg {
  width: min(600px, calc(100vw - 16px));
  max-height: calc(100dvh - 16px);
  padding: 0;
  border: 1px solid var(--bd);
  border-radius: 12px;
  background: var(--card);
  color: var(--tx);
  box-sizing: border-box;
}

.ldlg[open] {
  display: flex;
  flex-direction: column;
}

.ldlg::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.ldlg-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 14px 4px;
}

.ldlg-body h2 {
  margin-top: 0;
}

.ldlg-foot {
  padding: 8px 14px 12px;
  border-top: 1px solid var(--bd);
  background: var(--card);
}

.ldlg-foot p {
  margin: 4px 0;
}

.lrow,
.ladd {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 6px 0;
}

.lrow input,
.ladd input {
  flex: 1;
  min-width: 0;
}

.lrow .ln {
  white-space: nowrap;
  min-width: 5.6em;
  text-align: right;
}

.lrow .lvide {
  width: 38px;
}

.lbtn {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Téléphone : fenêtre pleine largeur, lignes compactes sur une seule ligne, effectif réduit à son nombre */
@media (max-width: 700px) {
  .ldlg {
    width: calc(100vw - 8px);
    max-height: calc(100dvh - 8px);
  }

  .ldlg-body {
    padding: 10px 10px 2px;
  }

  .ldlg-body h2 {
    font-size: 1.1rem;
    margin-bottom: 4px;
  }

  .ldlg-body > p.s {
    font-size: 0.8rem;
    margin: 0 0 6px;
  }

  .lrow {
    gap: 4px;
    margin: 3px 0;
  }

  .lrow button.x {
    min-width: 34px;
    min-height: 34px;
    padding: 2px 6px;
  }

  .lrow input {
    padding: 6px 8px;
  }

  .lrow .lw {
    display: none;
  }

  .lrow .ln {
    min-width: 1.4em;
    text-align: right;
  }

  .lrow .lvide {
    width: 34px;
  }

  .ldlg-foot {
    padding: 6px 10px 8px;
  }
}

/* Barres de boutons (catalogue, recettes) : libellés courts et une seule rangée sur téléphone */
.co {
  display: none;
}

@media (max-width: 700px) {
  .barb .lo {
    display: none;
  }

  .barb .co {
    display: inline;
  }

  .barb {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin: 6px 0;
  }

  .rbar.barb {
    grid-template-columns: repeat(3, 1fr);
  }

  .barb button {
    padding: 6px 8px;
    font-size: 0.92rem;
    white-space: nowrap;
  }

  .barb .s {
    grid-column: 1 / -1;
  }

  .barb .s:empty {
    display: none;
  }

  /* pastilles du filtre : plus petites, pour tenir sur moins de lignes */
  .rfiltre .chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
  }

  .rfiltre .chip {
    margin: 0;
    padding: 2px 8px;
    font-size: 0.85rem;
  }
}
