/* ============ RESET & BASE ============ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --sidebar-width: 260px;
  --vh: 1vh;
  /* Safe area insets for notched devices */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

html {
  height: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: #1E293B;
  background: linear-gradient(135deg, #FFF7ED 0%, #F0FDF4 100%);
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 22px; font-weight: 600; }
h3 { font-size: 18px; font-weight: 600; }
h4 { font-size: 16px; font-weight: 600; }

a { color: #EA580C; text-decoration: none; transition: color 0.2s; }
a:hover { color: #C2410C; }

/* ============ LOADING OVERLAY ============ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,247,237,0.97), rgba(240,253,244,0.97));
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-content {
  text-align: center;
  padding: 20px;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #FED7AA;
  border-top-color: #EA580C;
  border-right-color: #16A34A;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 18px;
  font-weight: 600;
  color: #1E293B;
  margin-bottom: 4px;
}

.loading-subtext {
  font-size: 13px;
  color: #94A3B8;
}

/* ============ INLINE LOADING SPINNER ============ */
.inline-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #FED7AA;
  border-top-color: #EA580C;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

.inline-spinner-sm {
  width: 12px;
  height: 12px;
  border-width: 1.5px;
}

/* ============ BUTTON SPINNER ============ */
.btn-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 8px;
}

.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

/* ============ CONNECTION STATUS ============ */
.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #64748B;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(255,255,255,0.8);
  border: 1px solid #FED7AA;
  backdrop-filter: blur(4px);
  flex-shrink: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot-online {
  background: #16A34A;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.2);
}

.status-dot-offline {
  background: #EF4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
  animation: pulse-dot 2s infinite;
}

.status-dot-checking {
  background: #F59E0B;
  animation: pulse-dot 1s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.status-text {
  white-space: nowrap;
}

/* ============ PASSWORD INPUT ============ */
.password-input-wrapper {
  position: relative;
}

.password-input-wrapper .input {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.password-toggle:hover {
  opacity: 1;
}

/* ============ LOGIN PAGE ============ */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #FFF7ED 0%, #ECFDF5 50%, #FFF7ED 100%);
  background-size: 400% 400%;
  animation: gradientShift 12s ease infinite;
  padding: 16px;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.login-container {
  display: flex;
  width: 900px;
  max-width: 100%;
  background: white;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(234, 88, 12, 0.12), 0 8px 24px rgba(22, 163, 74, 0.08);
}

.login-left {
  width: 45%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.login-left img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
}

.login-left-overlay {
  position: relative;
  z-index: 1;
  color: white;
  text-align: center;
  padding: 40px 20px;
  background: linear-gradient(135deg, rgba(234, 88, 12, 0.85), rgba(22, 163, 74, 0.80));
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.login-left-overlay h1 { font-size: 32px; margin-bottom: 8px; text-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.login-left-overlay p { font-size: 16px; opacity: 0.95; }

.login-right {
  width: 55%;
  padding: 48px;
  display: flex;
  align-items: center;
  overflow-y: auto;
}

.login-form-container { width: 100%; }
.login-form-container h2 { margin-bottom: 4px; color: #1E293B; }
.login-form-container .text-muted { color: #64748B; margin-bottom: 24px; }
.login-hint { color: #94A3B8; font-size: 12px; margin-top: 16px; text-align: center; word-break: break-all; }

/* ============ APP LAYOUT ============ */
.app-layout {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  position: relative;
}

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #1A1A2E 0%, #16213E 50%, #0F3D0F 100%);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 100;
  transition: transform 0.3s ease;
  box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  background: linear-gradient(135deg, rgba(234, 88, 12, 0.15), rgba(22, 163, 74, 0.15));
  flex-shrink: 0;
}

.sidebar-header h2 { font-size: 20px; color: white; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.nav-list {
  list-style: none;
  padding: 12px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  cursor: pointer;
  transition: all 0.2s;
  color: #94A3B8;
  font-size: 14px;
  font-weight: 500;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(234, 88, 12, 0.2), rgba(22, 163, 74, 0.15));
  color: #FDBA74;
  border-left: 3px solid #EA580C;
}

.nav-icon { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.user-avatar { font-size: 28px; flex-shrink: 0; }
.user-name { font-size: 14px; font-weight: 600; }
.user-role { font-size: 12px; color: #94A3B8; text-transform: capitalize; }

.btn-change-password {
  width: 100%;
  background: linear-gradient(135deg, rgba(234, 88, 12, 0.15), rgba(22, 163, 74, 0.15));
  color: #FDBA74;
  border: none;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: all 0.2s;
  margin-bottom: 8px;
}

.btn-change-password:hover {
  background: linear-gradient(135deg, rgba(234, 88, 12, 0.3), rgba(22, 163, 74, 0.3));
  color: white;
}

.btn-logout {
  width: 100%;
  background: rgba(239, 68, 68, 0.15);
  color: #FCA5A5;
  border: none;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
}

.btn-logout:hover { background: rgba(239, 68, 68, 0.3); }

/* ============ SIDEBAR OVERLAY (mobile) ============ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ============ MAIN CONTENT ============ */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  min-width: 0; /* Prevent flex child overflow */
  width: calc(100% - var(--sidebar-width));
}

.top-bar {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(234, 88, 12, 0.1);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
  min-width: 0;
}

.top-bar h1 {
  font-size: 20px;
  flex: 1;
  color: #1E293B;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.btn-hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  flex-shrink: 0;
}

.content-area {
  padding: 24px;
  flex: 1;
  min-width: 0; /* Prevent flex child overflow */
  overflow-x: hidden;
}

/* ============ PAGE HEADER ============ */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h2 { margin: 0; }
.subtitle { color: #64748B; font-size: 14px; }

/* ============ CARDS ============ */
.card {
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(234, 88, 12, 0.04);
  border: 1px solid rgba(234, 88, 12, 0.08);
  transition: box-shadow 0.2s, transform 0.2s;
  overflow: hidden; /* Prevent content overflow */
}

.card:hover {
  box-shadow: 0 4px 16px rgba(234, 88, 12, 0.08), 0 2px 8px rgba(22, 163, 74, 0.06);
}

.card-loading {
  position: relative;
  min-height: 100px;
}

.card-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mb-2 { margin-bottom: 16px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }

/* ============ SKELETON LOADING ============ */
.skeleton {
  background: linear-gradient(90deg, #FFF7ED 25%, #FED7AA 50%, #FFF7ED 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 6px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text { height: 14px; margin-bottom: 8px; width: 80%; }
.skeleton-text-sm { height: 12px; margin-bottom: 6px; width: 60%; }
.skeleton-title { height: 22px; margin-bottom: 12px; width: 40%; }
.skeleton-card { height: 180px; border-radius: 14px; }
.skeleton-stat { height: 80px; border-radius: 14px; }

/* ============ STATS GRID ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.02);
  border: 1px solid rgba(234, 88, 12, 0.08);
  transition: transform 0.2s, box-shadow 0.2s;
  min-width: 0;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(234, 88, 12, 0.1);
}

.stat-icon { font-size: 36px; flex-shrink: 0; }
.stat-info { min-width: 0; }
.stat-value { font-size: 28px; font-weight: 700; color: #1E293B; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-label { font-size: 13px; color: #64748B; }

.stat-blue { border-left: 4px solid #EA580C; }
.stat-orange { border-left: 4px solid #F59E0B; }
.stat-green { border-left: 4px solid #16A34A; }
.stat-purple { border-left: 4px solid #7C3AED; }

/* ============ DASHBOARD GRID ============ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  margin-bottom: 24px;
}

/* ============ HERO BANNER ============ */
.hero-banner {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  height: 200px;
  margin-bottom: 24px;
}

.hero-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(234, 88, 12, 0.80), rgba(22, 163, 74, 0.70));
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: white;
  text-align: center;
  padding: 24px;
}

.hero-overlay h2 { font-size: 24px; margin-bottom: 8px; text-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.hero-overlay p { font-size: 16px; opacity: 0.95; }

/* ============ LINGE GRID ============ */
.linge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.linge-card {
  background: rgba(255,255,255,0.95);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  border: 1px solid rgba(234, 88, 12, 0.08);
  transition: transform 0.2s, box-shadow 0.2s;
}

.linge-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(234, 88, 12, 0.12);
}

.linge-img {
  height: 180px;
  overflow: hidden;
  background: linear-gradient(135deg, #FFF7ED, #F0FDF4);
}

.linge-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.linge-body { padding: 16px; }
.linge-body h3 { margin-bottom: 8px; }
.linge-price { font-size: 20px; font-weight: 700; color: #EA580C; margin-top: 8px; }

.linge-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.linge-mini-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.linge-mini-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 10px;
  background: linear-gradient(135deg, #FFF7ED, #F0FDF4);
  transition: transform 0.15s;
}

.linge-mini-card:hover {
  transform: translateX(4px);
}

.linge-mini-card img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.linge-mini-card strong { display: block; font-size: 14px; }
.linge-mini-card span { font-size: 12px; color: #EA580C; font-weight: 600; }

/* ============ CATALOGUE (COMMANDE) ============ */
.catalogue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.catalogue-card {
  background: rgba(255,255,255,0.95);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  border: 1px solid rgba(234, 88, 12, 0.08);
  transition: transform 0.2s, box-shadow 0.2s;
}

.catalogue-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(234, 88, 12, 0.1);
}

.catalogue-img {
  height: 160px;
  overflow: hidden;
  background: linear-gradient(135deg, #FFF7ED, #F0FDF4);
  position: relative;
}

/* ============ SEARCH & FILTER SECTION ============ */
.search-filter-section {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  padding: 16px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(234, 88, 12, 0.04);
  border: 1px solid rgba(234, 88, 12, 0.08);
}

.search-bar-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.search-input-container {
  position: relative;
  flex: 1;
  max-width: 480px;
}

.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-filters .btn-outline {
  background: #F1F5F9;
  color: #475569;
  border: 1px solid #CBD5E1;
  transition: all 0.2s;
}

.category-filters .btn-outline:hover {
  background: #FFF7ED;
  border-color: #EA580C;
  color: #EA580C;
}

@media (max-width: 768px) {
  .search-filter-section {
    padding: 12px 14px;
  }

  .search-bar-wrapper {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .search-input-container {
    max-width: 100%;
  }

  .category-filters {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    gap: 6px;
  }

  .category-filters .btn {
    flex-shrink: 0;
    font-size: 12px !important;
    padding: 5px 12px !important;
  }
}

@media (max-width: 480px) {
  .search-filter-section {
    padding: 10px 10px;
  }
}

.catalogue-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.catalogue-info { padding: 12px 16px 0; }
.catalogue-info h3 { margin-bottom: 4px; }
.catalogue-price { font-size: 18px; font-weight: 700; color: #EA580C; margin-top: 8px; }

.catalogue-actions { padding: 12px 16px 16px; }

.quantity-control, .photo-upload {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.quantity-control label, .photo-upload label {
  font-size: 13px;
  color: #64748B;
  white-space: nowrap;
}

.panier-summary {
  display: flex;
  align-items: center;
}

/* ============ CLIENT ASSOCIATION ============ */
.client-association {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.divider-text {
  text-align: center;
  color: #94A3B8;
  font-weight: 600;
  font-size: 16px;
  position: relative;
}

.divider-text::before, .divider-text::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: linear-gradient(90deg, transparent, #FED7AA, transparent);
}

.divider-text::before { left: 0; }
.divider-text::after { right: 0; }

.client-found {
  background: linear-gradient(135deg, #ECFDF5, #F0FDF4);
  border: 1px solid #16A34A;
  border-radius: 10px;
  padding: 16px;
  margin-top: 12px;
}

/* ============ QR SCANNER ============ */
.scan-section {
  margin-bottom: 20px;
}

.qr-scanner-container {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 16px auto;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
}

.qr-video {
  width: 100%;
  display: block;
  border-radius: 14px;
}

.qr-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.qr-frame {
  width: 200px;
  height: 200px;
  border: 3px solid #16A34A;
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4);
  animation: qr-pulse 2s ease-in-out infinite;
}

@keyframes qr-pulse {
  0%, 100% { border-color: #16A34A; }
  50% { border-color: #4ADE80; }
}

.scan-hint {
  text-align: center;
  color: white;
  font-size: 13px;
  padding: 8px;
  background: rgba(0,0,0,0.6);
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
}

.divider-text-sm {
  text-align: center;
  color: #94A3B8;
  font-weight: 500;
  font-size: 13px;
  margin: 16px 0;
  position: relative;
}

.divider-text-sm::before, .divider-text-sm::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 30%;
  height: 1px;
  background: linear-gradient(90deg, transparent, #BBF7D0, transparent);
}

.divider-text-sm::before { left: 5%; }
.divider-text-sm::after { right: 5%; }

/* ============ RECAP ============ */
.recap-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.recap-client p { margin: 4px 0; }

.recap-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 24px 0;
  flex-wrap: wrap;
}

/* ============ COMMANDE CARDS (HISTORIQUE) ============ */
.commandes-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.commande-card {
  background: rgba(255,255,255,0.95);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  border: 1px solid rgba(234, 88, 12, 0.08);
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.commande-card:hover {
  box-shadow: 0 4px 16px rgba(234, 88, 12, 0.08);
}

.commande-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(135deg, #FFF7ED, #F0FDF4);
  border-bottom: 1px solid rgba(234, 88, 12, 0.08);
  flex-wrap: wrap;
  gap: 8px;
}

.commande-header h3 { font-size: 16px; }
.commande-header .text-muted { font-size: 12px; color: #64748B; }

.commande-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.commande-total { font-size: 18px; font-weight: 700; color: #EA580C; }

.commande-client { padding: 12px 20px; border-bottom: 1px solid #F1F5F9; }
.commande-client p { font-size: 13px; color: #64748B; word-break: break-word; }

.commande-details-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 8px 20px;
  font-size: 13px;
  border-bottom: 1px solid #F1F5F9;
}

.commande-items { padding: 0 20px; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.commande-footer {
  padding: 12px 20px;
  display: flex;
  gap: 8px;
  border-top: 1px solid rgba(234, 88, 12, 0.08);
  background: linear-gradient(135deg, #FFFBF5, #F8FFF8);
  flex-wrap: wrap;
  align-items: center;
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ============ FIDELITE CARDS ============ */
.fidelite-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
}

.fidelite-card {
  /* PVC card ratio: 85.6mm x 54mm ≈ 1.585:1 */
  width: 100%;
  max-width: 428px;
  aspect-ratio: 85.6 / 54;
  border-radius: 14px;
  color: white;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25), 0 4px 12px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.15);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  /* Base gradient */
  background:
    /* Decorative texture overlay - diagonal lines */
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 8px,
      rgba(255,255,255,0.03) 8px,
      rgba(255,255,255,0.03) 16px
    ),
    /* Subtle circle pattern */
    radial-gradient(circle at 20% 80%, rgba(255,255,255,0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.06) 0%, transparent 50%),
    radial-gradient(circle at 60% 60%, rgba(255,255,255,0.04) 0%, transparent 40%),
    /* Main gradient */
    linear-gradient(135deg, #1a1a2e 0%, #16213e 30%, #0f3460 60%, #1a1a2e 100%);
}

.fidelite-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    /* Gold foil accent stripe */
    linear-gradient(90deg, transparent 0%, transparent 3%, rgba(212,175,55,0.15) 3%, rgba(212,175,55,0.08) 5%, transparent 5%),
    /* Holographic shimmer effect */
    linear-gradient(135deg, transparent 40%, rgba(212,175,55,0.1) 45%, rgba(255,215,0,0.05) 50%, transparent 55%);
  pointer-events: none;
  z-index: 1;
}

.fidelite-card::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(212,175,55,0.06) 0%, transparent 70%);
  pointer-events: none;
  z-index: 1;
}

.fidelite-card:hover {
  transform: translateY(-6px) scale(1.01);
  box-shadow: 0 16px 40px rgba(0,0,0,0.35), 0 6px 16px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.2);
}

.fidelite-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px 8px;
  position: relative;
  z-index: 2;
}

.fidelite-card-header h3 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.fidelite-card-header .badge-primary {
  background: linear-gradient(135deg, #D4AF37, #F5D060);
  color: #1a1a2e;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.5px;
  padding: 3px 10px;
  border-radius: 3px;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(212,175,55,0.3);
}

.fidelite-card-body {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 18px 8px;
  flex: 1;
  position: relative;
  z-index: 2;
}

.fidelite-qr img {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  background: white;
  padding: 3px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.fidelite-info { min-width: 0; }
.fidelite-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.fidelite-code {
  font-size: 11px;
  opacity: 0.8;
  letter-spacing: 2px;
  margin-top: 3px;
  word-break: break-all;
  font-family: 'Courier New', monospace;
  font-weight: 600;
}
.fidelite-phone {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 3px;
}

.fidelite-card-footer {
  padding: 8px 18px 10px;
  display: flex;
  gap: 8px;
  border-top: 1px solid rgba(212,175,55,0.2);
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
}

.fidelite-card-footer .btn-secondary {
  background: rgba(212,175,55,0.2);
  color: #F5D060;
  border-color: rgba(212,175,55,0.4);
  font-size: 11px;
}

.fidelite-card-footer .btn-secondary:hover {
  background: rgba(212,175,55,0.35);
}

.fidelite-card-footer .btn-danger {
  background: rgba(239,68,68,0.2);
  border-color: rgba(239,68,68,0.4);
  font-size: 11px;
}

.fidelite-card-footer .btn-danger:hover {
  background: rgba(239,68,68,0.35);
}

/* Chip EMV decoration */
.fidelite-chip {
  width: 36px;
  height: 26px;
  border-radius: 5px;
  background: linear-gradient(135deg, #D4AF37 0%, #F5D060 40%, #D4AF37 60%, #C5A028 100%);
  position: relative;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.3);
  flex-shrink: 0;
}

.fidelite-chip::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  right: 4px;
  bottom: 4px;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 2px;
}

.fidelite-chip::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 3px;
  right: 3px;
  height: 1px;
  background: rgba(0,0,0,0.12);
}

/* Contactless icon */
.fidelite-contactless {
  width: 20px;
  height: 20px;
  position: absolute;
  top: 12px;
  right: 18px;
  z-index: 2;
  opacity: 0.5;
}

.fidelite-contactless svg {
  width: 100%;
  height: 100%;
  fill: white;
}

/* ============ CONFIG GRID ============ */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

/* ============ STATS SPECIFIC ============ */
.top-articles { display: flex; flex-direction: column; gap: 12px; }

.top-article-item {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  padding: 8px 12px;
  background: linear-gradient(135deg, #FFF7ED, #F0FDF4);
  border-radius: 10px;
}

.top-article-item .rank {
  font-weight: 700;
  color: #EA580C;
  width: 30px;
  flex-shrink: 0;
}

.top-article-item .name { flex: 1; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-article-item .count { font-weight: 600; color: #64748B; flex-shrink: 0; }

.top-article-item .bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #EA580C, #16A34A);
  border-radius: 0 0 10px 10px;
}

.statut-repartition {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.statut-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: linear-gradient(135deg, #FFF7ED, #F0FDF4);
  border-radius: 10px;
}

.statut-count { font-size: 20px; font-weight: 700; }

/* ============ TABLES ============ */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(234, 88, 12, 0.08);
  font-size: 13px;
}

.table th {
  background: linear-gradient(135deg, #FFF7ED, #F0FDF4);
  font-weight: 600;
  color: #64748B;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.table tbody tr:hover { background: rgba(234, 88, 12, 0.03); }

.table-sm th, .table-sm td { padding: 6px 10px; font-size: 12px; }

/* ============ FORMS ============ */
.form-group {
  margin-bottom: 16px;
  flex: 1;
  min-width: 0;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  margin-bottom: 4px;
}

.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: white;
  color: #1E293B;
  max-width: 100%;
}

.input:focus {
  outline: none;
  border-color: #EA580C;
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.1);
}

.input:disabled {
  background: #F8FAFC;
  color: #94A3B8;
  cursor: not-allowed;
}

.input-sm {
  padding: 6px 10px;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: white;
  max-width: 100%;
}

.input-sm:focus {
  outline: none;
  border-color: #EA580C;
  box-shadow: 0 0 0 2px rgba(234, 88, 12, 0.08);
}

.input-xs {
  padding: 4px 6px;
  border: 1px solid #E2E8F0;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  background: white;
  max-width: 100%;
}

.input-file {
  font-size: 12px;
  max-width: 200px;
}

.form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

textarea.input { resize: vertical; min-height: 60px; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: linear-gradient(135deg, #EA580C, #D97706);
  color: white;
  box-shadow: 0 2px 8px rgba(234, 88, 12, 0.25);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #C2410C, #B45309);
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.35);
  transform: translateY(-1px);
}

.btn-secondary { background: #F1F5F9; color: #475569; border-color: #E2E8F0; }
.btn-secondary:hover { background: #E2E8F0; }

.btn-success {
  background: linear-gradient(135deg, #16A34A, #15803D);
  color: white;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.25);
}
.btn-success:hover {
  background: linear-gradient(135deg, #15803D, #166534);
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.35);
  transform: translateY(-1px);
}

.btn-danger { background: #EF4444; color: white; }
.btn-danger:hover { background: #DC2626; }

.btn-warning {
  background: linear-gradient(135deg, #F59E0B, #EA580C);
  color: white;
}
.btn-warning:hover {
  background: linear-gradient(135deg, #D97706, #C2410C);
}

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-block { width: 100%; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============ BADGES ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-primary { background: #FFF7ED; color: #C2410C; }
.badge-info { background: #ECFDF5; color: #15803D; }
.badge-success { background: #DCFCE7; color: #15803D; }
.badge-warning { background: #FEF3C7; color: #B45309; }
.badge-danger { background: #FEE2E2; color: #DC2626; }

/* ============ MODALS ============ */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  overflow-y: auto;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 18px;
  width: 500px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2), 0 0 0 1px rgba(234, 88, 12, 0.05);
  animation: modal-appear 0.25s ease-out;
}

@keyframes modal-appear {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-sm { width: 400px; }
.modal-lg { width: 700px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(234, 88, 12, 0.1);
  position: sticky;
  top: 0;
  background: white;
  z-index: 5;
  border-radius: 18px 18px 0 0;
}

.modal-header h3 { margin: 0; font-size: 16px; }

.btn-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #64748B;
  padding: 0;
  line-height: 1;
  transition: color 0.2s;
  flex-shrink: 0;
}

.btn-close:hover { color: #EA580C; }

.modal-body { padding: 24px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid rgba(234, 88, 12, 0.1);
  position: sticky;
  bottom: 0;
  background: white;
  z-index: 5;
  flex-wrap: wrap;
}

/* ============ ALERTS ============ */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 14px;
  word-break: break-word;
}

.alert-danger { background: #FEE2E2; color: #DC2626; border: 1px solid #FECACA; }
.alert-success { background: #DCFCE7; color: #15803D; border: 1px solid #BBF7D0; }
.alert-warning { background: #FEF3C7; color: #B45309; border: 1px solid #FDE68A; }
.alert-info { background: #FFF7ED; color: #C2410C; border: 1px solid #FED7AA; }

/* ============ PERMISSIONS ============ */
.permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #FFF7ED, #F0FDF4);
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
}

.checkbox-label:hover { background: #FED7AA; }

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #EA580C;
  flex-shrink: 0;
}

/* ============ THUMBNAILS ============ */
.thumb {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 8px;
}

.thumb-sm {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
}

.preview-img {
  max-width: 200px;
  max-height: 150px;
  border-radius: 10px;
  margin-top: 8px;
}

/* ============ UTILITY CLASSES ============ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: #64748B; }
.text-danger { color: #EF4444; }
.text-info { color: #EA580C; }
.text-success { color: #16A34A; }
.bold { font-weight: 600; }
.empty-state {
  text-align: center;
  color: #94A3B8;
  padding: 40px 20px;
  font-size: 15px;
}

.hidden { display: none !important; }
.invisible { visibility: hidden; }

/* ============ FADE TRANSITIONS ============ */
.fade-in {
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-out {
  animation: fadeOut 0.3s ease-out forwards;
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ============ ACCESS CONTROL PAGE ============ */
.acces-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: rgba(255,255,255,0.9);
  border-radius: 14px;
  padding: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  border: 1px solid rgba(234, 88, 12, 0.08);
  flex-wrap: wrap;
}

.acces-tab {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  color: #64748B;
  transition: all 0.2s;
  min-width: 100px;
  text-align: center;
}

.acces-tab:hover {
  background: #FFF7ED;
  color: #EA580C;
}

.acces-tab.active {
  background: linear-gradient(135deg, #EA580C, #16A34A);
  color: white;
  box-shadow: 0 2px 8px rgba(234, 88, 12, 0.3);
}

/* Matrix table */
.acces-matrix-table {
  font-size: 12px;
}

.acces-matrix-table th.matrix-header {
  text-align: center;
  padding: 8px 6px;
  min-width: 80px;
  vertical-align: bottom;
}

.matrix-icon {
  display: block;
  font-size: 18px;
  margin-bottom: 4px;
}

.matrix-label {
  display: block;
  font-size: 10px;
  line-height: 1.2;
  white-space: nowrap;
}

.matrix-cell {
  text-align: center;
  padding: 8px 4px;
}

.matrix-check {
  font-size: 16px;
}

.admin-check {
  opacity: 0.6;
}

.admin-row {
  background: #FFF7ED;
}

.admin-row td {
  border-bottom: 2px solid #FED7AA;
}

/* Toggle switch for matrix */
.matrix-toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
}

.matrix-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.matrix-toggle-slider {
  position: absolute;
  inset: 0;
  background: #E2E8F0;
  border-radius: 20px;
  transition: all 0.3s;
}

.matrix-toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  top: 2px;
  left: 2px;
  transition: transform 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.matrix-toggle input:checked + .matrix-toggle-slider {
  background: linear-gradient(135deg, #16A34A, #4ADE80);
}

.matrix-toggle input:checked + .matrix-toggle-slider::before {
  transform: translateX(16px);
}

.sticky-col {
  position: sticky;
  left: 0;
  background: white;
  z-index: 2;
  min-width: 120px;
}

.sticky-col-2 {
  position: sticky;
  left: 120px;
  background: white;
  z-index: 2;
  min-width: 80px;
}

.admin-row .sticky-col,
.admin-row .sticky-col-2 {
  background: #FFF7ED;
}

thead .sticky-col,
thead .sticky-col-2 {
  background: linear-gradient(135deg, #FFF7ED, #F0FDF4);
  z-index: 3;
}

/* Profiles grid */
.profiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.profile-card {
  background: rgba(255,255,255,0.95);
  border-radius: 14px;
  border: 1px solid rgba(234, 88, 12, 0.08);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.profile-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(234, 88, 12, 0.1);
}

.profile-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(135deg, #FFF7ED, #F0FDF4);
  border-bottom: 1px solid rgba(234, 88, 12, 0.08);
}

.profile-card-header h3 {
  font-size: 16px;
  margin: 0;
}

.profile-desc {
  padding: 12px 20px 0;
  font-size: 13px;
  color: #64748B;
}

.profile-section {
  padding: 12px 20px;
}

.profile-section h4 {
  font-size: 13px;
  color: #475569;
  margin-bottom: 8px;
}

.profile-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.profile-tag {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}

.tag-active {
  background: #DCFCE7;
  color: #15803D;
}

.tag-inactive {
  background: #F1F5F9;
  color: #94A3B8;
  text-decoration: line-through;
}

.profile-footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(234, 88, 12, 0.08);
  background: #FAFBFC;
}

/* User access detail */
.user-acces-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}

.user-acces-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.user-acces-item:hover {
  transform: scale(1.02);
}

.acces-active {
  background: #DCFCE7;
  border-color: #86EFAC;
}

.acces-active:hover {
  background: #BBF7D0;
}

.acces-inactive {
  background: #FEE2E2;
  border-color: #FECACA;
}

.acces-inactive:hover {
  background: #FECACA;
}

.acces-icon { font-size: 20px; flex-shrink: 0; }
.acces-label { flex: 1; font-size: 13px; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.acces-status { font-size: 16px; flex-shrink: 0; }

/* ============ MATRIX 3D ============ */
.matrix3d-user-selector { margin-bottom: 20px; }
.matrix3d-user-selector > label { display: block; font-size: 13px; font-weight: 500; color: #475569; margin-bottom: 8px; }

.matrix3d-user-tabs { display: flex; flex-wrap: wrap; gap: 6px; }

.matrix3d-user-tab {
  padding: 8px 16px;
  border: 2px solid #E2E8F0;
  border-radius: 12px;
  background: white;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: #475569;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.matrix3d-user-tab:hover { border-color: #EA580C; background: #FFF7ED; }

.matrix3d-user-tab.active {
  border-color: #EA580C;
  background: linear-gradient(135deg, #EA580C, #D97706);
  color: white;
  box-shadow: 0 2px 8px rgba(234, 88, 12, 0.3);
}

.matrix3d-user-tab.active .badge { background: rgba(255,255,255,0.2); color: white; }

.matrix3d-user-tab.admin-tab { border-color: #F59E0B; background: #FFFBEB; color: #92400E; }

.matrix3d-user-tab.admin-tab.active {
  background: linear-gradient(135deg, #F59E0B, #EA580C);
  color: white;
}

.matrix3d-container { margin-top: 16px; }

.matrix3d-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.matrix3d-user-info { display: flex; align-items: center; gap: 8px; }
.matrix3d-user-name { font-size: 18px; font-weight: 600; }

.matrix3d-table { border-collapse: separate; border-spacing: 3px; }
.matrix3d-table th, .matrix3d-table td { border: none; border-bottom: none; }

.matrix3d-page-header {
  min-width: 200px;
  background: linear-gradient(135deg, #FFF7ED, #F0FDF4);
  border-radius: 8px 0 0 8px;
}

.matrix3d-action-header {
  text-align: center;
  padding: 10px 8px;
  min-width: 70px;
  background: linear-gradient(135deg, #FFF7ED, #F0FDF4);
  border-radius: 8px 8px 0 0;
}

.matrix3d-action-icon { display: block; font-size: 18px; margin-bottom: 2px; }

.matrix3d-action-label {
  display: block;
  font-size: 10px;
  line-height: 1.2;
  color: #64748B;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.matrix3d-page-cell {
  min-width: 200px;
  padding: 8px 12px;
  background: #FAFBFC;
  border-radius: 8px 0 0 8px;
}

.matrix3d-page-info { display: flex; align-items: center; gap: 8px; }
.matrix3d-page-icon { font-size: 20px; flex-shrink: 0; }
.matrix3d-page-name { font-weight: 500; font-size: 13px; flex: 1; }

.matrix3d-page-toggle {
  position: relative;
  display: inline-block;
  width: 28px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

.matrix3d-page-toggle input { opacity: 0; width: 0; height: 0; }

.matrix3d-page-toggle-dot {
  position: absolute;
  inset: 0;
  background: #E2E8F0;
  border-radius: 16px;
  transition: all 0.3s;
}

.matrix3d-page-toggle-dot::before {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: white;
  top: 2px;
  left: 2px;
  transition: transform 0.3s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.matrix3d-page-toggle input:checked + .matrix3d-page-toggle-dot {
  background: linear-gradient(135deg, #16A34A, #4ADE80);
}

.matrix3d-page-toggle input:checked + .matrix3d-page-toggle-dot::before {
  transform: translateX(12px);
}

.matrix3d-cell {
  text-align: center;
  padding: 6px;
  border-radius: 8px;
  transition: all 0.2s;
}

.matrix3d-cell-active { background: #DCFCE7; }
.matrix3d-cell-inactive { background: #FEE2E2; }
.matrix3d-cell-disabled { background: #F1F5F9; opacity: 0.5; }

.matrix3d-check { font-size: 14px; opacity: 0.6; }

.matrix3d-btn {
  width: 36px;
  height: 36px;
  border: 2px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.matrix3d-btn-on {
  background: linear-gradient(135deg, #16A34A, #4ADE80);
  color: white;
  border-color: #15803D;
}

.matrix3d-btn-on:hover {
  background: linear-gradient(135deg, #15803D, #16A34A);
  transform: scale(1.1);
}

.matrix3d-btn-off {
  background: white;
  color: #CBD5E1;
  border-color: #E2E8F0;
}

.matrix3d-btn-off:hover {
  background: #FEE2E2;
  color: #EF4444;
  border-color: #FECACA;
  transform: scale(1.1);
}

.matrix3d-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

.matrix3d-disabled-row { opacity: 0.4; }

/* ============ CUBE OVERVIEW ============ */
.cube-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.cube-user-block {
  background: rgba(255,255,255,0.95);
  border: 1px solid rgba(234, 88, 12, 0.08);
  border-radius: 14px;
  padding: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.cube-user-block:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(234, 88, 12, 0.08);
}

.cube-user-label {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cube-mini-matrix { display: flex; flex-direction: column; gap: 2px; }
.cube-header-row { display: flex; gap: 2px; margin-bottom: 2px; }
.cube-corner { width: 28px; height: 20px; flex-shrink: 0; }
.cube-action-label { width: 28px; height: 20px; display: flex; align-items: center; justify-content: center; font-size: 11px; color: #64748B; flex-shrink: 0; }
.cube-row { display: flex; gap: 2px; }
.cube-page-label { width: 28px; height: 22px; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }

.cube-cell {
  width: 28px;
  height: 22px;
  border-radius: 5px;
  flex-shrink: 0;
  transition: all 0.2s;
}

.cube-cell-on {
  background: linear-gradient(135deg, #16A34A, #4ADE80);
  box-shadow: 0 1px 3px rgba(22, 163, 74, 0.3);
}

.cube-cell-off {
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
}

/* ============ PROFILE PAGE ACTIONS ============ */
.profile-page-actions { display: flex; flex-direction: column; gap: 8px; }

.profile-page-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #FFF7ED, #F0FDF4);
  border-radius: 10px;
  flex-wrap: wrap;
}

.profile-page-name { font-size: 13px; font-weight: 500; min-width: 140px; }
.profile-action-tags { display: flex; flex-wrap: wrap; gap: 4px; }

/* ============ PROFILE PERMISSIONS EDITOR ============ */
.profile-permissions-editor { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

.profile-page-perm-row {
  background: linear-gradient(135deg, #FFF7ED, #F0FDF4);
  border-radius: 12px;
  padding: 8px 12px;
  border: 1px solid rgba(234, 88, 12, 0.08);
}

.profile-page-check { margin-bottom: 0; }

.profile-page-actions-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(234, 88, 12, 0.08);
}

.checkbox-label-sm {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.2s;
  border: 1px solid #E2E8F0;
}

.checkbox-label-sm:hover { background: #FFF7ED; border-color: #FED7AA; }

.checkbox-label-sm input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #EA580C;
  flex-shrink: 0;
}

.checkbox-label-sm.action-active { background: #DCFCE7; border-color: #86EFAC; }
.checkbox-label-sm.action-inactive { background: white; border-color: #E2E8F0; }

/* ============ USER PAGE ACTIONS DETAIL ============ */
.user-page-actions-detail { display: flex; flex-direction: column; gap: 8px; }

.user-page-detail-row {
  border-radius: 12px;
  border: 2px solid transparent;
  overflow: hidden;
  transition: all 0.2s;
}

.page-detail-active { background: #F0FDF4; border-color: #86EFAC; }
.page-detail-inactive { background: #FEF2F2; border-color: #FECACA; }

.page-detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.page-detail-header:hover { background: rgba(0,0,0,0.03); }

.page-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px 12px;
  border-top: 1px solid rgba(0,0,0,0.06);
}

/* ============ PAYMENT SECTION ============ */
.payment-section { margin-top: 12px; }

.payment-reste {
  margin-top: 8px;
  padding: 8px 12px;
  background: #FEF3C7;
  border-radius: 10px;
  font-size: 14px;
}

/* ============ PAIEMENT INFO IN COMMANDE CARD ============ */
.commande-paiement-info {
  padding: 10px 20px;
  border-bottom: 1px solid #F1F5F9;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  background: #FAFBFC;
}

.paiement-details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: #475569;
  min-width: 0;
}

/* ============ PAIEMENT MODAL ============ */
.paiement-modal-summary {
  background: linear-gradient(135deg, #FFF7ED, #F0FDF4);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  border: 1px solid rgba(234, 88, 12, 0.1);
}

.paiement-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
  gap: 8px;
}

.paiement-summary-row + .paiement-summary-row {
  border-top: 1px solid rgba(234, 88, 12, 0.08);
}

.paiement-reste-row {
  background: #FEF3C7;
  margin: 8px -16px -16px;
  padding: 10px 16px;
  border-radius: 0 0 12px 12px;
  font-size: 16px;
}

/* ============ PAYMENT PROGRESS BAR ============ */
.paiement-progress-container { margin-top: 16px; }

.paiement-progress-bar {
  display: flex;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  background: #F1F5F9;
}

.paiement-progress-fill { transition: width 0.5s ease; }
.paiement-fill-paye { background: linear-gradient(90deg, #16A34A, #4ADE80); }
.paiement-fill-partiel { background: linear-gradient(90deg, #F59E0B, #FBBF24); }
.paiement-fill-impaye { background: linear-gradient(90deg, #EF4444, #F87171); }

.paiement-progress-legend {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 12px;
  color: #64748B;
  flex-wrap: wrap;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.legend-paye { background: #16A34A; }
.legend-partiel { background: #F59E0B; }
.legend-impaye { background: #EF4444; }

/* ============ LINGE FILTERS ============ */
.linge-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.linge-filter-btn {
  background: #F1F5F9;
  color: #475569;
  border: 1px solid #E2E8F0;
}

.linge-filter-btn.active {
  background: linear-gradient(135deg, #EA580C, #D97706);
  color: white;
  border-color: transparent;
}

/* ============ MESSAGE TEMPLATES GRID ============ */
.message-templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

/* ============ NOTIFICATION INDICATOR ============ */
.notif-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
}

.notif-indicator-active { background: #DCFCE7; color: #15803D; }
.notif-indicator-inactive { background: #F1F5F9; color: #94A3B8; }
.notif-indicator-error { background: #FEE2E2; color: #DC2626; }

/* ============ TOAST NOTIFICATIONS ============ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 14px;
  background: white;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(234, 88, 12, 0.08);
  font-size: 13px;
  font-weight: 500;
  color: #1E293B;
  transform: translateX(120%);
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  border-left: 4px solid #94A3B8;
  min-width: 280px;
}

.toast-show { transform: translateX(0); opacity: 1; }
.toast-hide { transform: translateX(120%); opacity: 0; }

.toast-icon { font-size: 20px; flex-shrink: 0; }
.toast-message { flex: 1; line-height: 1.4; }

.toast-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #94A3B8;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.2s;
}

.toast-close:hover { color: #EA580C; }

.toast-success { border-left-color: #16A34A; background: linear-gradient(135deg, #ECFDF5, white); }
.toast-error { border-left-color: #EF4444; background: linear-gradient(135deg, #FEF2F2, white); }
.toast-info { border-left-color: #EA580C; background: linear-gradient(135deg, #FFF7ED, white); }
.toast-warning { border-left-color: #F59E0B; background: linear-gradient(135deg, #FFFBEB, white); }
.toast-whatsapp { border-left-color: #25D366; background: linear-gradient(135deg, #E8FFF3, white); }

/* ============ TOP BAR LOGOUT BUTTON ============ */
.btn-topbar-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #EF4444, #DC2626);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-topbar-logout:hover {
  background: linear-gradient(135deg, #DC2626, #B91C1C);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
  transform: translateY(-1px);
}

.btn-topbar-logout:active { transform: translateY(0); }

/* ============ SCROLLBAR CUSTOM ============ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #F1F5F9;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #FDBA74, #86EFAC);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #EA580C, #16A34A);
}

/* ============ SELECTION ============ */
::selection {
  background: rgba(234, 88, 12, 0.2);
  color: #1E293B;
}

/* ================================================================
   RESPONSIVE DESIGN
   ================================================================ */

/* ---- Tablet & Small Desktop (max-width: 1024px) ---- */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    width: 100%;
  }

  .btn-hamburger {
    display: block;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .config-grid {
    grid-template-columns: 1fr;
  }

  .config-grid .card[style*="grid-column"] {
    grid-column: auto !important;
  }

  .catalogue-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }

  .linge-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }

  .fidelite-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }

  .profiles-grid {
    grid-template-columns: 1fr;
  }

  .message-templates-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- Mobile (max-width: 768px) ---- */
@media (max-width: 768px) {
  /* --- Global --- */
  body {
    font-size: 13px;
  }

  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
  h3 { font-size: 16px; }
  h4 { font-size: 14px; }

  /* --- Sidebar --- */
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.active {
    display: block;
    opacity: 1;
  }

  /* --- Main Content --- */
  .main-content {
    margin-left: 0;
    width: 100%;
  }

  .btn-hamburger {
    display: block;
  }

  .content-area {
    padding: 12px;
  }

  /* --- Top Bar --- */
  .top-bar {
    padding: 10px 12px;
    gap: 8px;
  }

  .top-bar h1 {
    font-size: 14px;
    max-width: 40vw;
  }

  .top-bar-right {
    gap: 6px;
  }

  .connection-status .status-text {
    display: none;
  }

  .connection-status {
    padding: 4px 6px;
  }

  .logout-label {
    display: none;
  }

  .btn-topbar-logout {
    padding: 8px 10px;
  }

  /* --- Login Page --- */
  .login-page {
    padding: 0;
    align-items: stretch;
  }

  .login-container {
    flex-direction: column;
    max-width: 100%;
    border-radius: 0;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
  }

  .login-left {
    width: 100%;
    height: 160px;
    min-height: 160px;
    flex-shrink: 0;
  }

  .login-left-overlay {
    padding: 20px;
  }

  .login-left-overlay h1 {
    font-size: 24px;
    margin-bottom: 4px;
  }

  .login-left-overlay p {
    font-size: 13px;
  }

  .login-right {
    width: 100%;
    padding: 24px 20px;
    flex: 1;
  }

  .login-form-container h2 {
    font-size: 20px;
  }

  .login-hint {
    font-size: 11px;
  }

  /* --- Page Header --- */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 16px;
  }

  .page-header h2 {
    font-size: 18px;
  }

  .page-header .btn {
    width: 100%;
    justify-content: center;
  }

  /* --- Stats Grid --- */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
  }

  .stat-card {
    padding: 12px;
    gap: 10px;
    flex-direction: column;
    text-align: center;
  }

  .stat-icon { font-size: 28px; }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 11px; line-height: 1.3; }

  /* --- Dashboard Grid --- */
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 16px;
  }

  /* --- Cards --- */
  .card {
    padding: 16px;
    border-radius: 12px;
  }

  /* --- Hero Banner --- */
  .hero-banner {
    height: 140px;
    border-radius: 12px;
    margin-bottom: 16px;
  }

  .hero-overlay h2 { font-size: 18px; }
  .hero-overlay p { font-size: 13px; }

  /* --- Linge Grid --- */
  .linge-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }

  .linge-img { height: 140px; }
  .linge-body { padding: 12px; }
  .linge-body h3 { font-size: 15px; }
  .linge-price { font-size: 18px; }

  .linge-actions .btn {
    flex: 1;
    min-width: 0;
    justify-content: center;
  }

  .linge-filters {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .linge-filter-btn { flex-shrink: 0; }

  /* --- Catalogue Grid --- */
  .catalogue-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .catalogue-img { height: 130px; }
  .catalogue-info h3 { font-size: 15px; }
  .catalogue-price { font-size: 16px; }
  .catalogue-actions { padding: 10px 12px 14px; }

  /* --- Commandes List --- */
  .commandes-list { gap: 12px; }
  .commande-card { border-radius: 12px; }

  .commande-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 14px;
    gap: 6px;
  }

  .commande-header h3 { font-size: 14px; }

  .commande-header-right {
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }

  .commande-total { font-size: 16px; }
  .commande-client { padding: 8px 14px; }
  .commande-client p { font-size: 12px; }

  .commande-details-row {
    flex-direction: column;
    gap: 4px;
    padding: 8px 14px;
    font-size: 12px;
  }

  .commande-paiement-info {
    flex-direction: column;
    padding: 8px 14px;
    gap: 8px;
    align-items: flex-start;
  }

  .paiement-details {
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
  }

  .commande-items {
    padding: 0 8px;
  }

  .commande-items .table {
    min-width: 400px;
  }

  .commande-footer {
    flex-direction: column;
    padding: 10px 14px;
    gap: 6px;
  }

  .commande-footer .btn {
    width: 100%;
    justify-content: center;
  }

  .commande-footer .notif-indicator {
    text-align: center;
    width: 100%;
  }

  /* --- Filters --- */
  .filters {
    width: 100%;
    flex-direction: column;
    gap: 6px;
  }

  .filters .input-sm {
    width: 100%;
  }

  /* --- Fidelite Grid --- */
  .fidelite-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .fidelite-card-body { padding: 14px; gap: 12px; }
  .fidelite-qr img { width: 80px; height: 80px; }
  .fidelite-name { font-size: 16px; }
  .fidelite-code { font-size: 12px; }

  .fidelite-card-footer .btn {
    flex: 1;
    min-width: 0;
    justify-content: center;
  }

  /* --- Config Grid --- */
  .config-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .config-grid .card[style*="grid-column"] {
    grid-column: auto !important;
  }

  /* --- Forms --- */
  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .form-group {
    margin-bottom: 12px;
  }

  .input {
    padding: 10px 12px;
    font-size: 14px;
  }

  textarea.input { min-height: 80px; }

  /* --- Buttons --- */
  .btn { padding: 10px 16px; font-size: 13px; }
  .btn-lg { padding: 12px 24px; font-size: 15px; }
  .btn-sm { padding: 7px 12px; font-size: 12px; }
  .btn-xs { padding: 5px 8px; font-size: 11px; }

  /* --- Modals --- */
  .modal {
    padding: 0;
    align-items: flex-end;
  }

  .modal-content {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 16px 16px 0 0;
    animation: modal-slide-up 0.3s ease-out;
  }

  @keyframes modal-slide-up {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: translateY(0); }
  }

  .modal-sm, .modal-lg { width: 100%; }

  .modal-header {
    padding: 16px;
    border-radius: 16px 16px 0 0;
  }

  .modal-header h3 { font-size: 16px; }
  .modal-body { padding: 16px; }

  .modal-footer {
    padding: 12px 16px;
    padding-bottom: calc(12px + var(--safe-bottom));
    flex-direction: column;
  }

  .modal-footer .btn {
    width: 100%;
    justify-content: center;
  }

  /* --- Tables --- */
  .table-container {
    margin: 0 -8px;
    padding: 0 8px;
  }

  .table { min-width: 500px; }
  .table th, .table td { padding: 8px 10px; font-size: 12px; }
  .table th { font-size: 10px; }

  /* --- Recap --- */
  .recap-container { gap: 16px; }

  .recap-actions {
    flex-direction: column;
    gap: 10px;
    padding: 16px 0;
  }

  .recap-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* --- Client Association --- */
  .client-association { gap: 16px; }
  .client-found { padding: 12px; }

  /* --- QR Scanner --- */
  .qr-scanner-container { max-width: 100%; }
  .qr-frame { width: 160px; height: 160px; }

  /* --- Permissions Grid --- */
  .permissions-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .checkbox-label { padding: 10px 12px; font-size: 13px; }

  /* --- Access Control --- */
  .acces-tabs {
    flex-direction: column;
    gap: 2px;
  }

  .acces-tab {
    padding: 10px 14px;
    font-size: 13px;
    text-align: center;
    min-width: auto;
  }

  .user-acces-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .user-acces-item { padding: 12px 14px; }

  /* --- Matrix 3D --- */
  .matrix3d-user-tabs {
    flex-direction: column;
    gap: 4px;
  }

  .matrix3d-user-tab {
    width: 100%;
    justify-content: center;
  }

  .matrix3d-page-cell { min-width: 120px; }

  .matrix3d-header {
    flex-direction: column;
    align-items: flex-start;
  }

  /* --- Cube Grid --- */
  .cube-grid { grid-template-columns: 1fr; }

  /* --- Profiles Grid --- */
  .profiles-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .profile-card-header { padding: 12px 14px; }
  .profile-desc { padding: 10px 14px 0; }
  .profile-section { padding: 10px 14px; }
  .profile-footer { padding: 10px 14px; }

  /* --- Paiement Modal --- */
  .paiement-modal-summary { padding: 12px; }
  .paiement-summary-row { font-size: 13px; }

  .paiement-reste-row {
    font-size: 14px;
    margin: 8px -12px -12px;
    padding: 8px 12px;
  }

  /* --- Payment Progress --- */
  .paiement-progress-legend { flex-wrap: wrap; gap: 8px; }

  /* --- Notification Indicator --- */
  .notif-indicator { font-size: 10px; padding: 3px 8px; }

  /* --- Thumbnails --- */
  .thumb { width: 40px; height: 40px; }
  .thumb-sm { width: 30px; height: 30px; }
  .preview-img { max-width: 150px; max-height: 120px; }

  /* --- Skeleton Loading --- */
  .skeleton-card { height: 120px; }

  /* --- Panier Summary --- */
  .panier-summary {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  /* --- Divider Text --- */
  .divider-text::before, .divider-text::after { width: 25%; }

  /* --- Linge Mini Grid (Dashboard) --- */
  .linge-mini-grid { gap: 8px; }
  .linge-mini-card { padding: 6px; }
  .linge-mini-card img { width: 40px; height: 40px; }
  .linge-mini-card strong { font-size: 13px; }
  .linge-mini-card span { font-size: 11px; }

  /* --- Sidebar Footer --- */
  .sidebar-footer { padding: 12px 16px; }
  .btn-change-password, .btn-logout { font-size: 12px; padding: 8px; }

  /* --- Empty State --- */
  .empty-state { padding: 24px 16px; font-size: 14px; }

  /* --- Alerts --- */
  .alert { padding: 10px 12px; font-size: 13px; }

  /* --- Password Input --- */
  .password-input-wrapper .input { padding-right: 40px; }

  /* --- Profile Page Actions --- */
  .profile-page-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .profile-page-name { min-width: auto; }

  /* --- User Page Actions Detail --- */
  .page-detail-header { padding: 8px 10px; }
  .page-detail-actions { padding: 6px 10px 10px; }

  /* --- Broadcast Form --- */
  #broadcastForm .form-group { margin-bottom: 10px; }

  /* --- Toast --- */
  .toast-container {
    top: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
  }

  .toast { min-width: auto; }

  /* --- Message Templates --- */
  .message-templates-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- Small Mobile (max-width: 480px) ---- */
@media (max-width: 480px) {
  body { font-size: 12px; }
  .content-area { padding: 8px; }
  .top-bar { padding: 8px 10px; }

  .top-bar h1 {
    font-size: 13px;
    max-width: 35vw;
  }

  /* --- Stats Grid --- */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .stat-card {
    flex-direction: row;
    text-align: left;
    padding: 12px;
    gap: 12px;
  }

  .stat-icon { font-size: 24px; }
  .stat-value { font-size: 20px; }
  .stat-label { font-size: 11px; }

  /* --- Login --- */
  .login-left {
    height: 120px;
    min-height: 120px;
  }

  .login-left-overlay h1 { font-size: 20px; }
  .login-left-overlay p { font-size: 12px; }
  .login-right { padding: 20px 16px; }
  .login-form-container h2 { font-size: 18px; }

  /* --- Cards --- */
  .card { padding: 12px; border-radius: 10px; }

  /* --- Commande Header --- */
  .commande-header { padding: 10px 12px; }
  .commande-total { font-size: 15px; }

  /* --- Buttons --- */
  .btn { padding: 8px 14px; font-size: 12px; }
  .btn-lg { padding: 10px 20px; font-size: 14px; }

  /* --- Badges --- */
  .badge { padding: 2px 8px; font-size: 10px; }

  /* --- Fidelite --- */
  .fidelite-card-body {
    flex-direction: column;
    text-align: center;
    padding: 16px;
  }

  .fidelite-qr img { width: 100px; height: 100px; }

  /* --- Modal --- */
  .modal-header h3 { font-size: 15px; }

  /* --- Linge Card --- */
  .linge-grid {
    grid-template-columns: 1fr;
  }

  .linge-img { height: 120px; }
  .linge-body { padding: 10px; }
  .linge-price { font-size: 16px; }

  /* --- Catalogue --- */
  .catalogue-img { height: 110px; }

  /* --- Table --- */
  .table th, .table td { padding: 6px 8px; font-size: 11px; }

  /* --- Config --- */
  .config-grid { gap: 12px; }

  /* --- Paiement --- */
  .paiement-modal-summary { padding: 10px; }
  .paiement-summary-row { font-size: 12px; padding: 4px 0; }

  /* --- QR Scanner --- */
  .qr-frame { width: 140px; height: 140px; }

  /* --- Matrix Sticky Cols --- */
  .sticky-col { min-width: 90px; }
  .sticky-col-2 { left: 90px; min-width: 60px; }
}

/* ---- Extra Small (max-width: 360px) ---- */
@media (max-width: 360px) {
  .top-bar h1 {
    font-size: 12px;
    max-width: 30vw;
  }

  .stat-value { font-size: 18px; }

  .login-left {
    height: 100px;
    min-height: 100px;
  }

  .login-left-overlay h1 { font-size: 18px; }
  .content-area { padding: 6px; }
  .card { padding: 10px; }

  .btn-topbar-logout {
    padding: 6px 8px;
    font-size: 12px;
  }
}

/* ============ PRINT STYLES ============ */
@media print {
  .sidebar,
  .top-bar,
  .btn-hamburger,
  .sidebar-overlay,
  .toast-container,
  .loading-overlay,
  .modal,
  .connection-status {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
  }

  .content-area {
    padding: 0 !important;
  }

  body {
    background: white;
    font-size: 12px;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }

  .commande-card {
    break-inside: avoid;
  }
}