:root {
  --pico-font-size: 100%;
  --accent: #2a9d8f;
}
body { padding-bottom: env(safe-area-inset-bottom); }
main.container { padding-top: 1rem; }
h1 { font-size: 1.6rem; margin-bottom: .75rem; }
h2 { font-size: 1.25rem; margin-top: 1.5rem; }
h3 { font-size: 1.05rem; margin-bottom: .4rem; }

/* Barre de navigation */
.barre { border-bottom: 1px solid var(--pico-muted-border-color); background: var(--pico-card-background-color); }
.barre nav { padding-inline: 0; }
.barre nav ul li { padding: .3rem .4rem; }
.barre .marque { text-decoration: none; }
.barre button.compact { padding: .25rem .6rem; font-size: .85rem; margin: 0; }
form.inline { margin: 0; }
.pastille { display: inline-flex; align-items: center; gap: .4rem; text-decoration: none; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.8rem; height: 1.8rem; border-radius: 50%;
  background: var(--couleur, var(--accent)); color: #fff; font-weight: 700;
}
.avatar.grand { width: 4.5rem; height: 4.5rem; font-size: 2rem; }

/* Sélecteur de profil */
.grille-profils { display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); gap: 1rem; }
.grille-profils form { margin: 0; }
.carte-profil {
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: .6rem;
  padding: 1.2rem .5rem; background: var(--pico-card-background-color); color: var(--pico-color);
  border: 2px solid var(--pico-muted-border-color); border-radius: 1rem;
}
.carte-profil:hover, .carte-profil:focus { border-color: var(--couleur, var(--accent)); }

