/* ===========================================================================
   SafeDoc — Premium Design System (v1.3 — Safe-Doc compliant)
   =========================================================================== */

/* ---------- Tokens ---------- */
:root {
    /* Color palette (dark theme — default) */
    --bg-primary: #0a0a0f;
    --bg-secondary: #111118;
    --bg-tertiary: #1a1a24;
    --bg-card: #14141e;
    --bg-card-hover: #1c1c2a;
    --bg-input: #0e0e16;

    --text-primary: #f0f0f5;
    --text-secondary: #9595ad;
    --text-tertiary: #6565a0;
    --text-muted: #4a4a6a;
}

/* Light theme — applied when <html data-theme="light"> */
html[data-theme="light"] {
    --bg-primary:    #fafafe;
    --bg-secondary:  #f3f3f9;
    --bg-tertiary:   #ebebf5;
    --bg-card:       #ffffff;
    --bg-card-hover: #f5f5fa;
    --bg-input:      #ffffff;

    --text-primary:   #1a1a2e;
    --text-secondary: #5a5a78;
    --text-tertiary:  #8b8ba8;
    --text-muted:     #b5b5c8;

    --border-subtle: rgba(0, 0, 0, 0.06);
    --border-medium: rgba(0, 0, 0, 0.1);
    --border-strong: rgba(0, 0, 0, 0.16);

    --shadow-sm: 0 1px 2px rgba(20, 20, 50, 0.08);
    --shadow-md: 0 4px 12px rgba(20, 20, 50, 0.10);
    --shadow-lg: 0 8px 32px rgba(20, 20, 50, 0.14);
    --shadow-glow: 0 0 24px rgba(74, 158, 255, 0.15);
}

/* Light theme — element-specific overrides for hard-coded values */
html[data-theme="light"] .header {
    background: rgba(255, 255, 255, 0.85) !important;
    border-bottom-color: rgba(0, 0, 0, 0.08) !important;
}
html[data-theme="light"] .tab-switcher {
    background: var(--bg-secondary) !important;
    border-color: var(--border-medium);
}
html[data-theme="light"] .tab {
    color: var(--text-secondary);
}
html[data-theme="light"] .tab:hover {
    background: rgba(74, 158, 255, 0.08);
    color: var(--text-primary);
}
html[data-theme="light"] .drop-area {
    background: var(--bg-card);
    border-color: var(--border-medium);
}
html[data-theme="light"] body::before {
    background: radial-gradient(ellipse at top, rgba(74, 158, 255, 0.08), transparent 50%) !important;
}
html[data-theme="light"] .hero-glow {
    background: radial-gradient(ellipse, rgba(74, 158, 255, 0.08), transparent 70%) !important;
}

/* Re-declare so :root tokens above don't override the inheritance fallback */
:root {

    /* Bleu aligné sur la landing page (rendu plus pro que le violet précédent)
       Anciennes valeurs violettes : #4a9eff / #6eb3ff / #2f86ee — gardées en backup ci-dessous */
    --accent-primary: #4a9eff;
    --accent-primary-light: #6eb3ff;
    --accent-primary-dark: #2f86ee;
    --accent-gradient: linear-gradient(135deg, #4a9eff, #0ea5ff);
    --accent-gradient-soft: linear-gradient(135deg, rgba(74, 158, 255, 0.15), rgba(14, 165, 255, 0.08));

    --green: #00d68f;
    --green-soft: rgba(0, 214, 143, 0.12);
    --blue: #0ea5e9;
    --blue-soft: rgba(14, 165, 233, 0.12);
    --orange: #f59e0b;
    --orange-soft: rgba(245, 158, 11, 0.12);
    --red: #ef4444;
    --red-soft: rgba(239, 68, 68, 0.12);
    --pink: #ec4899;
    --cyan: #06b6d4;
    --yellow: #eab308;
    --purple: #0ea5ff;
    --purple-soft: rgba(14, 165, 255, 0.12);

    /* Entity colors */
    --entity-personne: #ec4899;
    --entity-personne-bg: rgba(236, 72, 153, 0.12);
    --entity-lieu: #06b6d4;
    --entity-lieu-bg: rgba(6, 182, 212, 0.12);
    --entity-organisation: #f59e0b;
    --entity-organisation-bg: rgba(245, 158, 11, 0.12);
    --entity-telephone: #10b981;
    --entity-telephone-bg: rgba(16, 185, 129, 0.12);
    --entity-email: #8b5cf6;
    --entity-email-bg: rgba(139, 92, 246, 0.12);
    --entity-date: #f97316;
    --entity-date-bg: rgba(249, 115, 22, 0.12);
    --entity-adresse: #14b8a6;
    --entity-adresse-bg: rgba(20, 184, 166, 0.12);
    --entity-iban: #ef4444;
    --entity-iban-bg: rgba(239, 68, 68, 0.12);
    --entity-numero_secu: #e11d48;
    --entity-numero_secu-bg: rgba(225, 29, 72, 0.12);
    --entity-siret: #64748b;
    --entity-siret-bg: rgba(100, 116, 139, 0.12);
    --entity-siren: #64748b;
    --entity-siren-bg: rgba(100, 116, 139, 0.12);
    --entity-code_postal: #0ea5e9;
    --entity-code_postal-bg: rgba(14, 165, 233, 0.12);
    --entity-divers: #94a3b8;
    --entity-divers-bg: rgba(148, 163, 184, 0.12);
    --entity-carte_id: #f43f5e;
    --entity-carte_id-bg: rgba(244, 63, 94, 0.12);
    /* NEW entity colors */
    --entity-montant: #22c55e;
    --entity-montant-bg: rgba(34, 197, 94, 0.12);
    --entity-url: #3b82f6;
    --entity-url-bg: rgba(59, 130, 246, 0.12);
    --entity-tva: #6eb3ff;
    --entity-tva-bg: rgba(167, 139, 250, 0.12);
    --entity-reference: #fb923c;
    --entity-reference-bg: rgba(251, 146, 60, 0.12);

    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.15);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 24px rgba(74, 158, 255, 0.2);

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;

    /* Font */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ---------- Header ---------- */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 15, 0.8);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
    transition: opacity 150ms ease;
}
.logo:hover { opacity: 0.85; }
.logo-mark {
    flex-shrink: 0;
    filter: drop-shadow(0 0 6px rgba(14, 165, 255, 0.3));
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-glow);
}

.logo-text {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.version-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: var(--purple-soft);
    color: var(--purple);
    border: 1px solid rgba(14, 165, 255, 0.2);
    letter-spacing: 0.03em;
}

.header-badges {
    display: flex;
    gap: 8px;
}

.badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge-green {
    background: var(--green-soft);
    color: var(--green);
    border: 1px solid rgba(0, 214, 143, 0.2);
}

.badge-blue {
    background: var(--blue-soft);
    color: var(--blue);
    border: 1px solid rgba(14, 165, 233, 0.2);
}

.badge-purple {
    background: var(--purple-soft);
    color: var(--purple);
    border: 1px solid rgba(14, 165, 255, 0.2);
}

.badge-dot {
    width: 6px;
    height: 6px;
    background: var(--green);
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

/* ---------- Hero ---------- */
.hero {
    text-align: center;
    padding: 36px 24px 24px;
    position: relative;
    overflow: hidden;
}

.hero-glow {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 400px;
    background: radial-gradient(ellipse, rgba(74, 158, 255, 0.15), transparent 70%);
    pointer-events: none;
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 800;
    letter-spacing: -0.035em;
    line-height: 1.15;
    margin-bottom: 10px;
    position: relative;
}

.gradient-text {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    color: var(--text-secondary);
    font-size: 1.02rem;
    max-width: 920px;
    margin: 0 auto;
    line-height: 1.45;
}

/* ---------- App Container ---------- */
.app-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 28px 24px 80px;
}

/* ---------- Tab Switcher ---------- */
.tab-switcher {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: 4px;
    margin-bottom: 24px;
    border: 1px solid var(--border-subtle);
}

.tab {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: var(--shadow-glow);
}

/* ---------- Mode Selector (Anonymisé vs Pseudonymisé) ---------- */
.mode-selector {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mode-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mode-toggle {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.mode-toggle-3 {
    grid-template-columns: repeat(3, 1fr);
}
.mode-toggle-2 {
    grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 700px) {
    .mode-toggle-3, .mode-toggle-2 {
        grid-template-columns: 1fr;
    }
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-medium);
    background: var(--bg-card);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-sans);
    text-align: left;
}

.mode-btn svg {
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity var(--transition-fast);
}

.mode-btn:hover {
    border-color: var(--accent-primary);
    background: var(--bg-card-hover);
    transform: translateY(-1px);
}

.mode-btn:hover svg {
    opacity: 1;
}

.mode-btn.active {
    border-color: var(--accent-primary);
    background: var(--accent-gradient-soft);
    box-shadow: 0 0 12px rgba(74, 158, 255, 0.2);
}

.mode-btn.active svg {
    opacity: 1;
    color: var(--accent-primary-light);
}

.mode-btn[data-mode="pseudonymize"].active {
    border-color: var(--cyan);
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.12), rgba(14, 165, 233, 0.06));
    box-shadow: 0 0 12px rgba(6, 182, 212, 0.2);
}

.mode-btn[data-mode="pseudonymize"].active svg {
    color: var(--cyan);
}

.mode-btn[data-mode="fake_data"].active {
    border-color: #10b981;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(52, 211, 153, 0.06));
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
}

.mode-btn[data-mode="fake_data"].active svg {
    color: #10b981;
}

.mode-btn-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
    display: block;
}

.mode-btn.active .mode-btn-title {
    color: var(--accent-primary-light);
}

.mode-btn[data-mode="pseudonymize"].active .mode-btn-title {
    color: var(--cyan);
}

.mode-btn[data-mode="fake_data"].active .mode-btn-title {
    color: #10b981;
}

.mode-btn-desc {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    display: block;
    margin-top: 2px;
}

.mode-btn-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Pseudo tag styling in output */
.pseudo-tag {
    border-bottom: 2px dashed currentColor;
    cursor: help;
}

/* ---------- Level Selector ---------- */
.level-selector {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.level-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.level-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.level-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 16px 16px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-medium);
    background: var(--bg-card);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast),
                transform var(--transition-fast), box-shadow var(--transition-fast);
    font-family: var(--font-sans);
    text-align: left;
    overflow: visible;
}

.level-btn:hover {
    border-color: var(--accent-primary);
    background: var(--bg-card-hover);
    transform: translateY(-1px);
}

.level-btn.active {
    border-color: var(--accent-primary);
    background: var(--accent-gradient-soft);
    box-shadow: 0 0 14px rgba(74, 158, 255, 0.18);
}

.level-btn[data-level="N2"].active {
    border-color: #f59e0b;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(251, 191, 36, 0.04));
    box-shadow: 0 0 16px rgba(245, 158, 11, 0.20);
}

.level-btn[data-level="N3"].active {
    border-color: #ef4444;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.08), rgba(249, 115, 22, 0.04));
    box-shadow: 0 0 14px rgba(239, 68, 68, 0.18);
}

/* "Recommended" badge floating on top of N2 */
.level-btn-recommended {
    border-color: rgba(245, 158, 11, 0.45);
}
.level-recommended-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    padding: 3px 12px;
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    color: #fff;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-radius: var(--radius-full);
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
    pointer-events: none;
}

/* Header row : badge + name on one line */
.level-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.level-badge {
    font-size: 0.78rem;
    font-weight: 800;
    font-family: var(--font-mono);
    padding: 2px 7px;
    border-radius: var(--radius-sm);
    background: rgba(74, 158, 255, 0.14);
    color: var(--accent-primary);
    letter-spacing: 0.02em;
}

.level-btn[data-level="N2"] .level-badge {
    background: rgba(245, 158, 11, 0.14);
    color: #f59e0b;
}
.level-btn[data-level="N3"] .level-badge {
    background: rgba(239, 68, 68, 0.14);
    color: #ef4444;
}

.level-btn.active .level-badge {
    background: var(--accent-primary);
    color: #fff;
}
.level-btn[data-level="N2"].active .level-badge {
    background: #f59e0b;
    color: #fff;
}
.level-btn[data-level="N3"].active .level-badge {
    background: #ef4444;
    color: #fff;
}

.level-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.005em;
}

/* Sub-line: short main descriptor */
.level-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.35;
}

/* Sub-line: use case (italic, smaller, lighter) */
.level-use {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    font-style: italic;
    line-height: 1.3;
}

/* Concrete example, monospace — visible "preview" of what the level produces */
.level-example {
    margin-top: 4px;
    padding: 5px 8px;
    background: rgba(0, 0, 0, 0.18);
    border: 1px dashed var(--border-medium);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.level-btn[data-level="N1"].active .level-example {
    color: var(--accent-primary-light);
    border-color: rgba(74, 158, 255, 0.35);
}
.level-btn[data-level="N2"].active .level-example {
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.45);
    background: rgba(245, 158, 11, 0.08);
}
.level-btn[data-level="N3"].active .level-example {
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.40);
}

/* Tooltip — hidden by default, revealed on hover/focus */
.level-tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: 320px;
    padding: 10px 14px;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.78rem;
    font-weight: 400;
    line-height: 1.45;
    text-align: left;
    white-space: normal;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease;
    z-index: 50;
}
.level-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--border-medium);
}
.level-btn:hover .level-tooltip,
.level-btn:focus-visible .level-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-2px);
}

/* Mobile : stack vertically */
@media (max-width: 760px) {
    .level-buttons { grid-template-columns: 1fr; gap: 8px; }
    .level-tooltip { max-width: 90vw; }
    .level-recommended-badge { font-size: 0.62rem; padding: 2px 9px; }

    /* Compact level cards on mobile — less vertical real-estate */
    .level-selector { margin-bottom: 14px; gap: 8px; }
    .level-label { font-size: 0.72rem; letter-spacing: 0.04em; }
    .level-btn { padding: 10px 12px 10px; gap: 4px; }
    .level-name { font-size: 0.92rem; }
    .level-desc { font-size: 0.74rem; line-height: 1.25; }
    .level-use { display: none; }
    .level-example {
        margin-top: 2px;
        padding: 4px 7px;
        font-size: 0.68rem;
    }
    /* The N2 floating badge: bring closer to its card to avoid the visual
       collision with the previous card on tight stacks. */
    .level-recommended-badge { top: -8px; }

    /* Compact mode cards */
    .mode-selector { margin-bottom: 14px; gap: 6px; }
    .mode-label { font-size: 0.72rem; letter-spacing: 0.04em; }
    .mode-btn { padding: 10px 14px; gap: 10px; }
    .mode-btn svg { width: 20px; height: 20px; }
    .mode-btn-title { font-size: 0.85rem; }
    .mode-btn-desc { font-size: 0.68rem; margin-top: 1px; }
}

/* ---------- Options row (LLM local toggle, etc.) ---------- */
.options-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    padding: 0 2px;
}

.toggle-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.toggle-option input[type="checkbox"] {
    display: none;
}

.toggle-knob {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    background: var(--border-medium);
    border-radius: 10px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.toggle-knob::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle-option input:checked + .toggle-knob {
    background: var(--blue);
}

.toggle-option input:checked + .toggle-knob::after {
    transform: translateX(16px);
}

.toggle-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge-beta {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--blue);
    color: white;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ---------- Input Zones ---------- */
.input-zone {
    margin-bottom: 32px;
}

.hidden {
    display: none !important;
}

/* Drop area */
.drop-area {
    border: 2px dashed var(--border-medium);
    border-radius: var(--radius-xl);
    padding: 56px 32px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
    background: var(--bg-card);
    position: relative;
    overflow: hidden;
}

.drop-area::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent-gradient-soft);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.drop-area:hover,
.drop-area.drag-over {
    border-color: var(--accent-primary);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.drop-area.drag-over {
    border-style: solid;
    transform: scale(1.01) translateY(-2px);
    box-shadow: 0 0 0 4px rgba(74,158,255,0.15), var(--shadow-glow);
    animation: drop-pulse 1s ease-in-out infinite;
}
@keyframes drop-pulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(74,158,255,0.15), var(--shadow-glow); }
    50%      { box-shadow: 0 0 0 8px rgba(74,158,255,0.08), var(--shadow-glow); }
}

.drop-area:hover::before,
.drop-area.drag-over::before {
    opacity: 1;
}

.drop-icon {
    color: var(--accent-primary-light);
    margin-bottom: 16px;
    position: relative;
}

.drop-text {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 4px;
    position: relative;
}

.drop-subtext {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 12px;
    position: relative;
}

.drop-formats {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-family: var(--font-mono);
    position: relative;
}

/* Paste textarea */
.paste-textarea {
    width: 100%;
    min-height: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    padding: 20px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    line-height: 1.7;
    resize: vertical;
    transition: border-color var(--transition-fast);
    outline: none;
}

.paste-textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.15);
}

.paste-textarea::placeholder {
    color: var(--text-muted);
}

/* ---------- Restore zone ---------- */
.restore-header {
    margin-bottom: 24px;
}
.restore-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.restore-desc {
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.6;
}
.restore-desc code {
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 0.87rem;
    color: var(--accent-primary);
}
.restore-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
@media (max-width: 720px) {
    .restore-layout { grid-template-columns: 1fr; }
}
.restore-step {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.restore-step-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.restore-step-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.restore-mapping-drop {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 28px 20px;
    background: var(--bg-card);
    border: 2px dashed var(--border-medium);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    min-height: 160px;
}
.restore-mapping-drop:hover,
.restore-mapping-drop.drag-over {
    border-color: var(--accent-primary);
    background: rgba(74, 158, 255, 0.06);
}
.restore-mapping-drop.loaded {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.06);
    color: #10b981;
}
.restore-mapping-drop svg {
    opacity: 0.5;
}
.restore-mapping-drop.loaded svg {
    opacity: 1;
    stroke: #10b981;
}
.restore-result {
    margin-top: 24px;
}
.restore-result-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.restore-result-title {
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}
.restore-result-count {
    font-size: 0.85rem;
    color: #10b981;
    font-weight: 600;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-md);
    margin-top: 16px;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow), var(--shadow-lg);
}

/* Prominent "download anonymized Excel" CTA — Excel green, only shown for xlsx sources */
.btn-xlsx-download {
    background: linear-gradient(135deg, #1D6F42, #21A366);
    color: #fff;
    font-weight: 600;
    border: none;
    box-shadow: 0 4px 14px rgba(33, 163, 102, 0.35);
    gap: 8px;
}
.btn-xlsx-download:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(33, 163, 102, 0.5);
}

.btn-ghost {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.btn-ghost:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-medium);
}

/* ---------- Admin header + sub-tabs ---------- */
.admin-header-bar {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 18px; gap: 12px; flex-wrap: wrap;
}
.admin-title {
    margin: 0; font-size: 1.3rem; font-weight: 700; color: var(--text-primary);
}
.admin-header-actions {
    display: flex; gap: 8px; flex-wrap: wrap;
}
.admin-link {
    text-decoration: none; display: inline-flex; align-items: center; gap: 4px;
}
.admin-subtabs {
    display: flex; gap: 6px; flex-wrap: wrap;
    margin-bottom: 22px; padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
}
.admin-subtab {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 8px 14px;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.admin-subtab:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-medium);
}
.admin-subtab.active {
    background: linear-gradient(135deg, rgba(74,158,255,0.15), rgba(14,165,255,0.10));
    color: var(--text-primary);
    border-color: var(--accent-primary);
    font-weight: 600;
}
.admin-tab-content { display: block; }
.admin-tab-content.hidden { display: none; }

/* ---------- Bench visuel : Original ↔ Anonymisé ---------- */
.bench-visual-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 10px;
}
.bench-visual-col h4 { margin: 0 0 6px; font-size: 0.85rem; color: var(--text-secondary); }
.bench-visual-text {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 8px 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    line-height: 1.45;
    max-height: 240px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-secondary);
    margin: 0;
}
.bench-visual-anon {
    background: rgba(34, 197, 94, 0.04);
    border-color: rgba(34, 197, 94, 0.2);
    color: var(--text-primary);
}
@media (max-width: 800px) {
    .bench-visual-compare { grid-template-columns: 1fr; }
}

