/* ============================================================
   Pilotage — styles
   Design : warm cream + terracotta accent · Source Serif 4 (titres) + Inter Tight (texte & chiffres)
   ============================================================ */

:root {
  --bg: #faf8f4;
  --bg-2: #f3efe7;
  --card: #ffffff;
  --ink: #1a1815;
  --ink-2: #514c44;
  --ink-3: #8a8479;
  --line: #e8e2d5;
  --line-2: #d9d2c2;
  --accent: #b85834;
  --accent-soft: #f5e4db;
  --accent-2: #d97641;
  --olive: #6b7a3a;
  --olive-soft: #eaecd8;
  --mimosa: #d9a91f;
  --mimosa-soft: #fbf2d2;
  --info: #4180a8;
  --info-soft: #d5e6f0;
  --plum: #7e3f5f;
  --plum-soft: #efdfe7;
  --danger: #c23b3b;
  --danger-soft: #fadede;
  --ok: #2d7a4f;
  --ok-soft: #dcefe2;
  --radius: 8px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --shadow-sm: 0 1px 2px rgba(26,24,21,.04), 0 1px 1px rgba(26,24,21,.03);
  --shadow: 0 4px 16px rgba(26,24,21,.06), 0 1px 2px rgba(26,24,21,.04);
  --shadow-lg: 0 18px 48px rgba(26,24,21,.12), 0 2px 4px rgba(26,24,21,.04);
  --ease: cubic-bezier(.2,.9,.3,1);
  --dur: .18s;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: 'Inter Tight', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
body { min-height: 100vh; min-height: 100dvh; }
.serif { font-family: 'Source Serif 4', Georgia, serif; font-optical-sizing: auto; }
.mono { font-family: 'Inter Tight', system-ui, sans-serif; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ====== LAYOUT ====== */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  width: 240px;
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
}
.brand { padding: 0 22px 24px; border-bottom: 1px solid var(--line); }
.brand-title {
  font-family: 'Source Serif 4', serif;
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.brand-title::before {
  content: "";
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
  transform: translateY(-2px);
}
.brand-sub {
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 6px;
  font-weight: 500;
}
.nav { padding: 16px 12px; flex: 1; }
.nav-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  padding: 12px 10px 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink-2);
  font-weight: 500;
  font-size: 13.5px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg-2); color: var(--ink); }
.nav-item.active { background: var(--ink); color: #faf8f4; }
.nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item .badge {
  margin-left: auto;
  font-size: 10px;
  padding: 1px 6px;
  background: var(--accent);
  color: white;
  border-radius: 10px;
  font-weight: 600;
}
.nav-item .badge:empty { display: none; }
.user-chip {
  margin: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 12px;
}
.user-info { flex: 1; min-width: 0; line-height: 1.3; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role { color: var(--ink-3); font-size: 11px; }
.user-switch {
  border: 1px solid var(--line);
  background: var(--card);
  width: 26px; height: 26px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink-3);
  font-size: 12px;
}
.user-switch:hover { color: var(--ink); border-color: var(--ink-3); }

.main { flex: 1; margin-left: 240px; min-height: 100vh; min-height: 100dvh; }
.topbar {
  padding: 18px 32px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(12px);
  background: rgba(250,248,244,.85);
}
.topbar h1 {
  font-family: 'Source Serif 4', serif;
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.015em;
}
.search-bar { margin-left: auto; position: relative; }
.search-bar input {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 12px 7px 32px;
  width: 260px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  transition: border-color var(--dur) var(--ease);
}
.search-bar input:focus { border-color: var(--ink-3); }
.search-bar::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 16px;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  background: var(--ink-3);
  -webkit-mask: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  mask: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  pointer-events: none;
}

/* Menu déroulant « + Nouveau » (header) */
.new-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
  z-index: 1200;
  padding: 6px;
}
.new-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 13.5px;
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
}
.new-menu button:hover { background: var(--bg-2); }
.new-menu svg { width: 17px; height: 17px; color: var(--ink-3); flex: none; }

/* Dropdown autocomplete de la recherche globale */
.gsearch-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 340px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
  z-index: 1200;
  padding: 6px;
}
.gsearch-group {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  padding: 8px 8px 4px;
}
.gsearch-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 7px;
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.gsearch-item:hover { background: var(--bg-2); }
.gsearch-ico { color: var(--ink-3); display: inline-flex; flex-shrink: 0; }
.gsearch-label {
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.gsearch-sub {
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
  flex-shrink: 0;
}
.gsearch-empty {
  padding: 14px 10px;
  font-size: 12.5px;
  color: var(--ink-3);
  text-align: center;
}

.btn {
  border: 1px solid var(--line-2);
  background: var(--card);
  padding: 7px 14px;
  border-radius: 6px;
  font-family: inherit;
  font-weight: 500;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: #faf8f4; border-color: var(--ink); }
.btn-primary:hover { background: #000; }
.btn-accent { background: var(--accent); color: white; border-color: var(--accent); }
.btn-accent:hover { background: #a04a2a; border-color: #a04a2a; }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #a82b2b; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 8px; font-size: 11px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg-2); }

.content { padding: 28px 32px 60px; max-width: 1400px; }

/* ====== CARDS & GRIDS ====== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-title {
  font-family: 'Source Serif 4', serif;
  font-weight: 500;
  font-size: 16px;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.card-sub { font-size: 12px; color: var(--ink-3); margin-bottom: 14px; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }

/* ====== KPI ====== */
.kpi {
  padding: 16px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
}
.kpi-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}
.kpi-value {
  font-family: 'Source Serif 4', serif;
  font-weight: 400;
  font-size: 30px;
  letter-spacing: -0.02em;
  margin-top: 6px;
}
.kpi-value .unit { font-size: 16px; color: var(--ink-3); margin-left: 2px; }
.kpi-delta {
  font-size: 11.5px;
  margin-top: 4px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}
.kpi-delta.up { color: var(--ok); }
.kpi-delta.down { color: var(--danger); }
.kpi-delta.warn { color: var(--accent); }
.kpi-delta.flat { color: var(--ink-3); }
.kpi-sparkline {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 70px;
  height: 30px;
  opacity: .65;
}

/* ====== TABLES ====== */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  padding: 9px 10px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--card);
}
tbody td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  transition: background var(--dur) var(--ease);
}
tbody tr:last-child td { border-bottom: none; }
tfoot td { padding: 11px 10px; }
tbody tr:hover { background: var(--bg-2); }
tbody tr.clickable { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono { font-family: 'Inter Tight', system-ui, sans-serif; font-size: 12px; }

/* Tableau Stocks : largeurs maîtrisées + nom d'article sur 2 lignes max.
   min-width = somme des colonnes → en dessous, le conteneur scrolle horizontalement
   au lieu d'écraser la colonne Article (qui garde sa largeur fixe de 240px). */
#stockTable { table-layout: fixed; width: 100%; min-width: 1160px; }
#stockTable td { overflow: hidden; }
#stockTable .stk-etat { display: none; }   /* badge état visible en carte mobile uniquement */
#stockTable .stk-val-prixu { display: none; }   /* prix/u : carte mobile uniquement (desktop = valeur €) */
.stock-art-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.25;
  word-break: break-word;
}

