/* Épicerie — PWA. Mobile d'abord, thème clair/sombre, impression. Aucune ressource externe. */
:root {
  --bg: #F7F8F6; --fg: #1C2420; --muted: #5D6A63; --line: #D9DED9; --surface: #FFFFFF;
  --accent: #2F6B4F; --accent-soft: #E3EFE7; --tag: #F2D25C; --tag-ink: #3A3000; --warn: #B4532A; --warn-soft: #FBE9E2;
  --plate: #EDEFEC; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121815; --fg: #E4EAE6; --muted: #9AA8A0; --line: #2C3631; --surface: #1B2420; --accent: #7CC09C; --accent-soft: #1E3328;
          --tag: #E9C84A; --tag-ink: #2A2200; --warn: #E08A62; --warn-soft: #3A251C; --plate: #18201C; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
       padding-top: var(--safe-t); display: flex; flex-direction: column; min-height: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
a { color: var(--accent); }

/* Accueil */
body.accueil { align-items: center; justify-content: center; padding: 24px 16px; }
.carte-accueil { max-width: 420px; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px 22px; text-align: center; }
.carte-accueil .logo { font-size: 44px; }
.carte-accueil h1 { font-size: 28px; margin: 6px 0 10px; }
.carte-accueil p { color: var(--muted); }
.carte-accueil form { justify-content: center; margin: 14px 0; }
.version { font-size: 12px; opacity: .7; }

/* Coquille */
.entete { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px 8px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.entete h1 { font-size: 20px; }
.entete small { color: var(--muted); display: block; font-size: 13px; }
.vue { flex: 1; padding: 12px 16px calc(84px + var(--safe-b)); max-width: 760px; width: 100%; margin: 0 auto; }
.onglets { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); z-index: 5; }
.onglets a { text-align: center; padding: 10px 2px 8px; font-size: 12px; color: var(--muted); text-decoration: none; font-weight: 600; }
.onglets a.on { color: var(--accent); border-top: 2px solid var(--accent); margin-top: -1px; }
.bandeau { background: var(--tag); color: var(--tag-ink); text-align: center; font-size: 13px; padding: 6px; }

/* Éléments de base */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent); color: #fff; border: 0; border-radius: 9px; padding: 9px 14px; font-weight: 700; cursor: pointer; text-decoration: none; min-height: 40px; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.ghost.danger { color: var(--warn); border-color: var(--warn); }
.btn.small { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn.grand { width: 100%; font-size: 17px; padding: 12px; }
.btn[disabled] { opacity: .5; cursor: default; }
input[type=text], input[type=number], input[type=url], select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); min-height: 40px; }
textarea { min-height: 140px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin: 8px 0 2px; }
label.case { display: flex; align-items: center; gap: 8px; color: var(--fg); font-weight: 500; }
.row { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.row > label { flex: 1; min-width: 120px; }
.note { color: var(--muted); font-size: 13px; }
.chip { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 700; vertical-align: middle; }
.chip.y { background: var(--tag); color: var(--tag-ink); }
.chip.w { background: var(--warn-soft); color: var(--warn); }
.vide { text-align: center; color: var(--muted); padding: 40px 10px; }
.vide b { display: block; color: var(--fg); font-size: 18px; margin-bottom: 6px; }

/* Ajout */
.ajout { display: flex; gap: 8px; margin-bottom: 10px; }
.ajout input { flex: 1; }
.ajout button { width: 48px; min-width: 48px; font-size: 22px; padding: 0; }

/* Liste */
.compte { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 10px; font-size: 14px; color: var(--muted); }
.rayon { margin-bottom: 14px; }
.rayon h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); display: flex; justify-content: space-between; padding: 0 2px 4px; }
.rayon .allee { text-transform: none; letter-spacing: 0; font-weight: 600; }
.carte { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.el { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-bottom: 1px dashed var(--line); }
.el:last-child { border-bottom: 0; }
.el input[type=checkbox] { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.el .t { flex: 1; min-width: 0; cursor: pointer; }
.el .t b { font-weight: 600; display: block; }
.el .t small { display: block; color: var(--muted); font-size: 12px; }
.el .q { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; padding-top: 2px; }
.el.coche .t b { text-decoration: line-through; color: var(--muted); }
.el.reporte .t b { color: var(--muted); }
.el .plus { background: transparent; border: 0; color: var(--muted); font-size: 20px; line-height: 1; padding: 0 2px; cursor: pointer; }
.el .btn.small { white-space: nowrap; }
details.panier summary { cursor: pointer; color: var(--muted); font-size: 14px; padding: 6px 2px; }

/* Magasin */
.barre { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 6px 0 14px; }
.barre i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.choix-magasin { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.choix-magasin select { flex: 1; }
.terminer { margin-top: 18px; text-align: center; }

/* Recettes */
.apercu { margin-top: 14px; }
.apercu .el .q { font-size: 14px; }
.recettes-liste { list-style: none; margin: 0; padding: 0; }
.recettes-liste li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); }

/* Historique */
.histo li { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px dashed var(--line); cursor: pointer; }
.histo li:last-child { border-bottom: 0; }

/* Feuille (dialog) */
dialog.feuille { border: 0; border-radius: 16px 16px 0 0; padding: 18px 16px calc(16px + var(--safe-b)); width: 100%; max-width: 560px; margin: auto auto 0; background: var(--surface); color: var(--fg); }
dialog.feuille::backdrop { background: rgba(0,0,0,.35); }
dialog.feuille h2 { font-size: 18px; margin-bottom: 4px; }
dialog.feuille .actions { margin-top: 14px; }
dialog.feuille .actions .btn { flex: 1; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(76px + var(--safe-b)); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 20; max-width: 92vw; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.erreur { background: var(--warn); color: #fff; }

/* Moi */
.membres li { display: flex; justify-content: space-between; padding: 8px 12px; border-bottom: 1px dashed var(--line); }
.membres li:last-child { border-bottom: 0; }

@media (min-width: 800px) {
  .onglets { left: 50%; right: auto; transform: translateX(-50%); width: 760px; border: 1px solid var(--line); border-bottom: 0; border-radius: 12px 12px 0 0; }
  .entete { padding-left: calc(50% - 380px); padding-right: calc(50% - 380px); }
}
@media print {
  /* Feuille compacte : deux colonnes, une ligne par article (nom, note, quantité), sans provenance ni panier. */
  @page { margin: 10mm; }
  .entete button, .onglets, .ajout, .bandeau, .toast, dialog, .plus, .btn, .choix-magasin, .terminer, .compte, .barre, .el.coche, .el .t small .prov, details.panier, .vide { display: none !important; }
  html, body { background: #fff; color: #000; font-size: 10.5px; line-height: 1.25; }
  .entete { position: static; padding: 0 0 3px; border-bottom: 1px solid #000; background: none; }
  .entete h1 { font-size: 13px; display: inline; }
  .entete small { display: inline; margin-left: 8px; font-size: 10px; color: #000; }
  .vue { padding: 4px 0 0; max-width: none; columns: 2; column-gap: 8mm; column-rule: 1px solid #ccc; }
  .rayon { break-inside: avoid; margin: 0 0 4px; }
  .rayon h2 { font-size: 9px; letter-spacing: .04em; color: #000; padding: 0 0 1px; margin: 0 0 1px; border-bottom: 1px solid #000; }
  .carte { border: 0; border-radius: 0; background: none; }
  .el { padding: 1px 0; gap: 5px; align-items: center; border-bottom: 1px dotted #bbb; }
  .el input[type=checkbox] { appearance: none; -webkit-appearance: none; width: 9px; height: 9px; margin: 0; border: 1px solid #000; border-radius: 2px; }
  .el .t b { display: inline; font-weight: 600; }
  .el .t small { display: inline; margin-left: 4px; font-size: 9px; color: #333; }
  .el .q { color: #000; font-size: 10px; padding-top: 0; }
  .el.reporte .t b { color: #000; font-style: italic; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Page Confidentialité (Loi 25) : la carte d'accueil, en plus large et alignée à gauche */
.carte-accueil.texte { max-width: 640px; text-align: left; }
.carte-accueil.texte h2 { font-size: 18px; margin: 18px 0 6px; }
.carte-accueil.texte p { text-align: left; }
.carte-accueil.texte table { width: 100%; border-collapse: collapse; font-size: 14px; color: var(--muted); }
.carte-accueil.texte th, .carte-accueil.texte td { text-align: left; padding: 6px 4px; border-top: 1px solid var(--line); vertical-align: top; }
