/* ==========================================================================
   JC PATH LAB • ARQUITECTURA VISUAL Y DESIGN SYSTEM INSTITUCIONAL
   Plataforma ImmunoMaster AI Universal (Open-ImmunoQuery v4.2)
   Neuroestética Quirúrgica: Zafiro Borosilicato, Slate 950, Emerald & Cyan
   Cumplimiento WCAG 2.2 AAA • Glassmorphism con Backdrop-Filter
   ========================================================================== */

:root {
    /* --- Escala Tonal Armónica Monocromática Zafiro & Slate --- */
    --slate-950: #020617;       /* Fondo Abisal Ultra Profundo */
    --sapphire-950: #050b14;    /* Fondo Base Alternativo */
    --sapphire-900: #0a1322;    /* Canvas de Plataforma */
    --sapphire-850: #0f1d33;    /* Superficie de Tarjetas Glass */
    --sapphire-800: #152946;    /* Elevación de Componentes y Modales */
    --sapphire-700: #1d375d;    /* Bordes Estructurales */
    --sapphire-600: #294d80;    /* Bordes Activos y Focus */
    --sapphire-500: #0284c7;    /* Acento Primario Quirúrgico */
    --sapphire-400: #38bdf8;    /* Bioluminiscencia / Badges / Sky */
    --sapphire-300: #7dd3fc;    /* Hover Háptico y Textos Claros */
    --sapphire-200: #bae6fd;    /* Metadatos y Subtítulos */
    --sapphire-100: #e2edfa;    /* Texto Primario Polar (Contraste 14.2:1 WCAG AAA) */
    --sapphire-50:  #f0f7ff;    /* Luz Especular en Títulos */

    /* --- Acentos Cromáticos Médicos de Precisión --- */
    --emerald-500: #10b981;    /* Reactividad Positiva / Alta Probabilidad / Verificado */
    --emerald-400: #34d399;    /* Glow Esmeralda / Badge Concordante */
    --emerald-600: #059669;    /* Botón Sólido Positivo */
    --emerald-700: #047857;    /* Degradado Quirúrgico Éxito */
    
    --cyan-500: #06b6d4;       /* Acento Cyan Clínico */
    --cyan-400: #22d3ee;       /* Glow Cyan */
    --sky-500: #0284c7;        /* Azul Médico Quirúrgico */
    --sky-400: #38bdf8;        /* Resplandor Azul Cielo */

    --rose-500: #f43f5e;       /* Negativo / Marcador Discordante */
    --rose-600: #e11d48;       /* Botón Sólido Negativo */
    --amber-500: #f59e0b;      /* Alertas / Casos Dudosos / Ranks Intermedios */

    /* --- Tokens Semánticos para Contenedores y Glassmorphism --- */
    --bg-body: var(--slate-950);
    --surface-dark: rgba(10, 19, 34, 0.95);
    --surface-card: rgba(15, 29, 51, 0.78);
    --surface-card-hover: rgba(21, 41, 70, 0.88);
    --surface-input: #070e1c;
    
    --border-glass: rgba(56, 189, 248, 0.16);
    --border-glass-active: rgba(56, 189, 248, 0.4);
    --border-slate-800: #1e293b;
    --border-slate-700: #334155;

    --glow-cyan: rgba(56, 189, 248, 0.28);
    --glow-emerald: rgba(16, 185, 129, 0.28);
    --glow-amber: rgba(245, 158, 11, 0.25);

    --text-primary: var(--sapphire-100);
    --text-secondary: #94a3b8;
    --text-dim: #64748b;
    --text-muted: #829ab1;

    /* --- Tipografía --- */
    --font-brand: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* --- Geometría y Transiciones --- */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 30px;
    --transition-fast: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-smooth: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   RESETEO BASE & ESTILIZADO GENERAL
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-ui);
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 16px clamp(16px, 2.2vw, 36px) 40px clamp(16px, 2.2vw, 36px);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
    overflow-x: hidden;
}

/* Scrollbars Estilizadas Quirúrgicas */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(10, 19, 34, 0.6);
}
::-webkit-scrollbar-thumb {
    background: var(--sapphire-700);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--sapphire-500);
}

/* ==========================================================================
   FONDOS DE ILUMINACIÓN AMBIENTAL (SURGICAL AMBIENT GLOWS)
   ========================================================================== */
.ambient-glow {
    position: fixed;
    width: 650px;
    height: 650px;
    border-radius: 50%;
    filter: blur(150px);
    pointer-events: none;
    z-index: 0;
    opacity: 0.12;
}

