/* styles.css - Sistema de diseño premium, responsive y optimizado para impresión */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

/* --- variables del sistema de diseño (estilo Impulse) --- */
:root {
    --font-heading: 'Outfit', 'Inter', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* --- modo oscuro ejecutivo --- */
    --bg-gradient: linear-gradient(135deg, rgba(26, 47, 61, 0.85) 0%, rgba(35, 58, 74, 0.85) 100%);
    --bg-app: #1A2F3D;
    --card-bg: rgba(46, 71, 89, 0.7); /* Glassmorphism slate */
    --card-border: rgba(255, 255, 255, 0.1);
    --text-primary: #FFFFFF;
    --text-main: #FFFFFF; /* Alias para index.html forms/tables */
    --text-secondary: #B0C4DE; /* Soft blue/gray */
    --text-muted: #7A90A4;
    --input-bg: rgba(0, 0, 0, 0.2);
    
    --primary: #00E5FF; /* Cyan accent */
    --primary-hover: #40EFFF;
    --primary-alpha: rgba(0, 229, 255, 0.15);
    
    --accent: #00BFFF;
    --accent-hover: #33CCFF;
    --accent-alpha: rgba(0, 191, 255, 0.15);
    
    --danger: #FF5252;
    --warning: #FFAB40;
    --success: #00E676;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 50px -12px rgba(0, 0, 0, 0.6);
    
    --glass-blur: blur(16px);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 30px;

    /* --- Enmarcado continuo perimetral homologado a 4mm de grosor en todos los módulos --- */
    --perimeter-stroke: var(--card-bg);
    --perimeter-stroke-width: 4mm;
    --canvas-bg: rgba(18, 32, 43, 0.45);
    --card-nested-bg: var(--card-bg);
    --card-nested-border: var(--card-border);
}

/* --- modo claro corporativo --- */
[data-theme="light"] {
    --bg-gradient: linear-gradient(135deg, rgba(236, 240, 241, 0.9) 0%, rgba(223, 230, 233, 0.9) 100%);
    --bg-app: #ECF0F1;
    --card-bg: rgba(255, 255, 255, 0.85);
    --card-border: rgba(0, 0, 0, 0.08);
    --text-primary: #0F172A; /* Very dark slate, almost black */
    --text-main: #0F172A;
    --text-secondary: #334155; /* Dark slate */
    --text-muted: #475569; /* Medium-dark slate for better legibility */
    --input-bg: rgba(255, 255, 255, 0.8);
    
    --primary: #00838F;
    --primary-hover: #006064;
    --primary-alpha: rgba(0, 131, 143, 0.1);
    
    --accent: #0277BD;
    --accent-hover: #01579B;
    --accent-alpha: rgba(2, 119, 189, 0.1);
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, 0.15);

    /* --- Enmarcado continuo perimetral en modo claro (color del sidebar claro, 4mm de grosor) --- */
    --perimeter-stroke: var(--card-bg);
    --perimeter-stroke-width: 4mm;
    --canvas-bg: rgba(245, 247, 250, 0.6);
    --card-nested-bg: var(--card-bg);
    --card-nested-border: var(--card-border);
}

/* Fix dropdown options visibility */
option {
    background: var(--bg-app);
    color: var(--text-primary);
}

/* --- reset global --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
}

input, textarea, select, button, table, th, td {
    color: inherit;
    font-family: inherit;
}

option {
    background: var(--bg-app);
    color: var(--text-primary);
}

html {
    height: 100vh;
    overflow: hidden;
}

body {
    font-family: var(--font-body);
    background: var(--bg-gradient), url('../assets/executive_bg.png') center/cover fixed no-repeat;
    background-blend-mode: multiply;
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    line-height: 1.5;
}

[data-theme="light"] body {
    background-blend-mode: lighten;
}

/* --- scrollbar --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
    background: var(--card-border);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* ==========================================================================
   BARRA DE TELEMETRÍA Y CARGA DE LA PLATAFORMA (WORKLOAD & SATURATION MONITOR)
   Muestra en tiempo real la saturación del sistema y procesos en segundo plano
   ========================================================================== */
.platform-workload-bar-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 3px !important;
    background: rgba(0, 0, 0, 0.35) !important;
    z-index: 10000000 !important; /* Por encima de todo, pegada al borde superior */
    pointer-events: auto !important;
    cursor: help !important;
    overflow: visible !important;
    box-sizing: border-box !important;
    user-select: none !important;
}

.platform-workload-bar {
    position: relative !important;
    height: 100% !important;
    width: 8%; /* Nivel inicial en reposo */
    min-width: 6px !important;
    max-width: 100% !important;
    border-radius: 0 3px 3px 0 !important;
    transition: width 0.35s cubic-bezier(0.25, 0.8, 0.25, 1), background 0.4s ease, box-shadow 0.4s ease !important;
    
    /* Estado 1: Reposo / Baja Saturación (5% - 20%) - Cian Neón Fluido */
    background: linear-gradient(90deg, #00e5ff 0%, #00b4d8 100%) !important;
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.9), 0 0 16px rgba(0, 180, 216, 0.5) !important;
}

/* Extremo luminoso / pulso en la cabeza de la barra */
.platform-workload-glow-head {
    position: absolute !important;
    right: 0 !important;
    top: -2px !important;
    bottom: -2px !important;
    width: 8px !important;
    background: #ffffff !important;
    border-radius: 50% !important;
    filter: blur(1px) !important;
    box-shadow: 0 0 6px #ffffff, 0 0 12px currentColor !important;
    opacity: 0.9 !important;
    pointer-events: none !important;
}

/* Nivel Moderado / Tareas Activas (25% - 75%) - Ámbar / Esmeralda Activo */
.platform-workload-bar.level-medium {
    background: linear-gradient(90deg, #10b981 0%, #f59e0b 100%) !important;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.95), 0 0 20px rgba(245, 158, 11, 0.6) !important;
}

/* Nivel Crítico / Saturación / Procesando mucha información (76% - 100%) - Rojo / Naranja Neón */
.platform-workload-bar.level-high {
    background: linear-gradient(90deg, #f59e0b 0%, #ef4444 50%, #dc2626 100%) !important;
    box-shadow: 0 0 12px rgba(239, 68, 68, 1), 0 0 24px rgba(220, 38, 38, 0.8) !important;
    animation: workloadStripeFlow 1.2s linear infinite !important;
}

@keyframes workloadStripeFlow {
    0% { filter: brightness(1); }
    50% { filter: brightness(1.35) drop-shadow(0 0 6px #ef4444); }
    100% { filter: brightness(1); }
}

@media print {
    .platform-workload-bar-container {
        display: none !important;
    }
}

/* --- layout de la app --- */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
    gap: 0;
}

/* --- barra lateral (sidebar) --- */
.sidebar {
    width: 340px;
    background: var(--card-bg) !important;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--card-border);
    border-top: none;
    border-bottom: none;
    border-left: none;
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100vh !important;
    min-height: 100vh !important;
    max-height: 100vh !important;
    top: 0;
    left: 0;
    margin: 0;
    margin-right: 0;
    border-radius: 0;
    overflow: hidden !important;
    z-index: 100;
    flex-shrink: 0;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- LIENZO INTERNO ESCALABLE DEL MENÚ LATERAL (#sidebarCanvasInner) --- */
.sidebar-canvas-inner {
    flex: 1;
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden !important; /* Cabecera fija + cuerpo scrolleable */
    padding: 0.4rem 0.6rem !important;
    box-sizing: border-box !important;
}

.sidebar-fixed-header {
    flex-shrink: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    zoom: 1 !important;
}

.sidebar-canvas-inner {
    flex: 1 !important;
    width: 100% !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

#sidebarSpaceClinica, #sidebarSpaceSistema {
    flex: 1;
    min-height: 0;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    width: 100%;
    box-sizing: border-box;
}

#sidebarSpaceClinica::-webkit-scrollbar,
#sidebarSpaceSistema::-webkit-scrollbar {
    width: 4px;
}
#sidebarSpaceClinica::-webkit-scrollbar-thumb,
#sidebarSpaceSistema::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}
.sidebar.collapsed {
    display: none !important;
}

/* --- Reloj Empotrado / Hundido (Embedded Clock Pill Neumórfico - Inset Recessed) --- */
.header-center-clock-container,
.sidebar-datetime-footer {
    flex-shrink: 0 !important;
    width: 100% !important;
    padding: 0.5rem 0.5rem 0.75rem 0.5rem !important;
    box-sizing: border-box !important;
    border-top: 1px solid var(--card-border) !important;
    background: transparent !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

.embedded-clock-pill,
.sidebar-gemini-clock-pill,
#sidebarGeminiClockPill {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    background: linear-gradient(180deg, rgba(22, 36, 48, 0.95) 0%, rgba(30, 48, 62, 0.92) 100%) !important;
    border: 1.5px solid rgba(12, 22, 30, 0.75) !important;
    border-bottom: 1.5px solid rgba(255, 255, 255, 0.16) !important;
    border-right: 1.5px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 9999px !important;
    box-shadow: 
        inset 0 6px 10px rgba(0, 0, 0, 0.65),
        inset 0 2px 4px rgba(0, 0, 0, 0.75),
        inset 0 -1px 3px rgba(0, 229, 255, 0.04),
        0 1px 1px rgba(255, 255, 255, 0.12) !important;
    box-sizing: border-box !important;
    user-select: none !important;
    width: 100% !important;
    max-width: 326px !important;
    margin: 0 auto !important;
    padding: 0.38rem 1.05rem !important;
    gap: 2px !important;
    overflow: hidden !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

[data-theme="light"] .embedded-clock-pill,
body.light-theme .embedded-clock-pill,
[data-theme="light"] .sidebar-gemini-clock-pill,
body.light-theme .sidebar-gemini-clock-pill,
[data-theme="light"] #sidebarGeminiClockPill,
body.light-theme #sidebarGeminiClockPill {
    background: rgba(230, 238, 245, 0.9) !important;
    border: 1.5px solid rgba(180, 195, 210, 0.8) !important;
    border-bottom: 1.5px solid rgba(255, 255, 255, 0.6) !important;
    box-shadow: 
        inset 0 4px 8px rgba(0, 0, 0, 0.15),
        inset 0 1px 3px rgba(0, 0, 0, 0.2),
        0 1px 1px rgba(255, 255, 255, 0.8) !important;
}

/* Renglón 1: Hora con Brillo Neón Cyan */
.clock-time-row,
.sidebar-clock-time-segment,
#sidebarGeminiClockPill .sidebar-clock-time-segment {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    color: #00e5ff !important;
    background: transparent !important;
    font-size: 1.04rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.4px !important;
    font-variant-numeric: tabular-nums !important;
    line-height: 1.15 !important;
    white-space: nowrap !important;
    text-shadow: 0 0 10px rgba(0, 229, 255, 0.85), 0 0 18px rgba(0, 229, 255, 0.4) !important;
}

.clock-time-row svg,
.sidebar-clock-time-segment svg {
    width: 16px !important;
    height: 16px !important;
    flex-shrink: 0 !important;
    stroke: #00e5ff !important;
    filter: drop-shadow(0 0 5px rgba(0, 229, 255, 0.75)) !important;
}

/* Renglón 2: Fecha Nítida Blanca/Gris */
.clock-date-row,
.sidebar-clock-date-segment,
#sidebarGeminiClockPill .sidebar-clock-date-segment {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 5px !important;
    font-size: 0.54rem !important;
    font-weight: 500 !important;
    color: #f1f5f9 !important;
    background: transparent !important;
    text-align: center !important;
    white-space: nowrap !important;
    line-height: 1.15 !important;
    letter-spacing: 0px !important;
}

.clock-date-row svg,
.sidebar-clock-date-segment svg {
    width: 11px !important;
    height: 11px !important;
    flex-shrink: 0 !important;
    stroke: #f1f5f9 !important;
    opacity: 0.92 !important;
}

.sidebar-toggle-btn {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    transition: all 0.2s ease;
}
.sidebar-toggle-btn:hover {
    background: var(--primary-alpha);
    color: var(--primary);
    border-color: var(--primary);
}

.sidebar-float-btn {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    z-index: 150;
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    box-shadow: var(--shadow-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar-float-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: scale(1.05);
    box-shadow: 0 4px 15px var(--primary-alpha);
}


.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.brand-logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    font-weight: 800;
    box-shadow: 0 4px 15px var(--primary-alpha);
    font-family: var(--font-heading);
}

.brand-name {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.3rem;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.menu-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.menu-item button {
    width: 100%;
    background: rgba(100, 100, 100, 0.05);
    border: 1px solid var(--card-border); margin-bottom: 0.5rem;
    color: var(--text-secondary);
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    text-align: left;
    outline: none;
}
[data-theme="light"] .menu-item button {
    background: rgba(0, 0, 0, 0.03);
}


.menu-item button svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.menu-item button:hover {
    background: var(--primary-alpha);
    color: var(--primary);
}

.menu-item.active button {
    background: linear-gradient(135deg, var(--primary) 0%, rgba(139, 92, 246, 0.8) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-top: 1px solid var(--card-border);
    padding-top: 1.5rem;
}

.theme-toggle-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.theme-switch {
    background: var(--primary-alpha);
    border: 1px solid var(--card-border);
    width: 55px;
    height: 28px;
    border-radius: 14px;
    cursor: pointer;
    position: relative;
    outline: none;
}

.theme-switch-slider {
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    box-shadow: var(--shadow-sm);
    transition: left 0.2s ease;
}

[data-theme="light"] .theme-switch-slider {
    left: 29px;
    background: var(--primary);
}

/* --- área de contenido principal y contenedor maestro con marco perimetral continuo (4mm) --- */
.main-content,
.main-content-wrapper {
    margin: 0 !important;
    margin-left: 0 !important;
    flex-grow: 1;
    width: calc(100vw - 280px);
    padding: var(--perimeter-stroke-width) !important; /* Marco perimetral continuo de 4mm */
    height: 100vh !important;
    max-height: 100vh !important;
    box-sizing: border-box !important;
    display: flex;
    flex-direction: column;
    overflow: hidden !important; /* El marco exterior es estático; el lienzo interior hace scroll */
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--card-bg) !important; /* Color y material idénticos a la barra lateral */
    backdrop-filter: var(--glass-blur) !important; /* Mismo desenfoque y difuminado que el sidebar */
    -webkit-backdrop-filter: var(--glass-blur) !important;
    border: none !important;
    border-radius: 0 !important; /* Bordes exteriores 100% rectos adaptados a la pantalla */
    box-shadow: none !important;
}
.main-content.sidebar-collapsed,
.main-content-wrapper.sidebar-collapsed {
    margin: 0 !important;
    margin-left: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    border-radius: 0 !important;
    padding: var(--perimeter-stroke-width) !important;
}

/* --- Lienzo interior de trabajo (Esquinas internas redondeadas en los 4 lados) --- */
.main-canvas-inner {
    flex: 1;
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    background: transparent !important;
    border-radius: 8px !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    box-sizing: border-box;
}


/* --- cabecera superior --- */
.header-top {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-bottom: 1rem;
    width: 100%;
}


.welcome-msg h1 {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 0.25rem;
}

.welcome-msg p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    outline: none;
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    background: var(--primary-alpha);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, rgba(139, 92, 246, 0.9) 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary) 100%);
    color: white;
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.35);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent) 0%, rgba(16, 185, 129, 0.9) 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.25);
}

