/* ═══════════════════════════════════════════════════════════
   ETS MGB — 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 */

/* ── VARIABLES GLOBALES ──────────────────────────────────── */
:root {
  /* Animations Fluides (Premium SaaS feel) */
  --ease:      cubic-bezier(0.4, 0, 0.2, 1);
  --trans:     all 0.3s var(--ease);
  --trans-fast:all 0.15s var(--ease);

  /* Sidebar */
  --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 */
  --bg:        #F4F6F8;
  --card:      #FFFFFF;
  --border:    #E5E7EB;
  --border2:   #F3F4F6;

  /* Couleurs sémantiques */
  --text:      #111827;
  --text2:     #4B5563;
  --text3:     #9CA3AF;
  
  --green:     #10B981;
  --green-lt:  #D1FAE5;
  --red:       #EF4444;
  --red-lt:    #FEE2E2;
  --blue:      #2563EB;
  --blue-lt:   #DBEAFE;
  --orange:    #F59E0B;
  --orange-lt: #FEF3C7;
  --purple:    #475569;
  --purple-lt: #E2E8F0;

  /* Dimensions */
  --topbar-h:  72px;

  /* Rayons */
  --r:   8px;
  --rlg: 8px;
  --rxl: 8px;

  /* Ombres Pro */
  --sh-sm: 0 1px 2px rgba(0,0,0,0.04);
  --sh:    0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
  --sh-md: 0 10px 15px -3px rgba(0,0,0,0.06), 0 4px 6px -2px rgba(0,0,0,0.03);
  --sh-lg: 0 20px 25px -5px rgba(0,0,0,0.08), 0 10px 10px -5px rgba(0,0,0,0.02);
}

/* ── 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; }

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 */
  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 */
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 0 60px rgba(0,0,0,0.15);
  transition: max-width 0.4s var(--ease);
}



/* ══════════════════════════════════════════════════
   ÉCRAN LOGIN (Square-like)
══════════════════════════════════════════════════ */
#s-login {
  width: 100%;
  min-height: 100%;
  height: 100vh;
  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%;
  height: 100%;
}

.login-brand {
  width: 45%;
  background: var(--sb-bg);
  background-image:
    radial-gradient(circle at 15% 50%, rgba(37,99,235,0.12), transparent 40%),
    linear-gradient(180deg, rgba(255,255,255,0.04), transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  position: relative;
}
.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;
  background: var(--blue);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 800; color: #fff;
  box-shadow: 0 8px 24px rgba(37,99,235,0.3);
}
.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(37,99,235,0.6);
}
.brand-city { font-size: 0.9rem; color: var(--sb-text); font-weight: 600; }

.login-form-panel {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 48px 32px;
  background: var(--card);
}
.lf-inner { width: 100%; max-width: 420px; }

.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;
  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(37,99,235,0.12), var(--sh);
  transform: translateY(-2px);
}
.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(37,99,235,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(37,99,235,0.3);
  cursor: pointer;
}
.btn-login svg { width: 20px; height: 20px; transition: transform 0.3s var(--ease); }
.btn-login:hover { background: #1D4ED8; box-shadow: 0 6px 20px rgba(37,99,235,0.4); transform: translateY(-2px); }
.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; }
  .login-form-panel { padding: 40px 24px; align-items: flex-start; }
}