/* Tableau Stocks → cartes compactes sur mobile (plus de scroll horizontal) */
@media (max-width: 840px) {
  .stocks-table-wrap { overflow: visible !important; border: none; background: transparent; box-shadow: none; }
  #stockTable { min-width: 0; width: 100%; table-layout: auto; display: block; }
  #stockTable thead { display: none; }
  #stockTable tbody { display: block; }
  #stockTable tr.stk-row {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "name   name"
      "stock  valeur"
      "niveau niveau"
      "foot   foot";
    align-items: center;
    gap: 2px 12px;
    padding: 11px 14px;
    margin-bottom: 8px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
  }
  #stockTable tr.stk-row:hover { background: var(--card); }
  #stockTable td { display: block; overflow: visible; padding: 0; border: none; font-size: 13px; }
  /* masqué sur la carte — dispo dans la fiche article au tap */
  #stockTable td.stk-check,
  #stockTable td[data-label="Catégorie"],
  #stockTable td[data-label="PMP"],
  #stockTable td.stk-evo { display: none; }
  #stockTable td[data-label]::before { content: none; }   /* pas de gros libellés empilés */

  #stockTable td.stk-name {
    grid-area: name;
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 1px;
  }
  #stockTable td.stk-name .stock-art-name {
    -webkit-line-clamp: unset; display: inline;
    font-size: 15.5px; font-weight: 600;
  }
  #stockTable td.stk-name .stk-etat { display: inline-block; margin-left: auto; }
  #stockTable td.stk-name .muted { display: none; }   /* unité redondante avec Stock */

  #stockTable td[data-label="Stock"] {
    grid-area: stock; text-align: left;
    font-size: 18px; font-weight: 700; color: var(--ink);
  }
  #stockTable td[data-label="Valeur"] {
    grid-area: valeur; text-align: right;
    font-size: 13px; color: var(--ink-2);
  }
  #stockTable td[data-label="Valeur"]::before {
    content: "prix "; color: var(--ink-3); font-size: 11px; font-weight: 500;
  }
  /* sur la carte mobile : prix/unité fournisseur favori (pas la valeur du stock) */
  #stockTable .stk-val-eur { display: none; }
  #stockTable .stk-val-prixu { display: inline; }
  #stockTable td.stk-niveau {
    grid-area: niveau;
    display: flex; align-items: center; gap: 10px;
    margin-top: 3px;
  }
  #stockTable td.stk-niveau .stock-bar { flex: 1; max-width: none; margin: 0; }
  #stockTable td.stk-niveau .muted { font-size: 10.5px; white-space: nowrap; margin: 0 !important; }

  /* pied : zones · fournisseur sur une ligne discrète */
  #stockTable td.stk-zones { grid-area: foot; font-size: 11.5px; color: var(--ink-3); margin-top: 5px; }
  #stockTable td.stk-fourn { display: none; }   /* fournisseur visible dans la fiche */
}

/* ====== BADGES ====== */
.badge-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  line-height: 1.5;
  white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--mimosa-soft); color: #8a6a10; }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-neutral { background: var(--bg-2); color: var(--ink-2); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-olive { background: var(--olive-soft); color: var(--olive); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-plum { background: var(--plum-soft); color: var(--plum); }

/* ====== STOCK BAR ====== */
.stock-bar {
  position: relative;
  width: 100%;
  height: 5px;
  background: var(--bg-2);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}
.stock-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .3s var(--ease);
}
.stock-bar-fill.high { background: var(--ok); }
.stock-bar-fill.mid { background: var(--mimosa); }
.stock-bar-fill.low { background: var(--danger); }

/* ====== SECTION HEADER ====== */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 28px 0 14px;
  gap: 14px;
  flex-wrap: wrap;
}
.section-header h2 {
  font-family: 'Source Serif 4', serif;
  font-weight: 500;
  font-size: 20px;
  letter-spacing: -0.015em;
}
.section-header .meta { font-size: 12px; color: var(--ink-3); }

/* ====== PAGE TRANSITION ====== */
.page { animation: fadeUp .25s var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ====== TABS / FILTERS ====== */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.tab {
  padding: 9px 14px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-weight: 500;
  font-size: 13px;
  color: var(--ink-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--dur) var(--ease);
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }

.filter-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* Page Commande (mobile) : 2 boutons d'action + filtres empilés */
.cmg-actions { display: flex; gap: 8px; margin-bottom: 12px; }
.cmg-actions .btn { flex: 1; justify-content: center; min-height: 44px; }
@media (max-width: 840px) {
  .cmg-filters { flex-direction: column; align-items: stretch; }
  .cmg-filters > *, .cmg-filters input, .cmg-filters select { width: 100%; max-width: none; }
}
.filter-row select, .filter-row input, .filter-row textarea {
  padding: 6px 10px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  background: var(--card);
  color: var(--ink);
  outline: none;
}
.filter-row select:focus, .filter-row input:focus { border-color: var(--ink-3); }

/* ====== ALERT STRIP ====== */
.alert-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 11px 14px;
  background: var(--mimosa-soft);
  border: 1px solid #eadd9a;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}
.alert-strip .alert-text { flex: 1; min-width: 180px; line-height: 1.4; }
.alert-strip .btn { flex-shrink: 0; }
.alert-strip.danger { background: var(--danger-soft); border-color: #f2bdbd; color: var(--danger); }
.alert-strip.ok { background: var(--ok-soft); border-color: #bfe2cb; color: #1a5a38; }
.alert-strip .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--mimosa);
  flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(217,169,31,.15);
}
.alert-strip.danger .dot { background: var(--danger); box-shadow: 0 0 0 4px rgba(194,59,59,.15); }
.alert-strip.ok .dot { background: var(--ok); box-shadow: 0 0 0 4px rgba(45,122,79,.15); }
.alert-dismiss {
  border: none; background: transparent;
  color: var(--ink-3);
  width: 24px; height: 24px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  display: inline-grid;
  place-items: center;
  margin-left: auto;
}
.alert-dismiss:hover { background: rgba(0,0,0,.06); color: var(--ink); }

/* ====== RECIPE CARDS ====== */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.recipe-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  cursor: pointer;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
  position: relative;
  overflow: hidden;
}
.recipe-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--rc, var(--accent));
}
.recipe-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--line-2); }
.rec-line-row { transition: background .15s ease; }
.rec-line-row:hover { background: var(--bg-2); }
.recipe-name {
  font-family: 'Source Serif 4', serif;
  font-weight: 500;
  font-size: 17px;
  letter-spacing: -0.01em;
  margin-bottom: 2px;
  margin-top: 4px;
}
.recipe-meta { font-size: 11.5px; color: var(--ink-3); margin-bottom: 14px; }
.recipe-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.recipe-stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  font-weight: 600;
}
.recipe-stat-value {
  font-family: 'Source Serif 4', serif;
  font-weight: 500;
  font-size: 15px;
  margin-top: 2px;
}

/* ====== MODAL ====== */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(26,24,21,.45);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-bg.show { display: flex; animation: fadeIn .2s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: scaleIn .22s var(--ease);
}
@keyframes scaleIn { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}
.modal-header h3 {
  font-family: 'Source Serif 4', serif;
  font-weight: 500;
  font-size: 20px;
  letter-spacing: -0.01em;
}
.modal-close {
  border: none;
  background: var(--bg-2);
  font-size: 18px;
  cursor: pointer;
  color: var(--ink-2);
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.modal-close:hover { background: var(--line); color: var(--ink); }
.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  background: var(--card);
}