.glow-top-left {
    top: -240px;
    left: -200px;
    background: radial-gradient(circle, var(--sapphire-500), transparent 70%);
}

.glow-mid-right {
    top: 30%;
    right: -260px;
    background: radial-gradient(circle, var(--emerald-500), transparent 70%);
    opacity: 0.08;
}

.glow-bottom-left {
    bottom: -200px;
    left: 15%;
    background: radial-gradient(circle, var(--cyan-500), transparent 70%);
}

/* ==========================================================================
   CABECERA SUPERIOR INSTITUCIONAL: JC PATH LAB
   ========================================================================== */
header.app-header {
    max-width: 1600px;
    margin: 0 auto 22px auto;
    position: relative;
    z-index: 50;
    background: rgba(10, 19, 34, 0.88);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 14px clamp(16px, 1.8vw, 28px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    box-shadow: 0 10px 32px 0 rgba(2, 6, 23, 0.7), inset 0 1px 0 0 rgba(240, 247, 255, 0.08);
}

/* Bloque de Identidad de Marca Institucional */
.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    flex-shrink: 0;
}

.brand-logo-glow {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 50%, #0d9488 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 22px;
    box-shadow: 0 0 20px var(--glow-cyan);
    border: 1px solid rgba(56, 189, 248, 0.35);
    flex-shrink: 0;
    transition: var(--transition-fast);
}

.brand-wrapper:hover .brand-logo-glow {
    transform: scale(1.04);
    box-shadow: 0 0 26px var(--glow-cyan), 0 0 14px var(--glow-emerald);
}

.brand-title-group h1 {
    font-family: var(--font-brand);
    font-size: 19px;
    font-weight: 900;
    letter-spacing: 0.6px;
    color: #ffffff;
    line-height: 1.1;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-title-group .brand-subtitle {
    font-family: var(--font-brand);
    font-size: 9.5px;
    font-weight: 700;
    color: var(--sapphire-400);
    letter-spacing: 1.3px;
    text-transform: uppercase;
    white-space: nowrap;
    display: block;
    margin-top: 2px;
}

/* Cluster de Badges Tecnológicos Institucionales */
.tech-badges-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.tech-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    background: rgba(15, 29, 51, 0.85);
    border: 1px solid var(--border-glass);
    color: var(--sapphire-200);
    backdrop-filter: blur(8px);
    transition: var(--transition-fast);
    white-space: nowrap;
}

.tech-badge:hover {
    border-color: var(--sapphire-400);
    color: #ffffff;
    transform: translateY(-1px);
}

.tech-badge i {
    font-size: 11px;
}

.tech-badge.cyan {
    background: rgba(6, 182, 212, 0.14);
    border-color: rgba(6, 182, 212, 0.35);
    color: #a5f3fc;
}

.tech-badge.emerald {
    background: rgba(16, 185, 129, 0.14);
    border-color: rgba(16, 185, 129, 0.38);
    color: #6ee7b7;
}

.tech-badge.amber {
    background: rgba(245, 158, 11, 0.14);
    border-color: rgba(245, 158, 11, 0.35);
    color: #fde68a;
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.badge-dot-cyan {
    background: #38bdf8;
    box-shadow: 0 0 8px #38bdf8;
}

.badge-dot-emerald {
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
    animation: pulseGlow 2.5s infinite;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.55; transform: scale(0.85); }
}

/* Acciones en Cabecera */
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.btn-header {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 24px;
    font-size: 12px;
    font-weight: 800;
    font-family: var(--font-brand);
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
}

.btn-header-portal {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    color: #ffffff;
    border-color: var(--sapphire-400);
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.32);
}

.btn-header-portal:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 22px var(--glow-cyan);
    background: linear-gradient(135deg, #0369a1, #0284c7);
}

.btn-header-matrix {
    background: rgba(15, 29, 51, 0.85);
    color: var(--sapphire-100);
    border: 1px solid var(--border-glass-active);
    backdrop-filter: blur(12px);
}

.btn-header-matrix:hover {
    background: rgba(2, 132, 199, 0.2);
    border-color: var(--sapphire-400);
    color: #ffffff;
    box-shadow: 0 0 14px var(--glow-cyan);
    transform: translateY(-2px);
}

.btn-header-wa {
    background: linear-gradient(135deg, #0d9488, #0f766e);
    color: #ffffff;
    border-color: rgba(52, 211, 153, 0.35);
    box-shadow: 0 4px 14px rgba(13, 148, 136, 0.3);
}

.btn-header-wa:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--glow-emerald);
}

/* ==========================================================================
   NAVEGACIÓN POR TABS (SWITCHER DE MODOS CLINICOS)
   ========================================================================== */
