/* GHS Hygiène — vert sapin #24504C, blanc sauge #EEF2EF. Une colonne, gros boutons, mode clair et sombre. */
:root {
  --bg: #F1F4F2; --surface: #FFFFFF; --sunk: #E4EBE8; --line: #D6E2DE;
  --fg: #16211F; --muted: #4D5D59;
  --accent: #24504C; --accent-ink: #FFFFFF; --accent-soft: #E0EBE7; --accent-strong: #183936;
  --brand: #24504C; --brand-ink: #EEF2EF; --brand-ink-soft: #D6E2DE;
  --danger: #B3261E; --danger-soft: #FBEAE8; --warn: #8A4B08; --warn-soft: #FBF0DF;
  --font-brand: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-ui: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1716; --surface: #152220; --sunk: #1C2C29; --line: #2A3B38; --fg: #E8EFEC; --muted: #9FB1AC;
    --accent: #8CC3B8; --accent-ink: #0E1716; --accent-soft: #1D3532; --accent-strong: #B5DDD4;
    --danger: #F08A80; --danger-soft: #3A1F1C; --warn: #E9B36B; --warn-soft: #362A18;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg); font-family: var(--font-ui); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; min-height: 100dvh;
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(16px, env(safe-area-inset-left));
}
body.brand-screen { background: var(--brand); color: var(--brand-ink); }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 16px; font-weight: 700; }
p { margin: 0; }
a { color: var(--accent); }

