/* ═══════════════════════════════════════════════════════════
   Kiosque Promesse de Dieu — CSS v8.0 | Design POS Square-inspired
   100% Responsive (Mobile & Desktop) - Animations Fluides
   Polices: Plus Jakarta Sans + JetBrains Mono
   ═══════════════════════════════════════════════════════════ */

/* Google Fonts chargé via <link> dans index.html — pas de @import ici pour éviter le double chargement bloquant */

/* ── BOOT OVERLAY — masque le flash login au rechargement ─── */
#s-boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--sb-bg, #0B111A);
  transition: opacity 0.18s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
#s-boot-overlay.boot-done {
  opacity: 0;
  pointer-events: none;
}
.boot-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.boot-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  animation: boot-pulse 1.4s ease-in-out infinite;
}
.boot-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--blue, #B5651D);
  border-radius: 50%;
  animation: boot-spin 0.8s linear infinite;
}
.boot-text {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.65);
  letter-spacing: 0.02em;
}
@keyframes boot-spin {
  to { transform: rotate(360deg); }
}
@keyframes boot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.94); }
}

/* ── VARIABLES GLOBALES ──────────────────────────────────── */
:root {
  /* Transitions sobres — pas de bounce/spring, juste fondu net */
  --ease:        ease;
  --ease-spring: ease;
  --trans:       background 0.15s var(--ease), border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), color 0.15s var(--ease), transform 0.1s var(--ease);
  --trans-fast:  background 0.12s var(--ease), border-color 0.12s var(--ease), color 0.12s var(--ease), transform 0.1s var(--ease);
  --trans-bounce:background 0.15s var(--ease), border-color 0.15s var(--ease);

  /* Sidebar (Couleurs originales) */
  --sb-w:      260px;
  --sb-w-col:  76px;
  --sb-bg:     #0B111A;
  --sb-border: rgba(255,255,255,0.08);
  --sb-text:   rgba(255,255,255,0.6);
  --sb-hover:  rgba(255,255,255,0.06);
  --sb-active: rgba(255,255,255,0.12);

  /* Content (Couleurs originales) */
  --bg:        #F4F6F8;
  --card:      #FFFFFF;
  --border:    #E5E7EB;
  --border2:   #F3F4F6;

  /* Couleurs sémantiques (Couleurs du boss) */
  --text:      #0F172A; /* Slate 900 */
  --text2:     #475569; /* Slate 600 */
  --text3:     #94A3B8; /* Slate 400 */
  
  --green:     #059669; /* Emerald 600 (Plus sombre, pro) */
  --green-lt:  #D1FAE5;
  --red:       #DC2626; /* Red 600 */
  --red-lt:    #FEE2E2;
  --blue:      #B5651D; /* Accent marque — Ardoise & Cuivre */
  --blue-lt:   #FDECD3; /* Accent marque clair */
  --orange:    #D97706; /* Amber 600 */
  --orange-lt: #FEF3C7;
  --purple:    #475569;
  --purple-lt: #E2E8F0;

  /* Dimensions */
  --topbar-h:  70px; /* Plus compact et net */

  /* Rayons (Arrondis affinés) */
  --r:   8px;  /* Arrondis plus nets */
  --rlg: 12px;
  --rxl: 16px;

  /* Ombres Pro (Nettes, plates, "Square/Stripe" style) */
  --sh-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --sh:    0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --sh-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
  --sh-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -2px rgba(15, 23, 42, 0.04);
  --sh-glow: 0 4px 14px rgba(15, 23, 42, 0.15); /* Plus de glow bleu vif */
}

/* ── RESET & BLINDAGE MOBILE ───────────────────── */
*, *::before, *::after { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
  -webkit-tap-highlight-color: transparent; 
}
[hidden] { display: none !important; }
button { cursor: pointer; font: inherit; }
button * { cursor: pointer; } /* FIX iOS DELEGATION BUG: Ensure all elements inside buttons trigger click events */

/* Sécurité login: masquer les contrôles natifs "afficher le mot de passe" */
#inp-pass::-ms-reveal,
#inp-pass::-ms-clear {
  display: none;
}
#inp-pass::-webkit-credentials-auto-fill-button,
#inp-pass::-webkit-contacts-auto-fill-button {
  visibility: hidden;
  display: none !important;
  pointer-events: none;
}

html, body {
  height: 100%;
  width: 100%;
  max-width: 100vw;
  overflow: hidden; /* iOS fix : hidden sur les deux axes empêche le scroll horizontal au niveau du document */
  overscroll-behavior: none; /* tue le rebond/pull-to-refresh du navigateur, sensation d'app native */
  touch-action: manipulation; /* supprime le delai de tap et le double-tap zoom, comme une vraie app */
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* ── FRAME PRINCIPALE ───────────────────────────── */
.frame {
  width: 100%;
  max-width: 100vw;
  height: 100dvh;      /* iOS fix : hauteur fixe = viewport, évite que le document déborde */
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;    /* iOS fix : .frame est le conteneur de scroll, plus le document */
  overscroll-behavior: contain; /* le rebond reste dans .frame, ne fuit jamais vers la page */
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 0 60px rgba(0,0,0,0.15);
  transition: max-width 0.4s var(--ease);
  /* Installée en app (status bar "black-translucent"), le contenu passe SOUS
     l'encoche/l'horloge sans ça : on pousse tout d'un cran sous la zone systeme. */
  padding-top: env(safe-area-inset-top);
}



/* ══════════════════════════════════════════════════
   ÉCRAN LOGIN (Square-like)
══════════════════════════════════════════════════ */
#s-login {
  width: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  opacity: 1;
  transition: opacity 0.5s var(--ease);
}

.login-split {
  display: flex;
  width: 100%;
  flex: 1;
}

.login-brand {
  width: 45%;
  background: var(--sb-bg);
  background-image:
    linear-gradient(180deg, rgba(10,14,24,0.78), rgba(10,14,24,0.88)),
    url("assets/partners/promesse-de-dieu.jpg");
  background-size: cover;
  background-position: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  position: relative;
  overflow: hidden;
}
.login-brand::before {
  content: ''; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.02' fill-rule='evenodd'%3E%3Ccircle cx='3' cy='3' r='3'/%3E%3Ccircle cx='13' cy='13' r='3'/%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}
.login-brand::after {
  content: '';
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.05), transparent);
}

.brand-inner { max-width: 360px; }

.brand-logo {
  display: flex; align-items: center; gap: 18px;
  margin-bottom: 50px;
}
.brand-d {
  width: 60px; height: 60px;
  object-fit: contain;
}
.brand-name {
  font-size: 2.2rem; font-weight: 800; color: #fff;
  letter-spacing: -0.04em; line-height: 1.1;
}
.brand-tag {
  font-size: 0.9rem; color: var(--sb-text);
  font-weight: 500; margin-top: 4px;
}

.brand-features { margin-bottom: 50px; }
.bf-item {
  display: flex; align-items: center; gap: 14px;
  color: rgba(255,255,255,0.7);
  font-size: 1rem; font-weight: 500;
  padding: 12px 0;
}
.bf-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 10px rgba(181,101,29,0.6);
}
.brand-city { font-size: 0.9rem; color: var(--sb-text); font-weight: 600; }

.brand-partners {
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid rgba(255,255,255,0.12);
  width: 100%;
}
.brand-partners-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  margin-bottom: 16px;
}
.brand-partners-logos {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}
.brand-partners-logos img {
  height: 36px;
  width: auto;
  border-radius: 6px;
  background: rgba(255,255,255,0.92);
  padding: 4px 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.login-form-panel {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 48px 32px;
  background:
    radial-gradient(circle at 0% 100%, rgba(217,31,38,0.08), transparent 45%),
    radial-gradient(circle at 100% 0%, rgba(181,101,29,0.10), transparent 50%),
    linear-gradient(160deg, #F4F6F8 0%, #F6F3EC 100%);
  position: relative;
}
.login-form-panel::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 100% 100%, rgba(250,204,21,0.06), transparent 50%);
  pointer-events: none;
}
.lf-inner {
  width: 100%; max-width: 420px;
  background: var(--card);
  padding: 40px; border-radius: 16px;
  box-shadow: var(--sh-lg);
  border: 1px solid var(--border);
}

.login-signature {
  width: 100%; max-width: 420px;
  text-align: center;
  margin-top: 20px;
  font-size: 0.75rem;
  color: var(--text2);
  letter-spacing: 0.02em;
}
.login-signature strong {
  color: var(--text);
  font-weight: 700;
}
.login-signature a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 600;
}
.login-signature a:hover { text-decoration: underline; }

.login-back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; padding: 0;
  margin-bottom: 20px;
  color: var(--text2); font-size: 0.85rem; font-weight: 700;
  cursor: pointer; transition: var(--trans-fast);
}
.login-back-btn svg { width: 16px; height: 16px; }
.login-back-btn:hover { color: var(--blue); }

.lf-header { margin-bottom: 40px; }
.lf-header h1 {
  font-size: 2.2rem; font-weight: 800;
  color: var(--text); letter-spacing: -0.04em; margin-bottom: 8px;
}
.lf-header p { font-size: 1rem; color: var(--text2); line-height: 1.5; font-weight: 500; }

.login-role-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 28px;
}
.login-role-card {
  min-height: 118px;
  min-width: 0;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: var(--trans);
  color: var(--text);
}
.login-role-card strong { font-size: 1.05rem; font-weight: 800; }
.login-role-card small { color: var(--text2); font-weight: 600; line-height: 1.35; }
.login-role-card:hover,
.login-role-card.active {
  background: var(--card);
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(181,101,29,0.12), var(--sh);
}
.role-chip {
  width: max-content;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--blue-lt);
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.role-chip-manager {
  background: var(--green-lt);
  color: var(--green);
}

.lf-form { display: flex; flex-direction: column; gap: 24px; }

.field-group { display: flex; flex-direction: column; gap: 8px; }
.field-label {
  font-size: 0.85rem; font-weight: 700;
  color: var(--text2); text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: color 0.3s var(--ease);
}
.field-wrap {
  position: relative;
  display: flex; align-items: center;
}
.field-icon {
  position: absolute; left: 16px;
  width: 18px; height: 18px;
  color: var(--text3);
  pointer-events: none;
  transition: color 0.3s var(--ease);
}
.field-input {
  width: 100%; height: 52px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 0 16px;
  font: inherit; font-size: 1rem; font-weight: 600;
  color: var(--text);
  outline: none;
  transition: var(--trans);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}
.field-input:focus {
  border-color: var(--blue); background: var(--card);
  box-shadow: 0 0 0 4px rgba(181,101,29,0.15);
}
.field-input:focus ~ .field-icon,
.field-wrap:focus-within .field-icon {
  color: var(--blue);
}
.field-input::placeholder { color: var(--text3); font-weight: 500; }
.field-wrap .field-icon ~ .field-input { padding-left: 44px; }