.btn-accent:hover {
    background: linear-gradient(135deg, var(--accent-hover) 0%, var(--accent) 100%);
    color: white;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

.btn-sm {
    padding: 0.5rem 0.9rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

/* --- vistas spa --- */
.view {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
    height: 100%;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.view.active {
    display: block;
}

#viewDashboard.view.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Agenda, Catálogo y Comunicador: misma alineación de altura superior e inferior que el sidebar */
#viewAgenda.view.active,
#viewCatalog.view.active {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}


/* --- HOMOLOGACIÓN TOTAL DE MÁRGENES AL CONTENEDOR (4 MM PERIMETRALES UNIFORMES EN TODOS LOS MÓDULOS) --- */
.main-content,
.main-content-wrapper,
body.in-cognitools-view .main-content,
body.in-cognitools-view .main-content-wrapper,
body.in-acp-view .main-content,
body.in-acp-view .main-content-wrapper,
body.in-corrigetea-view .main-content,
body.in-corrigetea-view .main-content-wrapper,
body.in-comunicador-view .main-content,
body.in-comunicador-view .main-content-wrapper,
body.in-standalonetest-view .main-content,
body.in-neurofit-view .main-content,
body.in-neurofit-view .main-content-wrapper,
body.in-standalonetest-view .main-content-wrapper {
    margin: 0 !important;
    margin-left: 0 !important;
    padding: 4mm !important;
    height: 100vh !important;
    max-height: 100vh !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

body.in-cognitools-view .main-content.sidebar-collapsed,
body.in-acp-view .main-content.sidebar-collapsed,
body.in-corrigetea-view .main-content.sidebar-collapsed,
body.in-comunicador-view .main-content.sidebar-collapsed,
body.in-neurofit-view .main-content.sidebar-collapsed,
body.in-standalonetest-view .main-content.sidebar-collapsed {
    margin: 0 !important;
    margin-left: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    border-radius: 0 !important;
    padding: 4mm !important;
}

.main-canvas-inner,
body.in-cognitools-view .main-canvas-inner,
body.in-acp-view .main-canvas-inner,
body.in-corrigetea-view .main-canvas-inner,
body.in-comunicador-view .main-canvas-inner,
body.in-neurofit-view .main-canvas-inner,
body.in-standalonetest-view .main-canvas-inner {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.view.active,
#viewCognitools.view.active,
#viewAcp.view.active,
#viewCorrigetea.view.active,
#viewComunicador.view.active,
#viewStandaloneTest.view.active,
#viewRegister.view.active,
#viewAgenda.view.active,
#viewCatalog.view.active,
#viewDashboard.view.active,
#viewActivityReport.view.active,
#viewDownloads.view.active,
#viewExpediente.view.active {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    flex: 1 !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 8px !important;
    border: none !important;
    box-shadow: none !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

#viewRegister > .card,
#viewAgenda > .card,
#viewAgenda .agenda-main-card,
#viewAgenda #agendaAiCopilotPanel,
#viewCatalog > .card,
#viewExpediente > .card,
#viewActivityReport > .card,
#viewDownloads > .card,
#viewDashboard > .card {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    flex: 1 !important;
    margin: 0 !important;
    border-radius: 8px !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

#iframeCogniTools,
#iframeAcp,
#iframeCorrigeTea,
#iframeComunicador,
#standaloneTestIframe {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    flex: 1 !important;
    border: none !important;
    border-radius: 8px !important;
    display: block !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

/* Registro de Historia Clínica: misma alineación inferior que el sidebar */
#viewRegister.view.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#viewRegister > .card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 0;
}

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

/* --- dashboard y widgets --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
}

.stat-icon.blue {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
}
.stat-icon.purple {
    background: linear-gradient(135deg, var(--primary) 0%, #6d28d9 100%);
}
.stat-icon.green {
    background: linear-gradient(135deg, var(--accent) 0%, #047857 100%);
}
.stat-icon.orange {
    background: linear-gradient(135deg, #f97316 0%, #c2410c 100%);
}

.stat-info h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-info .stat-value {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 800;
    margin-top: 0.1rem;
}

/* --- sección pacientes (Directorio Clínico y Google Calendar Lateral ampliado +5% -> 420px) --- */
.patients-section {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 420px !important;
    gap: 1.25rem !important;
    flex: 1 !important;
    min-height: 0 !important;
}

@media (max-width: 768px) and (orientation: portrait) {
    .patients-section {
        grid-template-columns: 1fr !important;
    }
}

/* --- Bisel original restaurado en Directorio Clínico y Agenda --- */
.patients-section > .card,
.patients-section > div > .card {
    background: var(--card-bg) !important;
    border: 1px solid var(--card-border) !important;
    backdrop-filter: var(--glass-blur) !important;
    -webkit-backdrop-filter: var(--glass-blur) !important;
    border-radius: var(--radius-lg, 20px) !important;
    box-shadow: var(--shadow-sm) !important;
    transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.2s ease;
}

.patients-section > .card:hover,
.patients-section > div > .card:hover {
    border-color: rgba(56, 189, 248, 0.35) !important;
    box-shadow: var(--shadow-md) !important;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

.card-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-bar {
    position: relative;
    margin-bottom: 1.5rem;
}

.search-input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 0.75rem 2.4rem 0.75rem 2.5rem;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    outline: none;
}

.search-input:focus {
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.25);
    box-shadow: 0 0 0 3px var(--primary-alpha);
}

.search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 16px;
    height: 16px;
}

.search-clear-btn {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.14);
    color: var(--text-muted, #94a3b8);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
    line-height: 1;
    z-index: 10;
    user-select: none;
}
.search-input:not(:placeholder-shown) ~ .search-clear-btn,
#searchPatientsInput:not(:placeholder-shown) ~ #clearSearchPatients {
    display: flex !important;
}
body.light-theme .search-clear-btn {
    background: rgba(148, 163, 184, 0.2);
    color: #64748b;
}
.search-clear-btn:hover {
    background: rgba(239, 68, 68, 0.28);
    color: #f87171;
    transform: translateY(-50%) scale(1.1);
}
body.light-theme .search-clear-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}
.search-clear-btn:active {
    transform: translateY(-50%) scale(0.92);
}

.patient-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
    min-height: 0;
}

.patient-row {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.patient-row:hover {
    background: var(--primary-alpha);
    border-color: var(--primary);
}

.patient-meta-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.patient-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-alpha) 0%, var(--primary) 100%);
    color: white;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.patient-info-desc h4 {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.15rem;
}

.patient-info-desc p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.patient-tag {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    display: inline-block;
}

.tag-infantil {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}
.tag-adolescente {
    background: rgba(249, 115, 22, 0.15);
    color: #fb923c;
}
.tag-adulto {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.patient-actions {
    display: flex;
    gap: 0.5rem;
}

/* --- formatería organizada --- */
.downloads-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 0.75rem;
    overflow-x: auto;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 1.25rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
}

.tab-btn:hover {
    color: var(--primary);
    background: var(--primary-alpha);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 10px var(--primary-alpha);
}

.formats-grid.view-excel {
    display: block !important;
    width: 100% !important;
    grid-template-columns: none !important;
    gap: 0 !important;
}

.formats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.format-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    overflow: hidden;
}

.format-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
}

.format-card.historias::before { background: var(--primary); }
.format-card.consentimientos::before { background: var(--accent); }
.format-card.anamnesis::before { background: #f97316; }
.format-card.guias::before { background: #3b82f6; }
.format-card.pruebas_psicologicas::before { background: #8b5cf6; }
.format-card.institucionales::before { background: #10b981; }

.format-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
}
.format-card:hover {
    transform: translateY(-2px);
    border-color: rgba(0, 229, 255, 0.4);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

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

/* Icono moderno y sutil sin caja tosca roja con texto PDF */
.format-icon-doc {
    width: 32px;
    height: 32px;
    background: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(56, 189, 248, 0.25);
    transition: all 0.2s ease;
}

.format-card:hover .format-icon-doc {
    background: rgba(56, 189, 248, 0.22);
    color: #ffffff;
    transform: scale(1.05);
}

.format-icon-doc.word-style {
    background: rgba(59, 130, 246, 0.12);
    color: #3b82f6;
    border-color: rgba(59, 130, 246, 0.25);
}

.format-size {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* ==========================================================================
   MODAL VISUALIZADOR DE PDFS DIRECTO EN PANTALLA COMPLETA
   ========================================================================== */
.pdf-viewer-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 999999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    box-sizing: border-box;
    animation: fadeInPdf 0.18s ease-out;
}

@keyframes fadeInPdf {
    from { opacity: 0; transform: scale(0.99); }
    to { opacity: 1; transform: scale(1); }
}

.pdf-viewer-modal-window {
    width: 100vw;
    height: 100vh;
    background: var(--bg-app, #0f172a);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
}

.pdf-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1.25rem;
    background: var(--card-bg, #1e293b);
    border-bottom: 1px solid var(--card-border);
    flex-shrink: 0;
    gap: 1rem;
    z-index: 10;
}

.pdf-viewer-title-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex: 1;
}

.pdf-viewer-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.pdf-viewer-body {
    flex: 1;
    width: 100%;
    height: 100%;
    min-height: 0;
    background: #323639;
    display: flex;
    overflow: hidden;
}

.pdf-viewer-body iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.format-body h4 {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.5rem;
}

.format-body p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.format-footer {
    margin-top: auto;
    display: flex;
    justify-content: flex-end;
}

/* --- formulario unificado dinámico --- */
.register-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 2rem;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

@media (max-width: 768px) {
    .register-layout {
        grid-template-columns: 1fr;
    }
}

.form-navigation {
    display: flex;
    flex-direction: column;
    gap: 3px;
    height: 100%;
    overflow-y: auto;
    justify-content: space-between;
    padding: 0.25rem 0;
}
.form-navigation::-webkit-scrollbar {
    width: 6px;
}
.form-navigation::-webkit-scrollbar-track {
    background: transparent;
}
.form-navigation::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}
.form-navigation::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.form-nav-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    padding: 0 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    flex: 1;
    min-height: 0;
    max-height: 44px;
    display: flex;
    align-items: center;
    text-align: left;
    outline: none;
    letter-spacing: 0.01em;
    transition: background 0.15s, color 0.15s;
}

.form-nav-item:hover {
    color: var(--primary);
    background: var(--primary-alpha);
}

.form-nav-item.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px var(--primary-alpha);
}

.form-nav-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

[data-theme="light"] .form-nav-item {
    background: rgba(0, 0, 0, 0.03);
    color: #0F172A; /* Forzar legibilidad (muy oscuro) */
    font-weight: 700;
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .form-nav-item:hover {
    color: var(--primary-hover);
    background: rgba(0, 131, 143, 0.15); /* primary alpha */
}

[data-theme="light"] .form-nav-item.disabled {
    opacity: 0.6;
}

.form-section {
    display: none;
}

.form-section.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
    overflow-y: auto;
    height: 100%;
    padding-right: 0.5rem;
}

/* Formulario: scrollable interno sin desbordarse */
#viewRegister .card .register-layout form {
    overflow-y: auto;
    height: 100%;
    min-height: 0;
    padding-right: 0.25rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

@media (max-width: 600px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group-full {
    grid-column: 1 / -1;
}

.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 0.7rem 0.9rem;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    outline: none;
}

[data-theme="light"] #narrativeReportTextarea {
    background: var(--input-bg) !important;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-alpha);
}

.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    background: rgba(0, 0, 0, 0.1);
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--card-border);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-label input {
    cursor: pointer;
    accent-color: var(--primary);
}

.form-actions-bar {
    display: flex;
    justify-content: space-between;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--card-border);
}

/* --- expediente digital y visualización --- */
.expediente-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 1rem;
    margin-bottom: 0.75rem;
    flex-shrink: 0;
}

.expediente-title h2 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 800;
}

.expediente-meta {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.expediente-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.expediente-block {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}

.expediente-block-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.expediente-fields {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem 2rem;
}

@media (max-width: 768px) {
    .expediente-fields {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 480px) {
    .expediente-fields {
        grid-template-columns: 1fr;
    }
}

.expediente-field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.expediente-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.expediente-value {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.expediente-value-full {
    grid-column: 1 / -1;
    white-space: pre-wrap;
    background: rgba(0, 0, 0, 0.1);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--card-border);
}

.qna-block {
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.qna-block:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.qna-question {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.qna-answer {
    font-size: 0.95rem;
    color: var(--text-primary);
    background: var(--input-bg);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--card-border);
}

.qna-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: baseline;
    padding: 0.4rem 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
}

.qna-inline .qna-question {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0;
}

.qna-inline .qna-answer {
    font-size: 0.95rem;
    color: var(--text-primary);
    background: transparent;
    border: none;
    padding: 0;
    font-weight: 500;
}

.qna-full-width {
    grid-column: 1 / -1;
}

/* --- módulo de registro de avance --- */
#avanceEditor[placeholder]:empty:before {
    content: attr(placeholder);
    color: var(--text-secondary);
    opacity: 0.7;
    pointer-events: none;
    display: block; /* For Firefox */
}
#avanceEditor {
    white-space: pre-wrap;
}
#avanceEditor ul, #avanceEditor ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

#avanceFloatingToolbar {
    display: flex; /* overridden by JS display logic */
    align-items: center;
}
.toolbar-btn {
    background: transparent;
    border: none;
    color: var(--text);
    width: 32px;
    height: 32px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.2s, color 0.2s;
}
.toolbar-btn:hover {
    background: var(--primary-alpha);
    color: var(--primary);
}
.toolbar-btn.active {
    background: var(--primary);
    color: white;
}

/* --- módulo de análisis funcional y de evolución --- */
.tab-subnavigation {
    display: flex;
    gap: 4px;
    margin-bottom: 0;
    background: transparent;
    padding: 0 4px;
    border-radius: 0;
    width: 100%;
    overflow: hidden;
    flex-wrap: wrap;
    border-bottom: 2px solid var(--card-border);
    scrollbar-width: none;
}

.tab-subnavigation.folder-tabs {
    flex-wrap: wrap;
    justify-content: space-between;
    flex-shrink: 0;
}

/* ── Cadena flex para alinear el Planificador al borde inferior del sidebar ── */
#viewExpediente.view.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    gap: 0; /* ELIMINAR ESPACIO ENTRE PESTAÑAS Y CONTENEDOR */
    padding-bottom: 0;
}

/* Contenedor que envuelve todos los sub-views */
.expediente-body-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Cada sub-view ocupa todo el espacio del contenedor */
.expediente-subview {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Sub-views que requieren scroll interno natural porque no tienen un card expandido con su propio scroll */
#subviewHistorial,
#subviewAvance,
#subviewSesiones,
#subviewAnalisis,
#subviewInforme,
#subviewEvaluaciones,
#subviewGrabaciones,
#subviewFormatos,
#subviewBateria,
#subviewBitacora {
    overflow-y: auto;
    padding-right: 0.5rem; /* Evitar que el scroll tape el contenido lateral */
    padding-bottom: 2rem; /* Espacio extra al final */
}

/* La tarjeta del Planificador se expande al 100% */
#subviewPlan > .card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 0;
}

/* El grid de dos columnas (checklist + gantt) llena el resto */
#subviewPlan .planner-main-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    /* Selector de necesidades: fluido entre 220px y 360px — se adapta al zoom y pantalla */
    grid-template-columns: clamp(220px, 25%, 360px) 1fr;
    gap: 1rem;
    overflow: hidden;
    align-items: stretch;
}

