/* Outil boucherie — charte claire, tablette et mobile. Un accent, peu d'ornements, gros textes. */
/*
 * Palette reprise de monboucherbio.com : crème, brun chaud, vert profond.
 * Le vert clair du site (#7BF259) n'est pas repris pour les boutons : blanc sur ce vert donne un
 * contraste d'environ 1,8:1, illisible sous les néons d'un magasin. Le vert profond sert d'accent.
 */
:root {
    color-scheme: light;
    --bg: #faf6f0;
    --surface: #ffffff;
    --surface-2: #f0ebe3;
    --text: #3d2b1a;
    --muted: #7a6555;
    --line: #ddd5c8;
    --line-strong: #c3b7a5;
    --accent: #2c5f2e;
    --accent-hover: #234c25;
    --accent-ink: #ffffff;
    --accent-soft: #d4edda;
    --ok: #2c5f2e;
    --ok-soft: #d4edda;
    --warn: #9a5b00;
    --warn-soft: #fbf0dc;
    --danger: #a32316;
    --danger-soft: #f8e3e0;
    --info: #4a3a28;
    --info-soft: #efe9e0;
    --radius: 12px;
    --nav-h: 62px;
    --tap: 52px;
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-head: "Playfair Display", Georgia, serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 17px;
    line-height: 1.4;
    color: var(--text);
    background: var(--bg);
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    overflow-wrap: break-word;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 700; letter-spacing: -.01em; }
/* Titres de page en Playfair, comme le site ; les données restent en Inter pour rester lisibles. */
h1 { font-size: 1.45rem; font-family: var(--font-head); font-weight: 600; letter-spacing: 0; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .6rem; }
/* Filet de sécurité : une icône sans règle dédiée reste à la taille du texte, jamais pleine largeur. */
svg { flex: none; width: 1.25em; height: 1.25em; vertical-align: -.2em; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.tiny { font-size: .8rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mt { margin-top: 1rem; }
.mb { margin-bottom: 1rem; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .danger { color: var(--danger); } .info { color: var(--info); }

/* Page */
.page { padding: 1rem .9rem 1.5rem; max-width: 960px; margin: 0 auto; }
@media (min-width: 900px) { .page { padding: 1.25rem 1.5rem 2rem; } }
.page-head { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; min-height: 44px; }
.page-head h1 { flex: 1; min-width: 0; }
.page-head .back {
    width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 10px;
    background: var(--surface); border: 1px solid var(--line); font-size: 1.4rem; line-height: 1; color: var(--text);
}
.page-head .sub { color: var(--muted); font-size: .92rem; margin-top: .1rem; font-weight: 400; }
.page-head .tools { display: flex; gap: .4rem; flex: none; }
.user-chip {
    width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 50%;
    background: var(--surface-2); border: 1px solid var(--line); color: var(--text); font-weight: 700; font-size: 1rem;
}
.section-title {
    font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
    margin: 1.25rem 0 .5rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
}
.section-title:first-child { margin-top: 0; }
.section-title a, .section-title .link { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--accent); font-size: .9rem; }

/* Navigation basse */
.bottomnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: flex; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line);
}
.bottomnav a {
    flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); font-weight: 600; padding: 0 2px;
}
.bottomnav a svg { width: 23px; height: 23px; }
.bottomnav a span {
    font-size: clamp(.6rem, 2.7vw, .73rem); letter-spacing: -.01em;
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bottomnav a.active { color: var(--accent); }
.bottomnav a.active svg { stroke-width: 2.2; }

/* Cartes et listes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: .75rem; }
.card.tight { padding: 0; overflow: hidden; }
.card.soft { background: var(--surface-2); border-color: transparent; }
.card.danger { background: var(--danger-soft); border-color: transparent; }
.card.warn { background: var(--warn-soft); border-color: transparent; }
.card.info { background: var(--info-soft); border-color: transparent; }
.card.ok { background: var(--ok-soft); border-color: transparent; }

.items { list-style: none; margin: 0; padding: 0; }
.items > li + li { border-top: 1px solid var(--line); }
.item { display: flex; align-items: center; gap: .8rem; padding: .8rem .9rem; min-height: 64px; color: var(--text); }
.item:active { background: var(--surface-2); }
.item .ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--muted); }
.item .ico svg { width: 22px; height: 22px; }
.item .ico.accent { background: var(--accent-soft); color: var(--accent); }
.item .ico.danger { background: var(--danger-soft); color: var(--danger); }
.item .ico.warn { background: var(--warn-soft); color: var(--warn); }
.item .ico.ok { background: var(--ok-soft); color: var(--ok); }
.item .ico.info { background: var(--info-soft); color: var(--info); }
.item img.ico { object-fit: cover; }
.item .body { flex: 1; min-width: 0; }
.item .name {
    font-weight: 600; font-size: 1.01rem;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.item .meta { color: var(--muted); font-size: .87rem; margin-top: .1rem; }
.item .aside { text-align: right; flex: none; max-width: 38%; }
.item .aside .big { font-weight: 700; font-size: 1.02rem; font-variant-numeric: tabular-nums; }
.item .aside .due { font-size: .79rem; font-weight: 600; margin-top: .1rem; }
.item .chev { color: var(--line-strong); font-size: 1.3rem; margin-left: -.3rem; flex: none; }
@media (max-width: 420px) {
    .item { gap: .6rem; padding: .75rem .7rem; }
    .item .chev { display: none; }
}

.tag { display: inline-block; font-size: .75rem; font-weight: 700; padding: .1em .5em; border-radius: 6px; background: var(--surface-2); color: var(--muted); vertical-align: middle; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.tag.info { background: var(--info-soft); color: var(--info); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }

/* Chiffres clés */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .5rem; }
@media (max-width: 420px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .8rem; color: var(--text); }
.stat .v { font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .l { font-size: .79rem; color: var(--muted); margin-top: .2rem; }
.stat.danger .v { color: var(--danger); } .stat.warn .v { color: var(--warn); } .stat.ok .v { color: var(--ok); }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: .75rem 0; }
.kpi { text-align: center; padding: .6rem .3rem; border-radius: 10px; background: var(--surface-2); }
.kpi .v { font-size: 1.2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* Boutons — le texte peut passer à la ligne : « Relever les températures » ne doit jamais déborder. */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    min-height: var(--tap); padding: .55rem 1rem; border-radius: 12px; border: 1px solid var(--line-strong);
    background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
    text-align: center; line-height: 1.25; max-width: 100%;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--accent); }
