/* ===== Facturier - Samsung One UI 8.5 Design System ===== */

/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

/* ===== Variables CSS ===== */
:root {
  /* Samsung One UI Palette */
  --primary: #3B82F6;
  --primary-light: #60A5FA;
  --primary-dark: #2563EB;
  --accent: #22C55E;
  --accent-light: #4ADE80;
  --danger: #EF4444;
  --warning: #F59E0B;

  /* Dark Mode Colors */
  --bg-deep: #0A0E17;
  --bg-main: #0F172A;
  --bg-card: #1E293B;
  --bg-card-hover: #273548;
  --bg-elevated: #334155;
  --bg-input: #1A2332;

  /* Text Colors */
  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-accent: #60A5FA;

  /* Borders & Dividers */
  --border: rgba(148, 163, 184, 0.15);
  --border-focus: #3B82F6;
  --divider: rgba(148, 163, 184, 0.1);

  /* Effects */
  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.08);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.3);

  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Safe Areas */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ===== Light Mode ===== */
[data-theme="light"] {
  --bg-deep: #F1F5F9;
  --bg-main: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F8FAFC;
  --bg-elevated: #F1F5F9;
  --bg-input: #F8FAFC;
  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --text-accent: #2563EB;
  --border: rgba(15, 23, 42, 0.1);
  --divider: rgba(15, 23, 42, 0.06);
  --glass-bg: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(0, 0, 0, 0.08);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);
}

[data-theme="light"] body { background: var(--bg-deep); }

[data-theme="light"] .topbar {
  background: #FFFFFF;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .volet {
  background: #FFFFFF;
  border-right: 1px solid rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .volet .tab:hover { background: #F1F5F9; }

[data-theme="light"] .volet-titre { border-bottom-color: rgba(15, 23, 42, 0.06); }

[data-theme="light"] .volet-footer { border-top-color: rgba(15, 23, 42, 0.06); }

[data-theme="light"] .connexion {
  background: #F1F5F9;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(34, 197, 94, 0.06) 0%, transparent 40%);
}

[data-theme="light"] .connexion-carte {
  background: #FFFFFF;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .modal {
  background: #FFFFFF;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .modal-backdrop {
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
}

[data-theme="light"] .toast {
  background: #1E293B;
  color: #FFFFFF;
}

[data-theme="light"] .batch-toolbar {
  background: var(--bg-card);
  border: 1px solid var(--border);
}

[data-theme="light"] .filters-toolbar {
  background: var(--bg-card);
  border: 1px solid var(--border);
}

[data-theme="light"] .user-actions-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
}

[data-theme="light"] .user-radio {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

[data-theme="light"] .dash-card::before {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.25) 0%, transparent 70%);
}

[data-theme="light"] .item-card {
  background: var(--bg-card);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .user-card {
  background: var(--bg-card);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .suggestions {
  background: #FFFFFF;
  border: 1px solid rgba(15, 23, 42, 0.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .suggestions li:hover { background: #F1F5F9; }

[data-theme="light"] #messenger-fab {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

[data-theme="light"] #messenger-panel {
  background: #FFFFFF;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .messenger-header {
  background: #F8FAFC;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

[data-theme="light"] .messenger-msg.autre {
  background: #F1F5F9;
}

[data-theme="light"] .messenger-input {
  background: #F8FAFC;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
}

[data-theme="light"] .messenger-input input {
  background: #FFFFFF;
  border: 1px solid rgba(15, 23, 42, 0.1);
}


[data-theme="light"] .table th {
  background: #F8FAFC;
}

[data-theme="light"] .totaux-lignes {
  background: #F8FAFC;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .sms-cible {
  background: #F8FAFC;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

.hidden { display: none !important; }

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, select, textarea {
  font: inherit;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 15px;
  transition: all 0.2s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}

/* ===== Top Bar ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  padding-top: var(--safe-top);
  height: calc(64px + var(--safe-top));
  background: var(--bg-main);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
}

.brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.select-boutique {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  max-width: 200px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.select-boutique:hover {
  border-color: var(--primary);
}

.select-boutique option {
  background: var(--bg-card);
  color: var(--text-primary);
}

.btn-menu {
  background: transparent;
  color: var(--text-secondary);
  border: 0;
  font-size: 24px;
  line-height: 1;
  padding: 8px;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.btn-menu:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.apk-download {
  margin-left: auto;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: var(--bg-deep);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  font-size: 14px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.apk-download:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ===== Banner Update ===== */
.banniere-maj {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(217, 119, 6, 0.1));
  border-bottom: 1px solid rgba(245, 158, 11, 0.3);
  font-size: 14px;
  font-weight: 600;
  color: var(--warning);
}

/* ===== Side Menu (Volet) ===== */
.volet {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  width: 280px;
  max-width: 85vw;
  background: var(--bg-main);
  color: var(--text-primary);
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  padding: 16px;
  padding-top: calc(20px + var(--safe-top));
  border-right: 1px solid var(--border);
}

.volet.ouvert {
  transform: translateX(0);
}

.volet-titre {
  font-size: 20px;
  padding: 0 12px 20px;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.volet .tabs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.volet .tab {
  background: transparent;
  color: var(--text-secondary);
  border: 0;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  text-align: left;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
}

.volet .tab:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.volet .tab.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: var(--shadow-glow);
}

.volet .tab-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.volet-fond {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.volet-footer {
  margin-top: auto;
  border-top: 1px solid var(--divider);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.volet-footer .tab-deconnexion {
  color: var(--danger);
}

.volet-footer .tab-deconnexion:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #FCA5A5;
}

/* ===== Connection Screen ===== */
.connexion {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
  padding: 20px;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(34, 197, 94, 0.1) 0%, transparent 40%);
}

.connexion-carte {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
}

.connexion-logo {
  font-size: 28px;
  text-align: center;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.connexion-logo-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.connexion-carte h2 {
  margin: 0 0 24px;
  font-size: 24px;
  font-weight: 700;
  text-align: center;
}

.connexion-carte .form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.connexion-carte .btn {
  width: 100%;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius-md);
}

.connexion-erreur {
  color: var(--danger);
  text-align: center;
  min-height: 20px;
  margin: 12px 0 0;
  font-size: 14px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
}

.mode-serveur {
  color: var(--text-accent);
  font-size: 11px;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Main Content ===== */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
  padding-bottom: calc(80px + var(--safe-bottom));
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.toolbar h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.search {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  width: 260px;
  background: var(--bg-input);
}

/* ===== Buttons ===== */
.btn {
  padding: 12px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}

.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: none;
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn:disabled,
.btn.primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  pointer-events: none;
}

.btn.danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--danger);
}

.btn.danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn.small {
  padding: 8px 14px;
  font-size: 13px;
}

.btn.mini {
  padding: 6px 12px;
  font-size: 12px;
}

.btn.tiny {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s;
}

.btn.tiny:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.btn-warn {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--warning);
}

.btn-warn:hover {
  background: rgba(245, 158, 11, 0.25);
}

.btn-success {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.3);
  color: var(--accent);
}

.btn-success:hover {
  background: rgba(34, 197, 94, 0.25);
}

.btn-info {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--primary-light);
}

