/* ============================================================
   Household Grocery List — feuille de style unique
   Mobile-first, thème clair/sombre, aucune ressource externe.
   ============================================================ */

/* ---------- 1. Jetons de design ---------- */
:root {
  --bg: #f6f7f6;
  --surface: #ffffff;
  --surface-2: #eef1ef;
  --surface-3: #e4e9e6;
  --text: #16211c;
  --muted: #5f6f68;
  --border: #e2e7e4;
  --border-strong: #c6cfca;
  --primary: #0f8a5f;
  --primary-strong: #0b6f4c;
  --primary-soft: #e0f4ea;
  --primary-text: #0b6f4c;
  --danger: #d64545;
  --danger-soft: #fdeaea;
  --warn: #b7791f;
  --sync-ok: #23a55a;
  --sync-wait: #e2a400;
  --sync-err: #e5484d;
  --shadow-sm: 0 1px 2px rgba(16, 24, 20, .06);
  --shadow-md: 0 2px 6px rgba(16, 24, 20, .07), 0 12px 28px rgba(16, 24, 20, .10);
  --radius: 14px;
  --radius-sm: 10px;
  --topbar-h: 56px;
  --dock-pad: calc(10px + env(safe-area-inset-bottom));
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html[data-theme="dark"] {
  --bg: #101513;
  --surface: #171d1a;
  --surface-2: #1e2622;
  --surface-3: #27312c;
  --text: #e9efec;
  --muted: #9aaba3;
  --border: #2a332f;
  --border-strong: #3b4741;
  --primary: #3ecf8e;
  --primary-strong: #67dfaa;
  --primary-soft: #173628;
  --primary-text: #6fe0b0;
  --danger: #ff7b7b;
  --danger-soft: #3a2222;
  --warn: #f0c060;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, .4), 0 14px 32px rgba(0, 0, 0, .45);
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3, p { margin: 0; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; touch-action: manipulation; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 6px;
}

::selection { background: var(--primary-soft); }

[hidden] { display: none !important; }

.noscript {
  max-width: 520px;
  margin: 15vh auto;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}

/* Barres de défilement discrètes */
.scroll-y { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.scroll-y::-webkit-scrollbar { width: 8px; }
.scroll-y::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; }

/* ---------- 3. Utilitaires & composants génériques ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-weight: 600;
  font-size: .95rem;
  transition: background .15s ease, transform .05s ease, border-color .15s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
html[data-theme="dark"] .btn-primary { color: #06231a; }
.btn-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--danger); border-color: transparent; background: var(--danger-soft); }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: .88rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }

.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn-ghost.is-loading::after, .btn:not(.btn-primary).is-loading::after {
  border-color: var(--surface-3);
  border-top-color: var(--primary);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: transparent;
  font-size: 1.25rem;
  line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); }

.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.field { display: flex; flex-direction: column; gap: 5px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.field > input, .field > select {
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 16px; /* évite le zoom auto sur iOS */
  font-weight: 500;
}
.field > input:focus-visible { border-color: var(--primary); }

.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: .9rem;
  font-weight: 600;
}
.field-error { color: var(--danger); font-size: .8rem; font-weight: 600; }

.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-text);
  font-size: .78rem;
  font-weight: 700;
}

/* ---------- 4. Démarrage ---------- */
.boot {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--bg);
  color: var(--muted);
  z-index: 50;
}

/* ---------- 5. Connexion ---------- */
.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  padding: 28px 24px 22px;
}

.login-logo { font-size: 3rem; text-align: center; }
.login-card h1 { text-align: center; font-size: 1.5rem; margin-top: 6px; }
.login-sub { text-align: center; color: var(--muted); font-size: .95rem; margin-top: 4px; }

.login-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.login-card label { font-size: .85rem; font-weight: 700; color: var(--muted); }
.login-card input[type="text"],
.login-card input[type="password"] {
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}
.login-card input:focus-visible { border-color: var(--primary); background: var(--surface); }

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500 !important;
  color: var(--text) !important;
  font-size: .9rem !important;
  min-height: 44px;
  cursor: pointer;
}
.checkbox-line input { width: 20px; height: 20px; accent-color: var(--primary); }

.login-help {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  color: var(--muted);
  font-size: .82rem;
  text-align: center;
}
.login-help code {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 6px;
}

