/* Luna — mobile first */

:root {
    --bg: #f7f1e8;
    --surface: #fffdf9;
    --surface-2: #f3ece1;
    --ink: #2d2a32;
    --muted: #7a7280;
    --line: #eadfce;
    --primary: #d9725b;
    --primary-ink: #ffffff;
    --primary-soft: #fbe6df;
    --sage: #5f9a7c;
    --sage-soft: #e3f0e8;
    --warn: #a86a12;
    --warn-soft: #fdf1d8;
    --danger: #c0473a;
    --danger-soft: #fbe3df;
    --info-soft: #e6edf8;

    --sub-sale: #6c8ebf;
    --sub-sucre: #b18ad6;
    --sub-legume: #6fae7f;
    --sub-feculent: #e3b04b;
    --sub-proteine: #c96b5c;
    --sub-fruit: #e58fb0;

    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgb(60 40 20 / 6%), 0 4px 16px rgb(60 40 20 / 6%);
    --tabbar-h: 64px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1b1a22;
        --surface: #25232d;
        --surface-2: #2e2b37;
        --ink: #f1ece6;
        --muted: #a59ead;
        --line: #393542;
        --primary: #ec8a72;
        --primary-ink: #1b1a22;
        --primary-soft: #43302c;
        --sage: #82c3a0;
        --sage-soft: #26372f;
        --warn: #f0bd62;
        --warn-soft: #3d3221;
        --danger: #f08070;
        --danger-soft: #45292a;
        --info-soft: #28303f;
        --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 25%);
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }

body {
    margin: 0;
    font-family: Nunito, ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.45;
    background: var(--bg);
    color: var(--ink);
}

body.is-app { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.45rem; font-weight: 800; }
h2 { font-size: 1.05rem; font-weight: 800; }
code { font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
[hidden] { display: none !important; }

.container { max-width: 1240px; margin: 0 auto; padding: 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.eyebrow { margin: 0 0 4px; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.eyebrow a { color: inherit; }
.lead { font-size: 1.1rem; color: var(--muted); }

/* ------------------------------------------------------------ barre du haut / onglets */

.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 16px;
    padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.2rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand svg { width: 26px; height: 26px; fill: var(--primary); }
.topnav { display: none; gap: 4px; margin-left: 16px; }
.topnav a { padding: 8px 14px; border-radius: 999px; color: var(--muted); font-weight: 700; }
.topnav a:hover { background: var(--surface-2); text-decoration: none; }
.topnav a[aria-current] { background: var(--primary-soft); color: var(--primary); }
.me { margin-left: auto; }
.me img, .me span {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
    background: var(--sage-soft); color: var(--sage); font-weight: 800; object-fit: cover;
}

.tabbar {
    position: fixed; inset: auto 0 0 0; z-index: 20;
    display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface);
    border-top: 1px solid var(--line);
}
.tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); font-size: .72rem; font-weight: 700;
}
.tabbar a:hover { text-decoration: none; }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current] { color: var(--primary); }

@media (min-width: 768px) {
    .topnav { display: flex; }
    .tabbar { display: none; }
    body.is-app { padding-bottom: 32px; }
    .container { padding: 24px; }
    h1 { font-size: 1.75rem; }
}