/* ====== DRAWER ====== */
/* z-index > modal (100) pour pouvoir s'ouvrir par-dessus une modal */
.drawer-bg {
  position: fixed; inset: 0;
  background: rgba(26,24,21,.35);
  backdrop-filter: blur(2px);
  display: none;
  z-index: 150;
}
.drawer-bg.show { display: block; animation: fadeIn .2s var(--ease); }
.drawer {
  position: fixed;
  top: 0; right: -680px;
  width: 660px;
  max-width: 100vw;
  height: 100vh; height: 100dvh;
  background: var(--card);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 32px rgba(26,24,21,.12);
  z-index: 151;
  transition: right .28s cubic-bezier(.2,.9,.3,1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.drawer.show { right: 0; }
@media (max-width: 840px) { .drawer { width: 100%; right: -100%; } }
.drawer-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.drawer-header-top {
  display: flex; justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.drawer-title {
  font-family: 'Source Serif 4', serif; font-weight: 500;
  font-size: 24px; letter-spacing: -0.02em;
  margin-bottom: 3px;
}
.drawer-sub { font-size: 12px; color: var(--ink-3); }
.drawer-close {
  border: none; background: var(--bg-2);
  width: 32px; height: 32px; border-radius: 50%;
  cursor: pointer; font-size: 18px; color: var(--ink-2);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.drawer-close:hover { background: var(--line); }
.drawer-kpis {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.drawer-kpi {
  padding: 10px 12px;
  background: var(--bg-2);
  border-radius: 8px;
}
.drawer-kpi-label {
  font-size: 9.5px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-3);
  font-weight: 600; margin-bottom: 2px;
}
.drawer-kpi-value {
  font-family: 'Source Serif 4', serif; font-weight: 500;
  font-size: 17px; letter-spacing: -0.01em;
}
.drawer-kpi-value .unit { font-size: 11px; color: var(--ink-3); margin-left: 2px; }
.drawer-tabs {
  display: flex; gap: 2px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  overflow-x: auto;
}
.drawer-tab {
  padding: 11px 14px;
  border: none; background: transparent;
  font-family: inherit; font-weight: 500; font-size: 13px;
  color: var(--ink-3); cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
  transition: color var(--dur) var(--ease);
}
.drawer-tab:hover { color: var(--ink); }
.drawer-tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.drawer-tab .count {
  font-size: 10.5px;
  padding: 1px 6px;
  background: var(--bg-2);
  border-radius: 10px;
  font-weight: 600;
}
.drawer-tab.active .count { background: var(--accent-soft); color: var(--accent); }
.drawer-body {
  flex: 1; overflow-y: auto;
  padding: 18px 24px 40px;
}
.drawer-tab-pane { display: none; }
.drawer-tab-pane.active { display: block; animation: fadeIn .2s var(--ease); }

/* ====== FORM ====== */
.form-grid { display: grid; gap: 14px; }
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field label {
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}
.form-field input,
.form-field select,
.form-field textarea {
  padding: 8px 11px;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--card);
  outline: none;
  transition: border-color var(--dur) var(--ease);
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus { border-color: var(--accent); }
.form-field textarea { min-height: 60px; resize: vertical; }
.form-field .hint { font-size: 11px; color: var(--ink-3); }
.form-field-row { display: flex; gap: 8px; align-items: center; }

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  background: var(--bg-2);
  border: 1px solid transparent;
  border-radius: 14px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.chip:hover { background: var(--line); }
.chip.active { background: var(--ink); color: #faf8f4; }

/* ====== TOAST ====== */
.toast-host {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99999; /* toasts toujours au-dessus de l'empilement dynamique modal/drawer */
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
@media (max-width: 840px) { .toast-host { bottom: 90px; } }
.toast {
  background: var(--ink);
  color: #faf8f4;
  padding: 11px 18px 11px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  max-width: 380px;
  pointer-events: auto;
  animation: toastIn .25s var(--ease);
}
.toast.leaving { animation: toastOut .2s var(--ease) forwards; }
.toast-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ok);
  flex-shrink: 0;
}
.toast.err .toast-dot { background: var(--danger); }
.toast.warn .toast-dot { background: var(--mimosa); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

/* ====== EMPTY STATE ====== */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-3);
}
.empty-icon {
  font-family: 'Source Serif 4', serif;
  font-size: 56px;
  opacity: .2;
  margin-bottom: 12px;
}
.empty-title {
  font-family: 'Source Serif 4', serif;
  font-size: 18px;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.empty-sub { font-size: 13px; max-width: 380px; margin: 0 auto; }

/* ====== STUB PAGE (à implémenter) ====== */
.page-stub {
  padding: 50px 20px;
  text-align: center;
  background: var(--card);
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-lg);
  color: var(--ink-3);
}
.page-stub-title {
  font-family: 'Source Serif 4', serif;
  font-size: 22px;
  color: var(--ink-2);
  margin-bottom: 8px;
}
.page-stub-sub { font-size: 14px; max-width: 520px; margin: 0 auto; }

/* ====== MOBILE ====== */
.mobile-only { display: none; }
.desktop-only { display: block; }

@media (max-width: 840px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .topbar { padding: 14px 16px; }
  .content { padding: 14px 14px 100px; }
  .desktop-only { display: none !important; }
  .mobile-only { display: block; }
  .grid-4, .grid-3, .grid-2, .grid-2-1 { grid-template-columns: 1fr; }
  /* KPI dashboard : 2 colonnes compactes plutôt qu'une pile de 4 */
  .dash-kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .dash-kpis .kpi-value { font-size: 22px; }
  /* Bandeau d'alerte : texte sur toute la largeur, bouton dessous */
  .alert-strip .alert-text { flex-basis: 100%; }
  .alert-strip .btn { width: 100%; justify-content: center; min-height: 42px; }
  .topbar h1 { font-size: 18px; }
  .form-grid.cols-2, .form-grid.cols-3 { grid-template-columns: 1fr; }

  /* Derniers mouvements : table → cartes empilées */
  .dash-mvt-wrap { overflow-x: visible; }
  .dash-mvt-table { display: block; min-width: 0; }
  .dash-mvt-table thead { display: none; }
  .dash-mvt-table tbody { display: block; }
  .dash-mvt-table tr.dash-mvt-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
  }
  .dash-mvt-table td { display: block; padding: 0; border: none; }
  .dash-mvt-table td.dash-mvt-art { grid-column: 1; font-weight: 600; font-size: 14px; order: 1; }
  .dash-mvt-table td.dash-mvt-type { grid-column: 2; text-align: right; order: 2; }
  .dash-mvt-table td[data-label] { order: 3; font-size: 12.5px; }
  .dash-mvt-table td[data-label]::before {
    content: attr(data-label) " : ";
    color: var(--ink-3); font-weight: 700; font-size: 11px;
  }
  .dash-mvt-table td.dash-mvt-note:empty { display: none; }
  .dash-mvt-table td.num { text-align: left; }

  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--card);
    border-top: 1px solid var(--line);
    z-index: 90;
    padding: 8px 8px calc(env(safe-area-inset-bottom, 8px) + 8px);
    justify-content: space-around;
    box-shadow: 0 -2px 8px rgba(0,0,0,.04);
  }
  .mobile-nav button {
    flex: 1;
    background: transparent;
    border: none;
    padding: 6px 2px;
    font-family: inherit;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--ink-3);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: color var(--dur) var(--ease);
    letter-spacing: 0.02em;
    border-radius: 10px;
  }
  .mobile-nav button.active { color: var(--accent); }
  .mobile-nav button.active .mn-icon { background: var(--accent-soft); color: var(--accent); }
  .mobile-nav button .mn-icon, .mobile-nav button > svg.mn-icon {
    width: 36px;
    height: 22px;
    padding: 2px 8px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    transition: background var(--dur) var(--ease);
    box-sizing: content-box;
  }
  .mobile-nav button > svg.mn-icon { padding: 3px 9px; }
}
@media (min-width: 841px) { .mobile-nav { display: none; } }

/* Helpers */
.row { display: flex; gap: 8px; align-items: center; }
.spacer { flex: 1; }
.muted { color: var(--ink-3); }
.strong { font-weight: 600; }
hr.sep { border: none; height: 1px; background: var(--line); margin: 14px 0; }
.var-pos { color: var(--ok); font-weight: 600; }
.var-neg { color: var(--danger); font-weight: 600; }

/* ============================================================
   DRAWER — Factures reçues / Évolution prix / Par fournisseur
   (matching demo1 exactly)
   ============================================================ */

/* Toolbar des filtres dans Factures reçues */
.inv-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.inv-toolbar select {
  padding: 6px 10px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--card);
  font-family: inherit;
  font-size: 12.5px;
  color: var(--ink);
  outline: none;
}
.inv-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  background: var(--bg-2);
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.inv-filter-chip:hover { background: var(--line); }
.inv-filter-chip.active {
  background: var(--ink);
  color: #faf8f4;
}