.btn-info:hover {
  background: rgba(59, 130, 246, 0.25);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* ===== Autocomplete ===== */
.client-recherche, .produit-recherche {
  position: relative;
}

.suggestions-flottante {
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
}

.suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 60;
  margin: 0;
  padding: 8px;
  list-style: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-height: 240px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.suggestions li {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s ease;
}

.suggestions li:hover, .suggestions li.active {
  background: var(--bg-card-hover);
}

.suggestions .sug-ville {
  color: var(--text-muted);
  font-size: 12px;
}

.suggestions .sug-creer {
  border-top: 1px dashed var(--divider);
  margin-top: 4px;
  color: var(--primary-light);
  font-weight: 600;
}

/* ===== Batch Toolbar ===== */
.table th.sel, .table td.sel {
  width: 40px;
  text-align: center;
  padding-left: 12px;
  padding-right: 6px;
}

.table td.sel input, .table th.sel input {
  cursor: pointer;
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.batch-toolbar {
  margin-top: 12px;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.batch-compteur {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 600;
  align-self: center;
}

.batch-actions {
  flex-wrap: wrap;
}

/* Sélection groupée des bulletins de paie : la colonne de cases réutilise
   .table th.sel / .table td.sel et la case des cartes .facture-card-check.
   Seuls les écarts avec la liste sont propres à l'onglet Paie (le résumé des
   paramètres est un .hint sans marge basse). */
#batch-toolbar-bulletins {
  margin-bottom: 12px;
}

#batch-toolbar-bulletins .batch-compteur {
  min-width: 96px;
}

/* ===== Filters ===== */
.filters-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.filter-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-date, .filter-select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  background: var(--bg-input);
}

/* Sélecteur de date de l'en-tête « Entrées du jour » (pointage atelier).
   Sur desktop il garde sa largeur naturelle, à côté du bouton Actualiser. */
#pointages-date-input {
  font-family: inherit;
  color: var(--text-primary);
}

@media (max-width: 768px) {
  #pointages-date-input {
    flex: 1 1 100%;
  }
}

.sel-boutique-user {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  min-width: 140px;
  max-width: 180px;
  background: var(--bg-input);
  color: var(--text-primary);
  cursor: pointer;
}

.sel-boutique-user:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== User Management Bar ===== */
.user-actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 16px;
}

.user-radio-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-radio-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
}

.user-radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  background: var(--bg-input);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.user-radio:hover {
  border-color: var(--primary);
}

.user-radio input[type="radio"] {
  accent-color: var(--primary);
  margin: 0;
}

.user-btn-group {
  display: flex;
  gap: 10px;
  margin-left: auto;
  flex-wrap: wrap;
}

.user-check {
  accent-color: var(--primary);
  cursor: pointer;
  width: 18px;
  height: 18px;
}

/* ===== User Cards (Mobile) ===== */
.users-mobile-view {
  padding: 0 12px;
}

.user-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin: 0 0 12px;
  border-left: 4px solid var(--primary);
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.user-card:active {
  transform: scale(0.98);
}

.user-card-moi {
  opacity: 0.7;
}

.user-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.user-check-card {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  accent-color: var(--primary);
}

.user-card-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
}

