/* =========================================================================
   MailBox — styles globaux.
   Public de plus de 60 ans : texte de base 18 px, zones tactiles ≥ 48 px,
   contraste AA (couleurs Fluent neutres + accent #0F6CBD).
   ========================================================================= */

/* Taille du texte (Paramètres → Affichage) : une seule variable globale, réglée sur <html>. */
:root { --text-scale: 1; }
:root[data-text-size="Large"] { --text-scale: 1.2; }
:root[data-text-size="ExtraLarge"] { --text-scale: 1.4; }

/* Jetons Fluent surchargés : ils s'héritent dans le shadow DOM des composants. */
body {
    --base-height-multiplier: calc(12 * var(--text-scale)); /* hauteur des contrôles : 12 × 4 px = 48 px au minimum */
    --design-unit: 4;
    --control-corner-radius: 6;
    --body-font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --type-ramp-minus-2-font-size: calc(15px * var(--text-scale));
    --type-ramp-minus-2-line-height: calc(20px * var(--text-scale));
    --type-ramp-minus-1-font-size: calc(16px * var(--text-scale));
    --type-ramp-minus-1-line-height: calc(22px * var(--text-scale));
    --type-ramp-base-font-size: calc(18px * var(--text-scale));
    --type-ramp-base-line-height: calc(26px * var(--text-scale));
    --type-ramp-plus-1-font-size: calc(20px * var(--text-scale));
    --type-ramp-plus-1-line-height: calc(28px * var(--text-scale));
    --type-ramp-plus-2-font-size: calc(22px * var(--text-scale));
    --type-ramp-plus-2-line-height: calc(30px * var(--text-scale));
    --type-ramp-plus-3-font-size: calc(26px * var(--text-scale));
    --type-ramp-plus-3-line-height: calc(34px * var(--text-scale));
    --type-ramp-plus-4-font-size: calc(30px * var(--text-scale));
    --type-ramp-plus-4-line-height: calc(40px * var(--text-scale));

    --touch-target: calc(48px * var(--text-scale));
    --gutter: 16px;
    --pane-folders-width: calc(300px * var(--text-scale));
    --pane-list-width: 440px;
    --appbar-height: 64px;
    --bottomnav-height: 68px;

    --mb-surface: var(--neutral-layer-1);
    --mb-surface-alt: var(--neutral-layer-2);
    --mb-text: var(--neutral-foreground-rest);
    /* Texte secondaire : 75 % du texte principal sur le fond, soit ≥ 6:1 en clair comme en sombre (AA). */
    --mb-text-muted: color-mix(in srgb, var(--neutral-foreground-rest) 75%, var(--neutral-layer-1));
    --mb-border: var(--neutral-stroke-rest);
    --mb-selected: var(--neutral-fill-stealth-active);
    --mb-hover: var(--neutral-fill-stealth-hover);
    --mb-danger: #B10E1C;
    --mb-success: #0E700E;

    margin: 0;
    font-family: var(--body-font);
    font-size: var(--type-ramp-base-font-size);
    line-height: var(--type-ramp-base-line-height);
    background: var(--mb-surface);
    color: var(--mb-text);
}

body[data-theme$="dark"] { --mb-danger: #FF9A9F; --mb-success: #7BD17B; }

h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: var(--type-ramp-plus-3-font-size); line-height: var(--type-ramp-plus-3-line-height); }
h2 { font-size: var(--type-ramp-plus-2-font-size); line-height: var(--type-ramp-plus-2-line-height); }
h3 { font-size: var(--type-ramp-plus-1-font-size); line-height: var(--type-ramp-plus-1-line-height); }
h1:focus { outline: none; }
p { margin: 0 0 12px; }
a { color: var(--accent-foreground-rest); }

:focus-visible { outline: 3px solid var(--accent-fill-rest); outline-offset: 2px; }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.muted { color: var(--mb-text-muted); }
.danger-text { color: var(--mb-danger); }
.success-text { color: var(--mb-success); }