/* ------------------------------------------------------------ boutons */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 10px 18px;
    border: 1px solid var(--line); border-radius: 999px;
    background: var(--surface); color: var(--ink);
    font: inherit; font-weight: 700; cursor: pointer;
    transition: transform .1s, background .15s;
}
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 88%, black); }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: transparent; }
.btn-google { width: 100%; background: var(--surface); }
.btn-google svg { width: 20px; height: 20px; }
.icon-btn {
    display: inline-grid; place-items: center; width: 36px; height: 36px; margin: -6px -6px -6px auto;
    border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 1.3rem; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------ messages */

.flash { padding: 12px 16px; margin-bottom: 16px; border-radius: var(--radius-sm); background: var(--info-soft); font-weight: 600; }
.flash ul { margin: 0; padding-left: 18px; }
.flash-success { background: var(--sage-soft); }
.flash-warning { background: var(--warn-soft); }
.flash-error { background: var(--danger-soft); }

.alert {
    margin-bottom: 16px; padding: 12px 16px;
    background: var(--warn-soft); border-radius: var(--radius-sm);
}
.alert summary { cursor: pointer; font-weight: 800; color: var(--warn); }
.alert ul { margin: 8px 0 0; padding-left: 20px; }
.alert li + li { margin-top: 4px; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .72rem; font-weight: 800; }
.badge-today { background: var(--primary); color: var(--primary-ink); }
.badge-new { background: var(--sage-soft); color: var(--sage); }

/* ------------------------------------------------------------ en-têtes de page */

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }
.page-head .muted { margin: 6px 0 0; }
.page-head form { margin: 0; }

