/*
 * dotCRM : interface légère
 * Inspirations : faltazi.com (menu latéral nu, filets fins), ekovore.com (titres fins, gris doux, champs sans bordure).
 * Aucune police externe : polices système, chargement instantané.
 *
 * Palette en trois familles, sans aucun double usage :
 *   1. Marque      : gris purs + rose fluo (logo, structure, action en cours)
 *   2. États       : problème, avertissement, succès, information, message
 *   3. Catégories  : couleurs des listes et des tags
 * Une couleur n'appartient qu'à une seule famille. Référence : maquette, planche « Palette graphique ».
 */

:root {
    /* 1. Marque */
    --brand-grey: #8a8a8a;  /* logo */
    --ink: #333;            /* titres, texte fort, bouton principal */
    --text: #6d6d6d;        /* texte courant */
    --muted: #767676;       /* légendes, menu inactif : gris le plus clair pour du texte */
    --line: #ececec;        /* filets */
    --field: #f2f2f2;       /* fond des champs */
    --hover: #fafafa;
    --paper: #fff;
    --veil: rgba(255, 255, 255, .8);  /* voile derrière un panneau ouvert */
    --accent: #e5007d;      /* rose fluo : logo et action en cours uniquement */
    --on-accent: #fff;      /* texte posé sur le rose */
    --title: #707070;       /* titres fins */
    --line-strong: #d6d6d6; /* contour des boutons secondaires et des sélecteurs */
    --shadow: 0 10px 30px rgba(0, 0, 0, .08);
    color-scheme: light;

    /* 2. États : plein (filets, barres) / texte (texte et icônes) / fond (bandeaux, badges) */
    --error: #e2401c;   --error-text: #b3300f;   --error-bg: #fdeee9;
    --warning: #f2a900; --warning-text: #8a5800; --warning-bg: #fff6e0;
    --success: #2e9e50; --success-text: #1d7a3b; --success-bg: #e9f6ed;
    --info: #1f8bd6;    --info-text: #0b65a0;    --info-bg: #e7f3fc;
    --note: #5f6b7a;    --note-text: #47515e;    --note-bg: #eef0f3;   /* « Message » : ardoise, pas un gris de marque */

    /* 3. Catégories (listes, tags) */
    --cat-indigo: #4c4fd6;
    --cat-violet: #7b3fe4;
    --cat-pourpre: #a83cc0;
    --cat-sarcelle: #0f8f8a;
    --cat-olive: #6f8f10;

    --sans: "Source Sans Pro", "Source Sans 3", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    --condensed: "Roboto Condensed", "Arial Narrow", "Helvetica Neue Condensed", "Avenir Next Condensed", sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, monospace;

    /* Icônes d'état (masques : elles prennent la couleur du texte) */
    --icon-error: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 1.8 16.2 9 9 16.2 1.8 9Z M9 5.5v4 M9 12.5v.1'/%3E%3C/svg%3E");
    --icon-warning: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 2 17 16H1Z M9 7v4 M9 13.5v.1'/%3E%3C/svg%3E");
    --icon-success: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 9A7 7 0 1 1 2 9a7 7 0 0 1 14 0Z M5.5 9.2l2.3 2.3 4.7-4.8'/%3E%3C/svg%3E");
    --icon-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 9A7 7 0 1 1 2 9a7 7 0 0 1 14 0Z M9 8v4.5 M9 5.5v.1'/%3E%3C/svg%3E");
    --icon-note: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 3.5h13v8.5H7l-4.5 3.5Z'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; color: var(--text); background: var(--paper); font: 15px/1.5 var(--sans); }
a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--accent); }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Logo ---------- */
.logo { display: block; height: 1em; width: auto; }
.logo-dot { fill: var(--accent); }

/* ---------- Menu latéral (façon Faltazi) ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 210px; padding: 44px 32px 32px; display: flex; flex-direction: column; background: var(--paper); overflow-y: auto; }
.brand { display: block; margin-bottom: 40px; font-size: 40px; line-height: 1; color: var(--brand-grey); }
.brand:hover { color: var(--ink); }
.sidebar nav { display: grid; border-top: 1px solid var(--line); }
.sidebar nav a { display: flex; align-items: center; min-height: 40px; padding: 0; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.sidebar nav a:hover { color: var(--ink); }
.sidebar nav a.active { color: var(--ink); border-bottom: 2px solid var(--accent); }
.sidebar form { margin-top: auto; }
.sidebar .link-button { padding: 0; color: var(--muted); font-size: 12px; }
.sidebar .link-button:hover { color: var(--ink); }
.sidebar-user { margin: auto 0 6px; font-size: 12px; }
.sidebar-user + form { margin-top: 0; }

/* ---------- Zone principale ---------- */
.main { margin-left: 210px; min-height: 100vh; max-width: 1180px; padding: 40px 48px 80px; }
.page-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 28px; }
.page-header h1, .auth-card h1 { margin: 0; color: var(--title); font-size: 42px; font-weight: 300; line-height: 1.1; letter-spacing: -1px; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font: 400 12px/1 var(--condensed); text-transform: uppercase; letter-spacing: 1.5px; }
.count { margin-left: 6px; color: var(--muted); font-size: 18px; font-weight: 300; letter-spacing: 0; vertical-align: super; }
.muted { color: var(--muted); font-weight: 400; }
h2 { margin: 0 0 20px; color: var(--title); font-size: 24px; font-weight: 300; letter-spacing: -.3px; }
h3 { margin: 20px 0 6px; color: var(--ink); font-size: 14px; }

