:root {
  --sidebar-bg: #1c1f26;
  --sidebar-text: #e8eaed;
  --sidebar-muted: #9aa0a6;
  --accent: #5f3dc4;
  --accent-hover: #4c2fa3;
  --rail-bg: #3b2a5a;
  --surface: #ffffff;
  --border: #e9ecef;
  --bg: #f4f6f8;
  --text: #212529;
  --danger: #fa5252;
  --success: #51cf66;
  --warning: #ffd43b;
}

* {
  box-sizing: border-box;
}

/* Coque plein écran (classe posée par crm-main.js) : seul .pd-main-inner défile. */
html.crm-app-root {
  height: 100%;
}

body.crm-app-root {
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

/* Bandeau préproduction (activé seulement si API build-info.stage = preprod) */
.crm-preprod-banner {
  background: linear-gradient(90deg, #1864ab 0%, #228be6 100%);
  color: #fff;
  padding: 0.5rem 1rem;
  font-size: 13px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  z-index: 150;
}

.crm-preprod-banner.hidden {
  display: none !important;
}

.crm-preprod-banner-inner {
  max-width: min(1200px, 100%);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
}

.crm-preprod-banner-versions {
  opacity: 0.95;
  flex: 1;
  min-width: 200px;
}

.crm-preprod-banner-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.crm-preprod-banner .btn-primary {
  background: #fff;
  color: #1864ab;
  border-color: rgba(255, 255, 255, 0.85);
}

.crm-preprod-banner .btn-primary:hover {
  background: #f1f3f5;
}

.crm-preprod-banner .btn-ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.45);
}

.crm-preprod-banner .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
}

body.crm-app-root .pd-app {
  flex: 1;
  min-height: 0;
}

.pd-app {
  display: grid;
  grid-template-columns: 56px 1fr;
  grid-template-rows: 1fr;
  flex: 1;
  min-height: 0;
}

.pd-rail {
  background: var(--rail-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.65rem 0 0.5rem;
  gap: 0.35rem;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  overflow: visible;
  z-index: 100;
  position: relative;
  min-height: 0;
  align-self: stretch;
}

.pd-rail-brand-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  margin-bottom: 0.25rem;
}

.pd-rail-logo {
  width: 40px;
  height: auto;
  max-height: 26px;
  object-fit: contain;
  display: block;
  opacity: 0.96;
}

.pd-rail-brand {
  font-weight: 400;
  font-size: 11px;
  letter-spacing: 0.06em;
  margin-bottom: 0;
  opacity: 0.9;
}

.pd-rail-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pd-rail-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.pd-rail-btn.active {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.35);
}

.pd-main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  position: relative;
  z-index: 0;
}

.pd-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pd-search-wrap {
  position: relative;
  flex: 1;
  max-width: min(420px, 100%);
}

.pd-search {
  width: 100%;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  opacity: 0.85;
}

.pd-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: min(70vh, 440px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  z-index: 400;
}

.pd-search-results.hidden {
  display: none !important;
}

.pd-search-hit {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.75rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: none;
  font: inherit;
  cursor: pointer;
  color: inherit;
}

.pd-search-hit:last-child {
  border-bottom: none;
}

.pd-search-hit:hover {
  background: rgba(0, 0, 0, 0.04);
}

.pd-search-hit-type {
  font-size: 11px;
  color: #868e96;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.15rem;
}

.pd-search-hit-snippet {
  margin-top: 0.25rem;
  font-size: 12px;
  line-height: 1.35;
}

.pd-main-inner {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
}

.sidebar .brand {
  padding: 0 1rem 1rem;
  font-weight: 700;
  font-size: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar nav a {
  display: block;
  padding: 0.65rem 1.25rem;
  color: var(--sidebar-muted);
  text-decoration: none;
  border-left: 3px solid transparent;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border-left-color: var(--accent);
}

main.main-content {
  padding: 1.25rem 1.5rem;
  overflow: auto;
}

h2 {
  margin: 0 0 1rem;
  font-size: 1.35rem;
  font-weight: 600;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.commune-enrich-panel {
  margin-top: 0.75rem;
}

.commune-enrich-live-log {
  max-height: 14rem;
  overflow: auto;
  font-size: 12px;
  margin: 0.5rem 0 0;
  white-space: pre-wrap;
}

.commune-enrich-banner {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(81, 207, 102, 0.45);
  background: rgba(81, 207, 102, 0.1);
  margin-bottom: 1rem;
  font-size: 13px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.65rem;
}

button.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  cursor: pointer;
}

button.btn-primary:hover {
  background: var(--accent-hover);
}

button.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
}