/* ---------- Bench régression panel (admin) ---------- */
.bench-panel {
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    background: var(--bg-card);
    padding: 18px 20px 16px;
    margin-bottom: 28px;
}
.bench-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-subtle);
}
.bench-header h3 {
    margin: 0 0 6px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    display: inline-flex; align-items: center; gap: 8px;
}
.bench-icon { font-size: 1.2rem; }
.bench-aggregate-badge { display: inline-flex; align-items: center; }
.bench-subtitle { font-size: 0.82rem; color: var(--text-tertiary); margin: 0; }
.bench-llm-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 0.78rem; color: var(--text-secondary);
    background: var(--bg-tertiary); border: 1px solid var(--border-subtle);
    border-radius: 6px; padding: 6px 10px; cursor: pointer;
}
.bench-progress { margin-bottom: 12px; }
.bench-progress.hidden { display: none; }
.bench-progress-bar {
    height: 6px; background: var(--bg-tertiary);
    border-radius: 3px; overflow: hidden;
}
.bench-progress-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, #4a9eff, #0ea5ff, #ec4899);
    transition: width 0.3s ease-out;
}
.bench-progress-label {
    font-size: 0.78rem; color: var(--text-tertiary); margin-top: 4px;
}
.bench-cases-list {
    display: flex; flex-direction: column; gap: 8px;
}
.bench-case-row {
    display: grid;
    grid-template-columns: 2.4fr 1.4fr auto;
    gap: 14px;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 10px 14px;
    flex-wrap: wrap;
}
.bench-case-main { min-width: 0; }
.bench-case-name {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.92rem; color: var(--text-primary);
    margin-bottom: 4px;
}
.bench-case-icon { font-size: 0.88rem; opacity: 0.7; }
.bench-case-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.bench-tag {
    background: rgba(74, 158, 255, 0.12);
    color: #6eb3ff;
    border: 1px solid rgba(74, 158, 255, 0.3);
    padding: 1px 7px; border-radius: 4px;
    font-size: 0.68rem; font-weight: 600; letter-spacing: 0.02em;
}
html[data-theme="light"] .bench-tag { color: #4a9eff; }
.bench-case-desc {
    font-size: 0.74rem; color: var(--text-tertiary); margin-top: 4px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bench-case-stats {
    display: flex; gap: 12px; flex-wrap: wrap;
    font-size: 0.78rem; color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
}
.bench-case-stats b { color: var(--text-primary); font-weight: 600; }
.bench-case-stats .red { color: #ef4444; }
.bench-case-stats .orange { color: #f59e0b; }
.bench-f1 { color: #6eb3ff; }
.bench-case-actions {
    display: flex; gap: 6px;
}
.bench-case-actions .action-btn {
    font-size: 0.78rem; padding: 4px 10px;
}
.bench-case-detail {
    grid-column: 1 / -1;
    margin-top: 10px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-size: 0.82rem;
}
.bench-case-detail.hidden { display: none; }
.bench-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
}
.bench-detail-col h4.bench-detail-h4 {
    margin: 0 0 6px; font-size: 0.85rem; font-weight: 700;
}
.bench-detail-col h4.ok    { color: #4ade80; }
.bench-detail-col h4.fail  { color: #ef4444; }
.bench-detail-col h4.warn  { color: #f59e0b; }
.bench-detail-col ul {
    margin: 0; padding-left: 0; list-style: none;
}
.bench-detail-col li {
    font-size: 0.76rem; padding: 2px 0;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}
.bench-detail-col li.muted { color: var(--text-tertiary); font-style: italic; }
.bench-pii-ok  { color: var(--text-secondary); }
.bench-pii-fn  { color: #ef4444; }
.bench-pii-fp  { color: #f59e0b; }
.bench-detail-col code {
    background: var(--bg-card);
    padding: 1px 5px; border-radius: 3px;
    font-size: 0.74rem;
}
@media (max-width: 800px) {
    .bench-detail-grid { grid-template-columns: 1fr; }
    .bench-case-row { grid-template-columns: 1fr; }
    .bench-case-stats { margin-top: 8px; }
    .bench-case-actions { margin-top: 8px; }
}

.bench-detail-col li.bench-pii-fp {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}
.bench-fp-actions {
    display: inline-flex;
    gap: 4px;
    flex-shrink: 0;
}
.bench-fp-btn {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    border: 1px solid transparent;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    white-space: nowrap;
}
.bench-fp-btn:hover:not(:disabled) {
    background: var(--bg-tertiary);
}
.bench-fp-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.bench-fp-tp     { color: #4ade80; border-color: rgba(34,197,94,0.35); }
.bench-fp-tp:hover:not(:disabled) { background: rgba(34,197,94,0.15); }
.bench-fp-hallu  { color: #f87171; border-color: rgba(239,68,68,0.35); }
.bench-fp-hallu:hover:not(:disabled) { background: rgba(239,68,68,0.15); }
.bench-fp-ignore { color: var(--text-tertiary); border-color: var(--border-subtle); }
.bench-fp-ignore:hover:not(:disabled) { background: var(--bg-tertiary); }

.bench-declare-fn {
    margin-top: 16px;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
}
.bench-declare-fn .bench-detail-h4 {
    margin: 0 0 8px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.bench-declare-fn-row {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
.bench-fn-text {
    flex: 1 1 200px;
    min-width: 160px;
    padding: 6px 9px;
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 5px;
    color: var(--text-primary);
    font-size: 0.78rem;
}
.bench-fn-text:focus {
    outline: none;
    border-color: var(--accent-primary);
}
.bench-fn-label {
    padding: 6px 9px;
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 5px;
    color: var(--text-primary);
    font-size: 0.78rem;
    cursor: pointer;
}
.bench-declare-fn-btn {
    font-size: 0.78rem;
    padding: 6px 12px;
}

.bench-status-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    margin-left: 6px;
}
.bench-status-badge.ok    { background: rgba(34,197,94,0.15); color: #4ade80; border: 1px solid rgba(34,197,94,0.4); }
.bench-status-badge.fail  { background: rgba(239,68,68,0.15); color: #ef4444; border: 1px solid rgba(239,68,68,0.4); }
.bench-status-badge.warn  { background: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.4); }
.bench-status-badge.muted { background: var(--bg-tertiary); color: var(--text-tertiary); border: 1px solid var(--border-subtle); }
html[data-theme="light"] .bench-status-badge.ok   { color: #16a34a; }
html[data-theme="light"] .bench-status-badge.fail { color: #dc2626; }
html[data-theme="light"] .bench-status-badge.warn { color: #d97706; }

/* Modal: ajouter un cas de bench */
.bench-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(3px);
}
.bench-modal-overlay.hidden { display: none; }
.bench-modal {
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    width: min(640px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.bench-modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 20px; border-bottom: 1px solid var(--border-subtle);
}
.bench-modal-header h3 { margin: 0; font-size: 1.05rem; font-weight: 700; }
.bench-modal-close {
    background: none; border: none; color: var(--text-secondary);
    font-size: 1.5rem; cursor: pointer; line-height: 1;
}
.bench-modal-body {
    padding: 16px 20px; overflow-y: auto; flex: 1;
    display: flex; flex-direction: column; gap: 12px;
}
.bench-field {
    display: flex; flex-direction: column; gap: 4px;
}
.bench-field.hidden { display: none; }
.bench-field span { font-size: 0.82rem; color: var(--text-secondary); font-weight: 500; }
.bench-field span .req { color: #ef4444; }
.bench-field input, .bench-field textarea {
    background: var(--bg-input);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    border-radius: 6px;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 0.88rem;
}
.bench-field textarea {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem; resize: vertical;
}
.bench-field code {
    background: var(--bg-tertiary);
    padding: 1px 5px; border-radius: 3px; font-size: 0.74rem;
}
.bench-source-tabs {
    display: flex; gap: 4px;
    background: var(--bg-tertiary); border-radius: 6px; padding: 3px;
}
.bench-source-tab {
    flex: 1; background: transparent; border: none;
    color: var(--text-secondary); padding: 6px;
    font-size: 0.82rem; cursor: pointer; border-radius: 4px;
    font-family: inherit;
}
.bench-source-tab.active {
    background: var(--bg-card);
    color: var(--text-primary);
    font-weight: 600;
}
.bench-modal-footer {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 14px 20px; border-top: 1px solid var(--border-subtle);
}
.bench-submit-btn {
    background: linear-gradient(135deg, #4a9eff, #0ea5ff) !important;
    color: white !important;
    border: none !important;
}
.bench-submit-btn:hover {
    opacity: 0.9;
}

/* ---------- Active Learning panel (admin) ---------- */
.active-learning-panel {
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    background: var(--bg-card);
    padding: 18px 20px 20px;
    margin-bottom: 28px;
}
.active-learning-header {
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
}
.active-learning-header h3 {
    margin: 0 0 6px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.active-learning-header .al-icon { font-size: 1.2rem; }
.al-subtitle {
    font-size: 0.82rem;
    color: var(--text-tertiary);
    margin: 0 0 12px;
    line-height: 1.5;
}
.al-flow {
    display: flex;
    align-items: stretch;
    gap: 10px;
    flex-wrap: wrap;
}
.al-step {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 10px 14px;
    flex: 1 1 240px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.4;
}
.al-step strong { color: var(--text-primary); }
.al-step-num {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a9eff, #0ea5ff);
    color: white;
    font-weight: 700;
    font-size: 0.78rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.al-step-mech {
    color: var(--text-tertiary);
    font-size: 0.75rem;
}
.al-arrow {
    align-self: center;
    color: var(--accent-primary);
    font-size: 1.2rem;
    font-weight: 700;
}
.al-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 14px 16px;
}
.al-section + .al-section { margin-top: 16px; }
.al-section code {
    background: var(--bg-tertiary);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.75rem;
}
.al-level-badge {
    display: inline-block;
    font-size: 0.66rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    margin-right: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    vertical-align: 2px;
}
.al-level-badge.level-1 {
    background: rgba(74, 158, 255, 0.18);
    color: #6eb3ff;
    border: 1px solid rgba(74, 158, 255, 0.4);
}
.al-level-badge.level-2 {
    background: rgba(236, 72, 153, 0.15);
    color: #f472b6;
    border: 1px solid rgba(236, 72, 153, 0.35);
}
.al-status-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    margin-left: 6px;
    vertical-align: 2px;
}
.al-status-badge.active {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.4);
}
.al-status-badge.paused {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.35);
}
html[data-theme="light"] .al-level-badge.level-1 {
    color: #4a9eff;
    background: rgba(74, 158, 255, 0.08);
}
html[data-theme="light"] .al-level-badge.level-2 {
    color: #db2777;
    background: rgba(236, 72, 153, 0.08);
}
html[data-theme="light"] .al-status-badge.active {
    color: #16a34a;
    background: rgba(34, 197, 94, 0.08);
}
html[data-theme="light"] .al-status-badge.paused {
    color: #d97706;
    background: rgba(245, 158, 11, 0.08);
}

/* Generic action button used in admin panels (Promouvoir, Actualiser, Exporter CSV…) */
.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-medium);
    border-radius: 7px;
    padding: 7px 14px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.08s;
    white-space: nowrap;
}
.action-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}
.action-btn:active:not(:disabled) {
    transform: translateY(1px);
}
.action-btn.admin-link:hover {
    color: var(--accent-primary);
}
.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-pdf {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: none;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

.btn-pdf:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.35);
}

.btn-report {
    background: linear-gradient(135deg, #4a9eff, #0ea5ff);
    color: white;
    border: none;
    box-shadow: 0 2px 8px rgba(74, 158, 255, 0.25);
}

.btn-report:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(74, 158, 255, 0.35);
}

.btn-share-feedback {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-medium);
    font-weight: 500;
}
.btn-share-feedback:hover {
    background: var(--bg-hover);
    color: var(--blue);
    border-color: var(--blue);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-medium);
}

.btn-outline:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary-light);
}

/* ---------- Loading ---------- */
.loading-overlay {
    text-align: center;
    padding: 80px 32px;
}

.loading-spinner {
    position: relative;
    width: 64px;
    height: 64px;
    margin: 0 auto 24px;
}

.spinner-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid transparent;
    animation: spin 1.5s ease-in-out infinite;
}

.spinner-ring:nth-child(1) {
    border-top-color: var(--accent-primary);
    animation-delay: 0s;
}

.spinner-ring:nth-child(2) {
    border-right-color: var(--pink);
    animation-delay: 0.15s;
    inset: 8px;
}

.spinner-ring:nth-child(3) {
    border-bottom-color: var(--cyan);
    animation-delay: 0.3s;
    inset: 16px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading-text {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.loading-subtext {
    color: var(--text-tertiary);
    font-size: 0.85rem;
}

/* History slide-in panel */
.history-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 9999;
    display: flex;
    justify-content: flex-end;
    animation: history-fade-in 0.2s ease-out;
}
.history-overlay.hidden { display: none; }
@keyframes history-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.history-panel {
    width: min(420px, 100vw);
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-medium);
    box-shadow: -8px 0 32px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    animation: history-slide-in 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes history-slide-in {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}
.history-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-subtle);
}
.history-panel-header h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}
/* Scope badges — clarify private (user) vs admin-only data ownership */
.scope-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
    cursor: default;
}
.scope-badge.scope-private {
    background: rgba(16, 185, 129, 0.14);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.35);
}
.scope-badge.scope-admin {
    background: rgba(168, 85, 247, 0.14);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.35);
}
.admin-scope-note {
    margin: 0 0 14px 0;
    padding: 8px 12px;
    background: rgba(168, 85, 247, 0.06);
    border-left: 3px solid rgba(168, 85, 247, 0.45);
    border-radius: 0 6px 6px 0;
    font-size: 0.78rem;
    color: var(--text-secondary, #94a3b8);
    line-height: 1.5;
}
.history-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}
.history-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.history-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
}
.history-loading,
.history-empty {
    text-align: center;
    color: var(--text-tertiary);
    padding: 40px 20px;
    font-size: 0.9rem;
}
.history-empty small {
    display: block;
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.history-item {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    transition: border-color 0.15s, transform 0.1s;
    cursor: default;
}
.history-item:hover {
    border-color: var(--accent-primary);
}
.history-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.history-item-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}
.history-item-meta {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 999px;
    flex-shrink: 0;
}
.history-item-sub {
    margin-top: 6px;
}
.history-item-date {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}
.history-item-pii {
    font-size: 0.75rem;
    color: var(--accent-primary-light);
    font-weight: 500;
}
.history-item-pages {
    font-size: 0.75rem;
    color: var(--text-secondary, #94a3b8);
    font-weight: 500;
    margin-left: 8px;
}

/* Step indicator (Parsing → Détection → Filtres → Finalisation) */
.loading-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin: 22px auto 0;
    width: min(420px, calc(100vw - 48px));
}
.loading-step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    position: relative;
}
.loading-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 7px;
    left: calc(50% + 9px);
    right: calc(-50% + 9px);
    height: 2px;
    background: var(--border-subtle);
    transition: background 0.4s;
}
.loading-step.done:not(:last-child)::after {
    background: var(--accent-primary);
}
.loading-step-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-subtle);
    transition: background 0.3s, border-color 0.3s, transform 0.3s, box-shadow 0.3s;
}
.loading-step.active .loading-step-dot {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    transform: scale(1.25);
    box-shadow: 0 0 0 4px rgba(74,158,255,0.18);
    animation: pulse-dot 1.4s ease-in-out infinite;
}
.loading-step.done .loading-step-dot {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}
.loading-step-label {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    font-weight: 500;
    transition: color 0.3s;
}
.loading-step.active .loading-step-label,
.loading-step.done .loading-step-label {
    color: var(--text-primary);
}
@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 4px rgba(74,158,255,0.18); }
    50%      { box-shadow: 0 0 0 8px rgba(74,158,255,0.10); }
}

/* Keyboard hint badge inside buttons */
.kbd-hint {
    display: inline-flex;
    gap: 3px;
    margin-left: 8px;
    opacity: 0.7;
}
.kbd-hint kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    background: rgba(0,0,0,0.22);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    line-height: 1;
}

/* LLM gate banner inside the loading overlay */
.loading-llm-banner {
    margin-top: 22px;
    width: min(440px, calc(100vw - 48px));
    background: linear-gradient(135deg, rgba(74, 158, 255, 0.12), rgba(14, 165, 255, 0.08));
    border: 1px solid rgba(14, 165, 255, 0.35);
    border-radius: 10px;
    padding: 14px 16px;
}
.loading-llm-banner.hidden { display: none; }
.loading-llm-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 8px;
}
.loading-llm-icon { font-size: 1.05rem; }
.loading-llm-label { flex: 1; }
.loading-llm-timer {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    color: #6eb3ff;
    background: rgba(14, 165, 255, 0.15);
    border-radius: 4px;
    padding: 2px 8px;
    min-width: 36px;
    text-align: center;
}
.loading-llm-progress {
    height: 4px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    overflow: hidden;
}
.loading-llm-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4a9eff, #0ea5ff, #ec4899);
    transition: width 0.3s ease-out;
    border-radius: 2px;
}
.loading-llm-hint {
    margin: 10px 0 0;
    font-size: 0.78rem;
    color: var(--text-tertiary);
    line-height: 1.4;
}
.loading-llm-hint code {
    background: var(--bg-tertiary);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.75rem;
}
html[data-theme="light"] .loading-llm-banner {
    background: linear-gradient(135deg, rgba(74, 158, 255, 0.06), rgba(14, 165, 255, 0.04));
    border-color: rgba(14, 165, 255, 0.25);
}
html[data-theme="light"] .loading-llm-progress {
    background: rgba(0, 0, 0, 0.06);
}
html[data-theme="light"] .loading-llm-timer {
    color: #4a9eff;
    background: rgba(14, 165, 255, 0.10);
}

/* ========== Quality Gates (NEW — Safe-Doc) ========== */
.quality-gates {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
    animation: slideUp 0.4s ease-out;
}

.gate-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    transition: all var(--transition-fast);
}

.gate-item:hover {
    transform: translateY(-1px);
}

.gate-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.gate-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.gate-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
}

.gate-value {
    font-size: 0.95rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

/* Gate states */
.gate-pass .gate-icon {
    background: var(--green-soft);
    color: var(--green);
}

.gate-pass .gate-value {
    color: var(--green);
}

.gate-pass {
    border-color: rgba(0, 214, 143, 0.2);
}

.gate-warn .gate-icon {
    background: var(--orange-soft);
    color: var(--orange);
}

.gate-warn .gate-value {
    color: var(--orange);
}

.gate-warn {
    border-color: rgba(245, 158, 11, 0.2);
}

.gate-fail .gate-icon {
    background: var(--red-soft);
    color: var(--red);
}

.gate-fail .gate-value {
    color: var(--red);
}

.gate-fail {
    border-color: rgba(239, 68, 68, 0.2);
}

.gate-neutral .gate-icon {
    background: rgba(148, 163, 184, 0.12);
    color: #94a3b8;
}

.gate-neutral .gate-value {
    color: #94a3b8;
}

/* ========== Residual Warnings (NEW) ========== */
.residual-warnings {
    background: var(--red-soft);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 20px;
    animation: slideUp 0.45s ease-out;
}

.residual-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--red);
    margin-bottom: 12px;
}

.residual-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.residual-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.2);
    font-size: 0.82rem;
}

.residual-severity {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    letter-spacing: 0.05em;
}

.residual-high .residual-severity {
    background: var(--red);
    color: white;
}

.residual-medium .residual-severity {
    background: var(--orange);
    color: #000;
}

.residual-low .residual-severity {
    background: var(--blue);
    color: white;
}

.residual-label {
    color: var(--text-secondary);
    font-weight: 600;
    min-width: 80px;
}

.residual-text {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--red);
    background: rgba(239, 68, 68, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

.residual-pos {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-family: var(--font-mono);
    margin-left: auto;
}

/* ---------- Stats Bar ---------- */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 32px;
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
    transition: all var(--transition-fast);
}

