:root {
  --bg: #f4f6fa;
  --page-gradient: radial-gradient(circle at 15% 15%, #a855f7 0%, transparent 45%),
                   radial-gradient(circle at 85% 85%, #d946ef 0%, transparent 50%),
                   linear-gradient(160deg, #7e22ce 0%, #6b21a8 45%, #581c87 100%);
  --sidebar-bg: #f6f1fd;
  --sidebar-border: #e9dffa;
  --sidebar-fg: #5b4b78;
  --sidebar-fg-active: #ffffff;
  --sidebar-active-bg: linear-gradient(135deg, #8b5cf6, #a855f7);
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-gradient: linear-gradient(135deg, #8b5cf6, #a855f7);
  --accent-soft: #f3edfe;
  --border: #e9e3f5;
  --text: #1f2937;
  --text-muted: #6b7280;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(76,29,149,.05), 0 4px 16px rgba(76,29,149,.08);
  --avatar-colors: #7c3aed, #db2777, #0891b2, #d97706, #16a34a, #4f46e5;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--page-gradient); background-color: #6b21a8; background-attachment: fixed; color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell { display: flex; min-height: calc(100vh - 32px); margin: 16px; background: #fff; border-radius: 24px; box-shadow: 0 20px 60px rgba(45,10,80,.35); overflow: hidden; }

.avatar {
  width: 30px; height: 30px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 11.5px; flex-shrink: 0; margin-right: 10px; vertical-align: middle;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
.name-cell { display: flex; align-items: center; }

.sidebar {
  width: 240px; flex-shrink: 0; background: var(--sidebar-bg); color: var(--sidebar-fg);
  border-right: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column; padding: 18px 0; position: relative; min-height: 100vh;
}
.brand { font-weight: 700; font-size: 16px; color: var(--text); padding: 0 20px 16px; border-bottom: 1px solid var(--sidebar-border); margin-bottom: 10px; letter-spacing: .02em; }
.brand-icon { margin-right: 2px; }
.sidebar nav { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.sidebar nav a { color: var(--sidebar-fg); padding: 8px 20px; font-size: 13.5px; display: flex; align-items: center; gap: 6px; border-radius: 0; margin: 0 8px; border-radius: var(--radius-sm); }
.sidebar nav a:hover { background: #f4f6fa; text-decoration: none; color: var(--text); }
.sidebar nav a.active { background: var(--sidebar-active-bg); color: var(--sidebar-fg-active); font-weight: 600; box-shadow: 0 4px 12px rgba(139,92,246,.35); }
.nav-group { padding: 14px 20px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #9aa3b2; font-weight: 700; }
.badge { background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; margin-left: auto; }
.sidebar-footer { padding: 14px 20px 0; border-top: 1px solid var(--sidebar-border); margin-top: 12px; }
.user-chip { font-size: 13px; color: var(--text); margin-bottom: 8px; }
.link-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0; font-size: 12.5px; }
.link-btn:hover { color: var(--danger); text-decoration: underline; }
a.sidebar-link { color: var(--text-muted); text-decoration: none; font-size: 12.5px; }
a.sidebar-link:hover { color: var(--accent); text-decoration: underline; }

.content { flex: 1; padding: 30px 36px; max-width: 1280px; }

h1 { font-size: 22px; margin: 0 0 4px; font-weight: 700; }
h2 { font-size: 15.5px; margin: 26px 0 12px; font-weight: 700; }
.subtitle { color: var(--text-muted); font-size: 13.5px; margin: 0 0 22px; }

.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow); }

.flash { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 13.5px; }
.flash-info { background: var(--accent-soft); color: #1e3a8a; }
.flash-success { background: #ecfdf3; color: #166534; }
.flash-error { background: #fef2f2; color: #991b1b; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr { cursor: default; }
tbody tr.row-link { cursor: pointer; }
tbody tr.row-link:hover td { background: var(--accent-soft); }

.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-gradient); color: #fff; border: none;
  padding: 9px 18px; border-radius: 999px; cursor: pointer; font-size: 13.5px; font-weight: 600; box-shadow: 0 4px 12px rgba(139,92,246,.3); }
.btn:hover { background: var(--accent-gradient); filter: brightness(1.06); text-decoration: none; color: #fff; }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); font-weight: 500; border-radius: 999px; }
.filter-pill.active-filter { background: var(--accent-gradient); color: #fff; border-color: transparent; box-shadow: 0 2px 8px rgba(139,92,246,.3); }
.btn-secondary:hover { background: #faf9fd; color: var(--text); }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #fecaca; font-weight: 500; border-radius: 999px; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 6px 14px; font-size: 12.5px; }

input[type=text], input[type=password], input[type=email], input[type=search], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13.5px; font-family: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=search] { border-radius: 999px; padding-left: 16px; }
textarea { resize: vertical; min-height: 70px; }
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); display: block; transition: transform .1s; }
a.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(76,29,149,.12); }
.stat-card .icon { font-size: 18px; margin-bottom: 4px; }
.stat-card .value { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-card .label { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.stat-card.featured { background: var(--accent-gradient); border: none; box-shadow: 0 10px 24px rgba(139,92,246,.35); }
.stat-card.featured .value, .stat-card.featured .label { color: #fff; }
.stat-card.featured .label { opacity: .85; }
.stat-card.tint-blue { border-top: 3px solid #3b82f6; }
.stat-card.tint-blue .icon { color: #2563eb; }
.stat-card.tint-amber { border-top: 3px solid #f59e0b; }
.stat-card.tint-amber .icon { color: #d97706; }
.stat-card.tint-pink { border-top: 3px solid #ec4899; }
.stat-card.tint-pink .icon { color: #db2777; }
.stat-card.tint-green { border-top: 3px solid #22c55e; }
.stat-card.tint-green .icon { color: #16a34a; }

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Badges/puces de listes de diffusion */
.pill-tag { display: inline-block; background: var(--accent-soft); color: #1d4ed8; border-radius: 999px; padding: 2px 10px; font-size: 11.5px; font-weight: 600; margin: 2px 3px 2px 0; white-space: nowrap; }
.pill-tag.more { background: #f1f2f4; color: var(--text-muted); }

/* Sélecteur générique à deux colonnes (droits utilisateurs) */
.dual-select { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dual-select .col h3 { font-size: 12.5px; text-transform: uppercase; color: var(--text-muted); margin: 0 0 8px; }
.dual-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.dual-list .item { padding: 8px 12px; font-size: 13.5px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #f1f2f4; }
.dual-list .item:last-child { border-bottom: none; }
.dual-list .item:hover { background: var(--accent-soft); }
.dual-list .item .remove { color: #9ca3af; font-size: 13px; opacity: .6; }
.dual-list .item .remove:hover { color: var(--danger); opacity: 1; }
.dual-list .empty { padding: 14px; color: var(--text-muted); font-size: 12.5px; text-align: center; }
.counter { font-size: 12.5px; color: var(--text-muted); margin-top: 6px; }

/* Arborescence Catégories > Listes (sélection de contacts) */
.tree-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.tree-picker .col h3 { font-size: 12.5px; text-transform: uppercase; color: var(--text-muted); margin: 0 0 8px; display: flex; justify-content: space-between; }
.tree-box { max-height: 340px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; padding: 4px 0; }
.tree-category { border-bottom: 1px solid #f1f2f4; }
.tree-category:last-child { border-bottom: none; }
.tree-cat-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer; }
.tree-cat-row:hover { background: #fafbfc; }
.tree-cat-row .chevron { width: 14px; color: var(--text-muted); font-size: 11px; transition: transform .1s; flex-shrink: 0; }
.tree-cat-row.expanded .chevron { transform: rotate(90deg); }
.tree-cat-row .cat-name { flex: 1; font-weight: 600; font-size: 13.5px; }
.tree-cat-row .cat-count { font-size: 11.5px; color: var(--text-muted); background: #f1f2f4; border-radius: 999px; padding: 1px 8px; }
.tree-lists { display: none; padding: 0 10px 8px 34px; }
.tree-lists.open { display: block; }
.tree-list-item { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; }
.tree-list-item label { font-weight: 400; color: var(--text); margin: 0; cursor: pointer; }
.selected-box { max-height: 340px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.selected-item { padding: 8px 12px; font-size: 13px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #f1f2f4; }
.selected-item:last-child { border-bottom: none; }
.selected-item .remove { color: #9ca3af; cursor: pointer; }
.selected-item .remove:hover { color: var(--danger); }
.selected-item .sub { display: block; font-size: 11.5px; color: var(--text-muted); }

/* Champ de recherche à tags (listes sur une fiche contact) */
.tag-picker { position: relative; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; background: #fff; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.tag-list:empty { margin-bottom: 0; }
.tag-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: #6d28d9; border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 12.5px; font-weight: 600; }
.tag-remove { cursor: pointer; opacity: .6; font-size: 11px; width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; }
.tag-remove:hover { opacity: 1; background: rgba(124,58,237,.15); }
.tag-input { border: none; padding: 4px 2px; font-size: 13.5px; width: 100%; }
.tag-input:focus { outline: none; box-shadow: none; }
.tag-suggestions { display: none; position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); max-height: 240px; overflow-y: auto; z-index: 20; }
.tag-suggestions.flip-up { top: auto; bottom: 100%; margin-top: 0; margin-bottom: 4px; }
.tag-suggestions.open { display: block; }
.tag-suggestion-item { padding: 8px 12px; font-size: 13.5px; cursor: pointer; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.tag-suggestion-item .sub { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.tag-suggestion-item:hover, .tag-suggestion-item.active { background: var(--accent-soft); }
.tag-suggestion-item.tag-suggestion-category { font-weight: 700; color: #4c1d95; background: #faf5ff; border-bottom: 1px solid var(--border); }
.tag-suggestion-item.tag-suggestion-category .sub { color: #7c3aed; font-weight: 600; }
.tag-suggestion-empty { padding: 10px 12px; font-size: 12.5px; color: var(--text-muted); }

.status-pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.status-en_attente { background: #fef3c7; color: #92400e; }
.status-acceptee { background: #dcfce7; color: #166534; }
.status-refusee { background: #fee2e2; color: #991b1b; }

.diff-table td.old { color: var(--danger); text-decoration: line-through; background: #fef2f2; }
.diff-table td.new { color: var(--success); background: #ecfdf3; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--page-gradient); background-color: #6b21a8; }
.login-box { background: #fff; border: none; border-radius: 24px; padding: 36px; width: 340px; box-shadow: 0 20px 60px rgba(45,10,80,.35); }
.login-box h1 { text-align: center; }

.pagination { display: flex; gap: 4px; margin-top: 16px; align-items: center; }
.pagination a, .pagination span { padding: 6px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12.5px; color: var(--text); }
.pagination a:hover { background: #f4f6fa; text-decoration: none; }
.pagination .active { background: var(--accent); color: #fff; border-color: var(--accent); }

.label-sheet { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4mm; padding: 10mm; }
.label-cell { border: 1px dotted #ccc; padding: 4mm; font-size: 11px; min-height: 25mm; }
@media print { .no-print { display: none !important; } .label-cell { border: none; } .sidebar { display: none; } .content { padding: 0; max-width: none; } }

/* ===================== Charte visuelle commune ===================== */

/* En-tête de page avec avatar/icône, titre, sous-titre et actions bien visibles */
.page-hero {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 26px; margin-bottom: 20px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.page-hero .hero-avatar {
  width: 56px; height: 56px; border-radius: 999px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 20px; background: var(--accent-gradient);
  box-shadow: 0 6px 16px rgba(139,92,246,.35);
}
.page-hero .hero-info { flex: 1; min-width: 200px; }
.page-hero .hero-info h1 { margin: 0 0 2px; }
.page-hero .hero-sub { color: var(--text-muted); font-size: 13px; }
.page-hero .hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Sections colorées avec icône, pour structurer une page (fiche contact, formulaires...) */
.section-block { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 18px; box-shadow: var(--shadow); }
.section-block .section-head {
  border-top-left-radius: var(--radius); border-top-right-radius: var(--radius);
  display: flex; align-items: center; gap: 10px; padding: 14px 20px;
  background: var(--accent-soft); border-bottom: 1px solid var(--border); font-weight: 700; font-size: 13.5px; color: #4c1d95;
}
.section-block .section-head .icon-badge {
  width: 26px; height: 26px; border-radius: 8px; background: var(--accent-gradient);
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; color: #fff;
}
.section-block .section-body { padding: 18px 20px; }
.section-block.tint-pink .section-head { background: #fdf2f8; color: #9d174d; }
.section-block.tint-pink .icon-badge { background: linear-gradient(135deg, #ec4899, #db2777); }
.section-block.tint-blue .section-head { background: #eff6ff; color: #1e3a8a; }
.section-block.tint-blue .icon-badge { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.section-block.tint-green .section-head { background: #ecfdf5; color: #065f46; }
.section-block.tint-green .icon-badge { background: linear-gradient(135deg, #22c55e, #16a34a); }
.section-block.tint-amber .section-head { background: #fffbeb; color: #92400e; }
.section-block.tint-amber .icon-badge { background: linear-gradient(135deg, #f59e0b, #d97706); }

/* Grille d'informations "clé / valeur" plus lisible qu'un tableau brut */
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 22px; }
.info-item .info-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 700; margin-bottom: 3px; }
.info-item .info-value { font-size: 14px; color: var(--text); }
.info-item .info-value.empty { color: #c4c8d1; }

/* Séparateur de section avec libellé, pour distinguer deux groupes d'actions */
.split-divider { display: flex; align-items: center; gap: 12px; margin: 26px 0 16px; }
.split-divider .line { flex: 1; height: 1px; background: var(--border); }
.split-divider .label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); white-space: nowrap; }

/* Boîtes d'option pour construire une sélection (deux méthodes bien séparées) */
.option-box { border: 1.5px solid var(--border); border-radius: var(--radius); padding: 16px 18px; background: #fafaff; height: 100%; }
.option-box .option-title { font-weight: 700; font-size: 13.5px; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.option-box .option-desc { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }

/* Bandeau d'état de la sélection active (persistant, bien visible) */
.selection-banner {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--accent-gradient); color: #fff; border-radius: var(--radius);
  padding: 14px 20px; margin-bottom: 18px; box-shadow: 0 8px 20px rgba(139,92,246,.3);
}
.selection-banner .count { font-size: 22px; font-weight: 800; }
.selection-banner .sub { font-size: 12px; opacity: .9; }
.selection-banner .spacer { flex: 1; }

/* Puces catégorie / sous-catégorie / liste, visuellement distinctes */
.badge-category { display: inline-flex; align-items: center; gap: 5px; background: #eef2ff; color: #3730a3; border-radius: 999px; padding: 3px 10px; font-size: 11.5px; font-weight: 700; }
.badge-subcategory { display: inline-flex; align-items: center; gap: 5px; background: #fdf4ff; color: #86198f; border-radius: 999px; padding: 3px 10px; font-size: 11.5px; font-weight: 700; }
.badge-list-count { display: inline-flex; align-items: center; gap: 5px; background: #f0fdfa; color: #0f766e; border-radius: 999px; padding: 3px 10px; font-size: 11.5px; font-weight: 600; }

/* Ligne de catégorie repliable (Listes de diffusion) */
details.cat-node { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; background: #fff; box-shadow: var(--shadow); overflow: hidden; }
details.cat-node > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 14px 18px; cursor: pointer; user-select: none; }
details.cat-node > summary::-webkit-details-marker { display: none; }
details.cat-node > summary:hover { background: #fafaff; }
details.cat-node > summary .chevron { transition: transform .15s; color: var(--text-muted); font-size: 12px; width: 14px; display: inline-block; }
details.cat-node[open] > summary .chevron { transform: rotate(90deg); }
.cat-node-body { padding: 0 18px 16px; }
details.cat-node.is-sub { margin-left: 30px; border-left: 3px solid #d8b4fe; }
.list-row-icon { color: #0d9488; margin-right: 4px; }
