/* =======================================================================
   Prospection Kinés · Design system
   ======================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Couleurs — neutres (slate) */
    --slate-50:  #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;

    /* Marque — indigo */
    --brand-50:  #eef2ff;
    --brand-100: #e0e7ff;
    --brand-500: #6366f1;
    --brand-600: #4f46e5;
    --brand-700: #4338ca;

    /* Sémantique */
    --success: #10b981;
    --success-bg: #d1fae5;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger:  #ef4444;
    --danger-bg: #fee2e2;
    --info:    #3b82f6;
    --info-bg: #dbeafe;

    /* Alias sémantiques */
    --bg:        var(--slate-50);
    --surface:   #ffffff;
    --border:    #eef0f4;
    --border-strong: var(--slate-200);
    --text:      var(--slate-900);
    --text-muted: var(--slate-500);
    --primary:   var(--brand-600);
    --primary-hover: var(--brand-700);

    /* Rayons, espacements, ombres */
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.10);

    --sidebar-w: 244px;
}

/* Reset ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; color: var(--slate-900); margin: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; color: var(--slate-800); }
h3 { font-size: 0.95rem; }
p { margin: 0; }

/* Layout global --------------------------------------------------------- */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}
.app > .content { min-width: 0; display: flex; flex-direction: column; }

/* Sidebar --------------------------------------------------------------- */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1.25rem 0.75rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.3rem 0.7rem 1.25rem;
    font-weight: 700;
    color: var(--slate-900);
    letter-spacing: -0.02em;
}
.sidebar .brand .logo {
    width: 32px; height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.sidebar .brand .logo svg { width: 18px; height: 18px; }
.sidebar .brand span { font-size: 0.98rem; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--r-sm);
    color: var(--slate-600);
    font-weight: 500;
    font-size: 0.88rem;
    transition: background 0.12s, color 0.12s;
}
.sidebar nav a svg { width: 18px; height: 18px; stroke-width: 1.8; color: var(--slate-400); flex-shrink: 0; }
.sidebar nav a:hover { background: var(--slate-100); color: var(--slate-900); }
.sidebar nav a:hover svg { color: var(--slate-600); }
.sidebar nav a.active { background: var(--brand-50); color: var(--primary); }
.sidebar nav a.active svg { color: var(--primary); }

.sidebar .spacer { flex: 1; }
.sidebar .user-box {
    border-top: 1px solid var(--border);
    padding: 0.85rem 0.5rem 0.2rem;
    display: flex; align-items: center; gap: 0.7rem;
}
.sidebar .avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--brand-100);
    color: var(--brand-700);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.82rem;
    flex-shrink: 0;
}
.sidebar .user-box .name { font-size: 0.85rem; font-weight: 500; color: var(--slate-800); }
.sidebar .user-box .logout { font-size: 0.78rem; color: var(--slate-500); }
.sidebar .user-box .logout:hover { color: var(--danger); }

/* Header de page -------------------------------------------------------- */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.9rem 2rem;
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem;
    min-height: 64px;
}
.topbar .page-title { font-size: 1.1rem; font-weight: 600; color: var(--slate-900); }
.topbar .crumbs { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.1rem; }
.topbar .crumbs a { color: var(--text-muted); }
.topbar .crumbs a:hover { color: var(--slate-700); }

/* Contenu --------------------------------------------------------------- */
.container {
    padding: 1.75rem 2rem 3rem;
    max-width: 1280px;
    width: 100%;
}