.stat-card:hover {
    border-color: var(--border-medium);
    transform: translateY(-2px);
}

.stat-number {
    font-size: 1.8rem;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ---------- Entity Review ---------- */
.entity-review {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    animation: slideUp 0.6s ease-out;
}

.section-title {
    font-size: 1.05rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.section-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 20px;
}

/* Entity filters */
.entity-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.entity-filter-btn {
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    border: 1px solid;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
}

.entity-filter-btn .count {
    font-size: 0.7rem;
    opacity: 0.7;
}

/* Entity list */
.entity-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 8px;
}

.entity-list::-webkit-scrollbar {
    width: 4px;
}

.entity-list::-webkit-scrollbar-track {
    background: transparent;
}

.entity-list::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 2px;
}

.entity-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    user-select: none;
}

.entity-chip:hover {
    transform: translateY(-1px);
}

.entity-chip.excluded {
    opacity: 0.35;
    text-decoration: line-through;
}

.entity-chip-checkbox {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 2px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.entity-chip-checkbox svg {
    width: 10px;
    height: 10px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.entity-chip:not(.excluded) .entity-chip-checkbox svg {
    opacity: 1;
}

.entity-chip-text {
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.entity-chip-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
}

.entity-chip-arrow {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.entity-chip-replacement {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 700;
}

.entity-chip-source {
    font-size: 0.6rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ---------- Output Panel ---------- */
.output-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    animation: slideUp 0.7s ease-out;
}

.output-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}

.output-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.output-text {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px;
    font-size: 0.9rem;
    line-height: 1.8;
    max-height: 500px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--font-sans);
}

.output-text::-webkit-scrollbar {
    width: 5px;
}

.output-text::-webkit-scrollbar-track {
    background: transparent;
}

.output-text::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 3px;
}

/* Highlighted replacements in output */
.anon-tag {
    display: inline;
    padding: 1px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}

.anon-tag.anon-gen {
    border: 1px dashed;
    border-color: inherit;
    font-style: italic;
}

/* GEN badge on entity chips (N2/N3 generalizations) */
.entity-chip-gen {
    font-size: 0.55rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    background: var(--orange-soft);
    color: var(--orange);
    border: 1px solid rgba(245, 158, 11, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ---------- FP Classifier confidence badges ---------- */
.entity-chip-confidence {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    cursor: help;
}
.entity-chip-confidence.low {
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.35);
}
.entity-chip-confidence.uncertain {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.entity-chip-confidence.filtered {
    background: rgba(109, 40, 217, 0.12);
    color: #7c3aed;
    border: 1px solid rgba(109, 40, 217, 0.25);
    opacity: 0.8;
}

/* ---------- Entity view toggle (Par type / Par source) ---------- */
.entity-view-toggle {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}
.entity-view-btn {
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.15s;
}
.entity-view-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* ---------- Source breakdown ---------- */
.source-breakdown { display: flex; flex-direction: column; gap: 6px; }
.source-section {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.source-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
    background: var(--bg-secondary);
    font-size: 0.82rem;
    font-weight: 500;
}
.source-summary:hover { background: var(--bg-hover); }
.source-icon { font-size: 1rem; }
.source-name { flex: 1; color: var(--text-primary); }
.source-count {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
}
.source-count.zero {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}
.source-items {
    padding: 8px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.source-empty {
    padding: 8px 12px;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
}
.source-entity-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 0.78rem;
    font-weight: 500;
}
.source-entity-label {
    font-size: 0.65rem;
    opacity: 0.75;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ---------- Comparison View ---------- */
.comparison-view {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0;
    margin-bottom: 16px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    animation: slideUp 0.4s ease-out;
}

.comparison-pane {
    padding: 16px;
    background: var(--bg-card);
    overflow-x: auto;
}

.comparison-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
}

.comparison-text {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.8;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
}

.comparison-divider {
    width: 2px;
    background: linear-gradient(180deg, var(--accent-primary), var(--accent-secondary));
    opacity: 0.5;
}

.btn-compare.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.btn-compare-gliner.active {
    background: #7c3aed;
    color: white;
    border-color: #7c3aed;
}

/* GLiNER compare extras */
.compare-count {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-tertiary);
    margin-left: 6px;
}

.compare-gliner-legend {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    padding: 4px 0 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.gliner-token-sample {
    display: inline-block;
    background: rgba(124, 58, 237, 0.15);
    border: 1px dashed #7c3aed;
    color: #7c3aed;
    border-radius: 4px;
    padding: 1px 6px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
}

.gliner-exclusive-mark {
    outline: 2px dashed #7c3aed;
    outline-offset: 1px;
    border-radius: 3px;
}

.gliner-compare-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px;
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

/* GLiNER compare toolbar */
.gliner-compare-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
}

.gliner-compare-summary {
    font-size: 0.85rem;
}

.diff-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.8rem;
}
.diff-badge.diff-found {
    background: rgba(124,58,237,0.15);
    color: #7c3aed;
    border: 1px solid rgba(124,58,237,0.3);
}
.diff-badge.diff-none {
    background: var(--bg-elevated);
    color: var(--text-tertiary);
    border: 1px solid var(--border-subtle);
}

.btn-show-diff.active {
    background: #7c3aed;
    color: white;
    border-color: #7c3aed;
}

/* GLiNER diff view */
.gliner-diff-view {
    border: 1px solid rgba(124,58,237,0.3);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 12px;
    animation: slideUp 0.3s ease-out;
}

.gliner-diff-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(124,58,237,0.1);
    font-size: 0.85rem;
    font-weight: 600;
    color: #7c3aed;
    border-bottom: 1px solid rgba(124,58,237,0.2);
}

.gliner-diff-list {
    padding: 12px 16px;
    background: var(--bg-card);
}

.diff-empty {
    color: var(--text-tertiary);
    font-size: 0.85rem;
    text-align: center;
    padding: 16px;
}

.diff-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.diff-table th {
    text-align: left;
    padding: 6px 12px;
    color: var(--text-tertiary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-subtle);
}
.diff-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}
.diff-table tr:last-child td {
    border-bottom: none;
}
.diff-orig {
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

/* Processing time badge */
.processing-time {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    background: var(--bg-card);
    color: var(--text-tertiary);
    border: 1px solid var(--border-subtle);
    margin-left: 12px;
    font-family: var(--font-mono);
}

/* ---------- Mapping Panel ---------- */
.mapping-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    animation: slideUp 0.8s ease-out;
}

.mapping-summary {
    padding: 16px 24px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
    list-style: none;
}

.mapping-summary::-webkit-details-marker {
    display: none;
}

.mapping-summary:hover {
    color: var(--text-primary);
}

.mapping-table-wrapper {
    padding: 0 24px 24px;
}

.mapping-table {
    width: 100%;
    border-collapse: collapse;
}

.mapping-table th {
    text-align: left;
    padding: 10px 16px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border-subtle);
}

.mapping-table td {
    padding: 10px 16px;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border-subtle);
}

.mapping-table tr:last-child td {
    border-bottom: none;
}

.mapping-table td:first-child {
    font-family: var(--font-mono);
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.mapping-table td:nth-child(2) {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--accent-primary-light);
    font-size: 0.82rem;
}

.mapping-table td:last-child { font-size: 0.8rem; }

.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.75rem;
    white-space: nowrap;
}
.source-badge.source-manual {
    background: rgba(168, 85, 247, 0.16);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.35);
}

/* ---------- Editable mapping table ---------- */
.mapping-toolbar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-secondary, #1a1a26);
    border: 1px solid var(--border-medium, rgba(255,255,255,0.08));
    border-radius: 8px;
    margin-bottom: 10px;
}
.mapping-add-toggle {
    align-self: flex-start;
    background: transparent;
    color: var(--accent, #818cf8);
    border: 1px dashed var(--accent, #818cf8);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
}
.mapping-add-toggle:hover { background: rgba(129, 140, 248, 0.10); }
.mapping-add-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding-top: 4px;
}
.mapping-add-form.hidden { display: none; }
.mapping-add-text {
    flex: 1 1 200px;
    padding: 6px 10px;
    background: var(--bg-card, #14141e);
    border: 1px solid var(--border-medium, rgba(255,255,255,0.12));
    border-radius: 6px;
    color: var(--text-primary, #f0f0f5);
    font-size: 0.85rem;
}
.mapping-add-label {
    padding: 6px 8px;
    background: var(--bg-card, #14141e);
    border: 1px solid var(--border-medium, rgba(255,255,255,0.12));
    border-radius: 6px;
    color: var(--text-primary, #f0f0f5);
    font-size: 0.85rem;
}
.mapping-add-confirm {
    padding: 6px 14px;
    background: var(--accent, #6366f1);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
}
.mapping-add-confirm:hover { filter: brightness(1.1); }
.mapping-add-cancel {
    padding: 6px 12px;
    background: transparent;
    color: var(--text-secondary, #94a3b8);
    border: 1px solid var(--border-medium, rgba(255,255,255,0.10));
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
}
.mapping-add-hint {
    flex: 1 0 100%;
    font-size: 0.78rem;
    color: var(--text-secondary, #94a3b8);
}
.mapping-add-hint.err { color: #ef4444; }

.mapping-type-select {
    padding: 3px 6px;
    background: var(--bg-card, #14141e);
    border: 1px solid var(--border-medium, rgba(255,255,255,0.10));
    border-radius: 4px;
    color: var(--text-primary, #f0f0f5);
    font-size: 0.78rem;
    cursor: pointer;
    max-width: 160px;
}
.mapping-type-select:hover { border-color: var(--accent, #818cf8); }

.mapping-del-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid rgba(239, 68, 68, 0.3);
    background: transparent;
    color: #ef4444;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s;
}
.mapping-del-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    transform: scale(1.05);
}

.mapping-replacement {
    background: rgba(99, 102, 241, 0.12);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-primary, #f0f0f5);
}

html[data-theme="light"] .mapping-toolbar { background: #f8fafc; border-color: #e2e8f0; }
html[data-theme="light"] .mapping-add-text,
html[data-theme="light"] .mapping-add-label,
html[data-theme="light"] .mapping-type-select { background: #fff; border-color: #cbd5e1; color: #1e293b; }
html[data-theme="light"] .mapping-add-hint { color: #475569; }

/* ---------- Reset Zone ---------- */
.reset-zone {
    text-align: center;
    padding: 16px 0;
}

/* ---------- Footer ---------- */
.footer {
    text-align: center;
    padding: 32px 24px;
    color: var(--text-muted);
    font-size: 0.82rem;
    border-top: 1px solid var(--border-subtle);
}

.footer-legal {
    margin-top: 16px !important;
    font-size: 0.78rem;
    color: var(--text-tertiary);
}
.footer-legal a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 150ms ease;
}
.footer-legal a:hover {
    color: var(--accent-primary-light);
}
.footer-sep {
    color: var(--text-muted);
    margin: 0 8px;
    opacity: 0.5;
}

.footer-sub {
    margin-top: 4px;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--green);
    color: #000;
    padding: 10px 24px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 1000;
    opacity: 0;
    transition: all var(--transition-base);
    box-shadow: 0 4px 20px rgba(0, 214, 143, 0.3);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-icon {
    font-size: 1.1rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
    .header-inner {
        padding: 12px 16px;
    }

    .header-badges {
        display: none;
    }

    .hero {
        padding: 28px 16px 18px;
    }

    .hero-subtitle {
        font-size: 0.95rem;
    }

    .app-container {
        padding: 20px 16px 60px;
    }

    .quality-gates {
        grid-template-columns: repeat(2, 1fr);
    }

    .level-buttons {
        grid-template-columns: 1fr;
    }

    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
    }

    .output-header {
        flex-direction: column;
    }

    .output-actions {
        width: 100%;
    }

    .output-actions .btn {
        flex: 1;
        justify-content: center;
        font-size: 0.8rem;
        padding: 8px 12px;
    }

    .entity-review {
        padding: 16px;
    }

    .comparison-view {
        grid-template-columns: 1fr;
    }

    .comparison-divider {
        width: 100%;
        height: 2px;
    }

    .residual-item {
        flex-wrap: wrap;
    }
}

/* ---------- AI Feedback Button ---------- */
.btn-feedback {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
    color: white !important;
    border: none !important;
}

.btn-feedback:hover {
    background: linear-gradient(135deg, #d97706, #b45309) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-feedback.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* ---------- AI Feedback Panel ---------- */
.feedback-panel {
    margin-top: 16px;
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.05), rgba(217, 119, 6, 0.03));
    overflow: hidden;
}

.feedback-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(245, 158, 11, 0.15);
    background: rgba(245, 158, 11, 0.08);
}

.feedback-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: #f59e0b;
}

.feedback-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.feedback-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.feedback-content {
    padding: 16px;
}

.feedback-loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 20px;
    font-style: italic;
}

.feedback-score {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
}

.feedback-score-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}

.feedback-score-value.score-good {
    color: #10b981;
}

.feedback-score-value.score-ok {
    color: #f59e0b;
}

.feedback-score-value.score-bad {
    color: #ef4444;
}

.feedback-score-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.feedback-summary {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
}

.feedback-section {
    margin-bottom: 12px;
}

.feedback-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.feedback-section-title.fp {
    color: #f59e0b;
}

.feedback-section-title.fn {
    color: #ef4444;
}

.feedback-item {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 4px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    font-size: 0.82rem;
}

.feedback-item-text {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.feedback-item-reason {
    color: var(--text-tertiary);
}

.feedback-empty {
    color: var(--text-tertiary);
    font-size: 0.82rem;
    font-style: italic;
    padding: 4px 0;
}

/* ========== Data Room ========== */
.tab-badge-new {
    font-size: 0.55rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: white;
    letter-spacing: 0.05em;
    margin-left: 6px;
    vertical-align: middle;
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.dataroom-header {
    text-align: center;
    margin-bottom: 24px;
}

.dataroom-title {
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.dataroom-desc {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.5;
}

.dataroom-drop {
    border: 2px dashed rgba(139, 92, 246, 0.3) !important;
    background: rgba(139, 92, 246, 0.03) !important;
}

.dataroom-drop:hover,
.dataroom-drop.drag-over {
    border-color: rgba(139, 92, 246, 0.6) !important;
    background: rgba(139, 92, 246, 0.08) !important;
}

.dataroom-docs {
    margin-top: 24px;
    animation: slideUp 0.5s ease-out;
}

.dataroom-docs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.dataroom-docs-header h3 {
    font-size: 1rem;
    font-weight: 700;
}

.dataroom-id {
    font-size: 0.7rem;
    font-family: var(--font-mono);
    color: var(--text-tertiary);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
}

.dataroom-doc-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.dataroom-doc-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    transition: all var(--transition-fast);
}

.dataroom-doc-card:hover {
    border-color: var(--border-medium);
    transform: translateY(-2px);
}

.dataroom-doc-card.success {
    border-left: 3px solid var(--green);
}

.dataroom-doc-card.error {
    border-left: 3px solid var(--red);
    opacity: 0.7;
}

.doc-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.doc-card-icon {
    font-size: 1.1rem;
}

.doc-card-name {
    font-weight: 600;
    font-size: 0.88rem;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-card-status {
    font-size: 0.9rem;
}

.doc-card-stats {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-bottom: 10px;
}

.doc-card-error {
    font-size: 0.8rem;
    color: var(--red);
}

.btn-sm {
    padding: 4px 12px !important;
    font-size: 0.75rem !important;
}

.dataroom-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.dataroom-mapping-panel {
    margin-top: 0;
}

/* Data Room Detail View */
.dataroom-detail-view {
    animation: slideUp 0.3s ease-out;
}

.dataroom-back-btn {
    margin-bottom: 16px;
    font-size: 0.85rem !important;
}

.dataroom-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.dataroom-detail-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.dataroom-detail-entities {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
}

.dataroom-detail-entities h4 {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.dataroom-detail-text {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
}

.dataroom-detail-text .output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.dataroom-detail-text h4 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.doc-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

/* Document badges in mapping table */
.doc-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    color: white;
    margin: 1px 2px;
    white-space: nowrap;
    font-family: var(--font-mono);
}

.doc-badges-cell {
    max-width: 200px;
    line-height: 1.8;
}

.text-muted {
    color: var(--text-muted);
}
/* ==========================================================================
   PROFILING BAR
   ========================================================================== */
.profiling-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px 20px;
    margin-bottom: 24px;
    animation: slideUp 0.4s ease-out;
}

.profiling-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    padding-right: 15px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
}

.profiling-items {
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
    align-items: center;
}

.profiling-item {
    display: flex;
    flex-direction: column;
}

.profiling-label {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.profiling-value {
    font-size: 14px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    color: #fff;
}

#profTotal { color: var(--accent); }

.profiling-sub .profiling-label { opacity: 0.6; font-size: 9px; }
.profiling-sub .profiling-value { font-size: 12px; font-weight: 400; opacity: 0.8; }

@media (max-width: 768px) {
    .profiling-bar { flex-direction: column; align-items: flex-start; gap: 12px; }
    .profiling-title { border-right: none; border-bottom: 1px solid rgba(255, 255, 255, 0.1); width: 100%; padding-bottom: 5px; }
    .profiling-items { gap: 15px; }
}

/* =========================================================================
   Auth Modal
   ========================================================================= */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 10, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.hidden { display: none; }

.modal-box {
    background: var(--bg-card, #14141e);
    border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.10));
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), 0 4px 12px rgba(0, 0, 0, 0.3);
    color: var(--text-primary, #f0f0f5);
}
html[data-theme="light"] .modal-box {
    background: #ffffff;
    border-color: #e2e8f0;
}

.auth-modal { text-align: center; }

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}

.auth-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.auth-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.auth-input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 16px;
    color: var(--text-primary);
    text-align: center;
    letter-spacing: 4px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.auth-input:focus { border-color: var(--accent); }

.auth-error {
    font-size: 13px;
    color: #ef4444;
    margin-top: 8px;
}

.auth-error.hidden { display: none; }

.auth-btn {
    width: 100%;
    margin-top: 16px;
}

.auth-toggle {
    margin-top: 14px;
    font-size: 13px;
    color: var(--text-muted);
}

.auth-toggle-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    margin-left: 4px;
}

.auth-toggle-link:hover { text-decoration: underline; }

/* =========================================================================
   Feedback FAB + Modal
   ========================================================================= */

.feedback-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, box-shadow 0.15s;
}

.feedback-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(139, 92, 246, 0.6);
}

.feedback-modal { max-width: 540px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
    line-height: 1;
}

.modal-close:hover { background: var(--surface-2); color: var(--text-primary); }

.form-group { margin-bottom: 20px; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-label .required { color: #ef4444; }

.form-input, .form-textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 14px;
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
    resize: vertical;
}

.form-textarea {
    min-height: 110px;
    line-height: 1.6;
}

.form-input:focus, .form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

.form-input::placeholder, .form-textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.feedback-cat-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.cat-btn {
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: 20px;
    padding: 7px 14px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    font-weight: 500;
}

.cat-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(139, 92, 246, 0.07); }

.cat-btn.active {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 700;
}

.feedback-include-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.feedback-include-text strong {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.feedback-include-text span {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.feedback-form-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 4px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.feedback-success {
    font-size: 13px;
    color: #22c55e;
    font-weight: 600;
}

.feedback-success.hidden { display: none; }

/* ── Beta feedback CTA ── */
.beta-feedback-cta {
    display: flex;
    align-items: center;
    gap: 16px;
    background: linear-gradient(135deg, rgba(124, 92, 252, 0.12), rgba(124, 92, 252, 0.06));
    border: 1.5px solid rgba(124, 92, 252, 0.35);
    border-radius: 14px;
    padding: 18px 22px;
    margin: 24px 0 8px;
}
.beta-feedback-icon { font-size: 2rem; flex-shrink: 0; }
.beta-feedback-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.4;
}
.beta-feedback-text strong { color: var(--text-primary); font-size: 0.95rem; }
.beta-feedback-btn { flex-shrink: 0; white-space: nowrap; }
@media (max-width: 600px) {
    .beta-feedback-cta { flex-direction: column; text-align: center; }
    .beta-feedback-btn { width: 100%; }
}

/* ── Role: test — éléments cachés pour les utilisateurs non-admin ── */
body.role-test .entity-view-toggle,
body.role-test #entityFilters,
body.role-test .gate-coverage,
body.role-test .gate-leakage,
body.role-test .entity-chip-source,
body.role-test .stat-card:has(#statPersons),
body.role-test .stat-card:has(#statOrgs),
body.role-test .stat-card:has(#statLocations),
body.role-test .stat-card:has(#statOther) {
    display: none !important;
}

/* Cache la colonne SOURCE de la table de correspondance pour les non-admin */
body.role-test .mapping-table th:nth-child(3),
body.role-test .mapping-table td:nth-child(3) {
    display: none !important;
}

/* ============================================================
   API Section
   ============================================================ */

.api-section { max-width: 740px; margin: 0 auto; }

.api-header { margin-bottom: 28px; }

.api-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 10px 0;
    color: var(--text-primary);
}

.api-subtitle {
    color: var(--text-secondary);
    font-size: 0.93rem;
    margin: 0;
    line-height: 1.55;
}

/* Empty state */
.api-empty-state {
    text-align: center;
    padding: 52px 24px;
    background: var(--bg-secondary);
    border: 2px dashed var(--border-medium);
    border-radius: var(--radius-lg);
}

.api-empty-icon {
    width: 68px;
    height: 68px;
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: 50%;
    opacity: 0.55;
}

.api-empty-text {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 6px;
}

.api-empty-sub {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin: 0 0 24px;
}

/* Key card */
.api-key-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    padding: 18px 22px;
    margin-bottom: 14px;
}

.api-key-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.api-key-card-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.api-plan-badge {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    background: rgba(74, 158, 255, 0.14);
    color: var(--accent-primary-light);
    border: 1px solid rgba(74, 158, 255, 0.3);
}

.api-key-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.api-key-display {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    letter-spacing: 0.03em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.api-key-warning {
    margin-top: 12px;
    font-size: 0.82rem;
    color: var(--orange);
    background: var(--orange-soft);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    line-height: 1.4;
}

/* Usage stats */
.api-usage-row {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.api-usage-card {
    flex: 1;
    min-width: 130px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
}

.api-usage-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.api-usage-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
}

.api-usage-limit {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-top: 3px;
}

/* Code examples */
.api-examples {
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 14px;
}

.api-examples-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-tertiary);
}

.api-examples-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.api-lang-tabs {
    display: flex;
    gap: 4px;
}

.api-lang-btn {
    font-size: 0.78rem;
    font-weight: 500;
    font-family: var(--font-mono);
    padding: 4px 11px;
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.api-lang-btn:hover { color: var(--text-primary); background: var(--bg-secondary); }

.api-lang-btn.active {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
}

.api-code-block {
    margin: 0;
    padding: 20px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.65;
    color: #cbd5e1;
    background: #111318;
    white-space: pre;
    overflow-x: auto;
    min-height: 140px;
}

.api-copy-code-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    opacity: 0.5;
    font-size: 0.74rem;
    padding: 4px 9px;
    background: var(--bg-tertiary) !important;
}

.api-copy-code-btn:hover { opacity: 1; }

/* Actions row */
.api-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.api-key-meta {
    font-size: 0.76rem;
    color: var(--text-tertiary);
}

/* Loading */
.api-loading {
    padding: 36px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ---------- Entity presets (one-click masking scheme) ---------- */
.entity-presets {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 12px 0 14px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}
.entity-presets-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 4px;
}
.entity-preset-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    color: var(--text-secondary);
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast),
                border-color var(--transition-fast);
}
.entity-preset-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}
.entity-preset-btn.active {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
}
.entity-preset-btn.entity-preset-recommended {
    border-color: rgba(245, 158, 11, 0.4);
    position: relative;
}
.entity-preset-btn.entity-preset-recommended::after {
    content: "✦";
    position: absolute;
    top: -3px;
    right: -3px;
    font-size: 0.65rem;
    color: #f59e0b;
}
.entity-preset-btn.entity-preset-recommended.active {
    background: #f59e0b;
    border-color: #f59e0b;
}
@media (max-width: 640px) {
    .entity-presets { padding: 8px 10px; }
    .entity-preset-btn { font-size: 0.76rem; padding: 4px 10px; }
}

/* ---------- Language warning banner (non-FR docs) ---------- */
.lang-warning {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px 12px 16px;
    margin: 0 0 16px 0;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.10), rgba(251, 191, 36, 0.05));
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-left: 4px solid #f59e0b;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.88rem;
    line-height: 1.5;
}
.lang-warning.hidden { display: none; }
.lang-warning-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    line-height: 1.4;
}
.lang-warning-body {
    flex: 1;
}
.lang-warning-body strong {
    color: #fbbf24;
}
.lang-warning-close {
    background: transparent;
    border: 0;
    color: var(--text-tertiary);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    align-self: flex-start;
    transition: color var(--transition-fast);
}
.lang-warning-close:hover { color: var(--text-primary); }