.field-prefix {
  position: absolute; left: 16px;
  font-weight: 800; color: var(--text2); font-size: 1.1rem;
  pointer-events: none;
}
.has-prefix { padding-left: 32px !important; }

select.field-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 44px;
}

.login-err {
  font-size: 0.9rem; font-weight: 600;
  color: var(--red); min-height: 20px;
}

.btn-login {
  height: 56px;
  background: var(--blue);
  color: #fff;
  border: none; border-radius: var(--r);
  font: inherit; font-weight: 800; font-size: 1.05rem;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: var(--trans);
  box-shadow: 0 4px 14px rgba(181,101,29,0.3);
  cursor: pointer;
}
.btn-login svg { width: 20px; height: 20px; transition: transform 0.3s var(--ease); }
.btn-login:hover { background: #8F4F17; box-shadow: 0 6px 20px rgba(181,101,29,0.4); }
.btn-login:hover svg { transform: translateX(4px); }
.btn-login:active { transform: scale(0.98); }

@media (max-width: 900px) {
  .login-split { flex-direction: column; }
  .login-brand { width: 100%; padding: 40px 24px; min-height: 200px;}
  .login-brand::after { display: none; }
  .brand-features { display: none; }
  .brand-logo { margin-bottom: 0; justify-content: center; }
  .brand-name { font-size: 1.5rem; }
  .brand-tag { font-size: 0.8rem; }
  .brand-partners { margin-top: 20px; padding-top: 20px; }
  .brand-partners-logos { justify-content: center; }
  .login-form-panel { padding: 40px 24px; align-items: flex-start; }
  /* Meme seuil que .login-split : evite une fenetre 768-900px ou le panneau
     de connexion est deja etroit (colonne unique) mais les 2 cartes de role
     essaient encore de tenir cote a cote et se compriment/chevauchent. */
  .login-role-grid { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════
   LAYOUT APP — SIDEBAR + CONTENU
══════════════════════════════════════════════════ */
#s-app {
  display: block;
  width: 100%;
  min-height: 100dvh;
  position: relative;
}

/* ── SIDEBAR (Dark Mode Square) ───────────────── */
.sidebar {
  width: var(--sb-w);
  min-height: 100dvh;
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-border);
  display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; bottom: 0;
  z-index: 50;
  transition: width 0.3s var(--ease), transform 0.3s var(--ease);
  overflow: hidden;
  will-change: width;
}
.sidebar.collapsed { width: var(--sb-w-col); }

.sidebar-header {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.sb-logo {
  width: 38px; height: 38px; flex-shrink: 0;
  object-fit: contain;
}
.sb-brand { flex: 1; overflow: hidden; }
.sb-name {
  font-size: 1.1rem; font-weight: 800; color: #fff;
  white-space: nowrap; letter-spacing: -0.02em;
}
.sb-sub { font-size: 0.75rem; color: var(--sb-text); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }

.sb-collapse {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 8px; border: 1px solid var(--sb-border);
  background: transparent; color: var(--sb-text);
  display: flex; align-items: center; justify-content: center;
  transition: var(--trans-fast);
  touch-action: manipulation;
}
.sb-collapse svg { width: 16px; height: 16px; transition: transform 0.3s var(--ease); }
.sb-collapse:hover { background: var(--sb-hover); color: #fff; }
.sidebar.collapsed .sb-collapse svg { transform: rotate(180deg); }

/* Sidebar header reflow when collapsed so collapse button stays visible */
.sidebar.collapsed .sidebar-header {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 14px 0;
  height: auto;
  min-height: var(--topbar-h);
  gap: 8px;
  border-bottom: 1px solid var(--sb-border);
}
.sidebar.collapsed .sb-brand { display: none; }

.sidebar-nav {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 16px 0;
}
.sidebar-nav::-webkit-scrollbar { width: 0; }

.sb-section-label {
  font-size: 0.7rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: rgba(255,255,255,0.3);
  padding: 16px 24px 8px;
  white-space: nowrap; overflow: hidden;
  transition: opacity 0.3s var(--ease);
}
.sidebar.collapsed .sb-section-label { opacity: 0; height: 0; padding: 0; }

.sb-item {
  display: flex; align-items: center; gap: 14px;
  height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  margin: 4px 14px;
  border: none; background: transparent;
  color: var(--sb-text);
  font-size: 0.9rem; font-weight: 600;
  transition: background 0.15s var(--ease), color 0.15s var(--ease), transform 0.15s var(--ease);
  position: relative;
  z-index: 2;
  pointer-events: auto;
  white-space: nowrap;
  width: calc(100% - 28px);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.sb-item:hover { background: var(--sb-hover); color: #fff; transform: translateX(3px); }
.sb-item.active {
  background: var(--sb-active);
  color: #fff;
}
.sb-item.active::before {
  content: '';
  position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 24px;
  background: var(--blue);
  border-radius: 0 4px 4px 0;
}

.sb-icon {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.3s var(--ease);
  pointer-events: none;
}
.sb-icon svg { width: 18px; height: 18px; }
.sb-item.active .sb-icon { color: var(--blue); }

.sb-label { flex: 1; overflow: hidden; text-align: left; }
.sidebar.collapsed .sb-label { opacity: 0; width: 0; }

.sb-badge {
  min-width: 24px; height: 24px; padding: 0 8px;
  background: var(--red);
  color: #fff; border-radius: 8px;
  font-size: 0.75rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.sidebar.collapsed .sb-badge { display: none; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--sb-border);
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
  background: var(--sb-bg);
  position: relative;
  z-index: 10;
}
.sb-avatar {
  width: 40px; height: 40px; flex-shrink: 0;
  background: #1F2937;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 800; color: #fff;
  letter-spacing: 0.03em;
}
.sb-user-info { flex: 1; overflow: hidden; }
.sidebar.collapsed .sb-user-info { display: none; }
.sb-user-name { font-size: 0.9rem; font-weight: 700; color: #fff; white-space: nowrap; }
.sb-user-role { font-size: 0.75rem; color: var(--green); font-weight: 600; display:flex; align-items:center; gap:6px; margin-top:2px;}
.sb-user-role::before { content:''; display:block; width:6px; height:6px; background:var(--green); border-radius:50%; box-shadow: 0 0 6px var(--green);}

.sb-logout {
  width: 38px; height: 38px; flex-shrink: 0;
  border-radius: 8px; border: 1px solid var(--sb-border);
  background: transparent; color: var(--sb-text);
  display: flex; align-items: center; justify-content: center;
  transition: var(--trans);
}
.sb-logout svg { width: 16px; height: 16px; }
.sb-logout:hover { background: rgba(239,68,68,0.15); color: var(--red); border-color: rgba(239,68,68,0.3); }
.sidebar.collapsed .sb-logout { display: none; }

/* ── POWERED BY ───────────────────────────────── */
.sidebar-powered {
  padding: 8px 16px 12px;
  text-align: center;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.25);
  line-height: 1.5;
  flex-shrink: 0;
  letter-spacing: 0.02em;
  background: var(--sb-bg);
  position: relative;
  z-index: 10;
}
.sidebar-powered strong {
  color: rgba(255,255,255,0.45);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.65rem;
}
.sidebar.collapsed .sidebar-powered { display: none; }

/* ── BOUTON PROFIL SIDEBAR FOOTER ─────────────── */
.sb-user-btn {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 12px;
  background: transparent; border: none;
  padding: 6px 8px; border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s var(--ease);
  text-align: left;
  touch-action: manipulation;
}
.sb-user-btn:hover { background: var(--sb-hover); }
.sb-user-btn .sb-profile-chevron {
  width: 14px; height: 14px; flex-shrink: 0;
  color: var(--sb-text); opacity: 0.5;
  transition: opacity 0.15s;
}
.sb-user-btn:hover .sb-profile-chevron { opacity: 1; }
.sidebar.collapsed .sb-user-btn .sb-user-info,
.sidebar.collapsed .sb-user-btn .sb-profile-chevron { display: none; }

/* ── VUE PROFIL ───────────────────────────────── */
.profile-avatar-lg {
  width: 72px; height: 72px;
  background: var(--blue); border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; font-weight: 800; color: #fff;
  box-shadow: 0 8px 24px rgba(181,101,29,0.3);
  flex-shrink: 0;
}
.profile-hero {
  display: flex; align-items: center; gap: 20px;
  padding: 20px; background: var(--card); border-radius: var(--r);
  border: 1px solid var(--border); margin-bottom: 20px;
  box-shadow: var(--sh);
}
.profile-hero-name { font-size: 1.2rem; font-weight: 800; color: var(--text); }
.profile-hero-role { font-size: 0.85rem; color: var(--green); font-weight: 600; display:flex; align-items:center; gap:6px; }
.profile-hero-role::before { content:''; width:6px; height:6px; background:var(--green); border-radius:50%; }
.profile-section {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r); padding: 20px;
  box-shadow: var(--sh); margin-bottom: 16px;
}
.profile-section-title {
  font-size: 0.7rem; font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.1em;
  margin-bottom: 16px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border2);
}
.profile-warn { font-size: 0.78rem; color: var(--text3); margin-top: 8px; line-height: 1.5; }

/* ── MAIN WRAP ────────────────────────────────── */
.main-wrap {
  margin-left: var(--sb-w);
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  display: flex; flex-direction: column;
  transition: margin-left 0.3s var(--ease);
  min-width: 0; /* FIX MOBILE : Empêche la frame de déborder */
}
.main-wrap.sidebar-collapsed { margin-left: var(--sb-w-col); }

/* ── TOPBAR ───────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: #FFFFFF;
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 30;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
  width: 100%;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-left > div { min-width: 0; }

.topbar-menu {
  display: none;
  width: 40px; height: 40px;
  border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--text);
  cursor: pointer;
  transition: var(--trans-fast);
  touch-action: manipulation;
}
.topbar-menu:hover { background: rgba(255,255,255,0.22); }
.topbar-menu:active { transform: scale(0.9); }
.topbar-menu { padding: 12px; }
.topbar-menu svg { width: 24px; height: 24px; pointer-events: none; }

.topbar-title {
  font-size: 1.25rem; font-weight: 800;
  color: var(--text); letter-spacing: -0.02em;
}
.topbar-date {
  font-size: 0.85rem; color: var(--text3); font-weight: 600; margin-top: 2px;
}

.topbar-right { display: flex; align-items: center; gap: 12px; min-width: 0; }

.build-indicator {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.82rem; font-weight: 800; color: var(--text);
  padding: 8px 12px; background: var(--bg); border-radius: 999px;
  border: 1px solid var(--border); white-space: nowrap;
}
.build-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--blue); box-shadow: 0 0 10px rgba(181,101,29,0.35);
}
.build-label {
  text-transform: uppercase; letter-spacing: 0.03em; color: var(--text3);
}
.build-code {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
}

.sync-indicator {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.85rem; font-weight: 700; color: var(--text3);
  padding: 8px 14px; background: var(--bg); border-radius: 999px; border: 1px solid var(--border);
  cursor: pointer;
}
.sync-time { color: var(--text3); font-size: 0.72rem; font-weight: 700; }
.sync-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px rgba(16,185,129,0.4);
}
.sync-indicator.syncing .sync-dot { background: var(--orange); box-shadow: none; animation: pulse 1s infinite; }
.sync-indicator.error .sync-dot   { background: var(--red); box-shadow: none; }
@keyframes pulse { 50% { opacity: 0.5; } }

.btn-cta {
  height: 44px; padding: 0 20px;
  background: var(--blue); color: #fff;
  border: none; border-radius: 8px;
  font: inherit; font-weight: 700; font-size: 0.95rem;
  display: flex; align-items: center; gap: 8px;
  transition: background 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.1s;
  box-shadow: 0 2px 4px rgba(181, 101, 29, 0.15);
  cursor: pointer;
}
.btn-cta svg { width: 18px; height: 18px; }
.btn-cta:hover { background: #8F4F17; box-shadow: 0 6px 12px rgba(181, 101, 29, 0.25); }
.btn-cta:active { transform: scale(0.97); }

.btn-primary-sm, .btn-orange-sm {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  transition: background 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.1s;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.btn-primary-sm { background: var(--blue); box-shadow: 0 1px 2px rgba(181, 101, 29, 0.12); }
.btn-primary-sm:hover { background: #8F4F17; box-shadow: 0 4px 8px rgba(181, 101, 29, 0.18); }
.btn-primary-sm:active, .btn-orange-sm:active { transform: scale(0.985); }

.btn-orange-sm { background: var(--red) !important; box-shadow: 0 1px 2px rgba(220,38,38,0.08); }
.btn-orange-sm:hover { background: #B91C1C !important; box-shadow: 0 4px 8px rgba(220,38,38,0.12); }

.select-pro {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%234B5563' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 16px;
  padding-right: 40px !important; cursor: pointer; background-color: var(--card); box-shadow: var(--sh-sm);
  width: 100%; max-width: 400px;
}
.select-pro:focus { box-shadow: 0 0 0 3px rgba(181,101,29,0.2); border-color: var(--blue); }

/* ── CONTENU ──────────────────────────────────── */
.content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 32px;
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
  min-width: 0; /* FIX MOBILE : Conteneur strict */
}

/* ══════════════════════════════════════════════════
   VUES & EN-TÊTES COMMUNS
══════════════════════════════════════════════════ */
.view {
  display: none;
  min-width: 0;
  width: 100%;
}
.view.active { display: block; }

/* POS view fills available height so checkout zone never clips payment buttons */
#v-pos.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.view-header-block {
  display: flex; align-items: flex-start; gap: 16px;
  margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--border);
}
.view-header-text { flex: 1; min-width: 0; }
.view-title { font-size: 1.8rem; font-weight: 800; color: var(--text); letter-spacing: -0.03em; margin-bottom: 6px; }
.view-sub { font-size: 0.95rem; color: var(--text3); font-weight: 500; }

