/* ═══════════════════════════════════════════════════════════
   ONLINE TRADER CRM — UI
   ═══════════════════════════════════════════════════════════ */
:root {
  --bg: #f4f6f9;
  --bg-hover: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: #eff6ff;
  --primary-ring: rgba(29, 78, 216, 0.18);
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #059669;
  --warning: #d97706;
  --sidebar-w: 232px;
  --sidebar-bg: #0b1220;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #1d4ed8;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 20px rgba(15, 23, 42, 0.08);
  --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 0.15s ease;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--bg-hover);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ── Layout ─────────────────────────────────────────────── */
body { display: flex; min-height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  z-index: 40;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 16px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-logo svg { opacity: 0.9; color: #93c5fd; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.nav-btn:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-btn.active {
  background: var(--sidebar-active);
  color: #fff;
  box-shadow: 0 6px 16px rgba(29, 78, 216, 0.35);
}
.nav-btn svg { flex-shrink: 0; opacity: 0.9; }

.sidebar-lang {
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.lang-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin-bottom: 8px;
}
.lang-toggle { display: flex; gap: 6px; }
.lang-btn {
  flex: 1;
  border: 1px solid rgba(255,255,255,0.1);
  background: transparent;
  color: var(--sidebar-text);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
}
.lang-btn.active, .lang-btn:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border-color: rgba(255,255,255,0.18);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.user-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.user-role { font-size: 11px; color: #64748b; }
.btn-logout {
  border: none; background: rgba(255,255,255,0.06);
  color: #94a3b8; border-radius: 8px; padding: 8px;
  display: flex; align-items: center; justify-content: center;
}
.btn-logout:hover { background: rgba(220,38,38,0.2); color: #fecaca; }

.main {
  flex: 1;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.view {
  display: none;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 20px 24px 28px;
}
.view.active { display: block; }
#view-agenda.active {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 12px;
}
#view-detail.active {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.view-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

/* ── Buttons ────────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-danger, .btn-sm, .btn-back, .btn-translate, .btn-danger-hero, .btn-kyc {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 14px;
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

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

.btn-danger, .btn-danger-hero {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #fecaca;
}
.btn-danger:hover, .btn-danger-hero:hover { background: #fee2e2; }

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-secondary);
}
.btn-sm:hover { background: var(--bg-hover); }
.btn-send-email { background: var(--primary-soft); border-color: #bfdbfe; color: var(--primary); }
.btn-send-email:hover { background: #dbeafe; }

.btn-back {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-color: rgba(255,255,255,0.18);
  padding: 7px 12px;
}
.btn-back:hover { background: rgba(255,255,255,0.2); }
.detail-hero .detail-nav-btn {
  background: rgba(255,255,255,0.12) !important;
  color: #fff !important;
  border-color: rgba(255,255,255,0.2) !important;
}
.detail-hero .detail-nav-btn:hover {
  background: rgba(255,255,255,0.22) !important;
}
.btn-kyc {
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  background: #10b981;
  color: #fff;
  border: 1px solid #059669;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.btn-kyc:hover { background: #059669; color: #fff; }
.detail-hero .btn-kyc {
  background: #34d399;
  color: #064e3b;
  border-color: #6ee7b7;
}
.detail-hero .btn-kyc:hover { background: #6ee7b7; }
.btn-kyc-inline {
  margin-left: 8px;
  padding: 5px 10px;
  font-size: 12px;
  vertical-align: middle;
}
.btn-translate {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-color: rgba(255,255,255,0.18);
}
.btn-icon {
  border: none;
  background: transparent;
  color: var(--text-light);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 14px;
}
.btn-icon:hover { background: var(--danger-soft); color: var(--danger); }

/* ── Forms ──────────────────────────────────────────────── */
input[type="text"], input[type="email"], input[type="password"], input[type="url"],
input[type="date"], input[type="search"], input[type="number"], input[type="tel"],
select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px var(--primary-ring);
}
textarea { resize: vertical; min-height: 72px; }
textarea.email-fallback {
  min-height: 260px;
  font-family: inherit;
  line-height: 1.55;
}
textarea.notes-full {
  min-height: 160px;
  max-height: none;
  height: auto;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
  field-sizing: content;
  font-size: 14px;
  font-weight: 400;
  color: var(--text, #0f172a);
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
textarea.notes-full:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px var(--primary-ring);
  outline: none;
  background: #fff;
}
.detail-notes-card {
  border: 1px solid #dbe4f0;
  box-shadow: var(--shadow);
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(29, 78, 216, 0.04) 0%, transparent 42%),
    var(--surface);
}
.detail-notes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px 18px;
  border-bottom: 1px solid #e8eef6;
  background: linear-gradient(180deg, #f7faff 0%, #ffffff 100%);
}
.detail-notes-head-main {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}
.detail-notes-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.detail-notes-icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #dbeafe;
}
.detail-notes-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.detail-notes-sub {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
}
.detail-notes-body {
  padding: 10px 12px 14px;
}
.detail-notes-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 999px;
  padding: 3px 8px;
}
.detail-notes-badge--soft {
  color: #1e40af;
  background: #eff6ff;
  border-color: #bfdbfe;
}
.detail-notes-badge--call {
  color: #065f46;
  background: #d1fae5;
  border-color: #a7f3d0;
}
.sr-only-field {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  border: 0 !important;
  opacity: 0;
  pointer-events: none;
}