.mode-nav {
    max-width: 1600px;
    margin: 0 auto 20px auto;
    position: relative;
    z-index: 40;
    display: flex;
    gap: 8px;
    background: rgba(10, 19, 34, 0.92);
    padding: 6px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(16px);
    box-shadow: 0 8px 24px rgba(2, 6, 23, 0.5);
}

.tab-btn {
    flex: 1;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-family: var(--font-brand);
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

.tab-btn i {
    font-size: 13px;
    color: var(--sapphire-400);
    transition: var(--transition-fast);
}

.tab-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    background: linear-gradient(135deg, rgba(2, 132, 199, 0.28) 0%, rgba(15, 29, 51, 0.9) 100%);
    color: #ffffff;
    border: 1px solid var(--sapphire-400);
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.25);
}

.tab-btn.active i {
    color: #ffffff;
}

/* ==========================================================================
   ÁREA DE TRABAJO (WORKSPACE) & GRID SURGICAL-GLASS
   ========================================================================== */
.workspace {
    max-width: 1600px;
    margin: 0 auto;
    position: relative;
    z-index: 20;
}

.view-panel {
    display: none;
    animation: fadeIn 0.24s ease-out;
}

.view-panel.active {
    display: block;
}

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

.grid-forward {
    display: grid;
    grid-template-columns: clamp(340px, 24vw, 400px) 1fr;
    gap: 22px;
}

.grid-inverse {
    display: grid;
    grid-template-columns: clamp(380px, 28vw, 460px) 1fr;
    gap: 22px;
}

/* Tarjetas con Efecto Borosilicato / Surgical Glass */
.card {
    background: var(--surface-card);
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: 0 10px 32px 0 rgba(2, 6, 23, 0.6), inset 0 1px 0 0 rgba(240, 247, 255, 0.08);
    transition: var(--transition-fast);
}

.card:hover {
    border-color: rgba(56, 189, 248, 0.28);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(56, 189, 248, 0.12);
}

.card-header h2 {
    font-family: var(--font-brand);
    font-size: 1.05rem;
    font-weight: 800;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.2px;
}

.card-header h2 i {
    color: var(--sapphire-400);
}

.helper-text {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 14px;
    line-height: 1.45;
}

.helper-text strong {
    color: var(--sapphire-100);
}

/* Buscadores Quirúrgicos */
.search-box {
    position: relative;
    margin-bottom: 12px;
}

.search-box input {
    width: 100%;
    background: var(--surface-input);
    border: 1px solid var(--border-slate-800);
    border-radius: var(--radius-sm);
    padding: 9px 12px 9px 36px;
    color: #ffffff;
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition-fast);
}

.search-box input:focus {
    border-color: var(--sapphire-400);
    box-shadow: 0 0 14px var(--glow-cyan);
    background: #091326;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 10px;
    color: var(--text-dim);
    font-size: 0.85rem;
}