/* Cartes */
.grille-cartes { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; }
.carte {
  display: block; padding: 1rem; margin: 0; text-decoration: none; color: inherit;
  background: var(--pico-card-background-color); border: 1px solid var(--pico-muted-border-color); border-radius: .75rem;
}
a.carte:hover { border-color: var(--accent); }
.carte.a-venir { opacity: .6; }
.carte p { margin: 0; font-size: .9rem; }
.etroit { max-width: 26rem; margin: 2rem auto; }
.erreur { color: #c0392b; }
.message { padding: .75rem 1rem; margin-bottom: 1rem; }
.message.alerte { border-left: 4px solid #e76f51; }
.meta { color: var(--pico-muted-color); font-size: .9rem; }

/* Recherche */
.ligne-recherche { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.ligne-recherche input[type=search] { margin-bottom: 0; }
details#filtres summary a { font-weight: 400; font-size: .85rem; }
.fil { font-size: .9rem; margin-bottom: .4rem; display: block; }
.puces { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; }
.puce {
  font-size: .82rem; padding: .2rem .6rem; border-radius: 999px; text-decoration: none;
  background: var(--pico-card-background-color); border: 1px solid var(--pico-muted-border-color); color: inherit;
}
.puce:hover { border-color: var(--accent); }
details#filtres { margin-bottom: .5rem; }
details#filtres summary { font-size: .95rem; }
.colonnes { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; }
.colonnes fieldset { margin: 0; }
.colonnes label { font-size: .9rem; margin-bottom: .2rem; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-block; }
.compte { color: var(--pico-muted-color); font-size: .85rem; margin-bottom: .3rem; }
.vide { color: var(--pico-muted-color); }

/* Tableaux */
.tableau-defilant { overflow-x: auto; }
table.aliments, table.teneurs { font-size: .9rem; }
table.aliments td, table.aliments th, table.teneurs td, table.teneurs th { padding: .45rem .5rem; }
table.aliments td small { display: block; color: var(--pico-muted-color); font-size: .75rem; }
table.aliments tr.exclu td { opacity: .55; }
th.triable a { color: inherit; text-decoration: none; white-space: nowrap; }
th.triable a:hover { color: var(--accent); }
th.triable .fleche { display: inline-block; width: .9em; margin-left: .15em; color: var(--pico-muted-color); font-size: .8em; }
th.triable:hover .fleche::after { content: "▾"; opacity: .4; }
th.triable.asc .fleche::after, th.triable.asc:hover .fleche::after { content: "▴"; opacity: 1; color: var(--accent); }
th.triable.desc .fleche::after, th.triable.desc:hover .fleche::after { content: "▾"; opacity: 1; color: var(--accent); }
table.compacte td { padding: .25rem .5rem; font-size: .85rem; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.confiance { color: var(--pico-muted-color); margin-left: .3rem; }
.badge { font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; white-space: nowrap; }
.badge.bas { background: #d8f3dc; color: #1b4332; }
.badge.milieu { background: #e9ecef; color: #343a40; }
.badge.haut { background: #ffe5d9; color: #7f2704; }
.pagination { display: flex; justify-content: space-between; align-items: center; margin: 1rem 0; font-size: .9rem; }
ul.simple { padding-left: 1.1rem; margin: 0; }
ul.simple li { margin-bottom: .2rem; }

@media (max-width: 600px) {
  .barre nav ul li { padding: .2rem .25rem; }
  .barre nav ul li a, .barre nav ul li button { font-size: .85rem; }
  h1 { font-size: 1.35rem; }
}

/* En-tête de page avec actions */
.entete-page { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.entete-page h1 { margin: 0; }
.entete-page [role=button], .entete-page button { margin: 0; padding: .4rem .9rem; font-size: .9rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.vide-appel { text-align: center; padding: 2rem; }
.etiquette { display: inline-block; font-size: .72rem; padding: 0 .45rem; border-radius: 999px; background: #e9f5f3; color: #1b4b45; margin-left: .3rem; }
.attention { color: #b7410e; }

/* Liste des recettes */
table.recettes td.vignette, table.recettes th.vignette { width: 3.2rem; padding: .25rem; }
table.recettes img, .sans-photo { width: 2.8rem; height: 2.8rem; object-fit: cover; border-radius: .5rem; display: block; }
.sans-photo { background: var(--pico-muted-border-color); }
table.recettes td small { display: block; color: var(--pico-muted-color); font-size: .75rem; }

/* Détail */
.colonnes-detail { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 900px) { .colonnes-detail { grid-template-columns: 3fr 2fr; } }
.photo-recette { width: 100%; max-height: 24rem; object-fit: cover; border-radius: .75rem; margin-bottom: 1rem; }
.photo-recette.petite { max-width: 12rem; max-height: 8rem; display: block; margin: .3rem 0; }
ul.ingredients { list-style: none; padding: 0; }
ul.ingredients li { padding: .4rem 0; border-bottom: 1px solid var(--pico-muted-border-color); }
ul.ingredients small { color: var(--pico-muted-color); }
ol.etapes li { margin-bottom: .5rem; }
.message.compacte { padding: .5rem .8rem; font-size: .9rem; }
form.avis { display: flex; gap: .5rem; margin: 0; }
form.avis button { margin: 0; padding: .35rem .7rem; font-size: .9rem; }
form.avis button.actif { border-width: 2px; }

/* Éditeur : lignes d'ingrédients */
.formulaire-recette .grid label { margin-bottom: 0; }
.lignes-ingredients { border-top: 1px solid var(--pico-muted-border-color); }
.ligne-ingredient {
  display: grid; grid-template-columns: 1fr 5rem 9rem 7rem auto auto; gap: .4rem; align-items: center;
  padding: .45rem 0; margin: 0; border-bottom: 1px solid var(--pico-muted-border-color);
}
.ligne-ingredient.exclu .nom { color: #b7410e; }
.ligne-ingredient .nom small { display: block; color: var(--pico-muted-color); font-size: .75rem; }
.ligne-ingredient input, .ligne-ingredient select { margin: 0; padding: .3rem .5rem; font-size: .9rem; height: auto; }
.ligne-ingredient .facultatif { font-size: .8rem; margin: 0; white-space: nowrap; }
.ligne-ingredient .supprimer { margin: 0; padding: .2rem .55rem; }
@media (max-width: 700px) {
  .ligne-ingredient { grid-template-columns: 1fr 4.5rem 1fr auto; }
  .ligne-ingredient .nom { grid-column: 1 / -1; }
  .ligne-ingredient .note { display: none; }
}
.resume-apports { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin: .8rem 0 .3rem; font-size: .9rem; }
.ajout-ingredient { margin-top: 1rem; }
ul.resultats-aliments { list-style: none; padding: 0; margin: 0; border: 1px solid var(--pico-muted-border-color); border-radius: .5rem; }
ul.resultats-aliments li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .4rem .7rem; border-bottom: 1px solid var(--pico-muted-border-color); }
ul.resultats-aliments li:last-child { border-bottom: 0; }
ul.resultats-aliments li.exclu span { opacity: .6; }
ul.resultats-aliments small { display: block; color: var(--pico-muted-color); font-size: .75rem; }
ul.resultats-aliments button { margin: 0; padding: .25rem .6rem; font-size: .85rem; white-space: nowrap; }

/* Étiquettes nutritionnelles automatiques */
.badge-nutri { display: inline-block; font-size: .72rem; font-weight: 600; padding: 0 .5rem; border-radius: 999px; margin-right: .25rem; white-space: nowrap; }
.badge-nutri.atout { background: #d8f3dc; color: #1b4332; }
.badge-nutri.vigilance { background: #ffe5d9; color: #7f2704; }
.badges-recette { margin: -.3rem 0 .8rem; }
.puce.atout.active { background: #d8f3dc; border-color: #1b4332; color: #1b4332; }
.puce.vigilance.active { background: #ffe5d9; border-color: #7f2704; color: #7f2704; }
.filtres-qualificatifs { margin: .2rem 0 .8rem; }
.etiquette.incomplet { background: #f1f3f5; color: #6c757d; }
sup.renvoi { color: #b7410e; font-weight: 700; margin-left: .1rem; }
.note-manquants { margin: .4rem 0 0; color: var(--pico-muted-color); }

/* Objectif journalier */
.onglets-membres { margin-bottom: 1rem; }
.onglets-membres .puce { display: inline-flex; align-items: center; gap: .35rem; }
.onglets-membres .puce.active { border-color: var(--couleur, var(--accent)); font-weight: 600; }
.avatar.mini { width: 1.25rem; height: 1.25rem; font-size: .7rem; }
table.objectif { font-size: .9rem; }
table.objectif td, table.objectif th { padding: .45rem .5rem; vertical-align: top; }
table.objectif td small { display: block; color: var(--pico-muted-color); font-size: .75rem; font-weight: 400; }
table.objectif td.total { font-weight: 600; }
table.objectif .tiret { color: var(--pico-muted-border-color); }
table.objectif.saisie input.q { width: 4.6rem; margin: 0; padding: .3rem .4rem; text-align: right; font-size: .9rem; height: auto; }
table.objectif.saisie input.q.total::placeholder { color: var(--pico-muted-color); font-style: italic; }
table.objectif.saisie input.mini { width: 3.6rem; display: inline-block; margin: 0; padding: .1rem .3rem; font-size: .8rem; height: auto; text-align: right; }
table.objectif.saisie input.note { margin: .3rem 0 0; padding: .2rem .4rem; font-size: .8rem; height: auto; width: 100%; }
table.objectif.saisie td.libelle { min-width: 14rem; }
.aide { color: var(--pico-muted-color); font-size: .9rem; }
.copie-objectif { margin-bottom: 1rem; }
.ligne-copie { display: flex; gap: .5rem; align-items: center; }
.ligne-copie select { margin: 0; max-width: 14rem; }
.ligne-copie button { margin: 0; white-space: nowrap; }
.grille-nutriments { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .6rem 1rem; }
.ligne-nutriment { display: flex; gap: .4rem; align-items: center; }
.ligne-nutriment select { margin: 0; width: 7.5rem; }
.ligne-nutriment input { margin: 0; width: 6rem; text-align: right; }
.historique { margin-top: 1.5rem; }
button.lien { border: 0; padding: 0 .3rem; font-size: .8rem; margin: 0; }

/* Planning */
.nav-periode { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin: .5rem 0 1rem; font-size: .95rem; }
.nav-periode strong small { font-weight: 400; color: var(--pico-muted-color); }
table.semaine { font-size: .85rem; table-layout: fixed; min-width: 56rem; }
table.semaine th, table.semaine td { padding: .35rem .4rem; vertical-align: top; }
table.semaine th.creneau { width: 5.5rem; font-weight: 600; color: var(--pico-muted-color); font-size: .8rem; }
table.semaine thead th a { text-decoration: none; }
table.semaine .aujourd-hui { background: #f0faf8; }
table.semaine .elem { font-size: .8rem; line-height: 1.25; padding: .15rem .3rem; margin-bottom: .2rem; border-radius: .3rem; background: var(--pico-card-background-color); border: 1px solid var(--pico-muted-border-color); }
table.semaine .elem.recette { border-left: 3px solid var(--accent); }
table.semaine .elem small { display: block; color: var(--pico-muted-color); font-size: .7rem; }
table.semaine a.ajouter { display: inline-block; font-size: .8rem; color: var(--pico-muted-color); text-decoration: none; padding: 0 .3rem; }
table.semaine a.ajouter:hover { color: var(--accent); }
table.semaine .ligne-kcal td, table.semaine .ligne-activite td { color: var(--pico-muted-color); font-size: .8rem; }
table.semaine.foyer { min-width: 0; }

.colonnes-jour { display: grid; grid-template-columns: 1fr; gap: 1.2rem; }
@media (min-width: 900px) { .colonnes-jour { grid-template-columns: 3fr 2fr; align-items: start; } }
.carte.creneau { margin-bottom: .8rem; padding: .8rem 1rem; }
.carte.creneau header { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .4rem; }
.carte.creneau header h3 { margin: 0; }
.carte.creneau header small { color: var(--pico-muted-color); }
.carte.creneau .vide { margin: .2rem 0 .5rem; font-size: .9rem; }
.ligne-element { display: grid; grid-template-columns: 1fr 4.5rem minmax(4rem, 9rem) auto; gap: .4rem; align-items: center; padding: .35rem 0; margin: 0; border-top: 1px solid var(--pico-muted-border-color); }
.ligne-element.exclu .nom { color: #b7410e; }
.ligne-element .nom small { display: block; color: var(--pico-muted-color); font-size: .75rem; }
.ligne-element input, .ligne-element select { margin: 0; padding: .3rem .5rem; font-size: .9rem; height: auto; }
.ligne-element .unite-fixe { font-size: .85rem; color: var(--pico-muted-color); }
.ligne-element .supprimer { margin: 0; padding: .2rem .55rem; }
.ajout-element { margin-top: .5rem; }
.ajout-element input[type=search] { margin: 0; padding: .4rem .7rem .4rem 2.2rem; font-size: .9rem; height: auto; }
ul.resultats-aliments li.recette { border-left: 3px solid var(--accent); }
.copie-repas, .copie-jour { margin: .5rem 0 0; }
.copie-repas summary, .copie-jour summary { font-size: .85rem; color: var(--pico-muted-color); }
.cibles { display: flex; flex-wrap: wrap; gap: .3rem 1rem; align-items: center; padding: .3rem 0; }
.cibles label { margin: 0; font-size: .9rem; }
.cibles button { margin: 0; }
.carte.activite h3 { margin-bottom: .3rem; }
.form-activite { margin: 0; }
.ligne-activite input[type=number] { width: 6rem; margin: 0; }
.ligne-activite input[type=text] { flex: 1; margin: 0; }

table.bilan { font-size: .9rem; margin-bottom: .3rem; }
table.bilan td { padding: .4rem .5rem; vertical-align: top; }
table.bilan td small { color: var(--pico-muted-color); }
table.bilan tr.sous td:first-child { border-left: 3px solid #f4a261; }
table.bilan tr.ok td:first-child { border-left: 3px solid #2a9d8f; }
table.bilan tr.dessus td:first-child { border-left: 3px solid #e63946; }
.barre-progression { height: .35rem; background: var(--pico-muted-border-color); border-radius: 999px; overflow: hidden; margin-top: .3rem; min-width: 5rem; }
.barre-progression span { display: block; height: 100%; background: var(--accent); }
tr.sous .barre-progression span { background: #f4a261; }
tr.dessus .barre-progression span { background: #e63946; }
.barre-col { width: 8rem; }
.mini-creneaux { display: flex; gap: .25rem; flex-wrap: wrap; margin-top: .2rem; }
.mini-creneaux span { font-size: .65rem; padding: 0 .35rem; border-radius: 999px; background: var(--pico-muted-border-color); color: #333; }
.mini-creneaux span.ok { background: #d8f3dc; color: #1b4332; }
.mini-creneaux span.sous { background: #fde8d7; color: #7f2704; }
.mini-creneaux span.dessus { background: #ffd6d9; color: #7a1c24; }

/* Détail d'une catégorie au survol (bulle css pure, pas de JS) */
.nom-avec-detail { position: relative; display: inline-block; border-bottom: 1px dotted var(--pico-muted-color); cursor: help; }
.bulle-detail {
  visibility: hidden; opacity: 0; position: absolute; z-index: 30; bottom: calc(100% + .4rem); left: 0;
  display: flex; flex-direction: column; gap: .15rem; min-width: 11rem; max-width: 18rem;
  background: #222; color: #fff; padding: .5rem .65rem; border-radius: .5rem; font-size: .78rem; font-weight: 400;
  line-height: 1.3; white-space: normal; box-shadow: 0 2px 10px rgba(0,0,0,.25); transition: opacity .12s ease;
  pointer-events: none;
}
.bulle-detail::after { content: ""; position: absolute; top: 100%; left: 1rem; border: .35rem solid transparent; border-top-color: #222; }
.bulle-detail .ligne-bulle { display: flex; justify-content: space-between; gap: .6rem; }
.bulle-detail .ligne-bulle b { font-weight: 600; white-space: nowrap; }
.nom-avec-detail:hover .bulle-detail, .nom-avec-detail:focus .bulle-detail, .nom-avec-detail:focus-within .bulle-detail {
  visibility: visible; opacity: 1;
}

/* Frigo */
.ajout-stock { margin-bottom: 1.2rem; }
table.stock td { vertical-align: middle; }
table.stock tr.a-racheter td:first-child { border-left: 3px solid #e63946; }
table.stock .quantite-restante { font-weight: 600; white-space: nowrap; }
.alerte-etiquette { background: #ffd6d9; color: #7a1c24; }
.filtre-racheter { display: inline-flex; align-items: center; gap: .3rem; font-size: .85rem; white-space: nowrap; margin: 0; }
.ligne-lot { display: grid; grid-template-columns: 4.5rem minmax(6rem, 9rem) 1fr auto; gap: .4rem; align-items: center; margin: 0; }
.ligne-lot input, .ligne-lot select { margin: 0; padding: .3rem .5rem; font-size: .9rem; height: auto; }
.ligne-lot .supprimer { margin: 0; padding: .2rem .55rem; }
table.stock td small { display: block; color: var(--pico-muted-color); font-size: .72rem; }

/* Liste des courses */
.barre-actions-courses { margin: .8rem 0 1rem; gap: .6rem; flex-wrap: wrap; }
.barre-actions-courses form { margin: 0; }
.barre-actions-courses button { margin: 0; }
h3.rayon { margin: 1.2rem 0 .3rem; font-size: 1rem; color: var(--pico-muted-color); text-transform: uppercase; letter-spacing: .03em; }
.lignes-courses { border-top: 1px solid var(--pico-muted-border-color); }
.ligne-course {
  display: grid; grid-template-columns: auto 1fr 4.5rem minmax(6rem, 9rem) auto; gap: .5rem; align-items: center;
  padding: .5rem 0; margin: 0; border-bottom: 1px solid var(--pico-muted-border-color);
}
.ligne-course .case-cocher { margin: 0; }
.ligne-course .case-cocher input { width: 1.2rem; height: 1.2rem; margin: 0; }
.ligne-course .nom small { display: block; color: var(--pico-muted-color); font-size: .75rem; }
.ligne-course input, .ligne-course select { margin: 0; padding: .3rem .5rem; font-size: .9rem; height: auto; }
.ligne-course .supprimer { margin: 0; padding: .2rem .55rem; }
.ligne-course.cochee { opacity: .55; }
.ligne-course.cochee .nom a { text-decoration: line-through; }
.ligne-course.manuelle .nom a { border-left: 3px solid var(--accent); padding-left: .4rem; }
@media (max-width: 700px) {
  .ligne-course { display: flex; flex-wrap: wrap; align-items: center; }
  .ligne-course .case-cocher { order: 1; }
  .ligne-course .nom { order: 2; flex: 1 1 auto; min-width: 55%; }
  .ligne-course .supprimer { order: 3; }
  .ligne-course .quantite { order: 4; flex: 1 1 5rem; margin-top: .35rem !important; }
  .ligne-course .unite { order: 5; flex: 2 1 8rem; margin-top: .35rem !important; }
}

/* Repas hors domicile */
.case-hors-domicile { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--pico-muted-color); margin: .2rem 0 .6rem; }
.case-hors-domicile input { width: 1.1rem; height: 1.1rem; margin: 0; }
.badge.hors-domicile { background: #fde8d7; color: #7f2704; font-weight: 500; vertical-align: middle; }