/* Ligne facture dans la liste */
.inv-row {
  display: grid;
  /* date | fournisseur | total ligne | prix normalisé (le + à droite avant badge) | badge */
  grid-template-columns: 72px 1fr 90px 110px 60px;
  gap: 10px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 6px;
  align-items: center;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.inv-row:hover {
  border-color: var(--line-2);
  box-shadow: var(--shadow-sm);
}
.inv-row.highest {
  border-color: #f2bdbd;
  background: #fdf7f7;
}
.inv-row.lowest {
  border-color: #bfe2cb;
  background: #f7fbf8;
}
.inv-date {
  font-family: 'Inter Tight', system-ui, sans-serif;
  font-size: 11.5px;
  color: var(--ink-2);
  line-height: 1.3;
}
.inv-date .yr {
  color: var(--ink-3);
  font-size: 10.5px;
}
.inv-supplier {
  font-weight: 600;
  font-size: 13px;
}
.inv-num {
  font-family: 'Inter Tight', system-ui, sans-serif;
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 2px;
}
.inv-qty {
  text-align: right;
  font-family: 'Inter Tight', system-ui, sans-serif;
  font-size: 12.5px;
  color: var(--ink-2);
}
.inv-price {
  text-align: right;
  font-family: 'Inter Tight', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 700;
}
.inv-price .price-unit {
  font-size: 10px;
  color: var(--ink-3);
  font-weight: 500;
  display: block;
  margin-top: 1px;
}
.inv-badge-slot {
  text-align: right;
}
.inv-row.ignored { opacity: 0.72; }
.inv-ignore-btn {
  display: inline-block;
  margin-top: 4px;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: var(--card);
  color: var(--ink-3);
  cursor: pointer;
  white-space: nowrap;
}
.inv-ignore-btn:hover { border-color: var(--ink-3); color: var(--ink); }
.inv-ignore-btn.on { background: var(--mimosa-soft); border-color: var(--mimosa); color: #8a6a10; }

/* Mini graphique d'évolution prix */
.price-mini-chart {
  background: var(--bg-2);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
  position: relative;
}
.price-mini-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  gap: 10px;
  flex-wrap: wrap;
}
.price-mini-chart-title {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 700;
}
.price-mini-chart-stats {
  font-size: 11.5px;
  color: var(--ink-2);
  font-family: 'Inter Tight', system-ui, sans-serif;
}
.price-mini-chart-stats strong { color: var(--ink); }
.price-mini-svg {
  width: 100%;
  height: 90px;
  display: block;
}

/* Carte d'insight (alerte / opportunité / analyse) */
.insight-card {
  padding: 14px 16px;
  background: var(--mimosa-soft);
  border: 1px solid #eadd9a;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 12.5px;
  color: #5a4410;
  line-height: 1.5;
}
.insight-card.danger {
  background: var(--danger-soft);
  border-color: #f2bdbd;
  color: #8a2a2a;
}
.insight-card.ok {
  background: var(--ok-soft);
  border-color: #bfe2cb;
  color: #1a5a38;
}
.insight-card strong {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
}

/* Ligne fournisseur ou variation mensuelle (Par fournisseur tab + Évolution prix tab) */
.supp-row {
  display: grid;
  grid-template-columns: 1fr 90px 90px 90px;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  align-items: center;
  font-size: 12.5px;
}
.supp-row:last-child { border-bottom: none; }
.supp-row.head {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  padding: 6px 12px;
}

/* Évolution prix dans la table stocks (sparkline) */
.evo-up { color: var(--danger); font-weight: 700; }
.evo-down { color: var(--ok); font-weight: 700; }
.evo-flat { color: var(--ink-3); font-weight: 500; }

/* Mobile : empile les colonnes de la ligne facture */
@media (max-width: 840px) {
  .inv-row {
    grid-template-columns: 56px 1fr 80px 50px;
    gap: 8px;
    padding: 10px 12px;
  }
  .inv-row .inv-qty { display: none; }
  .supp-row { grid-template-columns: 1fr 80px; gap: 6px; font-size: 12px; }
  .supp-row > div:nth-child(3),
  .supp-row > div:nth-child(4) { display: none; }
}

/* ============================================================
   ICÔNES INLINE — SVG flat pro (Lucide-like)
   ============================================================ */
.icon {
  display: inline-block;
  vertical-align: -0.2em;
  flex-shrink: 0;
}
button .icon, .btn .icon, h1 .icon, h2 .icon, h3 .icon, h4 .icon {
  vertical-align: -0.18em;
}
.icon + span, span + .icon { margin-left: 4px; }
.btn .icon { margin-right: 5px; }
.btn .icon:only-child { margin-right: 0; }
.modal-header h3 .icon { margin-right: 7px; vertical-align: -0.15em; }
.empty .icon { width: 28px; height: 28px; color: var(--ink-3); margin-bottom: 8px; }
.empty-icon .icon { width: 28px; height: 28px; }
.kpi-label .icon { vertical-align: -0.15em; margin-right: 3px; opacity: .7; }

/* Icône colorée selon contexte */
.icon-danger { color: var(--danger); }
.icon-ok { color: var(--ok); }
.icon-warn { color: var(--mimosa); }
.icon-accent { color: var(--accent); }

/* ============================================================
   SÉLECTEUR DE PÉRIODE — presets + dates personnalisées
   ============================================================ */
.period-custom {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Calendrier de sélection de période avec inventaires (page Écart théo/réel) */
.varcal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.varcal-head > div { text-align: center; font-size: 10px; color: var(--ink-3); font-weight: 700; padding: 2px 0; }
.varcal-day { position: relative; text-align: center; padding: 7px 0 9px; font-size: 12px; border-radius: 6px; cursor: pointer; user-select: none; }
.varcal-day.empty { cursor: default; }
.varcal-day:not(.empty):hover { background: var(--bg-2); }
.varcal-day.has-inv { font-weight: 700; }
.varcal-day.inrange { background: var(--bg-2); }
.varcal-day.sel { background: var(--accent); color: #fff; }
.varcal-dot { position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%); width: 6px; height: 6px; border-radius: 50%; }
.varcal-day[data-tip] { position: relative; }
.varcal-day[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 5px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 6px;
  z-index: 20;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}

/* Matrice Menu Engineering : nom du plat affiché au survol du point uniquement */
#fcMatrix .fc-pt-label { opacity: 0; transition: opacity .08s ease; }
#fcMatrix .fc-pt:hover .fc-pt-label { opacity: 1; }
#fcMatrix .fc-pt:hover circle { stroke: var(--ink-3); stroke-width: 1.6; }
.period-custom input[type="date"] {
  padding: 6px 8px;
  font-size: 12.5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--card);
  color: var(--ink);
  font-family: 'Inter Tight', system-ui, sans-serif;
}
@media (max-width: 840px) {
  .period-preset { flex: 1 1 100%; min-height: 44px; font-size: 15px; }
  .period-custom { flex: 1 1 100%; }
  .period-custom input[type="date"] { flex: 1; min-height: 44px; font-size: 15px; }
}

/* Bouton "attention" (badge nouveaux articles…) */
.btn-warn {
  background: var(--mimosa-soft);
  border-color: #eadd9a;
  color: #7a5e10;
}
.btn-warn:hover { background: #f3e9c0; }

/* ============================================================
   NOUVEAUX ARTICLES — lignes non rapprochées
   ============================================================ */
.na-card {
  border: 1px solid var(--line);
  border-left: 3px solid var(--mimosa);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--card);
}
.na-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.na-libelle {
  font-family: 'Inter Tight', system-ui, sans-serif;
  font-weight: 700;
  font-size: 13.5px;
}
.na-meta { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.na-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.na-form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  display: grid;
  gap: 10px;
}
@media (max-width: 840px) {
  .na-actions { width: 100%; }
  .na-actions .btn { flex: 1; min-height: 42px; }
}

/* ============================================================
   ÉVOLUTION COS — tableau des recettes
   ============================================================ */
.cos-header {
  display: grid;
  grid-template-columns: 1fr 100px 90px 95px 90px 100px;
  gap: 10px;
  font-size: 11px; font-weight: 700; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line-2);
}
.cos-header > div:not(:first-child) { text-align: right; }
.cos-row {
  display: grid;
  grid-template-columns: 1fr 100px 90px 95px 90px 100px;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px dashed var(--line);
  cursor: pointer;
  font-size: 13px;
  transition: background .15s ease;
}
.cos-row:hover { background: var(--bg-2); }
.cos-num { text-align: right; }
@media (max-width: 840px) {
  .cos-header { display: none; }
  .cos-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-bottom: 8px;
    padding: 12px;
  }
  .cos-row .cos-nom { flex: 1 1 60%; min-width: 0; }
  .cos-row > div:nth-child(6) { margin-left: auto; }     /* évolution en haut à droite */
  .cos-row .cos-num { text-align: left; font-size: 12.5px; }
  .cos-row > div:nth-child(2)::before,
  .cos-row > div:nth-child(3)::before,
  .cos-row > div:nth-child(5)::before {
    font-size: 9.5px; color: var(--ink-3);
    text-transform: uppercase; letter-spacing: 0.05em;
    margin-right: 3px;
  }
  .cos-row > div:nth-child(2)::before { content: 'coût'; }
  .cos-row > div:nth-child(3)::before { content: 'pv'; }
  .cos-row > div:nth-child(5)::before { content: 'marge'; }
}

/* En-têtes de colonnes triables (Stocks, Évolution Prix…) */
.th-sort { cursor: pointer; user-select: none; white-space: nowrap; }
.th-sort:hover { color: var(--accent); }
.sort-ind { font-size: 9px; color: var(--accent); }

