:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #1f2421;
  --muted: #6b716d;
  --line: #e4e2dc;
  --accent: #2e7d5b;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1e9;
  --warn: #b4531a;
  --warn-soft: #fbeee4;
  --danger: #b42318;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 2px 8px rgb(0 0 0 / 4%);
  --radius: 14px;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141715;
    --card: #1d211f;
    --ink: #ecefec;
    --muted: #9aa29d;
    --line: #2d332f;
    --accent: #5cc08e;
    --accent-ink: #0d1a13;
    --accent-soft: #1f3a2c;
    --warn: #f0a46c;
    --warn-soft: #3a2a1d;
    --danger: #ff7b6e;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[v-cloak] { display: none; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

.app { max-width: 720px; margin: 0 auto; padding: 0 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }

/* En-tête */
.top {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  display: flex; align-items: center; gap: 8px; padding: 12px 0 8px;
}
.top h1 { font-size: 20px; margin: 0; flex: 1; }
.top .sub { color: var(--muted); font-size: 13px; font-weight: 400; display: block; }
.offline { background: var(--warn-soft); color: var(--warn); border-radius: 999px; padding: 2px 10px; font-size: 12px; }

/* Barre du bas */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom);
}
.nav button {
  flex: 1; max-width: 180px; height: var(--nav-h); border: 0; background: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: 12px;
}
.nav button svg { width: 24px; height: 24px; }
.nav button.on { color: var(--accent); font-weight: 600; }
.nav .badge { position: absolute; margin: -22px 0 0 26px; background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 10px; padding: 0 5px; }
.nav button { position: relative; }

/* Éléments communs */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; margin: 10px 0; }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  padding: 8px 12px; min-height: 40px; display: inline-flex; align-items: center; gap: 6px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: 14px; }
.btn:disabled { opacity: .5; }
.icon-btn { border: 0; background: none; width: 40px; height: 40px; border-radius: 10px; display: inline-grid; place-items: center; color: var(--muted); }
.icon-btn svg { width: 20px; height: 20px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 6px 12px; white-space: nowrap; font-size: 14px;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); margin-right: 4px; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
input[type=text], input[type=number], input[type=password], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 9px 11px; min-height: 42px;
}
textarea { min-height: 90px; resize: vertical; }
label.field { display: block; margin: 10px 0; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.error { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 8px 12px; margin: 8px 0; }
.sep { height: 1px; background: var(--line); margin: 10px 0; }

/* Connexion */
.login { max-width: 360px; margin: 12vh auto 0; }
.login img { width: 72px; height: 72px; border-radius: 18px; display: block; margin: 0 auto 12px; }
.login h1 { text-align: center; margin: 0 0 20px; }

/* Semaine */
.weeknav { display: flex; align-items: center; gap: 4px; }
.weeknav .label { flex: 1; text-align: center; font-weight: 600; }
.summary { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.day { padding: 6px 4px 6px 14px; }
.day h3 { margin: 6px 0 2px; font-size: 15px; }
.day.today h3 { color: var(--accent); }
.day.past { opacity: .6; }
.meal {
  display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line);
  width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left;
}
.meal:first-of-type { border-top: 0; }
.meal .slot { width: 44px; color: var(--muted); font-size: 13px; flex: none; }
.meal .what { flex: 1; min-width: 0; }
.meal .what.free { font-style: italic; }
.meal .what.none { color: var(--muted); }
.meal .flags { display: flex; gap: 4px; align-items: center; color: var(--muted); }
.meal .flags svg { width: 16px; height: 16px; }
.prep { border-left: 4px solid var(--accent); }
.prep ul { margin: 6px 0 0; padding-left: 18px; }

/* Courses */
.stores { position: sticky; top: 52px; z-index: 4; background: var(--bg); }
.store-head { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.store-head h2 { margin: 0; font-size: 18px; flex: 1; }
.cat { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 14px 0 2px; }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.check {
  width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--line); flex: none;
  display: grid; place-items: center; background: var(--card); padding: 0;
}
.check svg { width: 18px; height: 18px; opacity: 0; }
.item.done .check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.item.done .check svg { opacity: 1; }
.item.done .name { text-decoration: line-through; color: var(--muted); }
.item .name { font-weight: 500; }
.item .qty { font-size: 13px; color: var(--muted); }
.item .price { font-size: 13px; color: var(--muted); min-width: 52px; text-align: right; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; }
.stepper button { border: 0; background: none; width: 34px; height: 34px; font-size: 18px; }
.stepper span { min-width: 26px; text-align: center; }
.addbar { display: flex; gap: 6px; margin: 10px 0; }
.addbar input { flex: 1; }
.addbar select { width: 130px; flex: none; }

/* Recettes */
.recipe { display: flex; gap: 10px; align-items: flex-start; }
.recipe .name { font-weight: 600; }
.star { color: var(--muted); }
.star.on { color: #e3a008; }
.star svg { width: 22px; height: 22px; }
.ing { display: grid; grid-template-columns: 1fr 90px 40px 36px; gap: 6px; align-items: center; margin: 6px 0; }
.ing .unit { color: var(--muted); font-size: 13px; }
ol.steps { padding-left: 20px; }

/* Stock */
.stock-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.stock-row:last-child { border-bottom: 0; }
.stock-row input { width: 90px; min-height: 36px; padding: 5px 8px; text-align: right; }

/* Fenêtre du bas */
.sheet-bg { position: fixed; inset: 0; background: rgb(0 0 0 / 40%); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--bg); width: 100%; max-width: 720px; max-height: 88vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
}
.sheet .grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 10px; }
.sheet h2 { margin: 0 0 8px; font-size: 18px; }
.pick { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: var(--card); border: 0; border-radius: 10px; padding: 10px 12px; margin: 6px 0; }
.pick .grow { min-width: 0; }
.pick.cur { outline: 2px solid var(--accent); }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 10px; z-index: 30; font-size: 14px; max-width: 90vw;
}

/* Budget */
.bar { height: 8px; border-radius: 8px; background: var(--line); overflow: hidden; margin: 8px 0 4px; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 8px; }
.bar span.over { background: var(--warn); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.neg { color: var(--danger); }
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 15px; }
.amount.pos { color: var(--accent); }
.item .opname { font-weight: 500; }
.item.done .opname { color: var(--ink); }
.acc { cursor: pointer; }
.linkish { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline dotted; font: inherit; }
.nav button { font-size: 11px; }