button.btn-violet {
  background: #6d28d9;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  cursor: pointer;
}

button.btn-violet:hover {
  background: #5b21b6;
}

button.btn-violet:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Actions liste campagnes (couleurs demandées) */
button.btn-camp-green.btn-sm {
  background: #15803d;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  font-weight: 500;
}
button.btn-camp-green.btn-sm:hover {
  background: #166534;
}

button.btn-camp-gray.btn-sm {
  background: #6b7280;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  font-weight: 500;
}
button.btn-camp-gray.btn-sm:hover {
  background: #4b5563;
}

button.btn-camp-trash.btn-sm {
  background: #b91c1c;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  font-weight: 700;
}
button.btn-camp-trash.btn-sm:hover {
  background: #991b1b;
}

button.btn-camp-modify.btn-sm {
  background: #fff;
  color: #1e293b;
  border: 1px solid #94a3b8;
  border-radius: 6px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  font-weight: 500;
}
button.btn-camp-modify.btn-sm:hover {
  background: #f8fafc;
  border-color: #64748b;
}

button.btn-camp-pipeline.btn-sm {
  padding: 0.45rem 0.85rem;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data-table th,
table.data-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.6rem;
  text-align: left;
}

table.data-table th {
  background: #f1f3f5;
  font-weight: 600;
}

table.data-table tr.lead-row {
  cursor: pointer;
}

table.data-table tr.lead-row:hover td {
  filter: brightness(0.98);
}

tr.tone-neutral td {
  background: transparent;
}

tr.tone-red td {
  background: rgba(250, 82, 82, 0.12);
}

tr.tone-green td {
  background: rgba(81, 207, 102, 0.15);
}

tr.tone-yellow td {
  background: rgba(255, 212, 59, 0.25);
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 12px;
  background: #e9ecef;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-backdrop.open {
  display: flex;
}

.crm-dialog {
  border: none;
  border-radius: 12px;
  padding: 1.25rem 1.35rem;
  max-width: min(560px, 94vw);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

.crm-dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.crm-dialog-wide {
  max-width: min(640px, 96vw);
}

.cf-qual-kind-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0.75rem 0;
}

.cf-qual-nq-label {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  font-size: 13px;
  cursor: pointer;
}

.cf-trash-list {
  max-height: 320px;
  overflow: auto;
  font-size: 13px;
}

.cf-trash-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.cf-equipments-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-bottom: 0.45rem;
}

.cf-equipments-head h4 {
  margin: 0;
}

.cf-centers-toolbar {
  display: none;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}

.cf-centers-toolbar.visible {
  display: flex;
}

.cf-centers-toolbar .btn-danger-outline {
  border-color: rgba(185, 28, 28, 0.55);
  color: #b91c1c;
}