/* ---------- Écran de chargement initial ---------- */
.app-loading { display: grid; place-items: center; min-height: 100vh; text-align: center; }
.loading-progress { position: relative; display: block; width: 8rem; height: 8rem; margin: 0 auto 1rem; }
.loading-progress circle { fill: none; stroke: #e0e0e0; stroke-width: 0.6rem; transform-origin: 50% 50%; transform: rotate(-90deg); }
.loading-progress circle:last-child {
    stroke: #0F6CBD;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

/* ---------- Shell ---------- */
.shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

.appbar {
    flex: 0 0 var(--appbar-height);
    display: flex; align-items: center; gap: 8px;
    padding: 0 var(--gutter);
    background: var(--mb-surface-alt);
    border-bottom: 1px solid var(--mb-border);
}
.appbar .brand { display: flex; align-items: center; gap: 10px; font-size: var(--type-ramp-plus-1-font-size); font-weight: 700; margin-right: 16px; text-decoration: none; color: inherit; }
.appbar .brand img { width: 36px; height: 36px; border-radius: 8px; }
.appbar nav { display: flex; gap: 4px; }
.appbar .spacer { flex: 1; }

.nav-link {
    display: inline-flex; align-items: center; gap: 8px;
    min-height: var(--touch-target); padding: 0 14px;
    border-radius: 8px; text-decoration: none; color: var(--mb-text);
}
.nav-link > span { white-space: nowrap; }
.nav-link:hover { background: var(--mb-hover); }
.nav-link.active { background: var(--mb-selected); font-weight: 600; box-shadow: inset 0 -3px 0 var(--accent-fill-rest); }

.shell-body { flex: 1; min-height: 0; display: flex; }
.shell-body > .page { flex: 1; min-width: 0; overflow: auto; }

.bottomnav {
    flex: 0 0 var(--bottomnav-height);
    display: flex; border-top: 1px solid var(--mb-border); background: var(--mb-surface-alt);
    padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav .nav-link { flex: 1; flex-direction: column; justify-content: center; gap: 2px; font-size: var(--type-ramp-minus-1-font-size); border-radius: 0; }
.bottomnav .nav-link.active { box-shadow: inset 0 3px 0 var(--accent-fill-rest); }

/* ---------- Volets ---------- */
.panes { display: flex; height: 100%; min-height: 0; }
.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--mb-surface); }
.pane + .pane { border-left: 1px solid var(--mb-border); }
.pane-folders { flex: 0 0 var(--pane-folders-width); background: var(--mb-surface-alt); }
.pane-list { flex: 0 0 var(--pane-list-width); }
.pane-reader { flex: 1; }
.layout-tablet .pane-list { flex-basis: 45%; max-width: 480px; }
.layout-mobile .pane { flex: 1; }

.pane-header {
    display: flex; align-items: center; gap: 8px;
    min-height: 64px; padding: 8px var(--gutter);
    border-bottom: 1px solid var(--mb-border);
}
.pane-header h1, .pane-header h2 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--type-ramp-plus-2-font-size); }
.pane-content { flex: 1; min-height: 0; overflow-y: auto; }
.pane-empty { display: grid; place-items: center; height: 100%; padding: 32px; text-align: center; color: var(--mb-text-muted); }

/* Tiroir des dossiers (tablette) */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; }
.drawer {
    position: fixed; top: 0; bottom: 0; left: 0; width: min(360px, 85vw); z-index: 21;
    display: flex; flex-direction: column; background: var(--mb-surface-alt); box-shadow: 4px 0 24px rgba(0,0,0,.25);
}

/* ---------- Dossiers ---------- */
.folder-section { padding: 8px 8px 16px; }
/* Blocs du volet des dossiers : un cadre par adresse, bien séparé des autres. */
.folder-block {
    margin: 10px 8px; padding: 4px 6px 8px; border: 1px solid var(--mb-border); border-radius: 12px;
    background: var(--mb-surface);
}
.mailbox-block, .card.mailbox-block {
    border: 2px solid color-mix(in srgb, var(--mb-color) 45%, var(--mb-border));
    border-left: 8px solid var(--mb-color);
    background: color-mix(in srgb, var(--mb-color) 5%, var(--mb-surface));
}
.folder-block-title { display: flex; align-items: center; gap: 10px; padding: 8px 6px 8px; font-weight: 700; }
.mailbox-block .folder-item.active { box-shadow: inset 4px 0 0 var(--mb-color); }
.folder-section-title { display: flex; align-items: center; gap: 10px; padding: 12px 12px 6px; font-weight: 700; }
.folder-item {
    display: flex; align-items: center; gap: 12px; width: 100%;
    min-height: var(--touch-target); padding: 0 12px; border: 0; border-radius: 8px;
    background: transparent; color: inherit; font: inherit; text-align: left; text-decoration: none; cursor: pointer;
}
.folder-item:hover { background: var(--mb-hover); }
.folder-item.active { background: var(--mb-selected); font-weight: 600; box-shadow: inset 4px 0 0 var(--accent-fill-rest); }
.folder-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-item .count { font-weight: 700; color: var(--accent-foreground-rest); }