/* ---------- Boutons ---------- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 8px 18px; border: 1px solid var(--ink); border-radius: 2px; background: var(--ink); color: var(--paper); font: 400 13px/1 var(--condensed); text-transform: uppercase; letter-spacing: 1px; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.button:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.button.secondary, .button.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.button.secondary:hover, .button.ghost:hover { background: transparent; border-color: var(--ink); color: var(--ink); }
.link-button, .danger-link { border: 0; padding: 0; background: none; font: inherit; cursor: pointer; }
.danger-link { color: var(--muted); }
.danger-link:hover { color: var(--error-text); }

/* ---------- Champs (façon Ekovore : gris clair, sans bordure) ---------- */
input, select, textarea { width: 100%; min-height: 38px; padding: 8px 12px; border: 1px solid transparent; border-radius: 2px; background: var(--field); color: var(--ink); font: inherit; font-size: 14px; transition: background .15s, border-color .15s; }
input:focus, select:focus, textarea:focus { outline: none; background: var(--paper); border-color: var(--ink); }
input[type="file"] { padding: 7px 10px; }
select { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: right 14px center, right 10px center; background-size: 4px 4px; background-repeat: no-repeat; }
textarea { resize: vertical; }
label { display: grid; gap: 6px; color: var(--muted); font: 400 12px/1.2 var(--condensed); text-transform: uppercase; letter-spacing: 1px; }
label .muted { text-transform: none; letter-spacing: 0; font-family: var(--sans); }

/* ---------- Filtres ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.filters > input { flex: 1 1 220px; min-width: 0; }
.filters > select { flex: 0 1 170px; min-width: 0; }
.filters > .button { flex: none; }
.filters input[type="search"] { padding-left: 34px; background: var(--field) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%23999' stroke-width='1.6'%3E%3Ccircle cx='6' cy='6' r='4.5'/%3E%3Cpath d='M9.5 9.5 13 13'/%3E%3C/svg%3E") no-repeat 12px center; }
.filters input[type="search"]:focus { background-color: var(--paper); }

/* ---------- Tableau : pas de carte, que des filets ---------- */
.table-card { border-top: 1px solid var(--line); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th:first-child, td:first-child { padding-left: 0; }
th { padding-top: 18px; padding-bottom: 10px; color: var(--muted); font: 400 11px/1 var(--condensed); text-transform: uppercase; letter-spacing: 1.2px; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--hover); }
td strong { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
table.cards td:first-child { min-width: 240px; }
.actions { width: 160px; text-align: right; white-space: nowrap; font-size: 13px; }
.actions a { color: var(--muted); }
.actions a:hover { color: var(--ink); }
.actions form { display: inline; margin-left: 14px; }
tbody tr .actions > * { opacity: 0; transition: opacity .12s; }
tbody tr:hover .actions > *, tbody tr:focus-within .actions > * { opacity: 1; }
@media (hover: none) { tbody tr .actions > * { opacity: 1; } }
.empty { height: 160px; text-align: center; color: var(--muted); font-weight: 300; font-size: 18px; }
tr.revoked td { opacity: .5; }

/* ---------- Catégories : listes et tags (couleurs réservées à cette famille) ---------- */
.cat-0, .cat-5 { --c: var(--cat-indigo); }
.cat-1, .cat-6 { --c: var(--cat-violet); }
.cat-2, .cat-7 { --c: var(--cat-pourpre); }
.cat-3, .cat-8 { --c: var(--cat-sarcelle); }
.cat-4, .cat-9 { --c: var(--cat-olive); }
.tag, .list-name { display: inline-flex; align-items: center; gap: 6px; margin: 2px 10px 2px 0; color: var(--text); font-size: 13px; }
.tag::before, .list-name::before, .cat-dot { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--muted)); box-sizing: border-box; }
.list-name::before { width: 9px; height: 9px; }
/* Seconde série : anneau au lieu de pastille pleine */
.cat-5::before, .cat-6::before, .cat-7::before, .cat-8::before, .cat-9::before,
.cat-dot.cat-5, .cat-dot.cat-6, .cat-dot.cat-7, .cat-dot.cat-8, .cat-dot.cat-9 { background: transparent; border: 2.5px solid var(--c); }
.cat-dot { display: inline-block; margin-right: 8px; vertical-align: 1px; }
.tag:hover { color: var(--ink); }