.cf-centers-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.cf-centers-table th,
.cf-centers-table td {
  vertical-align: top;
  padding: 0.45rem 0.35rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.cf-centers-table th:first-child,
.cf-centers-table td.cf-centre-chk-cell {
  width: 2rem;
}

.cf-centre-cell {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.cf-centre-title-row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.cf-centre-title-row .cf-merge-badge {
  margin-right: 0;
  flex-shrink: 0;
}

.cf-centre-title-row .cf-centre-title {
  flex: 1;
  min-width: 0;
}

.cf-centre-row--structure {
  background: rgba(139, 92, 246, 0.14);
}

.cf-centre-row--service {
  background: rgba(249, 115, 22, 0.14);
}

.cf-centre-row--nq {
  background: rgba(239, 68, 68, 0.14);
}

.cf-merge-badge {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  vertical-align: middle;
}

.cf-ville-q-badge {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-right: 0.15rem;
}

.cf-ville-q-inner {
  display: inline-flex;
  width: 1.25rem;
  height: 1.25rem;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(22, 101, 52, 0.85);
  font-weight: 800;
  font-size: 0.72rem;
  color: #166534;
  border-radius: 3px;
}

.enrich-row-ok .cf-ville-q-inner {
  border-color: rgba(22, 101, 52, 0.85);
  color: #166534;
}

.enrich-row-warn .cf-ville-q-inner,
.enrich-row-fail .cf-ville-q-inner {
  border-color: rgba(30, 41, 59, 0.55);
  color: #334155;
}

.cf-merge-badge-inner {
  display: inline-flex;
  width: 1.25rem;
  height: 1.25rem;
  align-items: center;
  justify-content: center;
  border: 2px solid currentColor;
  font-weight: 800;
  font-size: 0.72rem;
  color: inherit;
}

.cf-centre-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.cf-qual-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
}

.cf-qual-tag--nq {
  background: rgba(239, 68, 68, 0.22);
  color: #991b1b;
}

.cf-qual-tag--structure {
  background: rgba(139, 92, 246, 0.28);
  color: #5b21b6;
}

.cf-qual-tag--service {
  background: rgba(249, 115, 22, 0.28);
  color: #c2410c;
}

.cf-centre-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.cf-email-pill {
  display: inline-block;
  background: rgba(148, 163, 184, 0.25);
  color: #1d4ed8;
  padding: 0.2rem 0.55rem;
  border-radius: 8px;
  font-size: 12px;
}

.cf-email-pill a {
  color: inherit;
  text-decoration: none;
}

.cf-tel-links a {
  color: #2563eb;
  font-size: 12px;
  margin-right: 0.5rem;
}

.cf-centre-title {
  font-weight: 600;
  text-decoration: none;
  color: inherit;
}

.cf-centre-title:hover {
  text-decoration: underline;
}

.modal {
  background: var(--surface);
  border-radius: 10px;
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  padding: 1.25rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.modal h3 {
  margin: 0 0 0.75rem;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

button.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 12px;
}

.pd-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

.commune-pills-row {
  font-size: 12px;
}

.commune-pill {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  margin-right: 0.35rem;
  background: #e9ecef;
  border: 1px solid var(--border);
}

.commune-pill.pill-ok {
  background: rgba(81, 207, 102, 0.2);
  border-color: rgba(81, 207, 102, 0.5);
}

.commune-pill.pill-warn {
  background: rgba(255, 212, 59, 0.35);
  border-color: rgba(230, 180, 40, 0.6);
}

.commune-pill.pill-fail {
  background: rgba(250, 82, 82, 0.15);
  border-color: rgba(250, 82, 82, 0.45);
}

.contact-base-tags-cell {
  line-height: 1.5;
  max-width: 22rem;
}

.contact-base-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 0.12rem 0.4rem;
  margin: 0.1rem 0.2rem 0.1rem 0;
  border-radius: 4px;
  background: rgba(95, 61, 196, 0.12);
  color: #3b2a5a;
  border: 1px solid rgba(95, 61, 196, 0.25);
  white-space: nowrap;
}

.enrich-modal-toolbar {
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.base-enrich-sort {
  margin-left: 0.25rem;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  font: inherit;
  background: var(--surface);
}

.base-enrich-toolbar {
  margin-bottom: 0.5rem;
  gap: 0.5rem;
  align-items: center;
}

.base-enrich-rate-banner {
  margin: 0.5rem 0;
  padding: 0.55rem 0.75rem;
  background: #fff;
  color: #000;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
}

.contacts-row-clickable {
  cursor: pointer;
}

.contact-enrich-body .contact-dl dt {
  font-weight: 600;
  margin-top: 0.55rem;
}

.contact-enrich-body .contact-dl dd {
  margin: 0.15rem 0 0 0.25rem;
}

button.contact-enrich-centre-link {
  display: block;
  margin: 0.35rem 0;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  font: inherit;
  text-align: left;
}

.enrich-commune-panel {
  padding: 0;
  max-height: min(52vh, 440px);
  overflow: auto;
  margin-bottom: 0.75rem;
}

.enrich-commune-list {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.enrich-commune-list tbody tr:hover td {
  background: rgba(241, 243, 245, 0.85);
}

.enrich-commune-list tbody tr.enrich-row-ok td {
  background: rgba(34, 197, 94, 0.2);
}

.enrich-commune-list tbody tr.enrich-row-warn td {
  background: rgba(250, 204, 21, 0.35);
}

.enrich-commune-list tbody tr.enrich-row-fail td {
  background: rgba(248, 113, 113, 0.3);
}

#villes-table tbody tr.enrich-row-ok td {
  background: rgba(34, 197, 94, 0.2);
}

#villes-table tbody tr.enrich-row-warn td {
  background: rgba(250, 204, 21, 0.35);
}

#villes-table tbody tr.enrich-row-fail td {
  background: rgba(248, 113, 113, 0.3);
}

