/* ==========================================================================
   MAROC COMPTA PRO 2026 — Feuille de Style Maître (Design System Fintech)
   Conçu pour la clarté, l'élégance, la haute lisibilité et l'impression légale
   ========================================================================== */

:root {
  --primary: #c1121f;         /* Rouge Plan Comptable Marocain Foucher */
  --primary-hover: #991b1b;
  --primary-deep: #7f1d1d;
  --primary-light: #fef2f2;
  --primary-border: #fecaca;
  --primary-glow: rgba(193, 18, 31, 0.28);
  
  --secondary: #180507;       /* Noir Crimson profond du dos du livre */
  --secondary-light: #2b080d;
  
  --accent: #d97706;          /* Ambre doré */
  --accent-light: #fffbeb;
  
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --success: #10b981;
  --info: #2563eb;
  --info-light: #eff6ff;
  
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #0b132b;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --text-white: #ffffff;
  
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --sidebar-width: 270px;
  --header-height: 70px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base & Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* Layout */
#app-container {
  display: flex;
  width: 100%;
  min-height: 100vh;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  color: var(--text-white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  box-shadow: 4px 0 10px rgba(0, 0, 0, 0.15);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.28s ease;
}

.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary) 0%, #7f1d1d 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  color: white;
  box-shadow: 0 4px 10px rgba(193, 18, 31, 0.4);
}

.brand-info h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: white;
  margin: 0;
}

.brand-badge {
  display: inline-block;
  background: rgba(193, 18, 31, 0.15);
  color: #fca5a5;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  margin-top: 2px;
  letter-spacing: 0.5px;
}

.sidebar-menu {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  list-style: none;
}

.menu-section {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-light);
  letter-spacing: 0.8px;
  padding: 12px 12px 6px;
  font-weight: 600;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: #cbd5e1;
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 13.5px;
  cursor: pointer;
  margin-bottom: 2px;
  transition: var(--transition);
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.menu-item.active {
  background: var(--primary);
  color: white;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(193, 18, 31, 0.35);
}

.menu-item svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  opacity: 0.9;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
}

