/* ============================================================
   TaskFlow — Système de design moderne
   ============================================================ */

/* --- Variables CSS --- */
:root {
  --primary: #0086CD;
  --primary-dark: #0069A8;
  --primary-darker: #004F82;
  --primary-light: #EBF6FC;
  --primary-glow: rgba(0,134,205,0.15);

  --success: #059669;
  --success-light: #D1FAE5;
  --warning: #D97706;
  --warning-light: #FEF3C7;
  --danger: #DC2626;
  --danger-light: #FEE2E2;
  --info: #2563EB;
  --info-light: #DBEAFE;

  --bg: #F1F5F9;
  --surface: #FFFFFF;
  --surface2: #F8FAFC;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;

  --text: #0F172A;
  --text2: #475569;
  --text3: #94A3B8;

  --sidebar-w: 272px;
  --sidebar-collapsed: 68px;
  --topbar-h: 64px;

  --radius: 0.75rem;
  --radius-sm: 0.5rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 16px rgba(0,0,0,0.07), 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 8px 32px rgba(0,0,0,0.09), 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.12), 0 4px 16px rgba(0,0,0,0.08);
  --shadow-blue: 0 8px 32px rgba(0,134,205,0.25);

  --trans: 0.2s cubic-bezier(0.4,0,0.2,1);
  --trans-slow: 0.35s cubic-bezier(0.4,0,0.2,1);

  /* Statuts */
  --s-pasfait-c:  #6B7280;
  --s-encours-c:  #0086CD;
  --s-attente-c:  #D97706;
  --s-termine-c:  #059669;
  --s-annule-c:   #991B1B;
  --s-retard-c:   #DC2626;
  --s-rejete-c:   #7C3AED;
}

/* --- Dark mode --- */
.dark {
  --bg: #0F172A;
  --surface: #1E293B;
  --surface2: #162032;
  --border: #2D3F56;
  --border-strong: #3D5373;
  --text: #F1F5F9;
  --text2: #94A3B8;
  --text3: #64748B;
  --primary-light: rgba(0,134,205,0.12);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow: 0 4px 16px rgba(0,0,0,0.3);
  --shadow-md: 0 8px 32px rgba(0,0,0,0.35);
}

/* --- Reset & base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}

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

/* --- Custom scrollbar --- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  transition: width 0.3s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
  z-index: 50;
}

.app-sidebar.collapsed { width: var(--sidebar-collapsed); }

/* Main area */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Topbar */
.app-topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 40;
}

/* Content */
.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.75rem 2rem;
}

/* ============================================================
   SIDEBAR COMPONENTS
   ============================================================ */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 16px; flex-shrink: 0;
  box-shadow: var(--shadow-blue);
}

.brand-text { overflow: hidden; white-space: nowrap; }
.brand-name { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }
.brand-tagline { font-size: 11px; color: var(--text3); }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  margin: 0.75rem 0.75rem 0;
  border-radius: var(--radius);
  background: var(--primary-light);
  overflow: hidden;
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.user-info { overflow: hidden; white-space: nowrap; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); display: block; }
.user-role { font-size: 11px; color: var(--text3); display: block; }

.sidebar-nav {
  flex: 1;
  padding: 0.75rem;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.75rem 0.75rem 0.375rem;
  white-space: nowrap;
  overflow: hidden;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius);
  color: var(--text2);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: var(--trans);
  white-space: nowrap;
  overflow: hidden;
  margin-bottom: 2px;
  position: relative;
}

.nav-link:hover { background: var(--surface2); color: var(--text); }

.nav-link.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 25%; bottom: 25%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
}

.nav-link.danger:hover { background: var(--danger-light); color: var(--danger); }

.nav-icon {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
  background: var(--surface2);
  color: var(--text2);
  transition: var(--trans);
}

.nav-link:hover .nav-icon { background: var(--border); color: var(--text); }
.nav-link.active .nav-icon { background: rgba(0,134,205,0.15); color: var(--primary); }

.nav-badge {
  margin-left: auto;
  font-size: 11px; font-weight: 600;
  background: var(--border);
  color: var(--text2);
  padding: 1px 7px;
  border-radius: 99px;
  flex-shrink: 0;
}

