:root {
    /* --- Charte Master Report --- */
    --primary: #234E7E;          /* bleu Master Report (couleur dominante) */
    --primary-hover: #1A3D63;
    --primary-soft: #e8eef6;     /* bleu très pâle (fond) */
    --primary-soft-2: #d3dfee;   /* bleu pâle (chips actifs) */

    --accent: #9F195D;           /* bordeaux Master Report (accent / urgence) */
    --accent-hover: #7E144A;
    --accent-soft: #fbeaf2;
    --accent-soft-2: #f4d2e2;

    /* --- Neutres --- */
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #fafbfd;
    --border: #e2e6ef;
    --border-strong: #cdd2de;
    --text: #234E7E;             /* texte principal = bleu brand */
    --text-muted: #5a6478;
    --text-subtle: #8a90a3;

    /* --- États --- */
    --success: #2f8f4d;
    --success-soft: #def3e3;
    --warning: #c97a06;
    --warning-soft: #fdf0d3;
    --danger: #9F195D;           /* alias du bordeaux brand */
    --danger-soft: #fbeaf2;
    --video: #234E7E;            /* la vidéo s'aligne sur le bleu */
    --video-soft: #e8eef6;

    --shadow-sm: 0 1px 2px rgba(35, 78, 126, 0.06);
    --shadow-md: 0 4px 12px rgba(35, 78, 126, 0.08);
    --shadow-lg: 0 12px 40px rgba(35, 78, 126, 0.16);
    --radius: 12px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }
a { color: var(--primary); }

/* ---------- AUTH ---------- */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(180deg, #f6f7fb 0%, #eef0f9 100%);
}
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.brand-mark {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.brand-mark svg { width: 100%; height: 100%; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.brand-name .wm-blue     { color: var(--primary); }
.brand-name .wm-bordeaux { color: var(--accent); }
.auth-title { font-size: 22px; font-weight: 600; letter-spacing: -0.015em; margin: 0 0 8px; }
.auth-subtitle { color: var(--text-muted); margin: 0 0 28px; font-size: 14px; }

.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.input {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 15px; color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(35, 78, 126, 0.18); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--primary); color: #fff;
    font-size: 14px; font-weight: 500;
    transition: background 0.15s, transform 0.05s;
    text-decoration: none;
}
.btn:hover { background: var(--primary-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-secondary {
    background: var(--surface); color: var(--text); border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost {
    background: transparent; color: var(--text-muted); padding: 8px 12px;
    border: none; border-radius: var(--radius-sm);
}
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }

.auth-footer { margin-top: 20px; text-align: center; font-size: 13px; color: var(--text-subtle); }
.auth-footer a { color: var(--primary); text-decoration: none; font-weight: 500; }
.auth-hint { color: var(--text-subtle); font-size: 12px; margin: 12px 0 0; text-align: center; }

/* Bouton Google Sign-In */
.btn-google {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 11px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: #fff;
    color: #3c4043;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
    margin-bottom: 8px;
}
.btn-google:hover { background: #f8f9fa; border-color: #cdd2de; }
.btn-google svg { flex-shrink: 0; }

.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-subtle);
    font-size: 12px;
    margin: 18px 0 14px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border);
}
.auth-divider span { padding: 0 12px; }

/* Method picker (TOTP-enabled accounts: TOTP vs email OTP) */
.method-list { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 8px; }
.method-list form { margin: 0; }
.method-card {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.method-card:hover {
    border-color: var(--primary);
    background: var(--surface-2);
    box-shadow: 0 2px 8px rgba(35, 78, 126, 0.06);
}
.method-card:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.method-icon {
    flex-shrink: 0;
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--primary);
}
.method-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.method-title { font-size: 14px; font-weight: 600; color: var(--text); }
.method-desc { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.method-arrow {
    flex-shrink: 0;
    font-size: 22px;
    color: var(--text-subtle);
    line-height: 1;
}

.otp-row {
    display: flex; gap: 10px; justify-content: space-between;
    margin: 8px 0 16px;
}
.otp-cell {
    width: 48px; height: 56px;
    text-align: center;
    font-size: 22px; font-weight: 600;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text);
}
.otp-cell:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(35, 78, 126, 0.18);
}

