:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #14b8a6;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --sidebar-width: 260px;
  --radius: 12px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.5;
}

a { text-decoration: none; color: inherit; }

.login-body { background: linear-gradient(135deg, #667eea, #764ba2); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }

.login-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #667eea, #764ba2); padding: 1rem; }
.login-card { background: white; border-radius: 24px; padding: 2.5rem; width: 100%; max-width: 420px; box-shadow: 0 25px 50px rgba(0,0,0,0.15); }
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-icon { width: 64px; height: 64px; background: linear-gradient(135deg, var(--primary), var(--secondary)); border-radius: 20px; display: flex; align-items: center; justify-content: center; margin: 0 auto 1rem; font-size: 2rem; }
.login-logo h1 { font-size: 1.5rem; color: var(--gray-900); }
.login-logo p { font-size: 0.875rem; color: var(--gray-500); }
.login-subtitle { font-size: 0.75rem !important; color: var(--gray-400) !important; margin-top: 0.25rem; }
.login-footer { text-align: center; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--gray-200); }
.login-footer p { font-size: 0.8125rem; color: var(--gray-500); }

.app-layout { display: flex; min-height: 100vh; }

.sidebar { width: var(--sidebar-width); background: var(--gray-900); color: white; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; overflow-y: auto; }
.sidebar-logo { padding: 1.25rem; display: flex; align-items: center; gap: 0.75rem; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-logo-icon { width: 40px; height: 40px; background: linear-gradient(135deg, var(--primary), var(--secondary)); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; flex-shrink: 0; }
.sidebar-logo h2 { font-size: 1.1rem; font-weight: 700; }
.sidebar-subtitle { font-size: 0.7rem; opacity: 0.6; }
.sidebar-nav { flex: 1; padding: 0.75rem 0; }
.sidebar-section-title { padding: 0.75rem 1.25rem 0.25rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.4; }
.sidebar-nav-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.625rem 1.25rem; color: rgba(255,255,255,0.7); font-size: 0.875rem; transition: all 0.15s ease; }
.sidebar-nav-item:hover { background: rgba(255,255,255,0.05); color: white; }
.sidebar-user { padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,0.1); display: flex; align-items: center; gap: 0.75rem; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 0.8125rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 0.7rem; opacity: 0.5; }
.logout-btn { background: none; border: none; color: rgba(255,255,255,0.5); cursor: pointer; font-size: 1.25rem; padding: 4px; text-decoration: none; }

.main-content { flex: 1; margin-left: var(--sidebar-width); min-height: 100vh; }

.topbar { height: 64px; background: white; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem; position: sticky; top: 0; z-index: 50; }
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.topbar-title { font-size: 1.1rem; font-weight: 600; color: var(--gray-800); }
.topbar-right { display: flex; align-items: center; gap: 1rem; }

.role-badge { font-size: 0.75rem; padding: 0.25rem 0.75rem; border-radius: 20px; background: var(--gray-100); color: var(--gray-600); font-weight: 500; }
.notif-btn { position: relative; background: none; border: none; cursor: pointer; font-size: 1.25rem; padding: 8px; color: var(--gray-500); text-decoration: none; }
.notif-badge { position: absolute; top: 0; right: 0; background: var(--danger); color: white; font-size: 0.65rem; font-weight: 700; width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }

.page-content { padding: 1.5rem; }

.card { background: white; border-radius: var(--radius); border: 1px solid var(--gray-200); overflow: hidden; margin-bottom: 1rem; }
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.card-header h2, .card-header h3 { font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
.card-body { padding: 1.25rem; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-2 { margin-top: 0.5rem !important; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: white; border-radius: var(--radius); border: 1px solid var(--gray-200); padding: 1.25rem; transition: transform 0.15s ease, box-shadow 0.15s ease; }
.stat-card.clickable { cursor: pointer; }
.stat-card.clickable:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(0,0,0,0.08); }
.stat-card-content { display: flex; justify-content: space-between; align-items: center; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--gray-900); }
.stat-label { font-size: 0.8125rem; color: var(--gray-500); margin-top: 0.25rem; }
.stat-icon { width: 56px; height: 56px; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 1.75rem; }