.nav-link.active .nav-badge { background: rgba(0,134,205,0.15); color: var(--primary); }

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Collapsed state */
.app-sidebar.collapsed .brand-text,
.app-sidebar.collapsed .user-info,
.app-sidebar.collapsed .nav-section,
.app-sidebar.collapsed .nav-badge,
.app-sidebar.collapsed .nav-label { display: none; }

.app-sidebar.collapsed .sidebar-brand { justify-content: center; padding: 1rem; }
.app-sidebar.collapsed .sidebar-user { justify-content: center; padding: 0.75rem; margin: 0.75rem 0.5rem 0; }
.app-sidebar.collapsed .nav-link { justify-content: center; padding: 0.625rem; }
.app-sidebar.collapsed .nav-icon { width: 36px; height: 36px; }
.app-sidebar.collapsed .sidebar-footer a { justify-content: center; }

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar-toggle {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: var(--trans); flex-shrink: 0;
}
.topbar-toggle:hover { background: var(--surface2); color: var(--text); }

.topbar-search {
  flex: 1;
  max-width: 380px;
  position: relative;
}
.topbar-search input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.875rem 0.5rem 2.5rem;
  font-size: 13.5px;
  color: var(--text);
  transition: var(--trans);
  outline: none;
  font-family: inherit;
}
.topbar-search input::placeholder { color: var(--text3); }
.topbar-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); background: var(--surface); }
.topbar-search .search-icon { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); color: var(--text3); font-size: 13px; pointer-events: none; }
.topbar-search .kbd-hint { position: absolute; right: 0.75rem; top: 50%; transform: translateY(-50%); font-size: 10px; color: var(--text3); background: var(--border); border-radius: 4px; padding: 1px 5px; }

.topbar-actions { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }

.topbar-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: var(--trans); position: relative;
}
.topbar-btn:hover { background: var(--surface2); color: var(--text); }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem 0.375rem 0.375rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer; transition: var(--trans);
  text-decoration: none;
}
.topbar-user:hover { background: var(--surface2); }
.topbar-user .avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.topbar-user .avatar img { width: 100%; height: 100%; object-fit: cover; }
.topbar-user .user-label { font-size: 13px; font-weight: 500; color: var(--text); }

/* Breadcrumb */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text3); }
.breadcrumb a { color: var(--text3); transition: color var(--trans); }
.breadcrumb a:hover { color: var(--primary); }
.bc-sep { color: var(--text3); }
.bc-current { color: var(--text); font-weight: 500; }

/* Notifications */
.notif-wrap { position: relative; }
.notif-badge {
  position: absolute; top: -2px; right: -2px;
  background: var(--danger);
  color: #fff; font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}
.notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: none; z-index: 200;
  max-height: 400px; overflow-y: auto;
}
.notif-panel.open { display: block; }
.notif-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 13px;
}
.notif-header a { color: var(--primary); font-size: 11px; font-weight: 400; }
.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--trans);
}
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--primary-light); }
.notif-item-title { font-weight: 600; font-size: 12px; margin-bottom: 2px; }
.notif-item-msg { font-size: 12px; color: var(--text2); }
.notif-item-time { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* Search results */
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  max-height: 300px; overflow-y: auto;
  display: none; z-index: 200;
}
.search-results.visible { display: block; }
.search-result-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--trans);
  font-size: 13px;
}
.search-result-item:hover { background: var(--primary-light); }
.search-result-item:last-child { border-bottom: none; }