.app { max-width: 560px; margin: 0 auto; padding: 16px 0 48px; display: flex; flex-direction: column; gap: 18px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sub { color: var(--muted); font-size: 13px; }
.center { text-align: center; }

/* Marque */
.lockup { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: 8px 0; }
.frame { width: 76px; height: 76px; border: 1px solid currentColor; padding: 4px; display: flex; }
.frame > span { flex: 1; border: 1px solid currentColor; display: flex; align-items: center; justify-content: center; }
.frame svg { width: 44px; height: 44px; }
.lockup .ghs { font-family: var(--font-brand); font-weight: 600; font-size: 46px; letter-spacing: .06em; padding-left: .06em; line-height: .85; }
.lockup .hyg { font-size: 15px; font-weight: 600; letter-spacing: .4em; padding-left: .4em; }
.lockup .rule { width: 40px; height: 1px; background: currentColor; opacity: .7; }
.lockup .tag { font-size: 11px; font-weight: 600; letter-spacing: .24em; padding-left: .24em; color: var(--brand-ink-soft); }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand-mini { display: flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; }
.brand-mini .frame { width: 38px; height: 38px; padding: 2px; color: var(--accent); }
.brand-mini .frame svg { width: 22px; height: 22px; }
.brand-mini b { font-family: var(--font-brand); font-weight: 600; font-size: 22px; letter-spacing: .05em; line-height: .8; display: block; }
.brand-mini small { font-size: 9px; font-weight: 600; letter-spacing: .32em; display: block; margin-top: 3px; }

/* Boutons */
.btn {
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  font-weight: 700; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; color: var(--fg);
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.big { min-height: 54px; font-size: 16px; width: 100%; }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.brand-screen .btn.primary { background: var(--brand-ink); color: var(--brand); border-color: var(--brand-ink); }
.brand-screen .btn.ghost { color: var(--brand-ink); border-color: rgba(238, 242, 239, .45); }
.linkbtn { background: none; border: 0; padding: 8px 0; color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.brand-screen .linkbtn { color: var(--brand-ink); }
.back { background: none; border: 0; padding: 8px 0; color: var(--muted); font-weight: 600; display: inline-flex; gap: 6px; align-items: center; }
.brand-screen .back { color: var(--brand-ink-soft); }

/* Cartes et listes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.brand-screen .card { background: #2C5D58; border-color: #4A7A74; color: var(--brand-ink); }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column; overflow: hidden; }
.item { padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; border-top: 1px solid var(--line); background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; width: 100%; }
.item:first-child { border-top: none; }
button.item:active { background: var(--sunk); }
.item .txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.item .name { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.item .meta { font-size: 12.5px; color: var(--muted); }
.pill { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.pill.ok { background: var(--accent-soft); color: var(--accent-strong); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.neutral { background: var(--sunk); color: var(--muted); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; min-height: 92px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 8px; text-align: left; color: var(--fg);
}
.tile b { font-size: 15px; }
.tile.soon { opacity: .6; cursor: default; }
.tile.accent { border-color: var(--accent); }
.callout { background: var(--accent-soft); color: var(--accent-strong); border-radius: var(--r); padding: 14px; font-size: 14px; }
.callout.warn { background: var(--warn-soft); color: var(--warn); }
.callout.danger { background: var(--danger-soft); color: var(--danger); }
.brand-screen .callout { background: #33665F; color: var(--brand-ink); }

/* Formulaires */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .lbl { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.brand-screen .field > label { color: var(--brand-ink-soft); }
.input { min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 10px 12px; font-size: 16px; width: 100%; color: var(--fg); }
.brand-screen .input { background: #2C5D58; border-color: #4A7A74; color: var(--brand-ink); }
.err { color: var(--danger); font-size: 13.5px; font-weight: 600; }
.brand-screen .err { color: #FFB4A9; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { min-height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Code PIN */
.who-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.who-grid button {
  min-height: 64px; border-radius: var(--r); border: 1px solid #4A7A74; background: #2C5D58; color: var(--brand-ink);
  font-weight: 700; font-size: 17px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.who-grid button small { font-weight: 600; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-ink-soft); }
.dots { display: flex; justify-content: center; gap: 16px; padding: 8px 0; }
.dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; }
.dots span.on { background: currentColor; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 320px; margin: 0 auto; width: 100%; }
.pad button {
  min-height: 64px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface);
  font-size: 24px; font-weight: 700; font-family: var(--font-data); color: var(--fg);
}
.brand-screen .pad button { background: #2C5D58; border-color: #4A7A74; color: var(--brand-ink); }
.pad button.fn { font-family: var(--font-ui); font-size: 14px; }
.pad button[disabled] { opacity: .4; }
.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* QR */
.qr { background: #fff; border-radius: var(--r); padding: 12px; width: min(280px, 100%); margin: 0 auto; }
.qr svg { display: block; width: 100%; height: auto; }
.code-big { font-family: var(--font-data); font-size: 32px; font-weight: 600; letter-spacing: .18em; text-align: center; }

/* Feuille modale */
.sheet-wrap { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet {
  background: var(--bg); width: 100%; max-width: 560px; border-radius: 20px 20px 0 0; padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px; max-height: 90dvh; overflow: auto;
}
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--fg); color: var(--bg); padding: 12px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  max-width: calc(100% - 32px); z-index: 30; box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
}
.spinner { width: 28px; height: 28px; border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; margin: 24px auto; opacity: .7; }
@keyframes spin { to { transform: rotate(360deg); } }
.mono { font-family: var(--font-data); }
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; padding: 4px 0; }
.check input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
/* Étiquette à recopier */
.label-card { background: #fff; color: #16211F; border: 2px solid #16211F; border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.label-card .sub { color: #4D5D59; }
.label-product { font-size: 24px; font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.label-line { display: flex; justify-content: space-between; gap: 12px; border-top: 1px dashed #D6E2DE; padding-top: 6px; font-size: 15px; }
.label-line span { color: #4D5D59; }
.label-line b { text-align: right; }
.label-line.big b { font-size: 26px; }
.seg a.btn { text-decoration: none; }
button.tile { font: inherit; cursor: pointer; }
button.tile[disabled] { opacity: .5; cursor: not-allowed; }
select.input { appearance: auto; }

/* Fiche allergènes à afficher (A4 paysage) */
.allergen-sheet { background: #fff; color: #16211F; border-radius: 10px; padding: 12px; overflow-x: auto; }
.allergen-sheet h2 { margin: 0 0 4px; font-size: 18px; }
.allergen-sheet table { border-collapse: collapse; width: 100%; font-size: 12px; }
.allergen-sheet th, .allergen-sheet td { border: 1px solid #9AA8A4; padding: 4px 5px; text-align: center; }
.allergen-sheet th.dish, .allergen-sheet td.dish { text-align: left; min-width: 150px; }
.allergen-sheet thead th:not(.dish) { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; height: 96px; font-weight: 600; }
.allergen-sheet td.sec { background: #EEF2EF; text-align: left; font-weight: 700; }
.allergen-sheet .yes { font-weight: 800; }
.allergen-sheet .tr { color: #6B5A00; }
.allergen-sheet .foot { font-size: 11px; margin-top: 6px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
/* Registre */
.reg-scroll { overflow-x: auto; background: var(--card, #fff); border-radius: 10px; }
.reg-table { border-collapse: collapse; width: 100%; min-width: 640px; font-size: 13px; }
.reg-table th, .reg-table td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.reg-table th { font-size: 12px; color: var(--ink-soft, #55625F); white-space: nowrap; }
.reg-table td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.reg-table tr.bad td { background: rgba(198, 40, 40, .07); }
.reg-block { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.reg-head { font-size: 13px; }
.print-only { display: none; }
.control-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: #24504C; color: #fff; border-radius: 10px; padding: 8px 12px; font-size: 14px; }
@media print {
  @page { size: A4 landscape; margin: 8mm; }
  body * { visibility: hidden; }
  .allergen-sheet, .allergen-sheet *, .print-area, .print-area * { visibility: visible; }
  .allergen-sheet { position: absolute; inset: 0; padding: 0; overflow: visible; }
  /* Registre : on retire le reste de l'écran (et non le masquer) pour que le tableau s'étale sur plusieurs pages. */
  body.print-registry main.app > :not(.print-area), body.print-registry .sheet-wrap, body.print-registry .toast { display: none !important; }
  body.print-registry main.app { padding: 0; max-width: none; }
  .allergen-sheet table { font-size: 9.5pt; }
  .print-area { color: #000; }
  .print-area .reg-scroll { overflow: visible; }
  .print-area .reg-table { font-size: 8.5pt; min-width: 0; }
  .print-area .reg-table th, .print-area .reg-table td { border: 1px solid #999; padding: 3px 4px; }
  .print-area img { max-width: 60px; max-height: 60px; }
  .print-area .no-print { display: none !important; }
  .print-only { display: block; }
}