/* ---------- Panneaux et formulaires ---------- */
.panel { margin-top: 48px; padding-top: 28px; border-top: 1px solid var(--line); }
.panel.compact { margin: 0; padding: 0 0 0 32px; border-top: 0; border-left: 1px solid var(--line); }
details.panel > summary { list-style: none; cursor: pointer; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary h2 { display: inline-flex; align-items: center; gap: 10px; margin: 0; }
details.panel > summary h2::before { content: "+"; display: inline-grid; place-items: center; width: 26px; height: 26px; border: 1px solid var(--line-strong); border-radius: 50%; font-size: 16px; line-height: 1; color: var(--ink); transition: transform .2s, border-color .15s; }
details.panel > summary:hover h2::before { border-color: var(--accent); color: var(--accent); }
details.panel[open] > summary h2::before { transform: rotate(45deg); }
details.panel[open] > summary { margin-bottom: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px 18px; }
.form-grid fieldset { grid-column: 1 / -1; margin: 0; padding: 0; border: 0; }
.form-grid legend { margin-bottom: 10px; color: var(--muted); font: 400 12px/1 var(--condensed); text-transform: uppercase; letter-spacing: 1px; }
.checkbox-grid { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.checkbox { display: flex; align-items: center; gap: 8px; color: var(--text); font: 400 14px/1.3 var(--sans); text-transform: none; letter-spacing: 0; cursor: pointer; }
.checkbox input { width: 15px; min-height: 15px; height: 15px; margin: 0; accent-color: var(--accent); }
.form-actions { grid-column: 1 / -1; display: flex; gap: 8px; margin-top: 4px; }
.list-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 40px; align-items: start; }
.stack { display: grid; gap: 18px; }
.import-panel { max-width: 640px; margin-top: 0; }
.import-panel p { margin: 0 0 14px; }
.import-panel code { padding: 1px 5px; background: var(--field); border-radius: 2px; color: var(--ink); font-size: 13px; }
.pagination { display: flex; gap: 16px; align-items: center; justify-content: flex-end; margin: 12px 0 24px; font-size: 13px; }
.pagination a { color: var(--ink); }
.pagination a:hover { color: var(--accent); }
.code { margin: 8px 0 16px; padding: 12px 14px; overflow-x: auto; background: var(--field); color: var(--ink); font: 12px/1.5 var(--mono); white-space: pre-wrap; word-break: break-all; }
.plain-list { margin: 8px 0 16px; padding: 0; list-style: none; font-size: 13px; }
.plain-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }

/* ---------- États : messages, bandeaux, badges (toujours icône + texte) ---------- */
.alert { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 24px; padding: 2px 0 2px 14px; border-left: 2px solid var(--state, var(--note)); color: var(--state-text, var(--note-text)); font-size: 14px; }
.alert::before, .badge::before, .status::before { content: ""; flex: none; width: 16px; height: 16px; margin-top: 2px; background: currentColor; -webkit-mask: var(--state-icon, var(--icon-note)) no-repeat center / contain; mask: var(--state-icon, var(--icon-note)) no-repeat center / contain; }
.alert-error, .badge-error, .status-ko { --state: var(--error); --state-text: var(--error-text); --state-bg: var(--error-bg); --state-icon: var(--icon-error); }
.alert-warning, .badge-warning { --state: var(--warning); --state-text: var(--warning-text); --state-bg: var(--warning-bg); --state-icon: var(--icon-warning); }
.alert-success, .badge-success, .status-ok { --state: var(--success); --state-text: var(--success-text); --state-bg: var(--success-bg); --state-icon: var(--icon-success); }
.alert-info, .badge-info { --state: var(--info); --state-text: var(--info-text); --state-bg: var(--info-bg); --state-icon: var(--icon-info); }
.alert-note, .badge-note { --state: var(--note); --state-text: var(--note-text); --state-bg: var(--note-bg); --state-icon: var(--icon-note); }
/* Bandeau : même état, sur fond teinté, pour ce qui demande de l'attention */
.alert.banner { padding: 14px 16px; border-left: 0; border-radius: 2px; background: var(--state-bg, var(--note-bg)); }
.alert.banner a { color: inherit; font-weight: 600; text-decoration: underline; }
/* Badge et statut : petite étiquette sur fond teinté */
.badge, .status { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 2px; background: var(--state-bg, var(--note-bg)); color: var(--state-text, var(--note-text)); font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before, .status::before { width: 12px; height: 12px; margin-top: 0; }
.key-reveal { padding-left: 20px; border-left: 2px solid var(--info); }

/* ---------- Connexion / installation ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; background: var(--paper); }
.auth-card { width: min(360px, calc(100% - 40px)); }
.auth-card .brand { margin-bottom: 40px; font-size: 56px; }
.auth-card h1 { margin-bottom: 8px; font-size: 32px; }
.auth-card p { margin: 0 0 24px; color: var(--muted); }
.auth-card form { display: grid; gap: 18px; margin-top: 24px; }
.auth-card .button { justify-self: start; }

/* ---------- Tablette : le menu passe en haut ---------- */
@media (max-width: 900px) {
    .sidebar { position: static; width: auto; padding: 24px 20px 0; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px 28px; overflow: visible; }
    .brand { margin: 0; font-size: 34px; }
    .sidebar nav { grid-auto-flow: column; gap: 24px; border: 0; }
    .sidebar nav a { min-height: 44px; border: 0; }
    .sidebar nav a.active { border-bottom: 2px solid var(--accent); }
    .sidebar-user { margin: 0 0 0 auto; }
    .sidebar form { margin: 0; }
    .main { margin-left: 0; padding: 32px 20px 56px; }
    .page-header h1 { font-size: 34px; }
    .filters > input[type="search"] { flex-basis: 100%; }
    .filters > select { flex: 1 1 140px; }
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .list-layout { grid-template-columns: minmax(0, 1fr); }
    .panel.compact { padding: 28px 0 0; border-left: 0; border-top: 1px solid var(--line); }
}

/* ---------- Téléphone : une colonne, tableaux principaux en fiches ---------- */
@media (max-width: 600px) {
    .sidebar { padding: 20px 16px 0; gap: 0 16px; box-shadow: inset 0 -1px 0 var(--line); }
    .sidebar nav { order: 3; width: 100%; gap: 24px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; }
    .sidebar nav::-webkit-scrollbar { display: none; }
    .sidebar nav a { white-space: nowrap; }
    .sidebar-user { display: none; }
    .main { padding: 24px 16px 48px; }
    .page-header { flex-direction: column; align-items: stretch; margin-bottom: 20px; }
    .page-header h1 { font-size: 30px; }
    .page-header .button { width: 100%; }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .filters > input, .filters > select { flex: 1 1 100%; }
    .filters > .button { flex: 1 1 40%; }
    .form-grid fieldset, .form-actions { grid-column: 1; }
    .form-actions .button { flex: 1; }
    .panel { margin-top: 32px; }

    /* Tableaux secondaires (clés, journaux, utilisateurs) : défilement horizontal */
    .table-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table-card table:not(.cards) { min-width: 640px; }

    /* Tableaux principaux (contacts, listes, comptes) : chaque ligne devient une fiche */
    table.cards thead { display: none; }
    table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
    table.cards tr { padding: 14px 0; border-bottom: 1px solid var(--line); }
    table.cards tbody tr:hover { background: none; }
    table.cards td { padding: 2px 0; border: 0; }
    table.cards td:first-child { min-width: 0; }
    table.cards td:empty { display: none; }
    table.cards td[data-label]::before { content: attr(data-label); margin-right: 6px; color: var(--muted); font: 400 11px/1 var(--condensed); text-transform: uppercase; letter-spacing: 1px; }
    table.cards td.empty { height: auto; padding: 32px 0; }
    table.cards .actions { width: auto; margin-top: 6px; text-align: left; }
    table.cards .actions > * { opacity: 1; }
    table.cards .actions form { margin-left: 20px; }
}

/* ---------- Écrans tactiles : zones de 44 px minimum ---------- */
@media (pointer: coarse) {
    .button, input, select, textarea { min-height: 44px; }
    input[type="checkbox"] { min-height: 18px; width: 18px; height: 18px; }
    .checkbox { min-height: 44px; }
    .sidebar nav a { min-height: 44px; }
    .sidebar .link-button, .actions a, .danger-link { min-height: 44px; display: inline-flex; align-items: center; }
}

/* ---------- Panneaux d'édition : plein écran sur mobile ---------- */
.sheet-close, .mobile-only { display: none; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@media (max-width: 900px) {
    .mobile-only { display: inline-flex; }
    .sheet:not(.is-open) { display: none; }
    .sheet.is-open {
        position: fixed; inset: 0; z-index: 100; margin: 0;
        padding: 16px 20px calc(40px + env(safe-area-inset-bottom));
        border: 0; background: var(--paper);
        overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
        animation: sheet-in .2s ease-out;
    }
    .sheet.is-open > summary { pointer-events: none; margin-bottom: 24px; }
    .sheet.is-open > summary h2::before { display: none; }
    .sheet.is-open h2 { padding-right: 52px; }
    .sheet-close {
        display: grid; place-items: center; position: fixed; z-index: 101;
        top: calc(6px + env(safe-area-inset-top)); right: 8px; width: 44px; height: 44px;
        border-radius: 50%; background: var(--paper); color: var(--ink); font-size: 30px; line-height: 1;
    }
    .sheet-close:hover { color: var(--accent); }
    body:has(.sheet.is-open) { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) { .sheet.is-open { animation: none; } }

/* ---------- Menu : roue dentée « Paramètres » ---------- */
.sidebar nav a.nav-icon { justify-content: flex-end; }
/* Active ou survolée : la roue passe en rose, sans soulignement (le filet gris reste) */
.sidebar nav a.nav-icon:hover, .sidebar nav a.nav-icon.active { color: var(--accent); }
.sidebar nav a.nav-icon.active { border-bottom: 1px solid var(--line); }
@media (max-width: 900px) {
    .sidebar nav { display: flex; flex: 1 1 auto; }
    .sidebar nav a.nav-icon { margin-left: auto; }
    .sidebar nav a.nav-icon.active { border-bottom: 0; }
}
.sidebar nav a.nav-icon .icon { display: block; transition: transform .3s; }
.sidebar nav a.nav-icon:hover .icon { transform: rotate(45deg); }
@media (prefers-reduced-motion: reduce) { .sidebar nav a.nav-icon .icon { transition: none; } }

/* ---------- Pastille utilisateur (en haut à droite) ---------- */
.user-menu { position: absolute; top: 28px; right: 32px; z-index: 50; }
.user-badge {
    display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
    background: var(--ink); color: var(--paper); font: 600 14px/1 var(--sans); letter-spacing: .5px;
    list-style: none; cursor: pointer; user-select: none; transition: background .15s;
}
.user-badge::-webkit-details-marker { display: none; }
.user-badge:hover, .user-menu[open] .user-badge, .user-menu.active .user-badge { background: var(--accent); }
.user-badge:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.user-menu-panel {
    position: absolute; top: 50px; right: 0; width: 250px; padding: 16px 18px;
    background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.user-menu-name { margin: 0 0 10px; font-size: 13px; line-height: 1.4; word-break: break-all; }
.user-menu-panel a, .user-menu-panel .link-button { display: flex; align-items: center; width: 100%; min-height: 40px; border-top: 1px solid var(--line); color: var(--text); font-size: 13px; text-align: left; }
.user-menu-panel a:hover, .user-menu-panel .link-button:hover { color: var(--accent); }
.user-menu-panel form { margin: 0; }

/* ---------- Onglets des Paramètres ---------- */
.tabs { display: flex; gap: 28px; margin: -8px 0 28px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { display: flex; align-items: center; min-height: 40px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); font-size: 13px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin: 0 0 16px; }
.panel.first { margin-top: 0; padding-top: 0; border-top: 0; }

/* ---------- Choix de couleur (listes, tags) ---------- */
.color-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 16px; color: var(--text); font: 400 12px/1 var(--sans); text-transform: none; letter-spacing: 0; cursor: pointer; }
.swatch input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; padding: 0; opacity: 0; cursor: pointer; }
.swatch .cat-dot { width: 12px; height: 12px; margin: 0; }
.swatch:hover { border-color: var(--muted); }
.swatch:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.swatch:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
fieldset .color-picker { margin-top: 6px; }

@media (max-width: 900px) {
    .user-menu { top: 20px; right: 20px; }
    .sidebar { padding-right: 76px; }
}
@media (max-width: 600px) {
    .user-menu { top: 16px; right: 16px; }
    .user-badge { width: 44px; height: 44px; }
    .sidebar { padding-right: 72px; }
    .swatch { min-width: 40px; height: 40px; border-radius: 20px; }
}

/* Correctifs : place pour la pastille, fieldset de couleur sans cadre */
.page-header { padding-right: 60px; }
.stack fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.stack legend { padding: 0; margin-bottom: 10px; color: var(--muted); font: 400 12px/1 var(--condensed); text-transform: uppercase; letter-spacing: 1px; }
@media (max-width: 600px) { .page-header { padding-right: 0; } }

/* ---------- Rôles ---------- */
.role { display: inline-block; padding: 1px 8px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); font: 400 11px/1.6 var(--sans); letter-spacing: .3px; vertical-align: 2px; white-space: nowrap; }
.role-admin { border-color: var(--ink); color: var(--ink); }
h2 .role { margin-left: 6px; }
.impersonate-form { margin: 0 0 20px; }

/* ---------- Bandeau d'impersonation ---------- */
.impersonation-banner {
    position: sticky; top: 0; z-index: 60; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 20px;
    margin-left: 210px; padding: 10px 24px; background: var(--accent); color: var(--on-accent); font-size: 14px;
}
.impersonation-banner form { margin: 0; }
.impersonation-banner .button { min-height: 32px; padding: 4px 14px; border-color: var(--on-accent); background: var(--on-accent); color: var(--accent); }
@media (max-width: 900px) { .impersonation-banner { margin-left: 0; } }

/* ---------- Journal d'audit ---------- */
.history { margin-top: 28px; }
.audit { margin: 8px 0 16px; padding: 0; list-style: none; font-size: 13px; }
.audit > li { position: relative; padding: 10px 0 10px 16px; border-bottom: 1px solid var(--line); }
.audit > li::before { content: ""; position: absolute; left: 0; top: 17px; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.audit > li.audit-create::before { background: var(--success); }
.audit > li.audit-delete::before, .audit > li.audit-revoke::before { background: var(--error); }
.audit > li.audit-impersonate_start::before, .audit > li.audit-impersonate_stop::before { background: var(--accent); }
.audit-action { color: var(--ink); font-weight: 600; }
.audit-head a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line); }
.impersonated { color: var(--accent); }
.audit-changes { display: grid; gap: 2px; margin: 6px 0 0; }
.audit-changes > div { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 8px; }
.audit-changes dt { color: var(--muted); }
.audit-changes dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.audit-changes del { color: var(--muted); }
.audit-changes ins { text-decoration: none; color: var(--ink); }
.audit-detail { margin: 4px 0 0; }
@media (max-width: 600px) { .audit-changes > div { grid-template-columns: minmax(0, 1fr); gap: 0; margin-bottom: 4px; } }
/* La pastille reste visible sous le bandeau d'impersonation (ordinateur) */
@media (min-width: 901px) { body:has(.impersonation-banner) .user-menu { top: 72px; } }
.stack .checkbox { flex-wrap: wrap; }