.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.week-current { font-weight: 700; color: var(--muted); }
@media (max-width: 420px) { .hide-sm { display: none; } }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-weight: 700; white-space: nowrap; }
.tabs a:hover { text-decoration: none; }
.tabs a[aria-current] { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.empty-state { padding: 32px 16px; text-align: center; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty-state p { color: var(--muted); max-width: 520px; margin: 12px auto 0; }

/* ------------------------------------------------------------ planning */

.days { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .days { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .days { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1360px) { .days { grid-template-columns: repeat(4, 1fr); } }

.day { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.day.is-today { outline: 2px solid var(--primary); }
.day.is-past { opacity: .78; }
.day-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px 10px; background: var(--surface-2); }

.meal { padding: 12px 16px; border-top: 1px solid var(--line); }
.day-head + .meal { border-top: 0; }
.meal-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.slot { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-right: 2px; }
.tag { padding: 1px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.tag-pot { background: var(--info-soft); color: var(--sub-sale); }
.tag-maison { background: var(--sage-soft); color: var(--sage); }
.tag-empty { background: var(--danger-soft); color: var(--danger); }
.tag-edited { font-style: italic; }

.items { list-style: none; margin: 0; padding: 0; }
.items li { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.item-name { font-weight: 700; }
.portions { color: var(--muted); font-size: .9rem; font-weight: 700; }
.dot { flex: none; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.sub-sale { background: var(--sub-sale); }
.sub-sucre { background: var(--sub-sucre); }
.sub-legume { background: var(--sub-legume); }
.sub-feculent { background: var(--sub-feculent); }
.sub-proteine { background: var(--sub-proteine); }
.sub-fruit { background: var(--sub-fruit); }

.note { margin: 6px 0 0; font-size: .82rem; color: var(--warn); }
.note-warn { font-weight: 700; }
.meal-empty { margin: 0; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: .88rem; font-weight: 600; }
.meal-missing { opacity: .6; }
.meal.is-eaten .items { opacity: .65; }
.meal.is-eaten .item-name { text-decoration: line-through; text-decoration-color: var(--sage); text-decoration-thickness: 2px; }

.eat-form { margin: 10px 0 0; }
.eat { display: inline-flex; align-items: center; gap: 10px; min-height: 36px; cursor: pointer; font-weight: 700; user-select: none; }
.eat input { position: absolute; opacity: 0; pointer-events: none; }
.eat-box {
    display: grid; place-items: center; width: 26px; height: 26px;
    border: 2px solid var(--line); border-radius: 8px; background: var(--surface); transition: all .15s;
}
.eat input:checked + .eat-box { background: var(--sage); border-color: var(--sage); }
.eat input:checked + .eat-box::after { content: ""; width: 7px; height: 12px; border: solid #fff; border-width: 0 3px 3px 0; transform: translateY(-1px) rotate(45deg); }
.eat input:focus-visible + .eat-box { outline: 2px solid var(--primary); outline-offset: 2px; }
.eat input:checked ~ span:last-child { color: var(--sage); }
.eat.is-disabled { cursor: not-allowed; color: var(--muted); opacity: .6; }

/* ------------------------------------------------------------ stock / historique */

.stock-group { margin-bottom: 18px; }
.group-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.group-head h2 { display: flex; align-items: center; gap: 8px; }
.group-empty { margin: 0; padding: 10px 16px; background: var(--surface); border-radius: var(--radius-sm); }
.stock-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.stock-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-top: 1px solid var(--line); }
.stock-item:first-child { border-top: 0; }
.stock-item form { margin: 0; }
.stock-main { flex: 1; min-width: 0; color: var(--ink); }
.stock-main:hover { text-decoration: none; }
.stock-main .item-name { display: block; overflow-wrap: anywhere; }
.stock-meta { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: .82rem; color: var(--muted); }
.exp-soon .exp { color: var(--warn); font-weight: 800; }
.exp-expired .exp { color: var(--danger); font-weight: 800; }
.exp-expired .item-name { color: var(--danger); }

.stepper { display: flex; align-items: center; flex: none; border: 1px solid var(--line); border-radius: 999px; }
.stepper button { width: 38px; height: 38px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 1.2rem; font-weight: 800; cursor: pointer; border-radius: 50%; }
.stepper button:hover { background: var(--surface-2); }
.stepper .qty { min-width: 28px; text-align: center; font-weight: 800; }

.exhausted summary { cursor: pointer; font-weight: 700; color: var(--muted); margin-bottom: 8px; }

/* ------------------------------------------------------------ formulaires */

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card h2 { margin-bottom: 8px; }
.form { max-width: 640px; }
.form > * + * { margin-top: 16px; }

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend, .field > span { display: block; margin-bottom: 6px; font-size: .85rem; font-weight: 800; color: var(--muted); }
.field { display: block; }
.field-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.field-row > * { flex: 1 1 140px; }
.field-row .grow { flex: 3 1 220px; }
.portions-field { flex: 0 0 96px !important; }
.field-row-tight { flex-wrap: nowrap; }
.field-row-tight .grow { flex: 1 1 auto; min-width: 0; }
.portions-field { flex-basis: 84px !important; }

input[type=text], input[type=date], select {
    width: 100%; min-height: 46px; padding: 10px 12px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--bg); color: var(--ink); font: inherit; font-size: 16px;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }
select { text-overflow: ellipsis; }

.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.segmented legend { width: 100%; }
.segmented label, .chips label { cursor: pointer; }
.segmented input, .chips input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span, .chips label > span {
    display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding: 8px 16px;
    border: 1px solid var(--line); border-radius: 999px; background: var(--bg); font-weight: 700;
}
.segmented input:checked + span, .chips input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.segmented input:focus-visible + span, .chips input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips legend { width: 100%; }

.quick-dates { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px !important; }
.chip-btn { min-height: 32px; padding: 4px 12px; border: 1px dashed var(--line); border-radius: 999px; background: transparent; color: var(--ink); font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; }
.chip-btn:hover { background: var(--surface-2); }

.hint { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: .88rem; color: var(--muted); }
.kind-section > * + * { margin-top: 12px; }

.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding-top: 4px; }

.switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { flex: none; position: relative; width: 48px; height: 28px; margin-top: 2px; border-radius: 999px; background: var(--line); transition: background .15s; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 25%); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--sage); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--primary); outline-offset: 2px; }

.range-row { display: flex; align-items: center; gap: 12px; }
.range-row input { flex: 1; accent-color: var(--primary); }
.range-row output { min-width: 32px; padding: 4px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-weight: 800; text-align: center; }

.add-history summary { cursor: pointer; font-weight: 800; }
.add-history form > * + * { margin-top: 12px; }
.add-history form { margin-top: 12px; }

.account p { margin: 0 0 12px; }
.danger-zone { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.danger-zone summary { cursor: pointer; color: var(--danger); font-weight: 700; }
.danger-zone form { margin-top: 8px; }
.danger-zone .field-row > * { flex: 0 1 auto; }

/* ------------------------------------------------------------ connexion */

.login { min-height: calc(100vh - 32px); display: grid; place-items: center; }
.login-card { width: 100%; max-width: 400px; padding: 32px 24px; text-align: center; background: var(--surface); border-radius: 24px; box-shadow: var(--shadow); }
.login-card > * + * { margin-top: 12px; }
.login-moon { width: 56px; height: 56px; fill: var(--primary); }
.login-card h1 { font-size: 2.2rem; margin-top: 4px; }
.login-points { text-align: left; margin: 20px 0; padding: 0; list-style: none; }
.login-points li { position: relative; padding-left: 26px; margin: 8px 0; color: var(--muted); }
.login-points li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 10px; height: 10px; border-radius: 50%; background: var(--sage); }
.login-card form .btn { width: 100%; }
.login-card form .btn + .btn { margin-top: 8px; }

/* ------------------------------------------------------------ partage */

.invite {
    margin-bottom: 16px; padding: 14px 16px;
    background: var(--sage-soft); border: 1px solid color-mix(in srgb, var(--sage) 35%, transparent); border-radius: var(--radius);
}
.invite p { margin: 0; }
.invite-title { font-size: 1.05rem; }
.invite .small { margin-top: 4px; }
.invite-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.invite-actions form { margin: 0; }

.members { list-style: none; margin: 12px 0 16px; padding: 0; }
.members li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.members li:first-child { border-top: 0; }
.members form { margin: 0 0 0 auto; }
.members .avatar {
    flex: none; display: grid; place-items: center; width: 36px; height: 36px; overflow: hidden;
    border-radius: 50%; background: var(--sage-soft); color: var(--sage); font-weight: 800;
}
.members .avatar img { width: 100%; height: 100%; object-fit: cover; }
.members .pending .avatar { background: var(--surface-2); color: var(--muted); }
.member-id { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
input[type=email] {
    width: 100%; min-height: 46px; padding: 10px 12px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--bg); color: var(--ink); font: inherit; font-size: 16px;
}
.invite-form .field-row-tight input { flex: 1 1 auto; min-width: 0; }
.invite-form .btn { flex: none; }
.leave-form { margin-top: 12px; }

/* ------------------------------------------------------------ avis, alertes, exclusions, modes */

.eat-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.eat-row .eat-form { margin: 0; }
.rating { display: flex; gap: 4px; margin: 0; }
.rating-btn {
    display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 4px 10px;
    border: 1px solid var(--line); border-radius: 999px; background: transparent;
    color: var(--muted); font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer; opacity: .7;
}
.rating-btn:hover { opacity: 1; background: var(--surface-2); }
.rating-btn.is-active { opacity: 1; color: var(--ink); }
.rating-like.is-active { background: var(--sage-soft); border-color: var(--sage); }
.rating-dislike.is-active { background: var(--danger-soft); border-color: var(--danger); }

.rate-dialog {
    width: min(92vw, 380px); padding: 24px 20px 16px; border: 0; border-radius: 24px;
    background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / 30%); text-align: center;
}
.rate-dialog::backdrop { background: rgb(30 20 10 / 45%); }
.rate-dialog h2 { font-size: 1.25rem; }
.rate-dialog p { margin: 6px 0 16px; }
.rate-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rate-choice {
    display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 8px;
    border: 2px solid var(--line); border-radius: 18px; background: var(--bg);
    color: var(--ink); font: inherit; font-weight: 800; cursor: pointer;
}
.rate-choice span { font-size: 2.2rem; line-height: 1; }
.rate-choice.rating-like:hover, .rate-choice.rating-like:focus-visible { border-color: var(--sage); background: var(--sage-soft); }
.rate-choice.rating-dislike:hover, .rate-choice.rating-dislike:focus-visible { border-color: var(--danger); background: var(--danger-soft); }
.rate-actions { display: flex; justify-content: space-between; margin-top: 12px; }

.restock {
    display: block; margin-bottom: 16px; padding: 10px 14px; border-radius: var(--radius-sm);
    background: var(--primary-soft); color: var(--ink); font-size: .92rem;
}
.restock strong { color: var(--primary); }
.restock-list { margin-bottom: 16px; padding: 12px 16px; border-radius: var(--radius); background: var(--primary-soft); }
.restock-list h2 { color: var(--primary); margin-bottom: 6px; }
.restock-list ul { list-style: none; margin: 0; padding: 0; }
.restock-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 3px 0; }