/* ============================================================
   ÉVOLUTION DES PRIX — liste cross-articles
   ============================================================ */
.px-header {
  display: grid;
  grid-template-columns: 1fr 130px 130px 100px;
  gap: 12px;
  font-size: 11px; font-weight: 700; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line-2);
}
.px-header > div:nth-child(3) { text-align: right; }
.px-header > div:nth-child(4) { text-align: right; }
.px-row {
  display: grid;
  grid-template-columns: 1fr 130px 130px 100px;
  gap: 12px;
  align-items: center;
  padding: 11px 14px;
  border-bottom: 1px dashed var(--line);
  cursor: pointer;
  transition: background .15s ease;
}
.px-row:hover { background: var(--bg-2); }
.px-art-nom { font-weight: 600; font-size: 13.5px; }
.px-art-meta { font-size: 11px; color: var(--ink-3); margin-top: 1px; }
.px-price { text-align: right; font-weight: 700; font-size: 14px; }
.px-price .px-unit { font-size: 10.5px; color: var(--ink-3); font-weight: 500; }
.px-evo { text-align: right; }

@media (max-width: 840px) {
  .px-header { display: none; }
  .px-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "art  evo"
      "spark price";
    row-gap: 8px;
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-bottom: 8px;
    padding: 12px;
  }
  .px-row .px-art { grid-area: art; }
  .px-row .px-evo { grid-area: evo; align-self: start; }
  .px-row .px-spark { grid-area: spark; }
  .px-row .px-price { grid-area: price; align-self: center; }
}

/* ============================================================
   INVENTAIRE — écran de comptage mobile-first
   ============================================================ */
.inv-count-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 5;
  padding: 4px 0 10px;
}
.inv-count-toolbar input[type="text"] {
  flex: 1;
  min-height: 42px;
  font-size: 15px;
}
.inv-toggle-restants {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-2);
  white-space: nowrap;
  cursor: pointer;
}
/* Toggle vue Par zone / Totaux */
.inv-view-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  flex-shrink: 0;
}
.inv-view-toggle button {
  border: none;
  background: var(--card);
  padding: 9px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  min-height: 42px;
}
.inv-view-toggle button.active { background: var(--accent-soft); color: var(--accent); }

/* Chips de filtre par zone */
.inv-zone-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 0 2px;
}
.inv-zone-chip {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
}
.inv-zone-chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.inv-zone-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 14px 2px 6px;
  border-bottom: 1px solid var(--line-2);
  margin-bottom: 4px;
}
.inv-count-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px dashed var(--line);
}
.inv-count-row.counted { background: var(--ok-soft); border-radius: 8px; padding-left: 8px; padding-right: 8px; }
.inv-count-info { min-width: 0; flex: 1; }
.inv-count-nom {
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.inv-count-theo { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.inv-who {
  display: inline-grid;
  place-items: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 9.5px;
  font-weight: 700;
}
.inv-count-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.inv-btn-theo {
  min-height: 40px;
  white-space: nowrap;
  font-family: 'Inter Tight', system-ui, sans-serif;
  font-size: 11px;
}
.inv-count-input { height: 42px; width: 130px; }
.inv-count-input input[type="number"] { font-size: 15px; }
.inv-count-input .prix-cur { font-size: 11px; }

@media (max-width: 840px) {
  .inv-count-row { padding: 12px 6px; }
  .inv-count-nom { font-size: 15px; }
  .inv-btn-theo { min-height: 46px; padding: 0 12px; }
  .inv-count-input { height: 46px; width: 120px; }
  .inv-count-input input[type="number"] { font-size: 16px; }
}

/* ============================================================
   ÉDITEUR RECETTE — libellé d'ingrédient cliquable (rouvre le picker)
   ============================================================ */
.er-ing {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--card);
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  color: var(--ink);
}
.er-ing:hover { border-color: var(--accent); color: var(--accent); }
.er-ing .er-ing-nom {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.er-ing > svg:last-child { flex-shrink: 0; opacity: .45; }

/* ============================================================
   PAGE FOURNISSEURS — annuaire contacts
   ============================================================ */
.fourn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px;
}
.fourn-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  transition: transform .15s var(--ease), box-shadow .15s var(--ease);
}
.fourn-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.fourn-card.inactif { opacity: .55; }
.fourn-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.fourn-card-nom {
  font-family: 'Source Serif 4', serif;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.fourn-line {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  padding: 2px 0;
  color: var(--ink-2);
  min-width: 0;
}
.fourn-line a { color: var(--accent); text-decoration: none; overflow: hidden; text-overflow: ellipsis; }
.fourn-line a:hover { text-decoration: underline; }
.fourn-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 11px;
  color: var(--ink-3);
}
.fourn-card-meta span { display: inline-flex; align-items: center; gap: 4px; }

/* Sélecteur jours de livraison */
.fourn-jours { display: flex; gap: 6px; flex-wrap: wrap; }
.fourn-jour {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  min-height: 38px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  background: var(--card);
  color: var(--ink-2);
  transition: all .12s ease;
}
.fourn-jour input { display: none; }
.fourn-jour.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
@media (max-width: 840px) {
  .fourn-grid { grid-template-columns: 1fr; }
  .fourn-jour { min-height: 44px; flex: 1; }
}

/* Sélecteur multi-options : chips inline (ordi) / menu déroulant (mobile) */
.ms-dd > .ms-dd-summary { display: none; }
.ms-dd > .ms-dd-panel { display: flex; }   /* ordi : chips visibles (hérite .fourn-jours) */

@media (max-width: 840px) {
  .ms-dd { position: relative; }
  .ms-dd > .ms-dd-summary {
    display: flex; align-items: center; gap: 8px; width: 100%;
    min-height: 46px; padding: 11px 14px;
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--card); color: var(--ink); cursor: pointer;
    font-family: inherit; font-size: 15px; font-weight: 500; text-align: left;
  }
  .ms-dd .ms-dd-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ms-dd .ms-dd-caret { color: var(--ink-3); flex-shrink: 0; transition: transform .18s ease; }
  .ms-dd.open > .ms-dd-summary { border-color: var(--accent); border-radius: 10px 10px 0 0; }
  .ms-dd.open .ms-dd-caret { transform: rotate(180deg); }

  .ms-dd > .ms-dd-panel { display: none; }
  .ms-dd.open > .ms-dd-panel {
    display: flex; flex-direction: column; gap: 2px;
    padding: 4px; margin: 0;
    border: 1px solid var(--accent); border-top: none; border-radius: 0 0 10px 10px;
    background: var(--card); max-height: 48dvh; overflow-y: auto;
  }
  .ms-dd.open > .ms-dd-panel .fourn-jour {
    width: 100%; flex: none; justify-content: flex-start;
    min-height: 44px; padding: 10px 12px; gap: 10px;
    border: none; border-radius: 8px; font-weight: 500;
  }
  .ms-dd.open > .ms-dd-panel .fourn-jour.on { background: var(--accent-soft); }
  .ms-dd.open > .ms-dd-panel .fourn-jour:not(.ms-add)::before {
    content: ''; width: 19px; height: 19px; flex-shrink: 0;
    border: 1.6px solid var(--line-2); border-radius: 5px;
    background-position: center; background-repeat: no-repeat; background-size: 13px;
  }
  .ms-dd.open > .ms-dd-panel .fourn-jour.on::before {
    background-color: var(--accent); border-color: var(--accent);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  }
  .ms-dd.open > .ms-dd-panel .ms-add {
    color: var(--accent); justify-content: center;
    border: 1px dashed var(--line-2) !important; margin-top: 2px;
  }
}