/* ===========================================================================
   v1.4 — User menu, compact view, admin polish
   =========================================================================== */

/* ---------- Hero collapse on Admin/API/Restore/Dataroom ---------- */
body.compact-view .hero {
    padding: 16px 24px 0;
}
body.compact-view .hero h1 {
    display: none;
}
body.compact-view .hero-subtitle,
body.compact-view .hero-glow {
    display: none;
}
/* Onboarding 3-step guide is irrelevant outside the anonymize flow */
body.compact-view #onboardingBanner {
    display: none !important;
}

/* ---------- Theme toggle button (header) ---------- */
.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-left: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    color: var(--text-secondary);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.theme-toggle-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}
/* ---------- Language picker (header dropdown with flags) ---------- */
.lang-picker { position: relative; display: inline-flex; }
.lang-picker-trigger {
    width: auto;
    padding: 0 9px;
    gap: 5px;
}
.lang-flag { font-size: 0.95rem; line-height: 1; }
.lang-code { font-size: 0.74rem; font-weight: 700; letter-spacing: 0.02em; }
.lang-caret { opacity: 0.55; transition: transform 0.15s; }
.lang-picker-trigger[aria-expanded="true"] .lang-caret { transform: rotate(180deg); }
.lang-picker-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 168px;
    padding: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.lang-picker-menu.hidden { display: none; }
.lang-picker-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.86rem;
    text-align: left;
    width: 100%;
    transition: background 0.12s, color 0.12s;
}
.lang-picker-option:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.lang-picker-option.active { color: var(--accent-primary); font-weight: 600; }
.lang-picker-option .lang-flag { font-size: 1.15rem; }
.lang-picker-option .lang-check { margin-left: auto; opacity: 0; flex-shrink: 0; }
.lang-picker-option.active .lang-check { opacity: 1; }

.theme-toggle-btn .theme-icon-moon,
.theme-toggle-btn .theme-icon-sun { display: none; }
/* Dark mode active → show sun (clic = passer au clair) */
.theme-toggle-btn[data-theme="dark"] .theme-icon-sun { display: block; }
/* Light mode active → show moon (clic = passer au sombre) */
.theme-toggle-btn[data-theme="light"] .theme-icon-moon { display: block; }

/* ---------- User menu (header) ---------- */
.user-menu {
    position: relative;
    margin-left: 12px;
}
.user-menu.hidden { display: none; }

.user-menu-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    border-radius: var(--radius-full);
    padding: 4px 12px 4px 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}
.user-menu-trigger:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-strong);
}
.user-menu-trigger.open {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
}

.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: white;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
}

.user-email {
    color: var(--text-secondary);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Credits badge in header — shows remaining monthly pages/docs */
.credits-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px 5px 10px;
    margin-right: 8px;
    background: linear-gradient(135deg, rgba(74,158,255,0.14), rgba(168,85,247,0.14));
    border: 1px solid rgba(74,158,255,0.32);
    border-radius: 999px;
    color: var(--text-primary, #f0f0f5);
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
}
.credits-badge:hover { background: linear-gradient(135deg, rgba(74,158,255,0.22), rgba(168,85,247,0.22)); transform: translateY(-1px); }
.credits-badge.low { border-color: rgba(245,158,11,0.45); background: linear-gradient(135deg, rgba(245,158,11,0.16), rgba(239,68,68,0.10)); }
.credits-badge.empty { border-color: rgba(239,68,68,0.55); background: linear-gradient(135deg, rgba(239,68,68,0.20), rgba(239,68,68,0.10)); }
.credits-icon { font-size: 0.95rem; line-height: 1; }
.credits-text { line-height: 1; white-space: nowrap; }
.credits-plus {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(74,158,255,0.30);
    color: white;
    font-size: 0.85rem;
    line-height: 1;
    margin-left: 2px;
}
.credits-badge.unlimited .credits-plus { display: none; }
@media (max-width: 700px) { .credits-badge { padding: 4px 8px; font-size: 0.72rem; } .credits-plus { width: 16px; height: 16px; } }
@media (max-width: 480px) {
    /* On phones, collapse credits text — keep icon + number only */
    .credits-text { font-size: 0.7rem; }
    .credits-badge .credits-text { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    /* Avoid header overflow when credits + theme + menu all visible */
    .header-inner { gap: 6px; }
}

.user-chevron {
    color: var(--text-tertiary);
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}
.user-menu-trigger.open .user-chevron {
    transform: rotate(180deg);
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 240px;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 200;
    animation: dropdown-in 160ms ease;
}
.user-menu-dropdown.hidden { display: none; }

@keyframes dropdown-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-menu-info {
    padding: 10px 12px 12px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 4px;
}
.user-menu-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-menu-mail {
    font-size: 0.76rem;
    color: var(--text-secondary);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-menu-role {
    display: inline-block;
    margin-top: 6px;
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}
.user-menu-role[data-role="admin"] {
    background: linear-gradient(135deg, rgba(74, 158, 255, 0.2), rgba(14, 165, 255, 0.2));
    color: var(--accent-primary-light);
    border: 1px solid rgba(74, 158, 255, 0.3);
}
.user-menu-role[data-role="user"] {
    background: var(--green-soft);
    color: var(--green);
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    transition: background var(--transition-fast), color var(--transition-fast);
    text-align: left;
}
.user-menu-item:hover {
    background: var(--bg-card-hover);
    color: var(--accent-primary-light);
}

/* Language selector inside user menu */
.user-menu-lang {
    padding: 8px 12px 6px;
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
    margin: 4px 0;
}
.user-menu-lang-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}
.user-menu-lang-options {
    display: flex;
    gap: 4px;
}
.lang-option {
    flex: 1;
    background: transparent;
    border: 1px solid var(--border-medium);
    color: var(--text-secondary);
    padding: 5px 0;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.lang-option:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}
.lang-option.active {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
}

/* ---------- Admin dashboard polish ---------- */
.admin-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 18px 16px;
    text-align: center;
    transition: border-color var(--transition-base), transform var(--transition-base), box-shadow var(--transition-base);
    position: relative;
    overflow: hidden;
}
.admin-stat-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(74, 158, 255, 0.06), transparent 60%);
    opacity: 0;
    transition: opacity var(--transition-base);
    pointer-events: none;
}
.admin-stat-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.admin-stat-card:hover::before { opacity: 1; }

.admin-stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1;
}
.admin-stat-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 8px;
    font-weight: 500;
}
.admin-stat-sub {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.admin-source-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    min-width: 180px;
    flex: 1;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}
.admin-source-card:hover {
    border-color: var(--border-medium);
    background: var(--bg-card-hover);
}
.admin-source-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.admin-source-name {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-primary);
}
.admin-source-count {
    font-size: 0.84rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}
.admin-source-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 999px;
    overflow: hidden;
}
.admin-source-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 600ms cubic-bezier(0.16, 1, 0.3, 1);
}
.admin-source-excl {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    margin-top: 6px;
}

/* ---------- Admin analyses table ---------- */
.admin-table-wrap {
    overflow-x: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-top: 8px;
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-family: inherit;
    font-size: 0.85rem;
}
.admin-table thead {
    background: var(--bg-tertiary);
    position: sticky;
    top: 0;
    z-index: 1;
}
.admin-table thead th {
    padding: 12px 14px;
    text-align: left;
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}
.admin-table thead th.th-num { text-align: center; }
.admin-table tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition-fast);
}
.admin-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.015);
}
.admin-table tbody tr:hover {
    background: rgba(74, 158, 255, 0.06);
}
.admin-table tbody tr:last-child { border-bottom: none; }
.admin-table td {
    padding: 11px 14px;
    color: var(--text-primary);
    vertical-align: middle;
}
.admin-table td.td-muted { color: var(--text-secondary); font-size: 0.82rem; }
.admin-table td.td-num   { text-align: center; font-variant-numeric: tabular-nums; font-weight: 500; }
.admin-table td.td-mode  { font-size: 0.8rem; color: var(--text-secondary); white-space: nowrap; }

.admin-src-pill {
    display: inline-block;
    font-size: 0.72rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 2px 8px;
    color: var(--text-secondary);
    margin: 1px 2px 1px 0;
    font-variant-numeric: tabular-nums;
}

/* ---------- Copy prompt template dropdown ---------- */
.copy-prompt-group {
    display: inline-flex;
    position: relative;
}
.copy-prompt-main {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    margin-right: 0 !important;
}
.copy-prompt-toggle {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-left: 1px solid var(--border-medium) !important;
    padding: 0 8px !important;
    min-width: 28px;
}
.copy-prompt-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 280px;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 200;
    animation: dropdown-in 160ms ease;
}
.copy-prompt-menu.hidden { display: none; }
.copy-prompt-menu button {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    text-align: left;
    transition: background var(--transition-fast);
}
.copy-prompt-menu button span {
    color: var(--text-tertiary);
    font-size: 0.76rem;
    font-weight: 400;
}
.copy-prompt-menu button:hover {
    background: var(--bg-card-hover);
}
.copy-prompt-menu button.active {
    background: rgba(74, 158, 255, 0.12);
    color: var(--accent-primary-light);
}
.copy-prompt-menu button.active span {
    color: rgba(14, 165, 255, 0.7);
}

/* ---------- Download grouped dropdown ---------- */
.download-group {
    display: inline-flex;
    position: relative;
}
.download-main {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.download-caret {
    opacity: 0.7;
}
.download-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 280px;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 200;
    animation: dropdown-in 160ms ease;
}
.download-menu.hidden { display: none; }
.download-menu-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    text-align: left;
    transition: background var(--transition-fast);
}
.download-menu-item:hover {
    background: var(--bg-card-hover);
}
.download-menu-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    color: var(--accent-primary);
}
.download-menu-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.download-menu-hint {
    color: var(--text-tertiary);
    font-size: 0.76rem;
    font-weight: 400;
}

/* ---------- Generic button loading state ---------- */
button[data-loading="1"],
.profile-btn-primary[data-loading="1"],
.btn[data-loading="1"] {
    pointer-events: none;
    opacity: 0.7;
    position: relative;
    color: transparent !important;
}
button[data-loading="1"]::after,
.profile-btn-primary[data-loading="1"]::after,
.btn[data-loading="1"]::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: btn-spin 0.7s linear infinite;
}
@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

/* ---------- Tab transitions (fade-in zone) ---------- */
.input-zone {
    animation: tab-fade 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes tab-fade {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
/* Avoid flicker on the always-active default tab on first load */
.input-zone.hidden { animation: none; }

/* ---------- Admin search input ---------- */
.admin-search-wrap {
    position: relative;
    margin-bottom: 12px;
    max-width: 480px;
}
.admin-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}
.admin-search-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    padding: 8px 36px 8px 36px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.admin-search-input::placeholder {
    color: var(--text-tertiary);
}
.admin-search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.15);
}
.admin-search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background var(--transition-fast), color var(--transition-fast);
    user-select: none;
}
.admin-search-clear:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

/* ---------- Mobile adjustments ---------- */
@media (max-width: 720px) {
    .user-email { display: none; }
    .user-menu-trigger { padding: 4px 8px 4px 4px; }
    .header-badges { gap: 6px; }
    .header-badges .badge { font-size: 0.7rem; padding: 4px 8px; }
}

/* ---------- Profile modal ---------- */
.profile-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(5, 5, 10, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: overlay-fade 180ms ease;
}
.profile-overlay.hidden { display: none; }
@keyframes overlay-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.profile-modal {
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 0;
    animation: modal-rise 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modal-rise {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.profile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}
.profile-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}
.profile-close {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
.profile-close:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-subtle);
}

.profile-tabs {
    display: flex;
    gap: 4px;
    padding: 16px 24px 0;
    border-bottom: 1px solid var(--border-subtle);
}
.profile-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 10px 16px;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}
.profile-tab:hover { color: var(--text-primary); }
.profile-tab.active {
    color: var(--accent-primary-light);
    border-bottom-color: var(--accent-primary);
}

.profile-pane {
    display: none;
    padding: 24px;
}
.profile-pane.active { display: block; }

.profile-field {
    margin-bottom: 14px;
    flex: 1;
}
.profile-field label {
    display: block;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.profile-field input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.92rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.profile-field input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.15);
}
.profile-field input:disabled {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: not-allowed;
}
.profile-field-row {
    display: flex;
    gap: 12px;
}
.profile-field-row .profile-field { margin-bottom: 14px; }

.profile-actions {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.profile-btn-primary,
.profile-btn-secondary {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--transition-fast), filter var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
    border: none;
}
.profile-btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 16px rgba(74, 158, 255, 0.3);
}
.profile-btn-primary:hover { transform: translateY(-1px); filter: brightness(1.07); }
.profile-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; filter: none; }

.profile-btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
}
.profile-btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--border-strong); }

.profile-feedback {
    margin-top: 12px;
    font-size: 0.85rem;
    min-height: 1.2em;
}
.profile-feedback.success { color: var(--green); }
.profile-feedback.error   { color: var(--red); }

/* ---------- Org pane ---------- */
.org-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 18px;
    margin-bottom: 12px;
}
.org-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.org-card-meta {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.org-invite-code {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: 1px dashed var(--border-medium);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--accent-primary-light);
}
.org-invite-code .code-label {
    color: var(--text-tertiary);
    font-size: 0.78rem;
    margin-right: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-family: var(--font-sans);
}
.org-copy-btn {
    margin-left: auto;
    background: transparent;
    border: 1px solid var(--border-medium);
    color: var(--text-secondary);
    border-radius: 6px;
    padding: 4px 10px;
    font-family: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.org-copy-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.org-members-list {
    margin-top: 14px;
    border-top: 1px solid var(--border-subtle);
    padding-top: 12px;
}
.org-member {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 0.88rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.org-member:last-child { border-bottom: none; }
.org-member-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-card-hover);
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
}
.org-member-name { flex: 1; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-member-role {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.org-mode-switcher {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 4px;
}
.org-mode-switcher button {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.org-mode-switcher button.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

@media (max-width: 600px) {
    .profile-modal { max-width: 100%; }
    .profile-field-row { flex-direction: column; gap: 0; }
}

/* ---------- Info mark with hover tooltip ---------- */
.info-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 6px;
    cursor: help;
    position: relative;
    transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
    user-select: none;
    flex-shrink: 0;
}
.info-mark:hover,
.info-mark:focus {
    background: rgba(74, 158, 255, 0.18);
    border-color: rgba(14, 165, 255, 0.5);
    color: var(--accent-primary-light);
    outline: none;
}

.info-tooltip {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    width: 320px;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 400;
    line-height: 1.5;
    text-align: left;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 100;
    transition: opacity 180ms ease, transform 180ms ease;
}
.info-tooltip strong {
    color: var(--accent-primary-light);
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
}
.info-tooltip code {
    background: var(--bg-tertiary);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.78rem;
    color: #e9d5ff;
}
.info-tooltip em {
    color: var(--text-tertiary);
    font-style: italic;
    font-size: 0.78rem;
}
.info-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--border-medium);
}
.info-mark:hover .info-tooltip,
.info-mark:focus .info-tooltip {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Aligned right edge tooltip (when the mark is near the right edge of viewport) */
.info-mark.right .info-tooltip {
    left: auto;
    right: 0;
    transform: translateY(4px);
}
.info-mark.right .info-tooltip::after {
    left: auto;
    right: 8px;
    transform: none;
}
.info-mark.right:hover .info-tooltip,
.info-mark.right:focus .info-tooltip {
    transform: translateY(0);
}

/* ---------- FP classifier section (admin only) ---------- */
.fp-section {
    margin-top: 14px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(74, 158, 255, 0.06), rgba(14, 165, 255, 0.04));
    border: 1px dashed rgba(14, 165, 255, 0.3);
    border-radius: var(--radius-md);
}
.fp-section-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.fp-section-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.fp-section-badge {
    font-size: 0.78rem;
    font-weight: 700;
    background: linear-gradient(135deg, #4a9eff, #0ea5ff);
    color: white;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    letter-spacing: 0.02em;
    cursor: help;
}
.fp-section-count {
    font-size: 0.78rem;
    color: var(--accent-primary-light);
    font-weight: 600;
    background: rgba(74, 158, 255, 0.12);
    padding: 3px 9px;
    border-radius: var(--radius-full);
}
.fp-section-count-zero {
    color: var(--text-tertiary);
    background: rgba(255, 255, 255, 0.03);
    font-weight: 500;
}
.fp-section-subtitle {
    display: block;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-bottom: 10px;
    font-style: italic;
}
.fp-section-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

/* Filtered chips become clickable buttons (admin can reactivate) */
.fp-filtered-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
    opacity: 0.7;
}
.fp-filtered-chip .entity-chip-text {
    text-decoration: line-through;
    text-decoration-thickness: 1.5px;
}
.fp-filtered-chip:hover {
    background: var(--bg-card-hover);
    border-color: rgba(14, 165, 255, 0.5);
    opacity: 1;
    transform: translateY(-1px);
}