.btn { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem; border-radius: var(--radius-sm); font-size: 0.875rem; font-weight: 500; border: 1px solid transparent; cursor: pointer; transition: all 0.15s ease; text-decoration: none; }
.btn-primary { background: var(--primary); color: white; } .btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border-color: var(--gray-200); } .btn-secondary:hover { background: var(--gray-200); }
.btn-success { background: var(--success); color: white; } .btn-success:hover { background: #16a34a; }
.btn-warning { background: var(--warning); color: white; } .btn-warning:hover { background: #d97706; }
.btn-danger { background: var(--danger); color: white; } .btn-danger:hover { background: #dc2626; }
.btn-ghost { background: none; color: var(--gray-600); border: none; padding: 0.375rem; } .btn-ghost:hover { background: var(--gray-100); }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.w-full { width: 100%; justify-content: center; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.8125rem; font-weight: 500; color: var(--gray-700); margin-bottom: 0.375rem; }
.form-input { width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); font-size: 0.875rem; background: white; transition: border-color 0.15s ease; }
.form-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.1); }
textarea.form-input { resize: vertical; min-height: 80px; }
select.form-input { cursor: pointer; }

.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

.alert { padding: 0.75rem 1rem; border-radius: var(--radius-sm); font-size: 0.875rem; margin-bottom: 1rem; display: flex; align-items: flex-start; gap: 0.5rem; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.table-container { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th { text-align: left; padding: 0.75rem 1rem; font-weight: 600; color: var(--gray-500); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; background: var(--gray-50); border-bottom: 1px solid var(--gray-200); white-space: nowrap; }
.table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--gray-100); }
.table tr:hover td { background: var(--gray-50); }
.table .text-center { text-align: center; color: var(--gray-400); padding: 2rem; }