/* ---------- APP ---------- */
.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 32px;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 10;
}
.user-chip {
    display: flex; align-items: center; gap: 10px;
    color: var(--text-muted); font-size: 14px;
}
.avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px;
}
.container { max-width: 1080px; margin: 0 auto; padding: 32px; }
.page-title { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 4px; }
.page-subtitle { color: var(--text-muted); margin: 0 0 28px; font-size: 14px; }

.alert {
    display: flex; gap: 14px; align-items: flex-start;
    padding: 16px 18px; border-radius: var(--radius);
    margin-bottom: 24px; border: 1px solid;
}
.alert.alert-warning { background: var(--accent-soft);  border-color: var(--accent-soft-2); color: var(--accent); }
.alert.alert-info    { background: var(--accent-soft);  border-color: #c8d3e2; color: var(--accent); }
.alert.alert-success { background: var(--success-soft); border-color: #bbf7d0; color: #14532d; }
.alert.alert-error   { background: var(--danger-soft);  border-color: #fecaca; color: #7f1d1d; }
.alert-icon { flex-shrink: 0; width: 22px; height: 22px; margin-top: 1px; }
.alert-title { font-weight: 600; margin-bottom: 2px; font-size: 14px; }
.alert-body  { font-size: 13px; line-height: 1.5; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; align-items: center; }
.search { flex: 1; min-width: 240px; position: relative; }
.search input {
    width: 100%;
    padding: 10px 12px 10px 38px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 14px;
}
.search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(35, 78, 126, 0.18); }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-subtle); }

.filters {
    display: flex; gap: 6px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 4px;
}
.filter-chip {
    background: transparent; border: none; padding: 7px 12px;
    border-radius: 6px;
    font-size: 13px; color: var(--text-muted); font-weight: 500;
    display: inline-flex; align-items: center; gap: 6px;
    text-decoration: none;
}
.filter-chip:hover { color: var(--text); }
.filter-chip.active { background: var(--primary-soft); color: var(--primary); }
.filter-chip .count {
    background: rgba(35, 78, 126, 0.12); color: var(--primary);
    padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 600;
}
.filter-chip:not(.active) .count { background: var(--bg); color: var(--text-subtle); }