.back-btn {
  width: 44px; height: 44px; border-radius: 8px;
  background: var(--card); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text2); transition: var(--trans);
  flex-shrink: 0; box-shadow: var(--sh); margin-top: 2px;
}
.back-btn svg { width: 22px; height: 22px; transition: transform 0.3s var(--ease); }
.back-btn:hover { background: var(--blue-lt); color: var(--blue); border-color: var(--blue); }
.back-btn:hover svg { transform: translateX(-3px); }
.back-btn:active { transform: scale(0.92); }

.view-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.vt-left, .vt-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ══════════════════════════════════════════════════
   VUE 1 : CAISSE (POS) — Mode "Square"
══════════════════════════════════════════════════ */
.pos-layout {
  display: flex;
  width: 100%;
  align-items: stretch;
  gap: 24px;
  flex: 1;
  min-height: 0;
}

.pos-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

.pos-search-float {
  position: absolute;
  top: 0;
  left: 0;
  right: 8px;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.pos-search-float svg {
  width: 18px;
  height: 18px;
  color: #64748b;
  flex-shrink: 0;
  position: absolute;
  left: 14px;
  pointer-events: none;
}

.pos-search-input {
  pointer-events: auto;
  width: 100%;
  min-height: 46px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--sh-sm);
  padding: 0 16px 0 42px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.pos-search-input::placeholder { color: #94a3b8; }
.pos-search-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

/* PRODUCT GRID ODOO STYLE */
.product-grid-container {
  flex: 1;
  min-height: 0;
  max-height: calc(100dvh - var(--topbar-h) - 120px);
  overflow-y: auto;
  padding-top: 58px;
  padding-right: 8px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.product-grid-container::-webkit-scrollbar { width: 6px; }
.product-grid-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 16px;
  min-width: 0;
  overflow: hidden;
}
.product-grid img { display: block; object-fit: contain; max-width: 58px !important; max-height: 58px !important; }
.product-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r); padding: 14px; text-align: center;
  cursor: pointer; transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), border-color 0.18s var(--ease), background 0.18s var(--ease);
  box-shadow: var(--sh-sm); height: 116px; display: flex; flex-direction: column; justify-content: center; align-items: center; user-select: none; overflow: hidden; min-width: 0;
}
.product-card:hover { box-shadow: 0 4px 10px -4px rgba(181,101,29,0.18), var(--sh-md); border-color: var(--blue-lt); background: #F8FAFC; }
.product-card:active { transform: scale(0.95); }
.product-card-photo {
  width: 48px; height: 48px; border-radius: 8px;
  max-width: 48px; max-height: 48px;
  background: linear-gradient(180deg, #F8FAFC 0%, #EEF2F7 100%);
  border: 1px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px; overflow: hidden; flex-shrink: 0;
}
.product-card-photo img {
  width: 100% !important; height: 100% !important; max-width: 48px !important; max-height: 48px !important; object-fit: contain !important; object-position: center center !important; padding: 4px; background: #fff;
  filter: drop-shadow(0 4px 7px rgba(15,23,42,0.14));
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.product-card-photo.is-fallback {
  background: #0B111A;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23374151' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 2h4'/%3E%3Cpath d='M11 2v7l-4 6v5a3 3 0 0 0 6 0v-5l-4-6V2'/%3E%3Cpath d='M9 15h6'/%3E%3C/svg%3E");
  background-size: 65%;
  background-repeat: no-repeat;
  background-position: center;
  color: transparent;
  font-size: 0;
}
.product-card-name { width: 100%; max-width: 100%; min-width: 0; font-size: 0.78rem; font-weight: 700; color: var(--text); line-height: 1.18; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: normal; word-break: normal; hyphens: none; }
.product-card-price { font-size: 0.8rem; font-weight: 800; font-family: 'JetBrains Mono', monospace; color: var(--green); }
.product-card { height: 134px; }
.pc-stock-badge { font-size: 0.65rem; font-weight: 700; margin-top: 3px; padding: 1px 5px; border-radius: 4px; letter-spacing: 0.02em; }
.pc-stock-ok   { background: #dcfce7; color: #166534; }
.pc-stock-low  { background: #fef9c3; color: #854d0e; }
.pc-stock-zero { background: #fee2e2; color: #991b1b; }
.product-card-out { opacity: 0.55; pointer-events: none; }

/* SIDEBAR CART SQUARE STYLE */
.pos-side {
  width: min(380px, 36vw); flex-shrink: 0;
  display: flex; flex-direction: column;
}

.pos-checkout-zone {
  background: var(--card); border: 1px solid rgba(0,0,0,0.03);
  border-radius: var(--rlg); padding: 0; box-shadow: var(--sh-lg), 0 0 0 1px rgba(0,0,0,0.02);
  width: 100%; display: flex; flex-direction: column; overflow: hidden;
  flex: 1;
  position: relative;
}

.pos-cart-header { padding: 18px 20px; border-bottom: 1px dashed var(--border); background: var(--bg); display: flex; justify-content: space-between; align-items: center; }
.pos-cart-title { font-size: 1.1rem; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
.pos-cart-count { background: var(--blue); color: #fff; border-radius: 999px; padding: 2px 10px; font-size: 0.8rem; font-weight: 800; }

.pos-cart-items { flex: 1; overflow-y: auto; padding: 12px 16px; background: var(--card); scroll-behavior: smooth; overscroll-behavior: contain; }
.pos-cart-items::-webkit-scrollbar { width: 4px; }
.pos-cart-items::-webkit-scrollbar-thumb { background: var(--border2); }

.cart-row { display: grid; grid-template-columns: minmax(0, 1fr) 82px minmax(76px, auto); gap: 8px; padding: 12px 4px; border-bottom: 1px solid var(--border2); align-items: center; }
.cart-row:last-child { border-bottom: none; }
.cart-row-title { font-weight: 700; font-size: 0.95rem; color: var(--text); margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;}
.cart-row-sub { font-size: 0.8rem; color: var(--text3); font-weight: 600; font-family: 'JetBrains Mono', monospace; display: flex; align-items: center; gap: 6px; }
.cart-price-input { width: 70px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; font-size: 0.85rem; text-align: right; transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease); }
.cart-price-input:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 2px var(--blue-lt); }
.cart-price-input.input-warn { border-color: #f59e0b !important; background: #fffbeb !important; }
.badge-below-price { color: #d97706; font-size: 0.7rem; font-weight: 700; margin-left: 4px; white-space: nowrap; }
.cart-row-qty { display: flex; align-items: center; background: var(--bg); border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.cart-row-qty button { height: 32px; width: 26px; border: none; background: transparent; color: var(--text2); font-weight: 800; cursor: pointer; transition: background 0.1s; padding:0;}
.cart-row-qty button:hover { background: rgba(0,0,0,0.05); color: var(--blue); }
.cart-row-qty span { flex: 1; text-align: center; font-size: 0.9rem; font-weight: 800; font-family: 'JetBrains Mono', monospace; }
.cart-row-total { justify-self: end; font-weight: 800; font-size: 0.95rem; color: var(--text); font-family: 'JetBrains Mono', monospace; white-space: nowrap; }
.cart-del-btn { background:none; border:none; color:var(--red); padding:4px; margin-left:4px; border-radius:6px; cursor:pointer;}
.cart-del-btn:hover { background:var(--red-lt); }

.pos-cart-footer { padding: 18px 20px; background: #fff; border-top: 1px dashed var(--border); }
.pos-total-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.pos-total-title { font-size: 0.85rem; font-weight: 800; color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em; }
.pos-total-display { text-align: right; }
.pos-total-display span { 
  font-weight: 800; color: var(--text); font-size: 2.2rem; 
  font-family: 'JetBrains Mono', monospace; line-height: 1; letter-spacing: -0.05em; 
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.pos-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
body[data-role="gerant"] .pos-actions { grid-template-columns: 1fr; }
.pos-btn-cash {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--green); color: #fff; border: none; border-radius: var(--rlg);
  min-height: 44px; padding: 10px 12px; cursor: pointer; transition: var(--trans);
  box-shadow: 0 2px 6px rgba(16,185,129,0.18); text-align: center; width: 100%;
}
.pos-btn-dette {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--blue-lt); color: var(--blue); border: none; border-radius: var(--rlg);
  min-height: 44px; padding: 10px 12px; cursor: pointer; transition: var(--trans); text-align: center; width: 100%;
}
.pos-btn-cash:hover { background: #059669; box-shadow: 0 4px 10px rgba(16,185,129,0.24); }
.pos-btn-dette:hover { background: #BFDBFE; }
.pos-btn-cash:active, .pos-btn-dette:active { transform: scale(0.985); }

.btn-icon { min-width: 26px; height: 26px; padding: 0 6px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 900; line-height: 1; background: rgba(255,255,255,0.2); }
.pos-btn-dette .btn-icon { background: rgba(181,101,29,0.12); }
.pos-btn-cash div:last-child { font-weight: 800; font-size: 0.9rem; line-height: 1.15; }
.pos-btn-dette div:last-child { font-weight: 800; font-size: 0.9rem; line-height: 1.15; }

/* ══════════════════════════════════════════════════
   VUE 2 : DASHBOARD — ACCUEIL
══════════════════════════════════════════════════ */
.kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; margin-bottom: 32px;
  width: 100%;
}
.kpi-tile {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--rxl); padding: 28px; box-shadow: var(--sh);
  transition: var(--trans); width: 100%; cursor: pointer;
}
.kpi-tile:hover { box-shadow: var(--sh-md); border-color: var(--blue-lt); }

.kpi-tile-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.kpi-tile-label { font-size: 0.85rem; font-weight: 800; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-tile-icon { width: 44px; height: 44px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.kpi-tile-icon svg { width: 22px; height: 22px; }

.kpi-icon-green  { background: var(--green-lt);  color: var(--green); }
.kpi-icon-blue   { background: var(--blue-lt);   color: var(--blue); }
.kpi-icon-purple { background: var(--purple-lt); color: var(--purple); }
.kpi-icon-red    { background: var(--red-lt);    color: var(--red); }

.kpi-tile-val {
  font-size: 2.2rem; font-weight: 800; color: var(--text);
  letter-spacing: -0.04em; line-height: 1; font-family: 'JetBrains Mono', monospace; margin-bottom: 8px;
}
.kpi-tile-sub { font-size: 0.9rem; color: var(--text3); font-weight: 600; }

.dashboard-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); gap: 24px; width: 100%; min-width: 0; }
.dash-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--rxl); padding: 28px; box-shadow: var(--sh); margin-bottom: 24px;
  width: 100%; min-width: 0; cursor: pointer; transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
}
.dash-card:hover { box-shadow: var(--sh-md); border-color: var(--blue-lt); }
.dash-narrow { display: flex; flex-direction: column; gap: 24px; width: 100%; min-width: 0; align-items: stretch; }
.dash-narrow .dash-card { margin-bottom: 0; }

.card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.card-title { font-size: 1.15rem; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.card-sub   { font-size: 0.9rem; color: var(--text3); font-weight: 600; }
.card-link { font-size: 0.9rem; font-weight: 800; color: var(--blue); background: none; border: none; padding: 0; transition: color 0.2s var(--ease); cursor:pointer;}
.card-link:hover { color: #8F4F17; text-decoration: underline; }

.perf-table { width: 100%; overflow-x: auto; }
.perf-header {
  display: grid; grid-template-columns: 1fr 90px 90px 110px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: 0.8rem; font-weight: 800; color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em;
  min-width: 400px;
}
.perf-row {
  display: grid; grid-template-columns: 1fr 90px 90px 110px;
  padding: 16px; border-bottom: 1px solid var(--border2); align-items: center; transition: background 0.2s;
  min-width: 400px;
}
.perf-row:last-child { border-bottom: none; }
.perf-row:hover { background: var(--bg); }
.perf-prod { font-weight: 800; font-size: 1rem; color: var(--text); }
.perf-cat  { font-size: 0.85rem; color: var(--text3); margin-top: 4px; font-weight: 500;}
.perf-num  { font-family: 'JetBrains Mono', monospace; font-size: 1rem; font-weight: 700; text-align: right; }
.perf-num-green { color: var(--green); font-weight: 800;}
.perf-num-red   { color: var(--red); font-weight: 800;}
.perf-bar-wrap { display: flex; align-items: center; gap: 12px; justify-content: flex-end; }
.perf-bar-track { flex: 1; max-width: 60px; height: 8px; background: var(--border2); border-radius: 4px; overflow: hidden; }
.perf-bar-fill { height: 100%; border-radius: 4px; background: var(--green); transition: width 0.8s var(--ease); }
.perf-loading { text-align: center; padding: 50px; color: var(--text3); font-weight: 600; font-size:1rem;}

.alert-count {
  min-width: 28px; height: 28px; padding: 0 8px;
  background: var(--red-lt); color: var(--red);
  border-radius: 14px; font-size: 0.85rem; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.no-alerts { text-align: center; padding: 30px; font-size: 1rem; color: var(--text3); font-weight: 600; }
.alert-item { display: flex; align-items: flex-start; gap: 14px; padding: 14px 18px; border-radius: 8px; margin-bottom: 10px; font-size: 0.95rem; font-weight: 700; }
.alert-warn  { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }
.alert-danger { background: var(--red-lt); color: #991B1B; border: 1px solid #FCA5A5; }
.alert-item-icon { font-size: 1.2rem; flex-shrink: 0; }

.quick-actions { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.qa-btn {
  display: flex; align-items: center; gap: 14px; height: 54px; padding: 0 18px;
  border-radius: 8px; border: 1px solid transparent; font: inherit; font-size: 1rem; font-weight: 800;
  transition: var(--trans); width: 100%; text-align: left; cursor: pointer;
}
.qa-btn:active { transform: scale(0.96); }
.qa-icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.qa-icon svg { width: 18px; height: 18px; }

.qa-primary { background: var(--blue-lt); color: var(--blue); }
.qa-primary .qa-icon { background: var(--blue); color: #fff; }
.qa-primary:hover { background: #BFDBFE; }

.qa-orange  { background: var(--orange-lt); color: var(--orange); }
.qa-orange .qa-icon { background: var(--orange); color: #fff; }
.qa-orange:hover { background: #FED7AA; }

.qa-ghost   { background: var(--bg); color: var(--text2); border-color: var(--border); }
.qa-ghost .qa-icon { background: var(--card); border: 1px solid var(--border); color: var(--text2); }
.qa-ghost:hover { background: var(--card); border-color: #D1D5DB; }

/* ══════════════════════════════════════════════════
   ÉLÉMENTS COMMUNS (Filtres, Inputs, Tabs)
══════════════════════════════════════════════════ */
.date-picker {
  height: 44px; border: 1px solid var(--border); border-radius: 8px; padding: 0 16px;
  font: inherit; font-size: 0.95rem; font-weight: 700; color: var(--text); background: var(--card); outline: none;
  transition: var(--trans); font-family: 'JetBrains Mono', monospace; width: 100%; max-width: 100%;
}
.date-picker:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(181,101,29,0.15); }

.search-wrap { position: relative; width: 100%; max-width: 100%; }
.si { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text3); pointer-events: none; }
.search-input {
  height: 44px; padding: 0 16px 0 44px; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; font-size: 0.95rem; font-weight: 600; color: var(--text); background: var(--card);
  outline: none; width: 100%; transition: var(--trans);
}
.search-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(181,101,29,0.15); }
.search-input::placeholder { color: var(--text3); }

/* Le Fix du Scroll Horizontal sur Mobile */
.pills-bar { 
  display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; 
  width: 100%; max-width: 100%; 
}
.pill {
  height: 38px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); font: inherit; font-weight: 700; font-size: 0.9rem; color: var(--text2);
  transition: var(--trans-fast); cursor: pointer; box-shadow: var(--sh-sm);
  white-space: nowrap;
}
.pill.active { background: var(--blue-lt); color: var(--blue); border-color: var(--blue); box-shadow: none; }
.pill:hover:not(.active) { background: var(--bg); border-color: #D1D5DB; }
.pill:active { transform: scale(0.95); }

/* ── TABLES ──────────────────────────────────── */
/* Le Fix du débordement des tableaux */
.data-table-card { 
  background: var(--card); border: 1px solid var(--border); border-radius: var(--rlg); 
  overflow: hidden; box-shadow: var(--sh); width: 100%; max-width: 100%;
}
.tbl-loading { text-align: center; padding: 60px; color: var(--text3); font-weight: 700; font-size: 1.05rem; }
.dt-table { width: 100%; border-collapse: collapse; min-width: 700px; }
.dt-overflow { 
  overflow-x: auto; overflow-y: auto;
  max-height: calc(100vh - 280px);
  -webkit-overflow-scrolling: touch; 
  width: 100%; display: block; 
}
.dt-overflow::-webkit-scrollbar { width: 6px; height: 6px; }
.dt-overflow::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.dt-table thead tr { border-bottom: 1px solid var(--border); }
.dt-table thead th { position: sticky; top: 0; z-index: 10; background: var(--bg); box-shadow: 0 1px 0 var(--border); }
.dt-table th { padding: 14px 20px; font-size: 0.8rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text3); text-align: right; white-space: nowrap; }
.dt-table th:first-child { text-align: left; }
.dt-table td { padding: 18px 20px; border-bottom: 1px solid var(--border2); font-size: 1rem; font-weight: 600; text-align: right; white-space: nowrap; font-family: 'JetBrains Mono', monospace; }
.dt-table td:first-child { text-align: left; font-family: 'Plus Jakarta Sans', sans-serif; }
.dt-table tr:last-child td { border-bottom: none; }
.dt-table tbody tr:hover td { background: var(--bg); }

.td-name  { font-weight: 800; font-size: 1rem; color: var(--text); }
.td-cat   { font-size: 0.85rem; color: var(--text3); margin-top: 4px; font-weight: 600; }
.td-green { color: var(--green); font-weight: 800; }
.td-red   { color: var(--red); font-weight: 800; }
.td-muted { color: var(--text3); }

.stock-badge { display: inline-flex; padding: 4px 12px; border-radius: 999px; font-size: 0.85rem; font-weight: 800; font-family: 'JetBrains Mono', monospace; }
.stock-ok  { background: var(--green-lt); color: var(--green); }
.stock-low { background: var(--red-lt); color: var(--red); }

.total-footer { background: var(--text); border-radius: 0 0 var(--rlg) var(--rlg); padding: 24px 32px; display: flex; justify-content: space-between; align-items: center; width: 100%;}
.tf-label { font-size: 0.9rem; font-weight: 800; color: rgba(255,255,255,0.6); letter-spacing: 0.05em; }
.tf-val   { font-size: 1.8rem; font-weight: 800; color: #fff; font-family: 'JetBrains Mono', monospace; }

/* ── LISTES ITEMS (ENTRÉES / SORTIES) ────────────────── */
.item-list { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.il-item { background: var(--card); border: 1px solid var(--border); border-radius: var(--r); padding: 18px 24px; display: flex; justify-content: space-between; align-items: center; box-shadow: var(--sh); transition: var(--trans); width: 100%;}
.il-item:hover { box-shadow: var(--sh-md); }
.il-name  { font-weight: 800; font-size: 1.05rem; margin-bottom: 6px; }
.il-date  { font-size: 0.9rem; color: var(--text3); font-weight: 600; }
.il-right { text-align: right; }
.il-qty   { font-size: 1.4rem; font-weight: 800; font-family: 'JetBrains Mono', monospace; }
.il-price { font-size: 0.9rem; color: var(--text3); margin-top: 4px; font-weight: 600;}
.il-total { font-size: 1rem; font-weight: 800; margin-top: 4px; }
.qty-in  { color: var(--green); }
.qty-out { color: var(--orange); }

.filter-tabs { display: flex; gap: 4px; background: var(--bg); border-radius: 8px; padding: 4px; border: 1px solid var(--border); }
.ftab { height: 36px; padding: 0 18px; border-radius: 8px; border: none; background: transparent; color: var(--text2); font: inherit; font-weight: 700; font-size: 0.9rem; transition: var(--trans); display: flex; align-items: center; gap: 8px; cursor: pointer; }
.ftab.active { background: var(--card); color: var(--text); box-shadow: var(--sh); }
.ftab:hover:not(.active) { background: var(--border2); }
.ftab-badge { min-width: 22px; height: 22px; padding: 0 6px; background: var(--red); color: #fff; border-radius: 11px; font-size: 0.75rem; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }

.date-tabs { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dtab { height: 44px; padding: 0 20px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); font: inherit; font-weight: 800; font-size: 0.95rem; color: var(--text2); transition: var(--trans); cursor: pointer; }
.dtab.active { background: var(--blue-lt); color: var(--blue); border-color: var(--blue); }
.dtab:hover:not(.active) { background: var(--bg); }

/* ── DETTES ──────────────────────────────────── */
.debt-summary-bar { background: var(--card); border: 1px solid var(--border); border-radius: var(--rlg); padding: 24px 32px; display: flex; align-items: center; gap: 40px; margin-bottom: 24px; box-shadow: var(--sh); width: 100%; }
.dsb-item { display: flex; flex-direction: column; gap: 8px; }
.dsb-sep  { width: 1px; height: 50px; background: var(--border); }
.dsb-label { font-size: 0.8rem; font-weight: 800; color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em; }
.dsb-val  { font-size: 1.8rem; font-weight: 800; color: var(--text); font-family: 'JetBrains Mono', monospace; line-height: 1; }
.dsb-red  { color: var(--red); }

.dette-search-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.dette-search-bar .field-wrap { position: relative; }
.dette-search-bar .field-input { padding-left: 36px; height: 40px; font-size: 0.9rem; }
.dette-search-bar .field-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text3); pointer-events: none; }
.btn-secondary-sm { display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text2); font-size: 0.85rem; font-weight: 700; cursor: pointer; transition: var(--trans); height: 40px; }
.btn-secondary-sm:hover { background: var(--card); }
.btn-danger-outline { display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1.5px solid #ef4444; background: transparent; color: #ef4444; font-size: 0.82rem; font-weight: 800; cursor: pointer; transition: var(--trans); height: 40px; white-space: nowrap; }
.btn-danger-outline:hover { background: #fef2f2; }
.dette-print-btn { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; cursor: pointer; color: var(--text3); transition: var(--trans); display: flex; align-items: center; gap: 4px; font-size: 0.78rem; font-weight: 700; }
.dette-print-btn:hover { background: var(--bg); color: var(--text); }

.dette-row { background: var(--card); border: 1px solid var(--border); border-radius: var(--rlg); padding: 20px 28px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 20px; box-shadow: var(--sh); transition: var(--trans); width: 100%;}
.dette-row:hover { box-shadow: var(--sh-md); }
.dette-row.unpaid { border: 1px solid rgba(239, 68, 68, 0.3); background: rgba(239, 68, 68, 0.03); }
.dette-row.paid   { border: 1px solid rgba(16, 185, 129, 0.3); background: rgba(16, 185, 129, 0.03); }

.dette-info { flex: 1; }
.dette-client { font-weight: 800; font-size: 1.1rem; color: var(--text); margin-bottom: 6px; }
.dette-detail { font-size: 0.9rem; color: var(--text3); font-weight: 600; }

.dette-right { display: flex; align-items: center; gap: 24px; }
.dette-amount { font-size: 1.4rem; font-weight: 800; font-family: 'JetBrains Mono', monospace; }
.dette-amount.unpaid { color: var(--red); }
.dette-amount.paid   { color: var(--green); }

.status-btn { height: 38px; padding: 0 16px; border-radius: 8px; border: 1px solid transparent; font: inherit; font-size: 0.85rem; font-weight: 800; transition: var(--trans-fast); cursor: pointer; }
.status-unpaid { background: var(--red-lt); color: var(--red); border-color: #FCA5A5; }
.status-unpaid:hover { background: #FEE2E2; }
.status-paid   { background: var(--green-lt); color: var(--green); border-color: #86EFAC; }
.status-paid:hover { background: #BBFBD0; }
.status-btn:active { transform: scale(0.95); }

/* ── FORMULAIRES (Ajouts divers) ─────────────── */
.form-layout { display: grid; grid-template-columns: 1fr 380px; gap: 28px; align-items: start; width: 100%; min-width: 0;}
.form-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--rxl); padding: 32px; box-shadow: var(--sh); width: 100%; min-width: 0;}
.fc-step { display: flex; align-items: center; gap: 14px; font-weight: 800; font-size: 1.1rem; color: var(--text); margin-bottom: 24px; }
.step-badge { width: 34px; height: 34px; flex-shrink: 0; background: var(--blue); color: #fff; border-radius: 8px; font-size: 0.95rem; font-weight: 800; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(181,101,29,0.3); }
.step-orange { background: var(--orange); box-shadow: 0 4px 12px rgba(234,88,12,0.3); }

.fields-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; width: 100%;}

.selected-tag { display: inline-flex; align-items: center; background: var(--blue-lt); color: var(--blue); border: 1px solid rgba(181,101,29,0.2); border-radius: 8px; padding: 12px 20px; font-weight: 800; font-size: 1rem; margin-bottom: 24px; }
.selected-tag-orange { background: var(--orange-lt); color: var(--orange); border-color: rgba(234,88,12,0.2); }

.form-summary { position: sticky; top: calc(var(--topbar-h) + 24px); width: 100%;}
.form-summary-orange .fs-total { color: var(--orange); }

.fs-title { font-size: 0.85rem; font-weight: 800; color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 24px; }
.fs-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border2); font-size: 1rem; }
.fs-row:last-of-type { border-bottom: none; }
.fs-row span:first-child { color: var(--text2); font-weight: 600; }
.fs-row span:last-child  { font-weight: 800; font-family: 'JetBrains Mono', monospace; }
.fs-total { border-top: 2px solid var(--border); margin-top: 12px; padding-top: 20px; font-size: 1.1rem !important; border-bottom: none !important; }
.fs-total span:last-child { font-size: 1.4rem; color: var(--blue); }
.fs-total-red span:last-child { color: var(--red); }

.btn-submit { width: 100%; min-height: 46px; margin-top: 22px; padding: 10px 14px; border-radius: 8px; border: none; font: inherit; font-weight: 800; font-size: 0.98rem; line-height: 1.1; display: flex; align-items: center; justify-content: center; gap: 10px; transition: var(--trans); cursor: pointer; position: relative; overflow: hidden; }
.btn-submit::after { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 40%; background: linear-gradient(180deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 100%); pointer-events: none; }
.btn-submit:active { transform: scale(0.985); }
.btn-submit-primary { background: var(--blue); color: #fff; box-shadow: 0 4px 14px rgba(181,101,29,0.2); }
.btn-submit-primary:hover { box-shadow: 0 6px 16px rgba(181,101,29,0.22); filter: brightness(1.03); }
.btn-submit-orange { background: var(--orange); color: #fff; box-shadow: 0 4px 14px rgba(245,158,11,0.2); }
.btn-submit-orange:hover { box-shadow: 0 6px 16px rgba(245,158,11,0.22); filter: brightness(1.03); }

/* ── EXPORT PDF ─────────────────────────────── */
.select-all-row { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border2); }
.chk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }

.chk-item-pro { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); cursor: pointer; font-size: 0.95rem; font-weight: 700; color: var(--text); transition: var(--trans-fast); }
.chk-item-pro:has(input:checked) { border-color: var(--blue); background: var(--blue-lt); color: var(--blue); box-shadow: 0 2px 8px rgba(181,101,29,0.1); }
.chk-item-pro input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--blue); cursor: pointer; flex-shrink: 0; }

.pdf-cols-preview { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 28px; }
.pc-tag { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 6px 14px; font-size: 0.85rem; font-weight: 800; color: var(--blue); font-family: 'JetBrains Mono', monospace; }

/* ── PRODUITS ──────────────────────────────── */
#produits-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; width: 100%; max-height: calc(100vh - 220px); overflow-y: auto; padding-right: 8px; padding-bottom: 24px; align-content: start; scroll-behavior: smooth; overscroll-behavior: contain; }
#produits-grid::-webkit-scrollbar { width: 6px; }
#produits-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.prod-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r); padding: 16px 18px; display: flex; align-items: center; gap: 14px; box-shadow: var(--sh); transition: var(--trans); min-width: 0; overflow: hidden; }
.prod-card:hover { box-shadow: var(--sh-md); }
.prod-photo-editor { width: 76px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.prod-photo { width: 58px; height: 58px; max-width: 58px; max-height: 58px; flex-shrink: 0; border-radius: 8px; background: linear-gradient(180deg, #F8FAFC 0%, #EEF2F7 100%); border: 1px solid var(--border2); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.prod-photo img { width: 100% !important; height: 100% !important; max-width: 58px !important; max-height: 58px !important; object-fit: contain !important; object-position: center center !important; padding: 4px; background: #fff; filter: drop-shadow(0 5px 9px rgba(15,23,42,0.16)); }
.prod-photo.is-fallback { background: var(--blue-lt); color: var(--blue); font-size: 1.05rem; font-weight: 800; }
.prod-photo-change { border: none; background: none; color: var(--blue); cursor: pointer; font-size: 0.68rem; font-weight: 800; line-height: 1.15; padding: 0; text-align: center; }
.prod-photo-change:hover { text-decoration: underline; }
.prod-photo-remove { border: none; background: none; color: var(--red); cursor: pointer; font-size: 0.65rem; font-weight: 800; line-height: 1.1; padding: 0; }
.prod-photo-remove:hover { text-decoration: underline; }
.prod-body { min-width: 0; flex: 1; }
.prod-name  { max-width: 100%; font-weight: 800; font-size: 0.96rem; color: var(--text); margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: normal; word-break: normal; hyphens: none; }
.prod-name span { font-size: 0.82em; color: var(--blue); margin-left: 4px; }
.prod-meta  { font-size: 0.85rem; color: var(--text3); font-weight: 600; }
.prod-meta.low { color: var(--red); }
.prod-category { display: inline-flex; margin-top: 8px; padding: 4px 8px; border-radius: 7px; font-size: 0.74rem; font-weight: 800; }
.price-admin-note {
  max-width: 420px;
  padding: 10px 14px;
  border-radius: var(--r);
  background: var(--blue-lt);
  color: var(--blue);
  font-weight: 800;
  font-size: 0.88rem;
  line-height: 1.4;
}
.price-editor {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border2);
}
.price-editor label {
  display: block;
  margin-bottom: 6px;
  color: var(--text3);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.price-editor-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
}
.price-editor-row span {
  color: var(--green);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 900;
}
.price-editor-row input {
  min-width: 0;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  font: inherit;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800;
  outline: none;
}
.price-editor-row input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(181,101,29,0.14);
}
.price-editor-row button {
  height: 36px;
  border: none;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  padding: 0 10px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 900;
}
.price-editor-row button:hover { background: #1F2937; }

/* ── HISTORIQUE ────────────────────────────── */
.hist-kpi-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 28px; width: 100%;}
.hkpi { position: relative; background: var(--card); border: 1px solid var(--border); border-radius: var(--rlg); padding: 22px 24px 22px 28px; box-shadow: var(--sh); transition: var(--trans); overflow: hidden; }
.hkpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: #CBD5E1; }
.hkpi:hover { box-shadow: var(--sh-md); border-color: #E2E8F0; }
.hkpi-label { font-size: 0.8rem; font-weight: 800; color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; }
.hkpi-val   { font-size: 1.6rem; font-weight: 800; font-family: 'JetBrains Mono', monospace; color: var(--text); }
.hkpi-green::before { background: #0F766E; }
.hkpi-orange::before { background: #A16207; }
.hkpi-blue::before { background: #334155; }
.hkpi-red::before { background: #7F1D1D; }

.hist-section { background: var(--card); border: 1px solid var(--border); border-radius: var(--rxl); overflow: hidden; margin-bottom: 24px; box-shadow: var(--sh); width: 100%;}
.hs-title { padding: 18px 28px; background: var(--bg); border-bottom: 1px solid var(--border); font-size: 0.9rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text3); }
.hi-row { background: var(--card); border: 1px solid var(--border); border-radius: var(--rlg); display: flex; justify-content: space-between; align-items: center; padding: 18px 28px; margin-bottom: 12px; box-shadow: var(--sh); transition: var(--trans); width: 100%; cursor: pointer; }
.hi-row:last-child { margin-bottom: 0; }
.hi-row:hover { box-shadow: var(--sh-md); }
.hi-row.hi-in  { border: 1px solid rgba(16, 185, 129, 0.3); background: rgba(16, 185, 129, 0.03); }
.hi-row.hi-out { border: 1px solid rgba(245, 158, 11, 0.3); background: rgba(245, 158, 11, 0.03); }
.hi-row.hi-lost{ border: 1px solid rgba(239, 68, 68, 0.3); background: rgba(239, 68, 68, 0.03); }
.hi-name { font-weight: 800; font-size: 1.05rem; margin-bottom: 4px;}
.hi-sub  { font-size: 0.85rem; color: var(--text3); font-weight: 600;}
.hi-val  { font-family: 'JetBrains Mono', monospace; font-weight: 800; font-size: 1.15rem; text-align: right; }
.history-simple-stack { display: flex; flex-direction: column; gap: 18px; width: 100%; }
.history-simple-card { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.history-simple-title { font-size: 0.9rem; font-weight: 900; color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em; }
.history-plain-table th, .history-plain-table td { white-space: normal; }
.history-plain-table td { vertical-align: top; }

/* ── AIDE ──────────────────────────────────── */
.aide-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; width: 100%;}
.aide-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--rxl); padding: 32px; box-shadow: var(--sh); transition: var(--trans); cursor: pointer; }
.aide-card:hover { box-shadow: var(--sh-md); border-color: var(--blue-lt); }
.aide-num { font-size: 2.6rem; font-weight: 800; color: var(--border); font-family: 'JetBrains Mono', monospace; letter-spacing: -0.05em; margin-bottom: 20px; }
.aide-card h3 { font-size: 1.2rem; font-weight: 800; margin-bottom: 12px; color: var(--text); }
.aide-card p  { font-size: 0.95rem; color: var(--text2); line-height: 1.6; font-weight: 500; }
.access-admin-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px; width: 100%; margin-top: 26px; }
.access-card { margin-top: 24px; }
.access-note { margin: 0 0 18px; color: var(--text2); line-height: 1.6; font-size: 0.92rem; font-weight: 600; }
.access-fields { margin-bottom: 0; }
.access-lockline {
  min-height: 52px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text2);
  font-size: 0.92rem;
  font-weight: 700;
}
.access-table-wrap { width: 100%; }
.access-table td:last-child, .access-table th:last-child { text-align: right; }
.access-mini-btn { min-width: 110px; justify-content: center; margin-left: auto; }

/* ── ÉTAT VIDE ─────────────────────────────── */
.empty-state { text-align: center; padding: 70px 24px; background: var(--card); border: 1px solid var(--border); border-radius: var(--rxl); box-shadow: var(--sh); width: 100%;}
.es-icon { width: 48px; height: 48px; margin: 0 auto 20px; opacity: 0.35; color: var(--text2); }
.es-icon svg { width: 48px; height: 48px; display: block; }
.es-title { font-size: 1.2rem; font-weight: 800; color: var(--text2); margin-bottom: 10px; }
.es-sub   { font-size: 0.95rem; color: var(--text3); font-weight: 500;}

/* ══════════════════════════════════════════════════
   MOBILE BOTTOM NAV & OVERLAY
══════════════════════════════════════════════════ */
.mobile-nav { display: none; }
.sidebar-overlay { display: none; position: fixed; inset: 0; z-index: 80; background: rgba(2,6,23,0.54); transition: opacity 0.3s var(--ease); }
.sidebar-overlay.active { display: block; }

/* ══════════════════════════════════════════════════
   TOAST NOTIFICATION
══════════════════════════════════════════════════ */
#toast {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%); max-width: 480px; width: calc(100% - 48px);
  background: #111827; color: #fff; padding: 16px 24px; border-radius: 8px; font: inherit; font-weight: 600; font-size: 1rem;
  z-index: 100; display: flex; align-items: center; gap: 16px; box-shadow: 0 12px 48px rgba(0,0,0,0.3);
  animation: toastIn 0.15s ease;
}
@keyframes toastIn { from { opacity: 0; } to { opacity: 1; } }
#toast .undo-btn { margin-left: auto; background: rgba(255,255,255,0.15); color: #fff; border: 1px solid rgba(255,255,255,0.2); border-radius: 8px; padding: 8px 16px; font: inherit; font-size: 0.9rem; font-weight: 800; transition: background 0.15s; cursor: pointer;}
#toast .undo-btn:hover { background: rgba(255,255,255,0.25); }
#toast .undo-btn:active { transform: scale(0.95); }

body.modal-open { overflow: hidden; }
.receipt-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.65);
}
.receipt-dialog {
  position: relative;
  width: min(100%, 460px);
  background: #fff;
  border: 1px solid #E2E8F0;
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.24);
}
.receipt-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--text2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.receipt-close svg { width: 18px; height: 18px; }
.receipt-eyebrow {
  margin-bottom: 10px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.receipt-dialog h3 {
  margin: 0 0 10px;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
}
.receipt-summary {
  margin: 0 0 14px;
  color: var(--text2);
  line-height: 1.6;
  font-weight: 600;
}
.receipt-printer-note {
  margin: 0 0 20px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 0.9rem;
  line-height: 1.5;
}
.receipt-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.receipt-btn {
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--trans);
}
.receipt-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.receipt-btn-primary {
  background: #111827;
  color: #fff;
}
.receipt-btn-primary:hover:not(:disabled) {
  box-shadow: 0 12px 22px rgba(15, 23, 42, 0.18);
}
.receipt-btn-secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}
.receipt-btn-secondary:hover:not(:disabled) {
  background: var(--bg);
}
.receipt-link {
  margin-top: 14px;
  border: none;
  background: transparent;
  color: var(--text3);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* ══════════════════════════════════════════════════
   RESPONSIVE (100% BULLETPROOF)
══════════════════════════════════════════════════ */

@media (max-width: 1300px) {
  .dashboard-row { grid-template-columns: 1fr; }
  .dash-narrow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-layout { grid-template-columns: 1fr; }
  .form-summary { position: static; }
  .access-admin-grid { grid-template-columns: 1fr; }
  /* POS mobile : revert du layout flex desktop, scroll via main-wrap */
  .main-wrap { height: auto; min-height: 100dvh; overflow-y: visible; }
  .content { overflow: visible; }
  #v-pos.active { height: auto; display: block; overflow: visible; }
  .pos-layout { flex: none; flex-direction: column; min-height: 0; }
  .pos-checkout-zone { flex: none; height: auto; min-height: 320px; }
  .pos-side { width: 100%; position: static; }
  .product-grid-container { max-height: 260px; min-height: auto; overflow-y: auto; }
  .pos-cart-items { max-height: 300px; }
}

@media (max-width: 1024px) {
  .sidebar,
  .sidebar.collapsed {
    width: min(80vw, 340px);
    transform: translateX(-100%);
    transition: transform 0.3s var(--ease);
    z-index: 90;
    background: var(--sb-bg);
    border-right: 1px solid rgba(255,255,255,0.08);
    box-shadow: 16px 0 42px rgba(0,0,0,0.28);
  }
  .sidebar.open { transform: translateX(0); box-shadow: 18px 0 48px rgba(0,0,0,0.3); }
  .sidebar.open .sb-label { opacity: 1; width: auto; color: rgba(255,255,255,0.94); }
  .sidebar.open .sb-section-label { opacity: 1; height: auto; padding: 16px 24px 8px; color: rgba(255,255,255,0.48); }
  .sidebar.open .sb-user-info { display: block; }
  .sidebar.open .sb-logout { display: flex; }
  .sidebar.open .sb-badge { display: flex; }
  .sidebar.open .sb-collapse {
    display: flex;
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.82);
    border-color: rgba(255,255,255,0.14);
  }
  .sidebar.open .sb-collapse svg { transform: rotate(0deg); }
  /* Restore normal header layout on mobile when open (overrides desktop collapsed rules) */
  .sidebar.open .sidebar-header {
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    padding: 0 20px;
    height: var(--topbar-h);
    min-height: unset;
    gap: 14px;
  }
  .sidebar.open .sb-brand { display: block; }
  .sidebar.open .sb-item {
    color: rgba(255,255,255,0.88);
    font-weight: 700;
    min-height: 50px;
    height: auto;
    padding: 12px 18px;
    margin: 4px 12px;
    width: calc(100% - 24px);
    background: transparent;
    border: 1px solid transparent;
  }
  .sidebar.open .sb-item:hover { background: rgba(255,255,255,0.08); transform: none; }
  .sidebar.open .sb-item.active {
    color: #fff;
    background: rgba(181,101,29,0.26);
    border-color: rgba(181,101,29,0.28);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
  }
  .sidebar.open .sb-item.active::before { background: rgba(255,255,255,0.9); }
  .sidebar.open .sb-icon { color: rgba(255,255,255,0.82); }
  .sidebar.open .sb-item.active .sb-icon { color: #fff; }
  .main-wrap { margin-left: 0 !important; }
  .topbar-menu { display: flex; cursor: pointer; }
  .dashboard-row { grid-template-columns: 1fr; }
  .dash-narrow { grid-template-columns: 1fr; gap: 24px; }
  .mobile-nav { display: grid; }
  .content { padding-bottom: 120px; }
  .sidebar-nav { padding-bottom: 32px; }
  .sidebar-overlay.active {
    background: rgba(2, 6, 23, 0.5);
  }
}

/* FIX MOBILE 2 : LE BLINDAGE ANTI-DEBORDEMENT */
@media (max-width: 768px) {
  /* Anti-Zoom automatique iOS */
  .field-input, .search-input, .date-picker, .pos-qty-input { 
    font-size: 16px !important; 
  }

  .content { padding: 20px 16px; overflow-x: hidden;}
  .login-role-grid { grid-template-columns: 1fr; }
  .view-toolbar { flex-direction: column; align-items: stretch; gap: 16px; }
  .vt-left, .vt-right { width: 100%; flex-direction: column; align-items: stretch; gap: 12px !important; }
  .vt-left > *, .vt-right > * { width: 100% !important; max-width: 100% !important; }
  .view-toolbar > button, .vt-right > button, .vt-left > button { width: 100%; justify-content: center; height: 48px; }
  
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .fields-row { grid-template-columns: 1fr; gap: 12px; }
  .aide-grid { grid-template-columns: 1fr; gap: 16px; }
  .access-admin-grid { grid-template-columns: 1fr; gap: 16px; }
  .hist-kpi-bar { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .dash-narrow { grid-template-columns: 1fr; gap: 16px; }
  .chk-grid { grid-template-columns: 1fr; }
  #produits-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .prod-card { padding: 14px; gap: 10px; }
  .prod-photo { width: 48px; height: 48px; }
  .prod-name { font-size: 0.92rem; }
  .prod-name span { display: block; margin-left: 0; margin-top: 2px; }
  
  .topbar { padding: 0 16px; height: 64px; }
  .sync-label { display: none; }
  .sync-time { display: none; }
  .btn-cta span { display: none; }
  .btn-cta { padding: 0 12px; height: 40px; min-width: 40px; }
  .topbar-title { font-size: 1.1rem; }

  /* Touch Targets pour gros doigts */
  .btn-submit {
    min-height: 42px;
    font-size: 0.92rem;
    padding: 8px 14px;
    white-space: normal;
    line-height: 1.15;
  }
  .back-btn { width: 44px; height: 44px; margin-top: 0; }

  /* POS Mobile Opti */
  .pos-layout { gap: 16px; }
  .pos-search-float {
    top: -2px;
    right: 0;
  }
  .pos-search-float svg {
    left: 12px;
    width: 16px;
    height: 16px;
  }
  .pos-search-input {
    min-height: 42px;
    border-radius: 14px;
    padding-left: 38px;
    font-size: 0.9rem;
  }
  .product-grid-container { padding-top: 50px; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .product-card { height: 124px; padding: 10px; }
  .product-card-photo { width: 44px !important; height: 44px !important; max-width: 44px !important; max-height: 44px !important; font-size: 1rem; margin-bottom: 8px; }
  .product-card-photo img { max-width: 44px !important; max-height: 44px !important; }
  .product-card-name { font-size: 0.76rem; line-height: 1.16; }
  .pos-actions { grid-template-columns: 1fr 1fr; gap: 10px; }
  .pos-btn-cash, .pos-btn-dette { min-height: 46px; justify-content: center; text-align: center; padding: 9px 8px;}
  .prod-photo-change, .prod-photo-remove { min-height: 26px; display: inline-flex; align-items: center; justify-content: center; }
  .week-kpis { grid-template-columns: 1fr; }
  .pos-btn-cash div:last-child, .pos-btn-dette div:last-child { font-size: 0.9rem; }
  .pos-cart-header, .pos-cart-footer { padding: 16px; }
  .pos-total-display span { font-size: 1.5rem; }
  .cart-row { grid-template-columns: minmax(0, 1fr) 78px minmax(70px, auto); }
  
  .cart-row-name, .cart-row-total { word-break: break-word; }
  /* Scroll horizontal parfait type App Store */
  .pills-bar { 
    flex-wrap: nowrap; 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch; 
    padding-bottom: 8px; 
    scroll-snap-type: x mandatory;
    gap: 8px;
    margin-bottom: 16px;
    scrollbar-width: none; 
  }
  .pills-bar::-webkit-scrollbar { display: none; }
  .pill { scroll-snap-align: start; white-space: nowrap; flex-shrink: 0; }

  /* Tableaux scannables (Hint visuel) */
  .dt-overflow { box-shadow: inset -12px 0 12px -12px rgba(0,0,0,0.15); padding-bottom: 4px; max-height: none; }

  /* Cartes compactes */
  .form-card, .dash-card, .kpi-tile, .aide-card { padding: 20px; }
  .pos-checkout-zone { padding: 0; }
  
  /* Bar du bas du stock */
  .total-footer { padding: 16px 20px; flex-direction: column; gap: 8px; align-items: flex-start; }
  .tf-val { font-size: 1.5rem; }

  /* Dettes en colonnes propres */
  .dette-row { flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px; }
  .dette-right { width: 100%; justify-content: space-between; }
  
  /* View headers responsives */
  .view-header-block { flex-direction: row; align-items: center; padding-bottom: 16px; margin-bottom: 16px; }
  .view-title { font-size: 1.4rem; margin-bottom: 2px; }
  .view-sub { font-size: 0.85rem; line-height: 1.3; }

  /* Historique Mobile */
  .hi-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .hi-val { text-align: left; display: flex; gap: 12px; align-items: center; width: 100%; justify-content: space-between;}
  .receipt-actions { grid-template-columns: 1fr; }
  .receipt-btn {
    min-height: 40px;
    font-size: 0.88rem;
    padding: 8px 12px;
    white-space: normal;
    line-height: 1.15;
  }
  .btn-primary-sm,
  .btn-orange-sm {
    padding: 7px 12px;
    font-size: 0.84rem;
    min-height: 38px;
    max-width: 100%;
    white-space: normal;
    line-height: 1.15;
  }
  .btn-primary-sm svg,
  .btn-orange-sm svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
  }
  .topbar-action,
  .access-mini-btn {
    max-width: 100%;
    white-space: normal;
    line-height: 1.15;
  }
  .sidebar.open {
    width: min(92vw, 360px);
  }
}

@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .hist-kpi-bar { grid-template-columns: 1fr; }
  #produits-grid { grid-template-columns: 1fr; }
  .pos-actions { grid-template-columns: 1fr; }
}

/* ── MOBILE NAV BAR FIXE ─────────────────────── */
.mobile-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--card); border-top: 1px solid var(--border);
  grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 60; box-shadow: 0 -4px 30px rgba(0,0,0,0.08);
}
.mn-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 14px 4px 12px; border: none; background: transparent; color: var(--text3);
  font: inherit; font-size: 0.68rem; font-weight: 800; transition: color 0.2s; position: relative; cursor: pointer;
  touch-action: manipulation;
}
.mn-btn svg { width: 24px; height: 24px; transition: transform 0.2s var(--ease); pointer-events: none; }
.mn-btn span { pointer-events: none; }
.mn-btn.active { color: var(--blue); }
.mn-btn.active svg { transform: translateY(-2px); }
.mn-btn.active::after {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 28px; height: 3px; background: var(--blue); border-radius: 0 0 4px 4px;
}

.mn-center { margin-top: -20px; }
.mn-center::before, .mn-center::after { display: none !important; }
.mn-btn.mn-center {
  width: 60px; height: 60px; padding: 0;
  background: var(--blue); color: #fff; border-radius: 50%;
  box-shadow: 0 8px 24px rgba(181,101,29,0.4); margin-left: auto; margin-right: auto;
}
.mn-btn.mn-center svg { width: 26px; height: 26px; }
.mn-btn.mn-center:active { transform: scale(0.95); }

.mn-badge {
  position: absolute; top: 8px; right: 12px;
  background: var(--red); color: #fff;
  width: 18px; height: 18px; border-radius: 50%;
  font-size: 0.65rem; font-weight: 800; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--card);
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 1024px) {
    .content { padding-bottom: calc(120px + env(safe-area-inset-bottom)); }
  }
}

@media (prefers-reduced-motion: no-preference) {
  .product-card,
  .prod-card,
  .cart-row,
  .dash-card,
  .kpi-tile {
    will-change: transform;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* ══════════════════════════════════════════════════
   NOUVEAUX MODULES — P&L · AUDIT · REMBOURSEMENTS · FOURNISSEURS
   ══════════════════════════════════════════════════ */

/* CDF dans la caisse */
.pos-cdf-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0 6px;
  font-size: 0.78rem;
  color: var(--text3);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.pos-cdf-label { text-transform: uppercase; font-size: 0.7rem; }
#pos-cdf-val { font-family: 'JetBrains Mono', monospace; }

/* Badge audit */
.audit-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--blue-lt);
  color: var(--blue);
  white-space: nowrap;
}
.audit-badge.audit-vente      { background: #D1FAE5; color: #065F46; }
.audit-badge.audit-prix       { background: #FEF3C7; color: #92400E; }
.audit-badge.audit-création   { background: #EDE9FE; color: #5B21B6; }
.audit-badge.audit-remboursem { background: #FEE2E2; color: #991B1B; }
.audit-badge.audit-entrée     { background: #FDECD3; color: #8F4F17; }
.audit-badge.audit-perte      { background: #FEE2E2; color: #991B1B; }
.audit-badge.audit-compte     { background: #E0F2FE; color: #0369A1; }
.audit-badge.audit-fournisseu { background: #F0FDF4; color: #166534; }
.audit-badge.audit-taux       { background: #FFF7ED; color: #C2410C; }
.audit-badge.audit-sauvegarde { background: #F0FDF4; color: #166534; }
.audit-badge.audit-bon        { background: #FFF7ED; color: #9A3412; }
.audit-badge.audit-vente-reduit { background: #FEF3C7; color: #B45309; border: 1px solid #FCD34D; }

/* Badge audit — connexions */
.audit-badge.audit-connexion    { background: #D1FAE5; color: #065F46; }
.audit-badge.audit-déconnexion  { background: #F3F4F6; color: #374151; }
.audit-badge.audit-paiement     { background: #FEF3C7; color: #B45309; border: 1px solid #FCD34D; }

/* Dashboard gérant dans le POS */
#gerant-summary { margin-bottom: 14px; }
.gerant-summary-banner {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px;
}
.gerant-sum-title { font-size: 0.78rem; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; }
.gerant-sum-kpis  { display: flex; gap: 12px; flex-wrap: wrap; }
.gerant-sum-kpi   { flex: 1; min-width: 80px; }
.gsv { font-size: 1.05rem; font-weight: 800; color: var(--text1); }
.gsl { font-size: 0.72rem; color: var(--text3); margin-top: 2px; }

/* Fiche client — KPI mini */
.kpi-mini { background: var(--bg); border-radius: 8px; padding: 10px 14px; flex: 1; min-width: 90px; }
.kpi-mini-val { font-size: 1rem; font-weight: 800; color: var(--text1); }
.kpi-mini-lbl { font-size: 0.7rem; color: var(--text3); margin-top: 2px; }

/* Paiement partiel — bouton dans la dette */
.dette-partiel-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 10px; border-radius: 6px; border: 1px solid #FCD34D;
  background: #FEF9C3; color: #854d0e; font-size: 0.75rem; font-weight: 700;
  cursor: pointer; white-space: nowrap;
}
.dette-partiel-btn:hover { background: #FEF08A; }

/* M6 — modal de confirmation stylé */
.confirm-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 9999;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn .12s ease;
}
.confirm-box {
  background: var(--surface, #fff); border-radius: 14px; padding: 24px 20px 20px;
  max-width: 340px; width: 100%; box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.confirm-msg {
  margin: 0 0 20px; font-size: 0.92rem; line-height: 1.55;
  color: var(--text1, #111); white-space: pre-wrap;
}
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }
.confirm-cancel {
  padding: 9px 18px; border-radius: 8px; border: 1px solid var(--border, #e5e7eb);
  background: transparent; color: var(--text2, #374151); font-size: 0.88rem;
  font-weight: 600; cursor: pointer;
}
.confirm-ok {
  padding: 9px 18px; border-radius: 8px; border: none;
  background: var(--blue, #B5651D); color: #fff; font-size: 0.88rem;
  font-weight: 700; cursor: pointer;
}
.confirm-danger { background: #DC2626 !important; }
.photo-preview-dialog { max-width: 360px !important; }
.photo-preview-title { font-size: 0.95rem; font-weight: 800; margin-bottom: 14px; }
.photo-preview-image { width: 100%; height: 220px; object-fit: contain; border-radius: 10px; border: 1px solid var(--border); background: #fff; margin-bottom: 14px; }
.week-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.week-kpis div { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.week-kpis strong, .week-kpis span { display: block; }
.week-kpis strong { color: var(--text); font-size: 1.05rem; }
.week-kpis span { color: var(--text3); font-size: 0.75rem; font-weight: 700; margin-top: 4px; }

/* KPI icons new colors */
.kpi-tile-icon.kpi-icon-green  { background: #D1FAE5; color: #059669; }
.kpi-tile-icon.kpi-icon-red    { background: #FEE2E2; color: #DC2626; }
.kpi-tile-icon.kpi-icon-blue   { background: #FDECD3; color: #B5651D; }
.kpi-tile-icon.kpi-icon-purple { background: #EDE9FE; color: #7C3AED; }

/* Supplier datalist autocomplete */
#ae-supplier { width: 100%; }

/* History simple stack spacing */
.history-simple-stack > .history-simple-card + .history-simple-card { margin-top: 16px; }

/* Mobile: new views responsive */
/* ── Overdue debt badge ── */
.badge-overdue {
  display: inline-block; margin-left: 6px;
  padding: 1px 6px; border-radius: 20px;
  background: #fee2e2; color: #dc2626;
  font-size: 0.62rem; font-weight: 800; vertical-align: middle;
}
.dette-row.overdue { border: 1px solid rgba(239, 68, 68, 0.4); background: rgba(239, 68, 68, 0.08); }
.alert-overdue { color: #ef4444; font-weight: 700; }

/* ── POS discount row ── */
.pos-calc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  font-size: 0.8rem;
}
.pos-calc-label {
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--text3);
  font-weight: 700;
}
.pos-calc-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pos-calc-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--text);
}
.pos-calc-value-green {
  color: #059669;
}
.pos-discount-row {
  display: flex; align-items: center; gap: 6px;
  justify-content: space-between;
  padding: 4px 0; font-size: 0.8rem;
}
.pos-discount-input {
  width: 52px; padding: 3px 6px; border-radius: 6px;
  border: 1px solid var(--border, #e5e7eb);
  background: var(--surface, #fff); font-size: 0.82rem;
  text-align: center; color: var(--text1);
}
.pos-cash-input { width: 76px; }
.pos-discount-tag {
  font-size: 0.7rem; font-weight: 700;
  color: #059669; background: #d1fae5;
  padding: 1px 5px; border-radius: 4px; margin-left: 4px;
}
#pos-change-val {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
}
#pos-change-val.change-negative { color: #DC2626; }
#pos-change-val.change-positive { color: #059669; }

/* ── Inventaire physique ── */
.inv-qty-input {
  width: 60px; padding: 4px 6px; text-align: center;
  border: 1px solid var(--border, #e5e7eb); border-radius: 6px;
  background: var(--surface, #fff); font-size: 0.85rem;
  color: var(--text1);
}

/* ── Load more button ── */
.load-more-wrap { text-align: center; padding: 12px 0; }
.load-more-btn {
  padding: 8px 20px; border-radius: 8px;
  border: 1px solid var(--border, #e5e7eb);
  background: transparent; color: var(--text2, #374151);
  font-size: 0.82rem; font-weight: 600; cursor: pointer;
}
.load-more-btn:hover { background: var(--bg, #f3f4f6); }

@media (max-width: 768px) {
  .pos-cdf-row { font-size: 0.73rem; }
  .pos-calc-row { font-size: 0.73rem; }
  .pos-discount-row { font-size: 0.73rem; }
  .pos-discount-input { width: 48px; }
  .pos-cash-input { width: 68px; }
  #fournisseurs-list .dt-overflow { font-size: 0.8rem; }
  .audit-badge { font-size: 0.65rem; padding: 2px 5px; }
  .price-editor label { font-size: 0.72rem; }
}

/* ══════════════════════════════════════════════════
   CORRECTIFS RESPONSIVE MOBILE — v8.1
   Empêche le débordement horizontal sur tous les appareils
   ══════════════════════════════════════════════════ */

/* 1. Containment global — empêche tout débordement horizontal */
#s-app,
.main-wrap,
.content,
.view {
  overflow-x: hidden;
  max-width: 100%;
}

.dt-overflow {
  max-width: 100%;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  display: block;
}

.data-table-card {
  max-width: 100%;
}
.dt-overflow {
  max-width: 100%;
}

/* 2. Padding du contenu sur tablettes (769–1023px) */
@media (max-width: 1024px) {
  /* padding-bottom a part : reserve la place pour .mobile-nav (barre fixe en bas)
     + l'encoche iOS, sinon les derniers elements (boutons, lignes) restent caches dessous */
  .content { padding: 24px 20px; padding-bottom: calc(120px + env(safe-area-inset-bottom)); }
  .topbar  { padding: 0 20px; }
}

/* 3. Mobile phone — améliorations générales */
@media (max-width: 768px) {

  /* Réduction min-width des tableaux pour moins de scroll horizontal */
  .dt-table { min-width: 480px; }

  /* Perf table du dashboard */
  .perf-header,
  .perf-row { min-width: 300px; }

  /* KPI tiles — valeurs plus petites pour tenir en 2 colonnes */
  .kpi-tile { padding: 18px 14px; }
  .kpi-tile-head { margin-bottom: 12px; }
  .kpi-tile-val { font-size: 1.5rem; }
  .kpi-tile-sub { font-size: 0.8rem; }

  /* View toolbar en colonne sur mobile */
  .vt-left, .vt-right {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .vt-left .date-picker,
  .vt-right .date-picker,
  .vt-left .select-pro,
  .vt-left .field-input,
  .vt-right .search-input {
    max-width: 100% !important;
    width: 100% !important;
  }

  /* Eviter que le texte long dans les cellules déborde */
  .td-name { word-break: break-word; }
  .td-cat  { word-break: break-word; }

  /* Cart total — éviter débordement sur très petits écrans */
  .cart-row-total { font-size: 0.88rem; }
  .pos-total-display span { font-size: 1.35rem; }

  /* Réduction padding header vue sur mobile */
  .view-header-block { padding-bottom: 12px; margin-bottom: 16px; }

  /* Receipt modal — assure le padding correct */
  .receipt-dialog { padding: 20px 16px; }
  .receipt-actions { gap: 8px; }

  /* Form cards sur mobile */
  .form-card { padding: 18px; }
}

/* 4. Très petits écrans (< 400px) — iPhone SE, Galaxy A13, etc. */
@media (max-width: 400px) {
  .content { padding: 14px 12px; padding-bottom: calc(120px + env(safe-area-inset-bottom)); }
  .topbar  { padding: 0 12px; height: 60px; }

  .kpi-tile { padding: 12px; }
  .kpi-tile-val { font-size: 1.22rem; letter-spacing: -0.02em; }
  .kpi-tile-label { font-size: 0.72rem; }
  .kpi-tile-icon { width: 36px; height: 36px; }

  .view-title { font-size: 1.2rem; }
  .view-sub   { font-size: 0.8rem; }

  .cart-row { grid-template-columns: minmax(0,1fr) 68px minmax(58px,auto); gap: 6px; }
  .cart-row-qty button { width: 22px; }
  .cart-price-input { width: 58px; }

  .pos-btn-cash div:last-child,
  .pos-btn-dette div:last-child { font-size: 0.82rem; }

  .dt-table { min-width: 400px; font-size: 0.82rem; }
  .dt-table th, .dt-table td { padding: 12px 10px; }

  .login-form-panel { padding: 28px 16px; }
  .lf-header h1 { font-size: 1.7rem; }

  /* Performance table dashboard */
  .perf-header,
  .perf-row { grid-template-columns: 1fr 64px 64px 80px; min-width: 260px; }
  .perf-num { font-size: 0.85rem; }
  .perf-prod { font-size: 0.88rem; }

  /* Topbar compacte */
  .topbar-title { font-size: 0.95rem; }
  .topbar-date  { display: none; }
  .build-indicator { display: none; }
  .sync-label   { display: none; }
  .btn-cta span { display: none; }
  .btn-cta      { padding: 0 10px; height: 36px; }
}

/* Loading Spinner */
.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
.loading-spinner.large {
  width: 36px;
  height: 36px;
  border-width: 4px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