/* Reactivated state — admin clicked to force this entity back into anonymization */
.fp-filtered-chip.fp-reactivated {
    background: linear-gradient(135deg, rgba(74, 158, 255, 0.18), rgba(14, 165, 255, 0.12));
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 1px rgba(74, 158, 255, 0.3) inset;
    opacity: 1;
}
.fp-filtered-chip.fp-reactivated .entity-chip-text {
    text-decoration: none;
    font-weight: 500;
}
.fp-filtered-chip.fp-reactivated::after {
    content: "✓ réactivé";
    margin-left: 4px;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--accent-primary-light);
    background: rgba(74, 158, 255, 0.15);
    padding: 1px 6px;
    border-radius: var(--radius-full);
}

/* LLM gate recommended this entity to be reactivated */
.fp-filtered-chip.fp-llm-recommended {
    border-color: rgba(245, 158, 11, 0.5);
    background: rgba(245, 158, 11, 0.06);
}
.llm-rec-badge {
    display: inline-block;
    margin-left: 6px;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--orange);
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    padding: 1px 6px;
    border-radius: var(--radius-full);
    cursor: help;
}

.entity-chip-confidence.filtered {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
    margin-left: 4px;
}

/* ---------- FP Feedback admin journal ---------- */
.fp-fb-stat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
}
.fp-fb-stat b { color: var(--text-primary); font-weight: 700; }
.fp-fb-stat-total b      { color: var(--accent-primary-light); }
.fp-fb-stat-reactivate b { color: var(--green); }
.fp-fb-stat-confirm b    { color: var(--orange); }

.verdict-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.74rem;
    font-weight: 600;
    white-space: nowrap;
}
.verdict-reactivate {
    background: rgba(0, 214, 143, 0.12);
    color: var(--green);
    border: 1px solid rgba(0, 214, 143, 0.3);
}
.verdict-undo {
    background: rgba(245, 158, 11, 0.12);
    color: var(--orange);
    border: 1px solid rgba(245, 158, 11, 0.3);
}
.verdict-confirm {
    background: rgba(74, 158, 255, 0.12);
    color: var(--accent-primary-light);
    border: 1px solid rgba(74, 158, 255, 0.3);
}

.admin-table mark {
    background: rgba(14, 165, 255, 0.25);
    color: var(--accent-primary-light);
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 600;
}

/* ---------- Confirm modal (replaces window.confirm) ---------- */
.confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 600;
    background: rgba(5, 5, 10, 0.78);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: overlay-fade 160ms ease;
}
.confirm-overlay.hidden { display: none; }

.confirm-modal {
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 420px;
    padding: 28px 24px 22px;
    text-align: center;
    animation: modal-rise 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.confirm-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(74, 158, 255, 0.12);
    color: var(--accent-primary-light);
    margin-bottom: 14px;
}
.confirm-icon-danger {
    background: rgba(239, 68, 68, 0.12);
    color: var(--red);
}
.confirm-modal h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 8px;
}
.confirm-modal p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0 0 18px;
}
.confirm-typed-wrap {
    margin-bottom: 16px;
    text-align: left;
}
.confirm-typed-wrap.hidden { display: none; }
.confirm-typed-wrap label {
    display: block;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.confirm-typed-wrap input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.92rem;
    letter-spacing: 0.05em;
    transition: border-color var(--transition-fast);
}
.confirm-typed-wrap input:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}
.confirm-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}
.confirm-btn-cancel,
.confirm-btn-ok {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: transform 150ms ease, filter 150ms ease, background 150ms ease;
    min-width: 110px;
}
.confirm-btn-cancel {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
}
.confirm-btn-cancel:hover {
    background: var(--bg-card-hover);
}
.confirm-btn-ok {
    background: var(--accent-gradient);
    color: white;
}
.confirm-btn-ok:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: brightness(1.07);
}
.confirm-btn-ok:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.confirm-btn-ok.confirm-btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

/* ---------- RGPD pane in profile ---------- */
.rgpd-section {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    margin-bottom: 14px;
}
.rgpd-section h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px;
}
.rgpd-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 12px;
}
.rgpd-list {
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding-left: 20px;
    line-height: 1.6;
}
.rgpd-list em { color: var(--text-primary); font-style: normal; font-weight: 500; }

.rgpd-toggle {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    padding: 10px;
    border-radius: var(--radius-sm);
    transition: background 150ms ease;
}
.rgpd-toggle:hover { background: rgba(255,255,255,0.02); }
.rgpd-toggle input { display: none; }
.rgpd-toggle .toggle-knob {
    flex-shrink: 0;
    width: 36px;
    height: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: 10px;
    position: relative;
    transition: background 150ms ease;
    margin-top: 2px;
}
.rgpd-toggle .toggle-knob::after {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--text-secondary);
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1), background 150ms ease;
}
.rgpd-toggle input:checked + .toggle-knob {
    background: var(--accent-gradient);
    border-color: transparent;
}
.rgpd-toggle input:checked + .toggle-knob::after {
    transform: translateX(16px);
    background: white;
}
.rgpd-toggle span:last-child {
    color: var(--text-primary);
    font-size: 0.88rem;
    line-height: 1.4;
}
.rgpd-meta {
    font-size: 0.76rem;
    color: var(--text-tertiary);
    margin-top: 6px;
    padding-left: 10px;
}

.rgpd-section-danger {
    border-color: rgba(239, 68, 68, 0.2);
    background: rgba(239, 68, 68, 0.03);
}

.rgpd-section-beta {
    border-color: rgba(245, 158, 11, 0.3);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.06), rgba(236, 72, 153, 0.03));
}
.rgpd-section-beta.hidden { display: none; }
.beta-badge-large {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--orange), var(--pink));
    color: white;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.25);
}
.user-menu-role[data-role="beta"] {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(236, 72, 153, 0.2));
    color: var(--orange);
    border: 1px solid rgba(245, 158, 11, 0.3);
}
.rgpd-btn-primary {
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 150ms ease, transform 150ms ease;
    border: 1px solid rgba(74, 158, 255, 0.4);
    background: rgba(74, 158, 255, 0.12);
    color: var(--accent-primary-light, #6eb3ff);
}
.rgpd-btn-primary:hover { background: rgba(74, 158, 255, 0.22); transform: translateY(-1px); }
.rgpd-btn-primary:disabled { opacity: 0.6; cursor: wait; transform: none; }

.rgpd-btn-warn,
.rgpd-btn-danger {
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 150ms ease, transform 150ms ease;
    border: 1px solid;
}
.rgpd-btn-warn {
    background: rgba(245, 158, 11, 0.1);
    color: var(--orange);
    border-color: rgba(245, 158, 11, 0.3);
}
.rgpd-btn-warn:hover {
    background: rgba(245, 158, 11, 0.18);
    transform: translateY(-1px);
}
.rgpd-btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--red);
    border-color: rgba(239, 68, 68, 0.3);
}
.rgpd-btn-danger:hover {
    background: rgba(239, 68, 68, 0.18);
    transform: translateY(-1px);
}

/* ---------- Onboarding banner (1st visit) ---------- */
.onboarding-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: linear-gradient(135deg, rgba(74, 158, 255, 0.08), rgba(14, 165, 255, 0.04));
    border: 1px solid rgba(14, 165, 255, 0.2);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 20px;
    position: relative;
    flex-wrap: wrap;
    animation: ob-fade-in 220ms ease;
}
@keyframes ob-fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
.onboarding-banner.hidden { display: none; }
.onboarding-step {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 220px;
}
.onboarding-step-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
}
.onboarding-step-body {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    min-width: 0;
}
.onboarding-step-body strong {
    color: var(--text-primary);
    font-size: 0.92rem;
    font-weight: 600;
}
.onboarding-step-body span {
    color: var(--text-secondary);
    font-size: 0.78rem;
}
.onboarding-arrow {
    color: var(--text-tertiary);
    font-size: 1.1rem;
    user-select: none;
}
.onboarding-close {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 150ms ease, color 150ms ease;
}
.onboarding-close:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}
@media (max-width: 720px) {
    .onboarding-arrow { display: none; }
    .onboarding-banner { flex-direction: column; align-items: flex-start; }
}

/* ---------- User history ---------- */
.history-empty {
    text-align: center;
    padding: 28px 16px;
    color: var(--text-secondary);
}
.history-empty p { margin: 4px 0; font-size: 0.9rem; }
.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 60vh;
    overflow-y: auto;
}
.history-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}
.history-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-medium);
}
.history-item-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 4px;
}
.history-item-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}
.history-item-date {
    color: var(--text-tertiary);
    font-size: 0.75rem;
    white-space: nowrap;
}
.history-item-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: var(--text-secondary);
}
.history-item-meta b {
    color: var(--accent-primary-light);
    font-weight: 600;
}

/* ---------- Paste helper (example buttons) ---------- */
.paste-helper {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.paste-helper-text {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-right: 4px;
}
.paste-example-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-family: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}
.paste-example-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}
@media (max-width: 640px) {
    .paste-helper { flex-wrap: wrap; row-gap: 6px; }
    .paste-helper-text { flex-basis: 100%; }
    .paste-example-btn { font-size: 0.78rem; padding: 5px 10px; }
}

/* ---------- FP Feedback quality dashboard (admin) ---------- */
.quality-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 12px;
}
.quality-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px 16px;
}
.quality-card-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 12px;
}
.quality-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.quality-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    padding: 4px 10px;
    font-size: 0.82rem;
    color: var(--text-primary);
}
.quality-pill-count {
    color: var(--accent-primary-light);
    font-weight: 700;
    font-size: 0.78rem;
    margin-left: 4px;
    background: rgba(74, 158, 255, 0.15);
    padding: 1px 7px;
    border-radius: var(--radius-full);
}

.quality-bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 100px;
    margin-bottom: 8px;
}
.quality-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: help;
    min-width: 0;
}
.quality-bar-stack {
    width: 100%;
    height: 80px;
    display: flex;
    flex-direction: column-reverse;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
    overflow: hidden;
}
.quality-bar-r {
    background: linear-gradient(180deg, var(--green), rgba(0, 214, 143, 0.6));
    transition: height 600ms cubic-bezier(0.16, 1, 0.3, 1);
}
.quality-bar-c {
    background: linear-gradient(180deg, var(--accent-primary), rgba(74, 158, 255, 0.6));
    transition: height 600ms cubic-bezier(0.16, 1, 0.3, 1);
}
.quality-bar-label {
    font-size: 0.62rem;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.quality-bars-legend {
    display: flex;
    gap: 12px;
    font-size: 0.74rem;
    color: var(--text-secondary);
}
.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 4px;
    vertical-align: middle;
}
.legend-r { background: var(--green); }
.legend-c { background: var(--accent-primary); }

/* ---------- Document type badge (admin only) ---------- */
.doc-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 12px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.doc-type-text b {
    color: var(--text-primary);
    font-weight: 600;
}
.doc-type-conf {
    font-size: 0.72rem;
    color: var(--accent-primary-light);
    background: rgba(74, 158, 255, 0.15);
    padding: 1px 8px;
    border-radius: var(--radius-full);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* ===========================================================================
   Chat widget (pre-sales assistant) — bottom-right floating bubble + panel
   =========================================================================== */
/* En bas à GAUCHE pour ne pas entrer en conflit avec le bouton "Partager un retour"
   et autres widgets éventuels (Sentry, hotjar) qui squattent classiquement bottom-right. */
#sd-chat-root { position: fixed; bottom: 20px; left: 20px; z-index: 9999; }

.sd-chat-bubble {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(74, 158, 255, 0.40), 0 2px 6px rgba(0,0,0,0.20);
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    position: relative;
}
.sd-chat-bubble:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 8px 28px rgba(74, 158, 255, 0.55), 0 2px 8px rgba(0,0,0,0.25); }
.sd-chat-bubble--open svg { transform: rotate(-90deg); transition: transform 0.2s; }
.sd-chat-dot {
    position: absolute; top: 6px; right: 6px;
    width: 12px; height: 12px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid white;
    animation: sd-pulse 1.8s ease-in-out infinite;
}
@keyframes sd-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.75; }
}

.sd-chat-panel {
    position: absolute; bottom: 72px; left: 0;
    width: 360px; max-width: calc(100vw - 32px);
    height: 540px; max-height: calc(100vh - 100px);
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    box-shadow: 0 16px 48px rgba(0,0,0,0.45), 0 4px 12px rgba(0,0,0,0.25);
    display: flex; flex-direction: column;
    overflow: hidden;
    animation: sd-slide-in 0.22s ease-out;
    font-family: var(--font-sans);
}
@keyframes sd-slide-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.sd-chat-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-subtle);
}
.sd-chat-header-left { display: flex; align-items: center; gap: 10px; }
.sd-chat-avatar {
    width: 36px; height: 36px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    box-shadow: var(--shadow-glow);
}
.sd-chat-title { font-size: 0.95rem; font-weight: 700; color: var(--text-primary); line-height: 1.1; }
.sd-chat-status {
    font-size: 0.7rem; color: var(--text-tertiary);
    display: flex; align-items: center; gap: 5px; margin-top: 2px;
}
.sd-chat-dot-online {
    width: 7px; height: 7px;
    background: #10b981; border-radius: 50%;
    box-shadow: 0 0 4px #10b981;
}
.sd-chat-close {
    background: transparent; border: none;
    color: var(--text-secondary); cursor: pointer;
    font-size: 1.6rem; line-height: 1; padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background 0.15s, color 0.15s;
}
.sd-chat-close:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.sd-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex; flex-direction: column; gap: 10px;
    background: var(--bg-primary);
}
.sd-msg { display: flex; max-width: 100%; }
.sd-msg--bot { justify-content: flex-start; }
.sd-msg--user { justify-content: flex-end; }
.sd-msg-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.86rem;
    line-height: 1.45;
    word-wrap: break-word;
}
.sd-msg--bot .sd-msg-bubble {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-bottom-left-radius: 4px;
}
.sd-msg--user .sd-msg-bubble {
    background: var(--accent-gradient);
    color: white;
    border-bottom-right-radius: 4px;
}
.sd-msg-meta {
    align-self: center;
    font-size: 0.7rem;
    color: var(--text-tertiary);
    padding: 2px 10px;
    background: rgba(16, 185, 129, 0.10);
    border-radius: var(--radius-full);
}
.sd-typing { display: flex; gap: 4px; padding: 14px 16px; }
.sd-typing span {
    width: 6px; height: 6px;
    background: var(--text-tertiary);
    border-radius: 50%;
    animation: sd-typing-bounce 1.2s ease-in-out infinite;
}
.sd-typing span:nth-child(2) { animation-delay: 0.15s; }
.sd-typing span:nth-child(3) { animation-delay: 0.30s; }
@keyframes sd-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

.sd-chat-suggestions {
    padding: 0 14px 8px;
    display: flex; gap: 6px; flex-wrap: wrap;
    background: var(--bg-primary);
}
.sd-suggest {
    background: var(--bg-card);
    color: var(--accent-primary);
    border: 1px solid var(--border-medium);
    padding: 5px 11px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s;
}
.sd-suggest:hover {
    background: rgba(74, 158, 255, 0.10);
    border-color: var(--accent-primary);
}

.sd-chat-form {
    display: flex; align-items: flex-end; gap: 8px;
    padding: 12px 14px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-subtle);
}
.sd-chat-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    font-family: inherit;
    font-size: 0.85rem;
    resize: none;
    line-height: 1.4;
    max-height: 100px;
    min-height: 36px;
}
.sd-chat-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.12);
}
.sd-chat-send {
    background: var(--accent-gradient);
    color: white;
    border: none;
    width: 36px; height: 36px;
    border-radius: var(--radius-md);
    cursor: pointer;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.15s;
}
.sd-chat-send:hover { transform: scale(1.08); }
.sd-chat-footnote {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    text-align: center;
    padding: 6px 12px 10px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-subtle);
}

/* Mobile */
@media (max-width: 480px) {
    #sd-chat-root { bottom: 12px; left: 12px; }
    .sd-chat-bubble { width: 52px; height: 52px; }
    .sd-chat-panel {
        position: fixed;
        bottom: 12px; left: 12px; right: 12px;
        width: auto; height: calc(100vh - 100px);
        max-height: calc(100vh - 100px);
    }
}

/* ============================================================
   ONBOARDING TOUR (first-login guided product tour)
   ============================================================ */

.sd-onb-root {
    position: fixed; inset: 0; z-index: 100000;
    pointer-events: none;
    animation: sd-onb-fade-in 0.25s ease;
}
.sd-onb-root.sd-onb-leaving { animation: sd-onb-fade-out 0.2s ease forwards; }
@keyframes sd-onb-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sd-onb-fade-out { from { opacity: 1; } to { opacity: 0; } }

.sd-onb-overlay {
    position: absolute; inset: 0;
    background: rgba(15, 23, 42, 0.72);
    pointer-events: auto;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sd-onb-spotlight {
    position: absolute;
    display: none;
    border-radius: 10px;
    box-shadow:
        0 0 0 9999px rgba(15, 23, 42, 0.72),
        0 0 0 2px rgba(74, 158, 255, 0.9),
        0 0 30px rgba(74, 158, 255, 0.6);
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    animation: sd-onb-pulse 2s ease-in-out infinite;
}
@keyframes sd-onb-pulse {
    0%, 100% { box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.72), 0 0 0 2px rgba(74, 158, 255, 0.9), 0 0 30px rgba(74, 158, 255, 0.6); }
    50%      { box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.72), 0 0 0 4px rgba(74, 158, 255, 1.0), 0 0 50px rgba(74, 158, 255, 0.9); }
}

.sd-onb-root.sd-onb-has-target .sd-onb-overlay { background: transparent; }

.sd-onb-tooltip {
    position: absolute;
    width: 360px;
    max-width: calc(100vw - 32px);
    background: #ffffff;
    color: #0f172a;
    border-radius: 14px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45), 0 4px 12px rgba(0, 0, 0, 0.2);
    padding: 22px 24px 18px;
    pointer-events: auto;
    transition: top 0.3s ease, left 0.3s ease;
    border: 1px solid rgba(74, 158, 255, 0.3);
}