/* ============================================================
   PAGE STRUCTURE
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.page-subtitle { font-size: 13px; color: var(--text3); margin-top: 2px; }

/* Flash / Alert */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  margin-bottom: 1.25rem;
  border: 1px solid;
}
.flash button { background: none; border: none; cursor: pointer; font-size: 16px; opacity: .6; }
.flash-success { background: var(--success-light); color: var(--success); border-color: #6EE7B7; }
.flash-error   { background: var(--danger-light);  color: var(--danger);  border-color: #FCA5A5; }
.flash-info    { background: var(--info-light);    color: var(--info);    border-color: #93C5FD; }
.flash-warning { background: var(--warning-light); color: var(--warning); border-color: #FCD34D; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--trans);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.125rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text); }
.card-body { padding: 1.25rem; }

/* Stats / KPI grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: var(--trans-slow);
  position: relative;
  overflow: hidden;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 17px;
  background: var(--surface2);
  color: var(--text2);
}
.stat-icon--info { background: var(--info-light); color: var(--info); }
.stat-icon--success { background: var(--success-light); color: var(--success); }
.stat-icon--danger { background: var(--danger-light); color: var(--danger); }
.stat-icon--warning { background: var(--warning-light); color: var(--warning); }
.stat-icon--primary { background: var(--primary-light); color: var(--primary); }

/* Graphiques (rapport / dashboard) — hauteur maîtrisée */
.chart-wrap {
  position: relative;
  width: 100%;
  height: 200px;
  max-height: 200px;
}
.chart-wrap--dept {
  height: 220px;
  max-height: 220px;
}
.chart-wrap--dashboard-donut {
  height: 220px;
  max-height: 220px;
  max-width: 260px;
  margin: 0 auto;
}
.stat-value { font-size: 26px; font-weight: 800; line-height: 1; letter-spacing: -1px; }
.stat-label { font-size: 11.5px; color: var(--text3); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.04em; }

/* KPI Card (archives style) */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: var(--trans-slow);
  cursor: default;
  position: relative;
  overflow: hidden;
}
.kpi-card::after {
  content: ''; position: absolute; top: 0; right: 0;
  width: 80px; height: 80px; border-radius: 50%;
  opacity: 0.04; transition: var(--trans-slow);
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.kpi-card:hover::after { transform: scale(1.5); opacity: 0.07; }

.kpi-icon { width: 46px; height: 46px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.kpi-info { flex: 1; min-width: 0; }
.kpi-label { font-size: 11.5px; font-weight: 500; color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.25rem; }
.kpi-value { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1.1; letter-spacing: -1px; }
.kpi-delta { font-size: 11px; color: var(--text3); margin-top: 0.25rem; }

.kpi-blue .kpi-icon { background: var(--primary-light); color: var(--primary); }
.kpi-blue::after { background: var(--primary); }
.kpi-green .kpi-icon { background: var(--success-light); color: var(--success); }
.kpi-green::after { background: var(--success); }
.kpi-amber .kpi-icon { background: var(--warning-light); color: var(--warning); }
.kpi-amber::after { background: var(--warning); }
.kpi-red .kpi-icon { background: var(--danger-light); color: var(--danger); }
.kpi-red::after { background: var(--danger); }
.kpi-purple .kpi-icon { background: #EDE9FE; color: #7C3AED; }
.kpi-purple::after { background: #7C3AED; }

/* ============================================================
   TABLEAU
   ============================================================ */
.table-wrapper { overflow-x: auto; }

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

thead { background: var(--surface2); }

th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 11.5px; font-weight: 600;
  color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}

td {
  padding: 0.875rem 1rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 13px;
}

tbody tr { transition: background 0.15s ease; }
tbody tr:hover { background: var(--primary-light); }
tbody tr:last-child td { border-bottom: none; }

/* Row status coloring */
tr.row-pasfait td:first-child { border-left: 3px solid var(--s-pasfait-c); }
tr.row-encours  td:first-child { border-left: 3px solid var(--s-encours-c); }
tr.row-attente  td:first-child { border-left: 3px solid var(--s-attente-c); }
tr.row-termine  td:first-child { border-left: 3px solid var(--s-termine-c); }
tr.row-annule   td:first-child { border-left: 3px solid var(--s-annule-c); }
tr.row-retard   td:first-child { border-left: 3px solid var(--s-retard-c); }
tr.row-rejete   td:first-child { border-left: 3px solid var(--s-rejete-c); }
tr.row-retard { background: rgba(220,38,38,0.04) !important; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.15rem 0.6rem;
  border-radius: 99px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.01em;
  white-space: nowrap;
}

.priority-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px; font-weight: 600;
}
.priority-basse   { background: #F9FAFB; color: #6B7280; }
.priority-normale { background: var(--primary-light); color: var(--primary); }
.priority-haute   { background: var(--warning-light); color: var(--warning); }
.priority-urgente { background: var(--danger-light); color: var(--danger); }

/* ============================================================
   BOUTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer; transition: var(--trans);
  border: 1px solid transparent;
  text-decoration: none; white-space: nowrap;
  outline: none; font-family: inherit;
}

.btn-primary {
  background: var(--primary); color: white;
  box-shadow: 0 2px 8px rgba(0,134,205,0.3);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow-blue); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--surface); color: var(--text2);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface2); color: var(--text); border-color: var(--border-strong); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #047857; }

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

.btn-ghost { background: transparent; color: var(--text2); border: none; }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.btn-sm { padding: 0.3rem 0.7rem; font-size: 12px; border-radius: 8px; }
.btn-lg { padding: 0.7rem 1.5rem; font-size: 15px; }

.btn-icon {
  width: 34px; height: 34px;
  padding: 0; justify-content: center;
  border-radius: 8px;
  background: none; border: none;
  cursor: pointer; font-size: 15px;
  transition: background var(--trans);
  display: inline-flex; align-items: center;
}
.btn-icon:hover { background: var(--surface2); }

/* ============================================================
   FORMULAIRES
   ============================================================ */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 0.375rem; }
.form-label .req { color: var(--danger); }

.form-control {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5625rem 0.875rem;
  font-size: 13.5px; color: var(--text);
  font-family: inherit;
  outline: none;
  transition: var(--trans);
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.form-control::placeholder { color: var(--text3); }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-hint { font-size: 11px; color: var(--text3); margin-top: 4px; }
.form-error { font-size: 11px; color: var(--danger); margin-top: 4px; }

/* ============================================================
   KANBAN
   ============================================================ */
.kanban-board {
  display: flex; gap: 16px;
  overflow-x: auto; padding-bottom: 12px;
  align-items: flex-start;
}
.kanban-col {
  min-width: 280px; max-width: 320px;
  background: var(--surface2);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.kanban-col-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: 13px;
  border-top: 3px solid;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.kanban-col[data-status="pas_fait"]   .kanban-col-header { border-top-color: #6B7280; }
.kanban-col[data-status="en_cours"]   .kanban-col-header { border-top-color: var(--primary); }
.kanban-col[data-status="en_attente"] .kanban-col-header { border-top-color: var(--warning); }
.kanban-col[data-status="termine"]    .kanban-col-header { border-top-color: var(--success); }
.kanban-col[data-status="annule"]     .kanban-col-header { border-top-color: #991B1B; }
.kanban-col[data-status="rejete"]     .kanban-col-header { border-top-color: #7C3AED; }

.kanban-cards { padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 80px; }

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: grab;
  transition: box-shadow var(--trans), transform var(--trans);
  box-shadow: var(--shadow-sm);
}
.kanban-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.kanban-card.dragging { opacity: .6; transform: rotate(2deg); cursor: grabbing; }
.kanban-card.retard { border-left: 3px solid var(--danger); }
.kanban-card-title { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.kanban-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.kanban-card-due { font-size: 11px; color: var(--text3); }
.kanban-card-due.overdue { color: var(--danger); font-weight: 600; }
.kanban-card-assignee { font-size: 11px; color: var(--text3); }

/* ============================================================
   PROGRESSION
   ============================================================ */
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--primary);
  transition: width 1.2s cubic-bezier(0.4,0,0.2,1);
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex; align-items: center; gap: 4px;
  justify-content: center; margin-top: 1.25rem;
}
.page-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text2);
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: var(--trans);
  text-decoration: none;
}
.page-btn:hover { background: var(--surface2); color: var(--text); border-color: var(--border-strong); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ============================================================
   FILTRES
   ============================================================ */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 0.75rem;
  align-items: center;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  margin-bottom: 1.25rem;
}
.filter-bar select, .filter-bar input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2); color: var(--text);
  font-size: 13px; font-family: inherit;
  outline: none; transition: var(--trans);
}
.filter-bar select:focus, .filter-bar input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }

/* ============================================================
   TASK DETAIL
   ============================================================ */
.task-detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; }
@media (max-width: 900px) { .task-detail-grid { grid-template-columns: 1fr; } }

.detail-field { margin-bottom: 1rem; }
.detail-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text3); margin-bottom: 4px; }
.detail-value { font-size: 14px; }