/* Liste de rapports (une ligne = un document) */
.report-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.report-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  color: inherit;
  font: inherit;
  user-select: none;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
.report-row:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}
.report-row:hover {
  border-color: #bfdbfe;
  background: #f8fbff;
  box-shadow: 0 1px 0 rgba(29, 78, 216, 0.06);
}
.report-row-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #dbeafe;
  flex-shrink: 0;
}
.report-row-icon.is-summary {
  color: #92400e;
  background: #fffbeb;
  border-color: #fde68a;
}
.report-row-icon.is-call {
  color: #065f46;
  background: #ecfdf5;
  border-color: #a7f3d0;
}
.report-row-icon.is-rdv {
  color: #9a3412;
  background: #fff7ed;
  border-color: #fed7aa;
}
.report-row-icon.is-rdv-past {
  color: #64748b;
  background: #f8fafc;
  border-color: #e2e8f0;
}
.report-row-icon.is-email {
  color: #1e40af;
  background: #eff6ff;
  border-color: #bfdbfe;
}
.report-row-icon.is-email-in {
  color: #0f766e;
  background: #f0fdfa;
  border-color: #99f6e4;
}
.item-view-extra {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}
.item-view-extra[hidden] { display: none !important; }
.item-view-extra strong { color: var(--text); font-weight: 600; }
.item-view-body {
  margin: 0;
  min-height: 240px;
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  font: inherit;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}
.report-row-main { min-width: 0; }
.report-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.report-row-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}
.report-row-preview {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
}
.report-row-preview.is-empty {
  font-style: italic;
  color: var(--text-light);
}
.report-row-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}
.report-row-date {
  font-size: 11px;
  color: var(--text-light);
  white-space: nowrap;
}
.report-row-chevron {
  color: #94a3b8;
  font-size: 18px;
  line-height: 1;
}
.report-list-empty {
  padding: 22px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.modal.modal-report,
.modal-xl.modal-report {
  overflow: hidden; /* une seule barre : dans le corps du modal */
  max-height: min(92vh, 900px);
}
.modal-report .modal-header,
.modal-report .modal-footer {
  flex-shrink: 0;
}
.modal-report .modal-report-heading {
  min-width: 0;
  flex: 1;
}
.modal-report .modal-report-heading h2 {
  margin: 6px 0 0;
  font-size: 17px;
}
.modal-report-meta {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}
.modal-report-body {
  padding-top: 8px !important;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.report-modal-textarea {
  flex: 1 1 auto;
  width: 100%;
  min-height: 240px !important;
  max-height: none !important;
  height: 100% !important;
  overflow-y: auto !important;
  resize: none;
  field-sizing: fixed;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
}
.modal-report .item-view-body {
  flex: 1 1 auto;
  min-height: 240px;
  max-height: none;
  height: auto;
  overflow-y: auto;
}
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.form-hint { color: var(--text-muted); font-size: 13px; margin: 0 0 12px; }
.info-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
  padding: 16px 18px 18px;
}
@media (max-width: 720px) {
  .info-fields { grid-template-columns: 1fr; }
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.card-header h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-header h3 svg { color: var(--primary); flex-shrink: 0; }
.card-body { padding: 16px 18px; }
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
}

/* ── Toolbar / filters ──────────────────────────────────── */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.toolbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 220px;
  min-width: 180px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 10px;
}
.toolbar-search svg { color: var(--text-light); flex-shrink: 0; }
.toolbar-search input {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 9px 0;
}
.toolbar select, .toolbar input[type="text"] {
  width: auto;
  min-width: 0;
  flex: 0 0 auto;
}
.toolbar > select, .toolbar > input, .toolbar > a, .toolbar > button {
  height: 36px;
}