/* Columna checklist: scroll interno */
.planner-checklist-container {
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    box-sizing: border-box;
    /* Scroll suave nativo */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Columna gantt: scroll interno */
.planner-gantt-container {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

#ganttScrollArea {
    flex: 1;
    min-height: 0;
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ── Responsivo: en pantallas <900px el Planificador apila las columnas ── */
@media (max-width: 900px) {
    #subviewPlan .planner-main-grid {
        grid-template-columns: 1fr;
        grid-template-rows: 300px 1fr;
        overflow-y: auto;
    }
    .planner-checklist-container {
        height: 300px;
        max-height: 300px;
    }
    .planner-gantt-container {
        height: auto;
        min-height: 300px;
    }
}

.subtab-btn {
    background: rgba(255,255,255,0.03);
    border: 1px solid transparent;
    border-bottom: none;
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 8px 8px 0 0;
    flex: 1 1 0%;
    min-width: 0;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin-right: 2px;
    white-space: normal;
    line-height: 1.2;
    position: relative;
    top: 1px;
}
.subtab-btn:not(:last-child)::after {
    content: '';
    position: absolute;
    right: -2px;
    top: 20%;
    height: 60%;
    width: 1px;
    background: rgba(255,255,255,0.1);
}
.subtab-btn.active::after {
    display: none;
}
.subtab-btn:hover {
    color: var(--text);
    background: rgba(255,255,255,0.08);
}
.subtab-btn.active {
    background: var(--card-bg, var(--surface));
    color: var(--primary);
    border: 1px solid var(--card-border);
    border-bottom: 1px solid var(--card-bg, var(--surface));
    font-weight: 600;
    z-index: 2;
    border-radius: 8px 8px 0 0 !important;
}

.analysis-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.analysis-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 600px) {
    .analysis-form-row {
        grid-template-columns: 1fr;
    }
}

.clinical-notes-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.note-entry {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.note-entry-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 0.4rem;
    margin-bottom: 0.6rem;
}

.note-entry-body {
    font-size: 0.85rem;
    white-space: pre-wrap;
}

/* --- modal --- */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    overflow-y: auto;
    box-sizing: border-box;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-app);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.3s ease-out;
    box-sizing: border-box;
    margin: auto;
}

#configModal .modal-content {
    max-width: 650px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
}

#configModal .modal-header {
    position: sticky;
    top: -2rem;
    background: var(--bg-app);
    z-index: 10;
    padding-top: 0.25rem;
}

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

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    outline: none;
}

.close-btn:hover {
    color: var(--danger);
}

/* --- ESTILOS DE BORRADOR --- */
.patient-row.draft-row {
    border-color: rgba(245, 158, 11, 0.4);
    background: rgba(245, 158, 11, 0.03);
}
.patient-row.draft-row:hover {
    background: rgba(245, 158, 11, 0.08);
    border-color: var(--warning);
}
.tag-draft {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

/* --- ESTILOS DE INFORMANTES ADICIONALES --- */
.informant-row {
    display: grid;
    grid-template-columns: 1.5fr 2fr 1.5fr 1fr 2fr auto;
    gap: 0.75rem;
    align-items: center;
    background: rgba(0, 0, 0, 0.15);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--card-border);
    margin-bottom: 0.5rem;
}
[data-theme="light"] .informant-row {
    background: rgba(0, 0, 0, 0.02);
}
@media (max-width: 768px) {
    .informant-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}

/* --- ESTILOS DEL GENOGRAMA --- */
.genogram-section-container {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 1.5rem;
    background: rgba(0, 0, 0, 0.15);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--card-border);
    grid-column: 1 / -1;
}
[data-theme="light"] .genogram-section-container {
    background: rgba(0, 0, 0, 0.02);
}
@media (max-width: 1200px), (orientation: portrait) {
    .genogram-section-container {
        grid-template-columns: 1fr;
    }
}
.genogram-preview-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.genogram-preview {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 440px;
    overflow: hidden;
    position: relative;
}
[data-theme="light"] .genogram-preview {
    background: #ffffff;
}
.genogram-svg {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}
.genogram-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    justify-content: center;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-sm);
    width: 100%;
}

/* --- ESTILOS DE CARGA DE IA Y TOAST --- */
.clinical-toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    backdrop-filter: var(--glass-blur);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 1100;
    font-weight: 600;
    animation: slideInUp 0.3s ease-out;
}
.ai-loader-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 0.5rem;
}
.ai-loader-progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--card-border);
}
.ai-loader-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
    width: 0%;
    transition: width 0.4s ease;
}
.ai-loader-steps {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.ai-loader-step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.ai-loader-step.completed {
    color: var(--accent);
}
.ai-loader-step.active {
    color: var(--primary);
    font-weight: 600;
}
.ai-loader-step-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
}
.ai-loader-step.completed .ai-loader-step-dot {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}
.ai-loader-step.active .ai-loader-step-dot {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-alpha);
    color: var(--primary);
}

.prompt-copiable-container {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-top: 1rem;
}
.prompt-copiable-textarea {
    width: 100%;
    height: 150px;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: monospace;
    font-size: 0.8rem;
    padding: 0.5rem;
    resize: none;
    outline: none;
    margin-bottom: 0.75rem;
}

/* --- ESTILOS DE IMPRESIÓN EXCLUSIVOS --- */
@media print {
    body {
        background: white !important;
        color: black !important;
        font-size: 11pt !important;
    }
    
    .sidebar,
    .header-top,
    .btn,
    .app-container > *:not(.main-content),
    .view:not(.active),
    .tab-subnavigation,
    .form-actions-bar,
    .note-creation-block,
    .clinical-notes-list::-webkit-scrollbar,
    .patient-actions,
    .search-bar {
        display: none !important;
    }
    
    .app-container {
        display: block !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    
    .card,
    .expediente-block,
    .note-entry {
        background: transparent !important;
        border: 1px solid #ddd !important;
        box-shadow: none !important;
        color: black !important;
        margin-bottom: 1.2cm !important;
        page-break-inside: avoid !important;
        padding: 1.2cm !important;
    }
    
    .expediente-block-title {
        color: #111 !important;
        border-bottom: 1.5pt solid #333 !important;
        font-size: 12pt !important;
        font-weight: bold !important;
        margin-bottom: 0.5cm !important;
    }
    
    .expediente-fields {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.4cm 0.8cm !important;
    }
    
    .expediente-value-full {
        background: transparent !important;
        border: 1px solid #eee !important;
        color: black !important;
    }
    
    .patient-tag {
        border: 1px solid #888 !important;
        background: transparent !important;
        color: black !important;
    }
    
    .print-logo-header {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        border-bottom: 2pt solid black;
        padding-bottom: 0.4cm;
        margin-bottom: 0.8cm;
    }
    
    .print-logo-header .clinic-info {
        text-align: right;
    }

    /* --- Impresión del Informe Narrativo en Prosa --- */
    body.print-mode-informe #subviewHistorial,
    body.print-mode-informe #subviewSesiones,
    body.print-mode-informe #subviewAnalisis {
        display: none !important;
    }

    body.print-mode-informe #subviewInforme {
        display: block !important;
    }

    body.print-mode-informe #narrativeReportTextarea {
        display: none !important; /* Ocultar textarea y usar el div */
    }

    body.print-mode-informe .print-only-report {
        display: block !important;
        white-space: pre-wrap !important;
        font-family: 'Georgia', 'Times New Roman', serif !important;
        font-size: 11pt !important;
        line-height: 1.6 !important;
        color: black !important;
        text-align: justify !important;
    }

    /* --- Impresión de la Captura Original Q&A --- */
    body.print-mode-captura #subviewInforme,
    body.print-mode-captura #subviewSesiones,
    body.print-mode-captura #subviewAnalisis {
        display: none !important;
    }

    body.print-mode-captura #subviewHistorial {
        display: block !important;
    }
    
    body.print-mode-captura .expediente-block {
        background: transparent !important;
        border: 1px solid #bbb !important;
        box-shadow: none !important;
        color: black !important;
        margin-bottom: 0.6cm !important;
        page-break-inside: avoid !important;
        padding: 0.6cm !important;
    }

    body.print-mode-captura .expediente-block-title {
        color: #111 !important;
        border-bottom: 1.5pt solid #222 !important;
        font-size: 11pt !important;
        font-weight: bold !important;
        margin-bottom: 0.3cm !important;
        padding-bottom: 0.1cm !important;
        text-transform: uppercase !important;
        page-break-after: avoid !important;
    }

    body.print-mode-captura .qna-inline {
        display: flex !important;
        gap: 0.3rem !important;
        align-items: baseline !important;
        border-bottom: 1px dotted #888 !important;
        padding: 0.1rem 0 !important;
        margin-bottom: 0.15cm !important;
        page-break-inside: avoid !important;
    }
    
    body.print-mode-captura .qna-inline .qna-question {
        font-size: 9.5pt !important;
        color: #222 !important;
        font-weight: bold !important;
        margin-bottom: 0 !important;
    }
    
    body.print-mode-captura .qna-inline .qna-answer {
        font-size: 10pt !important;
        color: #000 !important;
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
        font-weight: normal !important;
    }

    body.print-mode-captura .qna-block {
        margin-bottom: 0.3cm !important;
        padding-bottom: 0.2cm !important;
        border-bottom: none !important;
        page-break-inside: avoid !important;
    }

    body.print-mode-captura .qna-question {
        font-size: 9.5pt !important;
        color: #222 !important;
        font-weight: bold !important;
        margin-bottom: 0.05cm !important;
    }

    body.print-mode-captura .qna-answer {
        font-size: 10pt !important;
        color: #000 !important;
        background: #fafafa !important;
        border: 1px solid #ccc !important;
        padding: 0.2cm 0.3cm !important;
        border-radius: 3px !important;
        white-space: pre-wrap !important;
    }

    body.print-mode-captura .qna-full-width {
        grid-column: 1 / -1 !important;
    }

    /* --- Impresión del Genograma SVG e Informantes --- */
    body.print-mode-captura .genogram-preview,
    body.print-mode-informe .genogram-preview {
        background: white !important;
        border: 1px solid #ccc !important;
        min-height: auto !important;
        padding: 0.5cm !important;
        page-break-inside: avoid !important;
        margin-top: 0.5cm !important;
        margin-bottom: 0.5cm !important;
    }
    body.print-mode-captura .genogram-svg,
    body.print-mode-informe .genogram-svg {
        background: white !important;
        border: none !important;
        box-shadow: none !important;
        filter: none !important;
    }
    body.print-mode-captura .genogram-legend,
    body.print-mode-informe .genogram-legend {
        background: transparent !important;
        color: black !important;
        border: 1px solid #ddd !important;
    }
    body.print-mode-captura .informant-row {
        background: transparent !important;
        border: 1px solid #ddd !important;
        color: black !important;
        grid-template-columns: 1fr 2fr 1fr 1fr 2fr !important;
    }
    body.print-mode-captura .btn-delete-informant {
        display: none !important;
    }
}

.print-only-report {
    display: none;
}

.print-logo-header {
    display: none;
}

/* --- Estilos Enriquecidos para Heredofamiliares --- */
.heredo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    margin-top: 0.5rem;
}
.heredo-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.heredo-item:hover {
    border-color: var(--primary-alpha);
    background: rgba(255, 255, 255, 0.04);
}
.heredo-detail-panel {
    animation: slideDown 0.25s ease-out;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Estilos Enriquecidos para Antropometría y Somatotipo --- */
.antropo-container {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
@media (max-width: 1200px), (orientation: portrait) {
    .antropo-container {
        grid-template-columns: 1fr;
    }
}
.antropo-card {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
}
.antropo-results {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    background: rgba(139, 92, 246, 0.05);
    border: 1px dashed var(--primary);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
    min-height: 220px;
}
.somatotipo-badge-large {
    font-size: 1.2rem;
    font-weight: 800;
    padding: 0.4rem 1.2rem;
    border-radius: var(--radius-xl);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: var(--shadow-md);
    display: inline-block;
    margin-top: 0.5rem;
}
.somatotipo-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin-top: 0.5rem;
}
.badge-ecto {
    background: rgba(59, 130, 246, 0.15) !important;
    color: #60a5fa !important;
    border: 1px solid rgba(59, 130, 246, 0.3) !important;
}
.badge-meso {
    background: rgba(16, 185, 129, 0.15) !important;
    color: #34d399 !important;
    border: 1px solid rgba(16, 185, 129, 0.3) !important;
}
.badge-endo {
    background: rgba(245, 158, 11, 0.15) !important;
    color: #fbbf24 !important;
    border: 1px solid rgba(245, 158, 11, 0.3) !important;
}
.badge-indet {
    background: rgba(107, 114, 128, 0.15) !important;
    color: #9ca3af !important;
    border: 1px solid rgba(107, 114, 128, 0.3) !important;
}

/* Print optimizations for new features */
@media print {
    .heredo-item {
        background: transparent !important;
        border: 1px solid #ddd !important;
        page-break-inside: avoid !important;
    }
    .antropo-container {
        display: block !important;
    }
    .antropo-card {
        border: 1px solid #ddd !important;
        margin-bottom: 0.5cm !important;
        background: transparent !important;
    }
    .antropo-results {
        border: 1px dashed #777 !important;
        background: transparent !important;
        min-height: auto !important;
        padding: 0.5cm !important;
    }
}

/* =========================================================================
   🔑 ESTILOS DEL MÓDULO DE SEGURIDAD (LOCK SCREEN)
   ========================================================================= */

.lock-screen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #080c14;
    background-image: 
        radial-gradient(circle at 15% 20%, rgba(2, 132, 199, 0.28) 0%, transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(99, 102, 241, 0.25) 0%, transparent 45%),
        radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.12) 0%, transparent 60%),
        radial-gradient(circle at 50% 10%, rgba(56, 189, 248, 0.15) 0%, transparent 50%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='rgba(56,189,248,0.06)' stroke-width='1.2'%3E%3Cpath d='M60 20 C40 30 25 50 35 75 C42 90 55 90 60 70 C65 90 78 90 85 75 C95 50 80 30 60 20 Z'/%3E%3Cpath d='M60 35 C48 45 38 60 46 75 C52 85 58 80 60 65 C62 80 68 85 74 75 C82 60 72 45 60 35 Z' stroke='rgba(99,102,241,0.05)'/%3E%3Ccircle cx='60' cy='20' r='3' fill='rgba(56,189,248,0.1)'/%3E%3Cpath d='M60 20 Q50 5 40 10 M60 20 Q70 5 80 10' stroke='rgba(132,204,22,0.1)'/%3E%3C/g%3E%3C/svg%3E");
    background-size: cover, cover, cover, cover, 140px 140px;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: fadeIn 0.4s ease-out;
    position: relative;
    overflow: hidden;
}

.lock-screen-overlay::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, transparent 30%, rgba(8, 12, 20, 0.6) 90%);
    pointer-events: none;
}

[data-theme="light"] .lock-screen-overlay {
    background: rgba(240, 244, 253, 0.9);
}

.lock-card {
    background: rgba(15, 23, 42, 0.78);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 30px 80px -10px rgba(0, 0, 0, 0.8), 0 0 50px rgba(2, 132, 199, 0.2);
    border-radius: 24px;
    width: 100%;
    max-width: 430px;
    padding: 2.75rem 2.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    animation: scaleUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    z-index: 10;
}

