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

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface2: #f8f9fc;
  --surface3: #f1f3f8;
  --border: #e8e8ed;
  --border-hover: #d1d5db;
  --primary: #6c63ff;
  --primary-end: #8b5cf6;
  --primary-glow: rgba(108,99,255,0.18);
  --primary-light: rgba(108,99,255,0.08);
  --text: #0f0f23;
  --text-muted: #6b7280;
  --text-dim: #9ca3af;
  --danger: #ef4444;
  --danger-light: rgba(239,68,68,0.08);
  --warning: #f59e0b;
  --warning-light: rgba(245,158,11,0.08);
  --success: #10b981;
  --success-light: rgba(16,185,129,0.08);
  --info: #3b82f6;
  --info-light: rgba(59,130,246,0.08);
  --card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 100px;
  --sidebar-w: 60px;
  --header-h: 52px;
  --action-w: 400px;
  --gradient: linear-gradient(135deg, var(--primary) 0%, var(--primary-end) 100%);
  /* Action panel stays dark for contrast */
  --action-bg: #1a1a2e;
  --action-surface: rgba(255,255,255,0.04);
  --action-surface2: rgba(255,255,255,0.07);
  --action-border: rgba(255,255,255,0.08);
  --action-text: #f0f0ff;
  --action-text-muted: rgba(240,240,255,0.6);
  --action-text-dim: rgba(240,240,255,0.3);
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(108,99,255,0.2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(108,99,255,0.4); }

/* ===== HEADER BAR ===== */
.header-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px 0 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.header-logo {
  width: var(--sidebar-w);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  gap: 6px;
}
.logo-icon { font-size: 18px; }
.logo-text {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--text-dim);
  pointer-events: none;
}
.header-search input {
  width: 100%;
  padding: 8px 14px 8px 36px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 200ms, box-shadow 200ms;
}
.header-search input::placeholder { color: var(--text-dim); }
.header-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.1);
  background: #fff;
}

.header-stats {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}
.stat-chip {
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid;
}
.stat-urgent {
  background: rgba(239,68,68,0.08);
  border-color: rgba(239,68,68,0.25);
  color: #dc2626;
}
.stat-todo {
  background: rgba(245,158,11,0.08);
  border-color: rgba(245,158,11,0.25);
  color: #d97706;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-compose-header {
  padding: 6px 16px;
  background: var(--gradient);
  color: white;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 2px 8px var(--primary-glow);
  transition: all 150ms;
}
.btn-compose-header:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--primary-glow);
}
.btn-contacts-header, .btn-logout-header, .btn-settings-header {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: all 150ms;
}
.btn-contacts-header:hover, .btn-settings-header:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-logout-header:hover { border-color: rgba(239,68,68,0.4); color: var(--danger); background: var(--danger-light); }

/* ===== APP BODY ===== */
.app-body {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--action-w);
  height: 100vh;
  padding-top: var(--header-h);
  min-height: 0;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  background: #ffffff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  position: relative;
  z-index: 50;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; align-items: center; width: 100%; }

.nav-item {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  transition: all 150ms;
  color: var(--text-dim);
}
.nav-item:hover {
  background: var(--surface3);
  color: var(--text-muted);
}
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  box-shadow: 0 0 0 1px rgba(108,99,255,0.2);
}
.nav-icon { font-size: 18px; line-height: 1; }
.nav-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 1.5px solid #ffffff;
  display: none;
}
.nav-badge.visible { display: block; }

.nav-divider {
  width: 32px;
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

/* Label flyout */
.label-flyout {
  position: absolute;
  left: calc(var(--sidebar-w) + 4px);
  top: 0;
  width: 200px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 0;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
.label-flyout-title {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  padding: 0 14px 8px;
}
.label-flyout .label-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  transition: all 150ms;
}
.label-flyout .label-item:hover {
  background: var(--surface2);
  color: var(--text);
}
.label-unread {
  background: var(--primary);
  color: white;
  border-radius: var(--radius-pill);
  padding: 1px 6px;
  font-size: 9px;
  font-weight: 700;
}

/* ===== SWIMLANES ZONE ===== */
.swimlanes-zone {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px;
  gap: 12px;
  background: var(--bg);
  min-height: 0;
  flex: 1;
}

.zone-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.zone-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}
.btn-refresh {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: #ffffff;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  transition: all 150ms;
  line-height: 1;
}
.btn-refresh:hover { border-color: var(--primary); color: var(--primary); transform: rotate(180deg); }

/* ===== FILTRE RAPIDE ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.filter-chip {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--surface2);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 140ms;
  white-space: nowrap;
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary); background: #eff6ff; }
.filter-chip.active { border-color: var(--primary); color: var(--primary); background: #eff6ff; font-weight: 600; }
.filter-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1.5px solid var(--primary);
  border-radius: 100px;
  padding: 3px 10px;
  flex: 1;
  min-width: 200px;
  max-width: 380px;
}
.filter-input {
  border: none;
  outline: none;
  font-size: 13px;
  background: transparent;
  color: var(--text);
  flex: 1;
  min-width: 0;
}
.filter-search-btn {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  padding: 2px 4px;
  border-radius: 4px;
  white-space: nowrap;
}
.filter-search-btn:hover { background: #eff6ff; }
.filter-clear-btn {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
}
.filter-clear-btn:hover { color: var(--danger); }
.filter-active-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #eff6ff;
  border: 1px solid var(--primary);
  border-radius: 100px;
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
}
.filter-active-pill button {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--primary);
  font-size: 13px;
  padding: 0;
  line-height: 1;
}
.filter-save-btn {
  padding: 5px 12px;
  border: 1px dashed var(--primary);
  border-radius: 100px;
  background: transparent;
  color: var(--primary);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 140ms;
  white-space: nowrap;
}
.filter-save-btn:hover { background: #eff6ff; }
/* Cards masquées par le filtre */
.mail-card.filter-hidden { display: none !important; }