/* ---------- 6. Coquille applicative ---------- */
.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: var(--topbar-h);
  padding: 6px 10px;
  padding-top: calc(6px + env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-logo { font-size: 1.45rem; }
.brand-name { font-weight: 800; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sync-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--sync-wait);
  flex: none;
}
.sync-dot[data-status="live"] { background: var(--sync-ok); }
.sync-dot[data-status="connecting"] { background: var(--sync-wait); animation: pulse 1.4s ease-in-out infinite; }
.sync-dot[data-status="offline"] { background: var(--sync-err); }
@keyframes pulse { 50% { opacity: .35; } }

.topbar-actions { display: flex; align-items: center; gap: 4px; }

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: .87rem;
  font-weight: 700;
}
.pill-btn[aria-pressed="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
html[data-theme="dark"] .pill-btn[aria-pressed="true"] { color: #06231a; }

.presence-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--primary-soft);
  color: var(--primary-text);
  font-size: .88rem;
  font-weight: 600;
  text-align: center;
}
.presence-banner .btn { min-height: 32px; font-size: .8rem; padding: 0 10px; background: var(--surface); }

/* ---------- 7. Mise en page principale ---------- */
.layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.col-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px 12px 0;
}

.col-side { display: none; }

/* Barre d'outils */
.toolbar { display: flex; flex-direction: column; gap: 8px; }

.search-wrap { position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 12px; font-size: .9rem; opacity: .7; pointer-events: none; }
.search-wrap input {
  width: 100%;
  min-height: 46px;
  padding: 0 42px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
}
.search-wrap input:focus-visible { border-color: var(--primary); }
.search-clear {
  position: absolute;
  right: 6px;
  width: 36px; height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .9rem;
}

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: 999px;
}
.segmented button {
  flex: 1;
  min-height: 38px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 700;
}
.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.chips {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: .84rem;
  font-weight: 700;
  white-space: nowrap;
}
.chip[aria-pressed="true"] {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-text);
}

/* En-tête de liste */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}
.list-title { font-size: 1.15rem; font-weight: 800; }
.list-count { color: var(--muted); font-size: .82rem; }

/* ---------- 8. Liste & articles ---------- */
.list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 0 24px;
  margin-top: 6px;
}

.group-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 2px 6px;
  background: var(--bg);
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.group-header .g-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px; height: 20px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text);
  font-size: .72rem;
}
.group-header .g-count { margin-left: auto; font-weight: 600; text-transform: none; letter-spacing: 0; }

.row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 8px;
  padding: 4px 8px 4px 2px;
  animation: row-in .18s ease-out;
}
@keyframes row-in { from { opacity: 0; transform: translateY(4px); } }

.check {
  position: relative;
  width: 48px;
  height: 48px;
  border: none;
  background: transparent;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex: none;
}
.check::before {
  content: "";
  width: 26px; height: 26px;
  border: 2.5px solid var(--border-strong);
  border-radius: 9px;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.check::after {
  content: "";
  position: absolute;
  width: 12px; height: 6px;
  border-left: 2.5px solid #fff;
  border-bottom: 2.5px solid #fff;
  border-radius: 1px;
  transform: rotate(-45deg) translateY(-2px);
  opacity: 0;
  transition: opacity .12s ease;
}
.check:active::before { transform: scale(.88); }
.check[aria-pressed="true"]::before { background: var(--primary); border-color: var(--primary); }
.check[aria-pressed="true"]::after { opacity: 1; }

.row-main {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 8px 4px;
  min-width: 0;
}
.row-title {
  font-weight: 650;
  font-size: 1rem;
  overflow-wrap: anywhere;
}
.row-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 3px; align-items: center; }
.tag {
  font-size: .76rem;
  font-weight: 650;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 2px 8px;
}
.tag.qty { background: var(--primary-soft); color: var(--primary-text); }
.tag.note { background: transparent; color: var(--muted); font-style: italic; font-weight: 500; padding-left: 0; }
.row-meta { margin-top: 3px; font-size: .74rem; color: var(--muted); }

.row-steps { display: flex; flex-direction: column; gap: 2px; }
.step {
  width: 40px;
  height: 34px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
  display: grid;
  place-items: center;
}
.step:first-child { border-radius: 10px 10px 2px 2px; }
.step:last-child { border-radius: 2px 2px 10px 10px; }
.step:active { background: var(--primary-soft); }
.step[disabled] { opacity: .35; }

/* Article coché */
.row.is-checked { background: var(--surface-2); border-style: dashed; }
.row.is-checked .row-title { text-decoration: line-through; color: var(--muted); font-weight: 550; }
.row.is-checked .tag { opacity: .8; }
.row.is-checked .row-meta { opacity: .8; }

.checked-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 14px 0 8px;
  padding: 10px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: .86rem;
}
.checked-divider .cd-chev { margin-left: auto; transition: transform .15s ease; }
.checked-divider[aria-expanded="true"] .cd-chev { transform: rotate(180deg); }

