/* ============ DARA — Thème terracotta / beige / blanc ============ */
:root {
  --terracotta: #C4593A;
  --terracotta-dark: #A84A2F;
  --terracotta-soft: #F0D9CF;
  --beige: #F5EFE3;
  --beige-dark: #EAE0CC;
  --white: #FFFFFF;
  --ink: #3B2A21;
  --muted: #8A7466;
  --danger: #B3362B;
  --success: #4E7C4A;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(59, 42, 33, 0.10);
  --shadow-sm: 0 3px 10px rgba(59, 42, 33, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* L'attribut hidden doit toujours gagner, même face à display:flex. */
[hidden] { display: none !important; }

/* ---------- Scrollbars (thème terracotta/beige) ---------- */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #D8C9AE;
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--terracotta);
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-corner { background: transparent; }

html, body {
  height: 100%;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--beige);
  font-size: 15px;
  -webkit-user-select: none;
  user-select: none;
}

input, textarea { -webkit-user-select: text; user-select: text; }

button { font-family: inherit; cursor: pointer; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  transition: background .15s, transform .05s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: var(--terracotta);
  color: var(--white);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) { background: var(--terracotta-dark); }

.btn-ghost {
  background: transparent;
  color: var(--terracotta);
  border: 1.5px solid var(--terracotta);
}
.btn-ghost:hover:not(:disabled) { background: var(--terracotta-soft); }

.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover:not(:disabled) { background: #92251c; }

.btn-icon {
  background: transparent;
  border: none;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--beige); color: var(--ink); }