/* ---------- Filtre tags : champs « étiquettes » Avec / Sans ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.segmented { display: inline-flex; flex: none; margin: 0 0 0 auto; padding: 0; border: 1px solid var(--line-strong); border-radius: 2px; }
.segmented label { position: relative; display: grid; place-items: center; min-width: 46px; min-height: 30px; padding: 0 8px; color: var(--muted); font: 400 11px/1 var(--condensed); text-transform: uppercase; letter-spacing: .8px; cursor: pointer; }
.segmented label + label { border-left: 1px solid var(--line-strong); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--ink); color: var(--paper); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.chip { display: inline-flex; align-items: center; min-height: 32px; padding: 0 2px 0 10px; border: 1px solid var(--line); border-radius: 16px; }
.chip .tag { margin: 0; }
.chip-out { border-style: dashed; }
.chip-out .tag { text-decoration: line-through; }
@media (pointer: coarse) { .segmented label { min-height: 44px; } }
.segmented label:has(input[value=""]:checked) { background: var(--hover); color: var(--ink); }

/* Téléphone : la roue dentée est calée sous la pastille (même bord droit, même largeur) */
@media (max-width: 600px) {
    .sidebar { padding-right: 16px; }
    .sidebar .brand { margin-right: 60px; }
    .sidebar nav a.nav-icon { justify-content: center; min-width: 44px; }
}