.statut-badge { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.2rem 0.6rem; border-radius: 20px; color: white; font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.analyse-badge { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.2rem 0.5rem; border-radius: 6px; font-size: 0.7rem; font-weight: 500; }
.analyse-badge.success { background: #f0fdf4; color: #166534; }
.analyse-badge.warning { background: #fffbeb; color: #92400e; }
.analyse-badge.danger { background: #fef2f2; color: #991b1b; }

.avatar { border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; width: 36px; height: 36px; font-size: 0.8rem; flex-shrink: 0; }
.avatar-sm { width: 32px; height: 32px; font-size: 0.75rem; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.75rem; }
.page-header h2 { display: flex; align-items: center; gap: 0.5rem; font-size: 1.25rem; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--gray-500); }
.empty-state h3 { margin: 1rem 0 0.5rem; color: var(--gray-700); }
.empty-state p { margin-bottom: 1rem; }

.loading { text-align: center; padding: 3rem; color: var(--gray-400); }

.welcome-banner { background: linear-gradient(135deg, var(--primary), #7c3aed); border-radius: var(--radius); padding: 1.5rem 2rem; color: white; margin-bottom: 1.5rem; }
.welcome-banner h2 { font-size: 1.25rem; margin-bottom: 0.25rem; display: flex; align-items: center; gap: 0.5rem; }
.welcome-banner p { opacity: 0.85; font-size: 0.875rem; }

.dashboard-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.dashboard-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

.info-lines { display: flex; flex-direction: column; gap: 0.5rem; }
.info-line { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0; border-bottom: 1px solid var(--gray-100); }
.info-line span { font-size: 0.875rem; color: var(--gray-500); }
.info-line strong { font-size: 0.875rem; }

.big-stat { font-size: 3rem; font-weight: 700; color: var(--primary); margin-bottom: 0.5rem; }
.text-muted { color: var(--gray-500) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-center { text-align: center; }

.activity-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 0; border-bottom: 1px solid var(--gray-100); }
.activity-detail { flex: 1; min-width: 0; }
.activity-detail strong { font-size: 0.875rem; display: block; }
.activity-detail p { font-size: 0.8125rem; color: var(--gray-500); }
.activity-detail small { font-size: 0.75rem; color: var(--gray-400); }

.tabs { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tab-btn { padding: 0.375rem 0.75rem; border-radius: var(--radius-sm); border: 1px solid var(--gray-200); background: white; font-size: 0.8125rem; cursor: pointer; color: var(--gray-600); transition: all 0.15s ease; }
.tab-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.tab-btn:hover:not(.active) { background: var(--gray-100); }

.filters-row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end; }
.filters-row .form-input { max-width: 250px; }

.user-cell { display: flex; align-items: center; gap: 0.75rem; }

.proposition-card { margin-bottom: 0.75rem; }
.proposition-card.selected { border-color: var(--primary); }
.proposition-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; flex-wrap: wrap; gap: 0.5rem; }
.proposition-sujets { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 0.5rem; }
.sujet-item { font-size: 0.8125rem; padding: 0.25rem 0; }
.sujet-item.retenu { background: #f0fdf4; padding: 0.25rem 0.5rem; border-radius: 4px; }

.validation-buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }

.partie-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.5rem; }
.partie-title { display: flex; align-items: center; gap: 0.5rem; }
.partie-meta { font-size: 0.75rem; color: var(--gray-500); margin-bottom: 0.5rem; }
.partie-analyses { display: flex; gap: 0.75rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.partie-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.correction-form { margin-top: 1rem; padding: 1rem; background: var(--gray-50); border-radius: var(--radius-sm); }

.code-input { font-family: monospace; font-size: 1rem !important; letter-spacing: 0.1em; text-transform: uppercase; }

.fiche-tabs { display: flex; gap: 0.25rem; margin-bottom: 1rem; flex-wrap: wrap; }

.fiche-item { display: flex; align-items: center; gap: 1rem; padding: 0.75rem; border: 1px solid var(--gray-200); border-radius: var(--radius-sm); margin-bottom: 0.5rem; }
.fiche-code { font-family: monospace; font-weight: 700; color: var(--primary); }

.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.doc-card { padding: 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; }
.doc-icon { font-size: 2rem; color: var(--primary); }
.doc-type-badge { align-self: flex-start; font-size: 0.7rem; padding: 0.2rem 0.5rem; border-radius: 6px; background: var(--gray-100); color: var(--gray-600); font-weight: 500; }

.messages-container { display: grid; grid-template-columns: 280px 1fr; height: calc(100vh - 64px - 3rem); border: 1px solid var(--gray-200); border-radius: var(--radius); overflow: hidden; background: white; }
.contacts-sidebar { border-right: 1px solid var(--gray-200); overflow-y: auto; }
.contacts-sidebar h3 { padding: 1rem; font-size: 0.875rem; border-bottom: 1px solid var(--gray-200); }
.contact-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; cursor: pointer; transition: background 0.15s ease; }
.contact-item:hover { background: var(--gray-50); }
.contact-item.active { background: var(--gray-100); border-left: 3px solid var(--primary); }
.contact-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8rem; flex-shrink: 0; }
.contact-info { flex: 1; min-width: 0; }
.contact-info strong { font-size: 0.8125rem; display: block; }
.contact-info small { font-size: 0.7rem; color: var(--gray-400); }

.messages-main { display: flex; flex-direction: column; }
.messages-list { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.message-bubble { max-width: 70%; padding: 0.625rem 0.875rem; border-radius: 12px; font-size: 0.875rem; }
.message-bubble.sent { align-self: flex-end; background: var(--primary); color: white; }
.message-bubble.received { align-self: flex-start; background: var(--gray-100); color: var(--gray-800); }
.message-time { font-size: 0.65rem; opacity: 0.6; margin-top: 0.25rem; text-align: right; }
.message-input-area { padding: 0.75rem; border-top: 1px solid var(--gray-200); display: flex; flex-direction: column; gap: 0.5rem; }
.message-input-row { display: flex; gap: 0.5rem; }

.code-verify { display: flex; gap: 0.5rem; align-items: center; }
.code-verify .form-input { flex: 1; }

@media (max-width: 1024px) {
  .sidebar { position: fixed; z-index: 100; transform: translateX(-100%); transition: transform 0.3s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .dashboard-grid-2, .dashboard-grid-3 { grid-template-columns: 1fr; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
  .messages-container { grid-template-columns: 1fr; }
  .contacts-sidebar { display: none; }
}