[data-theme="light"] .lock-card {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.1);
}

.lock-logo {
    font-size: 3rem;
    margin-bottom: 1.25rem;
    animation: pulseLogo 3s infinite ease-in-out;
    filter: drop-shadow(0 4px 10px var(--primary-alpha));
}

#lockTitle {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#lockSubtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 1.5rem;
}

/* =========================================================================
   📅 ESTILOS DE LA AGENDA Y CALENDARIO
   ========================================================================= */

.calendar-grid-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 0.5rem;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--card-border);
    font-family: var(--font-heading);
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: 1fr;
    gap: 4px;
    align-content: stretch;
}

.calendar-day {
    min-height: 60px;
    height: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 0.5rem 0.25rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    position: relative;
    user-select: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] .calendar-day {
    background: rgba(0, 0, 0, 0.01);
}

.calendar-day:hover {
    background: var(--primary-alpha);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.calendar-day.prev-date,
.calendar-day.next-date {
    color: var(--text-muted);
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.calendar-day.today {
    border: 2px solid var(--accent) !important;
    font-weight: 700;
    color: var(--accent);
}

.calendar-day.selected {
    background: var(--primary) !important;
    color: white !important;
    border-color: var(--primary) !important;
    box-shadow: 0 4px 15px var(--primary-alpha) !important;
}

.calendar-day.selected .calendar-event-dot {
    background: white !important;
}

/* Eventos en calendario */
.calendar-event-dots-container {
    display: flex;
    gap: 3px;
    justify-content: center;
    align-items: center;
    height: 6px;
    margin-top: auto;
}

.calendar-event-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
}

.calendar-event-dot.confirmada {
    background: #10b981;
}

.calendar-event-dot.pendiente {
    background: #f59e0b;
}

.calendar-event-dot.completada {
    background: #6366f1;
}

.calendar-event-dot.cancelada {
    background: #ef4444;
}

/* Elementos de la lista de citas */
.agenda-appointment-item {
    display: flex;
    flex-direction: column;
    padding: 1rem 1.25rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    transition: all 0.25s ease;
    animation: slideIn 0.3s ease-out;
}

[data-theme="light"] .agenda-appointment-item {
    background: rgba(255, 255, 255, 0.5);
}

.agenda-appointment-item:hover {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.04);
    box-shadow: var(--shadow-sm);
    transform: translateX(4px);
}

[data-theme="light"] .agenda-appointment-item:hover {
    background: rgba(255, 255, 255, 0.9);
}

/* =========================================================================
   🎬 ANIMACIONES Y TRANSICIONES PREMIUM
   ========================================================================= */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleUp {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes pulseLogo {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 4px 10px var(--primary-alpha)); }
    50% { transform: scale(1.08); filter: drop-shadow(0 4px 20px var(--primary)); }
}

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

.clinical-toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.88rem;
    font-weight: 550;
    color: var(--text-primary);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    animation: slideIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 350px;
}

[data-theme="light"] .clinical-toast {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.08);
}

.clinical-toast.success {
    border-left: 4px solid var(--success);
}

.clinical-toast.error {
    border-left: 4px solid var(--danger);
    color: #fca5a5;
}

[data-theme="light"] .clinical-toast.error {
    color: #b91c1c;
}

.clinical-toast.warning {
    border-left: 4px solid var(--warning);
}

/* Submenu y apartado de Pruebas Psicológicas */
.submenu {
    list-style: none;
    padding-left: 1.25rem;
    margin-top: 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.submenu.open {
    max-height: 250px !important;
    overflow-y: auto !important;
    opacity: 1;
}

/* Custom scrollbar for submenu */
.submenu::-webkit-scrollbar {
    width: 4px;
}
.submenu::-webkit-scrollbar-track {
    background: transparent;
}
.submenu::-webkit-scrollbar-thumb {
    background: var(--card-border);
    border-radius: var(--radius-sm);
}
.submenu::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.menu-item-sub button {
    width: 100%;
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-align: left;
    outline: none;
    transition: all 0.2s ease;
}

.menu-item-sub button svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.menu-item-sub button:hover {
    background: var(--primary-alpha);
    color: var(--primary);
}

.menu-item-sub.active button {
    background: var(--primary-alpha);
    color: var(--primary);
    font-weight: 600;
}

.menu-item.active-child > button {
    color: var(--primary);
    background: var(--primary-alpha);
}

/* Modo de aplicación de pruebas psicológicas al margen del menú lateral (Sin Traslape, Centrado Perfectamente & Sin Desborde) */
body.fullscreen-test-active .sidebar {
    display: flex !important;
    position: fixed !important;
    top: 1rem !important;
    left: 1rem !important;
    width: 280px !important;
    height: calc(100vh - 2rem) !important;
    z-index: 100 !important;
}

body.fullscreen-test-active .main-content {
    margin-left: 300px !important;
    margin-top: 1rem !important;
    margin-bottom: 1rem !important;
    width: calc(100vw - 315px) !important;
    height: calc(100vh - 2rem) !important;
    padding: 0 !important;
    overflow: hidden !important;
    border-radius: var(--radius-lg) !important;
    box-sizing: border-box !important;
    z-index: 1 !important;
}

body.fullscreen-test-active .header-top {
    display: flex !important;
}

body.fullscreen-test-active #viewStandaloneTest {
    height: 100% !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
}

body.fullscreen-test-active #standaloneTestIframe {
    width: 100% !important;
    height: 100% !important;
    border-radius: var(--radius-lg) !important;
    box-sizing: border-box !important;
}

/* Modo Maximizado (Oculta la barra lateral y la cintilla superior para 100% espacio de pantalla) */
body.test-maximized-fullscreen .sidebar {
    display: none !important;
}

body.test-maximized-fullscreen .header-top {
    display: none !important;
}

body.test-maximized-fullscreen .main-content {
    margin-left: 1rem !important;
    margin-top: 1rem !important;
    width: calc(100vw - 2rem) !important;
    height: calc(100vh - 2rem) !important;
}

/* --- NOM-004 y Plan de Intervención Split View --- */
.evolution-split-container {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    margin-top: 1rem;
}
.evolution-editor-pane {
    flex: 1.2;
    min-width: 0;
}
.evolution-reference-pane {
    flex: 0.8;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: sticky;
    top: 90px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding-right: 0.25rem;
}
.vital-signs-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    background: rgba(0, 0, 0, 0.05);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--card-border);
}
.vital-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.vital-field label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
}
.vital-field input {
    background: var(--bg-app);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 0.35rem 0.5rem;
    font-size: 0.82rem;
    width: 100%;
}
.signature-block {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--card-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.signature-line {
    width: 200px;
    height: 1px;
    background: var(--text-primary);
    margin-bottom: 0.5rem;
}
.signature-title {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}
.signature-cedula {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.autocomplete-container {
    position: relative;
    width: 100%;
}
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
}
.autocomplete-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
.autocomplete-item:hover {
    background: var(--primary-alpha);
    color: var(--primary);
}
.goals-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.goal-card {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
}
.goal-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
}
.goal-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--primary);
}
.goal-text {
    font-size: 0.82rem;
    color: var(--text-primary);
}

/* Print evolution note styles */
@media print {
    .print-evolution-note-only {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        background: #fff !important;
        color: #000 !important;
        z-index: 99999 !important;
        padding: 1.5cm !important;
    }
    .print-evolution-note-only * {
        color: #000 !important;
        background: transparent !important;
    }
}

/* --- Lucide Inline Icons --- */
.inline-icon {
    width: 1.1em;
    height: 1.1em;
    vertical-align: -0.15em;
    display: inline-block;
}

/* Global Lucide Icon Styling para armonizar con el entorno corporativo */
.lucide {
    stroke-width: 1.75; /* Más estilizados y finos */
    opacity: 0.9;       /* Ligeramente transparentes para no saturar la vista */
    transition: all 0.2s ease;
}

button:hover .lucide, a:hover .lucide {
    opacity: 1;         /* Brillo completo al pasar el ratón */
    stroke-width: 2;
}

/* ═══════════════════════════════════════════════════════════════════
   NOTAS RÁPIDAS INTELIGENTES — Sistema Flotante
   ═══════════════════════════════════════════════════════════════════ */

/* ── Botón FAB flotante ─────────────────────────────────────────── */
.qn-fab {
    position: fixed;
    bottom: 74px; /* Justo arriba del micrófono (20px + 44px + 10px) */
    right: 20px; /* Alineado exactamente con el micrófono */
    width: 44px; /* Más pequeño */
    height: 44px; /* Más pequeño */
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #6C5CE7);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(108, 92, 231, 0.45), 0 2px 8px rgba(0,0,0,0.3);
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 25000; /* Siempre encima de cualquier prueba */
    overflow: visible;
    color: white;
}

.qn-fab:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 8px 30px rgba(108, 92, 231, 0.6), 0 4px 12px rgba(0,0,0,0.35);
}

.qn-fab--active {
    transform: scale(0.92);
    background: linear-gradient(135deg, #6C5CE7, var(--primary));
}

.qn-fab-icon {
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.qn-fab--active .qn-fab-icon {
    transform: rotate(45deg);
}

.qn-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: var(--danger, #FF5252);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--bg-main, #0F1117);
    font-family: var(--font-heading);
    letter-spacing: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.qn-fab-ripple {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    animation: qnRipplePulse 2.5s ease-in-out infinite;
}

@keyframes qnRipplePulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50%       { transform: scale(1.6); opacity: 0; }
}

/* ── Overlay de fondo ────────────────────────────────────────────── */
.qn-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(2px);
    z-index: 24999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.qn-overlay--visible {
    opacity: 1;
    pointer-events: auto;
}

/* ── Panel deslizante ────────────────────────────────────────────── */
.qn-panel {
    position: fixed;
    bottom: 128px; /* Ajustado al nuevo bottom del FAB (74px + 44px + 10px) */
    right: 20px;
    width: 285px; /* Reducido de 360px para diseño más compacto */
    max-height: calc(100vh - 12rem);
    background: var(--card-bg, #1A1D27);
    border: 1px solid var(--card-border, rgba(255,255,255,0.08));
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(108,92,231,0.15);
    z-index: 25000; /* Siempre encima de cualquier prueba */
    display: flex;
    flex-direction: column;
    /* overflow hidden removed */
    transform: scale(0.85) translateY(20px);
    transform-origin: bottom right;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    resize: both; overflow: auto; padding-bottom:8px;
}

.qn-panel--open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* ── Header ─────────────────────────────────────────────────────── */
.qn-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 0.9rem 0.6rem;
    border-bottom: 1px solid var(--card-border, rgba(255,255,255,0.06));
    background: linear-gradient(135deg, rgba(108,92,231,0.12), rgba(108,92,231,0.04));
    flex-shrink: 0;
}

.qn-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.qn-icon-ring {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), #6C5CE7);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(108,92,231,0.35);
}

.qn-title {
    font-family: var(--font-heading);
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

.qn-subtitle {
    font-size: 0.7rem;
    color: var(--text-dim);
    font-weight: 500;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.qn-close-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.qn-close-btn:hover {
    background: var(--danger, #FF5252);
    color: white;
    border-color: var(--danger, #FF5252);
}

/* ── Área de composición ─────────────────────────────────────────── */
.qn-compose {
    padding: 0.85rem;
    border-bottom: 1px solid var(--card-border, rgba(255,255,255,0.06));
    flex-shrink: 0;
}

.qn-textarea {
    width: 100%;
    background: var(--bg-main, #0F1117);
    border: 1px solid var(--card-border, rgba(255,255,255,0.1));
    border-radius: 10px;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 0.85rem;
    padding: 0.7rem 0.85rem;
    resize: vertical;
    line-height: 1.5;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    display: block;
}

.qn-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108,92,231,0.15);
}

.qn-textarea::placeholder {
    color: var(--text-dim);
    opacity: 0.6;
    font-size: 0.8rem;
}

.qn-compose-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.5rem;
}

.qn-char-count {
    font-size: 0.7rem;
    color: var(--text-dim);
    font-family: var(--font-mono, monospace);
}

.qn-save-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), #6C5CE7);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: var(--font-heading);
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(108,92,231,0.3);
}

.qn-save-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(108,92,231,0.5);
}

/* ── Lista de notas ─────────────────────────────────────────────── */
.qn-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.85rem;
    background: rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.qn-list-header span {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-family: var(--font-heading);
}

.qn-clear-btn {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.68rem;
    padding: 0.2rem 0.4rem;
    border-radius: 5px;
    transition: all 0.2s;
    font-family: var(--font-body);
}

.qn-clear-btn:hover {
    color: var(--danger, #FF5252);
    border-color: var(--danger, #FF5252);
    background: rgba(255, 82, 82, 0.08);
}

.qn-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.qn-list::-webkit-scrollbar { width: 4px; }
.qn-list::-webkit-scrollbar-track { background: transparent; }
.qn-list::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 2px; }

.qn-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem 1rem;
    color: var(--text-dim);
    text-align: center;
}

.qn-empty-state p {
    font-size: 0.8rem;
    margin: 0;
    opacity: 0.6;
}

/* ── Tarjeta de nota individual ─────────────────────────────────── */
.qn-note-item {
    background: var(--bg-main, rgba(0,0,0,0.2));
    border: 1px solid var(--card-border, rgba(255,255,255,0.06));
    border-radius: 10px;
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.45rem;
    transition: all 0.2s;
    animation: qnNoteIn 0.25s ease;
}

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

.qn-note-item:hover {
    border-color: var(--primary);
    background: rgba(108,92,231,0.06);
}

.qn-note-text {
    font-size: 0.83rem;
    color: var(--text-main);
    line-height: 1.5;
    word-break: break-word;
    margin-bottom: 0.45rem;
}

.qn-note-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.qn-note-date {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.66rem;
    color: var(--text-dim);
    opacity: 0.7;
}

.qn-note-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.qn-note-item:hover .qn-note-actions {
    opacity: 1;
}

.qn-note-copy,
.qn-note-del {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    border: 1px solid var(--card-border);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    color: var(--text-dim);
}