.btn-icon.danger:hover { background: #F6DEDB; color: var(--danger); }

/* ---------- Formulaires ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: .02em;
}
.field input {
  width: 100%;
  border: 1.5px solid var(--beige-dark);
  background: var(--white);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 15px;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px rgba(196, 89, 58, .15);
}

/* ---------- Messages / badges ---------- */
.alert {
  display: none;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  margin-bottom: 14px;
}
.alert.show { display: block; }
.alert-error { background: #F6DEDB; color: var(--danger); }
.alert-success { background: #E2EDDF; color: var(--success); }

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .03em;
}
.badge-actif { background: #E2EDDF; color: var(--success); }
.badge-suspendu { background: #F6DEDB; color: var(--danger); }
.badge-role {
  background: var(--terracotta-soft);
  color: var(--terracotta-dark);
  text-transform: uppercase;
}

/* ---------- Avatars ---------- */
.avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

/* Utilitaires (évitent les styles inline, bloqués par la CSP) */
.t-bold { font-weight: 600; }
.t-muted { color: var(--muted); }
.t-mono { font-family: Consolas, monospace; }
.prod-thumb.sm { width: 34px; height: 34px; }
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--terracotta-soft);
  color: var(--terracotta-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

/* ---------- Page de connexion ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1000px 600px at 85% -10%, rgba(196, 89, 58, .16), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(196, 89, 58, .12), transparent 55%),
    var(--beige);
}
.login-card {
  width: 400px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 36px 32px;
  border-top: 5px solid var(--terracotta);
}
.login-logo {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  display: block;
  margin: 0 auto 14px;
  object-fit: cover;
  box-shadow: var(--shadow-sm);
}
.login-title {
  text-align: center;
  font-size: 30px;
  letter-spacing: .22em;
  color: var(--terracotta);
  font-weight: 800;
  margin-bottom: 2px;
}
.login-sub {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 26px;
}
.login-card .btn-primary { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }
.login-footer {
  text-align: center;
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- Layout application ---------- */
.app-body { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 240px;
  background: var(--white);
  border-right: 1px solid var(--beige-dark);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--beige-dark);
}
.sidebar-brand img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.sidebar-brand span {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: .18em;
  color: var(--terracotta);
}
.nav { flex: 1; padding: 14px 12px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
  text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--beige); color: var(--ink); }
.nav-item.active { background: var(--terracotta); color: var(--white); }

.sidebar-user {
  border-top: 1px solid var(--beige-dark);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-user .info { flex: 1; min-width: 0; }
.sidebar-user .info .name {
  font-weight: 700;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user .info .role { font-size: 11.5px; color: var(--muted); }

.main {
  flex: 1;
  overflow-y: auto;
  padding: 28px 34px;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 24px; font-weight: 800; }
.page-header .sub { color: var(--muted); font-size: 14px; margin-top: 3px; }

/* ---------- Carte / table ---------- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--beige-dark);
}
.toolbar input {
  flex: 1;
  max-width: 320px;
  border: 1.5px solid var(--beige-dark);
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 14px;
  outline: none;
  background: var(--beige);
}
.toolbar input:focus { border-color: var(--terracotta); background: var(--white); }

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  padding: 11px 14px;
  background: var(--beige);
  border-bottom: 1px solid var(--beige-dark);
  white-space: nowrap;
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--beige);
  font-size: 14px;
  vertical-align: middle;
}

/* Conteneur de tableau : défilement horizontal fin et discret uniquement
   quand c'est vraiment nécessaire, intégré au ras de la carte. */
.table-wrap { overflow-x: auto; }
.table-wrap::-webkit-scrollbar { height: 7px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }
.table-wrap::-webkit-scrollbar-thumb {
  background: #E4D8C2;
  border: none;
  border-radius: 999px;
}
.table-wrap::-webkit-scrollbar-thumb:hover { background: var(--terracotta-soft); }
tbody tr:hover { background: #FBF8F1; }
tbody tr:last-child td { border-bottom: none; }
.td-actions { text-align: right; white-space: nowrap; }
.code-pill {
  font-family: Consolas, monospace;
  background: var(--beige);
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 13px;
  font-weight: 600;
}
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-state .big { font-size: 42px; margin-bottom: 10px; }

/* ---------- Modales ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(59, 42, 33, .45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-backdrop.show { display: flex; }
.modal {
  width: 440px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 28px;
  border-top: 5px solid var(--terracotta);
}
.modal h2 { font-size: 19px; margin-bottom: 18px; }
.modal-lg { width: 760px; }

/* Modale à pied fixe : l'entête et les boutons restent visibles,
   seul le corps (formulaire) scrolle. */
.modal-flex {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-flex .modal-body {
  overflow-y: auto;
  min-height: 0;
  padding-right: 6px;
}
.modal-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--beige-dark);
  padding-top: 16px;
  margin-top: 16px;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.field select,
.field textarea {
  width: 100%;
  border: 1.5px solid var(--beige-dark);
  background: var(--white);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 15px;
  color: var(--ink);
  outline: none;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.field select:focus,
.field textarea:focus {
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px rgba(196, 89, 58, .15);
}
.field textarea { resize: vertical; }

/* Déclinaisons produit */
.variants-box {
  border: 1.5px solid var(--beige-dark);
  border-radius: 12px;
  padding: 14px 16px 16px;
  margin: 4px 0 6px;
}
.variants-box legend {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  padding: 0 8px;
  letter-spacing: .02em;
}
.variants-help {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 14px;
}

/* Champs à étiquettes (chips) */
.chip-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  border: 1.5px solid var(--beige-dark);
  background: var(--white);
  border-radius: 10px;
  padding: 7px 10px;
  min-height: 46px;
  cursor: text;
}
.chip-input:focus-within {
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px rgba(196, 89, 58, .15);
}
.chip-input .chips { display: contents; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--terracotta-soft);
  color: var(--terracotta-dark);
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.chip button {
  border: none;
  background: transparent;
  color: var(--terracotta-dark);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.chip button:hover { background: rgba(168, 74, 47, .2); }
.chip-entry {
  border: none;
  outline: none;
  flex: 1;
  min-width: 130px;
  font-size: 14px;
  padding: 4px 2px;
  background: transparent;
  color: var(--ink);
}

/* Résumé sous les chips */
.matrix-summary {
  font-size: 13px;
  font-weight: 600;
  color: var(--terracotta-dark);
  margin: 14px 0 8px;
  min-height: 18px;
}

/* Grille de déclinaisons (couleurs × tailles) */
.matrix-wrap {
  overflow-x: auto;
  border: 1px solid var(--beige-dark);
  border-radius: 10px;
}
.variant-matrix { border-collapse: collapse; width: 100%; }
.variant-matrix th,
.variant-matrix td {
  border: 1px solid var(--beige-dark);
  padding: 6px 8px;
  text-align: center;
}
.variant-matrix thead th {
  background: var(--beige);
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.variant-matrix .corner { background: var(--beige); }
.variant-matrix .row-head {
  background: var(--beige);
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}
.variant-matrix .row-head .rh {
  display: flex;
  align-items: center;
  gap: 8px;
}
td.cell-active { position: relative; padding: 4px; }
td.cell-active input {
  width: 68px;
  text-align: center;
  border: 1.5px solid var(--beige-dark);
  border-radius: 8px;
  padding: 6px 4px;
  font-size: 13.5px;
  outline: none;
  background: var(--white);
}
td.cell-active input:focus { border-color: var(--terracotta); box-shadow: 0 0 0 2px rgba(196,89,58,.14); }
.cell-x {
  position: absolute;
  top: 2px;
  right: 3px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  opacity: 0;
  transition: opacity .12s;
}
td.cell-active:hover .cell-x { opacity: 1; }
.cell-x:hover { color: var(--danger); }
td.cell-off { background: #FBF8F1; }
.cell-add {
  border: 1.5px dashed var(--beige-dark);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  width: 36px;
  height: 32px;
  cursor: pointer;
  font-size: 15px;
  transition: border-color .15s, color .15s;
}
.cell-add:hover { border-color: var(--terracotta); color: var(--terracotta); }

/* Références avancées */
.refs-advanced { margin-top: 12px; }
.refs-advanced summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 0;
}
.refs-advanced summary:hover { color: var(--terracotta); }
.refs-table { width: 100%; border-collapse: collapse; }
.refs-table th { background: var(--beige); font-size: 11px; padding: 7px 10px; }
.refs-table td { padding: 5px 10px; border-bottom: 1px solid var(--beige); font-size: 13px; }
.refs-table input {
  width: 100%;
  font-family: Consolas, monospace;
  border: 1.5px solid var(--beige-dark);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 13px;
  outline: none;
}
.refs-table input:focus { border-color: var(--terracotta); }

/* Vignette d'image (par couleur, dans l'entête de ligne de la grille) */
.v-thumb {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1.5px dashed var(--beige-dark);
  background: var(--beige);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  flex-shrink: 0;
  transition: border-color .15s;
}
.v-thumb:hover { border-color: var(--terracotta); }
.v-thumb img { width: 100%; height: 100%; object-fit: cover; }
.v-thumb-remove {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  padding: 0 2px;
}
.v-thumb-remove:hover { color: var(--danger); }

/* Image produit carrée */
.photo-square { border-radius: 12px !important; }
.photo-square img { border-radius: 8px; }

/* Ligne de déclinaisons dépliée dans la liste produits */
tr.expand-row > td { background: #FBF8F1; padding: 10px 18px 16px; }
.subtable { width: 100%; }
.subtable th {
  background: transparent;
  border-bottom: 1px solid var(--beige-dark);
  font-size: 11px;
  padding: 6px 10px;
}
.subtable td { padding: 7px 10px; font-size: 13.5px; border-bottom: 1px solid var(--beige-dark); }
.subtable tr:last-child td { border-bottom: none; }
.stock-zero { color: var(--danger); font-weight: 700; }
.prod-thumb {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--terracotta-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

/* Choix du mode de mot de passe */
.radio-row { display: flex; flex-direction: column; gap: 8px; }
.radio {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
}
.radio input[type="radio"] { accent-color: var(--terracotta); width: 16px; height: 16px; }

/* Upload de photo */
.photo-picker { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.photo-preview {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--terracotta-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--terracotta-dark);
  font-size: 26px;
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-picker .hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Mot de passe généré */
.pwd-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--beige);
  border: 1.5px dashed var(--terracotta);
  border-radius: 10px;
  padding: 13px 16px;
  margin: 14px 0;
}
.pwd-box code {
  flex: 1;
  font-family: Consolas, monospace;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .04em;
  -webkit-user-select: text;
  user-select: text;
}

/* ---------- Toasts ---------- */
#toasts {
  position: fixed;
  bottom: 22px;
  right: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
}
.toast {
  background: var(--ink);
  color: var(--white);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: toast-in .2s ease-out;
  max-width: 360px;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Clients ---------- */
.form-row-3 { grid-template-columns: 1fr 1.4fr 1fr; }
@media (max-width: 720px) { .form-row, .form-row-3 { grid-template-columns: 1fr; } }

.client-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--terracotta-soft); color: var(--terracotta-dark);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.contact-line { font-size: 13px; }
.contact-line .sub { color: var(--muted); font-size: 12.5px; }
.cell-clickable { cursor: pointer; }
tbody tr.row-link:hover { background: #FBF5EC; }

/* Fiche client */
.cd-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
@media (max-width: 1000px) { .cd-grid { grid-template-columns: 1fr; } }
.cd-contact { margin-bottom: 0; }
.cd-dl { padding: 8px 18px 16px; }
.cd-dl .row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--beige); }
.cd-dl .row:last-child { border-bottom: none; }
.cd-dl dt { color: var(--muted); font-size: 13px; width: 96px; flex-shrink: 0; }
.cd-dl dd { font-size: 14px; font-weight: 500; word-break: break-word; }
.cd-kpis { margin-bottom: 0; align-content: start; }
.cd-kpis .kpi { padding: 14px 16px; }
.cd-kpis .kpi-value { font-size: 22px; }

/* Segments de filtre */
.seg {
  display: inline-flex;
  background: var(--beige);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.seg-btn {
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--white); color: var(--terracotta-dark); box-shadow: var(--shadow-sm); }

/* Historique : ligne dépliée d'articles */
tr.order-items-row > td { background: #FBF8F1; padding: 8px 18px 14px; }

.pill-reussie { background: #E2EDDF; color: var(--success); }
.pill-renvoyee { background: #FBEED6; color: #9A6B12; }
.pill-annulee { background: #F6DEDB; color: var(--danger); }

/* Modale commande — recherche + panier */
.order-picker { position: relative; margin-bottom: 14px; }
.order-results {
  position: absolute;
  z-index: 5;
  left: 0; right: 0;
  top: 100%;
  margin-top: 4px;
  background: var(--white);
  border: 1.5px solid var(--beige-dark);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 260px;
  overflow-y: auto;
}
.order-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--beige);
}
.order-result:last-child { border-bottom: none; }
.order-result:hover { background: var(--beige); }
.order-result .thumb { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; background: var(--terracotta-soft); display:inline-flex;align-items:center;justify-content:center; }
.order-result .meta { flex: 1; min-width: 0; }
.order-result .meta .t { font-weight: 600; font-size: 13.5px; }
.order-result .meta .s { color: var(--muted); font-size: 12px; }
.order-result .stk { font-size: 12px; color: var(--muted); white-space: nowrap; }
.order-result.out { opacity: .5; cursor: not-allowed; }

.order-cart { width: 100%; border-collapse: collapse; }
.order-cart th { background: var(--beige); font-size: 11px; padding: 8px 10px; text-align: left; }
.order-cart td { padding: 7px 10px; border-bottom: 1px solid var(--beige); font-size: 13.5px; vertical-align: middle; }
.order-cart .qty-in { width: 66px; text-align: center; border: 1.5px solid var(--beige-dark); border-radius: 8px; padding: 6px; outline: none; }
.order-cart .qty-in:focus { border-color: var(--terracotta); }
.order-total { flex: 1; font-size: 16px; font-weight: 800; color: var(--terracotta-dark); }

/* ---------- Paniers ---------- */
.paniers-list { padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }
.panier {
  border: 1.5px solid var(--beige-dark);
  border-radius: 12px;
  overflow: hidden;
}
.panier-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--beige);
}
.panier-head .who { font-weight: 700; }
.panier-head .fb { font-size: 11px; color: var(--terracotta-dark); }
.panier-head .meta { color: var(--muted); font-size: 12.5px; }
.panier-head .total { margin-left: auto; font-weight: 800; color: var(--terracotta-dark); }
.panier-head .acts { display: flex; gap: 8px; }
.panier table { width: 100%; border-collapse: collapse; }
.panier td { padding: 8px 16px; border-top: 1px solid var(--beige); font-size: 13.5px; vertical-align: middle; }
.panier .pi-qty { width: 64px; text-align: center; border: 1.5px solid var(--beige-dark); border-radius: 8px; padding: 5px; outline: none; }
.panier .pi-qty:focus { border-color: var(--terracotta); }
.panier .pi-total { font-weight: 700; }
.panier.done { opacity: .85; }
.panier-date-sep { font-weight: 700; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; margin: 6px 2px -4px; }

/* ---------- Live Facebook ---------- */
.live-feed {
  max-height: 460px;
  overflow-y: auto;
  padding: 8px 0;
}
.lc {
  display: flex;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--beige);
  align-items: flex-start;
}
.lc:last-child { border-bottom: none; }
.lc-av {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: var(--beige-dark); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
}
.lc-body { flex: 1; min-width: 0; }
.lc-author { font-weight: 700; font-size: 13px; }
.lc-msg { font-size: 14px; margin-top: 1px; word-break: break-word; }
.lc-detect {
  margin-top: 7px;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.lc-detect.matched { background: #E9F1E6; border: 1px solid #CADFC2; }
.lc-detect.ambiguous { background: #FBEED6; border: 1px solid #EED9AE; }
.lc-detect .prod { font-weight: 700; }
.lc-detect .via { font-size: 11px; color: var(--muted); }
.lc-detect .via.ai { color: var(--terracotta-dark); font-weight: 700; }
.lc-detect .actions { margin-left: auto; display: flex; gap: 6px; }
.lc-ordered { background: var(--terracotta-soft); color: var(--terracotta-dark); }
.lc.done .lc-msg { color: var(--muted); }

.lo-detected {
  background: var(--beige);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 14px;
}
.lo-detected .p { font-weight: 700; }
.lo-detected .r { font-family: Consolas, monospace; font-size: 12px; color: var(--muted); }
.lo-client-picked {
  background: #E9F1E6;
  border: 1px solid #CADFC2;
  border-radius: 8px;
  padding: 9px 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
}
.lo-client-picked button { border: none; background: transparent; cursor: pointer; color: var(--muted); font-size: 14px; }

/* ---------- Inventaire ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.kpi {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  border-left: 4px solid var(--terracotta);
}
.kpi.kpi-hero {
  background: linear-gradient(135deg, var(--terracotta), var(--terracotta-dark));
  border-left: none;
  color: var(--white);
  grid-column: span 2;
}
.kpi-label {
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 7px;
}
.kpi-hero .kpi-label { color: rgba(255, 255, 255, .85); }
.kpi-value {
  font-size: 27px;
  font-weight: 800;
  margin-top: 8px;
  line-height: 1.1;
}
.kpi-hero .kpi-value { font-size: 34px; }
.kpi-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.kpi-hero .kpi-sub { color: rgba(255, 255, 255, .85); }
.kpi.kpi-warn { border-left-color: var(--danger); }
.kpi.kpi-warn .kpi-value { color: var(--danger); }
.kpi.kpi-ok { border-left-color: var(--success); }

.inv-cols {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
@media (max-width: 1100px) { .inv-cols { grid-template-columns: 1fr; } }
.inv-card { margin-bottom: 0; }
.inv-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--beige-dark);
  gap: 12px;
}
.inv-card-head h2 { font-size: 16px; font-weight: 700; }
.inv-card-note { font-size: 12px; color: var(--muted); white-space: nowrap; }

.cat-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 120px;
}
.cat-bar {
  flex: 1;
  height: 8px;
  background: var(--beige);
  border-radius: 999px;
  overflow: hidden;
  min-width: 60px;
}
.cat-bar span {
  display: block;
  height: 100%;
  background: var(--terracotta);
  border-radius: 999px;
}
.inv-pct { font-size: 12px; color: var(--muted); width: 38px; text-align: right; }

.pill-rupture { background: #F6DEDB; color: var(--danger); }
.pill-low { background: #FBEED6; color: #9A6B12; }

/* Accueil */
.welcome-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 34px 38px;
  border-left: 5px solid var(--terracotta);
}
.welcome-card h2 { font-size: 22px; margin-bottom: 8px; }
.welcome-card p { color: var(--muted); line-height: 1.6; }

/* ---------- Analyse photo (version web) ---------- */
.vision-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
@media (max-width: 900px) { .vision-grid { grid-template-columns: 1fr; } }

.vision-cam-card { overflow: hidden; }
.vision-stage {
  position: relative;
  background: #1c1512;
  aspect-ratio: 4 / 3;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius) var(--radius) 0 0;
}
.vision-stage video,
.vision-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.vision-stage video { transform: scaleX(-1); }        /* effet miroir naturel */
.vision-stage canvas { transform: scaleX(-1); pointer-events: none; }
.vision-stage img#vision-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #1c1512; z-index: 2; }
.vision-hint {
  position: absolute;
  left: 50%; bottom: 14px; transform: translateX(-50%);
  background: rgba(28, 21, 18, 0.72);
  color: #fff; font-size: 13px;
  padding: 7px 14px; border-radius: 999px;
  max-width: 90%; text-align: center;
}
.vision-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 16px;
}
.vision-actions { display: flex; gap: 10px; align-items: center; }
.vision-badge {
  font-size: 13px; font-weight: 600;
  padding: 6px 12px; border-radius: 999px;
  background: var(--beige-dark); color: var(--muted);
  transition: background .2s, color .2s;
}
.vision-badge.ready { background: #DCEBD6; color: var(--success); }
.vision-shutter:disabled { opacity: .5; cursor: not-allowed; }

.vision-result { padding: 6px 18px 20px; min-height: 120px; }
.vision-result .empty-state { padding: 30px 10px; }
.vision-analyzing { text-align: center; color: var(--muted); padding: 30px 10px; }
.spinner {
  width: 30px; height: 30px; margin: 0 auto 12px;
  border: 4px solid var(--beige-dark); border-top-color: var(--terracotta);
  border-radius: 50%; animation: spin .8s linear infinite;
}
.spinner-sm {
  display: inline-block; width: 15px; height: 15px; vertical-align: -3px; margin: 0 6px 0 0;
  border: 2.5px solid rgba(255,255,255,.5); border-top-color: #fff;
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.vision-photo {
  width: 100%; border-radius: 10px; margin-bottom: 14px;
  box-shadow: var(--shadow-sm); display: block;
}
.vr-type { font-size: 20px; font-weight: 700; color: var(--ink); }
.vr-cat { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.vr-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.vr-swatch {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--beige); border: 1px solid var(--beige-dark);
  padding: 5px 11px; border-radius: 999px; font-size: 13px;
}
.vr-swatch .dot { width: 13px; height: 13px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); }
.vr-dims {
  display: flex; gap: 10px; margin: 4px 0 14px;
}
.vr-dim {
  flex: 1; background: var(--beige); border-radius: 10px;
  padding: 12px 14px; text-align: center;
}
.vr-dim .v { font-size: 20px; font-weight: 700; color: var(--terracotta); }
.vr-dim .l { font-size: 12px; color: var(--muted); margin-top: 2px; }
.vr-note {
  font-size: 13px; color: var(--muted); line-height: 1.5;
  background: var(--beige); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px;
}
.vr-warn { color: var(--danger); font-weight: 600; }

/* ============ Responsive / Mobile ============ */
/* Sous 820px (téléphones, petites tablettes) : la barre latérale devient une
   barre supérieure avec une navigation qui défile horizontalement, et le
   contenu passe en pleine largeur avec défilement naturel de la page. */
@media (max-width: 820px) {
  .login-body { padding: 20px; }
  .login-card { width: 100%; max-width: 400px; padding: 32px 22px 26px; }

  .app-body { flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }

  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--beige-dark);
    position: sticky; top: 0; z-index: 50;
  }
  .sidebar-brand { padding: 10px 14px; border-bottom: none; flex: 0 0 auto; }
  .sidebar-brand img { width: 32px; height: 32px; }
  .sidebar-brand span { font-size: 16px; }

  .sidebar-user {
    order: 1; margin-left: auto; flex: 0 0 auto;
    border-top: none; padding: 8px 12px;
  }
  .sidebar-user .info { display: none; }   /* garder avatar + déconnexion */

  .nav {
    order: 2; flex: 1 1 100%;
    display: flex; gap: 6px;
    padding: 8px 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-top: 1px solid var(--beige-dark);
  }
  .nav::-webkit-scrollbar { height: 0; }
  .nav-item {
    flex: 0 0 auto; width: auto;
    white-space: nowrap;
    margin-bottom: 0;
    padding: 8px 13px; font-size: 13.5px;
  }

  .main { padding: 16px 14px; overflow-y: visible; }

  .page-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-header > * { width: 100%; }
  .page-header .btn { width: 100%; }

  .toolbar { flex-wrap: wrap; }
  .toolbar input { width: 100%; min-width: 0; }
  .seg { flex-wrap: wrap; }

  .kpi-grid { grid-template-columns: 1fr 1fr; }

  /* Modales : quasi plein écran, contenu défilant */
  .modal, .modal-lg { width: 94vw !important; max-width: 94vw; max-height: 92vh; }
  .modal-flex { max-height: 92vh; }

  /* Boutons d'action de fiche client empilés */
  .page-header > div[style*="display:flex"] { flex-direction: column; }
}

/* Très petits écrans : une seule colonne de KPI */
@media (max-width: 460px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .vision-toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .vision-actions { justify-content: stretch; }
  .vision-actions .btn { flex: 1; }
}