/* États vides */
.empty-card {
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 18px;
  padding: 26px 18px;
  margin-top: 8px;
}
.empty-card .empty-emoji { font-size: 2.4rem; }
.empty-card h2 { font-size: 1.1rem; margin-top: 8px; }
.empty-card p { color: var(--muted); font-size: .9rem; margin-top: 6px; }
.empty-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }

/* ---------- 9. Colonne latérale (tablette/PC) ---------- */
.side-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.side-card h2 { font-size: .85rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 10px; }
.side-card .btn-block { margin-top: 10px; }

.chip-column { display: flex; flex-direction: column; gap: 8px; }
.chip-column .quick-chip { justify-content: flex-start; width: 100%; }

.quick-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 650;
  font-size: .88rem;
  white-space: nowrap;
}
.quick-chip:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); }
.quick-chip .qc-qty { color: var(--muted); font-size: .78rem; font-weight: 700; }
.quick-chip:hover .qc-qty { color: var(--primary-text); }

.mini-list { display: flex; flex-direction: column; gap: 6px; }
.mini-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
}
.mini-row:hover { background: var(--surface-2); }
.mini-row .mr-main { flex: 1; min-width: 0; text-align: left; border: none; background: transparent; padding: 4px; }
.mr-title { font-weight: 650; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mr-meta { font-size: .76rem; color: var(--muted); }
.mini-row .mr-add {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-weight: 800;
  display: grid;
  place-items: center;
  flex: none;
}
.mini-row .mr-add:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.mr-pin {
  width: 34px; height: 34px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: .95rem;
  opacity: .45;
  flex: none;
}
.mr-pin[aria-pressed="true"] { opacity: 1; }
.mr-pin:hover { background: var(--surface-3); }
.mini-row .mr-inlist { font-size: .72rem; color: var(--warn); font-weight: 700; }

.stats-mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-tile {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  text-align: center;
}
.stat-tile .st-num { font-size: 1.3rem; font-weight: 800; color: var(--primary-text); }
.stat-tile .st-label { font-size: .7rem; color: var(--muted); font-weight: 650; }

/* ---------- 10. Barre du bas : suggestions + saisie ---------- */
.dock {
  position: relative;
  padding: 6px 12px var(--dock-pad);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 15;
}

.quick-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
}
.quick-strip::-webkit-scrollbar { display: none; }
.quick-strip:empty { display: none; }

