/* =========================================================
   Qhare Leads — thème clair premium animé
   ========================================================= */

:root {
  --bg: #f3f4fb;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: rgba(255, 255, 255, 0.9);
  --solid: #ffffff;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.14);
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --primary: #6d5efc;
  --primary-2: #8b5cf6;
  --accent: #06b6d4;
  --primary-soft: #eeecff;
  --grad: linear-gradient(135deg, #6d5efc 0%, #8b5cf6 50%, #06b6d4 100%);
  --grad-warm: linear-gradient(135deg, #f97316, #ec4899);
  --danger: #e11d48;
  --success: #059669;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow: 0 18px 40px -18px rgba(49, 46, 129, 0.22), 0 4px 12px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 30px 60px -20px rgba(49, 46, 129, 0.35);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Palettes de statuts ---------- */
.tone-blue    { --tone: #2563eb; --tone-soft: #dbeafe; }
.tone-cyan    { --tone: #0891b2; --tone-soft: #cffafe; }
.tone-green   { --tone: #16a34a; --tone-soft: #dcfce7; }
.tone-emerald { --tone: #059669; --tone-soft: #d1fae5; }
.tone-orange  { --tone: #ea580c; --tone-soft: #ffedd5; }
.tone-amber   { --tone: #d97706; --tone-soft: #fef3c7; }
.tone-red     { --tone: #e11d48; --tone-soft: #ffe4e6; }
.tone-pink    { --tone: #db2777; --tone-soft: #fce7f3; }
.tone-violet  { --tone: #7c3aed; --tone-soft: #ede9fe; }
.tone-gray    { --tone: #475569; --tone-soft: #e2e8f0; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 14px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-size: 12px; background: var(--primary-soft); color: var(--primary); padding: 1px 6px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.icon { width: 18px; height: 18px; flex: none; }
.icon.sm { width: 14px; height: 14px; vertical-align: -2px; }
[hidden] { display: none !important; }

/* ---------- Fond aurore animé ---------- */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aurora::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(15, 23, 42, 0.07) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 70%);
}
.aurora span {
  position: absolute; width: 46vmax; height: 46vmax; border-radius: 50%;
  filter: blur(90px); opacity: 0.45; mix-blend-mode: multiply;
  animation: drift 26s ease-in-out infinite alternate;
}
.aurora span:nth-child(1) { background: #c7d2fe; top: -18vmax; left: -10vmax; }
.aurora span:nth-child(2) { background: #a5f3fc; top: -12vmax; right: -14vmax; animation-duration: 32s; animation-delay: -6s; }
.aurora span:nth-child(3) { background: #f5d0fe; bottom: -22vmax; left: 20vmax; animation-duration: 36s; animation-delay: -12s; }
.aurora span:nth-child(4) { background: #fde68a; bottom: -26vmax; right: -8vmax; opacity: 0.28; animation-duration: 40s; }
@keyframes drift {
  0%   { transform: translate(0, 0) scale(1) rotate(0deg); }
  50%  { transform: translate(6vmax, 4vmax) scale(1.12) rotate(20deg); }
  100% { transform: translate(-4vmax, 7vmax) scale(0.95) rotate(-10deg); }
}

/* ---------- Animations d'entrée ---------- */
.reveal { animation: rise 0.7s var(--ease) both; animation-delay: calc(var(--d, 0) * 70ms); }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(0.99); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: none; } }
@keyframes fadeSlide { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { from { background-position: -400px 0; } to { background-position: 400px 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes pulse { 0% { transform: scale(1); opacity: 0.6; } 100% { transform: scale(2.6); opacity: 0; } }
@keyframes shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(2px); } 30%, 50%, 70% { transform: translateX(-4px); } 40%, 60% { transform: translateX(4px); } }
.shake { animation: shake 0.5s both; }

/* ---------- Structure ---------- */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.main { padding: 22px 26px; min-width: 0; }

.rail {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 18px;
  padding: 20px 14px;
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 10px; color: var(--text); text-decoration: none !important; }
.brand-text { font-size: 18px; font-weight: 800; letter-spacing: -0.03em; }
.brand-text b, .auth-brand h1 b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-mark {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px;
  background: var(--grad); color: #fff; box-shadow: 0 8px 20px -6px rgba(109, 94, 252, 0.6);
  background-size: 200% 200%; animation: gradientMove 8s ease infinite;
}
.brand-mark .icon { width: 20px; height: 20px; }
.brand-mark.big { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 14px; animation: gradientMove 8s ease infinite, float 4s ease-in-out infinite; }
.brand-mark.big .icon { width: 32px; height: 32px; }
@keyframes gradientMove { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

.rail-group { display: flex; flex-direction: column; gap: 2px; }
.rail-title { margin: 0 0 6px 10px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.rail-link {
  position: relative; display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 12px;
  color: var(--text-2); font-weight: 600; text-decoration: none !important;
  transition: background 0.25s var(--ease), color 0.25s, transform 0.25s var(--ease);
}
.rail-link:hover { background: rgba(109, 94, 252, 0.07); color: var(--primary); transform: translateX(3px); }
.rail-link.active { background: var(--solid); color: var(--primary); box-shadow: var(--shadow-sm); }
.rail-link.active::before {
  content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--grad);
  animation: pop 0.4s var(--spring);
}
.rail-footer { margin-top: auto; display: flex; align-items: center; gap: 6px; padding-top: 12px; border-top: 1px solid var(--border); }
.rail-footer form { margin: 0; }
.me { flex: 1; display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 12px; color: var(--text); text-decoration: none !important; min-width: 0; }
.me:hover, .me.active { background: rgba(109, 94, 252, 0.07); }
.me-text { display: flex; flex-direction: column; min-width: 0; }
.me-text b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: var(--muted); font-size: 11.5px; }
.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--grad); color: #fff; font-weight: 700; font-size: 14px;
}
.avatar.sm { width: 26px; height: 26px; font-size: 11.5px; margin-right: 6px; vertical-align: middle; }

/* ---------- Composants ---------- */
.card, .panel {
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow), inset 0 0 0 1px var(--border);
  border-radius: var(--radius);
}
.card { padding: 20px; }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; margin-bottom: 14px; }
.card-title .icon { color: var(--primary); }
.sub-title { font-size: 13px; margin: 18px 0 8px; }

.eyebrow { margin: 0 0 4px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--primary); }
.title { font-size: 28px; font-weight: 800; letter-spacing: -0.035em; }
.grad-text { background: var(--grad); background-size: 200% auto; -webkit-background-clip: text; background-clip: text; color: transparent; animation: gradientMove 6s ease infinite; }

.page { display: flex; flex-direction: column; gap: 18px; max-width: 1400px; }
.page.narrow { max-width: 820px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p.muted { margin: 6px 0 0; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  font: 600 14px/1 var(--font); white-space: nowrap; text-decoration: none !important;
  transition: transform 0.25s var(--spring), box-shadow 0.25s var(--ease), background 0.2s, border-color 0.2s, color 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
.btn-primary { background: var(--grad); background-size: 160% 160%; color: #fff; box-shadow: 0 10px 22px -10px rgba(109, 94, 252, 0.8); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 30px -12px rgba(109, 94, 252, 0.9); background-position: 100% 50%; }
.btn-ghost { background: var(--surface-strong); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: rgba(225, 29, 72, 0.25); }
.btn-danger-ghost:hover { background: #fff1f2; }
.btn-sm { padding: 7px 11px; font-size: 12.5px; border-radius: 10px; }
.btn-block { width: 100%; padding: 13px 16px; }
.btn-shine::after {
  content: ""; position: absolute; top: 0; left: -120%; width: 60%; height: 100%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-20deg); transition: left 0.7s var(--ease);
}
.btn-shine:hover::after { left: 140%; }
.spinner { display: inline-block; width: 12px; height: 12px; vertical-align: -2px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
.btn .spinner { width: 16px; height: 16px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border-radius: 10px; border: 0; background: transparent; color: var(--muted); cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.25s var(--spring);
}
.icon-btn:hover { background: rgba(109, 94, 252, 0.1); color: var(--primary); transform: scale(1.08); }
.icon-btn.danger:hover { background: #fff1f2; color: var(--danger); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
  background: var(--tone-soft, #e2e8f0); color: var(--tone, #475569);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.8; }

/* Formulaires */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-row { display: flex; align-items: flex-end; gap: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.form-actions.start { justify-content: flex-start; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
input, select, textarea { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface-strong);
  transition: border-color 0.2s, box-shadow 0.25s var(--ease), background 0.2s;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(109, 94, 252, 0.14); background: #fff; }
input:disabled { opacity: 0.6; }
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.w-num { width: 84px !important; }

.toggle { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--text-2); user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-ui { position: relative; width: 38px; height: 22px; border-radius: 999px; background: #cbd5e1; transition: background 0.3s var(--ease); flex: none; }
.toggle-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); transition: transform 0.35s var(--spring); }
.toggle input:checked + .toggle-ui { background: var(--primary); }
.toggle input:checked + .toggle-ui::after { transform: translateX(16px); }
.toggle input:focus-visible + .toggle-ui { box-shadow: 0 0 0 4px rgba(109, 94, 252, 0.2); }

.search { position: relative; display: flex; align-items: center; }
.search .icon { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 38px !important; }
.grow { flex: 1; }

/* Messages */
.flash {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; margin-bottom: 14px; border-radius: var(--radius-sm);
  font-weight: 600; animation: rise 0.5s var(--ease) both;
}
.flash-success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.flash-error { background: #fff1f2; color: #be123c; border: 1px solid #fecdd3; }
.flash-info { background: var(--primary-soft); color: #4c1d95; border: 1px solid #ddd6fe; }

.toast-root { position: fixed; top: 18px; right: 18px; z-index: 50; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px;
  min-width: 260px; max-width: 420px; padding: 12px 16px; border-radius: 14px;
  background: rgba(15, 23, 42, 0.92); color: #fff; box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px); font-weight: 600;
  animation: toastIn 0.5s var(--spring) both;
}
.toast.error { background: rgba(190, 18, 60, 0.95); }
.toast.success .icon { color: #6ee7b7; }
.toast.leaving { animation: toastOut 0.35s var(--ease) both; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px) scale(0.95); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px); } }

/* Tableaux */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background 0.2s; }
.table tbody tr:hover { background: rgba(109, 94, 252, 0.04); }
.table .num { text-align: right; }
.table .check { width: 36px; }
.is-off { opacity: 0.55; }

/* =========================================================
   Connexion / installation
   ========================================================= */
.guest-main { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(420px, 100%); padding: 34px; background: var(--surface); backdrop-filter: blur(24px) saturate(1.4); -webkit-backdrop-filter: blur(24px) saturate(1.4); border-radius: 26px; box-shadow: var(--shadow-lg), inset 0 0 0 1px rgba(255, 255, 255, 0.8); }
.auth-card.center { text-align: center; }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand h1 { font-size: 26px; font-weight: 800; }
.auth-brand p { margin: 6px 0 0; }
.auth-foot { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 18px 0 0; }
.error-code { font-size: 72px; font-weight: 800; margin: 0; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* =========================================================
   Espace de travail
   ========================================================= */
.workspace { display: flex; flex-direction: column; gap: 18px; height: calc(100vh - 44px); }
.ws-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat {
  position: relative; display: flex; flex-direction: column; align-items: flex-start;
  min-width: 108px; padding: 10px 16px; border-radius: 16px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.7); background: var(--surface);
  backdrop-filter: blur(14px); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border);
  font: inherit; color: inherit; text-align: left;
  transition: transform 0.3s var(--spring), box-shadow 0.3s;
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat.active { box-shadow: 0 0 0 2px var(--tone, var(--primary)), var(--shadow); }
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -0.03em; color: var(--tone, var(--text)); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.pulse-dot { position: absolute; top: 10px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--tone); }
.pulse-dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--tone); animation: pulse 1.6s ease-out infinite; }

.ws-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px minmax(380px, 1fr) minmax(380px, 1.1fr); gap: 16px; }
.panel { min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

/* Liste */
.list-panel { padding: 14px; gap: 10px; }
.list-filters { display: flex; align-items: center; gap: 10px; }
.list-filters select { flex: 1; padding: 8px 10px !important; }
.list-count { margin: 0 4px; }
.lead-list { list-style: none; margin: 0 -6px; padding: 2px 6px 6px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.lead-item {
  position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 11px;
  padding: 10px 12px; border-radius: 14px; cursor: pointer;
  background: rgba(255, 255, 255, 0.55); border: 1px solid transparent;
  transition: transform 0.3s var(--spring), background 0.2s, box-shadow 0.3s, border-color 0.2s;
}
.lead-list.animate .lead-item { animation: fadeSlide 0.45s var(--ease) both; animation-delay: calc(min(var(--i, 0), 14) * 35ms); }
.lead-item:hover { transform: translateX(4px); background: #fff; box-shadow: var(--shadow-sm); }
.lead-item.selected { background: #fff; border-color: rgba(109, 94, 252, 0.35); box-shadow: 0 10px 24px -14px rgba(109, 94, 252, 0.7); }
.lead-item.selected::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--grad); animation: pop 0.35s var(--spring); }
.lead-item .avatar { width: 38px; height: 38px; font-size: 13px; }
.lead-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-sub { grid-column: 2 / 4; font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; white-space: nowrap; overflow: hidden; }
.lead-item .avatar { grid-row: span 2; }
.due-tag { color: #c2410c; font-weight: 700; display: inline-flex; align-items: center; gap: 3px; }
.due-tag.late { color: var(--danger); }
.skeleton { height: 58px; border-radius: 14px; background: linear-gradient(90deg, rgba(226, 232, 240, 0.6) 0, rgba(241, 245, 249, 0.9) 40%, rgba(226, 232, 240, 0.6) 80%); background-size: 800px 100%; animation: shimmer 1.4s linear infinite; }
.empty-list { text-align: center; padding: 30px 10px; color: var(--muted); }

/* Détail */
.detail-panel { overflow-y: auto; padding: 22px; }
.empty-state { margin: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 30px; }
.empty-state h2 { font-size: 19px; }
.empty-state p { margin: 0; }
.empty-orb { position: relative; display: grid; place-items: center; width: 84px; height: 84px; border-radius: 50%; margin-bottom: 8px; background: var(--grad); color: #fff; animation: float 4s ease-in-out infinite; box-shadow: 0 18px 40px -12px rgba(109, 94, 252, 0.6); }
.empty-orb .icon { width: 34px; height: 34px; }
.empty-orb::before, .empty-orb::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(109, 94, 252, 0.35); animation: pulse 2.4s ease-out infinite; }
.empty-orb::after { animation-delay: 1.2s; }

.detail-enter { animation: rise 0.5s var(--ease) both; }
.lead-hero { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.hero-avatar { position: relative; width: 64px; height: 64px; flex: none; }
.hero-avatar::before { content: ""; position: absolute; inset: -4px; border-radius: 50%; background: conic-gradient(from 0deg, #6d5efc, #06b6d4, #ec4899, #6d5efc); animation: spin 6s linear infinite; }
.hero-avatar .avatar { position: relative; width: 64px; height: 64px; font-size: 22px; border: 3px solid #fff; }
.lead-hero h2 { font-size: 22px; font-weight: 800; }
.hero-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.sync-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; color: var(--muted); }

.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.contact {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.65); box-shadow: inset 0 0 0 1px var(--border); min-width: 0;
}
.contact.wide { grid-column: 1 / -1; }
.contact-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); flex: none; }
.contact-text { display: flex; flex-direction: column; min-width: 0; }
.contact-text small { color: var(--muted); font-size: 11.5px; font-weight: 600; }
.contact-text b, .contact-text a { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }

.action-bar { display: grid; grid-template-columns: 1.3fr 1fr; gap: 10px; margin-bottom: 10px; }
.btn-call { position: relative; padding: 14px 18px; font-size: 15px; border-radius: 14px; }
.btn-call::before { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: 0 0 0 0 rgba(109, 94, 252, 0.55); animation: ring 2.4s ease-out infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(109, 94, 252, 0.5); } 70%, 100% { box-shadow: 0 0 0 14px rgba(109, 94, 252, 0); } }
.btn-call .icon { animation: wiggle 3s ease-in-out infinite; }
@keyframes wiggle { 0%, 80%, 100% { transform: rotate(0); } 84% { transform: rotate(-14deg); } 88% { transform: rotate(12deg); } 92% { transform: rotate(-8deg); } 96% { transform: rotate(5deg); } }
.mail-row { display: flex; gap: 8px; margin-bottom: 18px; }
.mail-row select { flex: 1; }

.section-label { display: flex; align-items: center; gap: 8px; margin: 20px 0 10px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-strong); background: rgba(255, 255, 255, 0.7);
  font: 600 12.5px var(--font); color: var(--text-2);
  transition: transform 0.25s var(--spring), background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.25s;
}
.chip:hover { transform: translateY(-2px); border-color: var(--tone, var(--primary)); color: var(--tone, var(--primary)); }
.chip.active { background: var(--tone, var(--primary)); border-color: var(--tone, var(--primary)); color: #fff; box-shadow: 0 8px 18px -10px var(--tone, var(--primary)); }
.chip[class*="tone-"]::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--tone); }
.chip.active::before { background: #fff; }

.note-form { display: flex; flex-direction: column; gap: 10px; }
.reminder-row { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.reminder-row input { width: auto !important; flex: 1; min-width: 180px; padding: 7px 10px !important; }
.reminder-current { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; background: #fff7ed; color: #9a3412; font-weight: 600; font-size: 13px; }
.reminder-current.late { background: #fff1f2; color: #be123c; }
.reminder-current button { margin-left: auto; }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { position: relative; display: flex; gap: 12px; padding: 0 0 14px; animation: fadeSlide 0.4s var(--ease) both; animation-delay: calc(min(var(--i, 0), 10) * 40ms); }
.timeline li::before { content: ""; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline li:has(.tl-dot)::before { left: 4px; top: 20px; }
.tl-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; flex: none; background: var(--tone-soft, var(--primary-soft)); color: var(--tone, var(--primary)); }
.tl-icon .icon { width: 14px; height: 14px; }
.tl-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--grad); margin-top: 6px; flex: none; box-shadow: 0 0 0 4px var(--primary-soft); }
.timeline .tl-body { white-space: pre-wrap; margin-top: 2px; }
.link-more { display: inline-block; margin-top: 4px; font-weight: 600; font-size: 13px; }

/* Carte */
.map-panel { position: relative; }
.map-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-bottom: 1px solid var(--border); background: rgba(255, 255, 255, 0.6); }
.map-links { display: flex; gap: 6px; margin-left: auto; }
.seg { position: relative; display: inline-flex; padding: 3px; border-radius: 12px; background: rgba(15, 23, 42, 0.06); }
.seg button { position: relative; z-index: 1; border: 0; background: transparent; padding: 6px 12px; border-radius: 9px; font: 600 12.5px var(--font); color: var(--muted); cursor: pointer; transition: color 0.2s, background 0.3s var(--ease), box-shadow 0.3s; }
.seg button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow-sm); }
#map { flex: 1; min-height: 360px; }
.map-overlay {
  position: absolute; left: 14px; bottom: 14px; right: 14px; max-width: 360px;
  padding: 12px 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px); box-shadow: var(--shadow); animation: rise 0.5s var(--ease) both;
}
.map-overlay b { display: block; }
.marker { position: relative; width: 22px; height: 22px; }
.marker .core { position: absolute; inset: 3px; border-radius: 50%; background: var(--grad); border: 3px solid #fff; box-shadow: 0 6px 16px rgba(109, 94, 252, 0.6); }
.marker .ring { position: absolute; inset: 0; border-radius: 50%; background: rgba(109, 94, 252, 0.45); animation: pulse 2s ease-out infinite; }
.marker .ring:nth-child(2) { animation-delay: 1s; }
.maplibregl-ctrl-group { border-radius: 12px !important; box-shadow: var(--shadow-sm) !important; }

/* =========================================================
   Administration
   ========================================================= */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi { display: flex; flex-direction: column; gap: 4px; transition: transform 0.35s var(--spring), box-shadow 0.35s; }
.kpi:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.kpi-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: var(--tone-soft); color: var(--tone); margin-bottom: 8px; }
.kpi-value { font-size: 32px; font-weight: 800; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.kpi-label { color: var(--muted); font-weight: 600; font-size: 13px; }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.bars li { display: grid; grid-template-columns: 130px 1fr 40px; align-items: center; gap: 10px; }
.bar-track { height: 10px; border-radius: 999px; background: rgba(15, 23, 42, 0.06); overflow: hidden; }
.bar-fill { display: block; height: 100%; width: var(--w); border-radius: inherit; background: linear-gradient(90deg, var(--tone-soft), var(--tone)); animation: grow 1.1s var(--ease) both; animation-delay: calc(var(--i) * 90ms + 200ms); transform-origin: left; }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; }
.columns { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 10px; }
.column { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; }
.column-bar { width: 100%; max-width: 26px; height: max(var(--h), 3%); border-radius: 8px 8px 4px 4px; background: var(--grad); opacity: 0.9; animation: growUp 0.9s var(--spring) both; animation-delay: calc(var(--i) * 45ms + 200ms); transform-origin: bottom; transition: opacity 0.2s, transform 0.2s; }
.column:hover .column-bar { opacity: 1; transform: scaleY(1.04); }
@keyframes growUp { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.column-label { font-size: 11px; color: var(--muted); font-weight: 600; }

.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
.sticky { position: sticky; top: 22px; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 34px 20px; border-radius: 16px; cursor: pointer;
  border: 2px dashed rgba(109, 94, 252, 0.35); background: rgba(238, 236, 255, 0.45);
  transition: background 0.3s, border-color 0.3s, transform 0.3s var(--spring);
}
.dropzone:hover, .dropzone.dragover { background: rgba(238, 236, 255, 0.9); border-color: var(--primary); transform: scale(1.01); }
.dropzone-orb { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px; background: var(--grad); color: #fff; margin-bottom: 6px; animation: float 3.5s ease-in-out infinite; box-shadow: 0 12px 26px -10px rgba(109, 94, 252, 0.7); }
.dropzone-card .small { margin: 12px 0 0; }

.mapping { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.mapping-row { display: grid; grid-template-columns: 150px 1fr 1fr; gap: 10px; align-items: center; animation: fadeSlide 0.35s var(--ease) both; animation-delay: calc(var(--i) * 30ms); }
.mapping-row select { padding: 7px 10px !important; }
.mapping-row .sample { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mapping-row.mapped b { color: var(--primary); }
.import-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0; }
.import-summary div { text-align: center; padding: 12px; border-radius: 14px; background: var(--tone-soft); color: var(--tone); animation: pop 0.5s var(--spring) both; }
.import-summary b { display: block; font-size: 24px; font-weight: 800; }

.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.mini-list li { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.6); box-shadow: inset 0 0 0 1px var(--border); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar select { width: auto !important; }
.bulkbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 8px; border-radius: 14px; background: var(--primary-soft); }
.bulkbar select { width: auto !important; margin-left: auto; padding: 7px 10px !important; }
.pager { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 14px; }
.pager a { min-width: 34px; text-align: center; padding: 6px 10px; border-radius: 10px; font-weight: 600; color: var(--text-2); }
.pager a.active { background: var(--grad); color: #fff; }

.status-rows { display: flex; flex-direction: column; gap: 8px; }
.status-row { display: flex; align-items: center; gap: 8px; }
.status-row form { margin: 0; }
.status-form { flex: 1; display: grid; grid-template-columns: 130px 1fr 120px 84px auto auto auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.6); box-shadow: inset 0 0 0 1px var(--border); transition: box-shadow 0.25s; }
.status-form:hover { box-shadow: inset 0 0 0 1px rgba(109, 94, 252, 0.3), var(--shadow-sm); }
.status-form.add { grid-template-columns: 130px 1fr 120px 84px auto; margin-top: 14px; background: var(--primary-soft); }
.status-form input, .status-form select { padding: 7px 10px !important; }
.preview { justify-self: start; }

.template-list { display: grid; gap: 14px; }
.template header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.template h2 { font-size: 15px; }
.template p { margin: 4px 0; }
.template-body { white-space: pre-line; }
.template footer { display: flex; gap: 8px; margin-top: 12px; }
.template footer form { margin: 0; }
.template { transition: transform 0.35s var(--spring), box-shadow 0.35s; }
.template:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.connector-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.connector { display: flex; flex-direction: column; gap: 10px; transition: transform 0.35s var(--spring), box-shadow 0.35s; }
.connector:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.connector p { margin: 0; }
.connector form { margin: 0; }
.connector-head { display: flex; align-items: center; gap: 12px; }
.connector-head h2 { font-size: 15px; flex: 1; }
.connector-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--tone-soft); color: var(--tone); }
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.state i { position: relative; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.state.on { background: #dcfce7; color: #15803d; }
.state.on i::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: currentColor; animation: pulse 1.8s ease-out infinite; }
.state.off { background: #f1f5f9; color: #64748b; }
.copy-field { display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 12px; border-radius: 12px; background: rgba(15, 23, 42, 0.04); }
.copy-field code { flex: 1; background: none; color: var(--text-2); padding: 0; overflow-x: auto; white-space: nowrap; }
.error-line { color: var(--danger); margin: 0; }

.tip { background: linear-gradient(135deg, rgba(238, 236, 255, 0.8), rgba(207, 250, 254, 0.6)); }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; color: var(--text-2); }

/* ---------- Responsive ---------- */
@media (max-width: 1600px) {
  .workspace { height: auto; }
  .ws-grid { grid-template-columns: 330px minmax(0, 1fr); grid-template-areas: "list map" "list detail"; align-items: start; }
  .list-panel { grid-area: list; height: calc(100vh - 150px); position: sticky; top: 22px; }
  .map-panel { grid-area: map; height: 360px; }
  #map { min-height: 0; }
  .detail-panel { grid-area: detail; overflow: visible; }
}
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid, .split, .connector-grid { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .status-form, .status-form.add { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .rail-group { flex-direction: row; flex-wrap: wrap; }
  .rail-title, .rail-link span, .me-text { display: none; }
  .rail-link.active::before { display: none; }
  .rail-footer { margin: 0 0 0 auto; border: 0; padding: 0; }
  .main { padding: 16px; }
  .ws-grid { grid-template-columns: 1fr; grid-template-areas: "list" "map" "detail"; }
  .list-panel { position: static; height: auto; max-height: 50vh; }
  .map-panel { height: 300px; }
  .contact-grid, .action-bar { grid-template-columns: 1fr; }
  .mapping-row { grid-template-columns: 1fr; }
  .import-summary { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