/* ---------- Pastille d'adresse ---------- */
/* Pill d'adresse : fond teinté de la couleur, bord plein, texte normal (contraste AA dans les deux thèmes). */
.mailbox-pill {
    display: inline-flex; align-items: center; flex: 0 0 auto; max-width: 100%;
    padding: 1px calc(10px * var(--text-scale)); border: 2px solid var(--mb-color); border-radius: 999px;
    background: color-mix(in srgb, var(--mb-color) 16%, var(--mb-surface)); color: var(--mb-text);
    font-size: var(--type-ramp-minus-1-font-size); line-height: var(--type-ramp-minus-1-line-height); font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mailbox-pill.lg { padding: 3px calc(14px * var(--text-scale)); font-size: var(--type-ramp-base-font-size); line-height: var(--type-ramp-base-line-height); }
/* Petite pill de couleur seule (listes serrées, choix de couleur). */
.mailbox-swatch {
    display: inline-block; flex: 0 0 auto; width: calc(24px * var(--text-scale)); height: calc(12px * var(--text-scale));
    border-radius: 999px; background: var(--mb-color); box-shadow: 0 0 0 1px rgba(0,0,0,.25);
}
.mailbox-swatch.lg { width: calc(36px * var(--text-scale)); height: calc(18px * var(--text-scale)); }
.mailbox-tag { display: inline-flex; align-items: center; gap: 6px; font-size: var(--type-ramp-minus-1-font-size); color: var(--mb-text-muted); white-space: nowrap; }

/* ---------- Liste des messages ---------- */
.message-row {
    display: grid; grid-template-columns: 1fr auto; gap: 2px 12px;
    width: 100%; padding: 14px var(--gutter); border: 0; border-bottom: 1px solid var(--mb-border);
    background: transparent; color: inherit; font: inherit; text-align: left; text-decoration: none; cursor: pointer;
}
.message-row:hover { background: var(--mb-hover); }
.message-row.active { background: var(--mb-selected); box-shadow: inset 4px 0 0 var(--accent-fill-rest); }
.message-row .from { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-row .date { color: var(--mb-text-muted); font-size: var(--type-ramp-minus-1-font-size); white-space: nowrap; }
.message-row .subject { grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-row .preview { grid-column: 1 / -1; color: var(--mb-text-muted); font-size: var(--type-ramp-minus-1-font-size); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-row .meta { grid-column: 1 / -1; display: flex; gap: 12px; align-items: center; }
.message-row.unread .from, .message-row.unread .subject { font-weight: 700; }
.message-row.unread .from::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%; background: var(--accent-fill-rest); vertical-align: middle; }

.list-status { display: flex; align-items: center; gap: 12px; padding: 10px var(--gutter); color: var(--mb-text-muted); font-size: var(--type-ramp-minus-1-font-size); }
.list-footer { display: flex; justify-content: center; padding: 16px; }
/* Les bandeaux Fluent utilisent une petite police : on revient à une taille lisible. */
.fluent-messagebar, .fluent-messagebar .fluent-messagebar-message { font-size: var(--type-ramp-minus-1-font-size) !important; line-height: var(--type-ramp-minus-1-line-height) !important; }
.banner-stack { display: flex; flex-direction: column; gap: 8px; padding: 8px var(--gutter) 0; }

.fab { position: fixed; right: 20px; bottom: calc(var(--bottomnav-height) + 20px + env(safe-area-inset-bottom)); z-index: 10; }
.fab fluent-button { box-shadow: 0 6px 18px rgba(0,0,0,.3); border-radius: 28px; }

/* ---------- Lecture ---------- */
.reader { padding: var(--gutter); max-width: 960px; }
.reader h2 { font-size: var(--type-ramp-plus-3-font-size); line-height: var(--type-ramp-plus-3-line-height); margin-bottom: 12px; overflow-wrap: anywhere; }
.reader-meta { display: grid; gap: 4px; margin-bottom: 16px; }
.reader-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 16px; }
.reader-body { border: 1px solid var(--mb-border); border-radius: 8px; overflow: hidden; background: #fff; }
.reader-body iframe { display: block; width: 100%; min-height: 200px; border: 0; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.attachment { display: inline-flex; align-items: center; gap: 8px; min-height: var(--touch-target); padding: 0 14px; border: 1px solid var(--mb-border); border-radius: 8px; }

/* ---------- Formulaires et pages simples ---------- */
.page-narrow { max-width: 760px; margin: 0 auto; padding: 24px var(--gutter) 48px; }
.page-narrow > h1 { margin-bottom: 20px; }
.form-stack { display: flex; flex-direction: column; gap: 20px; }
.form-stack fluent-text-field, .form-stack fluent-text-area, .form-stack fluent-select, .form-stack fluent-combobox { width: 100%; }
.form-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.help { font-size: var(--type-ramp-minus-1-font-size); color: var(--mb-text-muted); margin: 4px 0 0; }

.card {
    padding: 20px; border: 1px solid var(--mb-border); border-radius: 12px; background: var(--mb-surface);
}
.card + .card { margin-top: 16px; }
.card-title { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.card-title h2 { flex: 1; font-size: var(--type-ramp-plus-1-font-size); }
.card > h2 { margin-bottom: 12px; }

.steps { display: flex; gap: 6px; margin-bottom: 8px; }
.steps span { flex: 1; height: 6px; border-radius: 3px; background: var(--mb-border); }
.steps span.done { background: var(--accent-fill-rest); }

.color-choices { display: flex; flex-wrap: wrap; gap: 12px; }
.color-choice {
    width: calc(var(--touch-target) * 1.6); height: var(--touch-target); border-radius: 999px; cursor: pointer;
    border: 3px solid transparent; box-shadow: 0 0 0 1px rgba(0,0,0,.25);
}
.color-choice[aria-checked="true"] { border-color: var(--mb-surface); box-shadow: 0 0 0 3px var(--mb-text); }

.role-grid { display: grid; grid-template-columns: minmax(140px, auto) 1fr; gap: 12px 16px; align-items: center; }

/* ---------- Contacts ---------- */
.letter { position: sticky; top: 0; z-index: 1; padding: 6px var(--gutter); font-weight: 700; background: var(--mb-surface-alt); border-bottom: 1px solid var(--mb-border); }
.contact-row {
    display: flex; align-items: center; gap: 12px; width: 100%;
    min-height: 64px; padding: 8px var(--gutter); border: 0; border-bottom: 1px solid var(--mb-border);
    background: transparent; color: inherit; font: inherit; text-align: left; text-decoration: none; cursor: pointer;
}
.contact-row:hover { background: var(--mb-hover); }
.contact-row.active { background: var(--mb-selected); box-shadow: inset 4px 0 0 var(--accent-fill-rest); }
.contact-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
    display: grid; place-items: center; flex: 0 0 auto; width: calc(44px * var(--text-scale)); height: calc(44px * var(--text-scale)); border-radius: 50%;
    background: var(--accent-fill-rest); color: var(--foreground-on-accent-rest); font-weight: 700;
}
.avatar.lg { width: 72px; height: 72px; font-size: 30px; }
.contact-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 0; border-bottom: 1px solid var(--mb-border); }
.contact-line .value { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Éditeur ---------- */
.suggestions { display: flex; flex-direction: column; border: 1px solid var(--mb-border); border-radius: 8px; margin-top: 4px; overflow: hidden; }
.suggestion { display: flex; gap: 8px; align-items: center; min-height: var(--touch-target); padding: 4px 12px; border: 0; background: var(--mb-surface); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.suggestion + .suggestion { border-top: 1px solid var(--mb-border); }
.suggestion:hover, .suggestion:focus-visible { background: var(--mb-hover); }

/* ---------- Tablette ---------- */
@media (max-width: 1200px) {
    .appbar .theme-label { display: none; }
}

/* ---------- Mobile ---------- */
@media (max-width: 599.98px) {
    .layout-mobile .pane-list .pane-content { padding-bottom: 96px; }
    body { --gutter: 14px; --appbar-height: 56px; }
    .page-narrow { padding-top: 16px; }
    .reader h2 { font-size: var(--type-ramp-plus-2-font-size); }
    .role-grid { grid-template-columns: 1fr; gap: 4px; }
}

/* ---------- Erreur Blazor ---------- */
#blazor-error-ui {
    color-scheme: light only; background: #fff4ce; color: #1a1a1a;
    bottom: 0; left: 0; width: 100%; box-sizing: border-box; display: none; position: fixed; z-index: 1000;
    padding: 12px 56px 12px 16px; box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
}
#blazor-error-ui .dismiss { position: absolute; right: 8px; top: 4px; width: 44px; height: 44px; border: 0; background: none; font-size: 20px; cursor: pointer; }

/* ---------- Connexion ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 24px var(--gutter); box-sizing: border-box; background: var(--mb-surface-alt); }
.login-card { width: 100%; max-width: 480px; box-sizing: border-box; padding: 32px; }
.login-card h1 { margin-bottom: 8px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; font-size: var(--type-ramp-plus-2-font-size); font-weight: 700; }
.login-brand img { width: 48px; height: 48px; border-radius: 10px; }
.login-help { margin-top: 16px; }
@media (max-width: 599.98px) { .login-card { padding: 20px; border: 0; background: transparent; } }

/* ---------- Impersonation : bandeau permanent ---------- */
.impersonation-banner {
    flex: 0 0 auto; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px;
    padding: 8px var(--gutter); background: #A4262C; color: #fff; font-weight: 600;
}
.impersonation-banner span { flex: 1 1 240px; }
.impersonation-quit {
    min-height: var(--touch-target); padding: 0 20px; border: 2px solid #fff; border-radius: 8px;
    background: #fff; color: #A4262C; font: inherit; font-weight: 700; cursor: pointer;
}
.impersonation-quit:hover { background: #fde7e9; }

/* ---------- Paramètres : tuiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, calc(320px * var(--text-scale))), 1fr)); gap: 16px; margin-top: 20px; }
.tile {
    display: flex; align-items: center; gap: 20px; min-height: calc(112px * var(--text-scale)); padding: 20px;
    border: 1px solid var(--mb-border); border-radius: 16px; background: var(--mb-surface);
    color: inherit; text-decoration: none; box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.tile:hover { background: var(--mb-hover); border-color: var(--accent-fill-rest); }
.tile-text { display: flex; flex-direction: column; gap: 4px; }
.tile-title { font-size: var(--type-ramp-plus-1-font-size); line-height: var(--type-ramp-plus-1-line-height); font-weight: 700; }
.tile-desc { color: var(--mb-text-muted); font-size: var(--type-ramp-minus-1-font-size); }
.tile.advanced { box-shadow: none; border-style: dashed; }

.choice-list { display: flex; flex-direction: column; gap: 10px; }
.choice {
    display: flex; align-items: center; gap: 16px; min-height: var(--touch-target); padding: 12px 16px;
    border: 2px solid var(--mb-border); border-radius: 12px; background: var(--mb-surface); color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.choice[aria-checked="true"] { border-color: var(--accent-fill-rest); background: var(--mb-selected); font-weight: 600; }
.choice .sample { font-weight: 700; width: 3em; text-align: center; }
.section-title { margin: 28px 0 12px; }
.strength { height: 8px; border-radius: 4px; background: var(--mb-border); overflow: hidden; margin-top: 8px; }
.strength > span { display: block; height: 100%; transition: width .2s; }
.codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(10em, 1fr)); gap: 8px; font-family: Consolas, "Courier New", monospace; font-size: var(--type-ramp-plus-1-font-size); }

/* ---------- Super admin (pensé d'abord pour la workstation) ---------- */
.admin { display: flex; flex-direction: column; min-height: 100%; }
.admin-nav { display: flex; gap: 4px; padding: 8px var(--gutter); overflow-x: auto; border-bottom: 1px solid var(--mb-border); background: var(--mb-surface-alt); }
.admin-wide { flex-direction: row; }
.admin-wide .admin-nav { flex: 0 0 calc(250px * var(--text-scale)); flex-direction: column; border-bottom: 0; border-right: 1px solid var(--mb-border); padding: 16px 8px; overflow: visible; }
.admin-content { flex: 1; min-width: 0; padding: 20px var(--gutter) 48px; }
.admin-content > h1 { margin-bottom: 16px; }
.admin-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 16px; margin-bottom: 16px; }
.admin-table-wrap { overflow-x: auto; border: 1px solid var(--mb-border); border-radius: 8px; }
/* Les lignes du FluentDataGrid ont une hauteur fixe (32 px) en style inline : on les laisse grandir avec le texte et les boutons. */
.admin-table-wrap td, .admin-table-wrap th { height: auto !important; min-height: calc(48px * var(--text-scale)); padding-top: 6px !important; padding-bottom: 6px !important; white-space: normal !important; overflow-wrap: break-word; align-content: center; }
.admin-toolbar > div { display: flex; flex-direction: column; gap: 4px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { padding: 16px; border: 1px solid var(--mb-border); border-radius: 12px; background: var(--mb-surface); color: inherit; text-decoration: none; }
.stat .value { display: block; font-size: var(--type-ramp-plus-4-font-size); line-height: var(--type-ramp-plus-4-line-height); font-weight: 700; }
.stat .label { color: var(--mb-text-muted); }
a.stat:hover { background: var(--mb-hover); }
.status-ok { color: var(--mb-success); font-weight: 600; }
.status-bad { color: var(--mb-danger); font-weight: 600; }
.status-warn { color: #8A5A00; font-weight: 600; }
body[data-theme$="dark"] .status-warn { color: #F2C661; }
.kv { display: grid; grid-template-columns: minmax(12em, auto) 1fr; gap: 8px 16px; }
.kv dt { color: var(--mb-text-muted); }
.kv dd { margin: 0; font-weight: 600; }
.qr { width: 220px; height: 220px; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: 8px; border: 1px solid var(--mb-border); }
.danger-zone { border-color: var(--mb-danger); }

/* ---------- Vue groupée (conversations) ---------- */
.thread-count {
    display: inline-block; min-width: 1.6em; margin-left: 8px; padding: 0 6px; border-radius: 999px;
    background: var(--mb-selected); border: 1px solid var(--mb-border); color: var(--mb-text);
    font-size: var(--type-ramp-minus-1-font-size); font-weight: 700; text-align: center;
}
.list-mode { display: flex; gap: 6px; padding: 8px var(--gutter); border-bottom: 1px solid var(--mb-border); flex-wrap: wrap; }
.list-mode button {
    flex: 1 1 auto; min-height: var(--touch-target); padding: 0 12px; border: 2px solid var(--mb-border); border-radius: 10px;
    background: var(--mb-surface); color: inherit; font: inherit; font-size: var(--type-ramp-minus-1-font-size); cursor: pointer;
}
.list-mode button[aria-checked="true"] { border-color: var(--accent-fill-rest); background: var(--mb-selected); font-weight: 700; }
.conv-item { border: 1px solid var(--mb-border); border-radius: 10px; margin-bottom: 10px; background: var(--mb-surface); }
.conv-item > .conv-head {
    display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; width: 100%; padding: 12px 16px; border: 0; border-radius: 10px;
    background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.conv-item > .conv-head:hover { background: var(--mb-hover); }
.conv-item .conv-preview { grid-column: 1 / -1; color: var(--mb-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item.unread .conv-from { font-weight: 700; }
.conv-item .conv-body { padding: 0 16px 16px; }
.conv-status { display: flex; align-items: center; gap: 10px; margin: 8px 0 12px; color: var(--mb-text-muted); }

/* Mobile : bascule « Grouper » dans l'en-tête de la liste (état visible : bord et fond d'accent quand elle est active). */
.list-mode-toggle {
    display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto;
    min-height: var(--touch-target); padding: 0 12px; border: 2px solid var(--mb-border); border-radius: 999px;
    background: var(--mb-surface); color: var(--mb-text); font: inherit; font-size: var(--type-ramp-minus-1-font-size); cursor: pointer;
}
.list-mode-toggle[aria-pressed="true"] { border-color: var(--accent-fill-rest); background: var(--mb-selected); font-weight: 700; }