/* Comments */
.comment-list { display: flex; flex-direction: column; gap: 12px; }
.comment-item { display: flex; gap: 10px; }
.comment-avatar { flex-shrink: 0; }
.comment-body {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px; flex: 1;
}
.comment-meta { font-size: 11px; color: var(--text3); margin-top: 6px; }

/* History */
.history-item {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 12px; padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.history-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 5px; flex-shrink: 0; }
.history-time { color: var(--text3); white-space: nowrap; }

/* ============================================================
   UPLOAD ZONE
   ============================================================ */
.upload-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--trans);
  color: var(--text3);
  min-height: 140px;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}
/* display:none empêche l’ouverture du sélecteur (clic programmatique ou zone). Overlay invisible à la place. */
.upload-zone > :not(input[type=file]) {
  position: relative;
  z-index: 0;
  pointer-events: none;
}
.upload-zone input[type=file] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
  font-size: 0;
}

.file-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.file-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 12px;
}
.file-icon { font-size: 18px; }
.file-name { flex: 1; }
.file-size { color: var(--text3); }

/* ============================================================
   TOAST
   ============================================================ */
#toast-container {
  position: fixed; top: 1.25rem; right: 1.25rem;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 0.5rem;
  pointer-events: none;
}

.toast {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  min-width: 280px; max-width: 380px;
  pointer-events: all;
  animation: toast-in 0.35s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(100%) scale(0.9); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(100%) scale(0.9); }
}