.qn-note-copy:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.qn-note-del:hover {
    background: var(--danger, #FF5252);
    border-color: var(--danger, #FF5252);
    color: white;
}

/* ── Animación de shake (input vacío) ───────────────────────────── */
.qn-shake {
    animation: qnShake 0.35s ease;
    border-color: var(--danger, #FF5252) !important;
}

@keyframes qnShake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-6px); }
    40%       { transform: translateX(6px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
}

/* ── Toast de confirmación ──────────────────────────────────────── */
.qn-toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--success, #00E676);
    color: #000;
    padding: 0.5rem 1.2rem;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: var(--font-heading);
    box-shadow: 0 4px 16px rgba(0,230,118,0.4);
    z-index: 9999;
    opacity: 0;
    transition: all 0.25s ease;
    pointer-events: none;
}

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

/* ── Modo claro ─────────────────────────────────────────────────── */
[data-theme="light"] .qn-panel {
    background: #ffffff;
    border-color: rgba(0,0,0,0.1);
    box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 0 0 1px rgba(108,92,231,0.1);
}

[data-theme="light"] .qn-header {
    background: linear-gradient(135deg, rgba(108,92,231,0.08), rgba(108,92,231,0.02));
}

[data-theme="light"] .qn-textarea {
    background: #f8f8fc;
    border-color: rgba(0,0,0,0.12);
    color: #1a1a2e;
}

[data-theme="light"] .qn-note-item {
    background: #f8f8fc;
    border-color: rgba(0,0,0,0.08);
}

[data-theme="light"] .qn-note-item:hover {
    background: rgba(108,92,231,0.05);
}

[data-theme="light"] .qn-list-header {
    background: rgba(0,0,0,0.04);
}

[data-theme="light"] .qn-fab-badge {
    border-color: #ffffff;
}


/* --- GANTT PLANNER STYLES --- */
.gantt-table th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #1a365d;
    color: white;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.gantt-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--card-border);
    border-right: 1px solid var(--card-border);
    vertical-align: middle;
}
.gantt-table tr:hover {
    background: rgba(255,255,255,0.05);
}
.gantt-area-header {
    background: rgba(43, 108, 176, 0.2);
    font-weight: bold;
    color: var(--primary-light);
}
.gantt-bar-cell {
    background: rgba(0,0,0,0.1);
    position: relative;
}
.gantt-bar {
    background: #27ae60;
    height: 16px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.planner-checklist-group summary {
    cursor: pointer;
    font-weight: 600;
    padding: 0.5rem;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    margin-bottom: 0.5rem;
}
.planner-checklist-item {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    padding: 0.4rem;
    border-bottom: 1px dashed var(--card-border);
    font-size: 0.85rem;
}
.planner-checklist-item:last-child {
    border-bottom: none;
}
.planner-checklist-item input[type="checkbox"] {
    margin-top: 0.2rem;
}



/* --- REVISED GANTT PRINT STYLES --- */
@media print {
    @page { size: landscape; margin: 10mm; }
    
    body.printing-gantt .sidebar,
    body.printing-gantt .header-top,
    body.printing-gantt .topbar,
    body.printing-gantt .planner-checklist-container,
    body.printing-gantt .patients-list,
    body.printing-gantt .floating-fab,
    body.printing-gantt .no-print {
        display: none !important;
    }
    
    body.printing-gantt .app-container,
    body.printing-gantt .main-content,
    body.printing-gantt .patients-section {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        display: block !important;
    }
    
    body.printing-gantt .expediente-subview {
        display: block !important; /* Ensure it's visible */
    }
    
    body.printing-gantt .planner-gantt-container {
        width: 100% !important;
        border: none !important;
        box-shadow: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    body.printing-gantt .gantt-table {
        width: 100% !important;
        font-size: 8pt !important;
    }
    
    body.printing-gantt .gantt-bar-cell div {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    body.printing-gantt tr.goal-completed {
        display: none !important;
    }
    
    body.printing-gantt .print-only-text {
        font-size: 7pt !important;
    }
}

tr.goal-completed td {
    opacity: 0.5;
    text-decoration: line-through;
    background: #f8f9fa;
}

/* --- ISOLATED GANTT PRINT STYLES --- */
@media print {
    @page { size: landscape; margin: 10mm; }
    
    body.printing-gantt-isolated > *:not(#print-host) {
        display: none !important;
    }
    
    body.printing-gantt-isolated {
        background: white !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        height: auto !important;
        position: relative !important;
    }
    html.printing-gantt-isolated {
        overflow: visible !important;
        height: auto !important;
    }
    
    
    #print-host .planner-gantt-container,
    #print-host .gantt-table-wrapper {
        overflow: visible !important;
        height: auto !important;
        max-height: none !important;
    }
    #print-host table {
        page-break-inside: auto;
    }
    #print-host tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
    #print-host td, #print-host th {
        page-break-inside: avoid;
    }

    #print-host {
        position: relative !important;
        display: block !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    #print-host .no-print {
        display: none !important;
    }
    
    #print-host .gantt-table {
        width: 100% !important;
        font-size: 8pt !important;
    }
    
    #print-host .gantt-bar-cell div {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    #print-host tr.goal-completed {
        display: none !important;
    }
}


/* --- COMPACT UI OVERRIDES (MÁRGENES HOMOLOGADOS A 4MM) --- */
.main-canvas-inner {
    padding: 0 !important;
}
.form-grid {
    gap: 0.75rem !important;
}
.form-group {
    gap: 0.25rem !important;
}
.form-label {
    margin-bottom: 0 !important;
}
.expediente-fields {
    gap: 0.5rem 1rem !important;
}
.expediente-block {
    padding: 1rem !important;
}
.card {
    padding: 1rem !important;
}
h2 {
    margin-bottom: 1rem !important;
}
.topbar {
    margin-bottom: 1.5rem !important;
}
.note-card, .goal-card {
    padding: 0.75rem !important;
}


/* --- EXTRA COMPACT HEADER --- */
.header-top {
    margin-bottom: 0.25rem !important;
}
.welcome-msg h1 {
    margin-bottom: 0 !important;
}


/* --- 100% COMPLETED GOAL STYLES --- */
tr.goal-100 {
    background-color: rgba(0, 0, 0, 0.04) !important;
    opacity: 0.7;
    transition: all 0.3s ease;
}
tr.goal-100 td:nth-child(2) div,
tr.goal-100 td:nth-child(3) {
    text-decoration: line-through;
    color: var(--text-muted) !important;
}
tr.goal-100 td.gantt-bar-cell div {
    filter: grayscale(100%);
    opacity: 0.5;
}


/* ==================================================
   TARGETED VERTICAL LAYOUT OVERRIDES 
   Solo para: Directorio Clínico, Informe de Evaluación y Planificador
   ================================================== */
@media (max-width: 1200px), (orientation: portrait) {
    /* 1. Directorio Clínico (Dashboard) */
    .patients-section {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) 375px !important;
        gap: 1.25rem !important;
    }
    .patients-section > .card {
        width: 100% !important;
        max-width: none !important;
    }

    /* 2. Informe de Evaluación Psicológica (Registro) */
    .register-layout {
        display: flex !important;
        flex-direction: column !important;
        gap: 1.5rem !important;
    }
    .register-layout aside.form-navigation {
        width: 100% !important;
        max-width: none !important;
        max-height: 250px !important;
    }

    /* 3. Planificador Sistematizado de Objetivos */
    #subviewPlan .note-creation-block > div[style*="grid"] {
        display: flex !important;
        flex-direction: column !important;
    }
    .planner-checklist-container {
        width: 100% !important;
        max-width: none !important;
        max-height: 400px !important;
    }
    
    /* Make tables inside these views horizontally scrollable if needed */
    .gantt-table-wrapper, 
    .planner-gantt-container,
    .patient-list {
        overflow-x: auto !important;
        max-width: calc(100vw - 2rem) !important;
        -webkit-overflow-scrolling: touch;
    }
    #ganttTable {
        width: 100% !important;
    }

    /* [sidebar portrait override removed] */


}

/* --- DIRECTORIO CLÍNICO: expansión vertical en pantalla vertical --- */
@media (orientation: portrait) {
    #viewDashboard .patients-section {
        grid-template-columns: 1fr !important;
    }
    #viewDashboard .patient-list,
    #viewDashboard #patientListContainer {
        max-height: 70vh !important;
        min-height: 400px !important;
        overflow-y: auto !important;
    }
}

/* ===== TIMELINE — BITÁCORA DE ACTIVIDADES ===== */
#bitacoraTimeline {
    position: relative;
    padding: 1rem 0;
    margin-left: 1rem;
}

#bitacoraTimeline::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 16px;
    width: 2px;
    background: var(--card-border);
}

.timeline-item {
    position: relative;
    margin-bottom: 1.5rem;
    padding-left: 3.5rem;
    animation: fadeSlideUp 0.35s ease;
}

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

.timeline-icon {
    position: absolute;
    left: 0;
    top: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    z-index: 2;
}

.timeline-content {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    transition: all 0.2s;
}

.timeline-content:hover {
    background: rgba(255,255,255,0.04);
    border-color: rgba(255,255,255,0.12);
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
    gap: 1rem;
}

.timeline-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.timeline-date {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

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

.timeline-type-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    white-space: nowrap;
}

@media print {
    body.print-mode-individual-evolution > *:not(#printEvolutionIndividualContainer) {
        display: none !important;
    }
    body.print-mode-individual-evolution {
        background: white !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    #printEvolutionIndividualContainer {
        display: block !important;
        width: 100% !important;
    }
    .print-evolution-note-only {
        position: relative !important;
        padding: 1.5cm !important;
        margin: 0 auto !important;
        box-shadow: none !important;
        border: none !important;
    }
    @page {
        margin: 0;
        size: portrait;
    }
}

 
 
/* GANTT FULLSCREEN */
.planner-gantt-fullscreen { position: fixed !important; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 9999; border-radius: 0 !important; display: flex; flex-direction: column; }
.planner-gantt-fullscreen #ganttScrollArea { flex: 1 !important; min-height: 0 !important; max-height: none !important; overflow-y: auto !important; overflow-x: auto !important; }
.current-week-col { background-color: rgba(26, 188, 156, 0.15) !important; border-left: 2px solid var(--accent) !important; border-right: 2px solid var(--accent) !important; }
.current-week-header { background-color: var(--accent) !important; color: white !important; font-weight: bold; border: 2px solid var(--accent) !important; }

.planner-checklist-group summary { color: var(--primary); font-weight: 700; font-size: 1.05rem; }
.gantt-area-header { color: #0056b3 !important; }



/* ==========================================================================
   VISTA TABLERO EN COLUMNAS (MULTICOLUMNA PANORÁMICA ESTILO EXCEL / MATRIZ)
   ========================================================================== */
/* ==========================================================================
   MATRIZ DE FORMATOS ESTILO HOJA DE CÁLCULO / EXCEL (EXACTO A CAPTURA)
   ========================================================================== */
.excel-matrix-container {
    width: 100%;
    overflow-x: auto;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 2rem;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    box-sizing: border-box;
}

[data-theme="dark"] .excel-matrix-container,
body.dark-mode .excel-matrix-container,
.dark-theme .excel-matrix-container {
    background: #0f172a;
    border-color: #334155;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.excel-matrix-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(180px, 1fr));
    width: 100%;
    min-width: 960px;
    align-items: stretch;
}

.excel-matrix-col {
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e2e8f0;
    background: #ffffff;
}

[data-theme="dark"] .excel-matrix-col,
body.dark-mode .excel-matrix-col,
.dark-theme .excel-matrix-col {
    background: #1e293b;
    border-right: 1px solid #334155;
}

.excel-matrix-col:last-child {
    border-right: none;
}

.excel-matrix-col.col-focused {
    box-shadow: inset 0 0 0 2px #10b981, 0 4px 16px rgba(16, 185, 129, 0.2);
    z-index: 5;
    transition: box-shadow 0.25s ease;
}

/* Columna 1 tintada de verde suave como en la captura */
.excel-matrix-col.col-pruebas {
    background: #e2f7e8 !important;
}
[data-theme="dark"] .excel-matrix-col.col-pruebas,
body.dark-mode .excel-matrix-col.col-pruebas,
.dark-theme .excel-matrix-col.col-pruebas {
    background: rgba(16, 185, 129, 0.08) !important;
}

/* Encabezados de columna estilo Excel */
.excel-matrix-col-header {
    padding: 7px 10px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #1f2937;
    border-bottom: 1px solid #cbd5e1;
    background: #f8fafc;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.excel-matrix-col.col-pruebas .excel-matrix-col-header {
    background: #c6f0d3;
    color: #065f46;
    border-bottom-color: #9fe0b5;
}

[data-theme="dark"] .excel-matrix-col-header,
body.dark-mode .excel-matrix-col-header,
.dark-theme .excel-matrix-col-header {
    background: #0f172a;
    color: #f1f5f9;
    border-bottom-color: #334155;
}

[data-theme="dark"] .excel-matrix-col.col-pruebas .excel-matrix-col-header,
body.dark-mode .excel-matrix-col.col-pruebas .excel-matrix-col-header,
.dark-theme .excel-matrix-col.col-pruebas .excel-matrix-col-header {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
    border-bottom-color: #10b981;
}

/* Cuerpo de la columna */
.excel-matrix-col-body {
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Renglón de documento (celda de Excel, limpia, sin descripciones) */
.excel-doc-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 10px;
    min-height: 27px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.1s, outline 0.1s;
    user-select: none;
    box-sizing: border-box;
}

.excel-matrix-col.col-pruebas .excel-doc-row {
    border-bottom: 1px solid #d4f2de;
}

[data-theme="dark"] .excel-doc-row,
body.dark-mode .excel-doc-row,
.dark-theme .excel-doc-row {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .excel-matrix-col.col-pruebas .excel-doc-row,
body.dark-mode .excel-matrix-col.col-pruebas .excel-doc-row,
.dark-theme .excel-matrix-col.col-pruebas .excel-doc-row {
    border-bottom: 1px solid rgba(16, 185, 129, 0.15);
}

/* Hover: Recuadro verde celda activa de Excel */
.excel-doc-row:hover {
    background: #d1fae5 !important;
    outline: 2px solid #10b981;
    outline-offset: -2px;
    z-index: 2;
}

[data-theme="dark"] .excel-doc-row:hover,
body.dark-mode .excel-doc-row:hover,
.dark-theme .excel-doc-row:hover {
    background: rgba(16, 185, 129, 0.22) !important;
    outline: 2px solid #10b981;
    outline-offset: -2px;
}

/* Texto del documento: limpio, sin descripciones */
.excel-doc-name {
    font-size: 0.83rem;
    font-weight: 500;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

[data-theme="dark"] .excel-doc-name,
body.dark-mode .excel-doc-name,
.dark-theme .excel-doc-name {
    color: #e2e8f0;
}

.excel-doc-row:hover .excel-doc-name {
    color: #065f46;
    font-weight: 600;
}

[data-theme="dark"] .excel-doc-row:hover .excel-doc-name,
body.dark-mode .excel-doc-row:hover .excel-doc-name,
.dark-theme .excel-doc-row:hover .excel-doc-name {
    color: #ffffff;
}

/* Mini acciones en hover */
.excel-doc-actions {
    display: none;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
    flex-shrink: 0;
}

.excel-doc-row:hover .excel-doc-actions {
    display: flex;
}

.excel-doc-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 1px 4px;
    font-size: 0.72rem;
    color: #4b5563;
    border-radius: 3px;
    line-height: 1;
    text-decoration: none;
}

.excel-doc-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #111827;
}

[data-theme="dark"] .excel-doc-btn,
body.dark-mode .excel-doc-btn,
.dark-theme .excel-doc-btn {
    color: #94a3b8;
}

[data-theme="dark"] .excel-doc-btn:hover,
body.dark-mode .excel-doc-btn:hover,
.dark-theme .excel-doc-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.excel-col-empty {
    padding: 12px;
    font-size: 0.78rem;
    color: #9ca3af;
    font-style: italic;
    text-align: center;
}

/* ==========================================================================
   VISTA LISTADO DE FORMATOS (ULTRA COMPACTA - CERO DESPERDICIO DE ESPACIO)
   ========================================================================== */
.formats-grid.view-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.65rem !important;
    width: 100% !important;
}