.user-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-card-nom {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-card-role {
  font-size: 13px;
  font-weight: 600;
}

.user-card-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-card-boutique {
  font-size: 13px;
  color: var(--text-secondary);
}

.user-card-date {
  font-size: 12px;
  color: var(--text-muted);
}

.user-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger, #ef4444);
  color: #fff;
  border: none;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-success {
  background: var(--success, #22c55e);
  color: #fff;
  border: none;
}

.btn-success:hover {
  background: #16a34a;
}

@media (min-width: 601px) {
  .users-mobile-view { display: none !important; }
  .mobile-cards-view { display: none !important; }
}

@media (max-width: 600px) {
  #table-utilisateurs-wrap { display: none !important; }
  #table-produits-wrap { display: none !important; }
  #table-clients-wrap { display: none !important; }
}

/* ===== Generic Item Card (Produits, Clients - mobile) ===== */
.mobile-cards-view {
  padding: 0 12px;
}

.item-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin: 0 0 10px;
  border-left: 4px solid var(--primary);
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.item-card:active {
  transform: scale(0.98);
}

.item-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.item-card-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
}

.item-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.item-card-nom {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-card-detail {
  font-size: 13px;
  color: var(--text-secondary);
}

.item-card-montant {
  font-size: 16px;
  font-weight: 800;
  color: var(--primary-light);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.item-card-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.item-card-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.item-card-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

/* ===== Filters Summary ===== */
.filters-summary {
  margin: 0 0 12px;
  padding: 12px 16px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-light);
}

/* ===== Print Page Break ===== */
.pf-saut-page { page-break-after: always; break-after: page; }
.pt-sep { border-top: 1px dashed #000; margin: 12px 0; }

/* ===== Tables ===== */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--divider);
  white-space: nowrap;
}

.table th {
  background: var(--bg-elevated);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  font-weight: 700;
}

.table tbody tr {
  transition: all 0.15s ease;
}

.table tbody tr:hover {
  background: var(--bg-card-hover);
}

.table td.num, .table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table th.actions, .table td.actions {
  text-align: right;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

/* Second niveau d'info dans une cellule (ex. période · fonction sous le nom
   du collaborateur dans la table des bulletins). */
.table .cell-sub {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 400;
}

.table .clickable {
  cursor: pointer;
}

.empty {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  margin: 0;
  font-size: 15px;
}

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge.brouillon { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge.envoyee { background: rgba(59, 130, 246, 0.15); color: var(--primary-light); }
.badge.payee { background: rgba(34, 197, 94, 0.15); color: var(--accent); }
.badge.annulee { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge.actif { background: rgba(34, 197, 94, 0.15); color: var(--accent); }
.badge.en-attente { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge.inactif { background: rgba(107, 114, 128, 0.2); color: #9ca3af; }
.badge.collab-lie { background: rgba(139, 92, 246, 0.15); color: #a78bfa; margin-left: 4px; }
/* Heure d'entrée saisie/corrigée à la main (pointage manuel) */
.badge.manuel { background: rgba(14, 165, 233, 0.15); color: #38bdf8; margin-left: 4px; }
/* Congés : type de congé (badge discret), période en cours, et statut « En congé »
   du pointage du jour (distinct d'« Absent »). */
.badge.conge { background: rgba(148, 163, 184, 0.15); color: var(--text-secondary); margin-left: 4px; }
.badge.en-conge { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }

/* Soldes de congés payés (droit malgache : 2,5 j/mois) */
.solde-positif { color: #34d399; font-weight: 600; }
.solde-nul { color: var(--text-secondary); font-weight: 600; }
.solde-negatif { color: #f87171; font-weight: 700; }
.ligne-solde-negatif { background: rgba(248, 113, 113, 0.07); }
.solde-detail { font-size: 11px; font-weight: 400; color: var(--text-muted); margin-top: 2px; }
.conge-avertissement {
  border: 1px solid rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.08);
  color: #f87171;
  padding: 8px 10px;
  border-radius: 8px;
}
.conge-avertissement strong { color: #fca5a5; }
.conge-avertissement.hidden { display: none; }

/* Rapport mensuel des congés : collaborateurs sans absence légèrement estompés */
.ligne-sans-absence { opacity: 0.6; }
#table-rapport-conges .badge { font-size: 11px; margin: 1px 2px 1px 0; display: inline-block; }
.badge.en-cours { background: rgba(245, 158, 11, 0.15); color: var(--warning); margin-left: 4px; }
.check-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary, #cbd5e1); cursor: pointer; white-space: nowrap; }
.badge.refuse { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge.credit { background: rgba(34, 197, 94, 0.15); color: var(--accent); }
.badge.approuve { background: rgba(34, 197, 94, 0.15); color: var(--accent); font-size: 11px; padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
/* Avances sur salaire : type d'avance (période en cours / mensuel). */
.badge.avance-periode { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge.avance-mensuel { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }

/* ===== Cards & Forms ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

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

.form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.form input, .form select, .form textarea {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font: inherit;
  font-weight: 400;
  color: var(--text-primary);
  background: var(--bg-input);
}

.form input[type="checkbox"] {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  accent-color: var(--primary);
  cursor: pointer;
}

/* Validation en temps réel des champs téléphone */
.form input.champ-invalide {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.champ-erreur {
  display: none;
  font-weight: 400;
  font-size: 12.5px;
  color: var(--danger);
}

.champ-erreur.visible {
  display: block;
}

/* Avertissement doublon client : pas une erreur bloquante, on utilise l'orange */
#client-doublon-msg.visible {
  display: block;
  color: var(--warning, #f59e0b);
}

.input-alerte {
  border-color: var(--warning, #f59e0b) !important;
}

.form label > .hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 13px;
}

.form textarea {
  resize: vertical;
  min-height: 80px;
}

/* Modale « WiFi atelier » : liste des SSID, chacune avec son bouton de suppression */
.atelier-ssids-titre {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.atelier-ssids-liste {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 6px 0 10px;
}

.atelier-ssids-vide {
  margin: 0;
  padding: 10px 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 13px;
}

.atelier-ssid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.atelier-ssid-nom {
  flex: 1;
  min-width: 0;
  font-weight: 500;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.atelier-ssid-suppr {
  flex: none;
  padding: 6px 10px;
  line-height: 1;
  color: var(--danger);
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.atelier-ssid-suppr:hover {
  background: rgba(239, 68, 68, 0.22);
  color: var(--danger);
}

.atelier-ssid-ajout {
  display: flex;
  gap: 8px;
}

.atelier-ssid-ajout input {
  flex: 1;
  min-width: 0; /* mobile : le champ doit pouvoir se réduire à côté du bouton */
}

.atelier-ssid-ajout .btn {
  flex: none;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid-2-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.full {
  grid-column: 1 / -1;
}

.form-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}

.hint {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
}

/* ===== Modals ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}

#modal-serveur { z-index: 3100; }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--glass-border);
}

.modal.wide { max-width: 960px; }

.modal h3 {
  margin: 0 0 20px;
  font-size: 20px;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* Modale de pointage manuel : collaborateur et date en lecture seule */
#modal-pointage input[readonly] {
  color: var(--text-secondary);
  cursor: default;
}

/* ===== Documents du collaborateur (photo d'identité, carte d'identité recto/verso) =====
   Trois emplacements dans la modale d'édition (la 2e colonne de la 2e ligne reste vide
   sur écran large) : aperçu + boutons. Un seul document par type (Envoyer/Remplacer
   écrase le précédent). */
#section-documents {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.documents-titre {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.documents-grille {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.document-bloc {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-input);
}

.document-entete {
  font-weight: 600;
  font-size: 13.5px;
}

.document-apercu {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 132px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  overflow: hidden;
}

.document-apercu img {
  display: block;
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
}

.document-vide {
  color: var(--text-muted);
  font-size: 13px;
}

.document-boutons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.document-info {
  font-size: 12.5px;
  word-break: break-word;
}

/* Petits écrans : les emplacements passent l'un sous l'autre. */
@media (max-width: 560px) {
  .documents-grille { grid-template-columns: 1fr; }
}

/* ===== Invoice Lines ===== */
.lignes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.lignes-header h4 {
  margin: 0;
}

.table.lignes input, .table.lignes select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
}

.ligne-produit { min-width: 180px; }
.ligne-desig { min-width: 220px; }
.ligne-qte { width: 90px; }
.ligne-prix { width: 120px; }
.ligne-total { width: 120px; }

/* Mobile : plus de défilement horizontal dans la saisie des lignes de facture.
   Le DOM (<table>/<tr>/<td>) et les classes restent identiques (la logique JS les
   lit par classe) : chaque ligne est simplement réorganisée en carte empilée. */
@media (max-width: 768px) {
  .modal .table-wrap {
    overflow-x: visible;
  }

  .table.lignes thead {
    display: none;
  }

  .table.lignes,
  .table.lignes tbody {
    display: block;
    width: 100%;
  }

  .table.lignes tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-items: end;
    padding: 12px;
    margin: 0 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 10px);
    background: var(--bg-soft, rgba(148, 163, 184, 0.06));
  }

  .table.lignes tbody tr:last-child {
    margin-bottom: 0;
  }

  .table.lignes td {
    display: block;
    padding: 0;
    border: 0;
    min-width: 0;
  }

  /* Produit et Désignation sur toute la largeur */
  .table.lignes td:nth-child(1),
  .table.lignes td:nth-child(2) {
    grid-column: 1 / -1;
  }

  /* Petits libellés au-dessus des champs numériques (l'en-tête du tableau est masqué) */
  .table.lignes td:nth-child(3)::before,
  .table.lignes td:nth-child(4)::before,
  .table.lignes td:nth-child(5)::before {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .table.lignes td:nth-child(3)::before { content: 'Qté'; }
  .table.lignes td:nth-child(4)::before { content: 'Prix unitaire'; }
  .table.lignes td:nth-child(5)::before { content: 'Total'; }

  .table.lignes td.ligne-total-cell {
    align-self: center;
  }

  .table.lignes td.ligne-total-cell strong {
    font-size: 15px;
    white-space: nowrap;
  }

  .table.lignes td.actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }
}

.totaux {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.totaux-lignes {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-width: 280px;
}

.tot-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.tot-row strong {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.totaux-lignes .grand {
  font-size: 18px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 6px;
  color: var(--primary-light);
  font-weight: 700;
}

/* ===== Logo ===== */
.logo-zone {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-apercu {
  max-height: 90px;
  max-width: 220px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-input);
}

/* ===== Invoice Preview ===== */
.apercu-infos {
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  font-size: 14px;
}

/* ===== Bluetooth Printers ===== */
.bt-liste {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
}

.bt-item {
  text-align: left;
  padding: 14px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.bt-item small {
  font-weight: 400;
  color: var(--text-muted);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 14px 24px;
  border-radius: var(--radius-full);
  font-weight: 600;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

/* =========================================================
   PRINT STYLES
   ========================================================= */
#print-area { display: none; }
#print-area * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

@page facture { size: A4; margin: 14mm; }
@page facture-a5 { size: A5; margin: 12mm; }
@page ticket-80 { size: 80mm auto; margin: 0; }
@page ticket-58 { size: 58mm auto; margin: 0; }

.print-facture { page: facture; font-family: Georgia, "Times New Roman", serif; color: #000; font-size: 12.5px; line-height: 1.45; }
.print-facture.a5 { page: facture-a5; font-size: 10.5px; line-height: 1.35; }
.print-facture.a5 .pf-en-tete { margin-bottom: 14px; }
.print-facture.a5 .pf-societe .pf-nom { font-size: 15px; }
.print-facture.a5 .pf-titre h1 { font-size: 19px; }
.print-facture.a5 .pf-blocs { margin-bottom: 14px; }
.print-facture.a5 .pf-cadre { padding: 7px 9px; min-height: 52px; }
.print-facture.a5 table.pf-table { margin-bottom: 12px; }
.print-facture.a5 table.pf-table td { padding: 4px 6px; }
.print-facture.a5 .pf-totaux { margin-bottom: 12px; }
.print-ticket { page: ticket-80; font-family: "Courier New", monospace; color: #000; font-size: 13.5px; line-height: 1.25; width: 72mm; margin: 0; }
/* Ticket 58 mm : page et largeur réduites, police proportionnelle (~32 colonnes). */
.print-ticket.pt-58 { page: ticket-58; width: 48mm; font-size: 10.5px; }

@media print {
  body > *:not(#print-area) { display: none !important; }
  body { background: #fff; }
  #print-area { display: block; }
}

/* --- Facture A4 --- */
.print-facture .pf-en-tete { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.print-facture .pf-logo { max-height: 70px; max-width: 220px; margin-bottom: 6px; object-fit: contain; }
.print-facture.a5 .pf-logo { max-height: 50px; max-width: 160px; }
.print-facture .pf-societe { max-width: 55%; }
.print-facture .pf-societe .pf-nom { font-size: 20px; font-weight: bold; margin-bottom: 4px; white-space: pre-line; }
.print-facture .pf-titre { text-align: right; }
.print-facture .pf-titre h1 { font-size: 26px; margin: 0 0 4px; letter-spacing: .05em; }
.print-facture .pf-infos { text-align: right; font-size: 11.5px; }
.print-facture .pf-blocs { margin-bottom: 20px; }
.print-facture .pf-cadre { border: 1px solid #000; padding: 10px 14px; min-height: 64px; }
.print-facture .pf-cadre h3 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.print-facture .pf-cadre p { margin: 0; white-space: pre-line; }
.print-facture table.pf-table { width: 100%; border-collapse: collapse; margin-bottom: 18px; }
.print-facture table.pf-table th { border-bottom: 2px solid #000; text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 6px 8px; }
.print-facture table.pf-table td { border-bottom: 1px solid #999; padding: 7px 8px; vertical-align: top; }
.print-facture table.pf-table td.num, .print-facture table.pf-table th.num { text-align: right; }
.print-facture .pf-totaux { display: flex; justify-content: flex-end; margin-bottom: 20px; }
.print-facture .pf-totaux table { border-collapse: collapse; min-width: 240px; }
.print-facture .pf-totaux td { padding: 3px 10px; }
.print-facture .pf-totaux td:first-child { color: #333; }
.print-facture .pf-totaux .pf-ttc td { font-size: 15px; font-weight: bold; border-top: 2px solid #000; padding-top: 6px; }
.print-facture .pf-mentions { font-size: 10.5px; color: #333; white-space: pre-line; text-align: center; }
.print-facture .pf-mentions:not(:empty) { margin-top: 26px; padding-top: 8px; border-top: 1px solid #999; }
.print-facture .pf-notes { margin-bottom: 14px; font-size: 12px; white-space: pre-line; }

/* --- Ticket 80mm --- */
.print-ticket { text-align: center; }
.print-ticket .pt-logo { margin-bottom: 4px; }
.print-ticket .pt-logo img { max-height: 50px; max-width: 60mm; object-fit: contain; }
.print-ticket .pt-nom { font-size: 1em; font-weight: bold; margin: 4px 0; white-space: pre-line; }
.print-ticket .pt-adresse { white-space: pre-line; margin-bottom: 2px; }
.print-ticket .pt-ligne { border-top: 1px dashed #000; margin: 6px 0; }
.print-ticket table { width: 100%; border-collapse: collapse; margin: 4px 0; }
.print-ticket td { padding: 1px 0; vertical-align: top; }
.print-ticket .pt-designation { text-align: left; word-break: break-word; }
.print-ticket .pt-detail { font-size: 1em; text-align: left; }
.print-ticket .pt-prix { text-align: right; white-space: nowrap; }
.print-ticket .pt-totaux { margin-top: 4px; }
.print-ticket .pt-totaux td { padding: 2px 0; }
.print-ticket .pt-grand td { font-weight: bold; font-size: 1.15em; border-top: 1px solid #000; padding-top: 4px; }
.print-ticket .pt-pied { white-space: pre-line; margin-top: 8px; font-size: 0.8em; }
.print-ticket .pt-numero { margin-top: 6px; font-size: 0.9em; }

/* ===== SMS ===== */
#vue-sms .card { margin-bottom: 16px; }
#vue-sms h3 { margin: 0 0 14px; font-size: 16px; }

.sms-cibles {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sms-cible {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  padding: 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.sms-cible input { margin-top: 4px; }
.sms-cible .hint { display: block; font-weight: 400; margin: 0; }

.sms-liste {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin: 12px 0;
}

.sms-liste label {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
  font-weight: 400;
}

#sms-texte { width: 100%; }

#sms-solde {
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--primary-light);
}

#sms-solde:empty { display: none; }

#sms-test-numero { width: 100%; max-width: 340px; }
#sms-test-resultat { font-weight: 600; min-height: 1.4em; }
#sms-test-resultat:empty { display: none; }
#sms-resultat { font-weight: 600; min-height: 1.4em; }
#sms-resultat:empty { display: none; }

.sms-h-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
  font-size: 14px;
}

.sms-h-item:last-child { border-bottom: 0; }

.sms-h-en-tete {
  display: flex;
  gap: 12px;
  align-items: baseline;
  flex-wrap: wrap;
}

.sms-h-statut { font-weight: 700; }
.sms-h-statut.ok { color: var(--accent); }
.sms-h-statut.erreur { color: var(--danger); }
.sms-h-noms { color: var(--primary-light); font-size: 14px; margin-top: 6px; font-weight: 600; }
.sms-h-texte { color: var(--text-secondary); margin-top: 4px; }

#sms-modele { width: 100%; }

/* Modèles de SMS - carte stylisée */
#sms-carte-modeles {
  margin-top: 12px;
}

#sms-carte-modeles label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 12px;
}

#sms-carte-modeles label input,
#sms-carte-modeles label textarea {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font: inherit;
  font-weight: 400;
  color: var(--text-primary);
  background: var(--bg-input);
  width: 100%;
  box-sizing: border-box;
}

#sms-carte-modeles label textarea {
  min-height: 60px;
  resize: vertical;
}

#sms-carte-modeles .grid-2 {
  margin-top: 4px;
}

#sms-liste-modeles {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
  border: none;
  padding: 0;
  margin: 0 0 20px;
}

.sms-m-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.sms-m-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}

.sms-m-en-tete {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.sms-m-en-tete strong {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sms-m-en-tete strong::before {
  content: '💬';
  font-size: 14px;
}

.sms-m-actions {
  display: flex;
  gap: 8px;
}

.sms-m-texte {
  color: var(--text-secondary);
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.5;
  background: var(--bg-card);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
  white-space: pre-wrap;
}

/* Séparateur visuel avant le formulaire d'ajout */
#sms-carte-modeles > label:first-of-type {
  margin-top: 8px;
}

/* Sélection clients SMS */
.sms-clients-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  font-size: 12px;
  color: var(--text-muted);
}

.sms-client-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-top: none;
  cursor: pointer;
  transition: background 0.15s;
  font-weight: 400;
}

.sms-client-item:last-child {
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.sms-client-item:hover {
  background: var(--bg-elevated);
}

.sms-client-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.sms-client-nom {
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.sms-client-tel {
  font-size: 13px;
  color: var(--text-muted);
  font-family: monospace;
}

/* Numéros personnalisés */
.sms-numero-custom {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.sms-numero-custom > label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 600;
  font-size: 13px;
}

.sms-numero-custom input {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font: inherit;
  color: var(--text-primary);
  background: var(--bg-input);
}

#sms-numeros-customs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.sms-numero-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
}

.sms-numero-remove {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

.sms-numero-remove:hover {
  color: #fff;
}

/* Badge compteur */
.sms-m-count {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

/* Compteur de caractères */
#sms-modele-compteur {
  color: var(--text-muted);
  font-size: 12px;
  display: block;
  text-align: right;
  margin-top: -8px;
}

/* ===== Dashboard ===== */
.dash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.dash-card {
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  text-align: center;
  color: white;
  box-shadow: var(--shadow-md);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.dash-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 70%);
  transform: rotate(30deg);
}

.dash-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.dash-card.card-bleu { background: linear-gradient(135deg, #1E40AF, #3B82F6); }
.dash-card.card-vert { background: linear-gradient(135deg, #15803D, #22C55E); }
.dash-card.card-orange { background: linear-gradient(135deg, #B45309, #F59E0B); }
.dash-card.card-gris { background: linear-gradient(135deg, #334155, #64748B); }
.dash-card.card-violet { background: linear-gradient(135deg, #6D28D9, #8B5CF6); }

.dash-card-icon {
  font-size: 28px;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.dash-card-val {
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  position: relative;
  z-index: 1;
}

.dash-card-label {
  font-size: 13px;
  opacity: 0.9;
  margin-top: 4px;
  position: relative;
  z-index: 1;
}

.dash-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.dash-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.dash-panel h3 {
  margin: 0 0 14px;
  font-size: 16px;
  color: var(--text-primary);
  font-weight: 700;
}

.dash-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dash-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.dash-item-val {
  font-weight: 700;
  color: var(--primary-light);
  font-variant-numeric: tabular-nums;
}

.dash-statuts {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.statut-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}

.statut-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.statut-nom {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.statut-nb {
  font-weight: 700;
  font-size: 14px;
  min-width: 24px;
  text-align: right;
  color: var(--text-primary);
}

.statut-pct {
  font-size: 13px;
  color: var(--text-secondary);
  min-width: 40px;
  text-align: right;
}

/* ===== Messenger FAB ===== */
#messenger-fab {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  z-index: 90;
  transition: all 0.3s ease;
  border: none;
}

#messenger-fab:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-lg), 0 0 30px rgba(59, 130, 246, 0.5);
}

#messenger-fab:active {
  transform: scale(0.95);
}

/* ===== Messenger Panel ===== */
#messenger-panel {
  position: fixed;
  bottom: calc(148px + var(--safe-bottom));
  right: 20px;
  width: 340px;
  height: 480px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  z-index: 91;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.messenger-header {
  padding: 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.messenger-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.messenger-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.messenger-close:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.messenger-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Messages chat */
.msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 85%;
  animation: fadeIn 0.2s ease;
}

.msg.msg-moi {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.msg.msg-moi .msg-avatar {
  background: var(--accent);
}

.msg-contenu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.msg-sender {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.msg.msg-moi .msg-sender {
  text-align: right;
  color: var(--accent-light);
}

.msg-bulle {
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 4px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
}

.msg.msg-moi .msg-bulle {
  background: var(--primary);
  color: white;
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: 4px;
}

.msg-time {
  font-size: 10px;
  color: var(--text-muted);
}

.msg.msg-moi .msg-time {
  text-align: right;
  color: var(--text-muted);
}

.messenger-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
  font-size: 14px;
}

.messenger-input {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

.messenger-input input {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-input);
}

.messenger-input button {
  padding: 10px 16px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
}

.messenger-input button:hover {
  background: var(--primary-dark);
}

/* Liste utilisateurs chat */
.messenger-liste-users {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
  background: var(--bg-card);
}

.messenger-liste-users button {
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.messenger-liste-users button:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.messenger-liste-users button.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Badge non-lus */
.messenger-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: white;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  z-index: 92;
}

/* ===== Profile Modal ===== */
#modal-profil .form {
  gap: 14px;
}


/* ===== Groupes & Permissions ===== */
.groupe-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 12px;
}
.groupe-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.groupe-titre {
  display: flex;
  align-items: center;
  gap: 10px;
}
.groupe-badge {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}
.groupe-default {
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(100, 116, 139, 0.15);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}
.groupe-actions {
  display: flex;
  gap: 6px;
}
.groupe-perms {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.perm-categorie {
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
.perm-categorie:first-child {
  border-top: none;
  padding-top: 0;
}
.perm-categorie strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}
.perm-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.perm-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}
.perm-tag small {
  font-weight: 400;
  opacity: 0.7;
}
.perm-tag.niv-write {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.3);
  color: #22c55e;
}
.perm-tag.niv-read {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.3);
  color: #3b82f6;
}
.perm-tag.niv-none {
  background: rgba(100, 116, 139, 0.12);
  border-color: rgba(100, 116, 139, 0.3);
  color: #64748b;
  text-decoration: line-through;
}
/* Modal groupe : édition granulaire */
.perm-categorie-edit {
  margin-bottom: 16px;
}
.perm-categorie-edit h4 {
  font-size: 14px;
  margin-bottom: 8px;
  padding: 6px 10px;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
}
.perm-categorie-edit h4:hover {
  background: var(--border);
}
.perm-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.perm-row:last-child {
  border-bottom: none;
}
.perm-label {
  font-size: 14px;
  font-weight: 500;
}
.perm-options {
  display: flex;
  gap: 12px;
}
.perm-radio {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  cursor: pointer;
}
.perm-radio input[type="radio"] {
  accent-color: var(--primary);
}
.user-card-groupe {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ===== Facture Mobile Card ===== */
.facture-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin: 0 0 10px;
  border-left: 4px solid var(--primary);
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.facture-card:active {
  transform: scale(0.98);
}

.facture-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.facture-card-check {
  display: flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.facture-card-check input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: #3b82f6;
}

.facture-card-num {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
}

.facture-card-client {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.facture-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.facture-card-montant {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary-light);
  font-variant-numeric: tabular-nums;
}

.facture-card-date {
  font-size: 12px;
  color: var(--text-muted);
}

/* Reste à payer - affiché en petit caractères dans la liste des factures */
.reste-a-payer {
  font-size: 12px;
  font-weight: 500;
  color: var(--warning, #f59e0b);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* =========================================================
   MOBILE RESPONSIVE
   ========================================================= */
@media (max-width: 768px) {
  .topbar {
    padding: 0 12px;
    padding-top: var(--safe-top);
  }

  .brand {
    font-size: 16px;
  }

  .topbar-user {
    display: none;
  }

  main {
    padding: 16px 12px;
    padding-bottom: calc(90px + var(--safe-bottom));
  }

  .toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .toolbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .search {
    width: 100%;
    flex: 1 1 auto;
  }

  .grid-2, .grid-2-inner {
    grid-template-columns: 1fr;
  }

  .form-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .form-footer .btn {
    width: 100%;
    justify-content: center;
  }

  .modal-backdrop {
    padding: 16px 10px;
    align-items: stretch;
  }

  .modal, .modal.wide {
    max-width: 100%;
  }

  .modal-actions .btn {
    flex: 1 1 45%;
  }

  .table th, .table td {
    padding: 10px 12px;
  }

  .totaux {
    justify-content: stretch;
  }

  .totaux-lignes {
    min-width: 0;
    width: 100%;
  }

  .dash-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .dash-card {
    padding: 16px 12px;
  }

  .dash-card-val {
    font-size: 22px;
  }

  .dash-row {
    grid-template-columns: 1fr;
  }

  /* Messenger Panel Mobile */
  #messenger-panel {
    width: calc(100vw - 20px);
    right: 10px;
    bottom: calc(100px + var(--safe-bottom));
    height: 60vh;
  }

  #messenger-fab {
    bottom: calc(90px + var(--safe-bottom));
    right: 16px;
    width: 52px;
    height: 52px;
    font-size: 22px;
  }

  .apercu-infos {
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .brand {
    font-size: 15px;
  }

  .btn.mini {
    padding: 5px 8px;
    font-size: 11px;
  }

  .modal-actions .btn {
    flex: 1 1 100%;
  }

  .lignes-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .dash-cards {
    grid-template-columns: 1fr 1fr;
  }

  .filters-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.animate-fadeIn {
  animation: fadeIn 0.3s ease;
}

.animate-slideIn {
  animation: slideIn 0.3s ease;
}

/* ===== Productions (lots de modèles) ===== */
.prod-card {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.prod-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.prod-resume {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0 16px;
}
.prod-resume-carte {
  flex: 1 1 110px;
  min-width: 100px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.prod-resume-valeur {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
}
.prod-resume-label {
  font-size: 12px;
  color: var(--text-secondary);
}
.prod-avancement {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 110px;
}
.prod-avancement-piste {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: var(--bg-elevated);
  overflow: hidden;
}
.prod-avancement-remplissage {
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
}
.prod-saisie-qte {
  width: 68px;
  margin-right: 6px;
}
.prod-collab-badge {
  display: inline-block;
  margin: 0 8px 8px 0;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* =========================================================
   PAIE - bulletins (onglet 💰 Paie)
   ========================================================= */

/* Sous-sections du formulaire Société (paramètres de paie). */
.sous-section-titre {
  margin: 26px 0 4px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 16px;
}
.sous-section-titre-2 {
  margin: 18px 0 6px;
  font-size: 14px;
  color: var(--text-secondary);
}

/* Lignes primes / retenues de la modale bulletin. */
.lignes-paie {
  margin: 14px 0 4px;
}
.lignes-paie-entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.lignes-paie-entete h4 {
  margin: 0;
  font-size: 14px;
}
.lignes-paie-liste:empty {
  display: none;
}
.ligne-paie {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.ligne-paie .ligne-libelle {
  flex: 1 1 auto;
  min-width: 0;
}
.ligne-paie .ligne-montant {
  flex: 0 0 140px;
  width: 140px;
  text-align: right;
}
.vide-lignes {
  margin: 0 0 8px;
  font-style: italic;
}

/* Badge 🔁 des lignes de prime récurrente (récurrence active, cliquable pour la gérer). */
.ligne-paie [data-gerer-recurrence] {
  flex: 0 0 auto;
  border-color: rgba(16, 185, 129, 0.5);
  color: var(--accent);
}
.ligne-paie [data-gerer-recurrence]:hover {
  background: rgba(16, 185, 129, 0.12);
}

/* Récapitulatif du net, recalculé en direct dans la modale. */
.bulletin-recap {
  margin: 16px 0 6px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elevated);
}
.bulletin-recap .recap-ligne {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  font-size: 14px;
}
.bulletin-recap .recap-total {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 16px;
  font-weight: 700;
}
.bulletin-recap .recap-alerte {
  margin-top: 6px;
  font-size: 12px;
  color: var(--danger, #c0392b);
}
.bulletin-recap .recap-provision {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  border-top: 1px dashed var(--border);
  padding-top: 6px;
}
.bulletin-recap .recap-provision strong { color: var(--text-primary); }
/* Provision sur le bulletin imprimé : sous le NET, en retrait discret. */
.print-bulletin table.pb-table tr.pb-provision td {
  font-style: italic;
  font-size: 10.5px;
  color: #333;
  border-bottom: 1px solid #000;
}

/* Résumé des paramètres de paie affiché au-dessus de la liste. */
#paie-parametres-resume {
  margin: 0 0 10px;
}

/* Éditeur du barème IRSA (paramètres société). */
#table-bareme-irsa input {
  width: 100%;
  text-align: right;
}
#table-bareme-irsa td.actions {
  white-space: nowrap;
}

/* =========================================================
   IMPRESSION - Bulletin de paie A4 et A5 — design « MushTari »
   Logo carré + nom en capitales, titre maigre à droite, cartes
   arrondies (Salarié / Congés), tableau à filets fins, montant
   en lettres, NET À PAYER en bloc arrondi, zone cachet.
   Accent institutionnel #2563eb ; fonds : gris clair only.
   Polices système : aucune dépendance réseau à l'impression.
   ========================================================= */
@page bulletin { size: A4; margin: 13mm 14mm 14mm; }
@page bulletin-a5 { size: A5; margin: 10mm 11mm 11mm; }

.print-bulletin {
  page: bulletin;
  font-family: "Plus Jakarta Sans", "Segoe UI", system-ui, Arial, sans-serif;
  color: #111827;
  font-size: 11.5px;
  line-height: 1.5;
  font-feature-settings: "tnum" 1;
}
.print-bulletin * { box-sizing: border-box; }
.print-bulletin .lbl {
  font-size: 9px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: #6b7280;
}
.print-bulletin .num { text-align: right; font-variant-numeric: tabular-nums; }

/* — En-tête : logo carré + nom, titre à droite — */
.print-bulletin .haut {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 26px; padding-bottom: 15px; border-bottom: 2px solid #111827;
}
.print-bulletin .soc { display: flex; gap: 12px; max-width: 58%; }
.print-bulletin .pb-logo {
  width: 46px; height: 46px; border-radius: 10px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: #2563eb; color: #fff; font-weight: 800; font-size: 22px;
  overflow: hidden;
}
.print-bulletin .pb-logo img { width: 100%; height: 100%; object-fit: contain; }
.print-bulletin .soc-nom {
  font-size: 16.5px; font-weight: 800; letter-spacing: .01em;
  line-height: 1.15; text-transform: uppercase;
}
.print-bulletin .soc-adr { font-size: 9.5px; color: #4b5563; line-height: 1.55; margin-top: 4px; }
.print-bulletin .titre { text-align: right; }
.print-bulletin .titre h1 {
  font-size: 23px; font-weight: 800; letter-spacing: .01em;
  margin: 0 0 2px; text-transform: uppercase;
}
.print-bulletin .titre .ref {
  font-size: 12.5px; font-weight: 800; color: #2563eb; margin-bottom: 10px;
}
.print-bulletin .infos { font-size: 9.5px; line-height: 1.75; }
.print-bulletin .infos .l { color: #6b7280; }
.print-bulletin .infos .v { font-weight: 600; }

/* — Cartes Salarié / Congés — */
.print-bulletin .cartes {
  display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin: 17px 0;
}
.print-bulletin .carte {
  border: 1px solid #e5e7eb; border-radius: 10px; padding: 11px 14px; min-height: 98px;
}
.print-bulletin .carte .lbl { display: block; margin-bottom: 8px; }
.print-bulletin .carte .nom { font-size: 13.5px; font-weight: 800; margin-bottom: 3px; }
.print-bulletin .carte .det { font-size: 10px; color: #4b5563; line-height: 1.6; }
.print-bulletin .carte.accent { background: #eef2ff; border-color: #c7d2fe; }
.print-bulletin .conges { display: flex; gap: 12px; }
.print-bulletin .conges .c { flex: 1; }
.print-bulletin .conges .n { font-size: 14px; font-weight: 800; line-height: 1.1; }
.print-bulletin .conges .n small { font-size: 8px; font-weight: 700; }
.print-bulletin .conges .t {
  font-size: 7.5px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: #6b7280; margin-top: 3px;
}
.print-bulletin .situation { font-size: 8.5px; color: #6b7280; margin-top: 8px; }

/* — Tableau des éléments : en-tête grisé, filets fins — */
.print-bulletin table.elem { width: 100%; border-collapse: collapse; margin-bottom: 15px; }
.print-bulletin table.elem thead th {
  background: #f3f4f6; font-size: 9px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: #374151; text-align: left; padding: 8px 12px;
}
.print-bulletin table.elem thead th.num { text-align: right; }
.print-bulletin table.elem tbody td { padding: 8px 12px; border-top: 1px solid #e5e7eb; font-size: 11px; }
.print-bulletin table.elem tbody td.num { text-align: right; }
.print-bulletin table.elem tr.sous td { font-weight: 800; border-top: 1px solid #111827; }

/* — Bas : montant en lettres + totaux + NET — */
.print-bulletin .bas {
  display: grid; grid-template-columns: 1.15fr 1fr; gap: 24px;
  align-items: start; margin-bottom: 12px;
}
.print-bulletin .bas > div { min-width: 0; overflow-wrap: break-word; }
.print-bulletin .lettres .t {
  font-size: 9px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: #6b7280; margin-bottom: 6px;
}
.print-bulletin .lettres .mot {
  font-size: 11.5px; font-weight: 700; border-bottom: 1px dotted #9ca3af; padding-bottom: 5px;
}
.print-bulletin .pb-note-libre { font-size: 9.5px; color: #4b5563; font-style: italic; margin-top: 8px; }
.print-bulletin .totaux { display: block; font-size: 11px; }
.print-bulletin .totaux .lig { display: flex; justify-content: space-between; padding: 2.5px 0; color: #374151; }
.print-bulletin .totaux .lig .v { font-weight: 600; color: #111827; }
.print-bulletin .net {
  display: flex; justify-content: space-between; align-items: center;
  border-radius: 10px; padding: 12px 17px; margin-top: 11px;
  background: #f3f4f6; border: 1px solid #e5e7eb;
}
.print-bulletin .net .l {
  font-size: 9.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
}
.print-bulletin .net .v { font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.print-bulletin .provision {
  font-size: 8.5px; color: #6b7280; text-align: right; margin: 2px 2px 0;
}

/* — Signatures + zone cachet + pied — */
.print-bulletin .sign {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 30px; margin-top: 28px;
}
.print-bulletin .sign .z { flex: 1; }
.print-bulletin .sign .z .t {
  font-size: 8.5px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: #6b7280;
}
.print-bulletin .sign .z .l { margin-top: 30px; border-top: 1px solid #9ca3af; }
.print-bulletin .caisse {
  width: 140px; height: 68px; border: 1.5px dashed #cbd5e1; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 8.5px; letter-spacing: .16em; text-transform: uppercase; color: #94a3b8;
}
.print-bulletin .pied {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 20px; margin-top: 24px; padding-top: 11px; border-top: 1px solid #e5e7eb;
}
.print-bulletin .pied .merci {
  font-size: 10px; font-weight: 700; color: #2563eb;
  border-left: 3px solid #2563eb; padding-left: 9px; line-height: 1.2;
}
.print-bulletin .pied .soc2 {
  font-size: 8px; color: #6b7280; text-align: right; line-height: 1.55;
}

/* — Variante A5 : même grille, échelle compacte — */
.print-bulletin.a5 { page: bulletin-a5; font-size: 9.5px; line-height: 1.4; }
.print-bulletin.a5 .pb-logo { width: 34px; height: 34px; border-radius: 8px; font-size: 15px; }
.print-bulletin.a5 .soc-nom { font-size: 12px; }
.print-bulletin.a5 .soc-adr { font-size: 7.5px; }
.print-bulletin.a5 .titre h1 { font-size: 17px; }
.print-bulletin.a5 .titre .ref { font-size: 10.5px; margin-bottom: 7px; }
.print-bulletin.a5 .infos { font-size: 7.8px; }
.print-bulletin.a5 .lbl { font-size: 7.2px; }
.print-bulletin.a5 .cartes { gap: 11px; margin: 13px 0; }
.print-bulletin.a5 .carte { padding: 8px 11px; min-height: 72px; border-radius: 8px; }
.print-bulletin.a5 .carte .nom { font-size: 10.5px; }
.print-bulletin.a5 .carte .det { font-size: 8px; }
.print-bulletin.a5 .conges { gap: 9px; }
.print-bulletin.a5 .conges .n { font-size: 10.5px; }
.print-bulletin.a5 .conges .n small { font-size: 6.5px; }
.print-bulletin.a5 .conges .t { font-size: 6px; }
.print-bulletin.a5 .situation { font-size: 6.8px; margin-top: 6px; }
.print-bulletin.a5 table.elem { margin-bottom: 11px; }
.print-bulletin.a5 table.elem thead th { font-size: 7px; padding: 6px 9px; }
.print-bulletin.a5 table.elem tbody td { font-size: 8.8px; padding: 6px 9px; }
.print-bulletin.a5 .bas { gap: 16px; margin-bottom: 9px; }
.print-bulletin.a5 .lettres .t { font-size: 7px; }
.print-bulletin.a5 .lettres .mot { font-size: 9px; }
.print-bulletin.a5 .pb-note-libre { font-size: 7.8px; }
.print-bulletin.a5 .totaux { font-size: 8.8px; }
.print-bulletin.a5 .net { padding: 9px 13px; border-radius: 8px; margin-top: 8px; }
.print-bulletin.a5 .net .l { font-size: 7.5px; }
.print-bulletin.a5 .net .v { font-size: 15px; }
.print-bulletin.a5 .provision { font-size: 6.8px; }
.print-bulletin.a5 .sign { margin-top: 18px; gap: 18px; }
.print-bulletin.a5 .sign .z .t { font-size: 6.8px; }
.print-bulletin.a5 .sign .z .l { margin-top: 20px; }
.print-bulletin.a5 .caisse { width: 100px; height: 50px; border-radius: 8px; font-size: 6.8px; }
.print-bulletin.a5 .pied { margin-top: 16px; padding-top: 8px; }
.print-bulletin.a5 .pied .merci { font-size: 8px; }
.print-bulletin.a5 .pied .soc2 { font-size: 6.5px; }

/* =========================================================
   IMPRESSION - État nominatif avec émargement (A4 PAYSAGE)
   Le bulletin de paie reste en portrait (@page bulletin).
   ========================================================= */
@page etat-nominatif { size: A4 landscape; margin: 10mm; }

.print-etat-nominatif {
  page: etat-nominatif;
  font-family: Georgia, "Times New Roman", serif;
  color: #000;
  font-size: 9px;
  line-height: 1.35;
}
.print-etat-nominatif .pen-en-tete {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 12px;
}
.print-etat-nominatif .pen-societe { max-width: 55%; }
.print-etat-nominatif .pen-societe > div { white-space: pre-line; }
.print-etat-nominatif .pen-logo { max-height: 52px; max-width: 170px; margin-bottom: 4px; object-fit: contain; }
.print-etat-nominatif .pen-societe-nom { font-size: 15px; font-weight: bold; margin-bottom: 3px; white-space: pre-line; }
.print-etat-nominatif .pen-titre { text-align: right; }
.print-etat-nominatif .pen-titre h1 { font-size: 16px; margin: 0 0 4px; letter-spacing: .05em; }
.print-etat-nominatif .pen-infos { text-align: right; font-size: 9.5px; }

/* Tableau compact : 12 colonnes, largeurs fixes pour tenir dans la page paysage. */
.print-etat-nominatif table.pen-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.print-etat-nominatif table.pen-table th,
.print-etat-nominatif table.pen-table td {
  border: 1px solid #000;
  padding: 3px 4px;
  vertical-align: middle;
  overflow-wrap: break-word;
}
.print-etat-nominatif table.pen-table th {
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: .03em;
  text-align: left;
  background: #eee;
}
.print-etat-nominatif table.pen-table th.num,
.print-etat-nominatif table.pen-table td.num { text-align: right; white-space: nowrap; }
.print-etat-nominatif table.pen-table th.pen-rang,
.print-etat-nominatif table.pen-table td.pen-rang { width: 3%; text-align: center; }
.print-etat-nominatif table.pen-table th.pen-nom,
.print-etat-nominatif table.pen-table td.pen-nom { width: 13%; font-weight: bold; }
.print-etat-nominatif table.pen-table th.pen-fonction,
.print-etat-nominatif table.pen-table td.pen-fonction { width: 10%; }
/* Colonne de signature : largeur confortable pour émarger à la main. */
.print-etat-nominatif table.pen-table th.pen-emargement,
.print-etat-nominatif table.pen-table td.pen-emargement { width: 15%; }
/* Hauteur des lignes : de la place pour signer au stylo. */
.print-etat-nominatif table.pen-table tbody td { height: 24px; }
.print-etat-nominatif table.pen-table td.pen-net { font-weight: bold; }
.print-etat-nominatif table.pen-table tfoot td { font-weight: bold; border-top: 2px solid #000; }
.print-etat-nominatif table.pen-table tfoot td.pen-totaux { text-align: right; font-style: italic; }
.print-etat-nominatif .pen-pied {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 10px;
  font-size: 10px;
}

/* ===== Journal des modifications de factures (aperçu) ===== */
.journal-modifs {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  font-size: 13px;
}
.journal-modifs summary {
  cursor: pointer;
  padding: 10px 14px;
  font-weight: 600;
  color: var(--text-primary, inherit);
  user-select: none;
}
.journal-modifs[open] summary {
  border-bottom: 1px solid var(--border);
}
.journal-modifs > ul {
  margin: 0;
  padding: 8px 14px 10px 30px;
}
.journal-modifs li {
  margin: 8px 0;
}
.journal-modifs li ul {
  margin: 4px 0 0;
  padding-left: 18px;
  color: var(--text-secondary);
  font-size: 12.5px;
}

/* ===== Stock produits ===== */
.badge-stock {
  display: inline-block;
  min-width: 34px;
  text-align: center;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(34, 197, 94, 0.15);
  color: var(--accent);
  font-weight: 700;
  font-size: 12.5px;
}
.badge-stock.stock-bas {
  background: rgba(239, 68, 68, 0.18);
  color: var(--danger);
}

/* ===== Tableau utilisateurs : tout voir sans perdre les actions ===== */
.table-wrap {
  overflow-x: auto;
}
#table-utilisateurs th,
#table-utilisateurs td {
  padding: 10px 10px;
}
#table-utilisateurs .sel-groupe-user,
#table-utilisateurs .sel-boutique-user,
#table-utilisateurs .sel-collaborateur-user {
  min-width: 118px;
  max-width: 150px;
  font-size: 12.5px;
  padding: 7px 8px;
}
#table-utilisateurs th.actions,
#table-utilisateurs td.actions {
  position: sticky;
  right: 0;
  background: var(--bg-card);
  box-shadow: -10px 0 14px -10px rgba(0, 0, 0, 0.55);
  z-index: 2;
}
#table-utilisateurs thead th.actions {
  z-index: 3;
  background: var(--bg-card);
}

/* ===== Listes SMS : scrollbar discrète, contenue dans la carte ===== */
#sms-liste-modeles,
.sms-liste {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  padding-right: 8px;
}
#sms-liste-modeles::-webkit-scrollbar,
.sms-liste::-webkit-scrollbar {
  width: 8px;
}
#sms-liste-modeles::-webkit-scrollbar-track,
.sms-liste::-webkit-scrollbar-track {
  background: transparent;
}
#sms-liste-modeles::-webkit-scrollbar-thumb,
.sms-liste::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 8px;
}
#sms-liste-modeles::-webkit-scrollbar-thumb:hover,
.sms-liste::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}
#sms-liste-modeles .sms-m-item:last-child,
.sms-liste .sms-m-item:last-child {
  margin-bottom: 6px;
}

/* ===== Scrollbars fines sur les zones de défilement internes ===== */
.suggestions,
.messenger-body,
.modal-backdrop {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.suggestions::-webkit-scrollbar,
.messenger-body::-webkit-scrollbar,
.modal-backdrop::-webkit-scrollbar {
  width: 8px;
}
.suggestions::-webkit-scrollbar-track,
.messenger-body::-webkit-scrollbar-track,
.modal-backdrop::-webkit-scrollbar-track {
  background: transparent;
}
.suggestions::-webkit-scrollbar-thumb,
.messenger-body::-webkit-scrollbar-thumb,
.modal-backdrop::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 8px;
}
.suggestions::-webkit-scrollbar-thumb:hover,
.messenger-body::-webkit-scrollbar-thumb:hover,
.modal-backdrop::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}
/* Suggestions : léger retrait pour que le pouce ne touche pas le texte */
.suggestions {
  padding-right: 6px;
}
