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

/* ---------- Tokens ---------- */
:root {
    /* Color palette */
    --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;

    --accent-primary: #6c5ce7;
    --accent-primary-light: #8b7cf7;
    --accent-primary-dark: #5a48d5;
    --accent-gradient: linear-gradient(135deg, #6c5ce7, #a855f7, #ec4899);
    --accent-gradient-soft: linear-gradient(135deg, rgba(108, 92, 231, 0.15), rgba(168, 85, 247, 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: #a855f7;
    --purple-soft: rgba(168, 85, 247, 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: #a78bfa;
    --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(108, 92, 231, 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: flex;
    align-items: center;
    gap: 10px;
}

.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(168, 85, 247, 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(168, 85, 247, 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: 72px 24px 48px;
    position: relative;
    overflow: hidden;
}

.hero-glow {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 400px;
    background: radial-gradient(ellipse, rgba(108, 92, 231, 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: 16px;
    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.1rem;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.7;
}

/* ---------- App Container ---------- */
.app-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 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);
}

@media (max-width: 700px) {
    .mode-toggle-3 {
        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(108, 92, 231, 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: 10px;
}

.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(3, 1fr);
    gap: 8px;
}

.level-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    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);
}

.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 12px rgba(108, 92, 231, 0.2);
}

.level-badge {
    font-size: 0.9rem;
    font-weight: 800;
    font-family: var(--font-mono);
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.level-btn.active .level-badge {
    background: linear-gradient(135deg, #fff, #ddd);
    -webkit-background-clip: text;
    background-clip: text;
}

.level-btn[data-level="N2"].active .level-badge {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    -webkit-background-clip: text;
    background-clip: text;
}

.level-btn[data-level="N3"].active .level-badge {
    background: linear-gradient(135deg, #ef4444, #f97316);
    -webkit-background-clip: text;
    background-clip: text;
}

.level-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}

.level-desc {
    font-size: 0.7rem;
    color: var(--text-tertiary);
}

.level-btn.active .level-name {
    color: var(--accent-primary-light);
}

.level-btn[data-level="N2"].active .level-name {
    color: var(--orange);
}

.level-btn[data-level="N3"].active .level-name {
    color: var(--red);
}

/* ---------- 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: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(108, 92, 231, 0.15);
}

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

/* ---------- 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);
}

.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);
}

.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, #6c5ce7, #a855f7);
    color: white;
    border: none;
    box-shadow: 0 2px 8px rgba(108, 92, 231, 0.25);
}

.btn-report:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(108, 92, 231, 0.35);
}

.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;
}

/* ========== 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;
}

/* ---------- 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);
}

/* 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:last-child {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--accent-primary-light);
    font-size: 0.82rem;
}

/* ---------- 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-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: 48px 16px 32px;
    }

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

    .app-container {
        padding: 0 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;
    }
}