.sd-onb-tooltip.sd-onb-tt-center {
    top: 50% !important; left: 50% !important;
    transform: translate(-50%, -50%);
    width: 440px;
}

.sd-onb-tooltip-header {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 10px;
}
.sd-onb-icon { font-size: 1.4rem; line-height: 1; }
.sd-onb-step-count {
    flex: 1;
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}
.sd-onb-close {
    background: transparent; border: none; cursor: pointer;
    color: #94a3b8; font-size: 22px; line-height: 1;
    padding: 4px 8px; border-radius: 6px;
    transition: all 0.15s;
}
.sd-onb-close:hover { background: #f1f5f9; color: #1e293b; }

.sd-onb-title {
    margin: 0 0 10px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.01em;
}

.sd-onb-body {
    font-size: 14px;
    line-height: 1.55;
    color: #334155;
    margin-bottom: 16px;
}
.sd-onb-body strong { color: #1e293b; font-weight: 700; }

.sd-onb-progress {
    height: 4px;
    background: #f1f5f9;
    border-radius: 4px;
    overflow: hidden;
    margin: 4px 0 14px;
}
.sd-onb-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4a9eff, #0ea5ff);
    border-radius: 4px;
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.sd-onb-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.sd-onb-nav { display: flex; gap: 8px; }
.sd-onb-btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.sd-onb-btn-skip {
    background: transparent;
    color: #94a3b8;
    padding: 8px 6px;
}
.sd-onb-btn-skip:hover { color: #64748b; }
.sd-onb-btn-prev {
    background: #f8fafc;
    color: #475569;
    border-color: #e2e8f0;
}
.sd-onb-btn-prev:hover:not(:disabled) { background: #f1f5f9; }
.sd-onb-btn-prev:disabled { opacity: 0.4; cursor: not-allowed; }
.sd-onb-btn-next {
    background: linear-gradient(135deg, #4a9eff, #0ea5ff);
    color: white;
    box-shadow: 0 2px 8px rgba(74, 158, 255, 0.35);
}
.sd-onb-btn-next:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.5);
}

/* Dark theme adaptation */
body.theme-dark .sd-onb-tooltip,
:root[data-theme="dark"] .sd-onb-tooltip {
    background: #1e293b;
    color: #f1f5f9;
    border-color: rgba(74, 158, 255, 0.4);
}
body.theme-dark .sd-onb-title,
:root[data-theme="dark"] .sd-onb-title {
    color: #f1f5f9;
}
body.theme-dark .sd-onb-body,
:root[data-theme="dark"] .sd-onb-body {
    color: #cbd5e1;
}
body.theme-dark .sd-onb-body strong,
:root[data-theme="dark"] .sd-onb-body strong {
    color: #f1f5f9;
}
body.theme-dark .sd-onb-step-count,
:root[data-theme="dark"] .sd-onb-step-count {
    color: #94a3b8;
}
body.theme-dark .sd-onb-progress,
:root[data-theme="dark"] .sd-onb-progress {
    background: #334155;
}
body.theme-dark .sd-onb-btn-prev,
:root[data-theme="dark"] .sd-onb-btn-prev {
    background: #334155;
    color: #cbd5e1;
    border-color: #475569;
}
body.theme-dark .sd-onb-btn-prev:hover:not(:disabled),
:root[data-theme="dark"] .sd-onb-btn-prev:hover:not(:disabled) {
    background: #475569;
}

/* Mobile */
@media (max-width: 600px) {
    .sd-onb-tooltip {
        width: calc(100vw - 24px);
        padding: 18px 20px 14px;
    }
    .sd-onb-tooltip.sd-onb-tt-center {
        width: calc(100vw - 24px);
    }
    .sd-onb-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }
    .sd-onb-nav { justify-content: space-between; }
    .sd-onb-btn-prev, .sd-onb-btn-next { flex: 1; }
}

/* ============================================================
   DEMO CTA — "Tester avec un exemple" below upload zone
   ============================================================ */
.demo-cta-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 14px;
    padding: 14px 18px;
    background: linear-gradient(135deg, rgba(74, 158, 255, 0.06), rgba(14, 165, 255, 0.04));
    border: 1px dashed rgba(74, 158, 255, 0.35);
    border-radius: 10px;
    flex-wrap: wrap;
}
.demo-cta-text {
    font-size: 0.88rem;
    color: var(--text-secondary, #64748b);
    font-weight: 500;
}
.demo-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #4a9eff, #0ea5ff);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(74, 158, 255, 0.25);
}
.demo-cta-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.4);
}
.demo-cta-btn:active { transform: translateY(0); }
.demo-cta-btn svg { flex-shrink: 0; }

@media (max-width: 480px) {
    .demo-cta-row { flex-direction: column; gap: 8px; padding: 12px 16px; }
    .demo-cta-btn { width: 100%; justify-content: center; }
}

/* ============================================================
   SUCCESS CARD — post-processing celebratory recap
   ============================================================ */