/* Variante FILTRE : menu déroulant flottant sur ordi ET mobile (jamais chips inline) */
.ms-filter { position: relative; display: inline-block; min-width: 160px; vertical-align: top; }
.ms-filter > .ms-dd-summary {
  display: flex !important; align-items: center; gap: 8px; width: 100%;
  min-height: 36px; padding: 6px 10px;
  border: 1px solid var(--line-2); border-radius: 6px;
  background: var(--card); color: var(--ink); cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 500; text-align: left;
}
.ms-filter .ms-dd-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-filter .ms-dd-caret { color: var(--ink-3); flex-shrink: 0; transition: transform .18s ease; }
.ms-filter.open > .ms-dd-summary { border-color: var(--accent); }
.ms-filter.open .ms-dd-caret { transform: rotate(180deg); }
.ms-filter > .ms-dd-panel {
  display: none !important;
  position: absolute !important; top: calc(100% + 4px); left: 0; z-index: 60;
  flex-direction: column; gap: 2px;
  min-width: 100%; width: max-content; max-width: 280px; max-height: 320px; overflow-y: auto;
  background: var(--card) !important; border: 1px solid var(--line-2) !important;
  border-radius: 8px !important; box-shadow: var(--shadow); padding: 4px;
}
.ms-filter.open > .ms-dd-panel { display: flex !important; }
.ms-filter .fourn-jour {
  width: 100%; flex: none; justify-content: flex-start;
  min-height: 38px; padding: 8px 10px; gap: 10px;
  border: none; border-radius: 6px; font-weight: 500; font-size: 13px;
}
.ms-filter .fourn-jour.on { background: var(--accent-soft); }
.ms-filter .fourn-jour::before {
  content: ''; width: 18px; height: 18px; flex-shrink: 0;
  border: 1.5px solid var(--line-2); border-radius: 5px;
  background-position: center; background-repeat: no-repeat; background-size: 12px;
}
.ms-filter .fourn-jour.on::before {
  background-color: var(--accent); border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
}
@media (max-width: 840px) {
  .ms-filter { display: block; width: 100%; min-width: 0; }
  .ms-filter > .ms-dd-summary { min-height: 46px; font-size: 15px; border-radius: 10px; }
  .ms-filter > .ms-dd-panel { max-width: none; width: 100%; }
}

/* ============================================================
   LIGHTBOX — zoom image plein écran
   ============================================================ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(20, 18, 16, .92);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
  animation: fadeIn .15s var(--ease);
}
.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  box-shadow: 0 12px 48px rgba(0,0,0,.5);
  object-fit: contain;
}
.lightbox-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.15);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.lightbox-close:hover { background: rgba(255,255,255,.28); }

/* ============================================================
   PAGE FACTURES — lignes avec matching
   ============================================================ */
.fac-line {
  position: relative;
  padding: 14px 14px 12px;
  padding-right: 44px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fac-line .fac-line-libelle {
  width: 100%;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 12px;
  min-height: 42px;
}
.fac-line-remove {
  position: absolute;
  top: 12px; right: 12px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-3);
  border: 1px solid var(--line);
  padding: 0;
  display: grid; place-items: center;
}
.fac-line-remove:hover, .fac-line-remove:active {
  background: var(--danger-soft); color: var(--danger); border-color: #f2bdbd;
}

/* Chip d'association produit */
.fac-match-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px dashed var(--line-2);
  background: var(--card);
  color: var(--ink-2);
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  min-height: 40px;
}
.fac-match-chip.matched {
  border-style: solid;
  border-color: var(--ok);
  background: var(--ok-soft);
  color: #1a5a38;
}
.fac-match-chip.unmatched:hover { border-color: var(--accent); color: var(--accent); }
.fac-match-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Contrôles qte + prix + total sur une ligne */
.fac-line-controls {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto;
  gap: 10px;
  align-items: center;
}
.fac-line-controls .qte-stepper { height: 44px; }
.fac-line-controls .prix-input { height: 44px; }
.fac-line-total {
  font-family: 'Inter Tight', system-ui, sans-serif;
  font-weight: 700;
  font-size: 14px;
  text-align: right;
  white-space: nowrap;
  min-width: 64px;
}

/* Footer du picker de matching */
.fac-match-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: var(--card);
}
.fac-match-footer .btn { width: 100%; justify-content: center; min-height: 44px; }
.fac-match-section-label {
  font-size: 10.5px; font-weight: 700; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.07em;
  padding: 12px 14px 6px;
  display: flex; align-items: center; gap: 5px;
}

@media (max-width: 840px) {
  .fac-line-controls { grid-template-columns: 1.4fr 1fr; grid-template-areas: "qte prix" "total total"; }
  .fac-line-controls .qte-stepper { grid-area: qte; }
  .fac-line-controls .prix-input { grid-area: prix; }
  .fac-line-total { grid-area: total; text-align: right; font-size: 15px; }
}

/* ============================================================
   PAGE RÉCEPTION — Mobile-first (cuisine, tablette, téléphone)
   ============================================================ */

/* Mode AUTO — 2 gros boutons côte à côte */
.recep-auto-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}
.recep-auto-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 12px;
  min-height: 88px;
  border: 1.5px dashed var(--line-2);
  background: var(--bg-2);
  transition: all .15s ease;
  border-radius: 12px;
}
.recep-auto-btn:hover, .recep-auto-btn:active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.recep-auto-btn-icon { font-size: 28px; line-height: 1; }
.recep-auto-btn-label { font-size: 13px; font-weight: 600; }

/* Liste des photos ajoutées (mode auto) — grille de cards */
.recep-photo-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}
.recep-photo-card {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  color: var(--ink);
}
.recep-photo-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}
.recep-photo-doc {
  aspect-ratio: 4/3;
  display: grid;
  place-items: center;
  font-size: 42px;
  background: var(--card);
}
.recep-photo-meta {
  padding: 8px 10px;
  font-size: 11.5px;
  line-height: 1.35;
}
.recep-photo-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recep-photo-size {
  color: var(--ink-3);
  font-size: 10.5px;
  margin-top: 2px;
}
.recep-photo-remove {
  position: absolute;
  top: 6px; right: 6px;
  width: 28px; height: 28px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  box-shadow: var(--shadow);
}


/* En-tête tableau (desktop) */
.recep-list-header {
  font-size: 11px; font-weight: 700; color: var(--ink-3);
  display: grid;
  grid-template-columns: 104px 1fr 80px 100px 104px 136px;
  column-gap: 12px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line-2);
  letter-spacing: 0.06em; text-transform: uppercase;
}

/* Vue Commande unifiée (desktop) : encarts par statut */
.ord-section { margin-bottom: 20px; }
.ord-section-head { display: flex; align-items: center; gap: 8px; margin: 0 0 8px 2px; }
.ord-section-head .icon { color: var(--ink-3); }
.ord-section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); }
.ord-section-count { margin-left: 2px; font-size: 10.5px; }
.ord-section .recep-row:last-child { border-bottom: none; }
.recep-list-header > div:nth-child(3),
.recep-list-header > div:nth-child(4),
.recep-list-header > div:nth-child(5) { text-align: right; }

/* Ligne réception (desktop) */
.recep-row {
  display: grid;
  grid-template-columns: 104px 1fr 80px 100px 104px 136px;
  column-gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
  align-items: center;
  cursor: pointer;
  transition: background .15s ease;
  min-height: 56px;
}
.recep-row:hover { background: var(--bg-2); }
/* Lignes « commande à réceptionner » (en haut de la liste Réception) — liseré accent */
.recep-row-pending { box-shadow: inset 3px 0 0 var(--accent); background: rgba(184, 88, 52, .05); }
.recep-row-pending:hover { background: rgba(184, 88, 52, .1); }
.recep-row .recep-date-block { line-height: 1.35; }
.recep-row .recep-supplier { font-weight: 600; }
.recep-row .recep-meta { color: var(--ink-3); font-size: 11px; margin-top: 2px; }
.recep-row .recep-num,
.recep-row .recep-total,
.recep-row .recep-status,
.recep-row .recep-action { text-align: right; }
.recep-row .recep-action button { min-height: 36px; }

