/* ============================================================
   GESTION FOURNISSEURS — Global Stylesheet (Light Theme)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── CSS Variables ───────────────────────────────────────── */
:root {
  --bg-primary:    #f4f6f9;
  --bg-sidebar:    #ffffff;
  --bg-card:       #ffffff;
  --bg-card-hover: #f8f9fb;
  --accent:        #e02020;
  --accent-hover:  #c01010;
  --accent-light:  rgba(224, 32, 32, 0.08);
  --text-primary:  #111111;
  --text-secondary:#555555;
  --text-muted:    #999999;
  --border:        #e5e7eb;
  --border-light:  #d1d5db;
  --sidebar-w:     210px;
  --header-h:      60px;
  --radius:        8px;
  --radius-lg:     12px;
  --shadow:        0 2px 12px rgba(0,0,0,0.08);
  --transition:    0.2s ease;

  /* Badge colors */
  --badge-high-bg:      rgba(220,53,69,0.12);
  --badge-high-color:   #c0392b;
  --badge-mid-bg:       rgba(255,140,0,0.12);
  --badge-mid-color:    #d68910;
  --badge-low-bg:       rgba(39,174,96,0.12);
  --badge-low-color:    #1e8449;
  --badge-paid-bg:      rgba(39,174,96,0.12);
  --badge-paid-color:   #1e8449;
  --badge-pending-bg:   rgba(255,140,0,0.12);
  --badge-pending-color:#d68910;
  --badge-late-bg:      rgba(220,53,69,0.12);
  --badge-late-color:   #c0392b;
  --badge-doing-bg:     rgba(41,128,185,0.12);
  --badge-doing-color:  #1a5276;
  --badge-todo-bg:      rgba(255,140,0,0.12);
  --badge-todo-color:   #d68910;
  --badge-done-bg:      rgba(39,174,96,0.12);
  --badge-done-color:   #1e8449;
  --badge-valid-bg:     rgba(142,68,173,0.12);
  --badge-valid-color:  #76448a;
}

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

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
ul { list-style: none; }

/* ── Layout ─────────────────────────────────────────────── */
.layout { display: flex; width: 100%; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: width var(--transition);
  overflow: hidden;
  box-shadow: 2px 0 8px rgba(0,0,0,0.05);
}

.sidebar.collapsed { width: 60px; }

.sidebar-brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-logo {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff;
  flex-shrink: 0;
}

.brand-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition);
}

.sidebar.collapsed .brand-name { opacity: 0; pointer-events: none; }
.sidebar.collapsed .brand-logo { opacity: 0; pointer-events: none; }

.sidebar-toggle {
  margin-left: auto;
  color: var(--text-secondary);
  font-size: 18px;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--bg-primary); color: var(--text-primary); }
.sidebar.collapsed .sidebar-toggle {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin-left: 0;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent);
  color: #fff;
}

.nav-item .nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item .nav-label { transition: opacity var(--transition); }
.sidebar.collapsed .nav-label { opacity: 0; pointer-events: none; }

/* Sidebar footer */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 8px 8px;
  flex-shrink: 0;
}

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  transition: margin-left var(--transition);
}

.sidebar.collapsed ~ .main-content { margin-left: 60px; }