.success-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 22px;
    margin: 0 0 20px;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.08), rgba(74, 158, 255, 0.06));
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-left: 4px solid #22c55e;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.08);
    animation: success-card-in 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
    flex-wrap: wrap;
}
@keyframes success-card-in {
    from { opacity: 0; transform: translateY(-12px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.success-card-main {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 280px;
}
.success-card-check {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.35);
    animation: success-check-pop 0.55s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes success-check-pop {
    0%   { transform: scale(0); opacity: 0; }
    60%  { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); }
}
.success-card-body { flex: 1; min-width: 0; }
.success-card-title {
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--text-primary, #0f172a);
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}
.success-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.82rem;
    color: var(--text-secondary, #64748b);
}
.success-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.success-meta-item svg { opacity: 0.7; flex-shrink: 0; }
.success-meta-local {
    color: #15803d;
    font-weight: 600;
}
.success-meta-local svg { opacity: 1; color: #16a34a; }

.success-card-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.success-cta-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 20px;
    background: linear-gradient(135deg, #4a9eff, #0ea5ff);
    color: white;
    border: none;
    border-radius: 9px;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 3px 10px rgba(74, 158, 255, 0.35);
}
.success-cta-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(74, 158, 255, 0.5);
}
.success-cta-primary:active { transform: translateY(0); }
.success-cta-primary.copied {
    background: linear-gradient(135deg, #16a34a, #22c55e);
    box-shadow: 0 3px 10px rgba(34, 197, 94, 0.4);
}
.success-cta-secondary {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    background: transparent;
    color: var(--text-secondary, #64748b);
    border: 1px solid var(--border-medium, #e2e8f0);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.success-cta-secondary:hover {
    background: var(--bg-elevated, #f8fafc);
    color: var(--text-primary, #0f172a);
}
.success-cta-secondary svg { transition: transform 0.2s; }
.success-cta-secondary:hover svg { transform: translateY(2px); }

/* Dark theme */
body.theme-dark .success-card,
:root[data-theme="dark"] .success-card {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.10), rgba(74, 158, 255, 0.08));
    border-color: rgba(34, 197, 94, 0.35);
}
body.theme-dark .success-meta-local,
:root[data-theme="dark"] .success-meta-local {
    color: #4ade80;
}

/* Mobile */
@media (max-width: 720px) {
    .success-card {
        flex-direction: column;
        align-items: stretch;
        padding: 16px 18px;
    }
    .success-card-actions {
        width: 100%;
    }
    .success-cta-primary { flex: 1; justify-content: center; }
    .success-cta-secondary { flex: 1; justify-content: center; }
}

/* ============================================================
   MOBILE RESPONSIVE — improvements for ≤480px viewports
   Covers: tab switcher icon-only, user menu trigger truncation,
   options row stacking, drop area padding.
   ============================================================ */
@media (max-width: 600px) {
    /* Tab switcher: keep icons + labels but allow horizontal scroll if needed */
    .tab-switcher {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .tab-switcher::-webkit-scrollbar { display: none; }
    .tab {
        flex: 0 0 auto;
        padding: 10px 14px;
        font-size: 0.82rem;
        min-width: max-content;
    }

    /* User menu: cap email width, prevent overflow */
    .user-menu-trigger {
        max-width: 180px;
    }
    .user-email {
        max-width: 110px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Options row: stack toggles vertically */
    .options-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .toggle-option {
        width: 100%;
        justify-content: flex-start;
    }

    /* Drop area: shrink padding so it fits in viewport */
    .drop-area {
        padding: 30px 16px !important;
    }
    .drop-icon svg { width: 36px; height: 36px; }
    .drop-text { font-size: 0.95rem !important; }
    .drop-subtext { font-size: 0.8rem !important; }
    .drop-formats { font-size: 0.72rem !important; }
}

@media (max-width: 380px) {
    /* Extra tight: hide tab text labels, keep only icons */
    .tab > span:not([class]):not(.kbd-hint),
    .tab > [data-i18n] {
        display: none;
    }
    .tab {
        padding: 10px 12px;
    }
    /* Logo: hide version badge */
    .version-badge { display: none; }
}

/* ============================================================
   GLOBAL DROP OVERLAY — drag file anywhere on the page
   ============================================================ */
.global-drop-overlay {
    position: fixed;
    inset: 0;
    z-index: 99000;
    background: rgba(15, 23, 42, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s ease;
}
.global-drop-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.global-drop-card {
    background: white;
    border: 3px dashed #4a9eff;
    border-radius: 24px;
    padding: 56px 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
    animation: global-drop-bounce 0.45s cubic-bezier(0.2, 1.2, 0.4, 1);
    max-width: 90vw;
}
@keyframes global-drop-bounce {
    from { transform: scale(0.9); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}
.global-drop-icon {
    width: 96px;
    height: 96px;
    background: linear-gradient(135deg, #4a9eff, #0ea5ff);
    color: white;
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(74, 158, 255, 0.4);
    animation: global-drop-icon-pulse 1.4s ease-in-out infinite;
}
@keyframes global-drop-icon-pulse {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}
.global-drop-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.02em;
}
.global-drop-sub {
    font-size: 0.95rem;
    color: #64748b;
    font-weight: 500;
}

/* Dark theme */
body.theme-dark .global-drop-card,
:root[data-theme="dark"] .global-drop-card {
    background: #1e293b;
    border-color: #4a9eff;
}
body.theme-dark .global-drop-title,
:root[data-theme="dark"] .global-drop-title { color: #f1f5f9; }
body.theme-dark .global-drop-sub,
:root[data-theme="dark"] .global-drop-sub { color: #94a3b8; }

@media (max-width: 600px) {
    .global-drop-card { padding: 36px 28px; }
    .global-drop-icon { width: 72px; height: 72px; }
    .global-drop-title { font-size: 1.25rem; }
}

/* ============================================================
   RESTORE WORKFLOW POLISH — progress trail, token detector,
   animated success card, highlighted output
   ============================================================ */
.restore-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin: 16px 0 28px;
    padding: 18px 12px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    border: 1px solid var(--border-subtle, rgba(74,158,255,0.12));
}
.restore-progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    transition: opacity 0.3s;
}
.restore-progress-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-input, #0e0e16);
    border: 2px solid var(--border-medium, rgba(255,255,255,0.12));
    color: var(--text-tertiary, #6a6a85);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    transition: all 0.35s cubic-bezier(0.2, 1.2, 0.4, 1);
}
.restore-progress-label {
    font-size: 0.74rem;
    color: var(--text-tertiary, #6a6a85);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transition: color 0.3s;
}
.restore-progress-line {
    flex: 1;
    height: 2px;
    background: var(--border-medium, rgba(255,255,255,0.10));
    margin: 0 12px 22px;
    max-width: 140px;
    transition: background 0.4s;
}
.restore-progress-step.done .restore-progress-circle {
    background: linear-gradient(135deg, #4a9eff, #0ea5ff);
    border-color: transparent;
    color: white;
    box-shadow: 0 2px 8px rgba(74,158,255,0.35);
}
.restore-progress-step.done .restore-progress-label {
    color: var(--accent-light, #6eb3ff);
}
.restore-progress-step.success .restore-progress-circle {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-color: transparent;
    color: white;
    box-shadow: 0 2px 10px rgba(34,197,94,0.45);
    animation: restore-success-pop 0.6s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes restore-success-pop {
    0%   { transform: scale(0.6); }
    60%  { transform: scale(1.18); }
    100% { transform: scale(1); }
}
.restore-progress-step.success .restore-progress-label {
    color: #4ade80;
}
.restore-progress-line.active {
    background: linear-gradient(90deg, #4a9eff, #0ea5ff);
}

/* Step hint */
.restore-step-hint {
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--text-tertiary, #6a6a85);
    line-height: 1.4;
}

/* Token detector badge in step 2 label */
.restore-step-label {
    display: flex;
    align-items: center;
    gap: 8px;
}
.restore-token-badge {
    margin-left: auto;
    padding: 3px 10px;
    background: rgba(74, 158, 255, 0.12);
    color: var(--accent-light, #6eb3ff);
    border: 1px solid rgba(74, 158, 255, 0.25);
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: all 0.2s;
    animation: token-badge-pop 0.3s cubic-bezier(0.2, 1.2, 0.4, 1);
}
.restore-token-badge.has-tokens {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.35);
}
@keyframes token-badge-pop {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
}

/* Main CTA polish */
.btn-restore-cta {
    margin-top: 20px;
    font-size: 1rem;
}
.btn-restore-cta:disabled {
    background: var(--bg-input) !important;
    color: var(--text-muted) !important;
    box-shadow: none !important;
}
.btn-restore-cta.processing {
    pointer-events: none;
    position: relative;
    overflow: hidden;
}
.btn-restore-cta.processing::after {
    content: '';
    position: absolute;
    top: 0; bottom: 0; left: -40%;
    width: 40%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
    animation: restore-sweep 1.1s linear infinite;
}
@keyframes restore-sweep {
    to { left: 110%; }
}

/* Success recap card */
.restore-success-card {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 18px 22px;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.10), rgba(74, 158, 255, 0.06));
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-left: 4px solid #22c55e;
    border-radius: 12px;
    margin-bottom: 18px;
    animation: success-card-in 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
    flex-wrap: wrap;
}
.restore-success-check {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(34, 197, 94, 0.4);
    animation: success-check-pop 0.55s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.restore-success-body { flex: 1; min-width: 220px; }
.restore-success-title {
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    margin-bottom: 4px;
}
.restore-success-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.restore-stat-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 0;
}
.restore-stat-chip strong {
    color: var(--text-primary);
    font-weight: 700;
}
.restore-copy-cta {
    padding: 10px 18px !important;
    font-size: 0.9rem !important;
    width: auto !important;
}

/* Highlighted output (alternative view) */
.restore-output-highlighted {
    padding: 16px 18px;
    background: var(--bg-input, #0e0e16);
    border: 1px solid var(--border-medium, rgba(255,255,255,0.12));
    border-radius: 10px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.88rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-primary);
    max-height: 420px;
    overflow-y: auto;
}
.restore-highlight {
    background: rgba(34, 197, 94, 0.18);
    color: #4ade80;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 600;
    border: 1px solid rgba(34, 197, 94, 0.35);
    animation: highlight-fade-in 0.4s ease;
}
@keyframes highlight-fade-in {
    from { background: rgba(34, 197, 94, 0.45); }
    to   { background: rgba(34, 197, 94, 0.18); }
}
.restore-view-toggle {
    margin-left: auto;
    background: transparent;
    border: 1px solid var(--border-medium, rgba(255,255,255,0.12));
    color: var(--text-secondary);
    padding: 5px 12px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    transition: all 0.15s;
}
.restore-view-toggle:hover {
    background: rgba(255,255,255,0.04);
    border-color: var(--border-hover, rgba(74,158,255,0.4));
}

/* Mobile */
@media (max-width: 600px) {
    .restore-progress-line { max-width: 50px; margin: 0 6px 22px; }
    .restore-progress-label { font-size: 0.65rem; }
    .restore-success-card {
        flex-direction: column;
        align-items: stretch;
    }
    .restore-copy-cta { width: 100% !important; justify-content: center; }
}

/* ============================================================
   HISTORY PANEL POLISH — toolbar, filters, sort, delete-all
   ============================================================ */
.history-panel-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.history-action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary, #9595ad);
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    font-family: inherit;
}
.history-action-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary, #f0f0f5);
}
.history-action-btn.spinning svg {
    animation: history-spin 0.6s linear;
}
@keyframes history-spin {
    to { transform: rotate(360deg); }
}

.history-toolbar {
    padding: 12px 18px 14px;
    border-bottom: 1px solid var(--border-subtle, rgba(74,158,255,0.12));
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.history-search {
    position: relative;
    display: flex;
    align-items: center;
}
.history-search svg {
    position: absolute;
    left: 11px;
    color: var(--text-tertiary, #6a6a85);
    pointer-events: none;
}
.history-search input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    background: var(--bg-input, #0e0e16);
    border: 1px solid var(--border-subtle, rgba(74,158,255,0.12));
    border-radius: 8px;
    color: var(--text-primary, #f0f0f5);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.history-search input:focus {
    border-color: rgba(74, 158, 255, 0.5);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.12);
}
.history-search input::placeholder {
    color: var(--text-muted, #4a4a6a);
}

.history-filters {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.history-chip {
    padding: 5px 12px;
    background: transparent;
    border: 1px solid var(--border-subtle, rgba(74,158,255,0.18));
    color: var(--text-secondary, #9595ad);
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    transition: all 0.15s;
    font-family: inherit;
}
.history-chip:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary, #f0f0f5);
}
.history-chip.active {
    background: rgba(74, 158, 255, 0.15);
    border-color: rgba(74, 158, 255, 0.5);
    color: var(--accent-light, #6eb3ff);
}

.history-sort-wrap {
    margin-left: auto;
    position: relative;
}
.history-sort {
    appearance: none;
    -webkit-appearance: none;
    background: var(--bg-input, #0e0e16);
    border: 1px solid var(--border-subtle, rgba(74,158,255,0.18));
    color: var(--text-secondary, #9595ad);
    padding: 5px 26px 5px 12px;
    border-radius: 7px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%239595ad' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
}
.history-sort:focus {
    outline: none;
    border-color: rgba(74, 158, 255, 0.5);
}

.history-panel-footer {
    border-top: 1px solid var(--border-subtle, rgba(74,158,255,0.12));
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}
.history-footer-count {
    font-size: 0.76rem;
    color: var(--text-tertiary, #6a6a85);
    font-weight: 600;
}
.history-delete-all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #fca5a5;
    border-radius: 7px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    transition: all 0.15s;
    font-family: inherit;
}
.history-delete-all:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.45);
    color: #f87171;
}
.history-delete-all:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Empty state polish (works with the new HTML structure) */
.history-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary, #9595ad);
    font-size: 0.88rem;
    line-height: 1.55;
}
.history-empty svg {
    display: inline-block;
    color: var(--text-tertiary, #6a6a85);
}

/* Mobile */
@media (max-width: 600px) {
    .history-toolbar { padding: 10px 14px 12px; }
    .history-sort-wrap { margin-left: 0; width: 100%; }
    .history-sort { width: 100%; }
}

/* ============================================================
   SHORTCUTS OVERLAY (? key)
   ============================================================ */
.shortcuts-overlay {
    position: fixed;
    inset: 0;
    z-index: 99500;
    background: rgba(10, 10, 15, 0.78);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}
.shortcuts-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.shortcuts-modal {
    background: var(--bg-card, #14141e);
    border: 1px solid var(--border-medium, rgba(255,255,255,0.10));
    border-radius: 16px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
    width: 100%;
    max-width: 560px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: shortcuts-modal-in 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes shortcuts-modal-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.shortcuts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-subtle, rgba(74,158,255,0.12));
}
.shortcuts-header h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary, #f0f0f5);
    letter-spacing: -0.01em;
}
.shortcuts-close {
    background: transparent;
    border: none;
    color: var(--text-secondary, #9595ad);
    font-size: 22px;
    line-height: 1;
    padding: 4px 10px;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.shortcuts-close:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary, #f0f0f5);
}
.shortcuts-body {
    padding: 8px 22px 18px;
    overflow-y: auto;
}
.shortcut-section {
    margin-top: 18px;
}
.shortcut-section h3 {
    margin: 0 0 10px;
    font-size: 0.72rem;
    color: var(--text-tertiary, #6a6a85);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
}
.shortcut-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
    font-size: 0.88rem;
    color: var(--text-secondary, #9595ad);
    gap: 16px;
}
.shortcut-row:last-child { border-bottom: none; }
.shortcut-row span { flex: 1; }
.shortcut-row strong { color: var(--text-primary, #f0f0f5); font-weight: 700; }
.shortcut-row > div:first-child {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    min-width: 96px;
}
.shortcut-row kbd {
    display: inline-block;
    min-width: 24px;
    padding: 3px 7px;
    background: var(--bg-input, #0e0e16);
    border: 1px solid var(--border-medium, rgba(255,255,255,0.16));
    border-bottom-width: 2px;
    border-radius: 5px;
    color: var(--text-primary, #f0f0f5);
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.78rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}
.shortcut-icon {
    font-size: 1rem;
    padding: 0 4px;
}
.shortcuts-footer {
    padding: 12px 22px;
    border-top: 1px solid var(--border-subtle, rgba(74,158,255,0.12));
    background: rgba(255, 255, 255, 0.02);
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-tertiary, #6a6a85);
}
.shortcuts-footer kbd {
    display: inline-block;
    padding: 2px 7px;
    background: var(--bg-input, #0e0e16);
    border: 1px solid var(--border-medium, rgba(255,255,255,0.16));
    border-radius: 4px;
    font-family: ui-monospace, Menlo, monospace;
    font-size: 0.74rem;
    margin: 0 2px;
}

/* Light theme adapt */
html[data-theme="light"] .shortcuts-modal {
    background: #ffffff;
    border-color: #e2e8f0;
}
html[data-theme="light"] .shortcut-row kbd,
html[data-theme="light"] .shortcuts-footer kbd {
    background: #f8fafc;
    color: #0f172a;
    border-color: #cbd5e1;
}

/* Mobile */
@media (max-width: 600px) {
    .shortcuts-overlay { padding: 12px; }
    .shortcuts-header { padding: 14px 18px; }
    .shortcuts-body { padding: 6px 18px 14px; }
    .shortcut-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    .shortcut-row > div:first-child { min-width: 0; }
}

/* ============================================================
   TOAST QUEUE (replaces single-toast pattern)
   ============================================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99800;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: calc(100vw - 48px);
    width: 380px;
}
.toast-item {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px 13px 16px;
    background: var(--bg-card, #14141e);
    border: 1px solid var(--border-medium, rgba(255,255,255,0.12));
    border-radius: 10px;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.2);
    color: var(--text-primary, #f0f0f5);
    font-size: 0.88rem;
    font-weight: 500;
    line-height: 1.4;
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateX(120%);
    transition: opacity 0.25s ease, transform 0.32s cubic-bezier(0.2, 0.95, 0.3, 1.15);
    cursor: pointer;
}
.toast-item-in {
    opacity: 1;
    transform: translateX(0);
}
.toast-item-out {
    opacity: 0;
    transform: translateX(120%);
    transition: opacity 0.18s ease, transform 0.22s ease;
}
.toast-item-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 800;
    color: white;
}
.toast-success { border-left: 3px solid #22c55e; }
.toast-success .toast-item-icon { background: linear-gradient(135deg, #22c55e, #16a34a); }
.toast-success .toast-item-bar-fill { background: linear-gradient(90deg, #22c55e, #4ade80); }
.toast-error { border-left: 3px solid #ef4444; }
.toast-error .toast-item-icon { background: linear-gradient(135deg, #ef4444, #dc2626); }
.toast-error .toast-item-bar-fill { background: linear-gradient(90deg, #ef4444, #f87171); }
.toast-info { border-left: 3px solid #4a9eff; }
.toast-info .toast-item-icon { background: linear-gradient(135deg, #4a9eff, #0ea5ff); }
.toast-info .toast-item-bar-fill { background: linear-gradient(90deg, #4a9eff, #6eb3ff); }

.toast-item-text {
    flex: 1;
    min-width: 0;
    color: var(--text-primary, #f0f0f5);
}
.toast-item-close {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: var(--text-tertiary, #6a6a85);
    font-size: 20px;
    line-height: 1;
    padding: 2px 8px;
    border-radius: 5px;
    cursor: pointer;
    margin: -4px -4px -4px 0;
    transition: color 0.15s, background 0.15s;
    font-family: inherit;
}
.toast-item-close:hover {
    color: var(--text-primary, #f0f0f5);
    background: rgba(255, 255, 255, 0.06);
}
.toast-item-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 0 0 10px 10px;
    overflow: hidden;
}
.toast-item-bar-fill {
    height: 100%;
    width: 100%;
    transform-origin: left center;
    animation: toast-progress linear forwards;
}
@keyframes toast-progress {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* Light theme adapt */
html[data-theme="light"] .toast-item {
    background: #ffffff;
    border-color: #e2e8f0;
    color: #0f172a;
    box-shadow: 0 10px 32px rgba(15, 23, 42, 0.12);
}
html[data-theme="light"] .toast-item-text { color: #0f172a; }
html[data-theme="light"] .toast-item-bar { background: rgba(15, 23, 42, 0.06); }

/* Mobile */
@media (max-width: 600px) {
    .toast-container {
        bottom: 16px;
        left: 16px;
        right: 16px;
        width: auto;
        max-width: none;
    }
    .toast-item {
        transform: translateY(120%);
    }
    .toast-item-out {
        transform: translateY(120%);
    }
}

/* ============================================================
   PWA INSTALL BANNER
   ============================================================ */
.pwa-install-banner {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 99600;
    max-width: 380px;
    background: var(--bg-card, #14141e);
    border: 1px solid rgba(74, 158, 255, 0.35);
    border-radius: 14px;
    padding: 16px 18px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(74, 158, 255, 0.18);
    display: flex;
    align-items: center;
    gap: 14px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.2, 0.95, 0.3, 1.1);
}
.pwa-install-banner-in { opacity: 1; transform: translateY(0); }
.pwa-install-banner-out {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.2s ease, transform 0.22s ease;
}
.pwa-install-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, #4a9eff, #0ea5ff);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(74, 158, 255, 0.35);
}
.pwa-install-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pwa-install-text strong {
    color: var(--text-primary, #f0f0f5);
    font-size: 0.92rem; font-weight: 700; letter-spacing: -0.01em;
}
.pwa-install-text span {
    color: var(--text-secondary, #9595ad);
    font-size: 0.78rem; line-height: 1.35;
}
.pwa-install-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.pwa-install-yes {
    padding: 7px 14px;
    background: linear-gradient(135deg, #4a9eff, #0ea5ff);
    color: white; border: none; border-radius: 7px;
    cursor: pointer; font-size: 0.82rem; font-weight: 700;
    font-family: inherit; transition: all 0.15s;
    box-shadow: 0 2px 8px rgba(74, 158, 255, 0.3);
}
.pwa-install-yes:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(74, 158, 255, 0.45); }
.pwa-install-no {
    padding: 4px 10px;
    background: transparent;
    color: var(--text-tertiary, #6a6a85);
    border: none; border-radius: 5px;
    cursor: pointer; font-size: 0.74rem; font-weight: 600;
    font-family: inherit; transition: color 0.15s;
}
.pwa-install-no:hover { color: var(--text-primary, #f0f0f5); }

html[data-theme="light"] .pwa-install-banner {
    background: white;
    border-color: #cbd5e1;
    box-shadow: 0 16px 48px rgba(15, 23, 42, 0.18);
}
html[data-theme="light"] .pwa-install-text strong { color: #0f172a; }
html[data-theme="light"] .pwa-install-text span { color: #64748b; }

@media (max-width: 600px) {
    .pwa-install-banner { left: 12px; right: 12px; bottom: 12px; max-width: none; padding: 14px 16px; }
    .pwa-install-actions { gap: 4px; }
    .pwa-install-yes { padding: 7px 12px; font-size: 0.78rem; }
}

@media all and (display-mode: standalone) {
    .pwa-install-banner { display: none !important; }
}

/* ============================================================
   ADMIN — Pricing plans management
   ============================================================ */
.pricing-admin-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.pricing-admin-header h3 {
    margin: 0 0 4px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary, #f0f0f5);
}
.pricing-admin-subtitle {
    margin: 0;
    font-size: 0.82rem;
    color: var(--text-tertiary, #6a6a85);
}
.pricing-admin-subtitle a { color: var(--accent, #4a9eff); text-decoration: none; }
.pricing-admin-subtitle a:hover { text-decoration: underline; }

.pricing-admin-actions {
    display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.pricing-stripe-status {
    display: inline-flex; align-items: center;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 600;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.10);
    color: var(--text-secondary);
    cursor: help;
}
.pricing-stripe-status.pricing-stripe-ok {
    background: rgba(34,197,94,0.10); color: #4ade80; border-color: rgba(34,197,94,0.30);
}
.pricing-stripe-status.pricing-stripe-local {
    background: rgba(245,158,11,0.10); color: #fcd34d; border-color: rgba(245,158,11,0.30);
}
.pricing-stripe-status.pricing-stripe-error {
    background: rgba(239,68,68,0.10); color: #fca5a5; border-color: rgba(239,68,68,0.30);
}
.pricing-add-btn {
    background: linear-gradient(135deg, #4a9eff, #0ea5ff) !important;
    color: white !important;
    border-color: transparent !important;
    font-weight: 600;
}

/* Plans table */
.pricing-plans-table-wrapper {
    overflow-x: auto;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border-subtle, rgba(74,158,255,0.12));
    border-radius: 10px;
}
.pricing-plans-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.pricing-plans-table th {
    text-align: left;
    padding: 11px 12px;
    background: rgba(255,255,255,0.03);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-subtle, rgba(74,158,255,0.12));
}
.pricing-plans-table th.num,
.pricing-plans-table td.num {
    text-align: right;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-variant-numeric: tabular-nums;
}
.pricing-plans-table td {
    padding: 12px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: var(--text-primary);
    vertical-align: middle;
}
.pricing-plans-table tr:hover td { background: rgba(255,255,255,0.02); }
.pricing-plans-table tr:last-child td { border-bottom: none; }
.pricing-plans-table tr.plan-row-reco {
    background: rgba(74,158,255,0.04);
}
.pricing-drag { color: var(--text-tertiary); cursor: grab; user-select: none; }
.pricing-slug {
    background: rgba(255,255,255,0.06);
    padding: 2px 7px;
    border-radius: 4px;
    font-family: ui-monospace, Menlo, monospace;
    font-size: 0.78rem;
    color: var(--text-secondary);
}
.features-cell {
    color: var(--text-secondary);
    font-size: 0.8rem;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pricing-tag-stripe-ok {
    color: #4ade80; font-size: 0.72rem; font-weight: 700;
    padding: 2px 8px; background: rgba(34,197,94,0.10);
    border-radius: 999px;
}
.pricing-tag-stripe-pending {
    color: #fcd34d; font-size: 0.72rem; font-weight: 700;
    padding: 2px 8px; background: rgba(245,158,11,0.10);
    border-radius: 999px;
}
.pricing-tag-stripe-off { color: var(--text-tertiary); font-size: 0.8rem; }
.pricing-tag-active {
    color: #4ade80; font-size: 0.74rem; font-weight: 700;
    padding: 2px 8px; background: rgba(34,197,94,0.10); border-radius: 999px;
}
.pricing-tag-inactive {
    color: var(--text-tertiary); font-size: 0.74rem; font-weight: 700;
    padding: 2px 8px; background: rgba(255,255,255,0.04); border-radius: 999px;
}
.pricing-tag-reco {
    color: #fcd34d; font-size: 0.72rem; font-weight: 700;
    padding: 2px 7px; background: rgba(245,158,11,0.10);
    border-radius: 999px; margin-left: 6px;
}
.pricing-actions { display: flex; gap: 4px; }
.pricing-action-btn {
    background: transparent; border: 1px solid var(--border-subtle, rgba(74,158,255,0.18));
    color: var(--text-secondary);
    padding: 4px 10px; border-radius: 6px;
    cursor: pointer; font-size: 0.92rem;
    transition: all 0.15s;
    font-family: inherit;
}
.pricing-action-btn:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
    border-color: rgba(74,158,255,0.4);
}
.pricing-action-danger:hover {
    color: #fca5a5;
    border-color: rgba(239,68,68,0.4);
    background: rgba(239,68,68,0.08);
}
.pricing-empty {
    padding: 40px 20px; text-align: center;
    background: rgba(255,255,255,0.02);
    border: 1px dashed var(--border-subtle, rgba(74,158,255,0.18));
    border-radius: 12px; color: var(--text-secondary);
}
.pricing-empty .pricing-add-btn { margin-top: 14px; }
.pricing-error { color: #fca5a5; padding: 14px; }

/* Modal */
.pricing-modal-overlay {
    position: fixed; inset: 0; z-index: 99500;
    background: rgba(10,10,15,0.78);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
}
.pricing-modal-overlay.hidden { display: none; }
.pricing-modal {
    background: var(--bg-card, #14141e);
    border: 1px solid var(--border-medium, rgba(255,255,255,0.10));
    border-radius: 16px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.55);
    width: 100%; max-width: 640px;
    max-height: 88vh;
    display: flex; flex-direction: column;
    overflow: hidden;
    animation: pricing-modal-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes pricing-modal-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.pricing-modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-subtle, rgba(74,158,255,0.12));
}
.pricing-modal-header h2 {
    margin: 0; font-size: 1.05rem; font-weight: 700;
    color: var(--text-primary);
}
.pricing-modal-close {
    background: transparent; border: none;
    color: var(--text-secondary); cursor: pointer;
    font-size: 22px; padding: 4px 10px;
    border-radius: 7px; font-family: inherit;
}
.pricing-modal-close:hover {
    background: rgba(255,255,255,0.06); color: var(--text-primary);
}
.pricing-modal-form {
    padding: 20px 22px;
    overflow-y: auto;
}
.pricing-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 12px;
}
.pricing-form-group { display: flex; flex-direction: column; margin-bottom: 12px; }
.pricing-form-group label {
    font-size: 0.78rem; font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.pricing-form-group input[type="text"],
.pricing-form-group input[type="email"],
.pricing-form-group input[type="number"],
.pricing-form-group input[type="password"],
.pricing-form-group textarea,
.pricing-form-group select {
    padding: 9px 12px;
    background: var(--bg-input, #0e0e16);
    border: 1px solid var(--border-subtle, rgba(74,158,255,0.18));
    border-radius: 8px;
    color: var(--text-primary, #f0f0f5);
    font-size: 0.92rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}
.pricing-form-group select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 32px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239595ad' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    cursor: pointer;
}
.pricing-form-group select option {
    background: var(--bg-card, #14141e);
    color: var(--text-primary, #f0f0f5);
}
.pricing-form-group input:focus,
.pricing-form-group textarea:focus,
.pricing-form-group select:focus {
    border-color: rgba(74,158,255,0.5);
    box-shadow: 0 0 0 3px rgba(74,158,255,0.12);
}
/* Kill Chrome's yellow autofill background */
.pricing-form-group input:-webkit-autofill,
.pricing-form-group input:-webkit-autofill:hover,
.pricing-form-group input:-webkit-autofill:focus,
.pricing-form-group input:-webkit-autofill:active {
    -webkit-text-fill-color: var(--text-primary, #f0f0f5) !important;
    -webkit-box-shadow: 0 0 0 30px var(--bg-input, #0e0e16) inset !important;
    transition: background-color 5000s ease-in-out 0s;
    caret-color: var(--text-primary, #f0f0f5);
}
/* Datalist suggestions (limited cross-browser styling, but match where possible) */
.pricing-form-group input[list]::-webkit-calendar-picker-indicator {
    opacity: 0.5;
    filter: invert(0.7);
    cursor: pointer;
}
.pricing-form-group small {
    margin-top: 4px;
    font-size: 0.74rem;
    color: var(--text-tertiary);
}
.pricing-checkbox {
    display: flex; align-items: center; gap: 8px;
    cursor: pointer; padding: 10px 0;
    text-transform: none !important;
    letter-spacing: normal !important;
    color: var(--text-primary) !important;
    font-size: 0.88rem !important;
    font-weight: 500 !important;
}
.pricing-checkbox input { margin: 0; }
.pricing-form-error {
    color: #fca5a5;
    font-size: 0.84rem;
    margin: 6px 0 0;
    display: none;
    padding: 10px 12px;
    background: rgba(239,68,68,0.08);
    border: 1px solid rgba(239,68,68,0.25);
    border-radius: 7px;
}
.pricing-form-error.show { display: block; }
.pricing-form-actions {
    display: flex; justify-content: flex-end; gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle, rgba(74,158,255,0.12));
}
.pricing-btn-secondary {
    padding: 9px 18px;
    background: transparent;
    border: 1px solid var(--border-subtle, rgba(74,158,255,0.18));
    color: var(--text-secondary);
    border-radius: 8px; font-weight: 600;
    cursor: pointer; font-family: inherit;
    font-size: 0.88rem;
}
.pricing-btn-primary {
    padding: 9px 22px;
    background: linear-gradient(135deg, #4a9eff, #0ea5ff);
    border: none; color: white;
    border-radius: 8px; font-weight: 700;
    cursor: pointer; font-family: inherit;
    font-size: 0.88rem;
    box-shadow: 0 2px 8px rgba(74,158,255,0.3);
}
.pricing-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(74,158,255,0.45); }
.pricing-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* Mobile */
@media (max-width: 600px) {
    .pricing-form-row { grid-template-columns: 1fr; }
    .pricing-admin-header { flex-direction: column; align-items: stretch; }
    .pricing-admin-actions { justify-content: stretch; }
    .pricing-plans-table th, .pricing-plans-table td { padding: 9px 10px; }
}

/* Per-row delete button in history panel */
.history-item { position: relative; }
.history-item-del {
    margin-left: auto;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-tertiary, #6a6a85);
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: all 0.15s;
    font-family: inherit;
    opacity: 0;
}
.history-item:hover .history-item-del { opacity: 0.6; }
.history-item-del:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.4);
    opacity: 1 !important;
}
@media (max-width: 600px) {
    .history-item-del { opacity: 0.6; }
}

/* ============================================================
   STATS DASHBOARD — slide-in user-facing panel
   ============================================================ */
.stats-overlay {
    position: fixed; inset: 0; z-index: 99400;
    background: rgba(10, 10, 15, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex; justify-content: flex-end;
    animation: stats-overlay-in 0.18s ease;
}
.stats-overlay.hidden { display: none; }
@keyframes stats-overlay-in { from { opacity: 0; } to { opacity: 1; } }

.stats-panel {
    width: min(900px, 96vw);
    max-width: 900px;
    height: 100vh;
    background: var(--bg-secondary, #111118);
    border-left: 1px solid var(--border-subtle, rgba(74,158,255,0.18));
    overflow-y: auto;
    box-shadow: -20px 0 60px rgba(0, 0, 0, 0.5);
    animation: stats-panel-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
    display: flex; flex-direction: column;
}
@keyframes stats-panel-in {
    from { transform: translateX(40px); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

.stats-panel-header {
    padding: 22px 28px 18px;
    border-bottom: 1px solid var(--border-subtle, rgba(74,158,255,0.12));
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-shrink: 0;
    background: linear-gradient(180deg, rgba(74,158,255,0.04), transparent);
}
.stats-panel-header h2 {
    margin: 0; font-size: 1.25rem; font-weight: 800;
    color: var(--text-primary, #f0f0f5);
    letter-spacing: -0.015em;
}
.stats-subtitle {
    margin: 4px 0 0;
    font-size: 0.82rem;
    color: var(--text-tertiary, #6a6a85);
}
.stats-close {
    background: transparent; border: none;
    color: var(--text-secondary, #9595ad);
    font-size: 22px; cursor: pointer;
    padding: 4px 10px; border-radius: 7px;
    font-family: inherit;
    transition: all 0.15s;
}
.stats-close:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }

.stats-body {
    padding: 24px 28px 60px;
    flex: 1;
}

/* ── Hero card (top banner) ─────────────────────────────────────────── */
.stats-hero {
    background: linear-gradient(135deg, rgba(74,158,255,0.14), rgba(168,85,247,0.10));
    border: 1px solid rgba(74,158,255,0.3);
    border-radius: 14px;
    padding: 22px 24px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}
.stats-hero::before {
    content: ''; position: absolute;
    top: -40%; right: -10%;
    width: 280px; height: 280px;
    background: radial-gradient(circle, rgba(74,158,255,0.25), transparent 70%);
    border-radius: 50%; pointer-events: none;
}
.stats-hero-greeting {
    font-size: 0.86rem;
    color: var(--text-secondary, #9595ad);
    font-weight: 600;
    letter-spacing: 0.02em;
    margin-bottom: 6px;
    position: relative;
}
.stats-hero-headline {
    font-size: 1.4rem;
    color: var(--text-primary, #f0f0f5);
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.35;
    margin-bottom: 16px;
    position: relative;
}
.stats-hero-headline strong {
    background: linear-gradient(135deg, #4a9eff, #0ea5ff);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    font-weight: 800;
}
.stats-hero-meta {
    display: flex; gap: 8px; flex-wrap: wrap;
    position: relative;
}
.stats-hero-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.10);
    color: var(--text-primary);
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
}
.stats-hero-pill strong { font-weight: 800; }

.stats-hero-empty {
    text-align: center; padding: 48px 24px;
}
.stats-hero-empty .stats-hero-icon {
    font-size: 3rem; line-height: 1; margin-bottom: 14px;
    filter: drop-shadow(0 4px 12px rgba(74,158,255,0.4));
}
.stats-hero-empty h3 {
    font-size: 1.3rem; color: var(--text-primary);
    margin: 0 0 8px; font-weight: 700;
}
.stats-hero-empty p {
    color: var(--text-secondary); margin: 0 auto 22px;
    max-width: 480px; line-height: 1.6;
    font-size: 0.94rem;
}
.stats-cta-primary {
    padding: 11px 22px;
    background: linear-gradient(135deg, #4a9eff, #0ea5ff);
    border: none; color: white; border-radius: 9px;
    font-weight: 700; font-size: 0.92rem;
    cursor: pointer; font-family: inherit;
    box-shadow: 0 4px 14px rgba(74,158,255,0.4);
    transition: transform 0.15s, box-shadow 0.15s;
}
.stats-cta-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74,158,255,0.55);
}

/* ── KPI grid (4 cards) ─────────────────────────────────────────────── */
.stats-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.stats-kpi {
    background: var(--bg-card, #14141e);
    border: 1px solid var(--border-subtle, rgba(74,158,255,0.12));
    border-radius: 12px;
    padding: 18px 18px 16px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.stats-kpi:hover {
    transform: translateY(-2px);
    border-color: rgba(74,158,255,0.35);
    box-shadow: 0 12px 28px rgba(74,158,255,0.10);
}
.stats-kpi-icon {
    width: 36px; height: 36px;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
.stats-kpi-label {
    font-size: 0.72rem;
    color: var(--text-tertiary, #6a6a85);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    margin-bottom: 4px;
}
.stats-kpi-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.025em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    margin-bottom: 4px;
}
.stats-kpi-value-text { font-size: 1.5rem; }
.stats-kpi-sub {
    font-size: 0.74rem;
    color: var(--text-tertiary, #6a6a85);
}

/* ── Card containers ────────────────────────────────────────────────── */
.stats-card {
    background: var(--bg-card, #14141e);
    border: 1px solid var(--border-subtle, rgba(74,158,255,0.12));
    border-radius: 12px;
    padding: 20px 22px;
    margin-bottom: 14px;
}
.stats-card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 14px;
}
.stats-card-header h3 {
    margin: 0; font-size: 0.92rem; font-weight: 700;
    color: var(--text-primary);
}
.stats-card-meta {
    font-size: 0.78rem; color: var(--text-tertiary);
    font-weight: 600;
}
.stats-empty-mini { color: var(--text-tertiary); font-size: 0.85rem; margin: 4px 0; }

.stats-row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* ── Sparkline ──────────────────────────────────────────────────────── */
.stats-sparkline {
    width: 100%; height: 60px; display: block;
}
.stats-spark-dot {
    fill: #4a9eff;
    stroke: var(--bg-card, #14141e);
    stroke-width: 1.5;
    transition: r 0.15s;
    cursor: pointer;
}
.stats-spark-dot:hover { r: 4; fill: #0ea5ff; }
.stats-spark-axis {
    display: flex; justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-tertiary, #6a6a85);
    margin-top: 8px;
    padding: 0 4px;
}

/* ── Stacked bar (levels) ───────────────────────────────────────────── */
.stats-stacked-bar {
    height: 16px;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    background: rgba(255,255,255,0.04);
    margin-bottom: 12px;
}
.stats-stacked-seg {
    height: 100%;
    transition: filter 0.15s;
}
.stats-stacked-seg:hover { filter: brightness(1.15); }
.stats-level-n1 { background: linear-gradient(135deg, #22c55e, #16a34a); }
.stats-level-n2 { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stats-level-n3 { background: linear-gradient(135deg, #ef4444, #dc2626); }

.stats-legend {
    display: flex; flex-direction: column; gap: 6px;
    font-size: 0.82rem; color: var(--text-secondary);
}
.stats-legend-row { display: flex; align-items: center; gap: 8px; }
.stats-legend-row strong { margin-left: auto; color: var(--text-primary); font-weight: 700; }
.stats-legend-dot {
    width: 10px; height: 10px; border-radius: 50%;
    flex-shrink: 0;
}

/* ── File types breakdown ───────────────────────────────────────────── */
.stats-types-list { display: flex; flex-direction: column; gap: 8px; }
.stats-type-row {
    display: grid;
    grid-template-columns: 100px 1fr 50px;
    align-items: center;
    gap: 10px;
    font-size: 0.82rem;
}
.stats-type-name { color: var(--text-secondary); }
.stats-type-bar {
    height: 8px;
    background: rgba(255,255,255,0.04);
    border-radius: 4px; overflow: hidden;
}
.stats-type-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4a9eff, #0ea5ff);
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.stats-type-count { text-align: right; color: var(--text-primary); font-weight: 600; font-size: 0.84rem; }

/* ── RGPD card ──────────────────────────────────────────────────────── */
.stats-card-rgpd {
    background: linear-gradient(135deg, rgba(34,197,94,0.08), rgba(74,158,255,0.05));
    border-color: rgba(34,197,94,0.25);
}
.stats-rgpd-list {
    list-style: none; padding: 0; margin: 0;
    display: flex; flex-direction: column; gap: 8px;
}
.stats-rgpd-list li {
    padding: 8px 0;
    border-bottom: 1px dashed rgba(255,255,255,0.05);
    font-size: 0.88rem;
    color: var(--text-secondary);
    display: flex; align-items: center; gap: 8px;
}
.stats-rgpd-list li:last-child { border-bottom: none; }
.stats-rgpd-list li::before {
    content: '✓'; color: #4ade80; font-weight: 800; flex-shrink: 0;
}
.stats-rgpd-list strong { color: var(--text-primary); font-weight: 700; }

.stats-footer-meta {
    text-align: center;
    margin-top: 14px;
    padding: 12px;
    font-size: 0.78rem;
    color: var(--text-tertiary);
}
.stats-footer-meta strong { color: var(--text-secondary); font-weight: 600; }

.stats-error {
    text-align: center; padding: 60px 20px;
    color: #fca5a5;
}

/* ── Skeletons (loading) ────────────────────────────────────────────── */
.stats-loading { padding: 0; }
.stats-skeleton-hero {
    height: 130px;
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 100%);
    background-size: 200% 100%;
    border-radius: 14px;
    margin-bottom: 20px;
    animation: stats-shimmer 1.4s infinite;
}
.stats-skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}
.stats-skeleton-card {
    height: 130px;
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 100%);
    background-size: 200% 100%;
    border-radius: 12px;
    animation: stats-shimmer 1.4s infinite;
}
@keyframes stats-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Light theme ────────────────────────────────────────────────────── */
html[data-theme="light"] .stats-panel { background: #f8fafc; }
html[data-theme="light"] .stats-kpi,
html[data-theme="light"] .stats-card { background: white; border-color: #e2e8f0; }
html[data-theme="light"] .stats-spark-dot { stroke: white; }

/* ── Mobile ─────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
    .stats-panel { width: 100vw; max-width: 100vw; }
    .stats-panel-header { padding: 16px 20px 14px; }
    .stats-body { padding: 18px 20px 50px; }
    .stats-hero { padding: 18px 18px; }
    .stats-hero-headline { font-size: 1.15rem; }
    .stats-row-2col { grid-template-columns: 1fr; }
    .stats-kpi-value { font-size: 1.7rem; }
    .stats-type-row { grid-template-columns: 80px 1fr 36px; font-size: 0.78rem; }
}

/* ============================================================
   PII HIGHLIGHT on original text (Original / Anonymisé view)
   ============================================================ */
.pii-highlight {
    background: rgba(239, 68, 68, 0.18);
    color: #fca5a5;
    padding: 1px 4px;
    border-radius: 3px;
    border-bottom: 2px solid rgba(239, 68, 68, 0.55);
    font-weight: 600;
    cursor: help;
    transition: background 0.15s, color 0.15s;
    text-decoration: line-through;
    text-decoration-color: rgba(239, 68, 68, 0.6);
    text-decoration-thickness: 1px;
}
.pii-highlight:hover {
    background: rgba(239, 68, 68, 0.35);
    color: #fecaca;
}

/* Tag badge attached visually with the data-label attribute */
.pii-highlight::after {
    content: attr(data-label);
    font-size: 0.62rem;
    font-weight: 800;
    color: rgba(239,68,68,0.9);
    background: rgba(239,68,68,0.08);
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
    text-decoration: none;
    vertical-align: middle;
    letter-spacing: 0.04em;
    display: inline-block;
    text-transform: uppercase;
    line-height: 1.4;
}

/* Light theme adapt */
html[data-theme="light"] .pii-highlight {
    background: rgba(239, 68, 68, 0.15);
    color: #b91c1c;
    border-bottom-color: rgba(239, 68, 68, 0.6);
}
html[data-theme="light"] .pii-highlight::after {
    color: #b91c1c;
    background: rgba(239, 68, 68, 0.10);
}

/* ============================================================
   ORG MANAGEMENT (profile → Organisation tab) — v2
   ============================================================ */
.org-sub-title {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary, #6a6a85);
    font-weight: 700;
    margin: 0 0 10px;
    display: flex; align-items: center; gap: 6px;
}
.org-count { color: var(--text-secondary, #9595ad); font-weight: 600; }
.org-loading { color: var(--text-tertiary, #6a6a85); font-size: 0.88rem; font-style: italic; margin: 6px 0; }

/* Invite-by-email form */
.org-invite-form {
    display: grid;
    grid-template-columns: 1fr 130px auto;
    gap: 8px;
    align-items: stretch;
}
.org-invite-form input[type="email"],
.org-invite-form select {
    padding: 9px 12px;
    background: var(--bg-input, #0e0e16);
    border: 1px solid var(--border-medium, rgba(255,255,255,0.10));
    border-radius: 8px;
    color: var(--text-primary, #f0f0f5);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
}
.org-invite-form input:focus,
.org-invite-form select:focus {
    border-color: rgba(74,158,255,0.4);
    box-shadow: 0 0 0 3px rgba(74,158,255,0.12);
}
.org-invite-form .profile-btn-primary { padding: 9px 18px !important; font-size: 0.88rem !important; }
.org-invite-hint {
    margin: 8px 0 0; font-size: 0.82rem;
    color: var(--text-tertiary, #6a6a85);
    min-height: 1.2em;
}
.org-invite-hint.ok { color: #4ade80; }
.org-invite-hint.err { color: #fca5a5; }

/* Pending invites list */
.org-pending-list { display: flex; flex-direction: column; gap: 6px; }
.org-pending-item {
    display: grid;
    grid-template-columns: 1fr 80px auto auto;
    align-items: center; gap: 10px;
    padding: 9px 12px;
    background: rgba(245, 158, 11, 0.06);
    border: 1px solid rgba(245, 158, 11, 0.22);
    border-radius: 8px;
    font-size: 0.86rem;
}
.org-pending-email { color: var(--text-primary); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.org-pending-role {
    font-size: 0.72rem; font-weight: 700;
    padding: 2px 8px; border-radius: 999px;
    background: rgba(74,158,255,0.12); color: var(--accent, #4a9eff);
}
.org-pending-expires { font-size: 0.76rem; color: var(--text-tertiary, #6a6a85); }
.org-pending-revoke {
    background: transparent; border: none;
    color: var(--text-tertiary); cursor: pointer;
    font-size: 1.1rem; padding: 2px 9px; border-radius: 5px;
    font-family: inherit; transition: all 0.15s;
}
.org-pending-revoke:hover {
    background: rgba(239,68,68,0.15); color: #f87171;
}

/* Members list v2 (row layout with actions) */
.org-members-list { display: flex; flex-direction: column; gap: 6px; }
.org-member {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    align-items: center; gap: 12px;
    padding: 9px 12px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border-subtle, rgba(74,158,255,0.10));
    border-radius: 8px;
}
.org-member:hover { background: rgba(255,255,255,0.04); }
.org-member-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a9eff, #0ea5ff);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 0.85rem;
    flex-shrink: 0;
}
.org-member-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.org-member-name { font-size: 0.9rem; color: var(--text-primary, #f0f0f5); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.org-member-email { font-size: 0.74rem; color: var(--text-tertiary, #6a6a85); overflow: hidden; text-overflow: ellipsis; }
.org-member-actions { display: flex; align-items: center; gap: 6px; }
.org-member-role {
    font-size: 0.74rem; font-weight: 600;
    color: var(--text-secondary, #9595ad);
    padding: 3px 9px; border-radius: 999px;
    background: rgba(255,255,255,0.04);
}
.org-member-role-select {
    background: var(--bg-input, #0e0e16);
    border: 1px solid var(--border-subtle, rgba(74,158,255,0.18));
    color: var(--text-primary, #f0f0f5);
    padding: 4px 22px 4px 9px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%239595ad' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 6px center;
}
.org-member-remove {
    background: transparent; border: 1px solid transparent;
    color: var(--text-tertiary, #6a6a85);
    padding: 3px 9px; border-radius: 6px;
    cursor: pointer; font-size: 1.05rem; line-height: 1; font-family: inherit;
    transition: all 0.15s;
}
.org-member-remove:hover {
    background: rgba(239,68,68,0.12); color: #f87171;
    border-color: rgba(239,68,68,0.3);
}
.org-member-remove:disabled { opacity: 0.4; cursor: not-allowed; }

@media (max-width: 600px) {
    .org-invite-form {
        grid-template-columns: 1fr;
    }
    .org-pending-item {
        grid-template-columns: 1fr auto auto;
    }
    .org-pending-expires { display: none; }
}

/* Inline plan selector in admin orgs table */
.admin-org-plan-select {
    appearance: none;
    -webkit-appearance: none;
    background: rgba(74,158,255,0.10);
    border: 1px solid rgba(74,158,255,0.25);
    color: #6eb3ff;
    padding: 3px 22px 3px 10px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236eb3ff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 7px center;
    max-width: 180px;
    transition: all 0.15s;
}
.admin-org-plan-select:hover {
    background-color: rgba(74,158,255,0.18);
    border-color: rgba(74,158,255,0.5);
}
.admin-org-plan-select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(74,158,255,0.18);
}
.admin-org-plan-select option {
    background: var(--bg-card, #14141e);
    color: var(--text-primary, #f0f0f5);
    font-weight: 500;
}
.admin-org-plan-select:disabled { opacity: 0.5; cursor: wait; }

/* ============================================================
   API KEY — improved messaging (warning post-creation + masked legacy note)
   ============================================================ */
.api-key-warning {
    margin-top: 10px;
    padding: 12px 14px;
    background: linear-gradient(135deg, rgba(34,197,94,0.08), rgba(74,158,255,0.04));
    border: 1px solid rgba(34,197,94,0.25);
    border-left: 3px solid #22c55e;
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary, #9595ad);
    line-height: 1.55;
}
.api-key-warning strong { color: var(--text-primary, #f0f0f5); }

.api-key-masked-note {
    margin-top: 10px;
    padding: 12px 14px;
    background: rgba(245,158,11,0.06);
    border: 1px solid rgba(245,158,11,0.22);
    border-left: 3px solid #f59e0b;
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary, #9595ad);
    line-height: 1.55;
    display: flex; align-items: flex-start; gap: 10px;
}
.api-key-masked-note .lock-icon { font-size: 1.1rem; line-height: 1; margin-top: 1px; }
.api-key-masked-note strong { color: var(--text-primary, #f0f0f5); }

.api-key-link-regen {
    background: transparent;
    border: none;
    color: #6eb3ff;
    text-decoration: underline;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    padding: 0;
    font-weight: 600;
}
.api-key-link-regen:hover { color: #4a9eff; text-decoration: none; }

/* ============================================================
   SMART RECOMMENDATIONS — post-anonymization actionable hints
   ============================================================ */
.reco-container {
    margin: 0 0 18px;
    background: linear-gradient(135deg, rgba(74,158,255,0.06), rgba(168,85,247,0.04));
    border: 1px solid rgba(74,158,255,0.20);
    border-left: 4px solid #4a9eff;
    border-radius: 12px;
    padding: 16px 18px;
    animation: reco-in 0.32s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes reco-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}
.reco-header {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 12px;
    font-size: 0.85rem; font-weight: 700;
    color: var(--text-secondary, #9595ad);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.reco-header-icon { font-size: 1rem; }
.reco-header > span:nth-child(2) { flex: 1; }
.reco-dismiss {
    background: transparent; border: none;
    color: var(--text-tertiary, #6a6a85);
    font-size: 18px; line-height: 1;
    padding: 2px 8px; border-radius: 5px;
    cursor: pointer; font-family: inherit;
    transition: all 0.15s;
}
.reco-dismiss:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }

.reco-cards { display: flex; flex-direction: column; gap: 10px; }

.reco-card {
    display: grid;
    grid-template-columns: 42px 1fr auto;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    transition: background 0.15s;
}
.reco-card:hover { background: rgba(255,255,255,0.05); }
.reco-card-icon {
    width: 42px; height: 42px;
    background: linear-gradient(135deg, #4a9eff, #0ea5ff);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 2px 8px rgba(74,158,255,0.25);
    flex-shrink: 0;
}
.reco-card-body { min-width: 0; }
.reco-card-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary, #f0f0f5);
    margin-bottom: 3px;
}
.reco-card-reason {
    font-size: 0.82rem;
    color: var(--text-secondary, #9595ad);
    line-height: 1.45;
}
.reco-card-cta {
    background: linear-gradient(135deg, #4a9eff, #0ea5ff);
    color: white;
    border: none;
    padding: 9px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.84rem;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 6px rgba(74,158,255,0.25);
    flex-shrink: 0;
}
.reco-card-cta:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(74,158,255,0.4); }
.reco-card-cta:disabled { opacity: 0.6; cursor: wait; transform: none; }
.reco-card-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.reco-card-cta-secondary {
    background: transparent;
    color: var(--accent, #818cf8);
    border: 1px dashed rgba(129, 140, 248, 0.45);
    box-shadow: none;
    font-size: 0.78rem;
    padding: 6px 12px;
}
.reco-card-cta-secondary:hover { background: rgba(129, 140, 248, 0.08); box-shadow: none; }

@media (max-width: 600px) {
    .reco-card {
        grid-template-columns: 32px 1fr;
        grid-template-rows: auto auto;
    }
    .reco-card-icon { width: 32px; height: 32px; font-size: 1rem; }
    .reco-card-cta { grid-column: 1 / -1; justify-self: stretch; margin-top: 4px; }
}