.swimlanes {
  display: grid;
  grid-template-columns: repeat(5, minmax(190px, 1fr));
  gap: 10px;
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  min-height: 0;
}

/* ===== SWIMLANE ===== */
.swimlane {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 0;
  max-height: 100%;
  box-shadow: var(--card-shadow);
}

.lane-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.lane-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.lane-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  flex: 1;
}
.lane-count {
  font-size: 11px;
  font-weight: 700;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Lane header colors */
.lane-urgent { background: rgba(239,68,68,0.04); }
.lane-urgent .lane-dot { background: #ef4444; }
.lane-urgent .lane-title { color: #dc2626; }
.lane-urgent .lane-count { background: rgba(239,68,68,0.1); color: #dc2626; }

.lane-todo { background: rgba(245,158,11,0.04); }
.lane-todo .lane-dot { background: #f59e0b; }
.lane-todo .lane-title { color: #d97706; }
.lane-todo .lane-count { background: rgba(245,158,11,0.1); color: #d97706; }

.lane-info { background: rgba(59,130,246,0.04); }
.lane-info .lane-dot { background: #3b82f6; }
.lane-info .lane-title { color: #2563eb; }
.lane-info .lane-count { background: rgba(59,130,246,0.1); color: #2563eb; }

.lane-docs { background: rgba(245,158,11,0.04); }
.lane-docs .lane-dot { background: #f59e0b; }
.lane-docs .lane-title { color: #b45309; }
.lane-docs .lane-count { background: rgba(245,158,11,0.12); color: #b45309; }

.lane-archive { background: rgba(59,130,246,0.04); }
.lane-archive .lane-dot { background: #3b82f6; }
.lane-archive .lane-title { color: #1d4ed8; }
.lane-archive .lane-count { background: rgba(59,130,246,0.12); color: #1d4ed8; }

.lane-done { background: rgba(124,58,237,0.04); }
.lane-auto { background: rgba(124,58,237,0.04); }
.lane-auto .lane-dot { background: #7c3aed; }
.lane-auto .lane-title { color: #7c3aed; }
.lane-auto .lane-count { background: rgba(124,58,237,0.12); color: #7c3aed; }

/* Lane cards container */
.lane-cards {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #f8f9fc;
}
.lane-cards::-webkit-scrollbar { width: 3px; }
.lane-cards::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); }

/* ===== MAIL CARD ===== */
.mail-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  cursor: pointer;
  transition: all 200ms ease;
  position: relative;
  overflow: hidden;
  animation: cardEnter 300ms ease both;
  box-shadow: var(--card-shadow);
  border-left-width: 3px;
}
.mail-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: var(--card-shadow-hover);
}

/* Colored left border by lane */
#lane-urgent  .mail-card { border-left-color: rgba(239,68,68,0.3); }
#lane-urgent  .mail-card:hover { border-left-color: #ef4444; }
#lane-todo    .mail-card { border-left-color: rgba(245,158,11,0.3); }
#lane-todo    .mail-card:hover { border-left-color: #f59e0b; }
#lane-docs    .mail-card { border-left-color: rgba(245,158,11,0.4); }
#lane-docs    .mail-card:hover { border-left-color: #d97706; }
#lane-archive .mail-card { border-left-color: rgba(59,130,246,0.3); }
#lane-archive .mail-card:hover { border-left-color: #3b82f6; }
#lane-info    .mail-card { border-left-color: rgba(107,114,128,0.3); }
#lane-info    .mail-card:hover { border-left-color: #6b7280; }
#lane-done    .mail-card { border-left-color: rgba(124,58,237,0.3); }
#lane-done    .mail-card:hover { border-left-color: #7c3aed; }

/* Unread state */
.mail-card.unread { background: #fafafe; border-left-width: 4px; }
#lane-urgent  .mail-card.unread { border-left-color: #ef4444; }
#lane-todo    .mail-card.unread { border-left-color: #f59e0b; }
#lane-docs    .mail-card.unread { border-left-color: #d97706; }
#lane-archive .mail-card.unread { border-left-color: #3b82f6; }
#lane-info    .mail-card.unread { border-left-color: #6b7280; }
#lane-done    .mail-card.unread { border-left-color: #7c3aed; }

/* Drag & drop */
.mail-card.dragging {
  opacity: 0.4;
  transform: scale(0.97);
  cursor: grabbing;
}
.droppable.drag-over {
  background: rgba(108,99,255,0.07) !important;
  border: 2px dashed rgba(108,99,255,0.4);
  border-radius: 8px;
}
.card-drag-handle {
  position: absolute;
  top: 50%;
  right: 7px;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--border);
  cursor: grab;
  opacity: 0;
  transition: opacity 150ms;
  letter-spacing: -2px;
  z-index: 2;
}
.mail-card:hover .card-drag-handle { opacity: 1; }

/* Boutons d'action rapide sur la card */
.card-quick-actions {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 150ms;
  z-index: 2;
}
.mail-card:hover .card-quick-actions { opacity: 1; }

.card-action-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 120ms;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 0;
}
.card-action-btn:hover { transform: scale(1.12); box-shadow: 0 2px 6px rgba(0,0,0,0.14); }
.card-action-archive:hover { background: #dbeafe; border-color: #93c5fd; }
.card-action-urgent:hover  { background: #fee2e2; border-color: #fca5a5; }

.mail-card.active {
  border-color: var(--primary) !important;
  background: var(--primary-light);
  box-shadow: 0 0 0 1px rgba(108,99,255,0.2), var(--card-shadow);
}

/* Card content */
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  gap: 6px;
}
.card-priority-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.priority-urgent .card-priority-dot { background: #ef4444; }
.priority-todo .card-priority-dot { background: #f59e0b; }
.priority-info .card-priority-dot { background: #3b82f6; }
.priority-done .card-priority-dot { background: #10b981; }

.card-sender {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mail-card.unread .card-sender { font-weight: 700; }

.card-date {
  font-size: 10px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.card-subject {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.mail-card.unread .card-subject { color: var(--text); font-weight: 600; }

.card-snippet {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.card-attachment {
  font-size: 10px;
  color: var(--text-dim);
  background: var(--surface3);
  border-radius: 4px;
  padding: 1px 5px;
}
.card-label {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  font-size: 9px;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(108,99,255,0.2);
  white-space: nowrap;
}
.card-label.lbl-urgent { background: var(--danger-light); color: #dc2626; border-color: rgba(239,68,68,0.2); }
.card-label.lbl-traite { background: var(--success-light); color: #059669; border-color: rgba(16,185,129,0.2); }
.card-label.lbl-facture { background: var(--warning-light); color: #d97706; border-color: rgba(245,158,11,0.2); }

/* Staggered animation */
@keyframes cardEnter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.mail-card:nth-child(1) { animation-delay: 0ms; }
.mail-card:nth-child(2) { animation-delay: 40ms; }
.mail-card:nth-child(3) { animation-delay: 80ms; }
.mail-card:nth-child(4) { animation-delay: 120ms; }
.mail-card:nth-child(5) { animation-delay: 160ms; }
.mail-card:nth-child(6) { animation-delay: 200ms; }
.mail-card:nth-child(7) { animation-delay: 240ms; }
.mail-card:nth-child(8) { animation-delay: 280ms; }

/* Lane empty state */
.lane-empty {
  text-align: center;
  padding: 24px 12px;
  color: var(--text-dim);
  font-size: 12px;
  animation: cardEnter 300ms ease both;
}
.lane-empty-icon { font-size: 28px; opacity: 0.4; margin-bottom: 8px; }

/* Load more */
.btn-load-more {
  padding: 8px 22px;
  border: 1px solid var(--border);
  background: #ffffff;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 12px;
  color: var(--primary);
  font-family: inherit;
  font-weight: 500;
  transition: all 150ms;
  box-shadow: var(--card-shadow);
}
.btn-load-more:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

/* ===== MAIL VIEW ZONE (in-place split, replaces swimlanes) ===== */
#mail-view-zone {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 10;
}

.swimlanes-zone { position: relative; }

.mail-view-zone-header {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
  flex-shrink: 0;
}

.btn-back-swimlanes {
  padding: 5px 14px;
  border: 1px solid var(--border);
  background: var(--surface2);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
  transition: all 150ms;
}
.btn-back-swimlanes:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

#mail-view-zone-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  background: #ffffff;
}

#mail-view-zone-body .mail-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#mail-view-zone-body .mail-view-body {
  flex: 1;
  overflow-y: auto;
}

/* Analyze IA button in action panel */
.btn-analyze-ia {
  padding: 13px 22px;
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 150ms;
  box-shadow: 0 3px 14px rgba(124,58,237,0.4);
  width: 100%;
}
.btn-analyze-ia:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 20px rgba(124,58,237,0.5);
}
.btn-analyze-ia:active { transform: translateY(0); }

/* ===== MAIL OVERLAY ===== */
.mail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,15,35,0.5);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.mail-overlay-content {
  width: 720px;
  max-width: 95vw;
  max-height: 88vh;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  animation: overlayIn 250ms ease both;
}
@keyframes overlayIn {
  from { opacity: 0; transform: scale(0.97) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.mail-overlay-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  transition: all 150ms;
  z-index: 10;
}
.mail-overlay-close:hover { color: var(--text); background: var(--surface3); }

/* Mail view inside overlay */
.mail-view { display: flex; flex-direction: column; height: 100%; }
.mail-view-header {
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.mail-view-subject {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.3;
  padding-right: 40px;
}
.mail-view-meta { display: flex; justify-content: space-between; align-items: flex-start; }
.mail-view-from { font-size: 12px; color: var(--text-muted); }
.mail-view-from strong { color: var(--text); font-weight: 600; }
.mail-view-date { font-size: 11px; color: var(--text-dim); }

.mail-view-actions {
  display: flex;
  gap: 6px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  background: #ffffff;
}
.btn-action {
  padding: 5px 12px;
  border: 1px solid var(--border);
  background: var(--surface2);
  border-radius: var(--radius-pill);
  font-size: 12px;
  cursor: pointer;
  transition: all 150ms;
  color: var(--text-muted);
  font-family: inherit;
}
.btn-action:hover { background: var(--surface3); border-color: var(--border-hover); color: var(--text); }
.btn-action.danger:hover { border-color: rgba(239,68,68,0.3); color: var(--danger); background: var(--danger-light); }

.mail-view-attachments {
  display: flex;
  gap: 6px;
  padding: 8px 22px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.attachment-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  background: var(--primary-light);
  border-radius: var(--radius-pill);
  font-size: 11px;
  cursor: pointer;
  border: 1px solid rgba(108,99,255,0.2);
  color: var(--primary);
  transition: background 150ms;
}
.attachment-chip:hover { background: rgba(108,99,255,0.14); }

.mail-view-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  background: #ffffff;
}
.mail-iframe {
  width: 100%;
  border: none;
  display: block;
  min-height: 300px;
  background: #fff;
}

/* Reply section */
.mail-view-reply { border-top: 1px solid var(--border); padding: 12px 18px; background: var(--surface2); }
.reply-box { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: #ffffff; }
.reply-body {
  min-height: 80px;
  max-height: 160px;
  overflow-y: auto;
  padding: 10px 14px;
  outline: none;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  font-family: inherit;
}
.reply-body:empty:before { content: attr(placeholder); color: var(--text-dim); }
.reply-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
}
.reply-toolbar {
  display: flex;
  gap: 6px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.reply-toolbar .btn-action { background: transparent; }

/* ===== ACTION PANEL (dark) ===== */
.action-panel {
  background: var(--action-bg);
  border-left: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.action-panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--action-border);
  font-weight: 600;
  font-size: 12px;
  background: rgba(255,255,255,0.03);
  color: var(--action-text-muted);
  letter-spacing: 0.3px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.btn-extract-pj {
  font-size: 11px;
  padding: 4px 9px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 100px;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  transition: all 140ms;
  white-space: nowrap;
  font-weight: 500;
}
.btn-extract-pj:hover { background: rgba(255,255,255,0.18); color: #fff; border-color: rgba(255,255,255,0.4); }
#action-panel-content { flex: 1; overflow-y: auto; }
.action-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--action-text-dim);
  text-align: center;
  padding: 24px;
  font-size: 12px;
  line-height: 1.6;
}

/* Analysis blocks */
.analysis-block { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.analysis-priority {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  background: var(--action-surface);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--action-border);
  color: var(--action-text);
}
.type-badge {
  background: var(--action-surface2);
  color: var(--action-text-muted);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 500;
  border: 1px solid var(--action-border);
}
.analysis-section {
  background: var(--action-surface);
  border: 1px solid var(--action-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.analysis-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--action-text-dim);
  letter-spacing: 0.8px;
  margin-bottom: 6px;
}
.analysis-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.analysis-text { font-size: 12px; color: var(--action-text-muted); line-height: 1.5; }
.analysis-actions { padding-left: 16px; font-size: 12px; color: var(--action-text-muted); line-height: 1.8; }

.draft-textarea {
  width: 100%;
  background: var(--action-surface2);
  border: 1px solid var(--action-border);
  border-radius: var(--radius-sm);
  color: var(--action-text);
  font-size: 12px;
  padding: 10px;
  resize: vertical;
  min-height: 120px;
  outline: none;
  font-family: inherit;
  line-height: 1.5;
  margin-bottom: 8px;
  transition: border-color 150ms;
}
.draft-textarea:focus { border-color: rgba(108,99,255,0.5); }

.draft-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.draft-actions-secondary { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

/* Gros bouton Valider & Envoyer */
.btn-validate-send {
  width: 100%;
  padding: 13px 18px;
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 150ms;
  box-shadow: 0 3px 12px rgba(22,163,74,0.35);
  margin-top: 8px;
  letter-spacing: 0.3px;
}
.btn-validate-send:hover { transform: translateY(-1px); box-shadow: 0 5px 18px rgba(22,163,74,0.45); }
.btn-validate-send:active { transform: translateY(0); }

/* Banner auto IA */
.auto-ia-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, rgba(124,58,237,0.15) 0%, rgba(124,58,237,0.08) 100%);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 4px;
}
.auto-ia-icon { font-size: 20px; }
.auto-ia-text { flex: 1; }
.auto-ia-text strong { display: block; font-size: 12px; color: #c4b5fd; font-weight: 700; }
.auto-ia-text span { display: block; font-size: 11px; color: rgba(196,181,253,0.7); margin-top: 2px; }
.btn-auto-send {
  padding: 7px 14px;
  background: #7c3aed;
  color: white;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: all 150ms;
}
.btn-auto-send:hover { background: #6d28d9; transform: translateY(-1px); }

.btn-send-draft {
  flex: 1;
  padding: 8px 14px;
  background: var(--gradient);
  color: white;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 150ms;
  box-shadow: 0 2px 8px var(--primary-glow);
}
.btn-send-draft:hover { transform: translateY(-1px); box-shadow: 0 4px 14px var(--primary-glow); }
.btn-improve-draft {
  padding: 8px 12px;
  background: var(--action-surface2);
  color: var(--action-text-muted);
  border: 1px solid var(--action-border);
  border-radius: var(--radius-pill);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 150ms;
}
.btn-improve-draft:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.15); }
.btn-secondary-sm {
  padding: 7px 12px;
  background: var(--action-surface2);
  color: var(--action-text-muted);
  border: 1px solid var(--action-border);
  border-radius: var(--radius-pill);
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  transition: all 150ms;
}
.btn-secondary-sm:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.15); color: var(--action-text); }

.template-badge {
  background: rgba(16,185,129,0.15);
  color: #34d399;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  border: 1px solid rgba(16,185,129,0.25);
}

/* Auto-response badge */
.auto-response-badge {
  background: rgba(245,158,11,0.15);
  color: #fbbf24;
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 150ms;
}
.auto-response-badge:hover { background: rgba(245,158,11,0.2); }

/* Context rule badge */
.context-rule-badge {
  background: rgba(108,99,255,0.15);
  color: #a5b4fc;
  border: 1px solid rgba(108,99,255,0.25);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 10px;
  font-weight: 500;
  margin-bottom: 4px;
}

.ai-mini-input {
  width: 100%;
  background: var(--action-surface2);
  border: 1px solid var(--action-border);
  border-radius: var(--radius-sm);
  color: var(--action-text);
  font-size: 12px;
  padding: 8px;
  resize: none;
  outline: none;
  font-family: inherit;
  margin-top: 4px;
  transition: border-color 150ms;
}
.ai-mini-input::placeholder { color: var(--action-text-dim); }
.ai-mini-input:focus { border-color: rgba(108,99,255,0.5); }

.ai-custom-response {
  background: var(--action-surface2);
  border: 1px solid var(--action-border);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 12px;
  color: var(--action-text-muted);
  line-height: 1.5;
  margin-top: 8px;
}

/* Badges */
.already-replied-badge {
  background: rgba(16,185,129,0.1);
  color: #34d399;
  border: 1px solid rgba(16,185,129,0.2);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
}
.not-replied-badge {
  background: rgba(245,158,11,0.1);
  color: #fbbf24;
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
}
.cc-badge {
  background: rgba(59,130,246,0.1);
  color: #93c5fd;
  border: 1px solid rgba(59,130,246,0.2);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
}

/* Related mails */
.relance-section { border-color: rgba(239,68,68,0.25) !important; }
.related-mails-list { display: flex; flex-direction: column; gap: 5px; margin-top: 4px; }
.related-mail {
  background: var(--action-surface2);
  border: 1px solid var(--action-border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  cursor: pointer;
  transition: border-color 150ms;
}
.related-mail:hover { border-color: rgba(108,99,255,0.4); }
.related-mail-subject { font-size: 11px; font-weight: 600; color: var(--action-text); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.related-mail-snippet { font-size: 10px; color: var(--action-text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.related-mail-date { font-size: 10px; color: var(--action-text-dim); margin-top: 2px; }

/* Thread */
.thread-msg {
  background: var(--action-surface2);
  border: 1px solid var(--action-border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: border-color 150ms;
}
.thread-msg:hover { border-color: rgba(108,99,255,0.4); }

/* SPINNER */
.spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--action-border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* VOICE */
.btn-voice.recording {
  background: var(--danger-light) !important;
  color: var(--danger) !important;
  border-color: var(--danger) !important;
  animation: pulse 1s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
.voice-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10000;
  background: var(--danger); color: white;
  text-align: center; padding: 6px;
  font-size: 13px; font-weight: 600;
  animation: pulse 1s infinite;
}
.voice-interim {
  font-size: 11px; color: var(--action-text-dim); font-style: italic;
  padding: 4px 8px; background: var(--action-surface2);
  border-radius: var(--radius-sm); margin-top: 4px;
  border-left: 2px solid var(--primary);
}

/* TOAST */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text);
  color: #ffffff;
  border: 1px solid rgba(255,255,255,0.1);
  padding: 9px 20px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  z-index: 9999;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

/* LOADING */
.loading { text-align: center; padding: 36px; color: var(--text-dim); font-size: 12px; }

/* ===== MODALS ===== */
.modal {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15,15,35,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal-content {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  color: var(--text);
}
.compose-modal { width: 600px; max-height: 80vh; }
.download-modal { width: 440px; }
.templates-modal { width: 820px; max-height: 85vh; }
.contacts-modal { width: 820px; max-height: 85vh; }
.settings-modal { width: 860px; max-height: 88vh; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  background: var(--surface2);
  border-radius: 16px 16px 0 0;
}
.btn-close {
  background: none; border: none; font-size: 16px; cursor: pointer;
  color: var(--text-muted); width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; transition: all 150ms;
}
.btn-close:hover { background: var(--surface3); color: var(--text); }

.compose-fields { padding: 0 18px; }
.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  padding: 9px 0;
}
.field-row label { width: 60px; font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.field-row input, .field-row select {
  flex: 1; border: none; outline: none;
  font-size: 13px; background: transparent; color: var(--text); font-family: inherit;
}
.field-row select option { background: #ffffff; color: var(--text); }

.compose-body {
  flex: 1; padding: 14px 18px;
  min-height: 160px; max-height: 280px; overflow-y: auto;
  outline: none; font-size: 13px; line-height: 1.6; color: var(--text);
}
.compose-body:empty:before { content: "Rédigez votre message..."; color: var(--text-dim); }

.download-form { padding: 14px 18px; display: flex; flex-direction: column; gap: 8px; }
.modal-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 12px 18px; border-top: 1px solid var(--border);
  background: var(--surface2);
  border-radius: 0 0 16px 16px;
}

/* Templates & Contacts modals */
.templates-body {
  display: grid; grid-template-columns: 1fr 1fr;
  flex: 1; overflow: hidden;
  max-height: calc(85vh - 52px);
}
.templates-left { padding: 16px; border-right: 1px solid var(--border); overflow-y: auto; }
.templates-right { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.templates-section-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  color: var(--text-dim); margin-bottom: 10px; letter-spacing: 0.8px;
}
.template-item {
  padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 8px;
  background: var(--surface2); transition: border-color 150ms;
}
.template-item:hover { border-color: var(--primary); }
.template-item-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px; font-size: 13px; color: var(--text);
}
.btn-icon-sm { background: none; border: none; cursor: pointer; font-size: 13px; padding: 2px 4px; transition: opacity 150ms; }
.btn-icon-sm:hover { opacity: 0.7; }

.field-col { display: flex; flex-direction: column; gap: 4px; }
.field-col label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.field-col input, .field-col textarea, .field-col select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px;
  font-size: 13px; outline: none; font-family: inherit;
  background: var(--surface2); color: var(--text); transition: border-color 150ms;
}
.field-col input:focus, .field-col textarea:focus, .field-col select:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(108,99,255,0.08); }
.field-col textarea { resize: vertical; }
.field-col select option { background: #ffffff; }

/* Buttons */
.btn-primary {
  padding: 9px 20px; background: var(--gradient); color: white;
  border: none; border-radius: var(--radius-pill); font-size: 13px;
  font-weight: 600; cursor: pointer; font-family: inherit; transition: all 150ms;
  box-shadow: 0 2px 8px var(--primary-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 14px var(--primary-glow); }
.btn-secondary {
  padding: 9px 18px; background: var(--surface2); color: var(--text-muted);
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  font-size: 13px; cursor: pointer; font-family: inherit; transition: all 150ms;
}
.btn-secondary:hover { background: var(--surface3); color: var(--text); border-color: var(--border-hover); }
.btn-danger {
  padding: 9px 18px; background: var(--danger-light); color: var(--danger);
  border: 1px solid rgba(239,68,68,0.2); border-radius: var(--radius-pill);
  font-size: 13px; cursor: pointer; font-family: inherit; transition: all 150ms;
}
.btn-danger:hover { background: rgba(239,68,68,0.15); }
.btn-attach {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-pill); font-size: 12px; cursor: pointer;
  color: var(--text-muted); transition: all 150ms; background: var(--surface2);
}
.btn-attach:hover { border-color: var(--primary); color: var(--primary); }

/* Contacts modal */
.contacts-body {
  display: grid; grid-template-columns: 1fr 1fr;
  flex: 1; overflow: hidden;
  max-height: calc(85vh - 52px);
}
.contacts-left { padding: 16px; border-right: 1px solid var(--border); overflow-y: auto; }
.contacts-right { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.contact-item {
  padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 6px;
  cursor: pointer; transition: all 150ms; background: var(--surface2);
}
.contact-item:hover { border-color: var(--primary); background: var(--primary-light); }

/* ===== SETTINGS MODAL ===== */
.settings-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  max-height: calc(88vh - 52px);
}
.settings-tabs {
  display: flex;
  gap: 2px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.settings-tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  transition: all 150ms;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  font-family: inherit;
}
.settings-tab:hover { color: var(--text); }
.settings-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.settings-panel { flex: 1; overflow-y: auto; padding: 20px; display: none; }
.settings-panel.active { display: block; }

.settings-list-item {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--surface2);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.settings-list-item-info { flex: 1; min-width: 0; }
.settings-list-item-name { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.settings-list-item-desc { font-size: 11px; color: var(--text-muted); }
.settings-list-item-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }

.settings-form {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface2);
  margin-top: 12px;
}
.settings-form-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.8px;
  margin-bottom: 12px;
}
.settings-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.style-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.style-card-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.style-card-value {
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
}

/* ===== BIENS MODAL ===== */
.biens-modal {
  width: 90vw;
  max-width: 1200px;
  height: 90vh;
  overflow: hidden;
}
.biens-body {
  display: flex;
  flex: 1;
  height: calc(90vh - 52px);
  overflow: hidden;
}
.biens-left {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface2);
}
.biens-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.bien-item {
  padding: 9px 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  margin-bottom: 3px;
  transition: all 150ms;
}
.bien-item:hover { background: var(--surface3); }
.bien-item.active { background: var(--primary-light); border-color: var(--primary-glow); }
.bien-item-ref {
  font-size: 10px;
  font-weight: 700;
  font-family: monospace;
  color: var(--primary);
  margin-bottom: 2px;
}
.bien-item-adresse {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bien-item-meta {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
  margin-top: 2px;
  align-items: center;
}
.bien-type-chip {
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 1px 6px;
  font-size: 10px;
  color: var(--text-muted);
}
.biens-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 0 0;
  overflow-x: auto;
}
.biens-tab {
  padding: 6px 12px;
  border: none;
  background: none;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  white-space: nowrap;
  transition: all 150ms;
  border-bottom: 2px solid transparent;
  font-family: inherit;
}
.biens-tab:hover { background: var(--surface3); color: var(--text); }
.biens-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* Biens tab content tables */
.biens-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.biens-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.biens-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.biens-table tr:last-child td { border-bottom: none; }
.biens-table tr:hover td { background: var(--surface2); }

.statut-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 600;
}
.statut-en_cours { background: rgba(245,158,11,0.12); color: #d97706; }
.statut-termine { background: var(--success-light); color: var(--success); }
.statut-annule { background: var(--danger-light); color: var(--danger); }
.statut-paye { background: var(--success-light); color: var(--success); }
.statut-en_attente { background: rgba(245,158,11,0.12); color: #d97706; }
.statut-impaye { background: var(--danger-light); color: var(--danger); }

.biens-add-form {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 12px;
}
.biens-add-form-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

/* Lier mail section in action panel */
.link-bien-section {
  background: var(--action-surface2);
  border: 1px solid var(--action-border);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-top: 6px;
}
.link-bien-results {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.link-bien-result-item {
  background: var(--action-surface);
  border: 1px solid var(--action-border);
  border-radius: 6px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.link-bien-result-addr {
  font-size: 11px;
  color: var(--action-text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Responsive horizontal scroll for small screens */
@media (max-width: 1100px) {
  .swimlanes {
    grid-template-columns: repeat(4, minmax(200px, 1fr));
    overflow-x: auto;
  }
  :root { --action-w: 320px; }
}
@media (max-width: 860px) {
  :root { --action-w: 0px; }
  .action-panel { display: none; }
}

/* ===== BIEN DETECTION PANEL ===== */
.action-bien-section {
  background: var(--action-surface);
  border: 1px solid var(--action-border);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 12px 0 0;
}
.action-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--action-text-muted);
  margin-bottom: 8px;
}
.bien-detected-card {
  background: var(--action-surface2);
  border-radius: 8px;
  padding: 10px;
}
.bien-detected-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.bien-ref-badge {
  background: var(--primary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.5px;
}
.bien-confidence {
  font-size: 10px;
  font-weight: 600;
}
.bien-detected-adresse {
  font-size: 12px;
  color: var(--action-text);
  margin-bottom: 8px;
  line-height: 1.4;
}
.bien-detected-actions {
  display: flex;
  gap: 6px;
}
.btn-bien-confirm {
  flex: 1;
  padding: 5px 10px;
  background: #10b981;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 120ms;
}
.btn-bien-confirm:hover { background: #059669; }
.btn-bien-change {
  padding: 5px 10px;
  background: var(--action-surface);
  color: var(--action-text-muted);
  border: 1px solid var(--action-border);
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  transition: all 120ms;
}
.btn-bien-change:hover { color: var(--action-text); border-color: rgba(255,255,255,0.2); }
.bien-not-found {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.bien-search-field {
  width: 100%;
  padding: 7px 10px;
  background: var(--action-surface2);
  border: 1px solid var(--action-border);
  border-radius: 6px;
  color: var(--action-text);
  font-size: 12px;
  font-family: inherit;
  outline: none;
  margin-bottom: 6px;
}
.bien-search-field:focus { border-color: var(--primary); }
.bien-search-result {
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 11px;
  color: var(--action-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 120ms;
}
.bien-search-result:hover { background: var(--action-surface2); }
.spinner-sm {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

/* ===== AGENTS ===== */
.agents-list-modal {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 300px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 20px rgba(0,0,0,0.10);
  z-index: 10;
  display: flex;
  flex-direction: column;
  animation: slideInLeft 180ms ease;
}
@keyframes slideInLeft {
  from { transform: translateX(-100%); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}
.agents-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.agents-modal-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.agents-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
}
.agents-modal-close:hover { background: var(--surface3); }
.agents-modal-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.agent-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: box-shadow 150ms, background 150ms;
  border-left-width: 4px;
  position: relative;
}
.agent-card:hover { background: var(--surface2); box-shadow: var(--card-shadow-hover); }
.agent-card-icon { font-size: 20px; flex-shrink: 0; }
.agent-card-body { flex: 1; min-width: 0; }
.agent-card-name { font-size: 13px; font-weight: 600; color: var(--text); }
.agent-card-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-card-del {
  background: none; border: none; cursor: pointer; color: var(--text-dim);
  font-size: 13px; padding: 2px 4px; border-radius: 4px; opacity: 0; transition: opacity 100ms;
}
.agent-card:hover .agent-card-del { opacity: 1; }
.agent-card-del:hover { color: var(--danger); }

.agents-modal-create {
  border-top: 1px solid var(--border);
  padding: 10px 12px 14px;
}
.agents-create-toggle {
  font-size: 12px; font-weight: 600; color: var(--primary); cursor: pointer;
  padding: 4px 0;
}
.agents-create-toggle:hover { opacity: 0.8; }
.agents-form-row { display: flex; gap: 6px; margin-bottom: 6px; }
.agents-form-emoji {
  width: 48px; text-align: center; font-size: 18px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 4px; outline: none;
}
.agents-form-emoji:focus { border-color: var(--primary); }
.agents-form-input {
  flex: 1; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px 8px; font-size: 12px; outline: none; color: var(--text);
  background: var(--surface);
}
.agents-form-input:focus { border-color: var(--primary); }
.agents-form-textarea {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px 8px; font-size: 11px; outline: none; resize: vertical;
  font-family: inherit; color: var(--text); background: var(--surface);
}
.agents-form-textarea:focus { border-color: var(--primary); }
.agents-form-colors {
  display: flex; gap: 8px; margin: 8px 0 6px;
}
.agents-color-pick {
  width: 20px; height: 20px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: border-color 100ms;
}
.agents-color-pick.selected { border-color: var(--text); }
.agents-form-submit {
  width: 100%; padding: 7px; background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius-sm); font-size: 12px; font-weight: 600;
  cursor: pointer; margin-top: 4px;
}
.agents-form-submit:hover { opacity: 0.88; }

/* Agents view zone */
.agents-view-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.agents-view-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

/* Agent mail table */
.agent-mail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.agent-mail-table thead th {
  position: sticky; top: 0;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  z-index: 2;
}
.agent-mail-table tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 100ms;
}
.agent-mail-table tbody tr:nth-child(even) { background: var(--surface2); }
.agent-mail-table tbody tr:hover { background: var(--primary-light); }
.agent-mail-table td {
  padding: 9px 10px;
  vertical-align: middle;
}
.agent-mail-date { width: 130px; color: var(--text-muted); white-space: nowrap; font-size: 12px; }
.agent-mail-from { width: 160px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.agent-mail-subject { color: var(--text); }
.agent-mail-attach { width: 32px; text-align: center; color: var(--text-muted); }
.agent-mail-actions { width: 130px; }
.agent-mail-actions-btns { display: flex; gap: 4px; }
.btn-agent-open, .btn-agent-archive {
  font-size: 11px; padding: 3px 8px; border-radius: 4px; border: 1px solid var(--border);
  cursor: pointer; background: var(--surface); color: var(--text); white-space: nowrap;
}
.btn-agent-open:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-agent-archive:hover { background: var(--surface3); }
.agents-view-count {
  font-size: 12px; color: var(--text-muted); background: var(--surface3);
  padding: 2px 10px; border-radius: var(--radius-pill); margin-left: auto;
}
.agents-view-title {
  font-size: 15px; font-weight: 700; color: var(--text);
}
.agents-view-desc {
  font-size: 12px; color: var(--text-muted);
}
.agents-view-reload {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 10px; cursor: pointer; font-size: 13px; color: var(--text-muted);
}
.agents-view-reload:hover { background: var(--surface3); }
.agents-loading {
  text-align: center; padding: 60px 20px; color: var(--text-muted); font-size: 14px;
}

/* ===== GED INDEXATION ===== */
.ged-index-section {
  padding: 4px 0 8px;
}
.btn-index-ged {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  background: rgba(13, 101, 45, 0.15);
  border: 1px solid rgba(13, 101, 45, 0.3);
  border-radius: 10px;
  color: #4ade80;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 150ms;
  text-align: left;
}
.btn-index-ged:hover:not(:disabled) {
  background: rgba(13, 101, 45, 0.25);
  border-color: rgba(74, 222, 128, 0.4);
}
.btn-index-ged:disabled { opacity: 0.6; cursor: default; }
.ged-btn-icon { font-size: 18px; }

.ged-indexed-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid;
  border-radius: 10px;
  margin-top: 6px;
}
.btn-open-ged {
  margin-left: auto;
  padding: 4px 10px;
  background: var(--action-surface2);
  border: 1px solid var(--action-border);
  border-radius: 6px;
  color: var(--action-text-muted);
  font-size: 11px;
  text-decoration: none;
  white-space: nowrap;
  transition: all 120ms;
}
.btn-open-ged:hover { color: var(--action-text); }

/* ===== MODAL EXTRACTION PJ IA ===== */
.extract-pj-modal {
  max-width: 600px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.extract-pj-body { flex: 1; overflow-y: auto; padding: 20px; }
.extract-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.extract-source-row, .extract-folder-row, .extract-options-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.extract-radio-label, .extract-check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.extract-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  background: var(--surface2);
  color: var(--text);
  box-sizing: border-box;
}
.extract-input:focus { border-color: var(--primary); }
.extract-select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface2);
  color: var(--text);
  outline: none;
  min-width: 200px;
}
.extract-footer { display: flex; gap: 10px; margin-top: 20px; }
.extract-progress-header { margin-bottom: 12px; }
.extract-progress-bar-wrap {
  height: 6px;
  background: var(--border);
  border-radius: 100px;
  margin: 8px 0;
  overflow: hidden;
}
.extract-progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 100px;
  transition: width 300ms ease;
}
.extract-progress-stats { font-size: 12px; color: var(--text-dim); }
.extract-log {
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.extract-log-line { line-height: 1.5; }
.extract-log-line.success { color: #16a34a; }
.extract-log-line.error   { color: var(--danger); }
.extract-log-line.warn    { color: #d97706; }
.extract-result-title { font-size: 15px; font-weight: 700; color: var(--text); margin-top: 16px; }
.extract-result-summary { font-size: 13px; color: var(--text-dim); margin-top: 6px; }
.extract-result-summary code { background: var(--surface2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