/* ── Top Header ──────────────────────────────────────────── */
.top-header {
  height: var(--header-h);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.search-box {
  flex: 1;
  max-width: 440px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 0 16px;
  height: 36px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(224,32,32,0.08);
}

.search-box input {
  background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 13px; width: 100%;
  font-family: inherit;
}

.search-box input::placeholder { color: var(--text-muted); }
.search-icon { color: var(--text-muted); font-size: 14px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.notif-btn {
  position: relative;
  width: 36px; height: 36px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  font-size: 16px;
  transition: background var(--transition), color var(--transition);
}
.notif-btn:hover { background: var(--border); color: var(--text-primary); }

.notif-badge {
  position: absolute;
  top: -2px; right: -2px;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}

.user-menu {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 4px 12px 4px 4px;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
}
.user-menu:hover { background: var(--border); }

.user-avatar {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  color: #fff;
  font-weight: 600;
}

.user-name { font-size: 12px; font-weight: 600; color: var(--text-primary); }

/* ── Page Content ─────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  animation: fadeIn 0.3s ease;
}

.page-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; color: var(--text-primary); }
.page-subtitle { font-size: 13px; color: var(--text-secondary); margin-bottom: 24px; }

/* ── Stats Grid ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.1); }

.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value { font-size: 24px; font-weight: 700; color: var(--text-primary); }

.stat-change { font-size: 11px; display: flex; align-items: center; gap: 4px; }
.stat-change.up   { color: #1e8449; }
.stat-change.down { color: var(--accent); }

.stat-icon {
  position: absolute;
  right: 16px; top: 16px;
  font-size: 32px;
  opacity: 0.06;
  color: var(--text-primary);
}

/* ── Card ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

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

.card-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }

.card-link {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  transition: opacity var(--transition);
}
.card-link:hover { opacity: 0.75; }

.card-body { padding: 20px; }

/* ── Chart Area ──────────────────────────────────────────── */
.chart-wrapper { position: relative; height: 220px; padding: 0 20px 20px; }

/* ── Two-col grid ────────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* ── Table ───────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  background: #fafafa;
}

.data-table td {
  padding: 14px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: #fafafa; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-paid     { background: var(--badge-paid-bg);    color: var(--badge-paid-color); }
.badge-pending  { background: var(--badge-pending-bg); color: var(--badge-pending-color); }
.badge-late     { background: var(--badge-late-bg);    color: var(--badge-late-color); }
.badge-high     { background: var(--badge-high-bg);    color: var(--badge-high-color); }
.badge-mid      { background: var(--badge-mid-bg);     color: var(--badge-mid-color); }
.badge-low      { background: var(--badge-low-bg);     color: var(--badge-low-color); }
.badge-doing    { background: var(--badge-doing-bg);   color: var(--badge-doing-color); }
.badge-todo     { background: var(--badge-todo-bg);    color: var(--badge-todo-color); }
.badge-done     { background: var(--badge-done-bg);    color: var(--badge-done-color); }
.badge-valid    { background: var(--badge-valid-bg);   color: var(--badge-valid-color); }

/* ── Task list item ──────────────────────────────────────── */
.task-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  transition: background var(--transition);
}
.task-item:last-child { border-bottom: none; }
.task-item:hover { background: #fafafa; }

.task-info { flex: 1; }
.task-name { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 3px; }
.task-assignee { font-size: 11px; color: var(--text-secondary); }
.task-badges { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

/* ── Invoice mini rows ───────────────────────────────────── */
.invoice-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.invoice-item:last-child { border-bottom: none; }
.invoice-item:hover { background: #fafafa; }

.invoice-ref { font-size: 13px; font-weight: 700; color: var(--accent); }
.invoice-supplier { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

.invoice-right { text-align: right; }
.invoice-amount { font-size: 13px; font-weight: 700; color: var(--text-primary); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  transition: background var(--transition), box-shadow var(--transition);
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 12px rgba(224,32,32,0.3); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
}
.btn-outline:hover { background: var(--bg-primary); color: var(--text-primary); }

/* ── Form ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-control {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 14px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(224,32,32,0.08);
}
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }

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

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 500px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform var(--transition);
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal-overlay.open .modal { transform: scale(1); }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.modal-close { font-size: 20px; color: var(--text-secondary); transition: color var(--transition); }
.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 20px; }
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
  background: #fafafa;
}

/* ── Notification list ───────────────────────────────────── */
.notif-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.notif-item:hover { background: #fafafa; }
.notif-item.unread { background: rgba(224,32,32,0.04); }

.notif-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 4px; flex-shrink: 0;
}
.notif-dot.read { background: var(--border-light); }

.notif-content { flex: 1; }
.notif-text { font-size: 13px; line-height: 1.5; color: var(--text-primary); }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.notif-delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
  margin-top: 2px;
}
.notif-delete-btn:hover {
  background: rgba(220, 53, 69, 0.1);
  color: #c0392b;
}

/* ── Calendar ────────────────────────────────────────────── */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }

.cal-header {
  font-size: 11px; font-weight: 700;
  color: var(--text-muted);
  text-align: center; padding: 8px 0;
  text-transform: uppercase;
}

.cal-day {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
  color: var(--text-primary);
}
.cal-day:hover { background: var(--bg-primary); }
.cal-day.today { background: var(--accent); color: #fff; font-weight: 700; }
.cal-day.other-month { color: var(--text-muted); }

/* ── Audit log ───────────────────────────────────────────── */
.audit-item {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.audit-item:last-child { border-bottom: none; }

.audit-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.audit-icon.create { background: var(--badge-done-bg); color: var(--badge-done-color); }
.audit-icon.edit   { background: var(--badge-doing-bg); color: var(--badge-doing-color); }
.audit-icon.delete { background: var(--badge-high-bg); color: var(--badge-high-color); }
.audit-icon.pay    { background: var(--badge-paid-bg); color: var(--badge-paid-color); }
.audit-icon.login  { background: var(--badge-valid-bg); color: var(--badge-valid-color); }

.audit-body { flex: 1; }
.audit-action { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.audit-meta { font-size: 11px; color: var(--text-secondary); margin-top: 3px; }
.audit-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* ── Rapport bars ────────────────────────────────────────── */
.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.bar-label { font-size: 12px; width: 100px; color: var(--text-secondary); flex-shrink: 0; font-weight: 500; }
.bar-track { flex: 1; background: var(--bg-primary); border-radius: 20px; height: 8px; overflow: hidden; border: 1px solid var(--border); }
.bar-fill  { height: 100%; border-radius: 20px; background: var(--accent); transition: width 1s ease; }
.bar-value { font-size: 12px; font-weight: 700; width: 80px; text-align: right; flex-shrink: 0; color: var(--text-primary); }

/* ── Settings tabs ───────────────────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 24px; }

.tab-btn {
  padding: 10px 20px;
  font-size: 13px; font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
  cursor: pointer;
  background: none;
  border-top: none; border-left: none; border-right: none;
  font-family: inherit;
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-btn:hover { color: var(--text-primary); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Supplier Grid View ──────────────────────────────────── */
.supplier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.supplier-grid-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: transform var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}
.supplier-grid-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}
.supplier-grid-card .card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.supplier-grid-card .card-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
  flex-shrink: 0;
}
.supplier-grid-card .card-info { flex: 1; min-width: 0; }
.supplier-grid-card .card-name {
  font-size: 14px; font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.supplier-grid-card .card-category {
  font-size: 11px; color: var(--text-muted);
  margin-top: 2px;
}
.supplier-grid-card .card-body {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 14px;
}
.supplier-grid-card .card-row {
  font-size: 12px; color: var(--text-secondary);
  display: flex; align-items: center; gap: 6px;
}
.supplier-grid-card .card-row svg {
  color: var(--text-muted); flex-shrink: 0;
}
.supplier-grid-card .card-actions {
  display: flex; gap: 6px; justify-content: flex-end;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

/* ── Kanban View ────────────────────────────────────────── */
.kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 8px;
  min-height: 500px;
}
.kanban-column {
  flex: 1;
  min-width: 240px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
}
.kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.kanban-column-count {
  background: var(--border);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}
.kanban-column-body {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
  min-height: 100px;
}
.kanban-column-body.drag-over {
  background: rgba(224,32,32,0.04);
}
.kanban-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 8px;
  cursor: grab;
  transition: box-shadow var(--transition), transform var(--transition);
  user-select: none;
}
.kanban-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging {
  opacity: 0.5;
  transform: rotate(2deg);
}
.kanban-card .card-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}
.kanban-card .card-meta {
  font-size: 11px;
  color: var(--text-muted);
}
.kanban-card .card-code {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Supplier rows ───────────────────────────────────────── */
.supplier-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.supplier-row:hover { background: #fafafa; }
.supplier-row:last-child { border-bottom: none; }

.supplier-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff;
  flex-shrink: 0;
}

.supplier-info { flex: 1; }
.supplier-name { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.supplier-category { font-size: 11px; color: var(--text-secondary); }

.supplier-amount { font-size: 13px; font-weight: 700; text-align: right; color: var(--text-primary); }
.supplier-amount small { display: block; font-size: 10px; color: var(--text-muted); font-weight: 400; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

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

/* ── Responsive ──────────────────────────────────────────── */

/* Mobile hamburger button */
.hamburger-btn {
  display: none;
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 1002;
  width: 40px;
  height: 40px;
  background: var(--bg-sidebar);
  /* border: 1px solid var(--border); */
  border-radius: var(--radius);
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-primary);
  /* box-shadow: var(--shadow); */
  transition: background var(--transition);
}
.hamburger-btn:hover { background: var(--bg-primary); }

/* Sidebar overlay backdrop */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* Table responsive wrapper */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  background:
    linear-gradient(to right, white 20px, transparent 20px),
    linear-gradient(to right, transparent calc(100% - 20px), white calc(100% - 20px)),
    radial-gradient(farthest-side at 0 50%, rgba(0,0,0,0.12), transparent),
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,0.12), transparent);
  background-repeat: no-repeat;
  background-color: white;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}
.table-responsive > .data-table {
  width: auto;
  min-width: 100%;
}
.table-responsive > .data-table th,
.table-responsive > .data-table td {
  white-space: nowrap;
}

/* ── Tablet (≤ 900px) ──────────────────────────────────── */
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .supplier-group-totals { gap: 10px; }
}