.doc-list {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.doc-list-head, .doc-row {
    display: grid;
    grid-template-columns: 1fr 180px 130px 130px 150px;
    gap: 16px;
    padding: 12px 20px;
    align-items: center;
}
.doc-list-head {
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: 12px; font-weight: 600;
    color: var(--text-subtle);
    text-transform: uppercase; letter-spacing: 0.04em;
}
.doc-row {
    padding: 8px 20px;          /* compact rows : 8px haut/bas au lieu de 16px */
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}
.doc-row:last-child { border-bottom: none; }
.doc-row:hover { background: var(--surface-2); }
.doc-row.urgent {
    background: linear-gradient(90deg, var(--accent-soft) 0%, #fff 100%);
    border-left: 3px solid var(--accent);
    padding-left: 17px;
}
.doc-row.urgent:hover {
    background: linear-gradient(90deg, var(--accent-soft-2) 0%, var(--surface-2) 100%);
}

.doc-title-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.doc-icon {
    width: 30px; height: 30px;  /* plus compact : 30 au lieu de 38 */
    border-radius: 6px;
    background: var(--primary-soft); color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.doc-icon svg { width: 14px; height: 14px; }
.doc-meta { min-width: 0; }
.doc-title {
    font-weight: 500; color: var(--text);
    margin: 0 0 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.doc-sub {
    font-size: 12px; color: var(--text-subtle);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.doc-cell { font-size: 13px; color: var(--text-muted); }

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 999px;
    font-size: 12px; font-weight: 500;
}
.badge-success { background: var(--success-soft); color: #166534; }
.badge-pending { background: #f1f5f9;             color: #475569; }
.badge-video   { background: var(--video-soft);   color: var(--video); }
.badge-warning { background: var(--accent-soft);  color: var(--accent); }
.badge-danger  { background: var(--danger-soft);  color: #991b1b; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.doc-actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.btn-download {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 12px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border-strong); border-radius: 7px;
    font-size: 13px; font-weight: 500;
    text-decoration: none;
    transition: all 0.12s;
}
.btn-download:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-download.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-download.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-download.video { background: var(--video-soft); color: var(--video); border-color: var(--accent-soft); }
.btn-download.video:hover { background: var(--video); color: #fff; border-color: var(--video); }

.empty { padding: 60px 20px; text-align: center; color: var(--text-subtle); }

/* ---------- PROFILE ---------- */
.user-link { text-decoration: none; }
.user-link:hover .avatar { box-shadow: 0 0 0 3px rgba(35, 78, 126, 0.18); }

.profile-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    max-width: 760px;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 26px;
    box-shadow: var(--shadow-sm);
}
.card-title { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.card-sub { color: var(--text-muted); margin: 0 0 14px; font-size: 13px; }

.kv {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 6px 18px;
    margin: 0;
    font-size: 14px;
}
.kv dt { color: var(--text-subtle); font-weight: 500; }
.kv dd { margin: 0; color: var(--text); }

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
}
.status-pill.status-on  { background: var(--success-soft); color: #166534; }
.status-pill.status-on  .badge-dot { background: var(--success); }
.status-pill.status-off { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.status-pill.status-off .badge-dot { background: var(--text-subtle); }

.totp-setup { margin-top: 8px; }
.setup-steps {
    list-style: decimal;
    padding-left: 22px;
    margin: 0;
}
.setup-steps li {
    margin-bottom: 18px;
    color: var(--text);
    font-size: 14px;
}
.setup-steps li:last-child { margin-bottom: 0; }

.totp-secret {
    display: block;
    background: var(--accent-soft);
    color: var(--accent);
    padding: 14px 16px;
    margin-top: 10px;
    border-radius: var(--radius-sm);
    font-family: 'SF Mono', Menlo, monospace;
    font-size: 16px;
    letter-spacing: 2px;
    font-weight: 600;
    word-break: break-all;
    border: 1px solid var(--accent-soft-2);
}

.link-strong { font-weight: 600; }

.totp-confirm {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    align-items: center;
}
.totp-confirm .input {
    width: auto;
    flex: 0 1 200px;
    letter-spacing: 4px;
    font-family: 'SF Mono', Menlo, monospace;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
}

.stats {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 12px; margin-bottom: 24px;
}
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px 18px;
}
.stat-label {
    font-size: 12px; color: var(--text-subtle);
    text-transform: uppercase; letter-spacing: 0.04em;
    font-weight: 600; margin-bottom: 6px;
}
.stat-value { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.stat-value.urgent { color: var(--accent); }

/* ---------- PAGINATION ---------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
    flex-wrap: wrap;
}
.pagination-info {
    color: var(--text-muted);
    font-size: 13px;
}
.pagination-list {
    display: flex;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.12s;
}
.pagination-link:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.pagination-link.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    cursor: default;
}
.pagination-link.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}
.pagination-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    color: var(--text-subtle);
    font-size: 14px;
}

@media (max-width: 860px) {
    .container { padding: 20px; }
    .app-header { padding: 12px 20px; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .doc-list-head { display: none; }
    .doc-row {
        grid-template-columns: 1fr auto;
        gap: 8px;
        padding: 14px 16px;
    }
    .doc-row .doc-title-cell { grid-column: 1 / -1; }
    .doc-row .doc-cell { display: none; }
    .doc-actions { grid-column: 1 / -1; justify-content: flex-start; }
    .filters { flex-wrap: wrap; }
}

/* ---------- DOWNLOAD ROWS (page détail document) ---------- */
.download-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.download-row:last-of-type { border-bottom: none; }
.download-info  { min-width: 0; flex: 1; }
.download-label { font-weight: 500; font-size: 14px; color: var(--text); }
.download-meta  { font-size: 12px; color: var(--text-subtle); margin-top: 2px; }

.bundle-help {
    margin: 4px 0 14px;
    padding: 12px 14px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-soft-2);
    border-radius: 8px;
    font-size: 13px;
    color: var(--accent);
}
.bundle-help p { margin: 6px 0 0; }

/* ---------- LANG SWITCH ---------- */
.lang-switch select {
    padding: 6px 8px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--surface);
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
}
.lang-switch-public {
    position: absolute;
    top: 16px;
    right: 16px;
}

/* ---------- EMITTERS TABLE (profile) ---------- */
.emitters-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}
.emitters-table td {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    font-size: 14px;
}
.emitters-table tr:last-child td { border-bottom: none; }

/* ---------- STAT CARDS CLIQUABLES ---------- */
a.stat-card {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}
a.stat-card:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(35, 78, 126, 0.12);
}
a.stat-card:active { transform: translateY(1px); }
a.stat-card.active {
    border-color: var(--primary);
    background: var(--primary-soft);
}
a.stat-card.active .stat-value { color: var(--primary); }
a.stat-card.active .stat-value.urgent { color: var(--accent); }

/* ---------- BADGE SUR LIGNE SÉPARÉE ---------- */
.doc-badges {
    margin: 4px 0 0;
    line-height: 1.2;
}

/* ---------- BOUTON CROIX RECHERCHE ---------- */
.search { position: relative; }
.search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-subtle);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 4px;
}
.search-clear:hover {
    color: var(--accent);
    background: var(--accent-soft);
}
.search-clear.hidden { display: none; }

/* ---------- FILTRE ÉMETTEUR (chips inline, auto-submit) ---------- */
.emitter-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
    padding: 4px 0;
}
.emitter-bar-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    margin-right: 4px;
}
.emitter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.12s;
    user-select: none;
    line-height: 1.3;
}
.emitter-chip:hover {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--text-subtle);
}
/* La checkbox réelle est masquée — la chip elle-même est l'élément interactif */
.emitter-chip input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
/* Double sélecteur : .active (rendu PHP) + :has() (auto-update via JS) */
.emitter-chip.active,
.emitter-chip:has(input[type="checkbox"]:checked) {
    background: var(--primary-soft-2);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 500;
}
.emitter-chip-name { line-height: 1; }
.emitter-chip-count {
    font-size: 11px;
    background: rgba(35, 78, 126, 0.10);
    color: inherit;
    opacity: 0.85;
    padding: 1px 7px;
    border-radius: 999px;
    font-weight: 600;
}
.emitter-chip.active .emitter-chip-count,
.emitter-chip:has(input[type="checkbox"]:checked) .emitter-chip-count {
    background: rgba(35, 78, 126, 0.18);
    opacity: 1;
}
.emitter-reset {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: 999px;
    background: transparent;
    border: 1px dashed var(--accent);
    color: var(--accent);
    font-size: 12px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.12s;
    margin-left: 4px;
}
.emitter-reset:hover { background: var(--accent-soft); }

