/* PMS SOFT — UI optimisée tablette cuisine */
:root {
  --bg: #f5f5f1;
  --card: #ffffff;
  --ink: #1a1a1a;
  --muted: #6c7378;
  --line: #e6e4dc;
  --primary: #0f3a2e;
  --primary-2: #16604c;
  --accent: #c89048;
  --ok: #2f7d4f;
  --warn: #b86a00;
  --danger: #b3261e;
  --info: #1e5cb3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.06);
  --sidebar-w: 260px;
  /* Thème personnalisable du bandeau (surchargé par applyTheme via JS) */
  --topbar-bg: var(--primary);
  --topbar-fg: #ffffff;
  --topbar-fg-soft: rgba(255,255,255,0.78);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: rgba(15,58,46,.15);
}
body.no-scroll { overflow: hidden; }
img, svg, video { max-width: 100%; height: auto; }

/* Évite le débordement horizontal partout : par défaut les enfants flex/grid
   ont min-width:auto (= max(min-content, taille du flex-basis)) ce qui empêche
   le shrink sous la taille du contenu. On force min-width:0 / min-height:0
   pour que le contenu puisse rétrécir et wrapper proprement. */
.layout, .layout > *,
.topbar, .topbar > *, .topactions, .topactions > *,
.card-head, .card-head > *,
.grid, .grid > *,
.field-row, .field-row > *,
.field-row-3, .field-row-3 > *,
.actions, .actions > *,
.field, .field > * { min-width: 0; }

/* Permet aux mots/URLs longs de wrapper sans pousser le layout, sans casser
   les mots normaux caractère-par-caractère (anywhere était trop aggressif). */
h1, h2, h3, p, label, span, a, button, .badge, .alert, .help, .page-sub {
  overflow-wrap: break-word;
}

/* Tables : on permet le scroll horizontal interne quand les colonnes débordent.
   max-content fait que la table garde sa taille naturelle ; min-width:100%
   garantit qu'elle remplit le wrap en desktop. */
.table-wrap { width: 100%; max-width: 100%; overflow-x: auto; }
.table { width: 100%; }
/* La matrice allergènes a beaucoup de colonnes : on autorise sa largeur naturelle
   et le wrap parent scrolle horizontalement plutôt que de casser le texte. */
.table.matrix { width: max-content; min-width: 100%; }
.table.matrix td, .table.matrix th { white-space: nowrap; }
.table.matrix tbody td:first-child { white-space: normal; min-width: 140px; }

/* Lien d'évitement : masqué hors focus clavier (sinon il s'affichait en permanence) */
.skiplink {
  position: absolute; left: -9999px; top: 0; z-index: 1100;
  background: var(--primary); color: #fff; padding: 8px 12px;
  border-radius: 0 0 8px 0; text-decoration: none;
}
.skiplink:focus { left: 0; }