/* ── Mobile (≤ 768px) ──────────────────────────────────── */
@media (max-width: 768px) {
  .hamburger-btn { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: var(--sidebar-w);
  }
  .sidebar .brand-name,
  .sidebar .nav-label { opacity: 1; pointer-events: auto; }
  .sidebar.mobile-open {
    transform: translateX(0);
    z-index: 1001;
  }

  .main-content {
    margin-left: 0;
  }

  .top-header {
    padding: 0 14px 0 60px;
  }

  .search-box {
    max-width: none;
  }

  .user-name { display: none; }

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

  .page-content { padding: 16px; }

  .card-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .modal {
    width: 95vw;
    max-height: 85vh;
    margin: 8px;
  }
  .modal-header { padding: 16px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; }

  .btn { min-height: 44px; }

  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0;
  }
  .tab-btn {
    padding: 10px 14px;
    white-space: nowrap;
    font-size: 12px;
  }

  .detail-stats-row {
    grid-template-columns: 1fr 1fr !important;
  }

  .kanban-board {
    min-height: auto;
  }
  .kanban-column {
    min-width: 260px;
  }

  .invoice-stat-card {
    padding: 12px 14px;
    gap: 10px;
  }
  .invoice-stat-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
  .invoice-stat-value {
    font-size: 15px;
  }

  .supplier-group-header {
    flex-wrap: wrap;
    gap: 8px;
  }
  .supplier-group-avatar { order: 1; }
  .supplier-group-info { order: 2; }
  .supplier-group-actions {
    order: 3;
    margin-left: auto;
  }
  .supplier-group-totals {
    order: 4;
    margin-left: 0;
    width: 100%;
    gap: 6px;
  }
  .supplier-group-totals > div {
    padding-left: 0;
    gap: 4px;
    flex-wrap: wrap;
  }

  .bar-row { flex-wrap: wrap; }
  .bar-label { width: auto; flex: 1; }
  .bar-value { width: auto; text-align: left; }

  .bulk-invoice-row { flex-wrap: wrap; }
  .bulk-invoice-amount { width: 100%; margin-top: 4px; }
}