/* ---------- Outils d'en-tête (Importer CSV, + Nouveau…) ---------- */
.header-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.header-tools .button { margin: 0; }
.button .icon { flex: none; }
@media (max-width: 600px) {
    .header-tools { width: 100%; }
    .header-tools .button { flex: 1 1 140px; }
}

/* ---------- Panneau latéral modal (import CSV, édition de vue) ---------- */
dialog.drawer {
    position: fixed; inset: 0 0 0 auto; width: min(560px, 100%); height: 100%; max-width: none; max-height: none; margin: 0;
    padding: 36px 40px 48px; border: 0; border-left: 1px solid var(--line); background: var(--paper); color: var(--text); overflow-y: auto;
}
dialog.drawer.drawer-wide { width: min(680px, 100%); }
dialog.drawer::backdrop { background: var(--veil); }
dialog.drawer[open] { animation: drawer-in .2s ease-out; }
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { dialog.drawer[open] { animation: none; } }
body:has(dialog.drawer[open]) { overflow: hidden; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 8px; }
.drawer-head h2 { margin: 6px 0 0; }
.drawer-close { display: grid; place-items: center; flex: none; width: 44px; height: 44px; margin: -4px -10px 0 0; border: 0; background: none; color: var(--ink); font-size: 30px; line-height: 1; cursor: pointer; }
.drawer-close:hover { color: var(--accent); }
.drawer fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.drawer legend:not(.tag), .label-like { margin: 0 0 8px; padding: 0; color: var(--muted); font: 400 12px/1.2 var(--condensed); text-transform: uppercase; letter-spacing: 1px; }
.drawer fieldset.group { padding-top: 20px; border-top: 1px solid var(--line); }
.drawer fieldset.group > legend { float: left; width: 100%; margin-bottom: 14px; color: var(--ink); font-size: 13px; letter-spacing: 1.4px; }
.drawer fieldset.group > legend + * { clear: both; }
.drawer-foot { display: flex; justify-content: space-between; gap: 16px; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }
.drawer-foot form { margin: 0; }
.drawer .form-actions { align-items: center; gap: 16px; }
.file-drop { position: relative; display: grid; justify-items: center; gap: 6px; padding: 26px 16px; border: 1px dashed var(--line-strong); border-radius: 2px; background: var(--hover); text-align: center; text-transform: none; letter-spacing: 0; font: inherit; color: var(--text); cursor: pointer; }
.file-drop strong { color: var(--ink); font-weight: 600; }
.file-drop .icon { width: 22px; height: 22px; color: var(--muted); }
.file-drop input { width: 100%; max-width: 320px; min-height: 0; margin-top: 6px; padding: 6px; background: transparent; font-size: 13px; }
.file-drop:hover, .file-drop:focus-within { border-color: var(--ink); }
.mapping { font-size: 14px; }
.mapping th, .mapping td { padding: 8px 8px 8px 0; vertical-align: top; }
.mapping th { width: 120px; color: var(--ink); font: 400 14px/1.4 var(--sans); text-transform: none; letter-spacing: 0; }
.mapping td { color: var(--text); }
.choice { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 8px 0; color: var(--ink); font: 400 14px/1.4 var(--sans); text-transform: none; letter-spacing: 0; cursor: pointer; }
.choice input { flex: none; width: 16px; height: 16px; min-height: 0; margin: 2px 0 0; accent-color: var(--accent); }
.choice small { display: block; color: var(--muted); font-size: 13px; }
.drawer .account-mode { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; }
.account-mode > legend { float: none; grid-column: 1 / -1; }
@media (max-width: 600px) {
    dialog.drawer { width: 100%; padding: 16px 16px 40px; border-left: 0; }
    dialog.drawer.drawer-wide { width: 100%; }
}