/* Fiche contact (type Pipedrive) */
.contact-fiche-root {
  min-height: 60vh;
}

.contact-fiche-bar {
  margin-bottom: 0.75rem;
}

.contact-fiche-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 1rem;
  align-items: start;
}

@media (max-width: 900px) {
  .contact-fiche-layout {
    grid-template-columns: 1fr;
  }
}

.contact-fiche-sidebar {
  font-size: 14px;
}

.contact-fiche-main-col {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.cf-subtitle {
  margin: 0 0 0.5rem 0;
  font-size: 15px;
}

.cf-tab-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.cf-kind-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.cf-composer-body {
  width: 100%;
  font: inherit;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  resize: vertical;
  min-height: 4.5rem;
  box-sizing: border-box;
}

.cf-summary-input {
  width: 100%;
  margin-top: 0.4rem;
  font: inherit;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-sizing: border-box;
}

.cf-history-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.cf-history-list {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.cf-trace-card {
  border-left: 3px solid var(--border);
  padding: 0.45rem 0.6rem 0.55rem 0.75rem;
  background: var(--surface);
  border-radius: 6px;
  font-size: 13px;
}

.cf-trace-card.cf-trace-note {
  background: #fffbea;
  border-left-color: #eab308;
}

.cf-trace-meta {
  font-size: 11px;
  color: var(--muted, #64748b);
  margin-bottom: 0.25rem;
}

.cf-trace-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 0.1rem 0.38rem;
  margin-right: 0.35rem;
  border-radius: 4px;
  background: rgba(95, 61, 196, 0.14);
  color: #433;
}

.cf-trace-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.cf-trace-body {
  white-space: pre-wrap;
  word-break: break-word;
}

.cf-interloc-block h4 {
  margin-bottom: 0.35rem;
}

.cf-interloc-new {
  margin-bottom: 0.65rem;
}

.cf-interloc-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.cf-interloc-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  background: #fafbfc;
  font-size: 13px;
}

.cf-interloc-card--primary {
  background: rgba(253, 224, 71, 0.28);
  border-color: rgba(202, 138, 4, 0.35);
}

.cf-interloc-card--secondary {
  background: rgba(219, 234, 254, 0.75);
  border-color: rgba(59, 130, 246, 0.4);
}

.cf-interloc-secondary-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.35);
  color: #1e40af;
  margin-bottom: 0.25rem;
}

.cf-interloc-primary-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: rgba(234, 179, 8, 0.45);
  color: #713f12;
  margin-bottom: 0.25rem;
}

.cf-interloc-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.45rem;
}

.cf-interloc-role {
  font-weight: 600;
  color: #343a40;
  margin-bottom: 0.2rem;
}

.cf-interloc-name {
  font-size: 13px;
  margin-bottom: 0.35rem;
}

.cf-interloc-row {
  margin-top: 0.2rem;
  word-break: break-word;
}

.cf-interloc-label {
  display: inline-block;
  min-width: 2.25rem;
  color: #868e96;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-right: 0.25rem;
}

.cf-interloc-notes {
  margin-top: 0.35rem;
  font-size: 12px;
  color: #495057;
  white-space: pre-wrap;
}