.fl-category-group {
    display: flex;
    flex-direction: column;
    background: var(--card-bg, #1e293b);
    border: 1px solid var(--card-border, rgba(255, 255, 255, 0.08));
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 0.5rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.fl-category-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.85rem;
    background: rgba(255, 255, 255, 0.035);
    border-bottom: 1px solid var(--card-border, rgba(255, 255, 255, 0.07));
    user-select: none;
}

.fl-category-group-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.fl-category-count {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
}

.format-list-row {
    display: flex;
    align-items: center;
    padding: 0.45rem 0.85rem;
    gap: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    background: transparent;
    transition: background 0.12s ease;
    cursor: pointer;
    min-height: 40px;
    box-sizing: border-box;
}

.format-list-row:last-child {
    border-bottom: none;
}

.format-list-row:hover {
    background: rgba(56, 189, 248, 0.05);
}

.fl-col-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.fl-type-pill {
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 5px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.fl-type-pill.is-pdf {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.fl-type-pill.is-word {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.fl-col-title-box {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.fl-doc-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--primary, #38bdf8);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.15s ease;
    flex-shrink: 0;
    max-width: 380px;
}

.fl-doc-title:hover {
    color: #00e5ff;
    text-decoration: underline;
}

.fl-doc-desc {
    font-size: 0.74rem;
    color: var(--text-secondary, #94a3b8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.fl-col-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.fl-category-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    white-space: nowrap;
}

.fl-size-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary, #94a3b8);
    white-space: nowrap;
}

.fl-col-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.fl-btn-action {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.25rem !important;
    height: 28px !important;
    border-radius: 6px !important;
    text-decoration: none !important;
    line-height: 1 !important;
}

.fl-btn-delete {
    border-color: rgba(239, 68, 68, 0.3) !important;
    color: #ef4444 !important;
}

.formats-grid.view-compact {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}
.formats-grid.view-compact .format-card {
    padding: 1rem;
    gap: 0.5rem;
}
.formats-grid.view-compact .format-card .format-header .format-icon-doc {
    width: 28px;
    height: 28px;
    font-size: 0.9rem;
}
.formats-grid.view-compact .format-card .format-body h4 {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}
.formats-grid.view-compact .format-card .format-body p {
    display: none;
}
.formats-grid.view-compact .format-card .format-footer {
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch !important;
}
.formats-grid.view-compact .format-card .format-footer > div {
    justify-content: space-between;
    width: 100%;
}

/* Sidebar mic recording indicator */
#menuRecorder.is-recording svg {
    stroke: #ef4444 !important;
    animation: blink 1.2s infinite;
}

/* CLINIC SIDEBAR WIDGET */
.clinic-sidebar-widget {
    background: linear-gradient(145deg, rgba(255,255,255,0.03) 0%, rgba(0, 229, 255, 0.02) 100%);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-left: 2px solid var(--primary);
    border-radius: 6px;
    padding: 0.85rem;
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}
.clinic-sidebar-widget:hover {
    background: linear-gradient(145deg, rgba(255,255,255,0.05) 0%, rgba(0, 229, 255, 0.04) 100%);
    border-color: rgba(255, 255, 255, 0.1);
}
.clinic-sidebar-widget .widget-motto {
    font-family: var(--font-heading);
    font-style: italic;
    font-size: 0.65rem;
    color: var(--primary);
    text-align: center;
    letter-spacing: 0.5px;
    margin-bottom: 0.2rem;
    text-transform: uppercase;
}
.clinic-sidebar-widget .widget-title {
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--text-primary);
    text-align: center;
    letter-spacing: 0.2px;
}
.clinic-sidebar-widget .widget-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    margin: 0.3rem 0;
}
.clinic-sidebar-widget .widget-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
    line-height: 1.3;
}
.clinic-sidebar-widget .widget-icon {
    width: 12px;
    height: 12px;
    color: var(--primary);
    flex-shrink: 0;
    margin-top: 0.1rem;
}

#viewDashboard .patients-section > .card,
#viewDashboard .patients-section > div > .card {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

#sidebarCollapseBtn {
    transition: color 0.2s, transform 0.2s;
}

#sidebarCollapseBtn:hover {
    background: transparent !important;
    color: var(--primary) !important;
    border: none !important;
    transform: translateX(-2px);
}

/* Cintilla superior (.header-top): Únicamente visible en vista Dashboard */
body:not(.in-dashboard-view) .header-top {
    display: none !important;
}

body.in-dashboard-view .header-top {
    display: flex !important;
}

/* --- MICRO-BARRA AUTO-OCULTABLE EN HOVER PARA TESTS --- */
.standalone-test-microbar {
    opacity: 0.85;
}
.standalone-test-microbar:hover {
    opacity: 1 !important;
    height: 34px !important;
    background: rgba(15, 23, 42, 0.95) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
}

body.fullscreen-test-active #viewStandaloneTest {
    height: calc(100vh - 2rem) !important;
}

body.test-maximized-fullscreen .standalone-test-microbar {
    height: 28px !important;
}


/* Preservar párrafos, saltos de línea y sangrías en Registro de Avance (Hoja de Ruta) y Bitácora */
.avance-content-text,
.timeline-desc,
#avanceTimelineContainer .avance-content-text {
    white-space: pre-wrap !important;
    word-break: break-word !important;
}

/* ==========================================================================
   VISTA DESKTOP COMPLETA EN TABLETAS (ACCESO VÍA QR)
   (PANELES PEGADOS SIN GAP Y EXPANSIÓN A 100% PANTALLA COMPLETA AL RETRAER MENÚ)
   ========================================================================== */

@media (max-width: 1366px), (pointer: coarse) {
    /* 1. CONTENEDOR RAÍZ AL 100% DE PANTALLA EN TABLETA SIN MÁRGENES MUERTOS NI DESPLAZAMIENTOS */
    html, body {
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        min-width: 100vw !important;
        min-height: 100dvh !important;
        max-width: 100vw !important;
        max-height: 100dvh !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
        transform: none !important;
        zoom: 1 !important;
    }

    /* CONTENEDOR CONTIGUO SIN ESPACIO VACÍO / GAP ENTRE BARRA LATERAL Y VENTANA PRINCIPAL */
    .app-container, #app-container {
        display: flex !important;
        flex-direction: row !important;
        align-items: stretch !important;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        margin: 0 !important;
        padding: 0 !important;
        gap: 0 !important; /* CERO VACÍO O SEPARACIÓN ENTRE MENÚ Y CONTENIDO */
        overflow: hidden !important;
        box-sizing: border-box !important;
        position: relative !important;
        transform: none !important;
        zoom: 1 !important;
    }

    /* 2. BARRA LATERAL IZQUIERDA: PEGADA FLUSH A LA VENTANA PRINCIPAL */
    .sidebar, body.is-touch-device .sidebar {
        position: relative !important;
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 340px !important;
        min-width: 340px !important;
        max-width: 340px !important;
        height: 100% !important;
        min-height: 100% !important;
        max-height: 100% !important;
        margin: 0 !important;
        margin-right: 0 !important;
        padding: 0 !important;
        border-radius: 0 !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        z-index: 10 !important;
        box-shadow: none !important;
        border-right: 1px solid var(--card-border) !important;
        flex-shrink: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        background: var(--card-bg) !important;
    }
    
    .sidebar.collapsed {
        display: none !important;
    }

    .menu-list {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        max-height: none !important;
        flex-grow: 1 !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .sidebar-float-btn {
        z-index: 100000 !important;
    }

    /* 3. PANEL PRINCIPAL Y VENTANA CONTIGUA: EXPANDIDA AL 100% DE LA PANTALLA AL RETRAER LA BARRA LATERAL */
    .main-content {
        position: relative !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        margin: 0 !important;
        margin-left: 0 !important; /* CERO MARGEN IZQUIERDO */
        flex: 1 !important;
        flex-grow: 1 !important;
        width: calc(100vw - 280px) !important;
        min-width: 0 !important;
        max-width: none !important;
        height: 100% !important;
        min-height: 100% !important;
        max-height: 100% !important;
        padding: var(--perimeter-stroke-width) !important;
        border-radius: 0 !important;
        box-sizing: border-box !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        border: none !important;
        background: var(--card-bg) !important;
        z-index: 5 !important;
        transition: width 0.35s ease, margin 0.35s ease !important;
    }

    .main-content.sidebar-collapsed {
        width: 100vw !important;
        min-width: 100vw !important;
        max-width: 100vw !important;
        margin-left: 0 !important;
        flex: 1 !important;
    }

    /* 4. REGLA CRÍTICA DE CORRECCIÓN DE NAVEGACIÓN: VISTAS INACTIVAS OCULTAS, VISTA ACTIVA SHOWN */
    .view {
        display: none !important;
    }

    .view.active,
    #viewDashboard.view.active,
    #viewPacientes.view.active,
    #viewAgenda.view.active,
    #viewCatalog.view.active,
    #viewComunicador.view.active,
    #viewRegister.view.active,
    #viewDownloads.view.active,
    #viewActivityReport.view.active,
    #viewStandaloneTest.view.active {
        display: flex !important;
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        min-height: 100% !important;
        flex: 1 !important;
        flex-grow: 1 !important;
        flex-direction: column !important;
        box-sizing: border-box !important;
    }

    .card,
    .patients-section,
    .expedientes-list,
    .table-responsive,
    table,
    .expediente-block,
    .view-container {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        margin-right: 0 !important;
        margin-bottom: 0 !important;
    }

    .patients-section {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) 350px !important;
        width: 100% !important;
        height: 100% !important;
        flex: 1 !important;
        gap: 1rem !important;
        min-height: 0 !important;
    }

    #iframeComunicador {
        width: 100% !important;
        height: 100% !important;
        min-height: 100% !important;
        flex: 1 !important;
        flex-grow: 1 !important;
        border: none !important;
    }
}


/* INTERACCIÓN VISUAL EN LOGOTIPO CHRYSALIS (CLIC: PANTALLA COMPLETA / HOLD: AJUSTE VENTANAS) */
.sidebar-logo-container {
    cursor: pointer !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.sidebar-logo-container:hover img {
    transform: scale(1.05);
    filter: drop-shadow(0 0 12px rgba(56, 189, 248, 0.6));
}

.sidebar-logo-container:active img {
    transform: scale(0.92);
    filter: drop-shadow(0 0 18px rgba(2, 132, 199, 0.9));
}

/* REGLAS RESPONSIVAS PARA PANTALLAS 1366X768 Y LAPTOPS */
@media (max-height: 850px), (max-width: 1366px) {
    .sidebar {
        padding: 0 !important;
    }
    .sidebar-canvas-inner {
        padding: 0.75rem 0.65rem !important;
    }
    .sidebar-logo-container img {
        max-height: 60px !important;
    }
    .menu-item button {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.85rem !important;
        margin-bottom: 0.3rem !important;
        gap: 0.6rem !important;
    }
    .menu-item button svg {
        width: 17px !important;
        height: 17px !important;
    }
    .sidebar-stats-row {
        padding: 0.3rem 0.1rem !important;
        margin-top: 0.2rem !important;
        margin-bottom: 0.2rem !important;
    }
    .sidebar-footer {
        gap: 0.5rem !important;
        padding-top: 0.75rem !important;
    }
}

/* =========================================================================
   VARIABLES Y ESTILOS DINÁMICOS DE TIPOGRAFÍA Y ESCALA DEL MENÚ LATERAL
   ========================================================================= */
.sidebar {
    font-size: var(--sb-font-size, 0.95rem) !important;
}

.sidebar .sidebar-logo-container img {
    max-height: var(--sb-logo-h, 75px) !important;
    transition: max-height 0.2s ease !important;
}

.sidebar .menu-list {
    gap: var(--sb-gap, 0.45rem) !important;
}

.sidebar .menu-item button {
    font-size: var(--sb-font-size, 0.95rem) !important;
    padding: var(--sb-btn-pad-y, 0.75rem) var(--sb-btn-pad-x, 0.9rem) !important;
    gap: calc(var(--sb-gap, 0.45rem) * 1.4) !important;
    margin-bottom: calc(var(--sb-gap, 0.45rem) * 0.4) !important;
}

.sidebar .menu-item button svg {
    width: var(--sb-icon-size, 20px) !important;
    height: var(--sb-icon-size, 20px) !important;
}

.sidebar .sidebar-stats-row {
    padding: calc(var(--sb-gap, 0.45rem) * 0.7) 0.1rem !important;
    margin-top: calc(var(--sb-gap, 0.45rem) * 0.4) !important;
    margin-bottom: calc(var(--sb-gap, 0.45rem) * 0.4) !important;
}

.sidebar .sidebar-stat-circle div {
    width: var(--sb-stat-circle-size, 25px) !important;
    height: var(--sb-stat-circle-size, 25px) !important;
}

.sidebar .sidebar-footer {
    gap: var(--sb-gap, 0.45rem) !important;
    padding-top: calc(var(--sb-gap, 0.45rem) * 1.5) !important;
}

.sidebar .sidebar-footer button,
.sidebar .sidebar-footer .btn {
    font-size: calc(var(--sb-font-size, 0.85rem) * 0.85) !important;
    padding: calc(var(--sb-btn-pad-y, 0.5rem) * 0.6) calc(var(--sb-btn-pad-x, 0.7rem) * 0.7) !important;
}

.sidebar #sidebarQRWidgetCard {
    padding: calc(var(--sb-gap, 0.45rem) * 1.2) !important;
}

/* AJUSTES PARA LA COLUMNA ESTRECHA DE GOOGLE CALENDAR */
.calendar-tabs {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.2rem !important;
    font-size: 0.72rem !important;
}

.calendar-tabs .btn {
    padding: 0.2rem 0.4rem !important;
    font-size: 0.72rem !important;
}


/* ============================================================
   VARIABLE-DRIVEN SIDEBAR & FLUID TYPOGRAPHY ADAPTATION
   ============================================================ */
.sidebar {
    width: var(--sb-width, 340px) !important;
    min-width: var(--sb-width, 340px) !important;
    max-width: var(--sb-width, 340px) !important;
    font-size: var(--sb-font-size, 0.92rem) !important;
}

.menu-item button,
.menu-item-sub button {
    padding: var(--sb-btn-pad-y, 0.70rem) var(--sb-btn-pad-x, 0.85rem) !important;
    font-size: var(--sb-font-size, 0.92rem) !important;
    gap: var(--sb-gap, 0.65rem) !important;
}

.menu-item button span,
.menu-item-sub button span {
    font-size: var(--sb-font-size, 0.92rem) !important;
}

.menu-item button svg,
.menu-item-sub button svg {
    width: var(--sb-icon-size, 19px) !important;
    height: var(--sb-icon-size, 19px) !important;
    min-width: var(--sb-icon-size, 19px) !important;
    min-height: var(--sb-icon-size, 19px) !important;
}

.sidebar-logo-container img,
.sidebar-logo-container svg {
    max-height: var(--sb-logo-h, 75px) !important;
}

/* ============================================================
   HOMOLOGACIÓN DE LA PESTAÑA SISTEMA CON LA PESTAÑA CLÍNICA
   Proporción visual, tipografía limpia (font-weight: 500),
   mismos radios, colores y armonía estética al 100%.
   ============================================================ */
#sidebarSpaceSistema {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    width: 100%;
    padding: 0.35rem 0.2rem !important;
    gap: calc(var(--sb-gap, 0.45rem) * 0.9) !important;
    box-sizing: border-box;
}