.company-mini-card {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.company-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.btn-sidebar-logout {
  width: 100%;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: rgba(220, 38, 38, 0.18);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fca5a5;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-sidebar-logout:hover {
  background: #c1121f;
  color: #ffffff;
  border-color: #ef4444;
  box-shadow: 0 4px 12px rgba(193, 18, 31, 0.35);
  transform: translateY(-1px);
}

/* Main Content Area */
.main-wrapper {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  max-width: calc(100% - var(--sidebar-width));
  flex: 1 1 auto;
  min-width: 0; /* Ensures flex child contents don't push layout off-screen */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.28s cubic-bezier(0.4, 0, 0.2, 1), width 0.28s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sidebar Toggle & Collapse Buttons */
.btn-sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: #f8fafc;
  border: 1px solid var(--border-color);
  color: var(--secondary);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

.btn-sidebar-toggle:hover {
  background: #e2e8f0;
  color: var(--primary);
  border-color: #cbd5e1;
  transform: scale(1.05);
}

.btn-sidebar-toggle:active {
  transform: scale(0.95);
}

.btn-sidebar-collapse {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-sidebar-collapse:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

/* Sidebar Collapsed State (Desktop) */
body.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
  box-shadow: none;
}

body.sidebar-collapsed .main-wrapper {
  margin-left: 0;
  width: 100%;
  max-width: 100%;
}

body.sidebar-collapsed .btn-sidebar-toggle {
  background: #fef2f2;
  border-color: #fecaca;
  color: #c1121f;
}

/* Mobile backdrop overlay */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  z-index: 95;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* ==========================================================================
   TOP HEADER — ARCHITECTURE 2-TIER COMPLÈTE & ÉPURÉE (ONGLETS 100% VISIBLES)
   ========================================================================== */
.top-header {
  height: auto;
  min-height: 104px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 90;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

/* Ligne Supérieure : Titre & Actions Globales */
.header-top-row {
  height: 56px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
  gap: 16px;
}

.header-top-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.page-title-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.page-title-box h2 {
  font-size: 17px;
  font-weight: 800;
  color: var(--secondary);
  line-height: 1.2;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-title-box p {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.2;
  margin: 2px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-top-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.header-btn-group {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.btn-header-link {
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 10px;
  border: 1px solid transparent;
  background: transparent;
  color: #475569;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
  text-decoration: none;
  cursor: pointer;
}

.btn-header-link:hover {
  background: #ffffff;
  color: var(--primary);
  border-color: #fecaca;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.btn-header-logout {
  background: rgba(220, 38, 38, 0.08) !important;
  border: 1px solid rgba(239, 68, 68, 0.25) !important;
  color: #dc2626 !important;
  font-weight: 700 !important;
}

.btn-header-logout:hover {
  background: #dc2626 !important;
  color: #ffffff !important;
  border-color: #dc2626 !important;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3) !important;
}

.btn-header-cta {
  background: linear-gradient(135deg, #c1121f 0%, #991b1b 100%);
  color: white;
  border: none;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  box-shadow: 0 3px 10px rgba(193, 18, 31, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-header-cta:hover {
  background: linear-gradient(135deg, #991b1b 0%, #7f1d1d 100%);
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(193, 18, 31, 0.4);
}

/* Ligne Inférieure : Bandeau des Onglets & Filtres de Contexte */
.header-tabs-bar {
  min-height: 44px;
  padding: 4px 24px;
  background: #fbfcfe;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

.header-tabs-bar::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.header-tabs-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.header-context-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  padding: 5px 12px;
  border-radius: 9999px;
  font-size: 12.5px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
  transition: all 0.2s ease;
  user-select: none;
}

.active-dossier-tab {
  background: #fff5f5;
  border-color: #fecaca;
  cursor: pointer;
}

.active-dossier-tab:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(193, 18, 31, 0.12);
}

.context-tab-icon {
  font-size: 14px;
  line-height: 1;
}

.context-tab-content {
  display: flex;
  align-items: center;
  gap: 5px;
}

.context-tab-label {
  color: #64748b;
  font-size: 11.5px;
  font-weight: 600;
}

.context-tab-value {
  color: #0f172a;
  font-size: 12.5px;
  font-weight: 700;
  max-width: 380px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.context-tab-badge {
  background: #c1121f;
  color: white;
  font-size: 10.5px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 10px;
  letter-spacing: 0.3px;
}

.context-tab-arrow {
  color: #991b1b;
  font-size: 10px;
  font-weight: 700;
}

.year-tab {
  padding: 4px 10px;
}

.year-tab .year-selector-select {
  font-size: 12.5px;
  font-weight: 700;
  color: #0f172a;
  border: none;
  background: transparent;
  outline: none;
  cursor: pointer;
}

.status-tab {
  padding: 4px 10px;
  background: #f8fafc;
}

.status-tab .status-chip {
  padding: 2px 8px;
  font-size: 11px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: #f1f5f9;
  color: #475569;
}

.status-chip.provisoire {
  background: #fef3c7;
  color: #92400e;
}

.status-chip.verifie {
  background: #d1fae5;
  color: #065f46;
}

/* Onglets Horizontaux de Navigation Rapide */
.header-tabs-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.header-nav-tab {
  border: none;
  background: transparent;
  padding: 5px 11px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.header-nav-tab:hover {
  background: rgba(255, 255, 255, 0.7);
  color: #0f172a;
}

.header-nav-tab.active {
  background: #c1121f;
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(193, 18, 31, 0.3);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 14px rgba(193, 18, 31, 0.35);
}

.btn-secondary {
  background: #f1f5f9;
  color: #334155;
  border-color: #e2e8f0;
}
.btn-secondary:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover {
  background: #b91c1c;
}

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
}

/* Page Views */
.view-content {
  padding: 24px 28px 60px;
  flex: 1;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.hidden-view {
  display: none !important;
}

/* Grid & Cards */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.card-clickable {
  cursor: pointer;
}
.card-clickable:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

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

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-icon.green { background: #d1fae5; color: #059669; }
.card-icon.blue { background: #dbeafe; color: #2563eb; }
.card-icon.amber { background: #fef3c7; color: #d97706; }
.card-icon.red { background: #fee2e2; color: #dc2626; }
.card-icon.purple { background: #f3e8ff; color: #7e22ce; }

.card-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--secondary);
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.card-subtext {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Charts Section */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.chart-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--secondary);
}

.chart-canvas-container {
  position: relative;
  height: 280px;
  width: 100%;
}

/* Tables */
.table-responsive {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13.5px;
}

.data-table th {
  background: #f8fafc;
  padding: 12px 16px;
  font-weight: 700;
  color: #475569;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: #f8fafc;
}

.text-right { text-align: right; }
.text-center { text-align: center; }

.font-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0f2fe; color: #075985; }
.badge-purple { background: #f3e8ff; color: #6b21a8; }

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.form-group label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-main);
  background: white;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.form-help {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Pedagogical Assistant Box */
.pedagogy-tip {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-left: 4px solid var(--info);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.pedagogy-tip.green {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border-left-color: var(--primary);
}

.pedagogy-tip.amber {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-left-color: var(--warning);
}

.pedagogy-tip-icon {
  font-size: 22px;
  line-height: 1;
}

.pedagogy-tip-content h4 {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 3px;
}

.pedagogy-tip-content p {
  font-size: 12.5px;
  color: #334155;
  line-height: 1.45;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(11, 19, 43, 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-dialog,
.modal-card {
  background: #ffffff !important;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 650px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.28), 0 8px 16px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(203, 213, 225, 0.8);
  animation: modalSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  position: relative;
}

.modal-dialog.lg,
.modal-card.lg {
  max-width: 900px;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--secondary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  background: #ffffff;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: #f8fafc;
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  background: var(--secondary);
  color: white;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  max-width: 450px;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.success { background: #065f46; border-left: 5px solid #10b981; }
.toast.danger { background: #991b1b; border-left: 5px solid #ef4444; }
.toast.warning { background: #92400e; border-left: 5px solid #f59e0b; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Official Moroccan Printable Invoice Styling */
.printable-invoice {
  background: white;
  padding: 40px;
  max-width: 800px;
  margin: 0 auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.invoice-header-legal {
  display: flex;
  justify-content: space-between;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 20px;
  margin-bottom: 24px;
}

.invoice-legal-box {
  font-size: 12px;
  color: #475569;
  line-height: 1.6;
}

.invoice-number-title {
  text-align: right;
}

.invoice-number-title h2 {
  font-size: 26px;
  color: var(--secondary);
  margin-bottom: 4px;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 30px rgba(0, 0, 0, 0.45);
  }
  .main-wrapper {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .top-header {
    padding: 0 16px;
    gap: 12px;
  }
  .view-content {
    padding: 16px;
  }
}

/* Print Styles */
@media print {
  .sidebar, .top-header, .btn, .no-print, #chatbot-float-btn, #chatbot-drawer {
    display: none !important;
  }
  .main-wrapper {
    margin-left: 0 !important;
  }
  .view-content {
    padding: 0 !important;
  }
  .card, .table-responsive, .printable-invoice {
    border: none !important;
    box-shadow: none !important;
  }
}

/* ==========================================================================
   OCR & DOCUMENT UPLOAD ZONE
   ========================================================================== */
.ocr-dropzone {
  border: 2px dashed #94a3b8;
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  margin-bottom: 20px;
}

.ocr-dropzone:hover, .ocr-dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.ocr-dropzone-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.ocr-dropzone-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 4px;
}

.ocr-dropzone-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.ocr-preview-container {
  display: flex;
  align-items: center;
  gap: 16px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.ocr-preview-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.ocr-progress-bar-bg {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 8px;
}

.ocr-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, #10b981 100%);
  width: 0%;
  transition: width 0.3s ease;
}

/* ==========================================================================
   YEAR SELECTOR (15-YEAR FISCAL RANGE)
   ========================================================================== */
.year-selector-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--secondary);
  box-shadow: var(--shadow-sm);
}

.year-selector-select {
  border: none;
  background: transparent;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--secondary);
  cursor: pointer;
  outline: none;
  font-family: inherit;
}

/* ==========================================================================
   RAG AI CHATBOT WIDGET & DRAWER
   ========================================================================== */
#chatbot-float-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #0b132b 0%, #059669 100%);
  color: white;
  box-shadow: 0 10px 25px -3px rgba(5, 150, 105, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  z-index: 250;
  border: 2px solid rgba(255, 255, 255, 0.2);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#chatbot-float-btn:hover {
  transform: scale(1.08);
}

#chatbot-drawer {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 440px;
  height: 620px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 120px);
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 35px -5px rgba(0, 0, 0, 0.2), 0 10px 15px -5px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 250;
  overflow: hidden;
  transition: width 0.25s ease, height 0.25s ease;
  animation: modalSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

#chatbot-drawer.expanded {
  width: 820px;
  height: 82vh;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 60px);
  bottom: 40px;
  right: 30px;
}

.chatbot-header {
  background: var(--secondary);
  color: white;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--primary);
}

.chatbot-title-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chatbot-status-indicator {
  width: 9px;
  height: 9px;
  border-radius: var(--radius-full);
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.chatbot-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chatbot-tool-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: white;
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition);
}

.chatbot-tool-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

.chatbot-nav-tabs {
  display: flex;
  background: #0f172a;
  padding: 0 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chatbot-tab-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 11.5px;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  display: flex;
  align-items: center;
}

.chatbot-tab-btn:hover {
  color: white;
}

.chatbot-tab-btn.active {
  color: white;
  border-bottom-color: var(--primary);
  font-weight: 700;
}

.chatbot-tab-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.rag-memory-container {
  padding: 14px;
  overflow-y: auto;
  flex: 1;
  background: #f8fafc;
}

.rag-memory-banner {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 12px;
}

.rag-knowledge-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.rag-source-tag {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: #475569;
  padding: 6px 10px;
  margin-top: 10px;
  display: block;
  line-height: 1.4;
}

.chatbot-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
}

.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.chat-bubble.bot {
  align-self: flex-start;
  background: white;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 3px;
  box-shadow: var(--shadow-sm);
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 3px;
}

.chat-quick-suggestions {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 12px;
  background: white;
  border-top: 1px solid var(--border-color);
}

.quick-chip {
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  background: #f1f5f9;
  border-radius: var(--radius-full);
  color: #334155;
  cursor: pointer;
  border: 1px solid #e2e8f0;
  transition: var(--transition);
}

.quick-chip:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.chatbot-footer {
  padding: 12px;
  background: white;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
  align-items: center;
}

.chatbot-input {
  flex: 1;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 10px 16px;
  font-size: 13.5px;
  outline: none;
  font-family: inherit;
}

.chatbot-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.chatbot-send-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.chatbot-send-btn:hover {
  background: var(--primary-hover);
}

/* ==================== STYLES RISQUE DÉLAIS DE PAIEMENT (LOI 69-21) ==================== */
.risk-card-banner {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.risk-card-banner.danger {
  background: #fef2f2;
  border: 1px solid #fee2e2;
  color: #991b1b;
}

.risk-card-banner.success {
  background: #ecfdf5;
  border: 1px solid #d1fae5;
  color: #065f46;
}

.risk-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.risk-stat-item {
  background: #f8fafc;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  text-align: center;
}

.risk-stat-val {
  font-size: 20px;
  font-weight: 800;
  color: var(--secondary);
}

.risk-stat-val.danger {
  color: var(--danger);
}

.risk-stat-label {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.badge-risk-overdue {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  font-weight: 700;
}

.badge-risk-warning {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
  font-weight: 700;
}

.badge-risk-info {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  font-weight: 600;
}

/* ==========================================================================
   PLAN COMPTABLE MAROCAIN (CGNC GUIDE)
   ========================================================================== */
.btn-tab-pill {
  transition: all 0.2s ease-in-out;
}
.btn-tab-pill:hover {
  filter: brightness(0.96);
  transform: translateY(-1px);
}
.cgnc-account-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
  transition: all 0.2s ease-in-out;
  display: flex;
  flex-direction: column;
}
.cgnc-account-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 6px 16px rgba(0,0,0,0.06);
  transform: translateY(-2px);
}
.cgnc-schema-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px;
  transition: all 0.2s ease;
}
.cgnc-schema-card:hover {
  border-color: #c7d2fe;
  background: #ffffff;
}
.cgnc-table-ecritures {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13px;
}
.cgnc-table-ecritures th {
  background: #f1f5f9;
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  color: #475569;
  border-bottom: 1px solid #e2e8f0;
}
.cgnc-table-ecritures td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
}
@media print {
  .cgnc-tabs-nav, #input-cgnc-search, #btn-cgnc-clear-search {
    display: none !important;
  }
  .cgnc-account-card, .cgnc-schema-card {
    break-inside: avoid;
    page-break-inside: avoid;
    border: 1px solid #cbd5e1 !important;
    margin-bottom: 12px !important;
  }
}

/* ==================== MODULE GESTION MULTI-DOSSIERS (SOUS-COMPTES) ==================== */
.subaccounts-hero-card {
  background: linear-gradient(135deg, #180507 0%, #2b080d 50%, #150305 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 30px;
  margin-bottom: 28px;
  border: 1px solid #5a141b;
  box-shadow: 0 10px 30px rgba(24, 5, 7, 0.25);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 24px;
}

.subaccounts-quota-box {
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(254, 202, 202, 0.2);
  border-radius: var(--radius-md);
  padding: 18px 24px;
  min-width: 320px;
}

.quota-bar-container {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 9999px;
  overflow: hidden;
  margin: 10px 0 6px;
}

.quota-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #16a34a 0%, #f59e0b 70%, #dc2626 100%);
  border-radius: 9999px;
  transition: width 0.4s ease;
}

.subaccounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 22px;
  margin-top: 20px;
}

.subaccount-item-card {
  background: #ffffff;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 22px;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

.subaccount-item-card:hover {
  transform: translateY(-4px);
  border-color: #c1121f;
  box-shadow: 0 12px 25px rgba(193, 18, 31, 0.12);
}

.subaccount-item-card.active-dossier {
  border-color: #16a34a;
  background: #f0fdf4;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.25);
}

.btn-switch-dossier {
  background: linear-gradient(135deg, #c1121f 0%, #991b1b 100%);
  color: white;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-switch-dossier:hover {
  background: linear-gradient(135deg, #991b1b 0%, #7f1d1d 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(193, 18, 31, 0.3);
}

/* ==================== MODULE RECOUVREMENT & BALANCE ÂGÉE (LOI 69-21) ==================== */
.aging-card {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}
.aging-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}
.tab-relance-btn {
  font-weight: 600;
  font-size: 12px;
  border-radius: 6px;
  transition: all 0.15s;
}
.tab-relance-btn.active {
  background: #c1121f !important;
  border-color: #c1121f !important;
  color: #ffffff !important;
}
.tab-recon-btn.active {
  background: #c1121f !important;
  border-color: #c1121f !important;
  color: #ffffff !important;
}
.recon-pane {
  animation: fadeInPane 0.2s ease-in-out;
}
@keyframes fadeInPane {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== PIPELINE COMMERCIAL KANBAN ==================== */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-top: 14px;
}
@media (min-width: 1400px) {
  .kanban-board {
    grid-template-columns: repeat(6, 1fr);
  }
}
.kanban-col {
  background: #f1f5f9;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  min-height: 480px;
  max-height: calc(100vh - 280px);
}
.kanban-col-header {
  padding: 12px 14px;
  font-weight: 700;
  font-size: 12.5px;
  border-bottom: 2px solid transparent;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
  border-top-left-radius: 9px;
  border-top-right-radius: 9px;
}
.kanban-col-body {
  padding: 10px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.kanban-card {
  background: #ffffff;
  border-radius: 8px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-color: #cbd5e1;
}
.kanban-card-title {
  font-weight: 700;
  font-size: 13px;
  color: #0f172a;
}
.kanban-card-amount {
  font-weight: 800;
  font-size: 14px;
  color: #c1121f;
}
.kanban-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #e2e8f0;
  font-size: 11px;
}

/* ==================== CASH FLOW FORECAST ==================== */
.forecast-card {
  border-radius: 12px;
  padding: 16px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  transition: all 0.2s ease;
}
.forecast-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}
.forecast-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
}

/* ==================== DIGITAL CLOSING SEAL ==================== */
.seal-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 12px;
}
.seal-hash-box {
  background: #0f172a;
  color: #38bdf8;
  font-family: monospace;
  font-size: 11.5px;
  padding: 10px 14px;
  border-radius: 6px;
  word-break: break-all;
  border: 1px solid #1e293b;
}

/* ==================== PAY-BY-LINK ==================== */
.paylink-box {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1px solid #86efac;
  border-radius: 10px;
  padding: 14px 18px;
}