/* Lista de Neoplasias para el Dilemma Solver */
.neoplasm-select-list {
    max-height: 380px;
    overflow-y: auto;
    border: 1px solid rgba(56, 189, 248, 0.14);
    border-radius: var(--radius-sm);
    background: rgba(7, 14, 28, 0.85);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.neo-item {
    padding: 9px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    transition: var(--transition-fast);
    border: 1px solid transparent;
}

.neo-item:hover {
    background: rgba(2, 132, 199, 0.15);
    border-color: rgba(56, 189, 248, 0.25);
}

.neo-item.selected {
    background: rgba(2, 132, 199, 0.22);
    border-color: var(--sapphire-400);
    color: #ffffff;
    font-weight: 600;
}

.neo-badge {
    font-size: 0.72rem;
    font-weight: 700;
    font-family: var(--font-mono);
    background: rgba(15, 29, 51, 0.9);
    color: var(--sapphire-300);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(56, 189, 248, 0.2);
}

.neo-item.selected .neo-badge {
    background: var(--sapphire-500);
    color: #ffffff;
    border-color: var(--sapphire-400);
}

/* Opciones y Controles Inferiores */
.options-row {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid rgba(56, 189, 248, 0.12);
}

.toggle-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.82rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.toggle-label select {
    background: var(--surface-input);
    border: 1px solid var(--border-slate-800);
    color: #ffffff;
    padding: 5px 10px;
    border-radius: 6px;
    font-family: var(--font-ui);
    font-size: 0.82rem;
    outline: none;
    cursor: pointer;
}

.toggle-label select:focus {
    border-color: var(--sapphire-400);
}

/* ==========================================================================
   CARDS DE BIOMARCADORES ÓPTIMOS (FORWARD ILP & SHANNON)
   ========================================================================== */
.panel-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.panel-marker-card {
    background: rgba(11, 20, 38, 0.85);
    border: 1px solid rgba(56, 189, 248, 0.18);
    border-radius: var(--radius-sm);
    padding: 16px;
    position: relative;
    overflow: hidden;
    transition: var(--transition-fast);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.panel-marker-card:hover {
    transform: translateY(-2px);
    border-color: var(--sapphire-400);
    box-shadow: 0 8px 24px var(--glow-cyan);
}

.panel-marker-card.rank-1 {
    border-top: 3px solid var(--emerald-500);
    background: linear-gradient(180deg, rgba(16, 185, 129, 0.08) 0%, rgba(11, 20, 38, 0.95) 100%);
}
.panel-marker-card.rank-2 {
    border-top: 3px solid var(--sapphire-400);
}
.panel-marker-card.rank-3 {
    border-top: 3px solid #818cf8;
}
.panel-marker-card.rank-4 {
    border-top: 3px solid var(--amber-500);
}

.marker-code {
    font-family: var(--font-brand);
    font-size: 1.2rem;
    font-weight: 800;
    color: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.marker-sub {
    font-size: 0.76rem;
    color: var(--text-secondary);
    margin-top: 3px;
}

.power-meter {
    margin-top: 12px;
}

.meter-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.meter-bar-bg {
    height: 7px;
    background: #111d33;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(56, 189, 248, 0.1);
}

.meter-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #0284c7, #10b981);
    border-radius: 4px;
}

/* ==========================================================================
   MATRIZ CRUZADA DE REACTIVIDAD (HEATMAP TABLES)
   ========================================================================== */
.heatmap-container {
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid rgba(56, 189, 248, 0.18);
    background: rgba(7, 14, 28, 0.95);
    margin-top: 12px;
}

table.heatmap-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    text-align: center;
}

table.heatmap-table th, 
table.heatmap-table td {
    padding: 10px 12px;
    border: 1px solid rgba(27, 46, 77, 0.85);
}

table.heatmap-table th {
    background: #0d1a33;
    color: var(--sapphire-200);
    font-family: var(--font-brand);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
}

table.heatmap-table th.col-tumor {
    text-align: left;
    min-width: 220px;
    color: #ffffff;
}

table.heatmap-table td.col-tumor {
    text-align: left;
    font-weight: 600;
    background: #091224;
    color: var(--sapphire-100);
}

.heatmap-cell {
    font-weight: 700;
    font-family: var(--font-mono);
    border-radius: 5px;
    padding: 6px 8px;
    cursor: pointer;
    transition: var(--transition-fast);
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.heatmap-cell:hover {
    outline: 2px solid var(--sapphire-400);
    transform: scale(1.06);
    box-shadow: 0 0 14px var(--glow-cyan);
    z-index: 10;
}

/* ==========================================================================
   PROFILER INVERSO (STAINING PATTERN CONTROLS & BAYESIAN INFERENCE)
   ========================================================================== */
.staining-input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    max-height: 540px;
    overflow-y: auto;
    padding-right: 6px;
}

.marker-stain-card {
    background: rgba(11, 21, 40, 0.9);
    border: 1px solid rgba(56, 189, 248, 0.16);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: var(--transition-fast);
}

.marker-stain-card:hover {
    border-color: rgba(56, 189, 248, 0.35);
}

.marker-stain-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.marker-name-bold {
    font-family: var(--font-brand);
    font-size: 0.88rem;
    font-weight: 800;
    color: #ffffff;
}

.stain-buttons {
    display: flex;
    gap: 5px;
}

.stain-btn {
    flex: 1;
    padding: 5px 0;
    border: 1px solid var(--border-slate-800);
    background: #111d33;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 800;
    border-radius: 5px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.stain-btn:hover {
    background: var(--sapphire-700);
    color: #ffffff;
}

.stain-btn.active-pos {
    background: var(--emerald-600);
    border-color: var(--emerald-400);
    color: #ffffff;
    box-shadow: 0 0 10px var(--glow-emerald);
}

.stain-btn.active-neg {
    background: var(--rose-600);
    border-color: var(--rose-500);
    color: #ffffff;
    box-shadow: 0 0 10px rgba(244, 63, 94, 0.4);
}

.stain-btn.active-unset {
    background: #334155;
    color: #e2e8f0;
}

/* Tarjetas de Diagnóstico Probable (Bayesian Ranking) */
.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rank-card {
    background: rgba(11, 21, 42, 0.88);
    border: 1px solid rgba(56, 189, 248, 0.18);
    border-radius: var(--radius-sm);
    padding: 16px 18px;
    position: relative;
    transition: var(--transition-fast);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.rank-card:first-child {
    border-left: 5px solid var(--emerald-500);
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.12) 0%, rgba(11, 21, 42, 0.95) 100%);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.18);
}

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