.cf-brevo-sync-log-body {
  max-height: min(420px, 55vh);
  overflow: auto;
  margin: 0.5rem 0 0;
  padding: 0.65rem 0.75rem;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  background: #f8f9fa;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.cf-merge-wait-spinner {
  width: 2.25rem;
  height: 2.25rem;
  margin: 0.85rem auto 0;
  border: 3px solid var(--border);
  border-top-color: var(--accent, #228be6);
  border-radius: 50%;
  animation: cf-spin 0.75s linear infinite;
}

@keyframes cf-spin {
  to {
    transform: rotate(360deg);
  }
}

.cf-trace-file {
  margin-top: 0.35rem;
}

.enrich-commune-list th,
.enrich-commune-list td {
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 0.55rem;
  text-align: left;
  vertical-align: middle;
}

.enrich-commune-list th {
  position: sticky;
  top: 0;
  background: #f1f3f5;
  z-index: 1;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.enrich-commune-list .col-nb {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.enrich-commune-list td:first-child {
  width: 2.75rem;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.5rem;
  }
  .sidebar nav {
    display: flex;
    gap: 0.25rem;
  }
}

.hidden {
  display: none !important;
}

.lead-emoji {
  font-size: 1.1rem;
  margin-right: 0.35rem;
}

.hint {
  color: #868e96;
  font-size: 12px;
  margin-top: 0.25rem;
}

.err {
  color: #c92a2a;
  font-size: 13px;
  margin: 0.5rem 0 0;
}

pre.import-log {
  max-height: min(50vh, 360px);
  overflow: auto;
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 0.85rem;
  font-size: 12px;
  border-radius: 8px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--border);
}

.import-modal-panel {
  max-width: 720px;
}

.cf-campaign-ribbon-wrap {
  margin-bottom: 0.65rem;
}

.cf-campaign-banner {
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  font-size: 13px;
  border: 1px solid #b2f2bb;
  background: #ebfbee;
  color: #2b8a3e;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.cf-campaign-banner--muted {
  border-color: var(--border);
  background: #f8f9fa;
  color: #495057;
}

.pl-board-root {
  display: flex;
  gap: 0;
  align-items: stretch;
  width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  min-height: 12rem;
}

.pl-col {
  flex: 1 1 0;
  min-width: 10rem;
  max-width: none;
  background: #f1f3f5;
  border: 1px solid var(--border);
  border-right: none;
  display: flex;
  flex-direction: column;
  min-height: 10rem;
}

.pl-col:first-child {
  border-radius: 10px 0 0 10px;
}

.pl-col:last-child {
  border-right: 1px solid var(--border);
  border-radius: 0 10px 10px 0;
}

.pl-col--lost {
  background: linear-gradient(180deg, #fff5f5 0%, #ffe8e8 100%);
}

.pl-col--lost .pl-col-head {
  background: linear-gradient(180deg, #ffe4e6 0%, #fecdd3 100%);
  border-bottom-color: #f9a8b4;
}

.pl-col--won {
  background: linear-gradient(180deg, #f4fcf7 0%, #e6fcf0 100%);
}

.pl-col--won .pl-col-head {
  background: linear-gradient(180deg, #d3f9d8 0%, #b2f2bb 100%);
  border-bottom-color: #8ce99a;
}

.pl-col-head {
  position: relative;
  padding: 0.55rem 1.1rem 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

/* Flèche vers l’étape suivante (sauf dernière colonne) */
.pl-col:not(:last-child) .pl-col-head {
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%);
  margin-right: -1px;
  z-index: 1;
}

.pl-col-title {
  font-weight: 600;
  font-size: 13px;
  margin: 0 0 0.15rem;
}

.pl-col-meta {
  font-size: 11px;
  color: #868e96;
  line-height: 1.35;
}

.pl-col-body {
  padding: 0.45rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 4rem;
  border-radius: 0 0 0 10px;
}

.pl-col:last-child .pl-col-body {
  border-radius: 0 0 10px 0;
}

.pl-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.5rem;
  font-size: 12px;
  cursor: grab;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.pl-card:active {
  cursor: grabbing;
}

.pl-card-title {
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.pl-card-amt {
  font-variant-numeric: tabular-nums;
  color: #495057;
  font-size: 11px;
}

.pl-stage-row {
  display: grid;
  gap: 0.35rem;
  padding: 0.65rem;
}

.pl-stage-row .pl-stage-name {
  width: 100%;
}

.pl-brevo-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.35rem;
  align-items: end;
  margin-bottom: 0.35rem;
}

.cf-pipeline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

/* Actions campagne (mail / SMS) — vert + icônes */
.cf-pl-action {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.75rem;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: #2f9e44;
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.cf-pl-action:hover {
  background: #2b8a3e;
  color: #fff;
}

.cf-pl-action__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  opacity: 0.95;
}

.cf-pl-action__label {
  line-height: 1.2;
}

/* Modale destinataires pipeline */
.cf-pipeline-recipients-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: min(50vh, 22rem);
  overflow-y: auto;
  margin-top: 0.5rem;
}

.cf-recipient-choice {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: #f8fafc;
}

.cf-recipient-choice:has(input:checked) {
  border-color: #2f9e44;
  box-shadow: 0 0 0 1px rgba(47, 158, 68, 0.25);
}

.cf-recipient-choice input {
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.cf-recipient-choice-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.cf-recipient-name {
  font-weight: 700;
  font-size: 14px;
  color: #1e293b;
}

.cf-recipient-role {
  font-size: 12px;
  color: #64748b;
}

.cf-recipient-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.15rem;
}

.cf-recipient-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
}

.cf-recipient-chip--primary {
  background: #e7f5ff;
  color: #1864ab;
}

.cf-recipient-chip--secondary {
  background: #f3f0ff;
  color: #5f3dc4;
}

.cf-recipient--structure {
  background: #e7f5ff;
}

.cf-recipient--service {
  background: #fff4e6;
}

.cf-recipient--nq {
  background: #f1f3f5;
}

/* Historique contact — timeline (ligne centrée sur les marqueurs) */
.cf-timeline {
  position: relative;
  padding: 0.35rem 0 0.5rem;
}

.cf-timeline-line {
  position: absolute;
  left: 13px;
  top: 0.4rem;
  bottom: 0.45rem;
  width: 0;
  border-left: 2px dashed #ced4da;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 0;
}

.cf-timeline-empty {
  margin: 0.5rem 0 0;
}

.cf-timeline-row {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding-bottom: 1rem;
  position: relative;
  z-index: 1;
}

.cf-timeline-row:last-child {
  padding-bottom: 0.25rem;
}

.cf-timeline-rail {
  flex: 0 0 28px;
  width: 28px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 3px;
}

.cf-timeline-cell {
  flex: 1;
  min-width: 0;
}

.cf-t-marker {
  flex-shrink: 0;
  box-sizing: border-box;
}

.cf-t-marker--dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #adb5bd;
  box-shadow: 0 0 0 1px #fff;
}

.cf-t-marker--lg {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #ced4da;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.cf-t-marker--note {
  border-color: #adb5bd;
  background: #f8f9fa;
}

.cf-t-marker--mail {
  border-color: #9775fa;
  color: #5f3dc4;
}

.cf-t-marker--call {
  border-color: #4dabf7;
  color: #1864ab;
}

.cf-t-marker--file {
  border-color: #fd7e14;
  color: #d9480f;
}

.cf-t-marker--sms {
  border-color: #15aabf;
  color: #0c8599;
  font-size: 1rem;
}

.cf-t-marker--wa {
  border-color: #25d366;
  background: #25d366;
  color: #fff;
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: -0.02em;
}

.cf-t-marker--activity {
  border-color: #37b24d;
  background: #37b24d;
  color: #fff;
  font-weight: 700;
  font-size: 0.78rem;
}

.cf-timeline-time {
  color: #868e96;
  font-size: 11px;
}

.cf-htag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 0.18rem 0.45rem;
  border-radius: 5px;
  margin-right: 0.3rem;
  margin-bottom: 0.2rem;
  vertical-align: middle;
}

.cf-htag--delivered {
  background: #d0ebff;
  color: #1864ab;
}

.cf-htag--opened {
  background: #d3f9d8;
  color: #2b8a3e;
}

.cf-htag--bounced {
  background: #ffe3e3;
  color: #c92a2a;
}

.cf-htag--blocked {
  background: #ffe8e8;
  color: #9b2222;
}

.cf-htag--center {
  background: #fff3bf;
  color: #5c4f00;
}

.cf-htag--provider {
  background: #e9ecef;
  color: #495057;
}

.cf-brevo-info-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

.cf-brevo-info-meta {
  margin-top: 0.25rem;
}

.cf-brevo-info-detail {
  margin-top: 0.4rem;
  font-size: 12px;
  color: #495057;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}

.cf-timeline-card {
  border-radius: 10px;
  padding: 0.55rem 0.75rem 0.65rem;
  font-size: 13px;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.cf-timeline-card--note {
  background: #fff9e6;
  border-color: #ffe066;
}

.cf-timeline-card--event {
  background: #f1f3f5;
  border-color: #dee2e6;
}

.cf-timeline-card-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  margin-bottom: 0.35rem;
}

.cf-timeline-card-meta {
  font-size: 11px;
  color: #868e96;
  line-height: 1.4;
}

.cf-timeline-card-title {
  font-weight: 700;
  font-size: 14px;
  margin: 0 0 0.25rem;
  color: #212529;
}

.cf-timeline-card-body {
  white-space: pre-wrap;
  word-break: break-word;
  color: #495057;
  font-size: 13px;
}

/* Appels Brevo Phone — résumé IA (2 lignes + accordéon) */
.cf-brevo-voice-card .cf-brevo-call-meta {
  font-size: 12px;
  color: #495057;
  margin-bottom: 0.35rem;
}

.cf-call-summary-preview {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  color: #343a40;
  line-height: 1.45;
  margin-top: 0.25rem;
}

.cf-call-summary-preview--short {
  -webkit-line-clamp: unset;
  display: block;
}

.cf-brevo-call-more {
  margin-top: 0.35rem;
  font-size: 12px;
}

.cf-brevo-call-more summary {
  cursor: pointer;
  color: #1864ab;
  font-weight: 600;
  user-select: none;
}

.cf-call-summary-full {
  margin-top: 0.35rem;
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
  background: #f8f9fa;
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.45;
  max-height: min(50vh, 18rem);
  overflow-y: auto;
}

/* —— Auth rail (mobile first) —— */
.pd-rail-scroll {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.pd-rail-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
}

.pd-rail-user-area {
  margin-top: auto;
  padding-top: 0.5rem;
  width: 100%;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}

/** Ancrage = largeur de l’avatar : le menu se centre sur le bouton, pas sur toute la colonne. */
.pd-rail-user-anchor {
  position: relative;
  width: fit-content;
  max-width: 100%;
}

.pd-user-menu-trigger {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.pd-user-menu-trigger:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.pd-user-avatar-fallback {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.pd-user-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* Position finale gérée par JS (fixed) pour éviter le recouvrement par .pd-main-area */
.pd-user-dropdown {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  transform: none;
  min-width: 11rem;
  width: max-content;
  max-width: min(16rem, calc(100vw - 2rem));
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
  z-index: 200;
  padding: 0.35rem 0;
}

/* Masqué jusqu’au premier sync JS — évite un flash en position absolue par défaut */
.pd-user-dropdown--prelayout {
  opacity: 0;
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .pd-rail-user-area:hover .pd-user-dropdown:not(.hidden) {
    /* desktop : menu ouvert au survol si déjà ouvert par clic; clic reste possible */
  }
}

.pd-user-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.85rem;
  border: none;
  background: none;
  font: inherit;
  cursor: pointer;
  color: inherit;
}

.pd-user-dropdown-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

.pd-user-dropdown-danger {
  color: var(--danger);
}

.settings-section-root .settings-lead {
  margin-bottom: 1rem;
}

details.settings-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.65rem;
  padding: 0 0.85rem;
}

details.settings-block > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.75rem 0;
  list-style: none;
}

details.settings-block > summary::-webkit-details-marker {
  display: none;
}

details.settings-block > summary::before {
  content: "▸ ";
  display: inline-block;
  transform: rotate(0deg);
  transition: transform 0.15s ease;
}

details.settings-block[open] > summary::before {
  transform: rotate(90deg);
}

.settings-block-body {
  padding-bottom: 0.85rem;
}

.settings-actions-footer {
  margin-top: 1rem;
}

.tasks-toolbar {
  align-items: center;
  margin-bottom: 0.75rem;
}

.cf-tab-row-with-task {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.cf-tab-spacer {
  flex: 1;
  min-width: 0.5rem;
}

.profile-panel label {
  display: block;
  margin-top: 0.65rem;
  margin-bottom: 0.25rem;
  font-weight: 500;
  font-size: 13px;
}

.profile-panel input {
  width: 100%;
  max-width: 28rem;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

@media (max-width: 640px) {
  .pd-main-inner {
    padding: 0.85rem 1rem 1.25rem;
  }

  h2 {
    font-size: 1.2rem;
  }

  .data-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .cf-tab-row-with-task .cf-btn-add-task {
    width: 100%;
    margin-top: 0.25rem;
  }
}