.suggest-wrap { position: relative; height: 0; }
.suggest {
  position: absolute;
  left: 0; right: 0;
  bottom: 6px;
  max-height: min(44dvh, 360px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 30;
}
.suggest-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 52px;
  padding: 6px 8px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  text-align: left;
}
.suggest-row:hover, .suggest-row.is-active { background: var(--primary-soft); }
.suggest-row .sr-title { font-weight: 700; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest-row .sr-meta { font-size: .76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest-row .sr-add {
  width: 40px; height: 40px;
  border: none;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 800;
  display: grid;
  place-items: center;
}
html[data-theme="dark"] .suggest-row .sr-add { color: #06231a; }
.suggest-empty { padding: 12px; color: var(--muted); font-size: .86rem; text-align: center; }

.composer { position: relative; }
.composer-row { display: flex; gap: 8px; align-items: stretch; }
.composer-row input {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  padding: 0 16px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}
.composer-row input:focus-visible { border-color: var(--primary); background: var(--surface); }
.composer-opt {
  width: 46px; height: 52px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.composer-opt[aria-expanded="true"] { background: var(--primary-soft); border-color: var(--primary); }
.add-btn {
  width: 56px; height: 52px;
  border: none;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: var(--shadow-sm);
  flex: none;
}
html[data-theme="dark"] .add-btn { color: #06231a; }
.add-btn:active { transform: scale(.95); }

.qty-hint {
  margin-top: 6px;
  font-size: .8rem;
  color: var(--primary-text);
  font-weight: 700;
}

.composer-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-top: 8px;
  padding: 10px;
  background: var(--surface-2);
  border-radius: var(--radius);
}
.store-quick { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.store-quick .chip { min-height: 32px; font-size: .8rem; }

/* ---------- 11. Notifications (undo) ---------- */
.toasts {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 132px);
  width: min(480px, calc(100vw - 24px));
  z-index: 90;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #22302a;
  color: #f2f7f4;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow-md);
  font-size: .9rem;
  font-weight: 600;
  pointer-events: auto;
  animation: toast-in .2s ease-out;
}
html[data-theme="dark"] .toast { background: #2c3a34; border: 1px solid var(--border); }
.toast .t-msg { flex: 1; }
.toast .t-action {
  border: none;
  background: transparent;
  color: #7ff0be;
  font-weight: 800;
  font-size: .9rem;
  min-height: 36px;
  padding: 0 8px;
  border-radius: 8px;
}
.toast .t-action:hover { background: rgba(255, 255, 255, .1); }
.toast.is-error { background: #5b2320; }
.toast.is-error .t-action { color: #ffc9c9; }
.toast .t-close { border: none; background: transparent; color: #b9c6c0; width: 32px; height: 32px; border-radius: 8px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }
.toast.is-leaving { opacity: 0; transition: opacity .18s ease; }

/* ---------- 12. Feuilles (bottom sheets / modales) ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 14, 11, .5);
  z-index: 70;
  animation: fade-in .15s ease-out;
}
@keyframes fade-in { from { opacity: 0; } }

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(640px, 100vw);
  max-height: min(88dvh, 820px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-md);
  z-index: 80;
  animation: sheet-up .22s cubic-bezier(.2, .8, .3, 1);
  padding-bottom: env(safe-area-inset-bottom);
}
@keyframes sheet-up { from { transform: translate(-50%, 6%); opacity: .6; } }

.sheet-handle {
  width: 44px; height: 5px;
  margin: 8px auto 0;
  border-radius: 999px;
  background: var(--surface-3);
  flex: none;
}
.sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 10px;
  border-bottom: 1px solid var(--border);
}
.sheet-head h2 { font-size: 1.05rem; font-weight: 800; flex: 1; min-width: 0; }
.sheet-head .sh-sub { font-size: .78rem; color: var(--muted); font-weight: 600; }
.sheet-body {
  padding: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sheet-foot {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.sheet-foot .btn { flex: 1; }

body.sheet-open { overflow: hidden; }

/* Menus de feuille */
.menu-list { display: flex; flex-direction: column; gap: 4px; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 0 12px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-weight: 650;
  font-size: .96rem;
  text-align: left;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item .mi-icon { font-size: 1.15rem; width: 26px; text-align: center; }
.menu-item .mi-hint { margin-left: auto; color: var(--muted); font-size: .8rem; font-weight: 600; }
.menu-item.is-danger { color: var(--danger); }

/* ---------- 13. Formulaires des feuilles ---------- */
.form-grid { display: flex; flex-direction: column; gap: 12px; }
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  align-items: end;
}

.qty-stepper { display: flex; align-items: center; gap: 6px; }
.qty-stepper .step { width: 48px; height: 48px; border-radius: var(--radius-sm); }
.qty-stepper input {
  min-height: 48px;
  min-width: 84px;
  flex: 1;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  text-align: center;
}

.meta-line { font-size: .8rem; color: var(--muted); }
.pin-toggle[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); }

/* Liste d'éléments éditables (packs, rayons) */
.edit-rows { display: flex; flex-direction: column; gap: 8px; }
.edit-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(70px, .6fr) auto;
  gap: 8px;
  align-items: center;
}
.edit-row input {
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 16px;
  min-width: 0;
}
.edit-row .row-remove {
  width: 44px; height: 44px;
  border: none;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 1rem;
}
.edit-row .row-extra { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.aisle-list { display: flex; flex-direction: column; gap: 6px; }
.aisle-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
}
.aisle-item input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
}
.aisle-item .ai-name { flex: 1; font-weight: 650; font-size: .92rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.aisle-item .ai-num { color: var(--muted); font-size: .78rem; width: 20px; text-align: center; }
.icon-mini {
  width: 38px; height: 38px;
  border: none;
  background: var(--surface);
  border-radius: 9px;
  font-size: .95rem;
  display: grid;
  place-items: center;
}
.icon-mini[disabled] { opacity: .35; }
.icon-mini.is-danger { color: var(--danger); background: var(--danger-soft); }

/* Réglages */
.settings-group { display: flex; flex-direction: column; gap: 8px; }
.settings-group h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-top: 6px; }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.settings-row .sr-label { font-weight: 650; font-size: .93rem; }
.settings-row .sr-desc { font-size: .78rem; color: var(--muted); }

.switch { position: relative; display: inline-flex; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  width: 52px; height: 30px;
  border-radius: 999px;
  background: var(--surface-3);
  transition: background .15s ease;
  display: flex;
  align-items: center;
  padding: 3px;
}
.switch .knob {
  width: 24px; height: 24px;
  background: #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease;
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track .knob { transform: translateX(22px); }
.switch input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Statistiques complètes */
.stats-title {
  font-size: .8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin-top: 8px;
}
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.stats-bars { display: flex; flex-direction: column; gap: 8px; }
.settings-row .theme-chips { margin-top: 0; flex-wrap: wrap; justify-content: flex-end; }
.settings-row .theme-chips .chip { min-height: 34px; }
.stat-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; }
.stat-bar .sb-label { font-size: .86rem; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-bar .sb-value { font-size: .8rem; color: var(--muted); font-weight: 700; }
.stat-bar progress { grid-column: 1 / -1; }

progress {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border: none;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
progress::-webkit-progress-bar { background: var(--surface-3); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--primary); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--primary); border-radius: 999px; }

/* Aide / première prise en main */
.help-steps { display: flex; flex-direction: column; gap: 14px; }
.help-step { display: flex; gap: 12px; align-items: flex-start; }
.help-step .hs-icon { font-size: 1.6rem; width: 40px; text-align: center; flex: none; }
.help-step h3 { font-size: .98rem; font-weight: 750; }
.help-step p { font-size: .88rem; color: var(--muted); margin-top: 2px; }

/* ---------- 14. Mode course ---------- */
body[data-mode="shopping"] .row-steps { display: none; }
body[data-mode="shopping"] .row-main { pointer-events: none; }
body[data-mode="shopping"] .check::before { width: 32px; height: 32px; border-radius: 11px; }
body[data-mode="shopping"] .check { width: 56px; height: 60px; }
body[data-mode="shopping"] .row { border-color: var(--primary); }
body[data-mode="shopping"] .toolbar .search-wrap input,
body[data-mode="shopping"] .segmented { opacity: .75; }

/* ---------- 15. Responsive ---------- */
@media (min-width: 640px) {
  .col-main { padding: 14px 18px 0; }
  .list { padding-bottom: 30px; }
  .toolbar { flex-direction: row; align-items: center; }
  .search-wrap { flex: 1; }
  .segmented { flex: none; }
  .segmented button { padding: 0 16px; }
}

@media (min-width: 1024px) {
  :root { --topbar-h: 64px; }

  .layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 350px;
    gap: 18px;
    padding: 0 22px;
    min-height: 0;
  }
  .col-main { padding: 14px 0 0; }
  .col-side {
    display: block;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 14px 0 24px;
  }
  .quick-strip { display: none; }

  .list-title { font-size: 1.3rem; }
  .dock { padding-left: 22px; padding-right: 22px; }
  .dock > form, .dock > .suggest-wrap { max-width: 760px; margin: 0 auto; }
  .dock > .suggest-wrap { max-width: 760px; }
  .dock .composer { max-width: 760px; margin: 0 auto; }

  .toasts { bottom: 24px; }
  .sheet {
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    border-radius: 18px;
    max-height: min(84dvh, 760px);
    animation: modal-in .18s ease-out;
  }
  @keyframes modal-in { from { opacity: 0; transform: translate(-50%, -48%); } }
  .sheet-handle { display: none; }
}

@media (max-width: 380px) {
  .pill-label { display: none; }
  .brand-name { font-size: .98rem; }
}

/* ---------- 16. Confort & accessibilité ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001s !important;
  }
}

/* ————— Entités, cloche de validation, admission ————— */
.group-btn { max-width: 44vw; overflow: hidden; }
.group-btn .g-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 750;
}

.bell-btn { position: relative; }
.bell-btn .badge-count {
  position: absolute;
  top: 1px;
  right: -1px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: var(--danger);
  color: #fff;
  font-size: .68rem;
}

.menu-item.is-current {
  background: var(--primary-soft);
  color: var(--primary-text);
}

.request-link { margin-top: 12px; border-style: dashed; }

.request-view {
  margin-top: 18px;
  border-top: 1px dashed var(--border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.request-view h2 { font-size: 1.15rem; text-align: center; }
.request-view form { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.request-view input,
.request-view select {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}
.request-view input:focus-visible,
.request-view select:focus-visible { border-color: var(--primary); }
#req-new-wrap { display: flex; flex-direction: column; gap: 6px; }

.request-list { display: flex; flex-direction: column; gap: 10px; }
.request-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.request-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 1.02rem; }
.request-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.request-note { font-size: .88rem; color: var(--muted); font-style: italic; margin: 0; }
.request-actions { display: flex; gap: 8px; }
.request-actions .btn { flex: 1; }

@media (max-width: 480px) {
  #btn-theme { display: none; }
  .group-btn .g-name { max-width: 72px; }
}