.rank-tumor-name {
    font-family: var(--font-brand);
    font-size: 1.05rem;
    font-weight: 800;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.rank-number {
    background: #111d33;
    color: var(--sapphire-400);
    font-size: 0.76rem;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 800;
    border: 1px solid rgba(56, 189, 248, 0.25);
}

.prob-badge {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--emerald-400);
    text-shadow: 0 0 10px var(--glow-emerald);
}

.concordance-row {
    display: flex;
    gap: 18px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.concordance-row strong {
    color: var(--sapphire-100);
}

.marker-chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.marker-chip-badge {
    font-size: 0.72rem;
    padding: 3px 9px;
    border-radius: 5px;
    font-family: var(--font-mono);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.chip-concordant {
    background: rgba(16, 185, 129, 0.16);
    border: 1px solid rgba(16, 185, 129, 0.38);
    color: #34d399;
}

.chip-discordant {
    background: rgba(244, 63, 94, 0.16);
    border: 1px solid rgba(244, 63, 94, 0.38);
    color: #fb7185;
}

/* ==========================================================================
   MODAL DE INFORME PATOLÓGICO SINÓPTICO (SURGICAL BOROSILICATE)
   ========================================================================== */
.modal-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(2, 6, 23, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop.show {
    display: flex;
}

.modal-window {
    background: rgba(10, 19, 34, 0.96);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 880px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.85), inset 0 1px 0 0 rgba(240, 247, 255, 0.12);
}

.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid rgba(56, 189, 248, 0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-family: var(--font-brand);
    color: var(--sapphire-400);
    font-size: 1.15rem;
    font-weight: 800;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.86rem;
    line-height: 1.55;
    white-space: pre-wrap;
    background: #050b14;
    color: var(--sapphire-100);
    border-radius: var(--radius-sm);
    margin: 16px 24px;
    border: 1px solid rgba(56, 189, 248, 0.14);
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(56, 189, 248, 0.15);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Tooltip Popover Flotante */
#tooltip-popover {
    position: fixed;
    display: none;
    background: rgba(10, 19, 34, 0.96);
    border: 1px solid var(--sapphire-400);
    padding: 9px 14px;
    border-radius: 8px;
    font-size: 0.78rem;
    color: #ffffff;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.75), 0 0 12px var(--glow-cyan);
    max-width: 280px;
    backdrop-filter: blur(12px);
}

/* ==========================================================================
   ESTILOS DE IMPRESIÓN OFICIAL (SINÓPTICO LIMPIO)
   ========================================================================== */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
        padding: 0;
    }
    .ambient-glow, .app-header, .mode-nav, .search-box, .options-row, .header-actions, .staining-input-grid, .modal-footer, .btn, .btn-header {
        display: none !important;
    }
    .card {
        border: 1px solid #cccccc !important;
        background: #ffffff !important;
        color: #000000 !important;
        box-shadow: none !important;
    }
    .modal-window {
        border: none !important;
        box-shadow: none !important;
        max-width: 100% !important;
    }
    .modal-body {
        background: #ffffff !important;
        color: #000000 !important;
        border: 1px solid #cccccc !important;
    }
}

/* ==========================================================================
   ARQUITECTURA RESPONSIVE MASTER & MOBILE READY (1920x1080 / 4K / TABLET / SMARTPHONE)
   Cumplimiento de Ergonomía Táctil (Touch Targets >= 42px), Zero-Overflow y Modos Fluidos
   ========================================================================== */

/* Utility: Ocultación Responsiva de Texto en Tabs */
.tab-text-short {
    display: none;
}
.tab-text-full {
    display: inline;
}

/* Indicador de Deslizamiento Horizontal en Tablas Médicas */
.mobile-heatmap-hint {
    display: none;
    font-size: 0.72rem;
    color: var(--sapphire-300);
    background: rgba(56, 189, 248, 0.08);
    border: 1px dashed rgba(56, 189, 248, 0.25);
    border-radius: 6px;
    padding: 5px 10px;
    margin-bottom: 8px;
    align-items: center;
    gap: 6px;
}

/* --------------------------------------------------------------------------
   1. PANTALLAS ULTRA-PANORÁMICAS Y 4K / UHD (>= 1800px & >= 2560px)
   -------------------------------------------------------------------------- */
