:root {
  --bg: #f7f7f5;
  --card: #ffffff;
  --ink: #1c1c1a;
  --muted: #6b6b66;
  --accent: #2f7d5d;
  --accent-ink: #ffffff;
  --border: #e2e2dd;
  --danger: #b23b3b;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .75rem 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 700; font-size: 1.2rem; color: var(--ink); }
.topbar nav { display: flex; align-items: center; gap: 1rem; flex: 1; }
.topbar .spacer { flex: 1; }
.whoami { color: var(--muted); font-size: .9rem; }

.container { max-width: 900px; margin: 1.5rem auto; padding: 0 1rem; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}
.card.narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
h1 { margin-top: 0; }
.muted { color: var(--muted); }

label { display: block; margin: .6rem 0; font-size: .9rem; color: var(--muted); }
input, select, textarea {
  display: block; width: 100%; margin-top: .25rem;
  padding: .5rem .6rem; font-size: 1rem;
  border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--ink);
}
button {
  cursor: pointer; padding: .55rem 1rem; font-size: 1rem;
  background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: 6px;
}
button:hover { filter: brightness(1.05); }
button.linklike, .linklike {
  background: none; color: var(--accent); padding: 0; font-size: .9rem;
}
form.inline { display: inline; margin: 0; }

.flash {
  background: #fdecec; color: var(--danger);
  border: 1px solid #f3caca; border-radius: 6px;
  padding: .6rem .8rem; margin-bottom: 1rem;
}
.code-box {
  font-family: ui-monospace, monospace; font-size: 1.3rem; letter-spacing: 1px;
  background: #f0f0ec; border: 1px dashed var(--border); border-radius: 6px;
  padding: .8rem 1rem; text-align: center; margin: .5rem 0;
}
.code-box.small { font-size: .95rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 1rem; margin-top: 1rem; }
.tile { display: block; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); color: var(--ink); }
.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile h3 { margin: 0 0 .3rem; }

/* Listes, tables (lots suivants) */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem; border-bottom: 1px solid var(--border); }
.rayon-group { margin-bottom: 1.5rem; }
.rayon-group h3 { border-bottom: 2px solid var(--accent); padding-bottom: .25rem; }
.item-checked { text-decoration: line-through; color: var(--muted); }
/* Combobox de sélection d'ingrédient (ingredient-combo.js) */
.combo { position: relative; display: block; }
.combo > input { width: 100%; }
.combo-list {
  position: absolute; z-index: 30; top: 100%; left: 0;
  margin: 2px 0 0; padding: 0; list-style: none;
  min-width: 100%; width: max-content; max-width: 22rem;
  background: #fff; border: 1px solid var(--border);
  border-radius: 6px; max-height: 240px; overflow-y: auto;
  box-shadow: 0 6px 18px rgba(0,0,0,.12);
}
.combo-list[hidden] { display: none; }
.combo-option {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: .75rem; padding: .45rem .65rem; cursor: pointer; white-space: nowrap;
}
.combo-option:hover, .combo-option.active { background: #eef6f1; }
.combo-nom { font-weight: 500; }
.combo-rayon { font-size: .8rem; white-space: nowrap; }
.combo-empty { padding: .45rem .65rem; color: var(--muted); font-size: .85rem; }

/* Boutons & variantes */
.button-link {
  display: inline-block; padding: .5rem .9rem; border-radius: 6px;
  background: var(--accent); color: var(--accent-ink);
}
.button-link:hover { filter: brightness(1.05); text-decoration: none; }
button.secondary, .secondary {
  background: #eceae4; color: var(--ink); border: 1px solid var(--border);
}
button.danger, .danger { background: var(--danger); color: #fff; }
button.small, .small { padding: .25rem .55rem; font-size: .85rem; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.list { list-style: none; padding: 0; }
.list li { padding: .5rem 0; border-bottom: 1px solid var(--border); }
.prewrap { white-space: pre-wrap; }
textarea { resize: vertical; font-family: inherit; }

.ing-table td { padding: .35rem .4rem; vertical-align: middle; }
.ing-table input, .ing-table select { margin: 0; width: 100%; }
.ing-table .col-actions { text-align: right; white-space: nowrap; }
.ing-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: 1rem; }
.ing-form input[name="nom"] { flex: 1 1 12rem; margin: 0; }
.ing-form select { margin: 0; }
.flash-error {
  background: #fdecec; color: var(--danger);
  border: 1px solid #f3caca; border-radius: 6px;
  padding: .5rem .7rem; margin: .6rem 0 0;
}
.flash-error[hidden] { display: none; }
.ing-table .unite, .ing-table .rayon { max-width: 8rem; }

/* Formulaires divers */
.row { display: flex; gap: 1rem; }
.row > label { flex: 1; }

/* Formulaire d'ajout d'article : Article large, Qté étroite, le reste au contenu. */
#add-item-form { flex-wrap: wrap; align-items: center; }
#add-item-form .combo { flex: 1 1 12rem; }
#add-item-form input[name="libelle"] { width: 100%; }
#add-item-form input[name="quantite"] { flex: 0 0 5rem; width: 5rem; }
#add-item-form select { flex: 0 0 auto; }
#add-item-form .rayon-display {
  flex: 0 0 auto; font-size: .85rem; padding: .3rem .6rem;
  border: 1px dashed var(--border); border-radius: 6px; white-space: nowrap;
}
label.checkbox { display: flex; align-items: center; gap: .5rem; color: var(--ink); }
label.checkbox input { width: auto; margin: 0; }
.inline-label { display: inline-flex; align-items: center; gap: .4rem; margin: 0; color: var(--muted); font-size: .85rem; }
.inline-label input { width: 4.5rem; }

/* Séjour / planning */
.jour { margin: 1rem 0; }
.jour h3 { border-bottom: 2px solid var(--accent); padding-bottom: .2rem; }
.repas { border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; margin: .5rem 0; }
.repas-recipes { list-style: none; padding-left: 0; margin: .5rem 0; }
.repas-recipes li { display: flex; align-items: center; gap: .5rem; padding: .2rem 0; }
.add-recipe-form select { max-width: 20rem; }
.repas-controls { display: flex; align-items: center; gap: 1rem; }
.add-repas { display: flex; flex-wrap: wrap; gap: 1rem; margin: .25rem 0 .5rem; }
.share-link { align-items: center; }
.share-link input { flex: 1 1 auto; font-family: ui-monospace, monospace; font-size: .85rem; }
.sejour-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.badge {
  display: inline-block; vertical-align: middle; font-size: .7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; padding: .15rem .5rem;
  border-radius: 999px; background: var(--accent); color: var(--accent-ink);
}
.danger-text { color: var(--danger); }
.small-text { font-size: .85rem; }

/* Liste de courses */
table.shopping td { border-bottom: 1px solid var(--border); vertical-align: middle; }
.col-check { width: 2rem; }
.col-check input { width: auto; margin: 0; transform: scale(1.3); }
.col-stock { width: 9rem; }
.col-del { width: 2rem; text-align: right; }
.shop-item.item-checked .libelle,
.shop-item.item-checked .qte { text-decoration: line-through; color: var(--muted); }
.coche-info { display: block; }
.live-badge { color: var(--accent); font-size: .8rem; margin-left: .5rem; }
.live-badge.off { color: var(--muted); }
.item-del { font-size: 1.2rem; line-height: 1; }

/* Modale */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--card); color: var(--ink);
  border-radius: var(--radius); padding: 1.5rem;
  width: 100%; max-width: 420px;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
.modal h2 { margin-top: 0; }
.flash[hidden] { display: none; }