/* ---------- Status column: stack expiry above status ---------- */
.doc-status-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: flex-start;
}
.doc-status-cell .badge { padding: 2px 7px; font-size: 11px; }

/* ---------- Language picker as flag buttons ---------- */
.lang-flags {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
}
.lang-flags-public {
    /* Replaces the public form on the login page (was top-right absolute) */
    position: absolute;
    top: 16px;
    right: 16px;
}
.lang-flag-form {
    display: inline-block;
    margin: 0;
}
.lang-flag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.1s, box-shadow 0.15s, border-color 0.15s;
    text-decoration: none;
    line-height: 0;
}
.lang-flag:hover {
    transform: scale(1.08);
    border-color: var(--border-strong);
}
.lang-flag.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(35, 78, 126, 0.18);
    cursor: default;
}
.lang-flag.active:hover { transform: none; }
.lang-flag svg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ---------- Collapsible flag dropdown (active flag visible, click to expand) ---------- */
.lang-flags-dropdown {
    position: relative;
    display: inline-block;
}
/* Hide the native disclosure marker */
.lang-flags-dropdown summary {
    list-style: none;
    cursor: pointer;
}
.lang-flags-dropdown summary::-webkit-details-marker { display: none; }
.lang-flags-dropdown summary::marker { content: ''; }

/* The summary IS the active flag button */
.lang-flags-dropdown > summary.lang-flag {
    /* inherits .lang-flag base styles (size, border, etc.) */
}

/* Open state — give the active flag a subtle "open" ring */
.lang-flags-dropdown[open] > summary.lang-flag {
    box-shadow: 0 0 0 3px rgba(35, 78, 126, 0.22);
}

/* The dropdown menu of other flags */
.lang-flags-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    /* small slide-in animation */
    animation: lang-menu-in 0.12s ease-out;
}
@keyframes lang-menu-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0);    }
}
.lang-flags-menu .lang-flag-form { display: block; }

/* Public variant on the login screen — anchor top-right of the auth-card */
.lang-flags-public {
    position: absolute;
    top: 16px;
    right: 16px;
}

/* Profile page: keep all flags visible side-by-side (deliberate setting view) */
.lang-flags-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
}
.lang-flags-row .lang-flag-form { display: inline-block; margin: 0; }