.toast.removing { animation: toast-out 0.25s ease forwards; }
.toast-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.toast-body { flex: 1; }
.toast-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.toast-msg { font-size: 12.5px; color: var(--text2); margin-top: 1px; }
.toast-close {
  width: 20px; height: 20px; border-radius: 4px;
  border: none; background: transparent; color: var(--text3);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 11px; padding: 0; transition: var(--trans); flex-shrink: 0;
}
.toast-close:hover { background: var(--surface2); color: var(--text); }

.toast-success { border-left: 3px solid var(--success); }
.toast-success .toast-icon { background: var(--success-light); color: var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-error .toast-icon { background: var(--danger-light); color: var(--danger); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-warning .toast-icon { background: var(--warning-light); color: var(--warning); }
.toast-info { border-left: 3px solid var(--primary); }
.toast-info .toast-icon { background: var(--primary-light); color: var(--primary); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  transform: scale(0.9) translateY(-20px);
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }

.modal-header {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 0.75rem;
}
.modal-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.modal-title { font-size: 16px; font-weight: 700; color: var(--text); }
.modal-subtitle { font-size: 13px; color: var(--text3); }
.modal-body { padding: 1.25rem 1.5rem; font-size: 14px; color: var(--text2); line-height: 1.7; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; gap: 0.75rem; justify-content: flex-end; }

/* ============================================================
   ACTION CARDS
   ============================================================ */
.action-card {
  display: flex; align-items: center; gap: 0.875rem;
  padding: 1rem 1.125rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none; transition: var(--trans); cursor: pointer;
}
.action-card:hover { border-color: var(--primary); background: var(--primary-light); transform: translateY(-2px); box-shadow: var(--shadow); }
.action-card-icon { width: 40px; height: 40px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.action-card-label { font-size: 13.5px; font-weight: 600; color: var(--text); }
.action-card-desc { font-size: 12px; color: var(--text3); margin-top: 1px; }

/* ============================================================
   TABS
   ============================================================ */
.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tab-btn {
  padding: 0.625rem 1rem; font-size: 13.5px; font-weight: 500;
  color: var(--text3); background: none; border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer; transition: var(--trans); margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 3rem 1.5rem; text-align: center;
}
.empty-icon { font-size: 2.5rem; color: var(--text3); margin-bottom: 1rem; opacity: 0.4; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 0.5rem; }
.empty-desc { font-size: 13.5px; color: var(--text3); max-width: 320px; }

/* ============================================================
   TIMELINE
   ============================================================ */
.timeline { display: flex; flex-direction: column; }
.timeline-item { display: flex; gap: 0.875rem; padding-bottom: 1.25rem; position: relative; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-line { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.timeline-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 3px; }
.timeline-connector { flex: 1; width: 2px; background: var(--border); margin-top: 4px; min-height: 20px; }
.timeline-item:last-child .timeline-connector { display: none; }
.timeline-content { flex: 1; min-width: 0; }
.timeline-time { font-size: 11px; color: var(--text3); margin-bottom: 0.2rem; }
.timeline-text { font-size: 13px; color: var(--text2); }
.timeline-text strong { color: var(--text); font-weight: 600; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .app-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    z-index: 200;
    transition: transform 0.3s ease, width 0.3s ease;
  }
  .app-sidebar.mobile-open { transform: translateX(0); }
  .app-content { padding: 1rem; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .kanban-board { padding-bottom: 20px; }
  .app-topbar { padding: 0 1rem; }
  .topbar-search { display: none; }
  .mobile-menu-btn { display: flex; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
}
.sidebar-overlay.active { display: block; }

/* Indicateur requêtes AJAX */
.tf-loading-bar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 10000;
  background: linear-gradient(90deg, transparent, var(--primary), #009640, transparent);
  background-size: 50% 100%;
  animation: tf-loading-sweep 0.9s ease-in-out infinite;
}
body.tf-fetching .tf-loading-bar { display: block; }
@keyframes tf-loading-sweep {
  0% { background-position: -100% 0; }
  100% { background-position: 200% 0; }
}

/* Chat par tâche */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.task-chat-messages {
  max-height: 320px;
  overflow-y: auto;
  padding: 12px 0;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.chat-msg--me {
  flex-direction: row-reverse;
}
.chat-msg--me .chat-msg-body {
  align-items: flex-end;
  text-align: right;
}
.chat-msg-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chat-msg-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
}
.chat-msg--me .chat-msg-head {
  flex-direction: row-reverse;
}
.chat-msg-time {
  color: var(--text3);
  font-size: 11px;
  font-weight: 400;
}
.chat-msg-text {
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
  background: var(--surface2);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.chat-msg--me .chat-msg-text {
  background: var(--primary-light);
  border-color: rgba(0, 134, 205, 0.25);
}
.task-chat-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.task-chat-form textarea {
  resize: vertical;
  min-height: 44px;
}

.task-chat-typing {
  margin: 0 0 10px;
  min-height: 1.25em;
  font-size: 12px;
  font-style: italic;
  color: var(--text3);
  animation: task-chat-typing-fade 0.35s ease;
}
@keyframes task-chat-typing-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Messagerie directe ── */
.dm-layout {
  display: grid;
  grid-template-columns: minmax(260px, 300px) 1fr;
  gap: 16px;
  align-items: stretch;
  height: calc(100vh - var(--topbar-h) - 120px);
  min-height: 480px;
}
@media (max-width: 900px) {
  .dm-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .dm-sidebar { order: 2; }
  .dm-main { order: 1; min-height: 50vh !important; }
}
.dm-thread-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.dm-thread-item {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
  align-items: center;
}
.dm-thread-item:hover { background: var(--surface2); }
.dm-thread-item.is-active {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
}
.dm-thread-meta {
  min-width: 0;
  flex: 1;
}
.dm-thread-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 3px;
}
.dm-thread-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.dm-thread-right {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.dm-thread-time {
  font-size: 10px;
  color: var(--text3);
  white-space: nowrap;
}
.dm-thread-preview {
  font-size: 12px;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dm-unread {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  flex-shrink: 0;
}
.dm-chat-pane {
  background: transparent;
  border-radius: 0;
  padding: 16px;
}
/* Nav badge (unread DMs in sidebar) */
.nav-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  flex-shrink: 0;
}