/* TOPBAR */
.topbar {
  min-height: 56px;
  background: var(--topbar-bg);
  color: var(--topbar-fg);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .burger {
  background: transparent;
  border: 0;
  color: var(--topbar-fg);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  display: none;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  flex-shrink: 0;
}
.topbar .burger:hover, .topbar .burger:focus-visible { background: rgba(127,127,127,.18); outline: none; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand > div { min-width: 0; }
.brand .logo {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: grid; place-items: center;
  color: #fff; font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}
.brand .logo img.brand-logo-img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 6px;
}
.brand strong {
  display: block;
  line-height: 1.1;
  font-size: 15px;
  letter-spacing: .04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand small, .brand .muted {
  display: block;
  color: var(--topbar-fg-soft);
  font-size: 12px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topactions { margin-left: auto; flex-shrink: 0; display: flex; align-items: center; gap: 10px; }

/* Bouton "Installer l'app" (PWA) */
.btn-install {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff;
  border: 0; border-radius: 999px;
  padding: 6px 14px; min-height: 36px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  touch-action: manipulation;
}
.btn-install:hover, .btn-install:focus-visible {
  background: #b07a3a; outline: none;
  box-shadow: 0 0 0 3px rgba(200,144,72,.35);
}
.btn-install .install-ico { font-size: 16px; line-height: 1; }
@media (max-width: 480px) {
  .btn-install { padding: 6px 10px; }
  .btn-install .install-ico { font-size: 18px; }
}

/* Pied de la barre latérale : actions Installer + Déconnexion (sorties de la topbar
   pour désencombrer le bandeau, surtout sur mobile). Épinglé en bas via flex
   (margin-top:auto) — robuste quel que soit l'overflow du parent. La sidebar passe
   en flex column pour que ce schéma fonctionne (voir .sidebar plus bas).
   Pas de padding-bottom: env(safe-area-inset-bottom) ici — .sidebar le pose déjà
   en mobile (sinon doublé sur iPhone avec barre Home → ~34 px de vide en trop). */
.sidebar-foot {
  margin-top: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 12px;
  background: #fff; border-top: 1px solid var(--line);
}
.sidebar-foot button { width: 100%; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.sidebar-foot .btn-install { border-radius: 8px; }
.sidebar-foot #logoutBtn {
  background: #fff; color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.sidebar-foot #logoutBtn:hover { background: #f5f5f1; }
.sidebar-foot .logout-ico { display: inline-flex; line-height: 0; }
.sidebar-foot .logout-ico svg { display: block; }

/* La date reste dans la topbar mais se masque sur mobile (place réduite). */
@media (max-width: 600px) { .datebadge { display: none; } }

/* Modal "Comment installer" (iOS) */
.install-help { max-width: 480px; }
.install-help ol { padding-left: 22px; line-height: 1.7; }
.install-help kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 24px; padding: 0 6px;
  background: #f5f5f1; border: 1px solid var(--line); border-radius: 6px;
  font-family: inherit; font-size: 13px; font-weight: 600;
}
.datebadge {
  background: rgba(127,127,127,.18);
  color: var(--topbar-fg);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
}

/* LAYOUT */
.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: calc(100vh - 56px); }
.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 8px 0;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  /* Flex column : .sidebar-nav scrolle, .sidebar-foot reste en bas (margin-top:auto).
     Plus robuste que `position:sticky` sur .sidebar-foot, qui exigeait que .sidebar ait
     overflow-y:auto et ne fonctionnait pas en cas de non-débordement (bordure flottante). */
  display: flex; flex-direction: column;
  min-height: 0;
}
.sidebar-nav { flex: 1; min-height: 0; overflow-y: auto; }
.sidebar a {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  min-height: 44px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
}
/* L'icône (span aria-hidden) garde sa largeur fixe ; le libellé (span data-i18n,
   ajouté pour l'i18n) remplit l'espace restant et coupe aux mots, pas aux lettres. */
.sidebar a span[aria-hidden] { width: 22px; text-align: center; flex-shrink: 0; }
.sidebar a span:not([aria-hidden]) { flex: 1; min-width: 0; }
.sidebar a:hover { background: #f5f5f1; }
.sidebar a.active { background: #ecf2ee; border-left-color: var(--primary); color: var(--primary); font-weight: 600; }
.navsection {
  padding: 14px 16px 6px;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.content { padding: 24px 28px 80px; max-width: 1200px; }
.loading { color: var(--muted); padding: 40px; text-align: center; }

/* TYPO */
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 24px 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.page-sub { color: var(--muted); margin: 0 0 24px; font-size: 14px; }

/* CARDS */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* KPI tiles */
.kpi {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.kpi .v { font-size: 26px; font-weight: 700; color: var(--primary); }
.kpi .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.kpi.warn .v { color: var(--warn); }
.kpi.danger .v { color: var(--danger); }
.kpi.ok .v { color: var(--ok); }

/* FORMS */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 12px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 16px; /* >= 16px évite l'auto-zoom iOS au focus */
  font-family: inherit;
  background: #fff;
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}
.field textarea { min-height: 88px; resize: vertical; }
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236c7378' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
  padding-right: 36px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(22,96,76,.15);
}
.field-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.field-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 700px) { .field-row, .field-row-3 { grid-template-columns: 1fr; } }
.field .help { font-size: 12px; color: var(--muted); }
.checkrow { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.checkrow input { width: auto; }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px;
  min-height: 44px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation; /* supprime le 300ms tap-delay sur mobile */
}
.btn:hover { background: #f5f5f1; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-2); }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #fdecea; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: 6px 10px; font-size: 13px; min-height: 32px; }
.btn-lg { padding: 14px 22px; font-size: 16px; min-height: 52px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions-end { justify-content: flex-end; }

/* TABLES */
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; vertical-align: top; }
.table th { background: #fafaf6; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }
.table tr.row-warn td { background: #fff7eb; }
.table tr.row-danger td { background: #fdecea; }
.table tr.row-ok td { background: #f1f9f3; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }

/* BADGES */
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: #eef2f0; color: var(--primary);
}
.badge.ok { background: #e3f3e8; color: var(--ok); }
.badge.warn { background: #fdf1dc; color: var(--warn); }
.badge.danger { background: #fdecea; color: var(--danger); }
.badge.info { background: #e3edf9; color: var(--info); }

/* ALERTS */
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 12px; border-left: 4px solid; }
.alert-warn { background: #fdf1dc; border-color: var(--warn); color: #6f4400; }
.alert-danger { background: #fdecea; border-color: var(--danger); color: #6f1414; }
.alert-info { background: #e3edf9; border-color: var(--info); color: #133e7a; }
.alert-ok { background: #e3f3e8; border-color: var(--ok); color: #194e2e; }

/* TOAST + MODAL */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 14px; z-index: 200; box-shadow: var(--shadow);
}
[hidden] { display: none !important; }
.modal {
  position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; padding: 16px;
}
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,30,25,.55); }
.modal-card {
  position: relative; background: #fff; border-radius: var(--radius);
  width: min(640px, 100%); max-height: 90vh; overflow: auto;
  box-shadow: 0 30px 60px rgba(0,0,0,.25);
}
.modal-card header { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; background: #fff; z-index: 1; }
.modal-card header h3 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.modal-card header button { background: transparent; border: 0; font-size: 28px; line-height: 1; cursor: pointer; color: var(--muted); width: 44px; height: 44px; border-radius: 8px; flex-shrink: 0; }
.modal-card header button:hover, .modal-card header button:focus-visible { background: #f5f5f1; outline: none; }
.modal-card > div { padding: 20px; }
.modal-card footer { padding: 12px 20px; padding-bottom: max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; position: sticky; bottom: 0; background: #fff; }

/* EMPTY STATES */
.empty {
  text-align: center; padding: 32px 16px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius); background: #fff;
}
.empty h3 { color: var(--ink); margin-bottom: 8px; }

/* SIDEBAR BACKDROP (mobile) */
.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(15,30,25,.45);
  z-index: 55; opacity: 0; transition: opacity .2s ease;
}
.sidebar-backdrop.visible { opacity: 1; }

/* RESPONSIVE */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; min-width: 0; }
  .topbar .burger { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar {
    position: fixed; left: -100%; top: 0; width: 84%; max-width: 320px;
    height: 100vh; height: 100dvh;
    padding-top: calc(56px + env(safe-area-inset-top));
    padding-bottom: env(safe-area-inset-bottom);
    transition: left .25s ease; z-index: 60;
    box-shadow: 4px 0 20px rgba(0,0,0,.15);
  }
  .sidebar.open { left: 0; }
  .content {
    padding: 16px;
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    max-width: 100%;
    min-width: 0;
  }
  /* Tout enfant direct du contenu doit respecter la largeur viewport */
  .content > * { max-width: 100%; }
  /* Modal plein écran sur petits mobiles */
  .modal { padding: 0; }
  .modal-card {
    width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }
  /* Card-head passe en colonne pour éviter que le titre + actions débordent */
  .card-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .card-head > div:first-child { width: 100%; }
  /* Boutons action plus larges sur mobile, mais autorisés à rétrécir */
  .actions { width: 100%; }
  .actions .btn { flex: 1 1 0; min-width: 0; }
  .card-head .actions { width: 100%; }
}

/* PETIT MOBILE */
@media (max-width: 480px) {
  body { font-size: 14px; }
  .topbar { gap: 6px; padding-left: 8px; padding-right: 8px; }
  .topactions { gap: 6px; }
  .brand small, .brand .muted { display: none; } /* gain de place */
  .brand strong { font-size: 14px; }
  .brand .logo { width: 32px; height: 32px; }
  .datebadge { font-size: 11px; padding: 4px 8px; }
  .content { padding: 12px; }
  .card { padding: 14px; }
  h1 { font-size: 19px; }
  h2 { font-size: 16px; margin-top: 18px; }
  .table th, .table td { padding: 8px 10px; font-size: 13px; }
  .modal-card > div { padding: 16px; }
  .modal-card header, .modal-card footer { padding-left: 16px; padding-right: 16px; }
  .toast { left: 12px; right: 12px; transform: none; bottom: max(16px, env(safe-area-inset-bottom)); border-radius: 12px; text-align: center; }
}

/* TRÈS PETIT (≤360px = vieux téléphones, écrans pliés) */
@media (max-width: 360px) {
  .topbar { padding-left: 6px; padding-right: 6px; gap: 4px; }
  .brand strong { font-size: 13px; letter-spacing: 0; }
  .datebadge { display: none; } /* date prend trop de place */
  .topbar .burger { width: 40px; height: 40px; font-size: 22px; }
  .content { padding: 10px; }
  .card { padding: 12px; }
}

/* PRINT */
@media print {
  .topbar, .sidebar, .actions, .btn, footer { display: none !important; }
  .layout { grid-template-columns: 1fr; }
  .card { box-shadow: none; border-color: #999; page-break-inside: avoid; }
  body { background: #fff; }
}

/* PHOTO INPUT (réception, capture caméra mobile) */
.photo-input-wrap { margin-top: 4px; }
.photo-controls {
  display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap;
}
.photo-actions {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  flex: 1; min-width: 0;
}
.photo-thumb {
  width: 80px; height: 80px; object-fit: cover;
  border: 1px solid var(--line); border-radius: 8px;
  cursor: pointer; flex-shrink: 0;
  background: #fff;
}
.photo-thumb:hover { border-color: var(--primary-2); box-shadow: 0 0 0 2px rgba(22,96,76,.2); }
/* Miniature dans le tableau "Produits livrés" — plus petite */
.table .photo-thumb { width: 56px; height: 56px; }

/* TEMPERATURE INPUT */
.temp-input { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.temp-input input {
  width: 90px; text-align: center;
  padding: 10px 8px; min-height: 44px;
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 16px; font-family: inherit;
}

/* CCP / PRP labels */
.tag-ccp { background: #b3261e; color:#fff; padding: 2px 8px; border-radius: 4px; font-size:11px; font-weight:700; }
.tag-prp { background: #1e5cb3; color:#fff; padding: 2px 8px; border-radius: 4px; font-size:11px; font-weight:700; }

/* CHECKLIST */
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: #fff; }
.checklist li.done { background: #f1f9f3; }
.checklist li input[type="checkbox"] { width: 22px; height: 22px; margin-top: 2px; }

/* MATRIX */
.matrix { font-size: 13px; }
.matrix th { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; padding: 8px 4px; }
.matrix td.allergen-yes { background: var(--accent); color: #fff; text-align: center; font-weight: 700; }
.matrix td.allergen-no { text-align: center; color: var(--muted); }
/* Sur mobile, les en-têtes verticaux gaspillent de la place et sont peu lisibles
   → on bascule en horizontal et on laisse le wrap scroller */
@media (max-width: 700px) {
  .matrix th { writing-mode: initial; transform: none; padding: 8px 10px; min-width: 80px; }
  .matrix th:first-child, .matrix th:nth-child(2) { min-width: auto; }
}

/* Matrice mobile-first : 1re colonne (nom du plat) figée pendant le défilement
   horizontal des 14 colonnes d'allergènes. La cellule doit avoir un fond opaque
   sinon les colonnes qui défilent apparaissent dessous. */
.matrix thead th:first-child,
.matrix tbody td:first-child:not(.cat-cell) {
  position: sticky; left: 0; z-index: 2; background: #fff;
}
.matrix thead th:first-child { background: #fafaf6; z-index: 3; }
/* Lignes de regroupement par catégorie dans la matrice */
.matrix tr.cat-row td.cat-cell {
  position: sticky; left: 0; background: #f1efe7; color: var(--primary-2);
  font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
}
/* Pastilles allergènes (rouge = présent, gris clair = absent) */
.matrix td.allergen-cell { text-align: center; }
.allergen-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: #e6e4dc; }
.matrix td.allergen-cell.on .allergen-dot { background: var(--danger); }
.matrix td.nb-cell { text-align: center; font-weight: 700; color: var(--muted); }
.matrix td.nb-cell.has { color: var(--danger); }

/* Filtre par catégorie : puces tactiles (cibles ≥ 40px, s'enroulent sur mobile) */
.cat-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.cat-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; min-height: 40px;
  border: 1px solid var(--line); border-radius: 999px;
  background: #fff; color: var(--ink); font-size: 14px; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.cat-chip:hover { border-color: var(--primary-2); }
.cat-chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.cat-chip .cat-count { font-size: 12px; opacity: .65; }
.cat-chip[aria-pressed="true"] .cat-count { opacity: .85; }

/* Sous-titre de groupe catégorie (matrice + liste) */
.cat-group-title {
  display: flex; align-items: center; gap: 8px;
  margin: 18px 0 10px; font-size: 15px; color: var(--primary-2);
}

/* Liste conviviale : carte de plat (vignette + nom + chips allergènes + actions) */
.plat-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.plat-item .photo-thumb { width: 56px; height: 56px; flex: 0 0 auto; }
.plat-item .plat-main { flex: 1 1 auto; min-width: 0; }
.plat-item .plat-name { margin-bottom: 6px; }
.plat-item .plat-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.allergen-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.allergen-chip {
  display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px;
  background: #fdecea; color: var(--danger); border: 1px solid #f3c9c5;
}
.allergen-chip.none { background: #e3f3e8; color: var(--ok); border-color: #bfe3cc; }

/* Sur mobile : les actions passent sous le contenu pour ne pas écraser les chips */
@media (max-width: 560px) {
  .plat-item { flex-wrap: wrap; }
  .plat-item .plat-actions { width: 100%; justify-content: flex-end; }
}

/* ABOUT */
.about-block { max-width: 720px; }
.about-block ul { line-height: 1.8; }

/* LANGUAGE SWITCH */
.lang-switch{display:inline-flex;align-items:center;gap:6px}
/* Bascule dans la topbar (app) : à l'extrême droite de .topactions */
#langSwitch{margin-left:6px}
/* Bascule de secours sur connexion/abonnement (topbar masquée) : fixe. Sa visibilité
   est pilotée par gate.js (attribut hidden) — pas par CSS :has() qui n'est pas supporté
   sur Safari/iPadOS <15.4 ni Firefox <121 (laissait alors le switch invisible pré-login). */
#langSwitchAuth{position:fixed;top:10px;right:12px;z-index:1000}
.lang-flag{position:relative;width:26px;height:26px;padding:0;border:0;border-radius:50%;overflow:hidden;cursor:pointer;background:#012169;opacity:.5;box-shadow:0 1px 2px rgba(0,0,0,.3);transition:opacity .15s,transform .15s,box-shadow .15s}
.lang-flag .flag-svg{display:block;width:100%;height:100%}
.lang-flag::after{content:"";position:absolute;inset:0;border-radius:50%;pointer-events:none;background:radial-gradient(circle at 32% 26%,rgba(255,255,255,.55),rgba(255,255,255,.08) 38%,rgba(255,255,255,0) 55%);box-shadow:inset 0 -3px 5px rgba(0,0,0,.35),inset 0 2px 3px rgba(255,255,255,.25)}
.lang-flag:hover{opacity:.85}
.lang-flag[aria-pressed="true"]{opacity:1;transform:scale(1.06);box-shadow:0 0 0 2px #fff,0 0 0 3px rgba(0,0,0,.2),0 1px 3px rgba(0,0,0,.35)}