/* Ficha del terapeuta */
#sidebarSpaceSistema #sidebarTherapistInfo {
    text-align: center;
    width: 100%;
    border-bottom: 1px solid var(--card-border);
    padding: 0.2rem 0.2rem 0.45rem 0.2rem !important;
    margin-bottom: 0.15rem !important;
    box-sizing: border-box;
}
#sidebarSpaceSistema #sideTherapistName {
    color: var(--text-primary);
    font-size: calc(var(--sb-font-size, 0.92rem) * 0.88) !important;
    font-weight: 600 !important;
    letter-spacing: 0.15px;
    display: block;
    line-height: 1.3;
}
#sidebarSpaceSistema #sideTherapistLicense,
#sidebarSpaceSistema #sideTherapistContact {
    font-size: calc(var(--sb-font-size, 0.92rem) * 0.74) !important;
    font-weight: 400 !important;
    color: var(--text-secondary);
    line-height: 1.35;
    opacity: 0.85;
    display: block;
}
#sidebarSpaceSistema #sidebarTherapistInfo i {
    font-size: calc(var(--sb-font-size, 0.92rem) * 0.65) !important;
    font-weight: 400 !important;
    font-style: italic;
    color: var(--text-muted);
    opacity: 0.65;
    margin-top: 3px;
    display: block;
}

/* Fila de Modo Claro */
#sidebarSpaceSistema .theme-toggle-container {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: calc(var(--sb-btn-pad-y, 0.70rem) * 0.65) var(--sb-btn-pad-x, 0.85rem) !important;
    background: rgba(100, 100, 100, 0.05);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md, 8px);
    margin-bottom: 0.1rem !important;
    box-sizing: border-box;
}
[data-theme="light"] #sidebarSpaceSistema .theme-toggle-container {
    background: rgba(0, 0, 0, 0.03);
}
#sidebarSpaceSistema .theme-toggle-container span {
    font-size: var(--sb-font-size, 0.92rem) !important;
    font-weight: 500 !important;
    color: var(--text-secondary);
}
#sidebarSpaceSistema .theme-switch {
    width: 42px !important;
    height: 22px !important;
    border-radius: 11px !important;
    background: var(--primary-alpha);
    border: 1px solid var(--card-border);
    cursor: pointer;
    position: relative;
    outline: none;
    flex-shrink: 0;
}
#sidebarSpaceSistema .theme-switch .theme-switch-slider {
    width: 16px !important;
    height: 16px !important;
    top: 2px !important;
    left: 2px !important;
    background: white;
    border-radius: 50%;
    position: absolute;
    transition: transform 0.25s ease;
}
[data-theme="light"] #sidebarSpaceSistema .theme-switch .theme-switch-slider {
    transform: translateX(20px) !important;
}

/* Botones universales de la pestaña Sistema (homologados con .menu-item button) */
#sidebarSpaceSistema .sistema-menu-btn {
    width: 100%;
    background: rgba(100, 100, 100, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    padding: calc(var(--sb-btn-pad-y, 0.70rem) * 0.75) var(--sb-btn-pad-x, 0.85rem) !important;
    border-radius: var(--radius-md, 8px);
    cursor: pointer;
    font-size: var(--sb-font-size, 0.92rem) !important;
    font-weight: 500 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: calc(var(--sb-gap, 0.45rem) * 1.2);
    text-align: center;
    outline: none;
    box-sizing: border-box;
    transition: all 0.2s ease;
    white-space: nowrap;
}
[data-theme="light"] #sidebarSpaceSistema .sistema-menu-btn {
    background: rgba(0, 0, 0, 0.03);
}
#sidebarSpaceSistema .sistema-menu-btn:hover {
    background: var(--primary-alpha);
    color: var(--primary);
    border-color: rgba(59, 130, 246, 0.35);
}
#sidebarSpaceSistema .sistema-menu-btn svg,
#sidebarSpaceSistema .sistema-menu-btn i {
    width: calc(var(--sb-icon-size, 19px) * 0.88) !important;
    height: calc(var(--sb-icon-size, 19px) * 0.88) !important;
    min-width: calc(var(--sb-icon-size, 19px) * 0.88) !important;
    min-height: calc(var(--sb-icon-size, 19px) * 0.88) !important;
    flex-shrink: 0;
    stroke: currentColor;
    stroke-width: 2.2;
    fill: none;
}
#sidebarSpaceSistema .sistema-menu-btn span {
    font-size: var(--sb-font-size, 0.92rem) !important;
    font-weight: 500 !important;
}

/* Botón Reiniciar Plataforma (acento suave, homologado) */
#sidebarSpaceSistema .sistema-menu-btn.btn-restart-accent {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.12) 0%, rgba(220, 38, 38, 0.22) 100%) !important;
    border: 1px solid rgba(239, 68, 68, 0.35) !important;
    color: #fca5a5 !important;
    font-weight: 500 !important;
}
#sidebarSpaceSistema .sistema-menu-btn.btn-restart-accent:hover {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.22) 0%, rgba(220, 38, 38, 0.35) 100%) !important;
    color: #fee2e2 !important;
    border-color: rgba(239, 68, 68, 0.55) !important;
}

/* Fila de botones duales (Importar / Exportar BD) */
#sidebarSpaceSistema .sistema-btn-row {
    display: flex;
    width: 100%;
    gap: 0.35rem;
    box-sizing: border-box;
}
#sidebarSpaceSistema .sistema-btn-row .sistema-menu-btn {
    flex: 1;
    min-width: 0;
    padding: calc(var(--sb-btn-pad-y, 0.70rem) * 0.65) 0.35rem !important;
    font-size: calc(var(--sb-font-size, 0.92rem) * 0.92) !important;
}
#sidebarSpaceSistema .sistema-btn-row .sistema-menu-btn span {
    font-size: calc(var(--sb-font-size, 0.92rem) * 0.92) !important;
}

/* Estado del Código de Respaldo */
#sidebarSpaceSistema #codeBackupStatus {
    font-size: calc(var(--sb-font-size, 0.92rem) * 0.75) !important;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 1px;
}
#sidebarSpaceSistema #codeBackupDot {
    width: 6px !important;
    height: 6px !important;
    border-radius: 50%;
    display: inline-block;
}
#sidebarSpaceSistema #codeBackupText {
    font-size: calc(var(--sb-font-size, 0.92rem) * 0.75) !important;
    font-weight: 500 !important;
}

/* Tarjeta QR de Acceso Móvil */
#sidebarSpaceSistema #sidebarQRWidgetCard {
    margin-top: 0.25rem !important;
    margin-bottom: 0.25rem !important;
    background: rgba(100, 100, 100, 0.05) !important;
    border: 1px solid var(--card-border) !important;
    border-radius: var(--radius-md, 8px) !important;
    padding: 0.45rem 0.55rem !important;
    text-align: center;
    box-sizing: border-box;
    width: 100%;
    box-shadow: none !important;
}
[data-theme="light"] #sidebarSpaceSistema #sidebarQRWidgetCard {
    background: rgba(0, 0, 0, 0.03) !important;
}
#sidebarSpaceSistema .sistema-qr-header {
    font-size: calc(var(--sb-font-size, 0.92rem) * 0.88) !important;
    font-weight: 500 !important;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}
#sidebarSpaceSistema .sistema-qr-hide-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    padding: 1px 5px !important;
    border-radius: 4px;
    font-size: calc(var(--sb-font-size, 0.92rem) * 0.72) !important;
    font-weight: 500 !important;
    cursor: pointer;
    transition: all 0.2s;
}
#sidebarSpaceSistema .sistema-qr-hide-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
}
#sidebarSpaceSistema #sidebarQRCodeContainer {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0.25rem auto !important;
    background: white;
    padding: 5px;
    border-radius: 6px;
    width: 85px !important;
    height: 85px !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
#sidebarSpaceSistema #sidebarQRUrlText {
    font-size: calc(var(--sb-font-size, 0.92rem) * 0.78) !important;
    font-weight: 500 !important;
    color: var(--primary) !important;
    word-break: break-all;
    margin: 0.2rem 0 !important;
    line-height: 1.2;
}
#sidebarSpaceSistema .sistema-qr-actions {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.3rem;
}
#sidebarSpaceSistema .sistema-qr-actions .btn {
    flex: 1;
    font-size: calc(var(--sb-font-size, 0.92rem) * 0.76) !important;
    font-weight: 500 !important;
    padding: 3px 5px !important;
    justify-content: center;
    border-radius: 5px;
}

/* ==========================================================================
   MODO IMPRESIÓN FÍSICA: HISTORIA CLÍNICA (DIF NAYARIT / CHRYSALIS)
   Ahorro de tinta/tóner en impresión física: Franjas en blanco con texto institucional
   ========================================================================== */
@media print {
    body.print-mode-icaten .hc-section-banner,
    .print-mode-icaten .hc-section-banner {
        background: #ffffff !important;
        background-color: #ffffff !important;
        color: #721c38 !important;
        border-bottom: 2px solid #721c38 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    body.print-mode-icaten .hc-section-banner-alert,
    .print-mode-icaten .hc-section-banner-alert {
        color: #991b1b !important;
        border-bottom: 2px solid #991b1b !important;
    }
    body.print-mode-chrysalis .hc-section-banner,
    .print-mode-chrysalis .hc-section-banner {
        background: #ffffff !important;
        background-color: #ffffff !important;
        color: #0369a1 !important;
        border-bottom: 2px solid #0284c7 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}



/* Homologación estética de recuadros: Líneas simples finas con ligero relieve físico (no IA) */
.card,
.content-card,
.modal-content {
    border: 1px solid var(--card-border) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.18) !important;
    border-bottom: 2px solid rgba(0, 0, 0, 0.28) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
}

[data-theme="light"] .card,
[data-theme="light"] .content-card,
[data-theme="light"] .modal-content {
    border: 1px solid #cbd5e1 !important;
    border-top: 1px solid #e2e8f0 !important;
    border-bottom: 2px solid #94a3b8 !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), inset 0 1px 0 #ffffff !important;
}


/* ==========================================================================
   🌟 NUEVO MENÚ LATERAL ESTILO NAVEGADOR DE GOOGLE (NAVIGATION RAIL CON HOVER)
   ========================================================================== */





/* ==========================================================================
   MENU LATERAL DINAMICO ESTILO GOOGLE CHROME (RAIL 44px FIJO + OVERLAY FLOTANTE)
   ========================================================================== */

#sidebarRailSpacer,
.sidebar-rail-spacer {
    display: none !important;
    width: 0 !important;
}

.app-container, #app-container {
    width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
    overflow: hidden !important;
}

/* ==========================================================================
   BARRA LATERAL DINÁMICA ESTILO GOOGLE CHROME (RAIL ULTRA-DELGADO 48PX / HOVER FLOTANTE)
   ========================================================================== */

/* 1. ESTRUCTURA BASE DEL SIDEBAR */
#app-container #mainSidebar.sidebar,
#mainSidebar.sidebar,
.sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    height: 100vh !important;
    min-height: 100vh !important;
    max-height: 100vh !important;
    z-index: 1050 !important;
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
    background: var(--card-bg, #1a2f3d) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-right: 1px solid var(--card-border, rgba(255, 255, 255, 0.1)) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    transition: width 0.22s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.22s ease !important;
}

/* 2. MODO REPOSO (RAIL): REDUCIDO, 100% CENTRADO Y CON ALTURA HOMOLOGADA A DESPLEGADO (CERO SALTO VERTICAL) */
#app-container #mainSidebar.sidebar.rail-mode,
#mainSidebar.sidebar.rail-mode,
.sidebar.rail-mode {
    width: 58px !important;
    min-width: 58px !important;
    max-width: 58px !important;
    padding: 6px 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.35) !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    overflow-x: hidden !important;
    overflow-y: hidden !important;
    box-sizing: border-box !important;
}

#mainSidebar.sidebar.rail-mode::-webkit-scrollbar,
#mainSidebar.sidebar.rail-mode *::-webkit-scrollbar,
#mainSidebar.sidebar.rail-mode .menu-list::-webkit-scrollbar,
#mainSidebar.sidebar.rail-mode #sidebarSpaceClinica::-webkit-scrollbar,
#mainSidebar.sidebar.rail-mode #sidebarSpaceSistema::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

/* Botón toggle de 3 líneas superior en reposo: ultra-compacto (24px) */
#mainSidebar.sidebar.rail-mode .sidebar-toggle-google-btn {
    width: 36px !important;
    height: 22px !important;
    min-width: 36px !important;
    max-width: 36px !important;
    min-height: 22px !important;
    max-height: 22px !important;
    padding: 0 !important;
    margin: 0 auto 2px auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
    border: none !important;
    color: var(--text-secondary, #94a3b8) !important;
    cursor: pointer !important;
    border-radius: 6px !important;
    flex-shrink: 0 !important;
}
#mainSidebar.sidebar.rail-mode .sidebar-toggle-google-btn svg {
    width: 16px !important;
    height: 16px !important;
}
#mainSidebar.sidebar.rail-mode .sidebar-toggle-google-btn:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #38bdf8 !important;
}

/* Cabecera fija en reposo: exactamente 26px de altura, pegada al toggle */
#mainSidebar.sidebar.rail-mode .sidebar-fixed-header {
    width: 58px !important;
    min-width: 58px !important;
    max-width: 58px !important;
    height: 50px !important;
    min-height: 50px !important;
    max-height: 50px !important;
    padding: 0 !important;
    margin: 0 auto 0 auto !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
}

/* Logo pequeño en reposo: centrado de 26px de altura */
#mainSidebar.sidebar.rail-mode .sidebar-logo-container {
    width: 42px !important;
    height: 26px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    max-height: 26px !important;
    padding: 0 !important;
    margin: 0 auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
}
#mainSidebar.sidebar.rail-mode .sidebar-logo-container img {
    max-width: 36px !important;
    max-height: 22px !important;
    margin: 0 auto !important;
    object-fit: contain !important;
}

/* Contenedores interiores de menú en reposo: supresión total de scrollbar visible y centrado simétrico */
#mainSidebar.sidebar.rail-mode .sidebar-canvas-inner,
#mainSidebar.sidebar.rail-mode #sidebarSpaceClinica,
#mainSidebar.sidebar.rail-mode #sidebarSpaceSistema,
#mainSidebar.sidebar.rail-mode .menu-list {
    width: 58px !important;
    max-width: 58px !important;
    min-width: 58px !important;
    padding: 0 !important;
    margin: 0 auto !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    box-sizing: border-box !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

/* Filas de categorías en reposo: exactamente centradas */
#mainSidebar.sidebar.rail-mode .menu-item,
#mainSidebar.sidebar.rail-mode .menu-list li {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 58px !important;
    max-width: 58px !important;
    min-width: 58px !important;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    margin: 0 auto 4px auto !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    text-align: center !important;
}

/* BOTONES EN REPOSO: 42px x 38px, perfectamente centrados en la columna de 58px */
#mainSidebar.sidebar.rail-mode .menu-item button,
#mainSidebar.sidebar.rail-mode .sistema-menu-btn {
    width: 42px !important;
    height: 38px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    padding: 0 !important;
    margin: 0 auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 9px !important;
    position: relative !important;
    box-sizing: border-box !important;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    box-shadow: none !important;
    cursor: pointer !important;
    transition: background 0.15s ease, transform 0.15s ease !important;
}
#mainSidebar.sidebar.rail-mode .menu-item button:hover,
#mainSidebar.sidebar.rail-mode .sistema-menu-btn:hover {
    background: rgba(255, 255, 255, 0.14) !important;
    transform: scale(1.05);
}
#mainSidebar.sidebar.rail-mode .menu-item button.active,
#mainSidebar.sidebar.rail-mode .sistema-menu-btn.active {
    background: rgba(0, 229, 255, 0.2) !important;
    border: 1px solid rgba(0, 229, 255, 0.5) !important;
    color: #00e5ff !important;
}