/* ══════════════════════════════════════════════════
   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;
  background: var(--blue);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 800; color: #fff;
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}
.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);
}
.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; overflow-y: auto; overflow-x: hidden;
  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;
  white-space: nowrap;
  width: calc(100% - 28px);
}
.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);
}
.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;
}
.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; }

/* ── 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;
}
.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(37,99,235,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);
  min-height: 100dvh;
  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: var(--card);
  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: var(--bg); color: var(--text);
  cursor: pointer;
  transition: var(--trans-fast);
}
.topbar-menu:active { transform: scale(0.9); }
.topbar-menu svg { width: 20px; height: 20px; }

.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; }

.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);
}
.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: 800; font-size: 0.95rem;
  display: flex; align-items: center; gap: 8px;
  transition: var(--trans);
  box-shadow: 0 4px 12px rgba(37,99,235,0.25);
  cursor: pointer;
}
.btn-cta svg { width: 18px; height: 18px; transition: transform 0.3s var(--ease); }
.btn-cta:hover { background: #1D4ED8; box-shadow: 0 6px 16px rgba(37,99,235,0.35); transform: translateY(-1px); }
.btn-cta:hover svg { transform: scale(1.1); }
.btn-cta:active { transform: scale(0.97); }

.btn-primary-sm, .btn-orange-sm {
  padding: 10px 18px; border-radius: 8px; font-weight: 800; font-size: 0.95rem;
  display: inline-flex; align-items: center; gap: 8px; border: none; cursor: pointer;
  transition: var(--trans); color: #fff; position: relative; overflow: hidden;
}
.btn-primary-sm::after, .btn-orange-sm::after {
  content: ''; position: absolute; inset: 0 0 50% 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 100%);
  pointer-events: none;
}
.btn-primary-sm { background: var(--blue); box-shadow: 0 2px 8px rgba(37,99,235,0.18); }
.btn-primary-sm:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,0.35); filter: brightness(1.05); }
.btn-primary-sm:active, .btn-orange-sm:active { transform: scale(0.96); }

.btn-orange-sm { background: var(--red) !important; box-shadow: 0 2px 8px rgba(239,68,68,0.18); }
.btn-orange-sm:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(239,68,68,0.35); filter: brightness(1.05); }

.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(37,99,235,0.2); border-color: var(--blue); }

/* ── CONTENU ──────────────────────────────────── */
.content {
  flex: 1;
  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; 
  animation: viewIn 0.25s var(--ease) both;
  min-width: 0; 
  width: 100%; 
}
.view.active { display: block; }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.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;
  min-height: calc(100dvh - var(--topbar-h) - 40px);
}

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

.scanner-flex-container { display: flex; gap: 12px; margin-bottom: 20px; width: 100%; align-items: stretch; }

.pos-scanner-box {
  position: relative;
  flex: 1;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.scanner-icon {
  position: absolute; left: 18px; top: 50%; transform: translateY(-50%);
  color: var(--blue); z-index: 10; pointer-events: none;
}
#pos-scanner {
  width: 100%; height: 52px;
  padding: 0 20px 0 56px;
  border: 1px solid var(--border);
  border-radius: var(--rlg);
  font-family: 'JetBrains Mono', monospace; font-size: 1.1rem; font-weight: 700;
  background: var(--card); color: var(--text);
  box-shadow: var(--sh-sm);
  outline: none; transition: var(--trans);
}
#pos-scanner:focus { box-shadow: 0 0 0 4px rgba(37,99,235,0.15); border-color: var(--blue); }
#pos-scanner::placeholder { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 500; color: var(--text3); }

.scanner-camera-btn {
  height: 52px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--text);
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  box-shadow: var(--sh-sm);
  transition: var(--trans-fast);
}
.scanner-camera-btn svg { width: 18px; height: 18px; }
.scanner-camera-btn:hover { background: #1F2937; transform: translateY(-1px); }
.scanner-camera-btn:active { transform: scale(0.98); }
.scanner-camera-btn:disabled { opacity: 0.65; cursor: progress; transform: none; }

.camera-container {
  margin-bottom: 18px;
  background: #0B111A;
  border-radius: var(--r);
  overflow: hidden;
  position: relative;
  box-shadow: var(--sh-md);
  border: 1px solid rgba(255,255,255,0.08);
}
.camera-helper {
  padding: 12px 14px;
  color: rgba(255,255,255,0.72);
  font-size: 0.9rem;
  font-weight: 700;
  background: rgba(255,255,255,0.04);
}
#reader { width: 100%; }
#reader video { width: 100% !important; display: block; }
#reader__dashboard_section_swaplink,
#reader__dashboard_section_csr span,
#reader__dashboard_section_csr button {
  font-family: 'Plus Jakarta Sans', sans-serif !important;
}
.btn-camera-stop {
  width: 100%;
  padding: 13px 14px;
  font: inherit;
  font-weight: 800;
  font-size: 0.95rem;
  background: var(--red);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}
.btn-camera-stop:hover { background: #DC2626; }

/* PRODUCT GRID ODOO STYLE */
.product-grid-container {
  flex: 1;
  min-height: 0;
  max-height: calc(100dvh - var(--topbar-h) - 165px);
  overflow-y: auto;
  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 { transform: translateY(-3px); box-shadow: var(--sh-md); border-color: var(--blue-lt); }
.product-card:active { transform: scale(0.96); }
.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));
}
.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: none;
  border-radius: var(--r); padding: 0; box-shadow: var(--sh-lg);
  width: 100%; display: flex; flex-direction: column; overflow: hidden;
  height: calc(100dvh - var(--topbar-h) - 40px);
}

