/* ─── Reset & base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── Scrollbars ─── */
/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,.15) transparent;
}
[data-theme="dark"] * {
    scrollbar-color: rgba(255,255,255,.15) transparent;
}

/* Webkit (Chrome, Edge, Safari) */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,.15);
    border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.3); }
::-webkit-scrollbar-corner { background: transparent; }

[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.3); }

:root {
    /* ─── Couleurs ─── */
    --color-primary:   #4F46E5;
    --color-primary-h: #4338CA;
    --color-bg:        #F8F7F4;
    --color-surface:   #FFFFFF;
    --color-border:    #E5E3DB;
    --color-text:      #1C1C1A;
    --color-muted:     #6B6B66;
    --color-success:   #059669;
    --color-danger:    #DC2626;
    --color-warning:   #D97706;
    --color-primary-light:   #EEF2FF;
    --color-primary-lighter: #E0E7FF;
    --color-success-light:   #ECFDF5;
    --color-danger-light:    #FEF2F2;
    --color-warning-light:   #FFFBEB;

    /* ─── Layout ─── */
    --sidebar-w:       240px;

    /* ─── Radii (cascade hiérarchique) ─── */
    --radius-sm:       6px;
    --radius:          8px;        /* alias de radius-md pour rétro-compat */
    --radius-md:       10px;
    --radius-lg:       14px;
    --radius-xl:       20px;
    --radius-full:     9999px;

    /* ─── Shadows (cascade hiérarchique, design-system style) ─── */
    --shadow-sm:       0 1px 2px rgba(15, 23, 42, .06);
    --shadow:          0 1px 3px rgba(15, 23, 42, .08);    /* alias de shadow-md pour rétro-compat */
    --shadow-md:       0 4px 12px rgba(15, 23, 42, .07), 0 1px 3px rgba(15, 23, 42, .04);
    --shadow-lg:       0 12px 32px rgba(15, 23, 42, .10), 0 2px 6px rgba(15, 23, 42, .04);
    --shadow-xl:       0 24px 56px rgba(15, 23, 42, .14);
    --shadow-focus:    0 0 0 3px rgba(79, 70, 229, .18);

    /* ─── Transitions ─── */
    --ease-smooth:     cubic-bezier(.4, 0, .2, 1);
    --transition:      .2s var(--ease-smooth);
}

body { font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
       font-size: 15px; line-height: 1.6; color: var(--color-text); background: var(--color-bg);
       -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
       font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11'; }

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Toast notifications ─── */
.toast-container {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 340px;
    max-width: calc(100vw - 2.5rem);
    pointer-events: none;
}

.toast {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: .875rem 1rem .875rem .875rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0,0,0,.10), 0 1px 4px rgba(0,0,0,.06);
    overflow: hidden;
    pointer-events: all;
    animation: toast-in .22s cubic-bezier(.21,1.02,.73,1) forwards;
}
.toast--out {
    animation: toast-out .2s ease forwards;
}