/* ── Small mobile (≤ 480px) ─────────────────────────────── */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-content { padding: 12px; }

  .top-header { padding: 0 10px 0 56px; height: 50px; }
  .hamburger-btn { top: 5px; left: 8px; width: 36px; height: 36px; }

  .page-title { font-size: 17px; }
  .page-subtitle { font-size: 12px; margin-bottom: 16px; }

  .stat-card { padding: 14px; }
  .stat-value { font-size: 20px; }

  .modal { width: 100vw; max-height: 100vh; margin: 0; border-radius: 0; }

  .filter-pills { gap: 6px; }
  .filter-pill { padding: 5px 10px; font-size: 11px; }

  .notif-item { padding: 12px 14px; }

  .detail-stats-row {
    grid-template-columns: 1fr !important;
  }
}

/* ── Utility ─────────────────────────────────────────────── */
.text-accent   { color: var(--accent); }
.text-muted    { color: var(--text-muted); }
.text-secondary{ color: var(--text-secondary); }
.text-right    { text-align: right; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex  { display: flex; }
.items-center { align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.fw-600 { font-weight: 600; }
.hidden { display: none !important; }

/* ── Factures View Custom Structure ── */
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
}
.view-toggle-btn {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  border: none;
  background: none;
  cursor: pointer;
  transition: all var(--transition);
}
.view-toggle-btn.active {
  background: var(--accent);
  color: #ffffff;
}
.view-toggle-btn:not(.active):hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* Stat cards adjustments for factures */
.invoice-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
}
.invoice-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.05);
}
.invoice-stat-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.invoice-stat-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.invoice-stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.invoice-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Grouped View classes */
.supplier-group {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform var(--transition);
}
.supplier-group-header {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  background: var(--bg-card);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}
.supplier-group-header:hover {
  background: var(--bg-card-hover);
}
.supplier-group-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  margin-right: 12px;
  flex-shrink: 0;
}
.supplier-group-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.supplier-group-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}
.supplier-group-count {
  font-size: 11px;
  color: var(--text-muted);
}
.supplier-group-totals {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-wrap: wrap;
  row-gap: 6px;
}
.supplier-group-totals > div {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 100%;
  padding-left: 24px;
}
.supplier-group-totals span {
  white-space: nowrap;
}
.supplier-group-totals .total-label {
  font-weight: 500;
  color: var(--text-muted);
}
.supplier-group-totals .total-val {
  color: var(--text-primary);
  font-weight: 700;
  margin-left: 4px;
}
.supplier-group-totals .val-paid {
  color: #1e8449;
  font-weight: 700;
  margin-left: 4px;
}
.supplier-group-totals .val-remaining {
  color: #d68910;
  font-weight: 700;
  margin-left: 4px;
}
.supplier-group-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 20px;
  flex-shrink: 0;
}
.supplier-group-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all var(--transition);
  background: none;
}
.supplier-group-btn:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--border-light);
}
.supplier-group-body {
  border-top: 1px solid var(--border);
  overflow: hidden;
  max-height: 2000px;
  transition: max-height 0.3s ease-in-out;
}
.supplier-group-body > .table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  /* ombre de défilement : indique qu'il y a du contenu à droite */
  background:
    linear-gradient(to right, white 20px, transparent 20px),
    linear-gradient(to right, transparent calc(100% - 20px), white calc(100% - 20px)),
    radial-gradient(farthest-side at 0 50%, rgba(0,0,0,0.12), transparent),
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,0.12), transparent);
  background-repeat: no-repeat;
  background-color: white;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}