.btn.soft { background: var(--surface-2); border-color: transparent; }
.btn.block { display: flex; width: 100%; }
.btn.big { min-height: 58px; font-size: 1.05rem; }
.btn.sm { min-height: 38px; padding: .25rem .7rem; font-size: .87rem; border-radius: 9px; white-space: nowrap; }
.btn.icon { width: var(--tap); padding: 0; flex: none; }
.btn.sm.icon { width: 38px; }
.btn svg { width: 22px; height: 22px; }
.btn.sm svg { width: 17px; height: 17px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .9rem 0; }
.actions > form { display: flex; flex: 1 1 auto; }
.actions .btn { flex: 1 1 auto; }
.actions.row .btn, .actions.row > form { flex: 0 0 auto; }
.sticky-actions {
    position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + .5rem); z-index: 5;
    display: flex; gap: .5rem; padding: .55rem; margin: 1rem -.25rem 0;
    background: rgba(255, 255, 255, .93); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 14px;
}
.sticky-actions .btn { flex: 1; }
.big-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .55rem; }
.big-actions .btn { min-height: 78px; flex-direction: column; gap: .35rem; font-size: 1rem; border-radius: 14px; padding: .6rem .7rem; }
.big-actions .btn svg { width: 25px; height: 25px; }
@media (max-width: 520px) { .big-actions { grid-template-columns: 1fr; } .big-actions .btn { flex-direction: row; min-height: 62px; } }

/* Zone des actions destructrices : repliée, donc impossible à toucher par erreur. */
details.danger-zone { margin: .5rem 0; }
details.danger-zone > summary { list-style: none; cursor: pointer; }
details.danger-zone > summary::-webkit-details-marker { display: none; }
.reason-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .45rem; }
.reason-buttons .btn { width: 100%; }