.toast--success { border-left: 4px solid #10B981; }
.toast--error   { border-left: 4px solid #EF4444; }
.toast--warning { border-left: 4px solid #F59E0B; }
.toast--info    { border-left: 4px solid #3B82F6; }

.toast__icon {
    flex-shrink: 0;
    width: 22px; height: 22px;
    border-radius: 50%;
    font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.toast--success .toast__icon { background: #D1FAE5; color: #059669; }
.toast--error   .toast__icon { background: #FEE2E2; color: #DC2626; }
.toast--warning .toast__icon { background: #FEF3C7; color: #D97706; }
.toast--info    .toast__icon { background: #DBEAFE; color: #2563EB; }

.toast__body { flex: 1; min-width: 0; }
.toast__type { display: block; font-size: 12px; font-weight: 700; letter-spacing: .03em; margin-bottom: 2px; }
.toast--success .toast__type { color: #059669; }
.toast--error   .toast__type { color: #DC2626; }
.toast--warning .toast__type { color: #D97706; }
.toast--info    .toast__type { color: #2563EB; }
.toast__msg  { font-size: 13px; line-height: 1.45; color: var(--color-text); }

.toast__close {
    flex-shrink: 0;
    background: none; border: none; cursor: pointer;
    color: var(--color-muted); font-size: 18px; line-height: 1;
    padding: 0; margin-top: 1px; opacity: .6; transition: opacity .15s;
}
.toast__close:hover { opacity: 1; }

.toast__bar {
    position: absolute;
    bottom: 0; left: 0;
    height: 3px;
    width: 100%;
    border-radius: 0 0 10px 10px;
    transition: none;
}
.toast--success .toast__bar { background: #10B981; }
.toast--error   .toast__bar { background: #EF4444; }
.toast--warning .toast__bar { background: #F59E0B; }
.toast--info    .toast__bar { background: #3B82F6; }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(calc(100% + 1.25rem)); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
    from { opacity: 1; transform: translateX(0); max-height: 120px; margin-bottom: 0; }
    to   { opacity: 0; transform: translateX(calc(100% + 1.25rem)); max-height: 0; padding-top: 0; padding-bottom: 0; }
}

/* ─── Layout app ─── */
.app { display: flex; min-height: 100vh; }

/* Pages plein-cadre (kanban, chat, journal) : on BORNE .app à la hauteur du
   viewport. Sans ça, un contenu interne tall (ex: colonne kanban remplie) fait
   grandir .app, et la barre de défilement horizontale finit hors écran.
   On utilise :has() pour cibler uniquement les pages avec .content--flush
   ET un fallback via body.page-flush pour les anciens navigateurs. */
.app:has(.content--flush),
body.page-flush .app {
    height: 100vh;
    height: 100dvh;     /* 100dvh = hauteur dynamique, exclut la barre URL mobile */
    min-height: 0;
    overflow: hidden;
}

.sidebar { width: var(--sidebar-w); background: var(--color-surface);
           border-right: 1px solid var(--color-border);
           display: flex; flex-direction: column; flex-shrink: 0;
           height: 100vh; position: sticky; top: 0; overflow: hidden; }

.sidebar__logo { display: flex; align-items: center; gap: 10px;
                 padding: 1.25rem 1rem; border-bottom: 1px solid var(--color-border);
                 font-weight: 600; font-size: 16px; }

.sidebar__nav { flex: 1; padding: .5rem .5rem; display: flex; flex-direction: column; overflow-y: auto; }

/* Groupes de navigation */
.sidebar__nav-group { display: flex; flex-direction: column; gap: 2px; }
.sidebar__nav-group--separated { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--color-border); }

.sidebar__nav-group-title {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    padding: 8px 10px 4px;
    user-select: none;
    border-radius: 4px 4px 0 0;
}
.sidebar__nav-group-title--conseil  { color: #4338CA; }
.sidebar__nav-group-title--residents { color: #15803D; }
[data-theme="dark"] .sidebar__nav-group-title--conseil   { color: #818CF8; }
[data-theme="dark"] .sidebar__nav-group-title--residents { color: #4ADE80; }

.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: .55rem .8rem;
    border-radius: var(--radius-md);
    color: var(--color-muted);
    font-size: 13.5px; font-weight: 500;
    position: relative;
    transition: background var(--transition), color var(--transition), transform .12s var(--ease-smooth);
}
.nav-item:hover {
    background: var(--color-bg);
    color: var(--color-text);
    text-decoration: none;
    transform: translateX(2px);
}
.nav-item--active {
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-weight: 600;
}
.nav-item--active::before {
    content: '';
    position: absolute; left: -4px; top: 8px; bottom: 8px;
    width: 3px; border-radius: 99px;
    background: var(--color-primary);
}
.nav-item--active:hover { transform: none; }
.nav-item__icon { width: 17px; height: 17px; flex-shrink: 0; opacity: .9; }
.nav-item--active .nav-item__icon { opacity: 1; }
/* Badge de notifications par module (compteur à droite de l'entrée) */
.nav-badge {
    margin-left: auto;
    flex-shrink: 0;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--color-surface);
}
.nav-badge[hidden] { display: none; }
.sidebar__sep { border: none; border-top: 1px solid var(--color-border); margin: .5rem 0; }

.sidebar__user { padding: .75rem 1rem; border-top: 1px solid var(--color-border); font-size: 13px; }
.sidebar__user-link {
    display: flex; align-items: center; gap: 10px;
    text-decoration: none; color: inherit;
    padding: 6px 8px; border-radius: 8px;
    transition: background .12s;
    margin-bottom: 6px;
}
.sidebar__user-link:hover { background: var(--color-hover); }
.sidebar__user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    object-fit: cover; flex-shrink: 0;
}
.sidebar__user-avatar--initials {
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12px; letter-spacing: -0.5px;
}
.sidebar__user-info { flex: 1; min-width: 0; }
.sidebar__user-name {
    display: flex; align-items: center; gap: 4px;
    font-weight: 600; font-size: 13px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar__user-admin-badge {
    color: #f59e0b; flex-shrink: 0;
    display: inline-flex; align-items: center;
}
[data-theme="dark"] .sidebar__user-admin-badge { color: #fbbf24; }
.sidebar__user-role {
    display: block; color: var(--color-muted);
    font-size: 11.5px; font-weight: 400;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar__user-chevron {
    flex-shrink: 0; color: var(--color-muted);
    transition: transform .15s;
}
.sidebar__user-link:hover .sidebar__user-chevron { color: var(--color-text); }
.sidebar__logout {
    color: var(--color-muted); font-size: 12px; text-decoration: none;
    display: inline-flex; align-items: center;
    transition: color .12s;
}
.sidebar__logout:hover { color: var(--color-danger); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }

.topbar {
    display: flex; align-items: center; gap: 1rem;
    padding: .9rem 1.5rem;
    /* Sticky avec effet "frosted glass" pour un look moderne quand on scroll */
    position: sticky; top: 0; z-index: 10;
    background: rgba(255, 255, 255, .82);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--color-border);
}
[data-theme="dark"] .topbar {
    background: rgba(31, 41, 55, .82);
}
.topbar__title {
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -.01em;
    flex: 1; min-width: 0;
    /* Le titre se comprime puis s'ellipse AVANT de chevaucher les actions
       (corrige le chevauchement titre/boutons observé en tablette). */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Titres « fil d'Ariane » des pages détail (réunion, sondage, devis, annonce…) :
   .show-breadcrumb est un inline-flex (boîte atomique) → l'ellipsis du h1 ne s'y
   applique pas et tronquerait net le titre. On confie donc la troncature au fil
   d'Ariane : seul le segment courant s'ellipse, le préfixe (« Réunions / ») reste
   visible. */
.topbar__title .show-breadcrumb { display: flex; min-width: 0; max-width: 100%; }
.topbar__title .show-breadcrumb__current {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.content { padding: 1.5rem; }
/* --flush : conteneur plein-cadre (kanban, chat, journal).
   Le min-height: 0 est INDISPENSABLE : sans lui, un flex item enfant n'est pas
   borné en hauteur (il prend la taille de son contenu), donc un contenu intérieur
   trop grand fait grandir le body au lieu de scroller en interne — symptôme :
   sur le kanban, une colonne avec beaucoup de cartes pousse le body et la barre
   de défilement horizontale finit hors écran. */
.content--flush {
    overflow: hidden;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* ─── Formulaires ─── */
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: .4rem;
    color: var(--color-text);
    letter-spacing: -.005em;
}
.form-input {
    width: 100%;
    padding: .625rem .9rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 14.5px;
    line-height: 1.4;
    color: var(--color-text);
    background: var(--color-surface);
    transition: border-color var(--transition), box-shadow var(--transition),
                background var(--transition);
    appearance: none;
    -webkit-appearance: none;
}
.form-input::placeholder { color: var(--color-muted); opacity: .7; }
.form-input:hover:not(:focus):not(:disabled) {
    border-color: rgba(79, 70, 229, .35);
}
.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--shadow-focus);
}
.form-input:disabled {
    background: var(--color-bg);
    opacity: .65;
    cursor: not-allowed;
}
/* Selects : flèche custom plus moderne */
select.form-input {
    /* appearance: none avec !important pour empêcher le browser d'imposer ses styles
       natifs dark mode (Firefox notamment) qui se superposent au SVG custom */
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    /* color-scheme normal indique au browser de ne pas appliquer son styling dark/light
       natif sur ce form control (la nôtre est custom) */
    color-scheme: normal;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B6B66' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .85rem center;
    background-color: var(--color-surface);
    padding-right: 2.25rem;
    cursor: pointer;
}
[data-theme="dark"] select.form-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-color: #13161C;
}
/* Masquer la flèche native sur IE/Edge legacy (au cas où) */
select.form-input::-ms-expand { display: none; }
/* Textarea : même style mais redimensionnable verticalement */
textarea.form-input {
    resize: vertical;
    min-height: 70px;
    line-height: 1.5;
}
/* Helper text sous l'input */
.form-help {
    margin-top: .35rem;
    font-size: 12.5px;
    color: var(--color-muted);
    line-height: 1.4;
}
/* État d'erreur */
.form-input--error {
    border-color: var(--color-danger) !important;
}
.form-input--error:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .18);
}
.form-error {
    margin-top: .35rem;
    font-size: 12.5px;
    color: var(--color-danger);
    font-weight: 500;
}

/* ─── Checklist de cases à cocher (membres, labels, options) ─── */
/* Utilisé par : commissions (création/édition membres), settings (labels),
   kanban (assignees, labels). Doit rester dans app.css pour fonctionner sur
   les pages qui ne chargent pas kanban.css. */
.user-checklist {
    display: flex; flex-direction: column; gap: 2px;
    max-height: 200px; overflow-y: auto;
    padding: .375rem .5rem; background: var(--color-bg);
    border: 1px solid var(--color-border); border-radius: var(--radius);
}
.label-option {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; cursor: pointer; padding: 2px 0;
}
.label-option input[type=checkbox] { cursor: pointer; }
[data-theme="dark"] .user-checklist { background: #111827; border-color: #374151; }
[data-theme="dark"] .label-option { background: transparent; }

/* ─── Boutons ─── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: .6rem 1.1rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 14px; font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background var(--transition), border-color var(--transition),
                box-shadow var(--transition), transform .12s var(--ease-smooth),
                color var(--transition);
    user-select: none;
    text-decoration: none;
}
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn--primary {
    background: var(--color-primary); color: #fff;
    border-color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}
.btn--primary:hover:not(:disabled) {
    background: var(--color-primary-h);
    border-color: var(--color-primary-h);
    box-shadow: var(--shadow-md);
    color: #fff;
}

.btn--ghost {
    background: transparent;
    border-color: var(--color-border);
    color: var(--color-text);
}
.btn--ghost:hover:not(:disabled) {
    background: var(--color-bg);
    border-color: var(--color-muted);
    color: var(--color-text);
}

.btn--danger {
    background: var(--color-danger); color: #fff;
    border-color: var(--color-danger);
    box-shadow: var(--shadow-sm);
}
.btn--danger:hover:not(:disabled) {
    background: #B91C1C;
    border-color: #B91C1C;
    box-shadow: var(--shadow-md);
    color: #fff;
}

.btn--success {
    background: var(--color-success); color: #fff;
    border-color: var(--color-success);
    box-shadow: var(--shadow-sm);
}
.btn--success:hover:not(:disabled) {
    background: #047857;
    border-color: #047857;
    box-shadow: var(--shadow-md);
    color: #fff;
}

.btn--full { width: 100%; justify-content: center; }
.btn--sm { padding: .35rem .8rem; font-size: 13px; }
.btn--lg { padding: .8rem 1.5rem; font-size: 15px; }

/* ─── Login ─── */
.login-page { background: var(--color-bg); }
.login-container { display: flex; align-items: center; justify-content: center;
                   min-height: 100vh; padding: 2rem; }
.login-card { background: var(--color-surface); border: 1px solid var(--color-border);
              border-radius: 12px; padding: 2.5rem; width: 100%; max-width: 400px;
              box-shadow: var(--shadow); }
.login-card__header { text-align: center; margin-bottom: 2rem; }
.login-card__title  { font-size: 22px; font-weight: 700; }
.login-card__subtitle { color: var(--color-muted); font-size: 14px; margin-top: .25rem; }

.login-remember { margin-top: .25rem; }
.login-remember__label {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; cursor: pointer; color: var(--color-text);
}
.login-remember__check { width: 15px; height: 15px; cursor: pointer; accent-color: var(--color-primary); }
.login-remember__hint  { color: var(--color-muted); font-size: 12px; }

/* ─── Dark mode ─── */
/* Palette gris neutre façon "GitHub / Linear" :
   - Aucune dominante bleue, gris pur tirant vers chaud
   - Background presque noir, surfaces avec micro-élévation perceptible
   - Texte gris très clair (pas de blanc pur — moins fatiguant)
   - Accent indigo conservé pour les éléments actifs uniquement
   - Bordures subtiles mais visibles */
[data-theme="dark"] {
    --color-primary:   #818CF8;
    --color-primary-h: #A5B4FC;
    --color-bg:        #0F1115;        /* presque noir, neutre légèrement chaud */
    --color-surface:   #181B22;        /* gris foncé — micro-élévation visible */
    --color-border:    #262A33;        /* gris moyen — discret mais perceptible */
    --color-text:      #E5E5E7;        /* gris très clair (pas blanc pur) */
    --color-muted:     #9CA3AF;
    --color-success:   #34D399;
    --color-danger:    #F87171;
    --color-warning:   #FBBF24;
    --color-primary-light:   #1E1B4B;
    --color-primary-lighter: #2E1F60;
    --color-success-light:   #064E3B;
    --color-danger-light:    #4C1D1D;
    --color-warning-light:   #451A03;
    /* Ombres très opaques sur fond gris quasi-noir */
    --shadow-sm:       0 1px 2px rgba(0, 0, 0, .45);
    --shadow:          0 2px 4px rgba(0, 0, 0, .45);
    --shadow-md:       0 6px 18px rgba(0, 0, 0, .50), 0 1px 3px rgba(0, 0, 0, .35);
    --shadow-lg:       0 16px 36px rgba(0, 0, 0, .60), 0 2px 6px rgba(0, 0, 0, .40);
    --shadow-xl:       0 32px 64px rgba(0, 0, 0, .70);
    --shadow-focus:    0 0 0 3px rgba(129, 140, 248, .25);
}
/* Hovers nav en gris (au lieu de bleuté) */
[data-theme="dark"] .nav-item:hover {
    background: #22262F;
    color: var(--color-text);
}
[data-theme="dark"] .nav-item--active {
    background: rgba(129, 140, 248, .14);
    color: #C7D2FE;
}
/* Form input en gris quasi-noir
   IMPORTANT : on utilise `background-color` (et NON le shorthand `background:`)
   pour ne pas écraser le `background-image` + `background-repeat` du select custom. */
[data-theme="dark"] .form-input {
    background-color: #13161C;
    color: var(--color-text);
}
[data-theme="dark"] .form-input:hover:not(:focus):not(:disabled) {
    border-color: rgba(129, 140, 248, .45);
}
[data-theme="dark"] .form-input:disabled {
    background: #0C0E12;
}
/* Note : pas de règle dark spécifique sur .card car les var() sont déjà context-aware
   (background et border utilisent var(--color-surface) et var(--color-border) qui suivent
   automatiquement le mode). Mettre une règle dark ici écraserait par cascade les bordures
   latérales colorées des cartes spécifiques (.dash-card--urgent, .dash-card--quotes…). */
[data-theme="dark"] .card--inner {
    background: #13161C;
}
[data-theme="dark"] .btn--ghost:hover:not(:disabled) {
    background: #22262F;
    border-color: #3A3F4B;
}
/* Topbar en sombre — frosted glass gris (au lieu de bleuté) */
[data-theme="dark"] .topbar {
    background: rgba(24, 27, 34, .82);
    border-bottom-color: var(--color-border);
}

/* Toast dark overrides */
[data-theme="dark"] .toast {
    background: var(--color-surface);
    border-color: var(--color-border);
}
[data-theme="dark"] .toast--success .toast__icon { background: rgba(52, 211, 153, .15); }
[data-theme="dark"] .toast--error   .toast__icon { background: rgba(248, 113, 113, .15); }
[data-theme="dark"] .toast--warning .toast__icon { background: rgba(251, 191, 36, .15); }
[data-theme="dark"] .toast--info    .toast__icon { background: rgba(96, 165, 250, .15); }
[data-theme="dark"] .toast__msg { color: var(--color-text); }

/* Selects dark — fond des options */
[data-theme="dark"] select.form-input option {
    background: var(--color-surface);
    color: var(--color-text);
}

/* Modal dark — utilise la nouvelle palette */
[data-theme="dark"] .modal { background: var(--color-surface); }

/* Badges dark — couleurs alignées sur la nouvelle palette */
[data-theme="dark"] .badge--red    { background: rgba(248, 113, 113, .15); color: #FCA5A5; }
[data-theme="dark"] .badge--amber  { background: rgba(251, 191, 36, .15); color: #FDE68A; }
[data-theme="dark"] .badge--green  { background: rgba(52, 211, 153, .15); color: #6EE7B7; }
[data-theme="dark"] .badge--blue   { background: rgba(96, 165, 250, .15); color: #93C5FD; }
[data-theme="dark"] .badge--gray   { background: rgba(156, 163, 175, .15); color: #D1D5DB; }

/* Résidence active dans la sidebar */
.sidebar__residence {
    display: flex; align-items: center; justify-content: space-between;
    padding: .5rem 1rem;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    font-size: 12px;
}
.sidebar__residence-name {
    font-weight: 600; color: var(--color-primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.sidebar__residence-switch {
    flex-shrink: 0; margin-left: 6px;
    color: var(--color-muted); font-size: 14px;
    text-decoration: none; border-radius: 4px; padding: 1px 4px;
    transition: .15s;
}
.sidebar__residence-switch:hover { background: var(--color-border); color: var(--color-text); }

/* Résidences grid (admin) */
.residences-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px,1fr)); gap: 1rem; }
.residence-card {
    display: flex; align-items: center; gap: 14px;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius); padding: 1.25rem 1rem;
    text-decoration: none; color: var(--color-text); transition: .15s;
}
.residence-card:hover { border-color: var(--color-primary); box-shadow: var(--shadow); text-decoration: none; }
.residence-card__icon { font-size: 28px; flex-shrink: 0; }
.residence-card__body { flex: 1; min-width: 0; }
.residence-card__name { font-weight: 700; font-size: 15px; margin-bottom: 3px; }
.residence-card__addr { font-size: 12px; color: var(--color-muted); margin-bottom: 6px;
                        overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.residence-card__stats { display: flex; gap: 10px; font-size: 12px; color: var(--color-muted); }
.residence-card__arrow { font-size: 18px; color: var(--color-muted); }

/* Theme toggle button */
.sidebar__bottom-row { display: flex; align-items: center; justify-content: space-between; }
.theme-toggle {
    background: none; border: 1px solid var(--color-border); border-radius: 20px;
    padding: 3px 8px; cursor: pointer; font-size: 14px; line-height: 1;
    color: var(--color-muted); transition: .15s;
}
.theme-toggle:hover { background: var(--color-bg); color: var(--color-text); }

/* ─── Cards ─── */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}
/* Variante interactive : appliquer .card--interactive sur les cards cliquables
   pour un effet de levée au survol. */
.card--interactive { cursor: pointer; }
.card--interactive:hover {
    border-color: rgba(79, 70, 229, .22);
    box-shadow: var(--shadow-md);
}
[data-theme="dark"] .card--interactive:hover {
    border-color: rgba(129, 140, 248, .35);
}
/* Sous-card (card dans card) — plus discrète */
.card--inner {
    border-radius: var(--radius-md);
    box-shadow: none;
    background: var(--color-bg);
}

/* ─── Admin tabs (super-admin) ─── */
.admin-tabs {
    display: flex; gap: 0; border-bottom: 2px solid var(--color-border);
    margin-bottom: 1.5rem;
}
.admin-tab {
    padding: .6rem 1.25rem; font-size: 14px; font-weight: 500;
    color: var(--color-muted); text-decoration: none;
    border-bottom: 2px solid transparent; margin-bottom: -2px;
    transition: color .15s, border-color .15s;
    display: flex; align-items: center; gap: 6px;
}
.admin-tab:hover { color: var(--color-text); }
.admin-tab--active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }
.admin-tab svg { width: 16px; height: 16px; }

/* ─── Badges ─── */
.badge { display: inline-flex; align-items: center; padding: .2rem .6rem;
         border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge--red    { background: #FEE2E2; color: #991B1B; }
.badge--amber  { background: #FEF3C7; color: #92400E; }
.badge--green  { background: #D1FAE5; color: #065F46; }
.badge--blue   { background: #DBEAFE; color: #1E40AF; }
.badge--gray   { background: #F3F4F6; color: #374151; }

/* ── Notification bell ──────────────────────────── */
.notif-wrap {
    position: relative;
}
.notif-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: none;
    color: var(--color-muted);
    cursor: pointer;
    transition: background .15s, color .15s;
    flex-shrink: 0;
}
.notif-bell:hover { background: var(--color-bg); color: var(--color-text); }
.notif-bell--active { color: var(--color-primary); }

/* ── Dropdown ── */
.notif-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 360px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.14);
    z-index: 600;
    overflow: hidden;
}
.notif-dropdown--open { display: block; }

.notif-dropdown__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--color-border);
}
.notif-dropdown__title {
    font-size: 13px;
    font-weight: 700;
}
.notif-dropdown__markread {
    font-size: 11px;
    color: var(--color-primary);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}
.notif-dropdown__markread:hover { text-decoration: underline; }

.notif-dropdown__list {
    max-height: 380px;
    overflow-y: auto;
}
.notif-dropdown__empty {
    padding: 1.5rem;
    text-align: center;
    font-size: 13px;
    color: var(--color-muted);
}

.notif-dropdown__item {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .625rem 1rem;
    text-decoration: none;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border);
    transition: background .12s;
}
.notif-dropdown__item:last-child { border-bottom: none; }
.notif-dropdown__item:hover { background: var(--color-bg); text-decoration: none; }
.notif-dropdown__item--unread { background: color-mix(in srgb, var(--color-primary) 6%, var(--color-surface)); }
.notif-dropdown__item--unread:hover { background: color-mix(in srgb, var(--color-primary) 11%, var(--color-surface)); }

/* Avatar (photo ou initiales) avec pastille d'icône de type en coin */
.notif-dropdown__avatar {
    position: relative;
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
}
.notif-dropdown__avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}
.notif-dropdown__icon {
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-surface);
    box-shadow: 0 0 0 1.5px var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    line-height: 1;
}
.notif-dropdown__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.notif-dropdown__text {
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
}
.notif-dropdown__item--unread .notif-dropdown__text { font-weight: 500; }
.notif-dropdown__time {
    font-size: 11px;
    color: var(--color-muted);
}
.notif-dropdown__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-primary);
    flex-shrink: 0;
}

.notif-dropdown__footer {
    display: block;
    text-align: center;
    padding: .625rem 1rem;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-primary);
    text-decoration: none;
    border-top: 1px solid var(--color-border);
    transition: background .12s;
}
.notif-dropdown__footer:hover { background: var(--color-bg); text-decoration: none; }

@media (max-width: 480px) {
    .notif-dropdown {
        position: fixed;
        top: 56px;
        right: 0;
        left: 0;
        width: 100%;
        border-radius: 0 0 12px 12px;
    }
}

.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--color-danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 99px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border: 2px solid var(--color-surface);
}

/* ── Page Notifications ─────────────────────────── */
.notif-page { max-width: 640px; }
.notif-page__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.notif-tabs {
    display: inline-flex;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
}
.notif-tab {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-muted);
    padding: 6px 14px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background .15s, color .15s;
}
.notif-tab:hover { color: var(--color-text); }
.notif-tab--active {
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.notif-tab__count {
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    padding: 0 5px;
}
.notif-page__markall {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-primary);
    padding: 6px 4px;
}
.notif-page__markall:hover { text-decoration: underline; }

.notif-page__empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-muted);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
}
.notif-page__empty-icon { font-size: 2.5rem; margin-bottom: .5rem; }

.notif-page__list {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    overflow: hidden;
}
.notif-row {
    position: relative;
    display: flex;
    border-bottom: 1px solid var(--color-border);
    transition: background .12s;
}
.notif-row:last-child { border-bottom: none; }
.notif-row:hover { background: var(--color-bg); }
.notif-row--unread { background: color-mix(in srgb, var(--color-primary) 6%, var(--color-surface)); }
.notif-row--unread:hover { background: color-mix(in srgb, var(--color-primary) 11%, var(--color-surface)); }
.notif-row__link {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    text-decoration: none;
    color: var(--color-text);
}
.notif-row__link:hover { text-decoration: none; }
.notif-row__avatar {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
}
.notif-row__avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.notif-row__icon {
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-surface);
    box-shadow: 0 0 0 1.5px var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
}
.notif-row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.notif-row__text { font-size: 14px; line-height: 1.4; }
.notif-row--unread .notif-row__text { font-weight: 500; }
.notif-row__muted { color: var(--color-muted); font-weight: 400; }
.notif-row__preview {
    font-size: 12.5px;
    color: var(--color-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.notif-row__time { font-size: 11.5px; color: var(--color-muted); }
.notif-row__dot {
    align-self: center;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--color-primary);
    flex-shrink: 0;
    margin-right: 14px;
}
.notif-row__dismiss {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--color-muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    opacity: 0;
    transition: opacity .15s, background .15s;
    z-index: 2;
}
.notif-row:hover .notif-row__dismiss { opacity: 1; }
.notif-row__dismiss:hover { background: var(--color-hover); color: var(--color-text); }

/* ════════════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile & Tablet
   ════════════════════════════════════════════════════════════════════ */

/* ── Topbar actions & badge wrapper ── */
.topbar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.topbar__badge {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Menu déroulant ⋯ "Plus d'actions" (global) ──
   Mutualisé : utilisé par le détail kanban (markup manuel) ET par le repli
   automatique des actions topbar (.topbar-actions-extra, voir app.js).
   Déplacé ici depuis kanban.css pour être disponible sur toutes les pages. */
.page-dropdown { position: relative; display: inline-block; }
.page-dropdown__trigger { display: flex; align-items: center; justify-content: center; padding: 7px 10px; }
.page-dropdown__menu {
    position: absolute; right: 0; top: calc(100% + 4px);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px; min-width: 210px; z-index: 300;
    box-shadow: 0 8px 24px rgba(0,0,0,.14);
    padding: 4px;
    display: none;
}
.page-dropdown__menu--open { display: block; }
.page-dropdown__item {
    display: flex; align-items: center; gap: 8px;
    padding: .5rem .75rem; border-radius: 6px;
    font-size: 13px; cursor: pointer; color: var(--color-text);
    background: none; border: none; width: 100%; text-align: left;
    transition: background .1s; font-family: inherit;
}
.page-dropdown__item:hover { background: var(--color-bg); }
.page-dropdown__item--danger { color: var(--color-danger); }
.page-dropdown__divider { height: 1px; background: var(--color-border); margin: 4px 0; }
[data-theme="dark"] .page-dropdown__menu { background: #1F2937; }
[data-theme="dark"] .page-dropdown__item:hover { background: #374151; }

/* ── Repli automatique des actions secondaires de la topbar ──
   Convention partagée : on enveloppe les actions secondaires d'une page dans
   <div class="topbar-actions-extra">. Sur desktop ET tablette elles s'affichent
   en ligne (display:contents → elles deviennent des items flex de .topbar__actions,
   donc espacées par son gap). Uniquement sur téléphone (≈640px, cf. COLLAPSE_BELOW
   dans app.js), app.js les déplace dans un menu ⋯ généré (.page-dropdown.topbar-overflow).
   L'action primaire reste visible. Filet de secours sur tablette : .topbar wrappe. */
.topbar-actions-extra { display: contents; }
/* .btn rapatriés dans le menu ⋯ : rendus comme des lignes de menu pleine largeur. */
.topbar-overflow .page-dropdown__menu .btn {
    display: flex;
    width: 100%;
    justify-content: flex-start;
    border: none;
    border-radius: 6px;
    margin: 0;
    padding: .5rem .75rem;
    font-size: 13px;
    background: none;
    box-shadow: none;
    min-height: 0;
}
.topbar-overflow .page-dropdown__menu .btn:hover { background: var(--color-bg); }
.topbar-overflow .page-dropdown__menu .btn--primary { color: var(--color-primary); }

/* ── Sidebar toggle (hamburger) — caché sur desktop ── */
.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: transparent;
    cursor: pointer;
    color: var(--color-muted);
    padding: 0;
    transition: background .15s, color .15s;
}
.sidebar-toggle:hover { background: var(--color-bg); color: var(--color-text); }
[data-theme="dark"] .sidebar-toggle:hover { background: #374151; }

/* ── Backdrop sidebar ── */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .48);
    z-index: 499;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: sb-backdrop-in .2s ease;
}
.sidebar-backdrop--open { display: block; }
@keyframes sb-backdrop-in { from { opacity: 0 } to { opacity: 1 } }

/* ════ Tablette & Mobile — point de rupture principal 1024 px ════
   Tablette portrait (768–1024) adopte la mise en page MOBILE (tiroir + 1 colonne).
   Voir docs/plans/responsive-mobile-tablet-plan.md (décision §2). */
@media (max-width: 1024px) {

    /* Sidebar — tiroir hors-canvas */
    .sidebar {
        position: fixed;
        top: 0; left: 0;
        height: 100%;
        height: 100dvh;
        z-index: 500;
        transform: translateX(-100%);
        transition: transform .28s cubic-bezier(.4, 0, .2, 1),
                    box-shadow .28s;
    }
    .sidebar--open {
        transform: translateX(0);
        box-shadow: 8px 0 40px rgba(0, 0, 0, .22);
    }

    /* Afficher le bouton hamburger */
    .sidebar-toggle { display: flex; }

    /* Barre supérieure */
    .topbar {
        padding: .75rem 1rem;
        position: sticky;
        top: 0;
        z-index: 100;
        gap: 8px;
        /* Filet de sécurité universel : si les actions sont trop larges pour
           tenir sur une ligne, elles passent en 2ᵉ ligne plutôt que d'être
           coupées hors écran (pages non converties au menu ⋯). */
        flex-wrap: wrap;
    }
    .topbar__title {
        flex: 1;
        min-width: 0;
        font-size: 16px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    /* Les actions peuvent wrapper en interne et rester alignées à droite. */
    .topbar__actions {
        flex-wrap: wrap;
        justify-content: flex-end;
        row-gap: 6px;
    }
    /* Masquer le badge (info d'accès) — trop verbeux sur mobile */
    .topbar__badge { display: none; }

    /* Contenu principal */
    .content { padding: 1rem; }

    /* Blocs de formulaire : empiler les paires sur mobile */
    .form-row { grid-template-columns: 1fr !important; }
}

/* ════ Petit smartphone — 480 px ════ */
@media (max-width: 480px) {

    .topbar { padding: .625rem .875rem; gap: 6px; }
    .topbar__title { font-size: 15px; }
    .content { padding: .875rem .75rem; }

    /* Les actions de la topbar peuvent s'empiler si besoin */
    .topbar__actions { gap: 4px; }

    /* Login card full-width */
    .login-card { padding: 1.75rem 1.25rem; }

    /* Petites grilles de résidences */
    .residences-grid { grid-template-columns: 1fr; }

    /* Les stat-cards du dashboard en 1 colonne sur très petits écrans */
    .dash-stats { grid-template-columns: 1fr 1fr; }
}

/* ════ Modaux ════ */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    /* z-index élevé pour passer au-dessus des contrôles Leaflet (z=1000) et autres libs JS */
    z-index: 9999;
    align-items: center; justify-content: center;
}
.modal-overlay--open { display: flex; }
.modal {
    background: var(--color-surface); border-radius: 12px;
    width: 100%; max-width: 520px;
    max-height: 90vh; max-height: 90dvh; /* dvh : footer non masqué par le chrome mobile */
    overflow-y: auto; padding: 1.5rem;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.modal__title  { font-size: 18px; font-weight: 600; }
.modal__close  { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--color-muted); line-height: 1; padding: 0; }
.modal__close:hover { color: var(--color-text); }
.modal__footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 1.25rem; }

/* ── Modaux — bottom-sheet sur mobile ── */
@media (max-width: 640px) {
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
    .modal {
        border-radius: 20px 20px 0 0 !important;
        max-width: 100% !important;
        width: 100%;
        max-height: 92vh; max-height: 92dvh;
        overflow-y: auto;
        animation: modal-slide-up .24s cubic-bezier(.4, 0, .2, 1);
    }
    @keyframes modal-slide-up {
        from { transform: translateY(40px); opacity: 0; }
        to   { transform: translateY(0);    opacity: 1; }
    }
    .modal__footer { flex-wrap: wrap; gap: 8px; padding-bottom: env(safe-area-inset-bottom, 0); }
    .modal__footer .btn { flex: 1; justify-content: center; }

    /* Profile layout : déjà géré à 768px dans annuaire.css */
    .profile-dl { grid-template-columns: 110px 1fr; }
}

/* ════ Hardening responsive — passes complémentaires ════
   Ces règles couvrent les patterns qu'on a vus casser au quotidien :
   - page-actions qui débordent (header avec beaucoup de boutons)
   - tableaux trop larges (vue liste kanban, listings) qui n'ont pas
     toujours un wrapper scrollable explicite
   - dropdowns avec width fixe sur très petit mobile
   - form-row paire qui ne s'empile pas toujours
   - touch targets trop petits (zone cliquable < 36px)
*/

/* ── Page actions du header : doit pouvoir wrapper ── */
.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

/* Helper class à mettre sur le wrapper d'un tableau "wide" pour le
   rendre scrollable horizontalement sur mobile sans casser le layout.
   À appliquer manuellement aux templates problématiques. */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Indique visuellement que c'est scrollable (ombre au bord droit) */
    background:
        linear-gradient(to right, var(--color-surface) 30%, rgba(255,255,255,0)),
        linear-gradient(to right, rgba(0,0,0,.06), rgba(255,255,255,0) 70%) 0 0/12px 100% no-repeat;
}

/* ════ Tablette / mobile (≤ 1024 px) — passes complémentaires ════
   Collapse des grilles de page en 1 colonne + scroll horizontal des tableaux
   larges : structurel, donc aligné sur le breakpoint principal 1024. */
@media (max-width: 1024px) {

    /* page-actions : chaque bouton prend la largeur naturelle, wrap proprement */
    .page-actions { gap: 6px; }
    .page-actions .btn { font-size: 13px; padding: 6px 10px; }

    /* Form rows déjà couvertes plus haut (1fr), mais on couvre toutes
       les grilles 2-col 1fr+220-340px qui pourraient rester */
    .reunion-layout,
    .feed-layout,
    .listing-page-layout,
    .annuaire-grid,
    .discussions-layout {
        grid-template-columns: 1fr !important;
    }

    /* Tableaux dans des cards : wrap auto-scroll horizontal si dépasse */
    .card > table,
    .listing-table-wrapper,
    .kanban-list-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Touch targets : tous les .btn ont au moins 36px de haut */
    .btn { min-height: 36px; }
}

/* ════ Petit smartphone (≤ 480 px) — passes complémentaires ════ */
@media (max-width: 480px) {

    /* Le titre de page peut wrap (2 lignes) si trop long sur petit écran */
    .topbar__title {
        white-space: normal;
        line-height: 1.25;
    }

    /* Page-actions : labels plus courts via espacement réduit */
    .page-actions { width: 100%; justify-content: flex-end; }

    /* Tabs Kanban / Quotes / autres : scroll horizontal au lieu de wrap */
    .quote-tabs,
    .kanban-view-toggle,
    .kanban-filter-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    .quote-tabs::-webkit-scrollbar,
    .kanban-filter-bar::-webkit-scrollbar { height: 4px; }

    /* Réduction des paddings dans les cards pour gagner de l'espace */
    .card { padding: .875rem; }

    /* Modaux : padding interne réduit */
    .modal { padding: 1rem; }
    .modal__title { font-size: 16px; }
}

/* ════ Très petit smartphone (≤ 360 px) — derniers fallbacks ════ */
@media (max-width: 360px) {

    /* Notif dropdown : déjà fullwidth depuis 480px (bon).
       On élargit juste le padding latéral pour ne pas avoir 8px partout */
    .notif-dropdown { top: 52px; }

    /* Logo sidebar : peut perdre son texte si trop étroit */
    .sidebar__logo-text { font-size: 14px; }

    /* Topbar : padding minimal */
    .topbar { padding: .5rem .625rem; }
    .topbar__title { font-size: 14px; }
}

/* Dark mode overrides responsive */
[data-theme="dark"] .sidebar-backdrop { background: rgba(0,0,0,.65); }

/* ─── Réactions partagées (chat + feed) : chips + popover "Qui a réagi" ─── */
.chat-reactions-summary,
.feed-reactions-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 6px;
}
.chat-rxn-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    cursor: pointer;
    font-size: 12px;
    color: var(--color-text);
    line-height: 1.5;
    transition: all .12s;
}
.chat-rxn-chip:hover {
    background: var(--color-surface);
    border-color: var(--color-primary);
    transform: translateY(-1px);
}
.chat-rxn-chip__emoji { font-size: 13px; }
.chat-rxn-chip__count { font-weight: 600; color: var(--color-muted); }

.chat-reactors-popover {
    position: fixed;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.16);
    min-width: 220px;
    max-width: 320px;
    max-height: 320px;
    overflow-y: auto;
    z-index: 1000;
    padding: 6px;
}
.chat-reactors-popover__head {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 8px 8px;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 4px;
    font-size: 12px;
    color: var(--color-muted);
}
.chat-reactors-popover__head .react-emoji { font-size: 16px; }
.chat-reactor-item {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 13px;
}
.chat-reactor-item:hover { background: var(--color-bg); }
.chat-reactor-item__avatar {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
    object-fit: cover;
}
.chat-reactor-item__name { flex: 1; }
.chat-reactor-item__name--me { color: var(--color-primary); font-weight: 500; }

/* ══════════════════════════════════════════════════════════════
   Recherche globale (topbar) — champ + dropdown de suggestions
   ══════════════════════════════════════════════════════════════ */
.gsearch { position: relative; flex-shrink: 1; min-width: 0; }
.gsearch__form {
    display: flex; align-items: center; gap: 7px;
    border: 1px solid var(--color-border);
    border-radius: 9px;
    padding: 5px 10px;
    background: var(--color-surface, #fff);
    color: var(--color-muted);
    width: 250px; max-width: 34vw;
    transition: border-color .15s, width .2s;
}
.gsearch__form:focus-within { border-color: var(--color-primary, #4F46E5); width: 320px; }
.gsearch__input {
    flex: 1; min-width: 0; border: none; outline: none; background: transparent;
    font-size: 13px; color: var(--color-text);
}
.gsearch__input::-webkit-search-cancel-button { -webkit-appearance: none; }
.gsearch__kbd {
    font: 10px/1.4 inherit; color: var(--color-muted);
    border: 1px solid var(--color-border); border-radius: 4px;
    padding: 0 5px; white-space: nowrap; user-select: none;
}
.gsearch__form:focus-within .gsearch__kbd { display: none; }
.gsearch__dropdown {
    position: absolute; top: calc(100% + 6px); right: 0;
    width: 420px; max-width: 88vw; max-height: 65vh; overflow-y: auto;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border); border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,.16);
    z-index: 50; padding: 6px;
}
.gsearch-dd__group {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .04em; color: var(--color-muted);
    padding: 8px 10px 4px;
}
.gsearch-dd__item {
    display: flex; gap: 9px; align-items: flex-start;
    padding: 7px 10px; border-radius: 8px;
    text-decoration: none; color: inherit;
}
.gsearch-dd__item:hover, .gsearch-dd__item--active { background: var(--color-hover); }
.gsearch-dd__kind { flex-shrink: 0; width: 16px; text-align: center; color: var(--color-muted); font-size: 12px; }
.gsearch-dd__body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.gsearch-dd__title {
    font-size: 13px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gsearch-dd__meta {
    font-size: 11px; color: var(--color-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gsearch-dd__all {
    justify-content: center; font-size: 12.5px; font-weight: 600;
    color: var(--color-primary, #4F46E5);
    border-top: 1px solid var(--color-border); border-radius: 0 0 8px 8px;
    margin-top: 4px; padding-top: 9px;
}
.gsearch-dd__empty { padding: 16px; text-align: center; font-size: 12.5px; color: var(--color-muted); }
@media (max-width: 720px) {
    .gsearch__kbd { display: none; }
    .gsearch__form { width: 40px; padding: 5px 8px; }
    .gsearch__form:focus-within { width: 60vw; }
    .gsearch__input { opacity: 0; }
    .gsearch__form:focus-within .gsearch__input { opacity: 1; }
}