/* Picker overlay (modal-dans-modal pour l'ajout de produit) */
.recep-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,24,21,.48);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fadeIn .15s var(--ease);
}
.recep-picker-card {
  background: var(--card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 640px;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: pickerSlideUp .25s var(--ease);
}
@keyframes pickerSlideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.recep-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
}
.recep-picker-title {
  font-family: 'Source Serif 4', serif;
  font-weight: 500;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.recep-picker-sub {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
}
.recep-picker-search {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}
.recep-picker-search input {
  width: 100%;
  font-size: 16px;
  padding: 10px 14px;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
}

/* Recherche picker (zone résultat) */
.recep-search-wrap { position: relative; }
.recep-search-results {
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-top: 4px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 10;
  display: none;
}
/* Variante inline (utilisée dans le picker overlay : pas de positionnement absolu,
   pas de border, déborde naturellement dans la card) */
.recep-search-results--inline {
  position: static;
  border: none;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
  max-height: none;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: block !important;
}
/* Groupe = article générique ; options = fiches fournisseur dessous */
.rsr-group { border-bottom: 1px solid var(--line); }
.rsr-group:last-child { border-bottom: none; }
.rsr-group-head {
  font-size: 13.5px;
  font-weight: 700;
  padding: 11px 14px 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rsr-group-count {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 20px;
  padding: 2px 8px;
  letter-spacing: 0.02em;
}
.rsr-group-head .cmd-stock-pill { margin-left: auto; }
.recep-line-title .cmd-stock-pill { vertical-align: middle; margin-left: 4px; }
.rsr-option {
  padding-left: 26px !important;     /* options indentées sous le générique */
  border-bottom: 1px dashed var(--line);
  min-height: 48px !important;
}
.rsr-option:last-child { border-bottom: none; }
.rsr-supplier-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  font-family: 'Inter Tight', system-ui, sans-serif;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recep-search-result {
  padding: 11px 14px;
  cursor: pointer;
  border-bottom: 1px dashed var(--line);
  display: grid;
  grid-template-columns: 1fr 130px;
  gap: 10px;
  align-items: center;
  min-height: 54px;
}
.recep-search-result:hover, .recep-search-result:active { background: var(--bg-2); }
.recep-search-result:last-child { border-bottom: none; }
.recep-search-result .rsr-title { font-weight: 600; font-size: 13px; line-height: 1.3; }
.recep-search-result .rsr-meta { color: var(--ink-3); font-size: 11.5px; margin-top: 3px; line-height: 1.35; }
.recep-search-result .rsr-price { text-align: right; font-family: 'Inter Tight', system-ui, sans-serif; font-size: 13px; }
.recep-search-result .rsr-price small { color: var(--ink-3); font-size: 10.5px; }

/* Lignes du modal réception (desktop) — alignement strict header/row */
.recep-line-header {
  font-size: 11px; font-weight: 700; color: var(--ink-3);
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 130px 180px 90px 36px;
  gap: 12px; padding: 10px 4px 6px;
  border-bottom: 1px solid var(--line-2);
  text-transform: uppercase; letter-spacing: 0.06em;
  align-items: end;
}
.recep-line-header > div:nth-child(2) { text-align: center; }
.recep-line-header > div:nth-child(3) { text-align: center; }
.recep-line-header > div:nth-child(4) { text-align: right; }

.recep-line {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 130px 180px 90px 36px;
  gap: 12px; align-items: center;
  padding: 12px 4px;
  border-bottom: 1px dashed var(--line);
  position: relative;
}
.recep-line .recep-line-product { min-width: 0; }
.recep-line .recep-line-title { font-weight: 600; font-size: 14px; line-height: 1.3; }
.recep-line .recep-line-sub { color: var(--ink-3); font-size: 11.5px; margin-top: 2px; }
.recep-line .recep-line-meta-mobile { display: none; }
.recep-line .recep-line-total {
  font-family: 'Inter Tight', system-ui, sans-serif;
  font-weight: 700;
  text-align: right;
  font-size: 14px;
}
.recep-line .recep-line-remove {
  width: 34px; height: 34px;
  padding: 0;
  display: grid; place-items: center;
  border-radius: 8px;
}

/* ============================================================
   COMPARATIF commande vs réception (vue détail réception)
   ============================================================ */
.cmp-header {
  display: grid;
  grid-template-columns: 1fr 130px 130px 110px;
  gap: 10px;
  font-size: 11px; font-weight: 700; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 8px 4px 6px;
  border-bottom: 1px solid var(--line-2);
}
.cmp-row {
  display: grid;
  grid-template-columns: 1fr 130px 130px 110px;
  gap: 10px;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
}
.cmp-row.cmp-warn {
  background: var(--mimosa-soft);
  border-left: 3px solid var(--mimosa);
  padding-left: 8px;
}
.cmp-row.cmp-missing {
  background: var(--danger-soft);
  border-left: 3px solid var(--danger);
  padding-left: 8px;
}
.cmp-prod-title { font-weight: 600; line-height: 1.3; }
.cmp-prod-sub { color: var(--ink-3); font-size: 11px; margin-top: 1px; }
.cmp-mini-label { display: none; }
.cmp-val-diff { color: #7a5e10; font-weight: 700; }
.cmp-val-bad { color: var(--danger); font-weight: 700; }
.cmp-statut {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  flex-wrap: wrap;
  align-items: center;
}

/* Chips d'écart chiffrées : la valeur du delta, signée et colorée */
.ecart-chip {
  display: inline-flex;
  align-items: center;
  font-family: 'Inter Tight', system-ui, sans-serif;
  font-weight: 700;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  line-height: 1.3;
}
.ecart-chip.e-down { background: var(--danger-soft); color: var(--danger); }        /* reçu en moins / manquant */
.ecart-chip.e-up { background: var(--mimosa-soft); color: #7a5e10; }                /* reçu en plus */
.ecart-chip.e-prix-up { background: var(--danger-soft); color: var(--danger); }     /* plus cher que commandé */
.ecart-chip.e-prix-down { background: var(--ok-soft); color: #1a5a38; }             /* moins cher */
.ecart-ok { color: var(--ok); display: inline-flex; }

@media (max-width: 840px) {
  /* Version COMPACTE : 2 lignes de texte par produit, badge à droite du titre,
     « commandé → reçu » sur une seule ligne, pas de labels verbeux. */
  .cmp-header { display: none; }
  .cmp-row {
    grid-template-columns: 1fr auto auto;
    grid-template-areas:
      "prod prod statut"
      "cmd  recu recu";
    row-gap: 3px;
    column-gap: 6px;
    align-items: center;
    border-radius: 9px;
    border: 1px solid var(--line);
    margin-bottom: 6px;
    padding: 9px 11px;
    font-size: 12.5px;
  }
  .cmp-row.cmp-warn, .cmp-row.cmp-missing { padding-left: 9px; border-left-width: 3px; }
  .cmp-row .cmp-prod { grid-area: prod; min-width: 0; }
  .cmp-prod-title {
    display: inline;
    font-size: 13.5px;
  }
  .cmp-prod-sub {
    display: inline;
    margin-left: 5px;
    font-size: 11px;
  }
  .cmp-row .cmp-cell:nth-of-type(2) { grid-area: cmd; }
  .cmp-row .cmp-cell:nth-of-type(3) {
    grid-area: recu;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .cmp-row .cmp-cell:nth-of-type(3)::before {
    content: "→";
    color: var(--ink-3);
    font-family: 'Inter Tight', system-ui, sans-serif;
  }
  .cmp-row .cmp-cell .mono { font-size: 12.5px; white-space: nowrap; }
  .cmp-mini-label { display: none; }
  .cmp-row .cmp-statut {
    grid-area: statut;
    justify-content: flex-end;
    align-self: start;
  }
  .cmp-row .cmp-statut .badge-tag,
  .cmp-row .cmp-statut .ecart-chip {
    font-size: 10px;
    padding: 2px 7px;
  }
}

/* Écart vs bon de commande — signalement visuel */
.recep-line.has-ecart {
  border-left: 3px solid var(--mimosa);
  background: var(--mimosa-soft);
  padding-left: 11px;
}
.recep-ecart-note {
  grid-column: 1 / -1;
  font-size: 11.5px;
  color: #7a5e10;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
.recep-ecart-note strong { color: #5a4410; }
.qte-stepper.field-ecart,
.prix-input.field-ecart {
  border-color: var(--mimosa);
  box-shadow: 0 0 0 2px var(--mimosa-soft);
}

/* ========== STEPPER quantité — composant réutilisable ========== */
.qte-stepper {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: var(--card);
  height: 40px;
  width: 100%;
  user-select: none;
}
.qte-stepper .qte-step-btn {
  flex: 0 0 38px;
  border: none;
  background: var(--bg-2);
  color: var(--ink);
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  line-height: 1;
  transition: background .12s ease;
}
.qte-stepper .qte-step-btn:hover { background: var(--line); }
.qte-stepper .qte-step-btn:active { background: var(--line-2); color: var(--accent); }
.qte-stepper input[type="number"] {
  flex: 1 1 auto;
  border: none;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  font-family: 'Inter Tight', system-ui, sans-serif;
  min-width: 0;
  padding: 0 4px;
  background: transparent;
  outline: none;
  /* masque les flèches natives du browser */
  appearance: textfield;
  -moz-appearance: textfield;
}
.qte-stepper input[type="number"]::-webkit-outer-spin-button,
.qte-stepper input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ========== INPUT prix avec suffixe d'unité ========== */
.prix-input {
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  height: 40px;
  padding: 0 10px 0 0;
  overflow: hidden;
}
.prix-input input[type="number"] {
  flex: 1 1 auto;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
  font-weight: 600;
  font-family: 'Inter Tight', system-ui, sans-serif;
  padding: 0 6px 0 12px;
  text-align: right;
  min-width: 0;
  appearance: textfield;
  -moz-appearance: textfield;
}
.prix-input input[type="number"]::-webkit-outer-spin-button,
.prix-input input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.prix-input .prix-unit {
  font-size: 11.5px;
  color: var(--ink-3);
  white-space: nowrap;
  font-weight: 500;
  flex-shrink: 0;
}

/* ============================================================
   MOBILE — Réception (≤ 840px)
   ============================================================ */
@media (max-width: 840px) {
  /* On masque l'en-tête tableau, on bascule les lignes en cards */
  .recep-list-header { display: none; }
  .recep-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "main  status"
      "date  total";
    row-gap: 2px;
    column-gap: 10px;
    padding: 10px 12px;
    min-height: auto;
    align-items: center;
  }
  .recep-row .recep-supplier-block { grid-area: main; }
  .recep-row .recep-supplier { font-size: 14.5px; }
  .recep-row .recep-meta { font-size: 11px; margin-top: 1px; }
  .recep-row .recep-date-block {
    grid-area: date; display: flex; gap: 6px; align-items: baseline; line-height: 1.2;
  }
  .recep-row .recep-date-block > div { font-size: 11.5px !important; font-weight: 500 !important; color: var(--ink-3) !important; }
  .recep-row .recep-num { display: none; }   /* nombre de lignes / comptés : superflu sur mobile */
  .recep-row .recep-total { grid-area: total; font-size: 15px; font-weight: 700; text-align: right; }
  .recep-row .recep-status { grid-area: status; text-align: right; align-self: center; }
  .recep-row .recep-temp,
  .recep-row .recep-action { display: none; }

  /* Page Commande mobile : bouton Réceptionner pleine largeur sous le badge */
  .cmg-row.has-receive {
    grid-template-areas:
      "main  status"
      "date  total"
      "action action";
  }
  .cmg-row.has-receive .recep-action {
    display: block; grid-area: action; margin-top: 2px;
  }
  .cmg-row.has-receive .recep-action .btn {
    width: 100%; justify-content: center; min-height: 42px;
  }

  /* Modale = bottom sheet : remonte du bas, coins hauts arrondis, laisse voir la page derrière */
  .modal-bg { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100% !important;
    width: 100%;
    max-height: 92dvh !important;
    height: auto;
    border-radius: 18px 18px 0 0;
    animation: sheetUp .28s var(--ease);
  }
  .modal::before {
    content: '';
    display: block;
    width: 38px; height: 4px;
    border-radius: 999px;
    background: var(--line-2);
    margin: 8px auto 2px;
    flex-shrink: 0;
  }
  .modal-body { padding: 12px 16px 88px; }
  .modal-header { padding: 8px 16px 12px; }
  .modal-footer {
    padding: 12px 16px calc(env(safe-area-inset-bottom, 8px) + 10px);
    position: sticky; bottom: 0;
    flex-wrap: wrap;           /* les boutons s'enroulent au lieu de déborder hors champ */
  }
  .modal-footer .btn { flex: 1 1 auto; min-height: 44px; justify-content: center; }
  .modal-footer .btn-accent, .modal-footer .btn-primary { flex-basis: 100%; }  /* action principale pleine largeur */
  .modal-footer > div:empty { display: none; }   /* spacer flex:1 ne prend pas une ligne */

  /* Inputs / selects : 16px pour éviter le zoom iOS, touch targets confortables */
  .modal input[type="text"],
  .modal input[type="number"],
  .modal input[type="search"],
  .modal input[type="file"],
  .modal textarea,
  .modal select {
    font-size: 16px;
    min-height: 44px;
    padding: 10px 12px;
  }
  .modal textarea { min-height: 70px; }

  /* Tabs réception (manuel/auto) plus gros */
  .modal .tabs .tab {
    padding: 12px 8px;
    font-size: 13px;
    min-height: 48px;
  }

  /* Search results : layout plus aéré */
  .recep-search-results { max-height: 50dvh; }
  .recep-search-result {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 14px;
    min-height: 64px;
  }
  .recep-search-result .rsr-price { text-align: left; font-size: 14px; }
  .recep-search-result .rsr-price small { display: inline; margin-left: 6px; }

  /* Lignes : card mobile — titre + total en haut, meta dessous, qte+prix en bas.
     Corbeille flotte en absolute coin haut droit. Sur mobile le prix n'affiche que "€"
     (le conditionnement est déjà dans la ligne meta). */
  .recep-line-header { display: none; }
  .recep-line {
    grid-template-columns: 1.5fr 1fr;
    grid-template-areas:
      "title  total"
      "qte    prix";
    row-gap: 8px;
    column-gap: 10px;
    padding: 10px 12px;
    padding-right: 40px;            /* place pour la poubelle */
    background: var(--card);
    border-radius: 10px;
    border: 1px solid var(--line);
    margin-bottom: 7px;
    position: relative;
    align-items: center;
  }
  .recep-line .recep-line-product { grid-area: title; min-width: 0; align-self: center; }
  .recep-line .recep-line-title { font-size: 14px; line-height: 1.2; }
  .recep-line .recep-line-sub { display: block; font-size: 11px; color: var(--ink-3); margin-top: 1px; }
  .recep-line .recep-line-meta-mobile { display: none; }   /* info déjà dans le sous-titre */
  .recep-line .recep-line-total {
    grid-area: total;
    font-size: 15px;
    text-align: right;
    align-self: center;
    font-weight: 700;
    white-space: nowrap;
  }

  /* Stepper — colonne gauche, compact */
  .recep-line .qte-stepper {
    grid-area: qte;
    height: 42px;
    width: 100%;
    min-width: 0;
  }
  .recep-line .qte-stepper .qte-step-btn {
    flex: 0 0 38px;
    font-size: 22px;
  }
  .recep-line .qte-stepper input[type="number"] {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 16px;
    padding: 0 2px;
  }

  /* Prix — colonne droite, compact */
  .recep-line .prix-input {
    grid-area: prix;
    height: 42px;
    width: 100%;
    min-width: 0;
    padding-right: 10px;
  }
  .recep-line .prix-input input[type="number"] {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 16px;
    padding-left: 10px;
  }
  .recep-line .prix-input .prix-cond { display: none; }   /* masque " / Bouteille 70cl" sur mobile */
  .recep-line .prix-input .prix-cur { font-size: 14px; font-weight: 600; color: var(--ink-2); }

  /* Poubelle : cercle discret coin haut droit */
  .recep-line .recep-line-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    grid-area: unset;
    width: 26px; height: 26px;
    border-radius: 50%;
    background: transparent;
    color: var(--ink-3);
    border: 1px solid var(--line);
    padding: 0;
    box-shadow: none;
  }
  .recep-line .recep-line-remove:hover,
  .recep-line .recep-line-remove:active {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: #f2bdbd;
  }

  /* Filter row au-dessus de la liste (page Réception) */
  .filter-row { flex-wrap: wrap; gap: 8px; }
  .filter-row input[type="text"],
  .filter-row select {
    min-height: 44px; font-size: 15px; flex: 1 1 100%;
  }
  .filter-row .btn { flex: 1 1 100%; min-height: 48px; font-size: 14px; }
  .filter-row .spacer { display: none; }

  /* Mode auto : boutons photo encore plus gros */
  .recep-auto-btn { min-height: 110px; padding: 22px 12px; }
  .recep-auto-btn-icon { font-size: 36px; }
  .recep-auto-btn-label { font-size: 14px; }

  /* Liste photos : 2 colonnes sur mobile pour rester lisible */
  .recep-photo-list { grid-template-columns: 1fr 1fr; gap: 8px; }
}