.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; animation: viewIn 0.2s; }
.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: 1.85rem; font-family: 'JetBrains Mono', monospace; line-height: 1; letter-spacing: -0.05em; }

.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: 10px;
  background: var(--green); color: #fff; border: none; border-radius: var(--rlg);
  min-height: 50px; padding: 12px 14px; cursor: pointer; transition: var(--trans);
  box-shadow: 0 4px 14px rgba(16,185,129,0.3); text-align: center; width: 100%;
}
.pos-btn-dette {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--blue-lt); color: var(--blue); border: none; border-radius: var(--rlg);
  min-height: 50px; padding: 12px 14px; cursor: pointer; transition: var(--trans); text-align: center; width: 100%;
}
.pos-btn-cash:hover { background: #059669; transform: translateY(-2px); box-shadow: 0 6px 18px rgba(16,185,129,0.4); }
.pos-btn-dette:hover { background: #BFDBFE; transform: translateY(-2px); }
.pos-btn-cash:active, .pos-btn-dette:active { transform: scale(0.96); }

.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(37,99,235,0.12); }
.pos-btn-cash div:last-child { font-weight: 800; font-size: 0.95rem; line-height: 1.2; }
.pos-btn-dette div:last-child { font-weight: 800; font-size: 0.95rem; line-height: 1.2; }

/* ══════════════════════════════════════════════════
   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); transform: translateY(-4px); 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); transform: translateY(-2px); 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: #1D4ED8; 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; transition: transform 0.3s var(--ease); }
.qa-icon svg { width: 18px; height: 18px; }
.qa-btn:hover .qa-icon { transform: scale(1.1); }

.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(37,99,235,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(37,99,235,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); transform: translateY(-2px); }
.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); }
.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); transform: translateY(-2px);}
.dette-row.unpaid { border-left: 5px solid var(--red); }
.dette-row.paid   { border-left: 5px solid var(--green); }

.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; transform: scale(1.02); }
.status-paid   { background: var(--green-lt); color: var(--green); border-color: #86EFAC; }
.status-paid:hover { background: #BBFBD0; transform: scale(1.02); }
.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(37,99,235,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(37,99,235,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%; height: 56px; margin-top: 28px; border-radius: 8px; border: none; font: inherit; font-weight: 800; font-size: 1.05rem; display: flex; align-items: center; justify-content: center; gap: 12px; 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.96); }
.btn-submit-primary { background: var(--blue); color: #fff; box-shadow: 0 4px 14px rgba(37,99,235,0.2); }
.btn-submit-primary:hover { box-shadow: 0 8px 20px rgba(37,99,235,0.28); transform: translateY(-1px); filter: brightness(1.04); }
.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 8px 20px rgba(245,158,11,0.28); transform: translateY(-1px); filter: brightness(1.04); }

/* ── 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(37,99,235,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); animation: viewIn 0.3s var(--ease) both; min-width: 0; overflow: hidden; }
.prod-card:hover { box-shadow: var(--sh-md); transform: translateY(-3px); }
.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-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-code { font-family:'JetBrains Mono', monospace; font-size:0.8rem; background:var(--bg); padding:2px 5px; border-radius:4px; margin-right:4px; color: var(--text2); }
.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(37,99,235,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; transform: translateY(-1px); }

/* ── 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 { transform: translateY(-2px); 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 { display: flex; justify-content: space-between; align-items: center; padding: 18px 28px; border-bottom: 1px solid var(--border2); transition: background 0.15s, transform 0.15s; width: 100%; cursor: pointer; }
.hi-row:last-child { border-bottom: none; }
.hi-row:hover { background: var(--bg); transform: translateX(2px); }
.hi-row.hi-in  { border-left: 4px solid var(--green); }
.hi-row.hi-out { border-left: 4px solid var(--orange); }
.hi-row.hi-lost{ border-left: 4px solid var(--red); }
.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); transform: translateY(-4px); 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 { font-size: 3.5rem; margin-bottom: 20px; opacity: 0.5; }
.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: 45; 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.3s var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(20px) scale(0.95); } to { opacity: 1; transform: translateX(-50%) translateY(0) scale(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.56);
  backdrop-filter: blur(4px);
}
.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: 52px;
  border-radius: 12px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 800;
  font-size: 0.96rem;
  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) {
  transform: translateY(-1px);
  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-layout { flex-direction: column; min-height: 0; }
  .pos-side { width: 100%; position: static; }
  .product-grid-container { max-height: none; min-height: auto; }
  .pos-checkout-zone { height: auto; min-height: 320px; }
  .pos-cart-items { max-height: 340px; }
}

@media (max-width: 1024px) {
  .sidebar,
  .sidebar.collapsed {
    width: min(84vw, 320px);
    transform: translateX(-100%);
    transition: transform 0.3s var(--ease);
    z-index: 90;
  }
  .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.92); }
  .sidebar.open .sb-section-label { opacity: 1; height: auto; padding: 16px 24px 8px; color: rgba(255,255,255,0.52); }
  .sidebar.open .sb-user-info { display: block; }
  .sidebar.open .sb-logout { display: flex; }
  .sidebar.open .sb-badge { display: flex; }
  .sidebar.open .sb-collapse { display: none; }
  /* 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.86); font-weight: 700; }
  .sidebar.open .sb-item.active { color: #fff; background: rgba(37,99,235,0.22); }
  .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; }
}

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

  .content { padding: 20px 16px; overflow-x: hidden;}
  .login-role-grid { grid-template-columns: 1fr; }
  .view-toolbar, .vt-left, .vt-right { width: 100%; }
  .view-toolbar > button { width: 100%; justify-content: center; }
  #stock-pills, #entries-pills, #exits-pills,
  #stock-date, #entries-date, #exits-date,
  #produit-search {
    max-width: 100% !important;
    width: 100% !important;
  }
  
  .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; }
  .btn-cta span { display: none; }
  .btn-cta { padding: 0 12px; height: 40px; }
  .topbar-title { font-size: 1.1rem; }

  /* Touch Targets pour gros doigts */
  .btn-submit { height: 50px; font-size: 1rem; }
  .back-btn { width: 44px; height: 44px; margin-top: 0; }

  /* POS Mobile Opti */
  .pos-layout { gap: 16px; }
  .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: 48px; justify-content: center; text-align: center; padding: 10px 8px;}
  .pos-btn-cash div:last-child, .pos-btn-dette div:last-child { font-size: 0.9rem; }
  #pos-scanner { font-size: 1rem; height: 52px;}
  .scanner-camera-btn { height: 52px; padding: 0 12px; }
  .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); }
  
  /* 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; }

  /* 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; }
}

@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .hist-kpi-bar { grid-template-columns: 1fr; }
  #produits-grid { grid-template-columns: 1fr; }
  .scanner-camera-btn span { display: none; }
  .scanner-camera-btn { width: 52px; padding: 0; }
  .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;
}
.mn-btn svg { width: 24px; height: 24px; transition: transform 0.2s var(--ease);}
.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(37,99,235,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: #DBEAFE; color: #1D4ED8; }
.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, #2563EB); color: #fff; font-size: 0.88rem;
  font-weight: 700; cursor: pointer;
}
.confirm-danger { background: #DC2626 !important; }

/* 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: #DBEAFE; color: #2563EB; }
.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-left: 3px solid #ef4444; }
.alert-overdue { color: #ef4444; font-weight: 700; }

/* ── POS discount row ── */
.pos-discount-row {
  display: flex; align-items: center; gap: 6px;
  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-discount-tag {
  font-size: 0.7rem; font-weight: 700;
  color: #059669; background: #d1fae5;
  padding: 1px 5px; border-radius: 4px; margin-left: 4px;
}

/* ── 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-discount-row { font-size: 0.73rem; }
  #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%;
}

/* Les conteneurs dt-overflow doivent pouvoir scroller sans faire déborder la page */
.data-table-card {
  max-width: 100%;
}
.dt-overflow {
  max-width: 100%;
}

/* 2. Padding du contenu sur tablettes (769–1023px) */
@media (max-width: 1024px) {
  .content { padding: 24px 20px; }
  .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; }
  .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; }
  .sync-label   { display: none; }
  .btn-cta span { display: none; }
  .btn-cta      { padding: 0 10px; height: 36px; }
}