/* Cards ----------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 1.25rem 1.4rem;
    box-shadow: var(--shadow-xs);
    margin-bottom: 1rem;
}
.card.flush { padding: 0; overflow: hidden; }
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}

/* Boutons --------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.5rem 0.9rem;
    font-size: 0.85rem; font-weight: 500; font-family: inherit;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--slate-800);
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: all 0.12s ease;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { background: var(--slate-50); border-color: var(--slate-300); color: var(--slate-900); text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn svg { width: 15px; height: 15px; stroke-width: 2; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }

.btn-danger  { background: var(--surface); border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); border-color: #fca5a5; color: #b91c1c; }

.btn-ghost { border-color: transparent; background: transparent; color: var(--slate-600); }
.btn-ghost:hover { background: var(--slate-100); color: var(--slate-900); }

.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.78rem; gap: 0.3rem; }
.btn-sm svg { width: 13px; height: 13px; }

.inline-actions { display: inline-flex; gap: 0.4rem; flex-wrap: wrap; }

/* Flashes --------------------------------------------------------------- */
.flash {
    padding: 0.7rem 1rem;
    border-radius: var(--r-sm);
    margin-bottom: 1rem;
    font-size: 0.88rem;
    display: flex; align-items: flex-start; gap: 0.6rem;
    border: 1px solid transparent;
}
.flash-success { background: var(--success-bg); color: #065f46; border-color: #a7f3d0; }
.flash-error   { background: var(--danger-bg);  color: #991b1b; border-color: #fecaca; }
.flash-warning { background: var(--warning-bg); color: #92400e; border-color: #fde68a; }
.flash-info    { background: var(--info-bg);    color: #1e40af; border-color: #bfdbfe; }

/* Formulaires ----------------------------------------------------------- */
form label { display: block; margin-bottom: 1rem; font-weight: 500; color: var(--slate-700); font-size: 0.82rem; }
form input[type=text], form input[type=email], form input[type=tel], form input[type=url],
form input[type=password], form input[type=date], form input[type=datetime-local],
form input:not([type]), form input[type=number], form input[type=search],
form select, form textarea {
    display: block; width: 100%;
    padding: 0.55rem 0.75rem;
    margin-top: 0.3rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    font-size: 0.9rem; font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.12s, box-shadow 0.12s;
}
form input::placeholder, form textarea::placeholder { color: var(--slate-400); }
form textarea { min-height: 96px; resize: vertical; }
form input:focus, form select:focus, form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}
form select {
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    padding-right: 2rem;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 1.25rem; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* Toolbar --------------------------------------------------------------- */
.toolbar { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.toolbar form { display: flex; gap: 0.6rem; align-items: center; flex: 1; flex-wrap: wrap; margin: 0; }
.toolbar form label { margin: 0; }
.toolbar input, .toolbar select { width: auto !important; margin: 0 !important; min-width: 160px; }
.toolbar .search { flex: 1; min-width: 220px !important; }

/* Tables ---------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; }
table th, table td {
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid var(--border);
    text-align: left; vertical-align: middle;
    font-size: 0.88rem;
}
table th {
    background: var(--slate-50);
    font-weight: 600;
    color: var(--slate-500);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom-color: var(--border-strong);
}
table tbody tr { transition: background 0.08s; }
table tbody tr:hover td { background: var(--slate-50); }
table tbody tr:last-child td { border-bottom: none; }

.table-empty {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-muted);
}
.table-empty .emoji { font-size: 2rem; display: block; margin-bottom: 0.5rem; opacity: 0.7; }

/* Badges de statut ------------------------------------------------------ */
.badge {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    font-size: 0.74rem; font-weight: 600;
    border-radius: 999px;
    background: var(--slate-100);
    color: var(--slate-700);
    line-height: 1.3;
    white-space: nowrap;
}
.badge::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%;
    background: currentColor; flex-shrink: 0;
}
.badge-nouveau       { background: #eef2ff; color: #4338ca; }
.badge-contacte      { background: #dbeafe; color: #1e40af; }
.badge-relance       { background: #e0f2fe; color: #075985; }
.badge-rdv_planifie  { background: #fef3c7; color: #92400e; }
.badge-interesse     { background: #fef9c3; color: #854d0e; }
.badge-negociation   { background: #ffedd5; color: #9a3412; }
.badge-client        { background: #d1fae5; color: #065f46; }
.badge-pas_interesse { background: #fee2e2; color: #991b1b; }
.badge-injoignable   { background: var(--slate-200); color: var(--slate-700); }

.stat-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; }

/* Stats (dashboard) ----------------------------------------------------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.9rem;
    margin-bottom: 1.25rem;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow-xs);
    display: flex; flex-direction: column; gap: 0.2rem;
}
.stat-card .label {
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-muted); font-weight: 600;
}
.stat-card .value { font-size: 1.7rem; font-weight: 700; color: var(--slate-900); letter-spacing: -0.02em; }
.stat-card .hint { font-size: 0.78rem; color: var(--text-muted); }
.stat-card.accent { background: linear-gradient(135deg, var(--brand-600), var(--brand-700)); border-color: transparent; color: #fff; }
.stat-card.accent .label, .stat-card.accent .hint { color: rgba(255,255,255,0.75); }
.stat-card.accent .value { color: #fff; }

/* Fiche kiné ------------------------------------------------------------ */
.page-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}
.page-header h1 { display: flex; align-items: center; gap: 0.7rem; }
.page-header .meta { color: var(--text-muted); font-size: 0.82rem; margin-top: 0.35rem; }

.kine-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.kine-info dl { display: grid; grid-template-columns: 130px 1fr; gap: 0.55rem 1.2rem; margin: 0; }
.kine-info dt { color: var(--text-muted); font-weight: 500; font-size: 0.82rem; }
.kine-info dd { margin: 0; color: var(--slate-800); font-size: 0.9rem; word-break: break-word; }

/* Timeline -------------------------------------------------------------- */
.timeline { list-style: none; padding: 0; margin: 1rem 0 0; }
.timeline li {
    position: relative;
    padding: 0.2rem 0 1.2rem 1.6rem;
    border-left: 2px solid var(--border-strong);
    margin-left: 0.5rem;
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0.2rem; }
.timeline li::before {
    content: ''; position: absolute; left: -7px; top: 0.35rem;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--primary);
    box-shadow: 0 0 0 3px var(--surface);
}
.timeline li.dir-recu::before { border-color: var(--success); }
.timeline .comm-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.timeline .comm-type {
    display: inline-flex; align-items: center; gap: 0.3rem;
    background: var(--brand-50); color: var(--brand-700);
    padding: 0.15rem 0.55rem; border-radius: 999px;
    font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
}
.timeline li.dir-recu .comm-type { background: var(--success-bg); color: #065f46; }
.timeline .comm-direction { font-size: 0.78rem; color: var(--text-muted); }
.timeline .comm-date { color: var(--text-muted); font-size: 0.8rem; margin-left: auto; }
.timeline .comm-subject { margin-top: 0.35rem; font-weight: 600; color: var(--slate-800); font-size: 0.9rem; }
.timeline .comm-body {
    margin-top: 0.35rem;
    white-space: pre-wrap;
    color: var(--slate-700);
    font-size: 0.88rem;
    line-height: 1.55;
}
.timeline .comm-follow {
    margin-top: 0.55rem;
    padding: 0.55rem 0.7rem;
    background: var(--slate-50);
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--slate-700);
}
.timeline .comm-follow strong { color: var(--slate-800); }
.timeline .comm-actions { opacity: 0; transition: opacity 0.12s; }
.timeline li:hover .comm-actions { opacity: 1; }

/* Utilitaires ----------------------------------------------------------- */
.meta { color: var(--text-muted); font-size: 0.82rem; }
.hstack { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.vstack { display: flex; flex-direction: column; gap: 0.3rem; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; }
.divider { height: 1px; background: var(--border); margin: 1rem 0; }

/* Avatars de lignes ----------------------------------------------------- */
.row-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--brand-50); color: var(--brand-700);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.78rem; flex-shrink: 0;
}
.row-ident { display: flex; align-items: center; gap: 0.7rem; }
.row-ident .name { font-weight: 600; color: var(--slate-900); }
.row-ident .sub  { font-size: 0.78rem; color: var(--text-muted); }

/* Pages d'authentification --------------------------------------------- */
body.auth {
    background:
        radial-gradient(1000px 500px at 10% -10%, rgba(99,102,241,0.15), transparent 60%),
        radial-gradient(800px 400px at 110% 110%, rgba(79,70,229,0.10), transparent 60%),
        var(--bg);
    min-height: 100vh;
    display: flex; justify-content: center; align-items: center;
    padding: 2rem;
}
body.auth .card {
    width: 100%; max-width: 440px;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    border-radius: var(--r-lg);
    margin: 0;
}
body.auth .card .auth-brand {
    display: flex; align-items: center; gap: 0.7rem;
    margin-bottom: 1.5rem;
}
body.auth .card .auth-brand .logo {
    width: 40px; height: 40px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    display: flex; align-items: center; justify-content: center; color: #fff;
    box-shadow: var(--shadow-sm);
}
body.auth .card .auth-brand .logo svg { width: 22px; height: 22px; }
body.auth .card .auth-brand h1 { font-size: 1.15rem; }
/* Ne cible que le bouton de soumission : laisse .pw-toggle et autres petits
   boutons utilitaires conserver leurs propres dimensions. */
body.auth .card form button[type=submit] { width: 100%; justify-content: center; padding: 0.7rem; font-size: 0.95rem; margin-top: 0.5rem; }

/* Statut select inline (badge cliquable) ------------------------------- */
.statut-select {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid transparent !important;
    padding: 0.2rem 1.6rem 0.2rem 0.7rem !important;
    font-size: 0.74rem !important;
    font-weight: 600 !important;
    border-radius: 999px !important;
    margin: 0 !important;
    width: auto !important;
    min-width: 135px !important;
    cursor: pointer;
    font-family: inherit;
    box-shadow: none !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%23334155' stroke-width='2.5'><polyline points='6 9 12 15 18 9'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.55rem center !important;
    transition: filter 0.12s;
}
.statut-select:hover:not(:disabled) { filter: brightness(0.97); }
.statut-select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.statut-select:disabled { opacity: 0.6; cursor: wait; }

/* Les <option> du menu déroulant ne doivent pas hériter de la couleur
   pastel du badge parent — sinon le menu natif devient illisible. */
.statut-select option {
    color: var(--slate-900);
    background-color: #ffffff;
    font-weight: 500;
}
html.dark .statut-select option {
    color: #e2e8f0;
    background-color: #1e293b;
}

/* Toasts --------------------------------------------------------------- */
#toast-container {
    position: fixed; top: 1rem; right: 1rem; z-index: 9999;
    display: flex; flex-direction: column; gap: 0.55rem;
    pointer-events: none;
    max-width: calc(100% - 2rem);
}
.toast {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-left: 3px solid var(--primary);
    color: var(--slate-800);
    padding: 0.75rem 1rem;
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-md);
    font-size: 0.88rem;
    pointer-events: auto;
    transform: translateX(calc(100% + 1.5rem));
    opacity: 0;
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.25s;
    min-width: 240px;
    max-width: 380px;
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast-success { border-left-color: var(--success); }
.toast-error   { border-left-color: var(--danger);  color: #7f1d1d; }
.toast-info    { border-left-color: var(--info); }

/* Modal ---------------------------------------------------------------- */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: none;
    align-items: flex-start; justify-content: center;
    z-index: 1000;
    padding: 3rem 1.5rem;
    opacity: 0;
    transition: opacity 0.18s ease;
    overflow-y: auto;
}
.modal-backdrop.show { display: flex; opacity: 1; }
.modal {
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    max-width: 680px; width: 100%;
    overflow: hidden;
    transform: translateY(-12px) scale(0.98);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.modal-backdrop.show .modal {
    transform: translateY(0) scale(1);
    opacity: 1;
}
.modal-head {
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.modal-head h2 { font-size: 1.05rem; margin: 0; }
.modal-body { padding: 1.25rem 1.4rem 0.25rem; }
.modal-body label:last-of-type { margin-bottom: 1.25rem; }
.modal-foot {
    padding: 0.85rem 1.4rem;
    border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 0.5rem;
    background: var(--slate-50);
}
.modal-close-btn {
    background: none; border: none;
    font-size: 1.5rem; line-height: 1;
    color: var(--slate-400);
    cursor: pointer;
    padding: 0.1rem 0.5rem;
    border-radius: var(--r-sm);
}
.modal-close-btn:hover { background: var(--slate-100); color: var(--slate-900); }

/* Indicateur de recherche ---------------------------------------------- */
.search-hint { font-size: 0.78rem; color: var(--text-muted); margin-left: 0.5rem; }

/* ======================================================================
   Widget tag-input : saisie de tags avec suggestions canoniques
   ====================================================================== */
.tag-input { position: relative; width: 100%; margin-top: 0.3rem; }
.tag-area {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem;
    min-height: 2.4rem;
    padding: 0.3rem 0.45rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    cursor: text;
    transition: border-color 0.12s, box-shadow 0.12s;
}
.tag-area.focus,
.tag-area:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}
.tag-pill {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.18rem 0.15rem 0.18rem 0.6rem;
    background: var(--brand-50);
    color: var(--brand-700);
    border-radius: var(--r-sm);
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.2;
    max-width: 100%;
    white-space: nowrap;
}
.tag-pill span { overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.tag-pill button {
    background: transparent; border: none; cursor: pointer;
    color: inherit; opacity: 0.6;
    font-size: 1rem; line-height: 1;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
}
.tag-pill button:hover { opacity: 1; background: rgba(0,0,0,0.08); }

/* L'input de saisie héberge le focus et doit neutraliser tous les styles
   form input[...] globaux (bordure, padding, ombre…). */
.tag-input .tag-entry {
    flex: 1 1 100px;
    min-width: 80px;
    border: none !important;
    outline: none !important;
    padding: 0.25rem 0.35rem !important;
    margin: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 0.9rem !important;
    color: var(--text) !important;
    width: auto !important;
    display: inline-block !important;
}
.tag-input .tag-entry:focus { box-shadow: none !important; }
.tag-input .tag-entry::placeholder { color: var(--slate-400); }

.tag-suggestions {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-md);
    max-height: 240px; overflow-y: auto;
    z-index: 20;
    padding: 0.3rem;
    display: flex; flex-direction: column; gap: 1px;
}
.tag-suggestions[hidden] { display: none; }
.tag-suggestions .sug-item {
    text-align: left;
    padding: 0.4rem 0.6rem;
    background: transparent; border: none; cursor: pointer;
    color: var(--text); font-size: 0.88rem;
    border-radius: 4px;
    display: flex; align-items: center; gap: 0.4rem;
}
.tag-suggestions .sug-item:hover,
.tag-suggestions .sug-item.active { background: var(--slate-100); }
.tag-suggestions .sug-note {
    margin-left: auto;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-style: italic;
}
.tag-suggestions .sug-create {
    color: var(--primary);
    font-weight: 500;
    border-top: 1px dashed var(--border);
    margin-top: 0.2rem;
    padding-top: 0.5rem;
}

/* Dark mode */
html.dark .tag-area { background: #0f172a; border-color: #334155; }
html.dark .tag-area:focus-within,
html.dark .tag-area.focus { border-color: #818cf8; box-shadow: 0 0 0 3px rgba(129,140,248,0.25); }
html.dark .tag-pill { background: rgba(129,140,248,0.2); color: #c7d2fe; }
html.dark .tag-pill button:hover { background: rgba(255,255,255,0.08); }
html.dark .tag-input .tag-entry { color: #e2e8f0 !important; }
html.dark .tag-input .tag-entry::placeholder { color: #64748b; }
html.dark .tag-suggestions { background: #1e293b; border-color: #334155; }
html.dark .tag-suggestions .sug-item { color: #e2e8f0; }
html.dark .tag-suggestions .sug-item:hover,
html.dark .tag-suggestions .sug-item.active { background: #334155; }
html.dark .tag-suggestions .sug-note { color: #94a3b8; }
html.dark .tag-suggestions .sug-create { color: #a5b4fc; border-top-color: var(--border); }

/* ======================================================================
   Toggle afficher/masquer sur les input[type=password]
   ====================================================================== */
.pw-toggle-wrap {
    position: relative;
    display: block;
    width: 100%;
}
/* L'enrichissement augmente le padding droit pour laisser la place au bouton */
.pw-toggle-wrap > input[data-pw-enhanced] {
    padding-right: 2.5rem !important;
}
.pw-toggle {
    position: absolute;
    right: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    padding: 0.35rem;
    cursor: pointer;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    line-height: 0;
    transition: background 0.12s, color 0.12s;
}
.pw-toggle:hover {
    color: #0f172a;
    background: rgba(15, 23, 42, 0.06);
}
.pw-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}
.pw-toggle svg { width: 18px; height: 18px; stroke-width: 1.8; }

html.dark .pw-toggle { color: #94a3b8; }
html.dark .pw-toggle:hover {
    color: #f1f5f9;
    background: rgba(255, 255, 255, 0.06);
}

/* ======================================================================
   Formulaire structuré par sections (kine_form, etc.)
   ====================================================================== */

.form-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 1.25rem;
    align-items: start;
}
@media (max-width: 1000px) {
    .form-layout { grid-template-columns: 1fr; }
    .form-side { position: static !important; top: auto !important; }
}
.form-main  { min-width: 0; }
.form-side  { position: sticky; top: 1rem; display: flex; flex-direction: column; gap: 1rem; }

.form-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-xs);
    margin-bottom: 1rem;
    overflow: hidden;
}
.form-side .form-section { margin-bottom: 0; }
.form-section-head {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.95rem 1.3rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(to bottom, #fafbfd, var(--surface));
}
.form-section-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: var(--brand-50);
    color: var(--brand-600);
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.form-section-icon svg { width: 20px; height: 20px; stroke-width: 1.8; }
.form-section-title  { font-size: 0.95rem; font-weight: 600; color: var(--slate-900); margin: 0; line-height: 1.2; }
.form-section-sub    { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.15rem; }
.form-section-body   { padding: 1.2rem 1.3rem 0.2rem; }
.form-section-body > *:last-child { margin-bottom: 0.6rem; }

/* Inputs avec icône de préfixe ---------------------------------------- */
.input-icon { position: relative; margin-top: 0.3rem; }
.input-icon svg {
    position: absolute;
    left: 0.78rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px; height: 16px;
    color: var(--slate-400);
    pointer-events: none;
    stroke-width: 1.8;
}
.input-icon input,
.input-icon select {
    padding-left: 2.3rem !important;
    margin-top: 0 !important;
}

/* Astérisque requis --------------------------------------------------- */
.req { color: var(--danger); margin-left: 0.15rem; font-weight: 700; }
.field-hint { display: block; font-size: 0.74rem; color: var(--text-muted); margin-top: 0.3rem; font-weight: 400; }

/* Pastilles de statut (radio stylés) ---------------------------------- */
.statut-pills { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.35rem; }
.statut-pill {
    display: inline-flex; align-items: center;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid transparent;
    opacity: 0.55;
    transition: opacity 0.12s, border-color 0.12s, transform 0.08s;
    margin: 0;
    user-select: none;
    line-height: 1.2;
}
.statut-pill input { position: absolute; opacity: 0; pointer-events: none; }
.statut-pill:hover { opacity: 0.88; transform: translateY(-1px); }
.statut-pill:has(input:checked) { opacity: 1; border-color: currentColor; }
.statut-pill:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Checkbox alignée ---------------------------------------------------- */
.checkbox-row {
    display: flex; align-items: flex-start; gap: 0.6rem;
    padding: 0.65rem 0.8rem;
    background: var(--slate-50);
    border: 1px dashed var(--border-strong);
    border-radius: var(--r-sm);
    font-weight: 500;
    color: var(--slate-700);
    font-size: 0.85rem;
    cursor: pointer;
    margin: 0.5rem 0 0.8rem !important;
}
.checkbox-row input { width: auto !important; margin: 0.15rem 0 0 !important; flex-shrink: 0; }

/* Barre d'actions (sticky) -------------------------------------------- */
.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    margin-top: 1rem;
    flex-wrap: wrap;
}
.form-actions-sticky {
    position: sticky;
    bottom: 0.75rem;
    z-index: 10;
    backdrop-filter: saturate(1.2);
}
.form-actions .left  { color: var(--text-muted); font-size: 0.82rem; }
.form-actions .right { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Aperçu (fiche miniature) -------------------------------------------- */
.preview-card {
    padding: 1rem 1.2rem;
    display: flex; align-items: center; gap: 0.8rem;
    background: linear-gradient(135deg, var(--brand-50), #ffffff);
    border: 1px solid var(--brand-100);
    border-radius: var(--r-md);
}
.preview-card .row-avatar { width: 44px; height: 44px; font-size: 0.92rem; }
.preview-card .name { font-weight: 600; color: var(--slate-900); font-size: 0.95rem; }
.preview-card .sub  { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; }

/* ======================================================================
   CONVERSATION (bulles type SMS) — fallback visuel si Tailwind indisponible
   ====================================================================== */
.conversation {
    list-style: none;
    padding: 0;
    margin: 1rem 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* ======================================================================
   DARK MODE
   ====================================================================== */

html.dark {
    /* Variables sémantiques : l'essentiel s'adapte via var(--...) */
    --bg:            #0b1220;
    --surface:       #111827;
    --border:        #1f2937;
    --border-strong: #334155;
    --text:          #e2e8f0;
    --text-muted:    #94a3b8;
    --primary:       #818cf8;
    --primary-hover: #a5b4fc;

    /* Ombres plus marquées sur fond sombre */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);

    color-scheme: dark;
}

html.dark a         { color: #a5b4fc; }
html.dark a:hover   { color: #c7d2fe; }
html.dark h1, html.dark h2, html.dark h3, html.dark h4 { color: #f1f5f9; }

/* -------- Sidebar & topbar -------- */
html.dark .sidebar             { border-right-color: var(--border); }
html.dark .sidebar .brand      { color: #f1f5f9; }
html.dark .sidebar nav a       { color: #94a3b8; }
html.dark .sidebar nav a:hover { background: #1e293b; color: #f1f5f9; }
html.dark .sidebar nav a:hover svg { color: #cbd5e1; }
html.dark .sidebar nav a.active        { background: rgba(99,102,241,0.16); color: #c7d2fe; }
html.dark .sidebar nav a.active svg    { color: #c7d2fe; }
html.dark .sidebar .user-box           { border-top-color: var(--border); }
html.dark .sidebar .avatar             { background: rgba(129,140,248,0.2); color: #c7d2fe; }
html.dark .sidebar .user-box .name     { color: #e2e8f0; }
html.dark .sidebar .user-box .logout   { color: #94a3b8; }
html.dark .sidebar .user-box .logout:hover { color: #fca5a5; }

html.dark .topbar              { border-bottom-color: var(--border); }
html.dark .topbar .page-title  { color: #f1f5f9; }

/* -------- Cards & sections -------- */
html.dark .card                { border-color: var(--border); }
html.dark .form-section        { background: var(--surface); border-color: var(--border); }
html.dark .form-section-head   { background: linear-gradient(to bottom, #0f172a, var(--surface)); border-bottom-color: var(--border); }
html.dark .form-section-title  { color: #f1f5f9; }
html.dark .form-section-sub    { color: var(--text-muted); }
html.dark .form-section-icon   { background: rgba(129,140,248,0.18); color: #c7d2fe; }

/* -------- Boutons -------- */
html.dark .btn                 { background: #1e293b; color: #e2e8f0; border-color: #334155; }
html.dark .btn:hover           { background: #283549; color: #f1f5f9; border-color: #475569; }
html.dark .btn-primary         { background: #4f46e5; border-color: #4f46e5; color: #f5f3ff; }
html.dark .btn-primary:hover   { background: #4338ca; border-color: #4338ca; }
html.dark .btn-danger          { background: #1e293b; color: #fca5a5; border-color: rgba(239,68,68,0.35); }
html.dark .btn-danger:hover    { background: rgba(239,68,68,0.18); color: #fecaca; border-color: rgba(239,68,68,0.5); }
html.dark .btn-ghost           { background: transparent; color: #94a3b8; border-color: transparent; }
html.dark .btn-ghost:hover     { background: #1e293b; color: #f1f5f9; }

/* -------- Tables -------- */
html.dark table                       { color: var(--text); }
html.dark table th                    { background: #0f172a; color: #94a3b8; border-bottom-color: var(--border-strong); }
html.dark table td                    { border-bottom-color: var(--border); }
html.dark table tbody tr:hover td     { background: rgba(255,255,255,0.025); }
html.dark .table-empty                { color: var(--text-muted); }

/* -------- Formulaires legacy -------- */
html.dark form label                  { color: #cbd5e1; }
html.dark form input[type=text],
html.dark form input[type=email],
html.dark form input[type=tel],
html.dark form input[type=url],
html.dark form input[type=password],
html.dark form input[type=date],
html.dark form input[type=datetime-local],
html.dark form input:not([type]),
html.dark form input[type=number],
html.dark form input[type=search],
html.dark form select,
html.dark form textarea {
    /* background-color (pas `background` raccourci) : sinon le raccourci
       remet background-repeat à `repeat` et le chevron des <select> se
       répète sur toute la largeur. */
    background-color: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}
html.dark form input::placeholder,
html.dark form textarea::placeholder  { color: #64748b; }
html.dark form input:focus,
html.dark form select:focus,
html.dark form textarea:focus         { border-color: #818cf8; box-shadow: 0 0 0 3px rgba(129,140,248,0.25); }
html.dark form select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>");
}
html.dark .checkbox-row { background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.3); color: #fcd34d; }

/* Inputs calendriers natifs : retourner l'icône */
html.dark input[type=date]::-webkit-calendar-picker-indicator,
html.dark input[type=datetime-local]::-webkit-calendar-picker-indicator { filter: invert(0.85); }

/* -------- Badges de statut (teintes douces sur fond sombre) -------- */
html.dark .badge                       { background: #1e293b; color: #cbd5e1; }
html.dark .badge-nouveau               { background: rgba(129,140,248,0.18); color: #c7d2fe; }
html.dark .badge-contacte              { background: rgba(59,130,246,0.18); color: #93c5fd; }
html.dark .badge-relance               { background: rgba(14,165,233,0.18); color: #7dd3fc; }
html.dark .badge-rdv_planifie          { background: rgba(245,158,11,0.18); color: #fcd34d; }
html.dark .badge-interesse             { background: rgba(234,179,8,0.18); color: #fde68a; }
html.dark .badge-negociation           { background: rgba(249,115,22,0.18); color: #fdba74; }
html.dark .badge-client                { background: rgba(16,185,129,0.18); color: #6ee7b7; }
html.dark .badge-pas_interesse         { background: rgba(239,68,68,0.18); color: #fca5a5; }
html.dark .badge-injoignable           { background: #334155; color: #cbd5e1; }
html.dark .statut-select {
    border-color: rgba(255,255,255,0.05) !important;
    /* Chevron clair (stroke slate-300) pour être visible sur fond sombre */
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%23cbd5e1' stroke-width='2.5'><polyline points='6 9 12 15 18 9'/></svg>") !important;
}

/* -------- Avatars de ligne -------- */
html.dark .row-avatar                  { background: rgba(129,140,248,0.2); color: #c7d2fe; }
html.dark .row-ident .name             { color: #e2e8f0; }
html.dark .row-ident .sub              { color: var(--text-muted); }

/* -------- Flashes -------- */
html.dark .flash                       { border-color: transparent; }
html.dark .flash-success               { background: rgba(16,185,129,0.12); color: #6ee7b7; border-color: rgba(16,185,129,0.3); }
html.dark .flash-error                 { background: rgba(239,68,68,0.12);  color: #fca5a5; border-color: rgba(239,68,68,0.3); }
html.dark .flash-warning               { background: rgba(245,158,11,0.12); color: #fcd34d; border-color: rgba(245,158,11,0.3); }
html.dark .flash-info                  { background: rgba(59,130,246,0.12); color: #93c5fd; border-color: rgba(59,130,246,0.3); }

/* -------- Timeline -------- */
html.dark .timeline li                 { border-left-color: #334155; }
html.dark .timeline li::before         { background: var(--surface); box-shadow: 0 0 0 3px var(--surface); border-color: #818cf8; }
html.dark .timeline li.dir-recu::before { border-color: #34d399; }
html.dark .timeline .comm-type         { background: rgba(129,140,248,0.2); color: #c7d2fe; }
html.dark .timeline li.dir-recu .comm-type { background: rgba(16,185,129,0.2); color: #6ee7b7; }
html.dark .timeline .comm-subject      { color: #e2e8f0; }
html.dark .timeline .comm-body         { color: #cbd5e1; }
html.dark .timeline .comm-follow       { background: #0f172a; border-color: var(--border); color: #cbd5e1; }
html.dark .timeline .comm-follow strong{ color: #f1f5f9; }
html.dark .timeline .comm-direction    { color: #94a3b8; }
html.dark .timeline .comm-date         { color: #64748b; }

/* -------- Stats / dashboard -------- */
html.dark .stat-card                   { background: var(--surface); border-color: var(--border); }
html.dark .stat-card .value            { color: #f1f5f9; }
html.dark .stat-card.accent            { background: linear-gradient(135deg, #4f46e5, #4338ca); border-color: transparent; color: #fff; }

/* -------- Modal -------- */
html.dark .modal                       { background: var(--surface); }
html.dark .modal-head                  { border-bottom-color: var(--border); }
html.dark .modal-head h2               { color: #f1f5f9; }
html.dark .modal-foot                  { background: #0f172a; border-top-color: var(--border); }
html.dark .modal-close-btn             { color: #94a3b8; }
html.dark .modal-close-btn:hover       { background: #1e293b; color: #f1f5f9; }
html.dark .modal-backdrop              { background: rgba(0, 0, 0, 0.65); }

/* -------- Toasts -------- */
html.dark .toast                       { background: var(--surface); border-color: var(--border-strong); color: #e2e8f0; }
html.dark .toast-error                 { color: #fca5a5; }

/* -------- Kine info -------- */
html.dark .kine-info dt                { color: var(--text-muted); }
html.dark .kine-info dd                { color: #e2e8f0; }

/* -------- Preview card -------- */
html.dark .preview-card                { background: linear-gradient(135deg, rgba(129,140,248,0.12), var(--surface)); border-color: rgba(129,140,248,0.25); }
html.dark .preview-card .name          { color: #f1f5f9; }

/* -------- Auth pages -------- */
html.dark body.auth {
    background:
        radial-gradient(1000px 500px at 10% -10%, rgba(129,140,248,0.2), transparent 60%),
        radial-gradient(800px 400px at 110% 110%, rgba(99,102,241,0.15), transparent 60%),
        var(--bg);
}
html.dark body.auth .card              { background: var(--surface); border-color: var(--border); }
html.dark body.auth .card .meta        { color: var(--text-muted); }

/* -------- Divers -------- */
html.dark .meta                        { color: var(--text-muted); }
html.dark .divider                     { background: var(--border); }
html.dark .search-hint                 { color: var(--text-muted); }

/* -------- Bouton de bascule thème -------- */
.theme-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    background: transparent;
    color: var(--slate-500);
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.theme-toggle:hover                    { background: var(--slate-100); color: var(--slate-900); }
html.dark .theme-toggle                { color: #94a3b8; }
html.dark .theme-toggle:hover          { background: #1e293b; color: #f1f5f9; }
.theme-toggle svg                      { width: 18px; height: 18px; }
.theme-toggle .icon-moon               { display: none; }
.theme-toggle .icon-sun                { display: inline-block; }
html.dark .theme-toggle .icon-moon     { display: inline-block; }
html.dark .theme-toggle .icon-sun      { display: none; }

/* Responsive ------------------------------------------------------------ */
@media (max-width: 820px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: static; height: auto;
        flex-direction: row; align-items: center;
        padding: 0.6rem 1rem;
    }
    .sidebar .brand { padding: 0; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; margin-left: auto; }
    .sidebar nav a { padding: 0.4rem 0.6rem; }
    .sidebar .spacer, .sidebar .user-box { display: none; }
    .topbar { padding: 0.75rem 1rem; }
    .container { padding: 1rem; }
}