@media (min-width: 1800px) {
    header.app-header,
    .mode-nav,
    .workspace {
        max-width: min(94vw, 1920px);
    }
    .grid-forward {
        grid-template-columns: 460px 1fr;
        gap: 28px;
    }
    .grid-inverse {
        grid-template-columns: 480px 1fr;
        gap: 28px;
    }
    .panel-cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 16px;
    }
    .staining-input-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 12px;
        max-height: 580px;
    }
}

@media (min-width: 2560px) {
    :root {
        font-size: 17px;
    }
    header.app-header,
    .mode-nav,
    .workspace {
        max-width: 2400px;
    }
    .ambient-glow {
        width: 950px;
        height: 950px;
        filter: blur(200px);
    }
    .card {
        padding: 26px 30px;
        border-radius: 18px;
    }
    .grid-forward {
        grid-template-columns: 520px 1fr;
        gap: 34px;
    }
    .grid-inverse {
        grid-template-columns: 540px 1fr;
        gap: 34px;
    }
    .panel-cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
    .staining-input-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        max-height: 650px;
    }
    table.heatmap-table th, table.heatmap-table td {
        padding: 12px 16px;
        font-size: 0.88rem;
    }
}

/* --------------------------------------------------------------------------
   2. PANTALLAS DE ESCRITORIO ESTÁNDAR Y PORTÁTILES (1200px - 1799px)
   -------------------------------------------------------------------------- */
@media (min-width: 1200px) and (max-width: 1799px) {
    header.app-header,
    .mode-nav,
    .workspace {
        max-width: min(96vw, 1680px);
    }
}

/* --------------------------------------------------------------------------
   3. TABLETS Y PORTÁTILES COMPACTOS (769px - 1199px)
   -------------------------------------------------------------------------- */
@media (max-width: 1199px) {
    header.app-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 14px 18px;
    }
    .brand-wrapper {
        justify-content: space-between;
    }
    .tech-badges-group {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }
    .header-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }
    .header-actions .btn-header {
        flex: 1 1 auto;
        min-height: 40px;
        justify-content: center;
    }
    .grid-forward, .grid-inverse {
        grid-template-columns: 1fr;
        gap: 18px;
    }
    .panel-cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
    .staining-input-grid {
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
        max-height: 420px;
    }
    /* Heatmap sticky column for tablet */
    table.heatmap-table th.col-tumor,
    table.heatmap-table td.col-tumor {
        position: sticky;
        left: 0;
        z-index: 4;
        background: #0b1426 !important;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.5);
    }
    table.heatmap-table th.col-tumor {
        background: #111d38 !important;
        z-index: 5;
    }
    .mobile-heatmap-hint {
        display: flex;
    }
}