/* ---------- Vues ---------- */
.views-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 40px; align-items: start; }
.views-nav ul { margin: 0 0 24px; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.views-nav a { display: grid; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--text); font-size: 14px; }
.views-nav a strong { color: var(--ink); font-weight: 400; }
.views-nav a:hover strong { color: var(--accent); }
.views-nav a.active { border-bottom: 2px solid var(--accent); }
.views-nav a.active strong { font-weight: 600; }
.views-nav small { font-size: 12px; }
.views-result h2 { margin: 0 0 12px; }
.criteria { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 20px; font-size: 13px; }
.criteria b { color: var(--muted); font: 400 11px/1 var(--condensed); text-transform: uppercase; letter-spacing: 1.2px; }
.criteria .chip { padding-right: 10px; }
.criteria-sep { width: 1px; height: 20px; margin: 0 6px; background: var(--line); }
@media (max-width: 900px) {
    .views-layout { grid-template-columns: minmax(0, 1fr); gap: 24px; }
    .views-nav ul { margin-bottom: 16px; }
}
.hint { color: var(--muted); font: 400 13px/1.3 var(--sans); text-transform: none; letter-spacing: 0; }
p.hint { margin: 0; }
.drawer .checkbox { min-height: 40px; }

.drawer-head h2:focus { outline: none; }

.tag-filters { flex: 1 1 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 16px; margin-top: 8px; }
.tag-filters .tag-picker-out { grid-column: 2; grid-row: 1; }
.tag-filters .tag-mode { grid-column: 1; }
.tag-picker { display: grid; gap: 6px; min-width: 0; }
.tag-picker .label-like { margin: 0; }
.tag-picker-box { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 38px; padding: 4px 6px; border-radius: 2px; background: var(--field); }
.tag-picker-box:focus-within { background: var(--paper); box-shadow: inset 0 0 0 1px var(--ink); }
.tag-picker-chips { display: contents; }
.tag-picker select { flex: 1 1 150px; width: auto; min-width: 0; min-height: 30px; padding: 4px 6px; border: 0; background-color: transparent; }
.tag-picker select:focus { border: 0; }
.tag-picker .chip { min-height: 28px; padding: 0 0 0 10px; background: var(--paper); }
.chip button { display: grid; place-items: center; width: 26px; height: 26px; border: 0; background: none; color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; }
.chip button:hover { color: var(--accent); }
.tag-mode { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; color: var(--muted); font: 400 13px/1.3 var(--sans); text-transform: none; letter-spacing: 0; }
.tag-mode select { width: auto; min-height: 32px; padding: 4px 8px; font-size: 13px; }
.drawer .tag-filters { grid-template-columns: minmax(0, 1fr); }
.drawer .tag-filters .tag-picker-out, .drawer .tag-filters .tag-mode { grid-column: 1; grid-row: auto; }
@media (max-width: 600px) {
    .tag-filters { grid-template-columns: minmax(0, 1fr); }
    .tag-filters .tag-picker-out, .tag-filters .tag-mode { grid-column: 1; grid-row: auto; }
}
@media (pointer: coarse) { .chip button { width: 36px; height: 36px; } .tag-picker select { min-height: 40px; } }