/* Segments, filtres, recherche */
.segments { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: .9rem; }
.segments a, .segments button {
    flex: 1; min-width: 0; text-align: center; padding: .55rem .4rem; border-radius: 9px; font-weight: 600; font-size: .93rem; color: var(--muted);
    border: 0; background: transparent; font-family: inherit; cursor: pointer;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.segments .active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
/* Les filtres passent à la ligne : aucun n'est caché hors de l'écran. */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .75rem; }
.chips a { padding: .4rem .8rem; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); font-size: .87rem; font-weight: 600; color: var(--text); }
.chips a.active { background: var(--text); color: #fff; border-color: var(--text); }
.search { display: flex; gap: .5rem; margin-bottom: .75rem; }
.search input { flex: 1; min-width: 0; }
.toolbar { display: flex; align-items: center; gap: .5rem; margin-bottom: .75rem; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

/* Bandeaux et messages */
.flash { padding: .7rem .9rem; border-radius: 12px; margin-bottom: .75rem; font-weight: 600; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.flash svg { width: 22px; height: 22px; }
.flash .msg { flex: 1 1 12rem; min-width: 0; }
.flash form.inline { margin: 0; display: inline-flex; }
.flash.success { background: var(--ok-soft); color: var(--ok); }
.flash.error { background: var(--danger-soft); color: var(--danger); }
.flash.info { background: var(--info-soft); color: var(--info); }
.notice { padding: .65rem .85rem; border-radius: 10px; font-size: .92rem; margin-bottom: .75rem; }
.notice.info { background: var(--info-soft); color: var(--info); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.danger { background: var(--danger-soft); color: var(--danger); }
.notice a { text-decoration: underline; }
.offline-bar {
    position: fixed; left: 0; right: 0; top: 0; z-index: 40; padding: .45rem .8rem; text-align: center;
    background: var(--warn); color: #fff; font-weight: 700; font-size: .88rem;
}
body.is-offline { padding-top: 2rem; }

/* Progression des tâches du jour */
.progress { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; flex: 1 1 6rem; min-width: 4rem; }
.progress > span { display: block; height: 100%; background: var(--ok); }

/* Formulaires */
.form-row { margin-bottom: .85rem; }
.form-row label, fieldset legend { display: block; font-weight: 600; font-size: .9rem; color: var(--muted); margin-bottom: .3rem; }
.form-row .help { color: var(--muted); font-size: .82rem; margin-top: .25rem; }
.req { color: var(--accent); text-decoration: none; font-weight: 700; margin-left: .15em; }
input[type=text], input[type=number], input[type=date], input[type=time], input[type=datetime-local], input[type=password],
input[type=search], input[type=email], select, textarea {
    width: 100%; min-height: var(--tap); padding: .55rem .75rem; font: inherit; font-size: 1.02rem; color: var(--text);
    background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px;
}
textarea { min-height: 76px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.form-row.low input, .form-row.low select { border-color: var(--warn); background: var(--warn-soft); }
.form-row.low label::after { content: " · à vérifier"; color: var(--warn); font-weight: 700; }
.form-row.invalid input, .form-row.invalid select { border-color: var(--danger); }
.form-error { color: var(--danger); font-size: .88rem; margin-top: .3rem; font-weight: 600; }
.form-grid { display: grid; gap: 0 .9rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid, .form-grid.three { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: .6rem; min-height: var(--tap); font-weight: 600; }
.check input { width: 24px; height: 24px; flex: none; accent-color: var(--accent); }
.choice-group { display: flex; flex-wrap: wrap; gap: .45rem; }
.choice-group label {
    display: inline-flex; align-items: center; min-height: 46px; padding: .3rem .9rem;
    border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); font-weight: 600; margin: 0; cursor: pointer; color: var(--text); font-size: .95rem;
}
.choice-group label:has(input:checked) { background: var(--text); color: #fff; border-color: var(--text); }
.choice-group input { position: absolute; opacity: 0; width: 0; height: 0; }
details.more { border-top: 1px solid var(--line); margin-top: .5rem; padding-top: .5rem; }
details.more > summary { cursor: pointer; list-style: none; font-weight: 600; color: var(--accent); padding: .6rem 0; display: flex; align-items: center; gap: .4rem; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "＋"; font-size: 1.1rem; }
details.more[open] > summary::before { content: "－"; }
.inline-photo { display: flex; gap: .8rem; align-items: center; margin-bottom: .9rem; }
.inline-photo img { width: 88px; height: 88px; flex: none; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.inline-photo .txt { font-size: .88rem; color: var(--muted); }

/* Tableaux */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { padding: .55rem .5rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Fiche : clé / valeur, en-tête, chronologie */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.1rem; font-size: .96rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; min-width: 0; }
@media (max-width: 420px) { .kv { grid-template-columns: 1fr; gap: .1rem; } .kv dd { margin-bottom: .5rem; } }
.photo { width: 100%; max-height: 62vh; object-fit: contain; border-radius: 10px; background: var(--surface-2); }
.hero { display: flex; gap: .9rem; align-items: flex-start; }
.hero .thumb { width: 76px; height: 76px; border-radius: 12px; object-fit: cover; border: 1px solid var(--line); flex: none; }
.hero .body { flex: 1; min-width: 0; }
.hero h1 { font-size: 1.25rem; }
.hero .state { display: flex; flex-wrap: wrap; gap: .4rem .6rem; margin-top: .4rem; align-items: center; }
.due-line { font-weight: 700; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: .92rem; }
.timeline li { display: flex; gap: .6rem; padding: .35rem 0; align-items: baseline; }
.timeline li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); flex: none; transform: translateY(-1px); }
.timeline li.now::before { background: var(--accent); }
.timeline .when { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Connexion */
.login { max-width: 440px; margin: 2rem auto; padding: 1rem; }
.login .logo { text-align: center; margin-bottom: 1.25rem; }
.login .logo h1 { margin-top: .5rem; }
.login .users { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .55rem; margin-bottom: 1rem; }
.login .users button { min-height: 60px; font-size: 1.05rem; }
.login .users button.selected { background: var(--text); color: #fff; border-color: var(--text); }
.pin-display { text-align: center; font-size: 1.8rem; letter-spacing: .5em; min-height: 2.8rem; margin: .4rem 0; }

/* Pavé numérique (PIN, températures) */
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; margin-top: .7rem; }
.pad button { min-height: 58px; font-size: 1.3rem; border-radius: 12px; }
.keypad-panel { border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem; background: var(--surface); margin-top: .75rem; }
.keypad-panel .value { font-size: 2.4rem; font-weight: 800; text-align: center; letter-spacing: -.02em; font-variant-numeric: tabular-nums; min-height: 3rem; }
.keypad-panel .value.out { color: var(--danger); }

/* Scan */
.scan-zone {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .9rem;
    min-height: 34vh; padding: 1.6rem 1rem; border: 2px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface); text-align: center;
}
/* Enfant direct seulement : sinon la grande icône rouge écrase celle du bouton, qui devient invisible. */
.scan-zone > svg { width: 52px; height: 52px; color: var(--accent); }
.scan-preview { max-width: 100%; max-height: 42vh; border-radius: 10px; }
.spinner { width: 40px; height: 40px; border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Calendrier */
/* Sept colonnes ne tiennent pas sur un téléphone : le calendrier défile dans son cadre,
   jamais la page entière. */
.cal-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: .3rem; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(84px, 1fr)); gap: 3px; min-width: 620px; }
.cal .dow { text-align: center; font-size: .7rem; color: var(--muted); font-weight: 700; padding: .25rem 0; text-transform: uppercase; }
.cal .day { min-height: 76px; padding: .25rem; background: var(--surface); border-radius: 8px; border: 1px solid var(--line); font-size: .78rem; }
.cal .day.other { opacity: .4; }
.cal .day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal .day .n { font-weight: 700; margin-bottom: .15rem; }
.cal .day a { display: block; padding: .1rem .25rem; margin-bottom: 2px; border-radius: 5px; font-size: .72rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal .day a.danger { background: var(--danger-soft); color: var(--danger); }
.cal .day a.warn { background: var(--warn-soft); color: var(--warn); }
.cal .day a.ok { background: var(--ok-soft); color: var(--ok); }
.cal .day a.muted { background: var(--surface-2); color: var(--muted); }

/* Collections (ingrédients) */
.collection-item { display: grid; grid-template-columns: 1fr 140px 52px; gap: .5rem; align-items: end; margin-bottom: .6rem; }
.collection-item .form-row { margin-bottom: 0; }
@media (max-width: 560px) { .collection-item { grid-template-columns: 1fr 1fr; } .collection-item .form-row:first-child { grid-column: 1 / -1; } }

@media print {
    .bottomnav, .actions, .sticky-actions, .btn, .page-head .back, .offline-bar { display: none !important; }
    body { padding: 0; background: #fff; }
}