/* --------------------------------------------------------------------------
   4. SMARTPHONES Y VISTA DENTRO DEL SIMULADOR MÓVIL (<= 768px & <= 480px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    html, body {
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden !important;
        -webkit-tap-highlight-color: transparent;
    }

    body {
        padding: 10px 10px 32px 10px;
    }

    /* Ambient glow reducido en móviles para preservar GPU/batería */
    .ambient-glow {
        width: 320px;
        height: 320px;
        filter: blur(80px);
        opacity: 0.08;
    }

    /* Cabecera Móvil Compacta */
    header.app-header {
        margin-bottom: 12px;
        padding: 10px 12px;
        border-radius: 12px;
        gap: 10px;
    }

    .brand-wrapper {
        gap: 10px;
    }

    .brand-logo-glow {
        width: 38px;
        height: 38px;
        font-size: 17px;
        border-radius: 10px;
    }

    .brand-title-group h1 {
        font-size: 16px;
        letter-spacing: 0.3px;
    }

    .brand-subtitle {
        font-size: 8.5px;
        letter-spacing: 0.8px;
    }

    /* Badges de tecnología en carrusel swipe táctil */
    .tech-badges-group {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 6px;
        padding-bottom: 4px;
        width: 100%;
        scrollbar-width: none;
    }
    .tech-badges-group::-webkit-scrollbar {
        display: none;
    }

    .tech-badge {
        font-size: 9px;
        padding: 3px 8px;
        flex-shrink: 0;
    }

    /* Dual Mode Selector Responsivo en Móviles */
    .dual-mode-header-container {
        width: 100%;
        margin-bottom: 10px;
    }

    .dual-mode-switch-card {
        width: 100%;
        padding: 6px 8px;
        box-sizing: border-box;
    }

    .dual-mode-toggle {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4px;
        width: 100%;
        box-sizing: border-box;
    }

    .mode-toggle-btn {
        padding: 6px 8px;
        gap: 6px;
        font-size: 0.76rem;
        min-height: 42px;
        justify-content: center;
    }

    .mode-name {
        font-size: 0.76rem;
    }

    .mode-badge-pill {
        font-size: 0.62rem;
        padding: 1px 5px;
    }

    .mode-caption {
        font-size: 0.68rem;
        line-height: 1.25;
        text-align: center;
    }

    /* Botones de Cabecera en Grilla 2x2 con Touch Targets >= 42px */
    .header-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        width: 100%;
    }

    .header-actions .btn-header {
        width: 100%;
        min-height: 42px;
        padding: 6px 8px;
        font-size: 0.74rem;
        justify-content: center;
        text-align: center;
        border-radius: 8px;
        box-sizing: border-box;
    }

    /* Barra de Navegación Segmentada (Segmented Control Táctil) */
    .mode-nav {
        margin-bottom: 14px;
        padding: 4px;
        border-radius: 10px;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
        width: 100%;
        box-sizing: border-box;
    }

    .tab-btn {
        padding: 8px 4px;
        font-size: 0.74rem;
        min-height: 42px;
        border-radius: 8px;
        flex-direction: column;
        justify-content: center;
        gap: 2px;
        white-space: normal;
        text-align: center;
        line-height: 1.2;
    }

    .tab-btn i {
        font-size: 13px;
    }

    .tab-text-full {
        display: none !important;
    }

    .tab-text-short {
        display: inline !important;
    }

    /* Grillas y Tarjetas en Columna Única Fluida */
    .grid-forward,
    .grid-inverse {
        display: flex;
        flex-direction: column;
        gap: 14px;
        width: 100%;
    }

    .card {
        padding: 14px 12px;
        border-radius: 12px;
        width: 100%;
        box-sizing: border-box;
    }

    .card-header h2 {
        font-size: 0.95rem;
    }

    .helper-text {
        font-size: 0.76rem;
        line-height: 1.35;
        margin-bottom: 10px;
    }

    /* Dilema: Selectores y Presets Táctiles */
    .dilemma-presets-bar {
        padding: 8px 10px;
        gap: 6px;
    }

    .preset-select {
        width: 100%;
        min-height: 42px;
        font-size: 0.82rem;
        padding: 8px 10px;
        border-radius: 8px;
    }

    .dilemma-chips-container {
        gap: 5px;
    }

    .dilemma-chip {
        font-size: 0.72rem;
        padding: 5px 8px;
        min-height: 32px;
        border-radius: 6px;
    }

    .chip-remove-btn {
        width: 22px;
        height: 22px;
        font-size: 12px;
    }

    .search-box-wrap input {
        min-height: 42px;
        font-size: 0.84rem;
        padding: 10px 12px 10px 34px;
    }

    /* Categorías Anatómicas con Swipe Táctil */
    .category-filter-bar {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 4px;
        padding-bottom: 4px;
        scrollbar-width: none;
    }
    .category-filter-bar::-webkit-scrollbar {
        display: none;
    }

    .category-pill {
        padding: 6px 10px;
        font-size: 0.72rem;
        white-space: nowrap;
        min-height: 34px;
        flex-shrink: 0;
    }

    .neoplasm-select-list {
        max-height: 240px;
    }

    .neo-item {
        min-height: 44px;
        padding: 9px 10px;
        font-size: 0.8rem;
    }

    .options-row {
        flex-direction: column;
        gap: 10px;
    }

    .toggle-label {
        font-size: 0.78rem;
        min-height: 36px;
    }

    #sel-panel-size {
        min-height: 38px;
        font-size: 0.84rem;
    }

    /* Panel Discriminador Óptimo (Cards en 2 columnas móviles) */
    .panel-cards-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
        gap: 8px;
    }

    .panel-marker-card {
        padding: 10px;
        border-radius: 8px;
    }

    .marker-code {
        font-size: 1.05rem;
    }

    .marker-sub {
        font-size: 0.68rem;
    }

    /* Heatmap Táctil con Desplazamiento Fluido y Columna Neoplasia Congelada (Sticky) */
    .mobile-heatmap-hint {
        display: flex;
    }

    .heatmap-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
        width: 100%;
        max-width: 100%;
        margin-top: 8px;
    }

    table.heatmap-table {
        font-size: 0.74rem;
    }

    table.heatmap-table th, table.heatmap-table td {
        padding: 6px 6px;
    }

    table.heatmap-table th.col-tumor,
    table.heatmap-table td.col-tumor {
        position: sticky;
        left: 0;
        z-index: 4;
        min-width: 125px;
        max-width: 145px;
        background: #0b1426 !important;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.6);
        word-break: break-word;
        font-size: 0.72rem;
        line-height: 1.25;
    }

    table.heatmap-table th.col-tumor {
        background: #111d38 !important;
        z-index: 5;
    }

    .heatmap-cell {
        font-size: 0.72rem;
        padding: 5px 6px;
    }

    /* Modo Inverso: Filtros y Botones Táctiles */
    .inverse-filter-chips {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 4px;
        padding-bottom: 4px;
        scrollbar-width: none;
    }
    .inverse-filter-chips::-webkit-scrollbar {
        display: none;
    }

    .inv-filter-btn {
        padding: 6px 10px;
        font-size: 0.72rem;
        white-space: nowrap;
        min-height: 34px;
        flex-shrink: 0;
    }

    .staining-input-grid {
        grid-template-columns: 1fr;
        gap: 8px;
        max-height: 320px;
    }

    .marker-stain-card {
        padding: 8px 10px;
        border-radius: 8px;
    }

    .marker-name-bold {
        font-size: 0.92rem;
    }

    .stain-buttons {
        gap: 6px;
    }

    .stain-btn {
        min-height: 40px;
        font-size: 1rem;
        font-weight: 800;
        border-radius: 6px;
        padding: 6px 0;
    }

    /* Gráfico de Probabilidad Posterior y Rankings */
    .prob-chart-card {
        padding: 12px;
    }

    .prob-bar-meta {
        flex-wrap: wrap;
        gap: 4px;
        font-size: 0.8rem;
    }

    .prob-tumor-title {
        flex-wrap: wrap;
        gap: 4px;
        font-size: 0.82rem;
    }

    .rank-card {
        padding: 12px;
        border-radius: 10px;
    }

    .rank-card-header {
        flex-wrap: wrap;
        gap: 6px;
    }

    .rank-tumor-name {
        font-size: 0.92rem;
        flex-wrap: wrap;
    }

    .prob-badge {
        font-size: 1.05rem;
    }

    .concordance-row {
        flex-direction: column;
        gap: 4px;
        font-size: 0.74rem;
    }

    .marker-chips-row {
        gap: 4px;
    }

    .marker-chip-badge {
        font-size: 0.68rem;
        padding: 3px 6px;
    }

    /* Modales Quirúrgicos Adaptados a Móvil */
    .modal-backdrop {
        padding: 8px;
    }

    .modal-window,
    .consensus-modal-window {
        max-height: 95vh;
        width: 100%;
        border-radius: 12px;
    }

    .modal-header {
        padding: 12px 14px;
    }

    .modal-body {
        margin: 8px 12px;
        padding: 12px;
        font-size: 0.74rem;
        max-height: 55vh;
    }

    .modal-footer {
        flex-direction: column;
        gap: 8px;
        padding: 12px 14px;
    }

    .modal-footer .btn,
    .modal-footer button {
        width: 100%;
        min-height: 42px;
        justify-content: center;
    }

    .consensus-meta-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 8px 12px;
    }

    .consensus-tabs-bar {
        display: flex;
        width: 100%;
    }

    .consensus-tab-btn {
        flex: 1;
        text-align: center;
        font-size: 0.74rem;
        padding: 8px 4px;
    }

    .clinical-report-sheet {
        padding: 14px 10px;
        font-size: 8pt;
    }

    .inst-letterhead {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .inst-sig-block {
        width: 100%;
    }
}

/* --------------------------------------------------------------------------
   5. MODO EMBEBIDO EN SIMULADOR DE SMARTPHONE (body.is-embedded)
   Ajustes específicos para cuando ImmunoMaster corre dentro del mockup
   -------------------------------------------------------------------------- */
body.is-embedded {
    padding: 8px 8px 24px 8px !important;
    background: #020617 !important;
}

body.is-embedded .ambient-glow {
    display: none !important;
}

body.is-embedded header.app-header {
    margin-bottom: 8px !important;
    padding: 8px 10px !important;
    border-radius: 10px !important;
}

body.is-embedded .brand-logo-glow {
    width: 32px !important;
    height: 32px !important;
    font-size: 14px !important;
}

body.is-embedded .brand-title-group h1 {
    font-size: 14px !important;
}

body.is-embedded .brand-subtitle {
    display: none !important;
}

body.is-embedded .mode-nav {
    margin-bottom: 10px !important;
}

body.is-embedded .card {
    padding: 10px 8px !important;
}