/* ---------- Fil d'activité (contacts, comptes) ---------- */
.activity { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line); }
.activity h3 { margin: 0 0 12px; }
.activity-form { display: grid; gap: 8px; margin: 0 0 20px; }
.activity-form textarea { min-height: 76px; resize: vertical; }
.activity-form-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.activity-form-actions select { width: auto; flex: 0 1 180px; }
.activity-list { margin: 0; padding: 0; list-style: none; }
.activity-list > li { position: relative; padding: 10px 0 10px 18px; border-bottom: 1px solid var(--line); font-size: 14px; }
.activity-list > li::before { content: ""; position: absolute; left: 0; top: 17px; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--muted); box-sizing: border-box; }
.activity-note::before { background: var(--ink); border-color: var(--ink) !important; }
.activity-note p { margin: 4px 0 0; color: var(--ink); white-space: normal; overflow-wrap: anywhere; }
.activity-type { color: var(--ink); font: 400 12px/1 var(--condensed); text-transform: uppercase; letter-spacing: 1px; }
.activity-head .muted, .activity-event .muted { font-size: 12px; }
.activity-event { color: var(--text); }
.activity-sentence { display: block; }
.activity-event .muted { display: block; margin-top: 2px; }

/* ---------- Campagnes ---------- */
.results-bar { margin: 8px 0 4px; font-size: 13px; }
.results-bar .link-button { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.results-bar .link-button:hover { color: var(--accent); }
.campaign-feed { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin: 0 0 16px; }
.campaign-feed label { flex: 1 1 260px; }
.campaign-sources { margin: 0 0 16px; font-size: 14px; }
.campaign-sources summary { cursor: pointer; color: var(--muted); }
.campaign-sources summary:hover { color: var(--ink); }
.campaign-quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.campaign-quick select { flex: 1 1 180px; width: auto; }


/* ---------- Thème sombre ----------
 * Choix de l'utilisateur (Mon compte) : data-theme="dark" | "light" sur <html> ; sans attribut, on suit le système.
 * Mêmes rôles que le thème clair, contrastes du texte ≥ 4,5:1 sur --paper.
 */
:root[data-theme="dark"] {
    --brand-grey: #9a9a9a;
    --ink: #ececec;
    --text: #c2c2c2;
    --muted: #9b9b9b;
    --line: #2c2c2c;
    --field: #232323;
    --hover: #1c1c1c;
    --paper: #151515;
    --veil: rgba(0, 0, 0, .6);
    --accent: #ff3d9c;
    --on-accent: #151515;
    --title: #b8b8b8;
    --line-strong: #4a4a4a;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5);
    --error-text: #ff8f75;   --error-bg: #3a1b13;
    --warning-text: #f4c25a; --warning-bg: #33270b;
    --success-text: #63d48c; --success-bg: #11291b;
    --info-text: #72bcf2;    --info-bg: #0d2639;
    --note-text: #b7c1ce;    --note-bg: #23272e;  --note: #8793a3;
    --cat-indigo: #8486f2;
    --cat-violet: #a985f2;
    --cat-pourpre: #d077e8;
    --cat-sarcelle: #2fc2ba;
    --cat-olive: #a2c63f;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --brand-grey: #9a9a9a;
        --ink: #ececec;
        --text: #c2c2c2;
        --muted: #9b9b9b;
        --line: #2c2c2c;
        --field: #232323;
        --hover: #1c1c1c;
        --paper: #151515;
        --veil: rgba(0, 0, 0, .6);
        --accent: #ff3d9c;
        --on-accent: #151515;
        --title: #b8b8b8;
        --line-strong: #4a4a4a;
        --shadow: 0 10px 30px rgba(0, 0, 0, .5);
        --error-text: #ff8f75;   --error-bg: #3a1b13;
        --warning-text: #f4c25a; --warning-bg: #33270b;
        --success-text: #63d48c; --success-bg: #11291b;
        --info-text: #72bcf2;    --info-bg: #0d2639;
        --note-text: #b7c1ce;    --note-bg: #23272e;  --note: #8793a3;
        --cat-indigo: #8486f2;
        --cat-violet: #a985f2;
        --cat-pourpre: #d077e8;
        --cat-sarcelle: #2fc2ba;
        --cat-olive: #a2c63f;
        color-scheme: dark;
    }
}

/* ---------- Choix de l'affichage (Mon compte, menu de la pastille) ---------- */
.theme-choice { margin: 0 0 8px; }
.theme-choice .segmented { margin: 0; }
.theme-choice .segmented label { min-width: 96px; min-height: 36px; }
.user-menu-theme { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; margin: 0; border-top: 1px solid var(--line); font-size: 13px; }
.user-menu-theme .segmented { margin: 0; }
.user-menu-theme .segmented label { min-width: 40px; }