.badge-excluded { margin-left: 6px; background: var(--danger-soft); color: var(--danger); vertical-align: 2px; }

.slot-modes { display: grid; gap: 10px; }
.slot-mode { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.slot-mode-label { font-weight: 800; }
.segmented-sm span { min-height: 36px; padding: 6px 12px; font-size: .9rem; }

.add-exclusion summary { cursor: pointer; font-weight: 800; }
.add-exclusion form { margin-top: 12px; }
.add-exclusion form > * + * { margin-top: 12px; }
.members .dot { margin: 0 13px; }

/* ------------------------------------------------------------ statistiques */

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 768px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.tile-value { font-size: 1.9rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-label { color: var(--muted); font-size: .85rem; font-weight: 700; }
.tile-label small { display: block; font-weight: 600; }

.stats-note { margin: 0 0 12px; }
.stats-grid { display: grid; gap: 14px; }
@media (min-width: 900px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card { margin: 0; }
.stat-sub { margin-top: 16px; }

.rate-list { list-style: none; margin: 4px 0 0; padding: 0; }
.rate-row {
    display: grid; grid-template-columns: minmax(0, 1fr) 72px auto; align-items: center; gap: 4px 10px;
    padding: 7px 0; border-top: 1px solid var(--line);
}
.rate-row:first-child { border-top: 0; }
.rate-row:has(.btn, .badge) { grid-template-columns: minmax(0, 1fr) 72px auto auto; }
.rate-label { font-weight: 700; overflow-wrap: anywhere; }
.rate-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.rate-bar span { display: block; height: 100%; border-radius: 4px; background: var(--sage); }
.rate-value { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rate-value small { color: var(--muted); }
.rate-row .btn { min-height: 30px; padding: 2px 10px; font-size: .8rem; }
.rate-row:hover { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }

.weeks { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; align-items: end; height: 160px; margin: 8px 0; }
.week-col { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.week-col:hover .week-track span { background: color-mix(in srgb, var(--sage) 80%, var(--ink)); }
.week-value { font-size: .78rem; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.week-track { flex: 1; width: 100%; max-width: 36px; display: flex; align-items: flex-end; border-bottom: 1px solid var(--line); }
.week-track span { display: block; width: 100%; border-radius: 4px 4px 0 0; background: var(--sage); }
.week-label { font-size: .72rem; color: var(--muted); }

/* ------------------------------------------------------------ autocomplétion */

.suggest-wrap { position: relative; }
.suggest {
    position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; right: 0;
    max-height: min(320px, 50vh); overflow-y: auto; margin: 0; padding: 6px; list-style: none;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
    box-shadow: 0 10px 30px rgb(40 25 10 / 16%);
}
.suggest li {
    display: flex; align-items: center; min-height: 44px; padding: 8px 12px;
    border-radius: 8px; cursor: pointer; font-weight: 600;
}
.suggest li:hover, .suggest li[aria-selected="true"] { background: var(--primary-soft); }
.suggest mark { background: transparent; color: var(--primary); font-weight: 800; }

/* ------------------------------------------------------------ grammages */

.input-suffix { position: relative; display: block; }
.input-suffix input { padding-right: 34px; }
.input-suffix > span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; pointer-events: none; }
.targets-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 12px; }
@media (min-width: 640px) { .targets-grid { grid-template-columns: repeat(3, 1fr); } }
.target > span:first-child { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; font-size: .85rem; font-weight: 800; color: var(--muted); }
.targets small { display: block; margin-top: 8px; }
.grams-out { display: block; min-height: 1.2em; margin-top: 2px; font-size: .78rem; text-align: center; }
.stock-meta .missing { color: var(--warn); font-weight: 700; }
.portions:empty { display: none; }
