/* ============================================================
   CRM Manifst : feuille de style
   Tokens repris de manifst/assets/css/style.css (indigo #6366f1,
   barre latérale #0f172a, Inter) ; s'appuie sur Bootstrap 5.3.
   ============================================================ */

:root {
  --primary:        #6366f1;
  --primary-dark:   #4f46e5;
  --primary-light:  #e0e7ff;
  --success:        #10b981;
  --warning:        #f59e0b;
  --danger:         #ef4444;
  --info:           #3b82f6;
  --sidebar-bg:     #0f172a;
  --sidebar-text:   #94a3b8;
  --sidebar-hover:  #1e293b;
  --bg:             #f8fafc;
  --surface:        #ffffff;
  --surface-alt:    #f1f5f9;
  --border:         #e2e8f0;
  --text-primary:   #1e293b;
  --text-secondary: #64748b;
  --text-muted:     #94a3b8;
  --bar:            #6366f1;
  --bar-track:      #eef2f7;
  --radius:         8px;
  --radius-lg:      12px;
  --shadow:         0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-lg:      0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.05);
  --sidebar-w:      232px;
  --header-h:       58px;
  --kb-col-bg:      #f1f4f8;
  --link:           #6366f1;
  --link-hover:     #4f46e5;
  --on-light-accent: #4f46e5;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg:             #0f172a;
  --surface:        #1e293b;
  --surface-alt:    #162032;
  --border:         #334155;
  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --primary-light:  rgba(99,102,241,.18);
  --bar:            #818cf8;
  --bar-track:      #273449;
  --kb-col-bg:      #162032;
  /* Indigo #6366f1 sur ardoise : contraste trop faible pour du texte, on éclaircit. */
  --link:           #818cf8;
  --link-hover:     #a5b4fc;
  --on-light-accent: #c7d2fe;
  --shadow:        0 1px 3px rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.25);
  --shadow-lg:      0 10px 15px -3px rgba(0,0,0,.35), 0 4px 6px -2px rgba(0,0,0,.25);
  color-scheme: dark;
  /* Bootstrap passe aussi en sombre (data-bs-theme, posé par theme.js) ;
     on aligne ses variables sur la palette slate du CRM au lieu de son gris #212529. */
  --bs-body-bg: var(--surface);
  --bs-body-bg-rgb: 30,41,59;
  --bs-body-color: var(--text-primary);
  --bs-body-color-rgb: 241,245,249;
  --bs-emphasis-color: #f8fafc;
  --bs-emphasis-color-rgb: 248,250,252;
  --bs-border-color: var(--border);
  --bs-border-color-translucent: rgba(148,163,184,.2);
  --bs-secondary-color: var(--text-secondary);
  --bs-secondary-bg: #273449;
  --bs-tertiary-color: var(--text-muted);
  --bs-tertiary-bg: var(--surface-alt);
  --bs-heading-color: var(--text-primary);
  --bs-link-color: #818cf8;
  --bs-link-color-rgb: 129,140,248;
  --bs-link-hover-color: #a5b4fc;
  --bs-link-hover-color-rgb: 165,180,252;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }
[data-theme="dark"] .text-danger { color: #fca5a5 !important; }
[data-theme="dark"] .text-success { color: #6ee7b7 !important; }
[data-theme="dark"] .text-warning { color: #fcd34d !important; }
h1, h2, h3, h4, h5 { color: var(--text-primary); font-weight: 700; letter-spacing: -.01em; }
.text-muted, .muted { color: var(--text-secondary) !important; }
.small-muted { font-size: 12px; color: var(--text-muted); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--sidebar-bg); color: var(--sidebar-text);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 16px 12px; z-index: 30;
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; }
.sidebar-logo:hover { text-decoration: none; color: #fff; }
/* Logo Manifst (assets/img/logo.svg). Ses dégradés finissent en quasi-noir :
   sur fond sombre il passe en blanc, comme le fait manifst/assets/js/logo-contrast.js.
   La barre latérale est toujours sombre ; la carte de connexion seulement en thème sombre. */
.brand-logo { display: block; flex-shrink: 0; object-fit: contain; }
.sidebar .brand-logo,
[data-theme="dark"] .login-card .brand-logo { filter: brightness(0) saturate(100%) invert(100%); }
.logo-name { font-weight: 800; font-size: 16px; letter-spacing: -.02em; }
.logo-name small { display: block; font-size: 11px; font-weight: 600; color: var(--sidebar-text); letter-spacing: .04em; text-transform: uppercase; }
.sidebar-section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 12px 10px 6px; font-weight: 600; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--sidebar-text); font-weight: 500; margin-bottom: 2px;
}
.sidebar-link i { font-size: 16px; width: 18px; text-align: center; }
.sidebar-link:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.sidebar-link.active { background: rgba(99,102,241,.18); color: #fff; }
.sidebar-link.active i { color: #a5b4fc; }
.sidebar-link .badge { margin-left: auto; font-size: 11px; }
/* En sombre, la barre latérale a la couleur du fond : un filet la détache. */
[data-theme="dark"] .sidebar { border-right: 1px solid #1e293b; }
.sidebar-bottom { margin-top: auto; border-top: 1px solid #1e293b; padding-top: 12px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.sidebar-user .user-name { color: #fff; font-weight: 600; font-size: 13px; line-height: 1.2; }
.sidebar-user .user-role { font-size: 11px; color: var(--sidebar-text); }
.sidebar-user .btn-icon { color: var(--sidebar-text); margin-left: auto; }
.sidebar-user .btn-icon:hover { color: #fff; background: var(--sidebar-hover); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--header-h); display: flex; align-items: center; gap: 12px;
  padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar .menu-toggle { display: none; }
.content { padding: 24px; max-width: 1480px; width: 100%; }
.content.wide { max-width: none; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-head .sub { color: var(--text-secondary); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Recherche globale ---------- */
.global-search { position: relative; flex: 1; max-width: 460px; }
.global-search input { padding-left: 34px; background: var(--surface-alt); border-color: transparent; }
.global-search input:focus { background: var(--surface); }
.global-search > i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  max-height: 70vh; overflow: auto; padding: 6px; display: none;
}
.search-results.open { display: block; }
.search-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); padding: 8px 10px 4px; font-weight: 600; }
.search-item { display: flex; gap: 10px; align-items: center; padding: 7px 10px; border-radius: 8px; color: var(--text-primary); }
.search-item:hover, .search-item.active { background: var(--surface-alt); text-decoration: none; color: var(--text-primary); }
.search-item i { color: var(--text-muted); }
.search-item .meta { color: var(--text-secondary); font-size: 12px; margin-left: auto; white-space: nowrap; }

/* ---------- Cartes ---------- */
.card-x {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); margin-bottom: 20px;
}
.card-x > .card-h {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card-x > .card-h h2, .card-x > .card-h h3 { font-size: 15px; margin: 0; }
.card-x > .card-b { padding: 16px 18px; }
.card-x > .card-b.p0 { padding: 0; }
.card-h .hint { font-size: 12px; color: var(--text-muted); }

/* ---------- Indicateurs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .label { color: var(--text-secondary); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.kpi .foot { color: var(--text-secondary); font-size: 12px; }
.progress-thin { height: 6px; background: var(--bar-track); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress-thin > span { display: block; height: 100%; background: var(--bar); border-radius: 999px; }
.progress-thin.done > span { background: var(--success); }

/* ---------- Graphiques en barres (HTML) ---------- */
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: 150px 1fr 96px; align-items: center; gap: 10px; font-size: 13px; }
.hbar .name { color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .name small { color: var(--text-muted); margin-left: 4px; }
.hbar .track { height: 12px; background: var(--bar-track); border-radius: 4px; position: relative; }
.hbar .fill { position: absolute; inset: 0 auto 0 0; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .val { text-align: right; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.hbar:hover .fill { filter: brightness(1.1); }

.vbars { display: flex; align-items: flex-end; gap: 14px; height: 180px; padding-top: 18px; border-bottom: 1px solid var(--border); }
.vbar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; position: relative; cursor: default; }
.vbar .vcol { width: 100%; max-width: 44px; background: var(--bar); border-radius: 4px 4px 0 0; min-height: 2px; }
.vbar.current .vcol { background: var(--primary-dark); }
[data-theme="dark"] .vbar.current .vcol { background: #a5b4fc; }
.vbar .top { font-size: 11px; color: var(--text-secondary); margin-bottom: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vbar-labels { display: flex; gap: 14px; margin-top: 6px; }
.vbar-labels span { flex: 1; text-align: center; font-size: 12px; color: var(--text-secondary); text-transform: capitalize; }
.chart-tip {
  position: fixed; pointer-events: none; z-index: 2000; background: #0f172a; color: #f1f5f9;
  font-size: 12px; padding: 6px 9px; border-radius: 6px; box-shadow: var(--shadow-lg); white-space: nowrap; display: none;
}

/* ---------- Tableaux ---------- */
.table-x { width: 100%; border-collapse: collapse; }
.table-x th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-secondary);
  font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-alt); white-space: nowrap;
}
.table-x td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table-x tr:last-child td { border-bottom: 0; }
.table-x tbody tr:hover { background: var(--surface-alt); }
.table-x tr.clickable { cursor: pointer; }
.table-x .right { text-align: right; }
.table-wrap { overflow-x: auto; }
.empty { text-align: center; color: var(--text-secondary); padding: 36px 16px; }
.empty i { font-size: 28px; display: block; margin-bottom: 8px; color: var(--text-muted); }

/* ---------- Filtres ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.filters .form-control, .filters .form-select { width: auto; min-width: 150px; }
.filters .search-input { min-width: 240px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 6px 12px; font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.active { background: var(--primary-light); color: var(--on-light-accent); font-weight: 600; }

/* ---------- Pastilles ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-alt); color: var(--text-secondary); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: 0 0 8px; }
.pill-stage { background: var(--surface-alt); color: var(--text-primary); }
.lc-prospect    { background: #f1f5f9; color: #475569; }
.lc-lead        { background: #dbeafe; color: #1d4ed8; }
.lc-opportunity { background: #ede9fe; color: #6d28d9; }
.lc-customer    { background: #d1fae5; color: #047857; }
.lc-partner     { background: #fef3c7; color: #b45309; }
.lc-churned     { background: #fee2e2; color: #b91c1c; }
[data-theme="dark"] .lc-prospect    { background: rgba(148,163,184,.15); color: #cbd5e1; }
[data-theme="dark"] .lc-lead        { background: rgba(59,130,246,.18); color: #93c5fd; }
[data-theme="dark"] .lc-opportunity { background: rgba(139,92,246,.18); color: #c4b5fd; }
[data-theme="dark"] .lc-customer    { background: rgba(16,185,129,.18); color: #6ee7b7; }
[data-theme="dark"] .lc-partner     { background: rgba(245,158,11,.18); color: #fcd34d; }
[data-theme="dark"] .lc-churned     { background: rgba(239,68,68,.18); color: #fca5a5; }
.warn-text { color: #b45309; }
.danger-text { color: #dc2626; }
[data-theme="dark"] .warn-text { color: #fcd34d; }
[data-theme="dark"] .danger-text { color: #fca5a5; }

.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #fff; flex: 0 0 auto; background: #6366f1;
}
.avatar.sm { width: 22px; height: 22px; font-size: 10px; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }

.btn-icon {
  border: 0; background: transparent; width: 32px; height: 32px; border-radius: 8px;
  display: inline-grid; place-items: center; color: var(--text-secondary);
}
.btn-icon:hover { background: var(--surface-alt); color: var(--text-primary); }
.btn-icon:disabled { opacity: .35; cursor: default; background: transparent; color: var(--text-secondary); }
.btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary-dark); --bs-btn-hover-border-color: var(--primary-dark); --bs-btn-active-bg: var(--primary-dark); }
.btn { font-weight: 600; border-radius: 8px; }
.form-label { font-weight: 600; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.form-control, .form-select { border-radius: 8px; font-size: 14px; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.18); }
[data-theme="dark"] .form-control, [data-theme="dark"] .form-select { background-color: var(--surface-alt); border-color: var(--border); color: var(--text-primary); }
[data-theme="dark"] .form-control::placeholder { color: var(--text-muted); }
/* Sans ça, un champ désactivé ou en lecture seule ressemble à un champ saisissable. */
[data-theme="dark"] .form-control:disabled, [data-theme="dark"] .form-select:disabled,
[data-theme="dark"] .form-control[readonly] { background-color: var(--bg); color: var(--text-secondary); }
[data-theme="dark"] .form-control-color { padding: .25rem; }
[data-theme="dark"] .form-check-input:not(:checked) { background-color: var(--surface-alt); border-color: #475569; }
[data-theme="dark"] .input-group-text { background-color: var(--bg); border-color: var(--border); color: var(--text-secondary); }
[data-theme="dark"] .modal-content { background: var(--surface); color: var(--text-primary); border-color: var(--border); }
[data-theme="dark"] .modal-backdrop { --bs-backdrop-opacity: .7; }
[data-theme="dark"] .btn-outline-secondary { --bs-btn-color: var(--text-secondary); --bs-btn-border-color: var(--border); --bs-btn-hover-bg: var(--surface-alt); --bs-btn-hover-color: var(--text-primary); --bs-btn-hover-border-color: #475569; --bs-btn-active-bg: var(--surface-alt); --bs-btn-active-color: var(--text-primary); --bs-btn-active-border-color: #475569; }
[data-theme="dark"] .btn-link { --bs-btn-color: var(--link); --bs-btn-hover-color: var(--link-hover); --bs-btn-active-color: var(--link-hover); }
[data-theme="dark"] .nav-tabs { --bs-nav-tabs-border-color: var(--border); --bs-nav-tabs-link-hover-border-color: var(--border) var(--border) var(--border); --bs-nav-tabs-link-active-color: var(--text-primary); --bs-nav-tabs-link-active-bg: var(--bg); --bs-nav-tabs-link-active-border-color: var(--border) var(--border) var(--bg); }
[data-theme="dark"] .nav-tabs .nav-link:not(.active) { color: var(--text-secondary); }
[data-theme="dark"] .nav-tabs .nav-link:not(.active):hover { color: var(--text-primary); }
[data-theme="dark"] .table { --bs-table-bg: transparent; --bs-table-color: var(--text-primary); --bs-table-border-color: var(--border); --bs-table-hover-bg: var(--surface-alt); }
[data-theme="dark"] .alert-danger  { --bs-alert-bg: rgba(239,68,68,.12);  --bs-alert-border-color: rgba(239,68,68,.35);  --bs-alert-color: #fca5a5; }
[data-theme="dark"] .alert-warning { --bs-alert-bg: rgba(245,158,11,.12); --bs-alert-border-color: rgba(245,158,11,.35); --bs-alert-color: #fcd34d; }
[data-theme="dark"] .alert-success { --bs-alert-bg: rgba(16,185,129,.12); --bs-alert-border-color: rgba(16,185,129,.35); --bs-alert-color: #6ee7b7; }
[data-theme="dark"] .alert-info    { --bs-alert-bg: rgba(99,102,241,.14); --bs-alert-border-color: rgba(99,102,241,.4);  --bs-alert-color: #c7d2fe; }
[data-theme="dark"] .alert .alert-link, [data-theme="dark"] .alert a { color: inherit; text-decoration: underline; }
[data-theme="dark"] .dropdown-menu { --bs-dropdown-bg: var(--surface); --bs-dropdown-link-color: var(--text-primary); --bs-dropdown-border-color: var(--border); --bs-dropdown-link-hover-bg: var(--surface-alt); --bs-dropdown-link-hover-color: var(--text-primary); }

/* ---------- Pipeline (kanban) ---------- */
.pipeline-summary { display: flex; gap: 22px; flex-wrap: wrap; color: var(--text-secondary); font-size: 13px; }
.pipeline-summary b { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; min-height: calc(100vh - 240px); }
.kb-col { flex: 0 0 272px; background: var(--kb-col-bg); border-radius: var(--radius-lg); display: flex; flex-direction: column; max-height: calc(100vh - 230px); }
.kb-col.closed { flex-basis: 232px; }
.kb-head { padding: 12px 12px 8px; border-top: 3px solid var(--stage-color, #94a3b8); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.kb-head .t { display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 13px; }
.kb-head .t .count { background: var(--surface); color: var(--text-secondary); border-radius: 999px; padding: 0 8px; font-size: 12px; }
.kb-head .s { color: var(--text-secondary); font-size: 12px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kb-body { padding: 4px 8px 10px; overflow-y: auto; flex: 1; min-height: 80px; border-radius: 0 0 var(--radius-lg) var(--radius-lg); transition: background .12s; }
.kb-body.drag-over { background: rgba(99,102,241,.10); outline: 2px dashed rgba(99,102,241,.45); outline-offset: -4px; }
.kb-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
  box-shadow: var(--shadow); cursor: grab; user-select: none;
}
.kb-card:hover { border-color: #c7d2fe; }
[data-theme="dark"] .kb-card:hover { border-color: #6366f1; }
.kb-card.dragging { opacity: .45; }
.kb-card .co { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kb-card .ti { font-weight: 600; margin: 2px 0 8px; line-height: 1.3; color: var(--text-primary); }
.kb-card .row1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; }
.kb-card .mrr { font-weight: 700; font-variant-numeric: tabular-nums; }
.kb-card .next { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); font-size: 12px; color: var(--text-secondary); display: flex; gap: 6px; align-items: center; }
.kb-card .next.late { color: #dc2626; }
.kb-card .next.none { color: #b45309; }
[data-theme="dark"] .kb-card .next.late { color: #fca5a5; }
[data-theme="dark"] .kb-card .next.none { color: #fcd34d; }

/* ---------- Fiche (deal / compte / contact) ---------- */
.record-head { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.record-head .ttl { flex: 1; min-width: 260px; }
.record-head h1 { font-size: 22px; margin: 0 0 4px; }
.record-meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--text-secondary); font-size: 13px; align-items: center; }
.record-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; }
.fields { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 13px; }
.fields dt { color: var(--text-secondary); font-weight: 500; }
.fields dd { margin: 0; word-break: break-word; }
.big-figure { font-size: 28px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

.stepper { display: flex; gap: 4px; margin: 18px 0 20px; flex-wrap: wrap; }
.stepper button {
  flex: 1; min-width: 96px; border: 0; padding: 8px 10px; font-size: 12px; font-weight: 600;
  background: var(--surface-alt); color: var(--text-secondary); position: relative; border-radius: 6px;
}
.stepper button:hover:not(:disabled) { background: var(--primary-light); color: var(--on-light-accent); }
.stepper button.past { background: var(--primary-light); color: var(--on-light-accent); }
.stepper button.current { background: var(--primary); color: #fff; }
.stepper button.won.current { background: var(--success); }
.stepper button.lost.current { background: var(--danger); }
.stepper button:disabled { cursor: default; }
/* Le survol ne doit pas éteindre l'étape en cours (texte blanc sur fond pâle). */
.stepper button.current:hover:not(:disabled) { background: var(--primary-dark); color: #fff; }
.stepper button.won.current:hover:not(:disabled) { background: #059669; }
.stepper button.lost.current:hover:not(:disabled) { background: #dc2626; }

/* ---------- Timeline d'activités ---------- */
.composer { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); margin-bottom: 16px; }
.composer-tabs { display: flex; gap: 2px; padding: 6px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.composer-tabs button { border: 0; background: transparent; border-radius: 6px; padding: 6px 10px; font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.composer-tabs button.active { background: var(--primary-light); color: var(--on-light-accent); font-weight: 600; }
.composer-body { padding: 12px; }
.timeline { position: relative; }
.tl-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.tl-item:last-child { border-bottom: 0; }
.tl-icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-alt); color: var(--text-secondary); flex: 0 0 32px; }
.tl-item.todo .tl-icon { background: var(--primary-light); color: var(--link); }
.tl-item.late .tl-icon { background: #fee2e2; color: #dc2626; }
[data-theme="dark"] .tl-item.late .tl-icon { background: rgba(239,68,68,.18); color: #fca5a5; }
.tl-main { flex: 1; min-width: 0; }
.tl-title { font-weight: 600; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.tl-title .when { font-weight: 400; color: var(--text-secondary); font-size: 12px; }
.tl-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.tl-body { margin-top: 6px; white-space: pre-wrap; word-break: break-word; font-size: 13px; color: var(--text-primary); }
.tl-actions { display: flex; gap: 2px; align-items: flex-start; }
.done-check { width: 18px; height: 18px; cursor: pointer; accent-color: var(--success); margin-top: 7px; }

/* ---------- Liste de tâches ---------- */
.task-group-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); margin: 18px 0 8px; display: flex; gap: 8px; align-items: center; }
.task-group-title .n { background: var(--surface-alt); border-radius: 999px; padding: 0 8px; }
.task-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.task-row:last-child { border-bottom: 0; }
.task-row .done-check { margin-top: 3px; }
.task-row.done .t-subj { text-decoration: line-through; color: var(--text-muted); }
.task-row .t-main { flex: 1; min-width: 0; }
.task-row .t-subj { font-weight: 600; }
.task-row .t-links { font-size: 12px; color: var(--text-secondary); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.task-row .t-when { font-size: 12px; white-space: nowrap; color: var(--text-secondary); text-align: right; }

/* ---------- Fenêtres de saisie ---------- */
.modal-header { padding: 16px 24px; align-items: flex-start; }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.modal-body { padding: 18px 24px 22px; }
.modal-footer { padding: 12px 24px; background: var(--surface-alt); border-top: 1px solid var(--border); }
.form-grid { --bs-gutter-y: .85rem; }
.form-grid .form-label { margin-bottom: 4px; }
.form-grid .form-text { font-size: 12px; margin-top: 3px; }
/* Titre de section : sépare les blocs du formulaire */
.form-section {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin-top: 1.4rem !important; padding-top: 1rem; border-top: 1px solid var(--border);
}
.form-grid > .form-section:first-child, .form-grid > [data-field="_test"] + .form-section { margin-top: 0 !important; padding-top: 0; border-top: 0; }
.form-section h6 {
  margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary);
  display: inline-flex; align-items: center; gap: 7px;
}
.form-section h6 i { color: var(--primary); font-size: 14px; }
.form-section .hint { font-size: 12px; color: var(--text-muted); }
.form-break { width: 100%; height: 0; margin: 0 !important; padding: 0 !important; }
/* Lignes d'offre d'une opportunité */
.lines-box { background: var(--surface-alt); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px 4px; }
.lines-head { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 4px; }
.lines-box .form-select, .lines-box .form-control { background-color: var(--surface); }
[data-theme="dark"] .lines-box .form-select:not(:disabled), [data-theme="dark"] .lines-box .form-control:not(:disabled):not([readonly]) { background-color: var(--surface); }
/* Pièces jointes d'un e-mail */
.attach-box { border: 1px dashed var(--border); border-radius: 10px; padding: 10px 12px; transition: background .12s, border-color .12s; }
.attach-box.drag-over { background: var(--primary-light); border-color: var(--primary); }
.attach-list { list-style: none; margin: 0; padding: 0; }
.attach-list:not(:empty) { margin-top: 8px; }
.attach-list li { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; border-top: 1px solid var(--border); min-width: 0; }
.attach-list li:first-child { border-top: 0; }
.attach-list li > i { color: var(--text-muted); }
.attach-list .grow { flex: 1; min-width: 0; }
.attach-list .btn-icon { width: 26px; height: 26px; }
/* Récapitulatif de valeur */
.value-strip { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.value-strip > div { padding: 10px 14px; border-left: 1px solid var(--border); }
.value-strip > div:first-child { border-left: 0; }
.value-strip span { display: block; font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; }
.value-strip b { display: block; font-size: 18px; font-weight: 800; color: var(--text-primary); }
.value-strip > div:nth-child(2) b { color: var(--primary); }
[data-theme="dark"] .value-strip > div:nth-child(2) b { color: #a5b4fc; }
@media (max-width: 640px) {
  .value-strip { grid-template-columns: repeat(2, 1fr); }
  .value-strip > div:nth-child(3) { border-left: 0; }
  .value-strip > div:nth-child(n+3) { border-top: 1px solid var(--border); }
}

/* ---------- Lookup (autocomplétion) ---------- */
.lookup { position: relative; }
.lookup-menu {
  position: absolute; z-index: 1080; top: calc(100% + 4px); left: 0; right: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); max-height: 240px; overflow: auto; display: none;
}
.lookup-menu.open { display: block; }
.lookup-menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 12px; color: var(--text-primary); }
.lookup-menu button:hover, .lookup-menu button.active { background: var(--surface-alt); }
.lookup-menu button small { color: var(--text-secondary); margin-left: 6px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; }
.toast-x { background: #0f172a; color: #f1f5f9; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13px; display: flex; gap: 8px; align-items: center; max-width: 380px; animation: toast-in .16s ease-out; }
.toast-x.error { background: #991b1b; }
/* Bulle et toast #0f172a = la couleur du fond en sombre : invisibles sans relief. */
[data-theme="dark"] .toast-x, [data-theme="dark"] .chart-tip { background: #334155; border: 1px solid #475569; }
[data-theme="dark"] .toast-x.error { background: #7f1d1d; border-color: #b91c1c; }
.toast-x.success i { color: #6ee7b7; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Connexion ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 10% -10%, rgba(99,102,241,.18), transparent), var(--bg); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 32px; }

/* ---------- Divers ---------- */
.loading { color: var(--text-muted); padding: 30px; text-align: center; }
.skeleton { background: linear-gradient(90deg, var(--surface-alt), var(--border), var(--surface-alt)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 6px; height: 14px; }
@keyframes sk { to { background-position: -200% 0; } }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--border); }
.list-plain li:last-child { border-bottom: 0; }
.list-plain .grow { flex: 1; min-width: 0; }
.list-plain .grow a, .ellipsis { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-top: 1px solid var(--border); color: var(--text-secondary); font-size: 13px; }
.notes-box { white-space: pre-wrap; word-break: break-word; font-size: 13px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .record-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .topbar { padding: 0 16px; }
  .topbar .menu-toggle { display: inline-grid; }
  .content { padding: 16px; }
  .hbar { grid-template-columns: 110px 1fr 80px; }
  .fields { grid-template-columns: 110px 1fr; }
  .filters .form-control, .filters .form-select, .filters .search-input { min-width: 0; flex: 1 1 140px; }
}

/* ---------------- Assistant IA (agents à la demande) ---------------- */
.btn-ai {
  --bs-btn-color: var(--primary-dark);
  --bs-btn-bg: var(--primary-light);
  --bs-btn-border-color: transparent;
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--primary);
  --bs-btn-hover-border-color: transparent;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--primary-dark);
  --bs-btn-disabled-color: var(--primary-dark);
  --bs-btn-disabled-bg: var(--primary-light);
  --bs-btn-disabled-border-color: transparent;
  font-weight: 600;
}
[data-theme="dark"] .btn-ai { --bs-btn-color: #c7d2fe; --bs-btn-disabled-color: #c7d2fe; }
.ai-ico, .ai-ico i { color: var(--primary); }
[data-theme="dark"] .ai-ico, [data-theme="dark"] .ai-ico i { color: #a5b4fc; }
.ai-box { border: 1px dashed var(--primary); background: var(--primary-light); border-radius: var(--radius); padding: 10px; }
.ai-box textarea, [data-theme="dark"] .ai-box textarea { background: var(--surface); }
.ai-busy { display: flex; gap: 10px; align-items: center; padding: 28px 4px; color: var(--text-secondary); }
.ai-busy .spinner-border { color: var(--primary); }
.ai-note { font-size: 12px; color: var(--text-muted); }
.ai-sec { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.ai-sec.ai-empty { font-size: 13px; color: var(--text-secondary); }
.ai-sec-h { display: flex; gap: 8px; align-items: center; font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.ai-sec.applied, .ai-change.applied { opacity: .55; }
.ai-change { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; padding: 4px 0; }
.ai-change .k { font-weight: 600; white-space: nowrap; }
.ai-change .from { color: var(--text-muted); text-decoration: line-through; }
.ai-change input.form-control:not([type=date]) { flex: 1 1 260px; }
.ai-questions ul, .ai-brief ul { padding-left: 18px; margin: 0; }
.ai-questions li, .ai-brief li { margin-bottom: 4px; font-size: 13.5px; }
.ai-brief h6 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); margin: 18px 0 6px; }
.ai-brief p { font-size: 13.5px; }
.ai-objective { background: var(--primary-light); border-radius: var(--radius); padding: 10px 12px; font-weight: 600; }
.ai-people { list-style: none; padding-left: 0 !important; }
.ai-people li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.ai-people li:last-child { border-bottom: 0; }
.ai-focus { max-width: 360px; }
@media (max-width: 575.98px) { .ai-focus { max-width: none; flex-basis: 100%; } }
.ai-action { padding: 8px 0; border-top: 1px solid var(--border); }
.ai-action:first-of-type { border-top: 0; padding-top: 0; }
.ai-action.applied { opacity: .55; }
.ai-action .k { font-size: 13px; }
.ai-name { width: 150px; flex: 0 1 150px; }

/* ---------------- Journal des modifications ---------------- */
.audit-list li.audit-item { align-items: flex-start; }
.audit-ico { margin-top: 2px; color: var(--text-muted); }
.audit-ico.a-create { color: var(--success); }
.audit-ico.a-delete { color: var(--danger); }
.audit-ico.a-merge { color: var(--primary); }
.audit-changes { list-style: none; padding: 0; margin: 4px 0 0; font-size: 12.5px; }
.audit-changes li { padding: 1px 0; border: 0 !important; display: block !important; }
.audit-changes .k { color: var(--text-secondary); font-weight: 600; margin-right: 4px; }
.audit-changes .from { color: var(--text-muted); text-decoration: line-through; }
.audit-changes .to { color: var(--text-primary); }
.audit-changes .bi { font-size: 11px; color: var(--text-muted); }

/* ---------------- Fusion de doublons ---------------- */
.merge-cards { display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap; }
.merge-card { flex: 1 1 220px; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.merge-card.keep { border-color: var(--success); }
.merge-card.drop { border-style: dashed; }
.merge-card .text-uppercase { font-size: 11px; letter-spacing: .04em; }
.merge-table th { font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; }
.merge-opt { display: flex; gap: 6px; align-items: flex-start; font-size: 13px; cursor: pointer; margin: 0; word-break: break-word; }
.merge-opt input { margin-top: 3px; flex-shrink: 0; }
.dup-pair > div { margin-bottom: 2px; }

/* ---------------- Analyse du pipeline / coach ---------------- */
.pill.sig { background: rgba(245,158,11,.12); color: #b45309; font-weight: 500; }
[data-theme="dark"] .pill.sig { color: #fbbf24; }
.pill.prio-1 { background: rgba(239,68,68,.14); color: #b91c1c; }
.pill.prio-2 { background: rgba(245,158,11,.16); color: #b45309; }
.pill.prio-3 { background: var(--surface-alt); color: var(--text-secondary); }
[data-theme="dark"] .pill.prio-1 { color: #fca5a5; }
[data-theme="dark"] .pill.prio-2 { color: #fbbf24; }
.pipe-item .ai-action { border-top: 0; padding-top: 4px; }
.coach-verdict { display: flex; gap: 12px; align-items: flex-start; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.coach-verdict > .bi { font-size: 22px; line-height: 1; }
.coach-verdict.v-ok { background: rgba(16,185,129,.12); }
.coach-verdict.v-ok > .bi { color: var(--success); }
.coach-verdict.v-warn { background: rgba(245,158,11,.14); }
.coach-verdict.v-warn > .bi { color: var(--warning); }
.coach-verdict.v-bad { background: rgba(239,68,68,.12); }
.coach-verdict.v-bad > .bi { color: var(--danger); }
.coach-h { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); margin: 16px 0 6px; }
.coach-meddic th { font-size: 13px; white-space: nowrap; width: 1%; }
.coach-meddic td { font-size: 13px; }
.coach-meddic td:nth-child(2) { white-space: nowrap; width: 1%; }
.coach-meddic .m-ok { color: var(--success); }
.coach-meddic .m-part { color: #b45309; }
[data-theme="dark"] .coach-meddic .m-part { color: #fcd34d; }
.coach-meddic .m-miss { color: var(--danger); }