.supplier-group-body > .table-wrap > .data-table {
  width: auto;
  min-width: 100%;
}
.supplier-group-body > .table-wrap > .data-table th,
.supplier-group-body > .table-wrap > .data-table td {
  white-space: nowrap;
}

/* Vue liste : wrapper card avec scroll */
.card[style*="overflow-x"] {
  padding: 0;
}
[style*="overflow-x"] > .data-table {
  width: auto;
  min-width: 100%;
}
[style*="overflow-x"] > .data-table th,
[style*="overflow-x"] > .data-table td {
  white-space: nowrap;
}
.supplier-group.collapsed .supplier-group-body {
  max-height: 0 !important;
  border-top: none;
}
.supplier-group.collapsed .rotate-icon {
  transform: rotate(-90deg);
}
.rotate-icon {
  transition: transform 0.2s ease;
}

/* Filter pills for Flat list view */
.filter-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.filter-pill {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.filter-pill:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}
.filter-pill.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

/* Tasks table: action buttons side by side */
#taskTableView td:last-child {
  display: flex;
  gap: 4px;
  align-items: center;
}

/* Action button icons in table */
.action-icon-btn {
  width: 28px; height: 28px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: all var(--transition);
  margin-right: 4px;
}
.action-icon-btn:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--border-light);
}
.action-icon-btn.delete-btn:hover {
  background: rgba(220,53,69,0.08);
  color: #c0392b;
  border-color: rgba(220,53,69,0.2);
}

/* Dropdown styling for interactive status badge */
.status-dropdown-wrapper {
  position: relative;
  display: inline-block;
}
.status-dropdown-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.status-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  padding: 4px 0;
  margin-top: 4px;
  min-width: 120px;
  display: none;
}
.status-dropdown-menu.open {
  display: block;
}
.status-dropdown-item {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition);
  text-align: left;
}
.status-dropdown-item:hover {
  background: var(--bg-primary);
}

/* ── Search filter (hide rows without breaking pagination) ── */
.filter-hidden { display: none !important; }

/* ── Pagination ──────────────────────────────────────────── */
.pag-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0;
  gap: 4px;
}
.pag-bar .pag-btn:disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}
.pag-info {
  margin: 0 12px;
  font-size: 12px;
  color: var(--text-secondary, #666);
}

/* ── Bulk Payment / Selection ──────────────────────────────── */
.bulk-checkbox,
.select-all-bulk {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #10b981;
}
.bulk-checkbox:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.bulk-selection-bar {
  display: none;
}
.bulk-invoice-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.bulk-invoice-row:last-child {
  border-bottom: none;
}
.bulk-invoice-num {
  font-weight: 600;
  color: var(--accent);
  min-width: 130px;
}
.bulk-invoice-remaining {
  color: var(--text-muted);
  font-size: 12px;
  min-width: 100px;
  text-align: right;
}
.bulk-invoice-amount {
  margin-left: auto;
  width: 140px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  text-align: right;
  outline: none;
  transition: border-color var(--transition);
}
.bulk-invoice-amount:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}


/* Document thumbnails in invoice table */
.doc-thumbnail {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.doc-thumbnail:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.doc-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: color 0.15s, background 0.15s;
}
.doc-link:hover {
  color: var(--primary);
  background: rgba(59,130,246,0.06);
}

/* Document preview in edit modal */
.doc-preview-current {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  padding: 8px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.doc-thumbnail-preview {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.doc-preview-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.doc-preview-link:hover {
  text-decoration: underline;
}