/* Iconos de 20x20px en reposo, 100% visibles y centrados */
#mainSidebar.sidebar.rail-mode .menu-item button > svg:not(.arrow-icon),
#mainSidebar.sidebar.rail-mode .menu-item button > img,
#mainSidebar.sidebar.rail-mode .sistema-menu-btn > svg:not(.arrow-icon),
#mainSidebar.sidebar.rail-mode .sistema-menu-btn > img {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    margin: 0 auto !important;
    display: block !important;
    flex-shrink: 0 !important;
}

/* Ocultar etiquetas de texto, flechas chevron, badges y controles inferiores en reposo */
#mainSidebar.sidebar.rail-mode .menu-item button span,
#mainSidebar.sidebar.rail-mode .sistema-menu-btn span,
#mainSidebar.sidebar.rail-mode .arrow-icon,
#mainSidebar.sidebar.rail-mode svg.arrow-icon,
#mainSidebar.sidebar.rail-mode [id$="Badge"],
#mainSidebar.sidebar.rail-mode .sidebar-badge,
#mainSidebar.sidebar.rail-mode #sidebarBottomControls {
    display: none !important;
}

/* Reloj compacto en reposo: solo hora (HH:mm) y 100% centrado */
#mainSidebar.sidebar.rail-mode #sidebarDatetimeFooter {
    width: 58px !important;
    min-width: 58px !important;
    max-width: 58px !important;
    padding: 4px 0 !important;
    margin: auto auto 4px auto !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    border-top: none !important;
    background: transparent !important;
    box-sizing: border-box !important;
}
#mainSidebar.sidebar.rail-mode #sidebarGeminiClockPill {
    width: 46px !important;
    height: 24px !important;
    min-width: 46px !important;
    max-width: 46px !important;
    min-height: 24px !important;
    padding: 0 !important;
    margin: 0 auto !important;
    border-radius: 6px !important;
    background: rgba(0, 229, 255, 0.1) !important;
    border: 1px solid rgba(0, 229, 255, 0.35) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}
#mainSidebar.sidebar.rail-mode #sidebarRailTime {
    display: block !important;
    font-size: 0.70rem !important;
    font-weight: 800 !important;
    color: #00e5ff !important;
    text-align: center !important;
    line-height: 1 !important;
}
#mainSidebar.sidebar.rail-mode #systemTime,
#mainSidebar.sidebar.rail-mode #systemDate,
#mainSidebar.sidebar.rail-mode #sidebarGeminiClockPill svg {
    display: none !important;
}


/* 3. MODO EXPANDIDO FLOTANTE (HOVER / SELECCIONADO / FIJADO) */
/* ANCHO FLUIDO QUE SE ADAPTA AL CONTENIDO (TEXTO) Y AL ZOOM/TAMAÑO DE FUENTE */
#app-container #mainSidebar.sidebar.pinned-mode,
#mainSidebar.sidebar.pinned-mode {
    width: max-content !important;
    min-width: 215px !important;
    max-width: 380px !important;
    padding: 6px 10px 6px 4px !important;
    box-shadow: 14px 0 45px rgba(0, 0, 0, 0.75) !important;
    scrollbar-width: thin !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    box-sizing: border-box !important;
}

/* En desplegado, contenedores internos se expanden al ancho del contenido */
#mainSidebar.sidebar.pinned-mode .sidebar-canvas-inner,
#mainSidebar.sidebar.pinned-mode #sidebarSpaceClinica,
#mainSidebar.sidebar.pinned-mode #sidebarSpaceSistema,
#mainSidebar.sidebar.pinned-mode .menu-list {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Cabecera fija en desplegado: EXACTAMENTE 50px de altura (idéntica a reposo para CERO salto vertical) */
#mainSidebar.sidebar.pinned-mode .sidebar-fixed-header {
    width: 100% !important;
    height: 50px !important;
    min-height: 50px !important;
    max-height: 50px !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    padding: 0 4px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

/* Logo en desplegado: centrado en la cabecera de 50px */
#mainSidebar.sidebar.pinned-mode .sidebar-logo-container {
    width: auto !important;
    height: 46px !important;
    max-height: 46px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
}
#mainSidebar.sidebar.pinned-mode .sidebar-logo-container img {
    max-width: 130px !important;
    max-height: 44px !important;
    object-fit: contain !important;
}

/* Toggle btn en desplegado posicionado a la derecha de la cabecera */
#mainSidebar.sidebar.pinned-mode .sidebar-toggle-google-btn {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    max-width: 28px !important;
    min-height: 28px !important;
    max-height: 28px !important;
    position: absolute !important;
    right: 4px !important;
    top: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
    border: none !important;
    color: var(--text-secondary, #94a3b8) !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    z-index: 10 !important;
}

/* Filas de categorías en desplegado: exactamente 38px + 4px = 42px (idéntico a reposo) */
#mainSidebar.sidebar.pinned-mode .menu-item,
#mainSidebar.sidebar.pinned-mode .menu-list li {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    margin: 0 0 4px 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* BOTONES EN DESPLEGADO: El icono se mantiene en la misma posición horizontal (padding-left: 10px) */
#mainSidebar.sidebar.pinned-mode .menu-item button,
#mainSidebar.sidebar.pinned-mode .sistema-menu-btn {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    padding: 0 12px 0 10px !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    border-radius: 9px !important;
    box-sizing: border-box !important;
}

/* Iconos de 20x20px idénticos en ambos modos */
#mainSidebar.sidebar.pinned-mode .menu-item button > svg,
#mainSidebar.sidebar.pinned-mode .sistema-menu-btn > svg {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    margin: 0 !important;
    display: inline-block !important;
    flex-shrink: 0 !important;
}

/* Mostrar textos de categorías en desplegado con white-space: nowrap para auto-ajuste de ancho */
#mainSidebar.sidebar.pinned-mode .menu-item button span,
#mainSidebar.sidebar.pinned-mode .sistema-menu-btn span {
    display: inline-block !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    font-size: var(--sb-font-size, 0.88rem) !important;
}

/* Flecha chevron para submenús a la derecha */
#mainSidebar.sidebar.pinned-mode .arrow-icon {
    display: inline-block !important;
    margin-left: auto !important;
    flex-shrink: 0 !important;
}

/* Badges en desplegado */
#mainSidebar.sidebar.pinned-mode [id$="Badge"],
#mainSidebar.sidebar.pinned-mode .sidebar-badge {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin-left: auto !important;
    flex-shrink: 0 !important;
}

/* CONTROLES INFERIORES EN DESPLEGADO (SELECTOR GEMINI Y ESTADÍSTICAS) */
#mainSidebar.sidebar.pinned-mode #sidebarBottomControls {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    margin-top: auto !important;
    padding: 6px 4px 2px 4px !important;
    gap: 4px !important;
    box-sizing: border-box !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
}

#mainSidebar.sidebar.pinned-mode .gemini-sidebar-selector {
    display: flex !important;
    width: 100% !important;
    margin: 2px 0 4px 0 !important;
}

#mainSidebar.sidebar.pinned-mode .sidebar-stats-row {
    display: flex !important;
    width: 100% !important;
    margin: 2px 0 !important;
}

/* Reloj restaurado a cápsula completa */
#mainSidebar.sidebar.pinned-mode #sidebarDatetimeFooter {
    width: 100% !important;
    max-width: 100% !important;
    padding: 4px 4px 8px 4px !important;
    display: flex !important;
    box-sizing: border-box !important;
}
#mainSidebar.sidebar.pinned-mode #sidebarGeminiClockPill {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    align-items: center !important;
    justify-content: center !important;
}
#mainSidebar.sidebar.pinned-mode #sidebarRailTime {
    display: none !important;
}
#mainSidebar.sidebar.pinned-mode #systemTime {
    display: inline !important;
}
#mainSidebar.sidebar.pinned-mode #systemDate {
    display: flex !important;
}
#mainSidebar.sidebar.pinned-mode #sidebarGeminiClockPill svg {
    display: inline-block !important;
}

/* ==========================================================================
   AJUSTE MAESTRO DE CONTENEDOR: CERO ESPACIO A LA IZQUIERDA Y CERO DESBORDE A LA DERECHA
   ========================================================================== */
#app-container #mainContent,
#mainContent,
.main-content,
.main-content-wrapper {
    position: relative !important;
    flex: 1 1 0% !important;
    width: auto !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: 100vh !important;
    max-height: 100vh !important;
    margin: 0 !important;
    padding: 1rem 1rem !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    background: var(--card-bg, #1a2f3d) !important;
}

/* Lienzo interior de trabajo */
#mainCanvasInner,
.main-canvas-inner {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

/* Cabecera superior */
.header-top {
    margin-bottom: 0.65rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Ajuste general para todas las vistas (Directorio, Expedientes, Catálogo, Registro, etc.) */
.view.active,
.view,
#viewDashboard {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    flex: 1 !important;
    min-height: 0 !important;
}

/* Sección de Pacientes (Directorio Clínico y Agenda Google Calendar) */
.patients-section,
#viewDashboard .patients-section {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 350px) !important;
    gap: 1rem !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    flex: 1 !important;
    min-height: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

/* Las dos columnas (Directorio y Agenda) ajustadas al contenedor sin desborde */
.patients-section > .card,
.patients-section > div,
.patients-section > div > .card {
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    margin: 0 !important;
}

#patientListContainer {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Herramientas de pantalla completa / IFrames (CorrigeTEA, Comunicador, NeuroFit, ACP, CogniTools, Standalone) */
body.in-corrigetea-view #mainContent,
body.in-cognitools-view #mainContent,
body.in-acp-view #mainContent,
body.in-neurofit-view #mainContent,
body.in-comunicador-view #mainContent,
body.in-standalonetest-view #mainContent {
    padding: 0 !important;
}

#viewCorrigetea,
#viewCognitools,
#viewAcp,
#viewNeurofit,
#viewComunicador,
#viewStandaloneTest {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

.view iframe,
#iframeCorrigeTea,
#iframeCogniTools,
#iframeAcp,
#iframeNeurofit,
#iframeComunicador,
#iframeStandaloneTest {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: 100% !important;
    border-radius: 0 !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    display: block !important;
}

.card,
.patients-section,
.expedientes-list,
.table-responsive,
table,
.expediente-block,
.view-container {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    margin-right: 0 !important;
}


/* Selector Gemini en Controles Inferiores */
.gemini-sidebar-selector {
    display: flex;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
    padding: 3px;
    margin: 4px 0 6px 0;
    width: 100%;
    box-sizing: border-box;
    gap: 3px;
    user-select: none;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}
.gemini-tab-btn {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 6px 8px;
    border-radius: 9999px;
    border: none;
    background: transparent;
    color: var(--text-secondary, #94a3b8);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}
.gemini-tab-btn.active {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%) !important;
    color: #ffffff !important;
    font-weight: 800 !important;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.45) !important;
}
.gemini-tab-btn:hover:not(.active) {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.08) !important;
}

/* ==========================================================================
   ESTUDIO DE GRABACIÓN Y TRANSCRIPCIÓN CLÍNICA EN VIVO (HULI / DOCTORALIA)
   ========================================================================== */
.transcript-bubble {
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    font-size: 0.85rem;
    line-height: 1.45;
    position: relative;
    transition: all 0.15s ease;
    border: 1px solid var(--card-border);
}
.transcript-bubble:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.transcript-bubble.therapist-bubble {
    background: rgba(56, 189, 248, 0.08);
    border-left: 4px solid var(--primary);
    margin-right: 1.5rem;
}
.transcript-bubble.patient-bubble {
    background: rgba(16, 185, 129, 0.08);
    border-left: 4px solid #10b981;
    margin-left: 1.5rem;
}
.transcript-bubble-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
    font-size: 0.72rem;
}
.transcript-speaker-tag {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.therapist-bubble .transcript-speaker-tag {
    color: #0284c7;
}
.patient-bubble .transcript-speaker-tag {
    color: #059669;
}
.transcript-time-tag {
    color: var(--text-secondary);
    font-family: monospace;
    font-size: 0.72rem;
}
.transcript-bubble-text {
    color: var(--text);
    outline: none;
    cursor: text;
}
.transcript-bubble-text:focus {
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
    box-shadow: 0 0 0 2px var(--primary);
    padding: 2px 4px;
}


/* ==========================================================================
   HOMOLOGACIÓN ESTRICTA Y OCULTACIÓN DE TEXTOS EN REPOSO (SISTEMA Y PERFIL)
   ========================================================================== */

/* Ocultar en modo corto (rail) los datos del terapeuta, modo claro y textos de sistema (SOLO PUROS ICONOS) */
#mainSidebar.sidebar.rail-mode #sidebarSpaceSistema #sidebarTherapistInfo,
#mainSidebar.sidebar.rail-mode #sidebarSpaceSistema .theme-toggle-container,
#mainSidebar.sidebar.rail-mode #sidebarSpaceSistema #codeBackupStatus,
#mainSidebar.sidebar.rail-mode #sidebarSpaceSistema #platformStatusBadge,
#mainSidebar.sidebar.rail-mode #sidebarSpaceSistema .sidebar-therapist-card,
#mainSidebar.sidebar.rail-mode #sidebarSpaceSistema i,
#mainSidebar.sidebar.rail-mode #sidebarSpaceSistema span {
    display: none !important;
}

#mainSidebar.sidebar.rail-mode #sidebarSpaceSistema .sistema-btn-row {
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    width: 100% !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
}

#mainSidebar.sidebar.rail-mode #sidebarSpaceSistema .sistema-menu-btn {
    width: 42px !important;
    height: 38px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    padding: 0 !important;
    margin: 0 auto 4px auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 9px !important;
    box-sizing: border-box !important;
}

#mainSidebar.sidebar.rail-mode #sidebarSpaceSistema .sistema-menu-btn svg {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    margin: 0 auto !important;
    display: block !important;
}

/* ==========================================================================
   BARRA DE COLAPSO INFERIOR (OCULTAR HACIA ABAJO CON CHEVRON / BOTÓN)
   ========================================================================== */
.sidebar-bottom-toggle-bar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px 2px 4px 2px;
    box-sizing: border-box;
}

.btn-toggle-bottom-panel {
    width: 100%;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 3px 0;
    color: var(--text-muted, #94a3b8);
    transition: color 0.15s ease;
}

.btn-toggle-bottom-panel:hover {
    color: #38bdf8;
}

.toggle-bar-line {
    flex: 1;
    height: 1px;
    background: var(--card-border, rgba(255, 255, 255, 0.1));
}

.toggle-bar-btn-content {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: inherit;
    background: var(--card-bg, #1a2f3d);
    padding: 0 6px;
    border-radius: 4px;
}

.sidebar-bottom-collapsible-group {
    display: flex;
    flex-direction: column;
    width: 100%;
    transition: max-height 0.28s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
    max-height: 400px;
    opacity: 1;
    overflow: hidden;
}

.sidebar-bottom-collapsible-group.is-collapsed {
    max-height: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.btn-toggle-bottom-panel.is-collapsed #iconBottomPanelChevron {
    transform: rotate(180deg);
}