.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
}
.bulk-count { font-weight: 700; color: var(--primary); font-size: 13px; }

/* ── Tables ─────────────────────────────────────────────── */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
}
.clients-table, .data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}
.clients-table th, .data-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}
.clients-table td, .data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.clients-table tbody tr {
  cursor: pointer;
  transition: background var(--transition);
}
.clients-table tbody tr:hover { background: var(--bg-hover); }
.clients-table tbody tr.row-selected { background: #eff6ff; }
.clients-table tbody tr.row-nouveau { box-shadow: inset 3px 0 0 var(--primary); }
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--primary); }
.sort-icon { font-size: 10px; color: var(--primary); }
.row-name { display: flex; align-items: center; gap: 10px; }
.row-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.av-a { background: #2563eb; }
.av-b { background: #7c3aed; }
.av-c { background: #db2777; }
.av-d { background: #ea580c; }
.av-e { background: #059669; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--text-muted); font-size: 12px; }
.tel-link { color: var(--primary); font-weight: 500; }
.assign-select {
  width: auto;
  min-width: 120px;
  max-width: 160px;
  padding: 5px 8px;
  font-size: 12px;
}
.table-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 13px;
}
.table-info-count { font-weight: 500; }
.empty-state, .table-loading {
  text-align: center;
  padding: 36px 16px !important;
  color: var(--text-muted);
}
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pagination {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}
.pagination button {
  min-width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.pagination button:hover { background: var(--bg-hover); }
.pagination button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* ── Badges / priority ──────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.prio-badge {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}
.prio-haute { background: #fef2f2; color: #b91c1c; }
.prio-moyenne { background: #fff7ed; color: #c2410c; }
.prio-basse { background: #f0fdf4; color: #15803d; }
.badge-admin { background: #ede9fe; color: #6d28d9; }
.badge-agent { background: #e0f2fe; color: #0369a1; }

.followup-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  line-height: 1.3;
}
.followup-overdue { background: #fef2f2; color: #b91c1c; }
.followup-today { background: #fff7ed; color: #c2410c; }
.followup-soon { background: #f0fdf4; color: #15803d; }
.followup-future { background: var(--bg-hover); color: var(--text-muted); }

.status-select { min-width: 140px; }

/* ── Detail fiche ───────────────────────────────────────── */
.detail-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 60vh;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}
.detail-placeholder svg { opacity: 0.35; }
.detail-placeholder p { margin: 0; font-size: 15px; line-height: 1.5; }

.detail-sticky-top {
  position: sticky;
  top: 0;
  z-index: 12;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--border);
}

.detail-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 55%, #1d4ed8 100%);
  color: #fff;
}
.detail-hero-avatar {
  width: 48px; height: 48px; border-radius: 14px;
  background: rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700;
  flex-shrink: 0;
}
.detail-hero-info { min-width: 0; }
.detail-hero-info h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.detail-hero-company {
  font-size: 13px;
  opacity: 0.8;
  margin-top: 2px;
}
.detail-hero-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.data-lang-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.15);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.identity-verified-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Barre de navigation des sections fiche */
.detail-section-nav {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  scrollbar-width: thin;
}
.detail-section-nav::-webkit-scrollbar { height: 4px; }
.detail-section-link {
  flex: 0 0 auto;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  white-space: nowrap;
  transition: all var(--transition);
}
.detail-section-link:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.detail-section-link.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: #bfdbfe;
}
.detail-section-nav .btn-kyc-nav {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
}

.company-config-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 800px) {
  .company-config-grid { grid-template-columns: 1fr; }
}
.company-logo-panel {
  background: #f8fafc;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 14px;
}
.company-logo-preview {
  width: 100%;
  min-height: 110px;
  background: #0d1b3e;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 12px;
  overflow: hidden;
}
.company-logo-preview img {
  max-width: 100%;
  max-height: 120px;
  object-fit: contain;
  display: block;
}

.call-count-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}
.call-count-wrap strong {
  font-size: 18px;
  min-width: 28px;
  color: var(--primary, #1d4ed8);
}
.btn-call-log {
  background: #eff6ff !important;
  border-color: #bfdbfe !important;
  color: #1d4ed8 !important;
  font-weight: 700;
}
.cf-docs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}
.cf-docs-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-direction: row;
  font-size: 13px;
  font-weight: 500;
  color: #334155;
}
.cf-docs-grid input { width: auto; margin: 0; accent-color: var(--primary); }
@media (max-width: 600px) {
  .cf-docs-grid { grid-template-columns: 1fr; }
}
.doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: #fff;
}
.doc-item .doc-meta { font-size: 12px; color: var(--text-muted, #64748b); }

/* ── Popup alerte RDV + sonnerie ─────────────────────────── */
.rdv-alert-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(15, 23, 42, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.rdv-alert-box {
  position: relative;
  width: min(420px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px 20px;
  text-align: center;
  box-shadow: 0 25px 50px rgba(0,0,0,0.35);
  overflow: hidden;
}
.rdv-alert-pulse {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, rgba(239,68,68,0.18), transparent 60%);
  animation: rdvPulse 1.2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes rdvPulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}
.rdv-alert-icon {
  font-size: 42px;
  line-height: 1;
  margin-bottom: 8px;
  animation: rdvShake 0.5s ease-in-out infinite;
}
@keyframes rdvShake {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-12deg); }
  75% { transform: rotate(12deg); }
}
.rdv-alert-box h2 {
  margin: 0 0 8px;
  font-size: 20px;
  color: #0f172a;
}
.rdv-alert-when {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
  color: #dc2626;
}
.rdv-alert-client {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
}
.rdv-alert-meta {
  margin: 0 0 18px;
  font-size: 13px;
  color: #64748b;
  white-space: pre-line;
}
.rdv-alert-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 16px 18px 28px;
}
.detail-grid > .card { scroll-margin-top: 12px; }
.detail-info, .detail-grid > .card[style*="grid-column"] { grid-column: 1 / -1; }
@media (max-width: 980px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.detail-save-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.detail-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  color: var(--text-muted);
}

.item-list { padding: 8px 12px 14px; max-height: 360px; overflow: auto; }
.emails-grid { display: grid; gap: 8px; }
.c-item, .agenda-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.a-title { font-weight: 700; font-size: 13px; }
.a-author, .a-client, .a-notes, .agenda-date, .agenda-info { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.agenda-list { display: flex; flex-direction: column; gap: 8px; }
.agenda-section-title {
  margin: 18px 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.agenda-past { opacity: 0.65; }

.agenda-header { flex-shrink: 0; }
.agenda-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.agenda-week-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  min-width: 180px;
}
.agenda-agent-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0;
}
.agenda-agent-filter select { width: auto; min-width: 160px; margin: 0; }
.cal-modes {
  display: inline-flex;
  background: #eef2f7;
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.cal-mode-btn {
  border: 0;
  background: transparent;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
}
.cal-mode-btn.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }
.cal-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 14px;
  background: #eef3f7;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}
.cal-side {
  flex: 0 0 232px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
.cal-side-hint {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.45;
}
.cal-mini {
  background: #fff;
  border-radius: 10px;
  padding: 10px;
  border: 1px solid var(--border);
}
.cal-mini-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
}
.cal-mini-head button {
  border: 0;
  background: #f1f5f9;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
}
.cal-mini-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
  font-size: 11px;
}
.cal-mini-dow { color: var(--text-muted); font-weight: 700; padding: 4px 0; }
.cal-mini-day {
  border: 0;
  background: transparent;
  border-radius: 6px;
  padding: 6px 0;
  cursor: pointer;
  position: relative;
}
.cal-mini-day.out { color: #cbd5e1; }
.cal-mini-day.today { font-weight: 800; color: var(--primary); }
.cal-mini-day.sel { background: var(--primary); color: #fff; }
.cal-mini-day.has::after {
  content: '';
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #f59e0b;
  margin: 2px auto 0;
}
.cal-mini-day.sel.has::after { background: #fff; }
.cal-board {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.cal-year {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 14px;
}
.cal-year-month { border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.cal-year-month h3 {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: capitalize;
  color: var(--primary);
  cursor: pointer;
}
.cal-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  min-height: 100%;
}
.cal-month-head, .cal-month-cell {
  min-height: 88px;
  border: 1px solid #eef2f7;
  padding: 6px;
  font-size: 12px;
}
.cal-month-head {
  min-height: 0;
  padding: 8px;
  text-align: center;
  font-weight: 700;
  color: var(--text-muted);
  background: #f8fafc;
}
.cal-month-cell { cursor: pointer; vertical-align: top; }
.cal-month-cell.out { background: #f8fafc; color: #94a3b8; }
.cal-month-cell.today { outline: 2px solid var(--primary); outline-offset: -2px; }
.cal-month-num { font-weight: 700; margin-bottom: 4px; }
.cal-chip {
  display: block;
  border: 0;
  width: 100%;
  text-align: left;
  border-radius: 4px;
  padding: 2px 5px;
  margin-bottom: 3px;
  font-size: 10px;
  font-weight: 700;
  color: #1e293b;
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.cal-time {
  display: grid;
  grid-template-columns: 52px repeat(var(--cal-cols, 7), minmax(110px, 1fr));
  min-width: 100%;
}
.cal-time.day { --cal-cols: 1; }
.cal-time-head, .cal-time-hour, .cal-time-slot {
  border-right: 1px solid #e8eef4;
  border-bottom: 1px solid #e8eef4;
}
.cal-time-head {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f8fafc;
  padding: 8px 6px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}
.cal-time-head.today { background: #eff6ff; color: var(--primary); }
.cal-time-hour {
  height: 52px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  padding: 2px 6px 0 0;
  background: #fff;
}
.cal-time-col {
  position: relative;
  background-image: linear-gradient(#f1f5f9 1px, transparent 1px);
  background-size: 100% 52px;
}
.cal-time-slot {
  height: 52px;
  cursor: pointer;
  background: transparent;
}
.cal-time-slot:hover { background: rgba(29, 78, 216, 0.06); }
.cal-lunch {
  position: absolute;
  left: 0; right: 0;
  background: #e8edf3;
  pointer-events: none;
  z-index: 0;
}
.cal-event {
  position: absolute;
  left: 4px;
  right: 4px;
  z-index: 2;
  border: 0;
  border-radius: 4px;
  padding: 4px 6px;
  text-align: left;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15,23,42,.08);
}
.cal-event strong { display: block; font-size: 11px; }
.cal-event span { display: block; font-size: 10px; opacity: .85; }
.cal-now {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: #ef4444;
  z-index: 4;
  pointer-events: none;
}
@media (max-width: 1100px) {
  .cal-shell { flex-direction: column; }
  .cal-side { flex: none; width: 100%; }
  .cal-year { grid-template-columns: repeat(2, 1fr); }
}

.tag-input-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  background: var(--surface);
}
.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
}
.tag-chip button {
  border: none;
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: 12px;
  line-height: 1;
}
#detail-tag-input {
  border: none !important;
  box-shadow: none !important;
  flex: 1;
  min-width: 140px;
  padding: 4px !important;
}

/* ── View grids ─────────────────────────────────────────── */
.payment-grid, .statuses-grid, .templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

/* ── Modals / toast ─────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 10050;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex !important; }
#modal-report.modal-overlay.open,
#modal-item-view.modal-overlay.open {
  z-index: 10060;
}
.modal {
  background: var(--surface);
  border-radius: 14px;
  width: min(560px, 100%);
  max-height: min(90vh, 900px);
  overflow: auto;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}
.modal-lg { width: min(820px, 100%); }
.modal-xl { width: min(960px, 100%); max-height: min(92vh, 900px); display: flex; flex-direction: column; }
.modal-kyc .modal-kyc-body {
  overflow-y: auto;
  flex: 1;
  gap: 16px;
}
.kyc-intro {
  margin: 0;
  font-size: 13px;
  color: var(--muted, #64748b);
  line-height: 1.45;
}
.kyc-section {
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 14px 14px 10px;
  background: #f8fafc;
}
.kyc-section-title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}
.kyc-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}
.kyc-fields label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
}
.kyc-fields label.kyc-full { grid-column: 1 / -1; }
.kyc-fields input,
.kyc-fields textarea,
.kyc-fields select {
  font-weight: 400;
  font-size: 13px;
}
.kyc-preview-wrap {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 12px;
  background: #fff;
}
.kyc-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.kyc-preview {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  max-height: 220px;
  overflow-y: auto;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 10px 12px;
  color: #1e293b;
}
@media (max-width: 700px) {
  .kyc-fields { grid-template-columns: 1fr; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.modal-header h2 { margin: 0; font-size: 16px; }
.modal-close {
  border: none;
  background: var(--bg-hover);
  width: 32px; height: 32px;
  border-radius: 8px;
  color: var(--text-muted);
}
.modal-close:hover { background: var(--danger-soft); color: var(--danger); }
.modal-body { padding: 16px 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

#toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 200;
  min-width: 220px;
  max-width: 380px;
  padding: 12px 16px;
  border-radius: 10px;
  background: #0f172a;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
#toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
#toast.error { background: #991b1b; }
#toast.success { background: #065f46; }

/* Color swatches (statuts) */
.color-swatch {
  width: 22px; height: 22px; border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
}
.color-swatch.active { border-color: var(--text); outline: 2px solid #fff; }

/* Day calendar chips if any */
.day {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  font-size: 12px;
}

/* Status vertical tabs (si présents) */
.clients-status-nav, #clients-status-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.status-nav-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: transparent;
  padding: 8px;
  border-radius: 8px;
  color: var(--text-muted);
  text-align: left;
}
.status-nav-tab:hover, .status-nav-tab.active {
  background: var(--primary-soft);
  color: var(--primary);
}
.status-nav-dot {
  width: 24px; height: 24px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.status-nav-label { font-size: 11px; font-weight: 600; }

@media (max-width: 860px) {
  body { overflow: auto; }
  .sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .main { height: auto; min-height: 100vh; }
}
