/* Extraído desde templates/base.html — 2 bloque(s), ~1806 líneas
   Cache-busting via vstatic(). Generado por extract_inline_css.py */

/* Variables globales mejoradas */
        :root {
            --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            --primary-gradient-hover: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
            --glass-bg: rgba(255, 255, 255, 0.95);
            --glass-border: rgba(255, 255, 255, 0.2);
            --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.1);
            --shadow-medium: 0 12px 40px rgba(0, 0, 0, 0.15);
            --shadow-strong: 0 20px 60px rgba(0, 0, 0, 0.2);
            --border-radius-lg: 16px;
            --border-radius-xl: 24px;
            --transition-smooth: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            --mobile-input-height: 80px;
        }

        /* Estilos base mejorados - sin espaciado extra */
        body {
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            position: relative;
            font-family: var(--font-primary);
            background: #f5f7f9;
            color: #2c3e50;
            margin: 0;
            padding: 0;
            overflow-x: hidden;
        }

        main {
            flex: 1;
        }

        /* Navbar con altura original del documento inicial */
        .navbar-desktop {
            padding: 0.3rem 0.6rem !important;
            min-height: 48px;
            max-width: 100vw;
            transition: var(--transition-smooth);
            background: var(--glass-bg) !important;
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border-bottom: 1px solid var(--glass-border);
            box-shadow: var(--shadow-soft);
            /* overflow: visible sólo en el eje Y para que los dropdowns sean visibles,
               pero evitar overflow-x que expande la página */
            overflow-x: clip;
            overflow-y: visible;
        }

        /* Brand solo con logo para más espacio */
        .navbar-brand {
            display: flex;
            align-items: center;
            padding: 0.4rem;
            margin-right: 0.3rem;
            transition: var(--transition-smooth);
        }

        .navbar-brand:hover {
            transform: translateY(-1px) scale(1.05);
        }

        .navbar-brand img {
            height: 30px;
            filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
        }

        .navbar-spacer {
            height: 48px;
        }

        /* Sistema de navegación completamente responsivo.
           NO envolver a segunda fila: los items se mantienen siempre
           en una sola línea (en desktop mostramos solo íconos). */
        .navbar-collapse {
            flex-grow: 1;
            height: 100%;
            align-items: center;
            justify-content: space-between;
            overflow: visible;
            flex-wrap: nowrap;
            min-width: 0;
        }

        @media (min-width: 992px) {
            .navbar-collapse {
                display: flex !important;
            }
        }

        .navbar-nav {
            display: flex;
            flex-direction: row;
            align-items: center;
            margin: 0;
            padding: 0;
            list-style: none;
            height: 100%;
            flex-wrap: nowrap;
            min-width: 0;
        }

        .navbar-nav.me-auto {
            flex: 1 1 auto;
            min-width: 0;
        }

        /* Enlaces de navegación - tamaños originales */
        .navbar-nav .nav-item {
            display: flex;
            align-items: center;
            height: 100%;
            position: relative;
        }

        .navbar-nav .nav-link {
            color: #2c3e50 !important;
            font-weight: 500;
            padding: 0.45rem 0.5rem !important;
            margin: 0 0.05rem;
            border-radius: 8px;
            transition: var(--transition-smooth);
            position: relative;
            font-size: 0.82rem;
            /* white-space: nowrap restaurado para evitar que el texto se parta
               en dos líneas cuando hay muchos items (modo admin). Seguro porque
               el navbar usa overflow-x: clip, no hay riesgo de scroll horizontal. */
            white-space: nowrap;
            display: flex;
            align-items: center;
            gap: 0.3rem;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        /* El <span class="nav-text"> dentro del nav-link también nowrap, por si
           algún estilo hijo reintroduce el wrap */
        .navbar-nav .nav-link .nav-text {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        /* Ajuste responsivo para pantallas medianas */
        @media (min-width: 1200px) and (max-width: 1399px) {
            .navbar-nav .nav-link {
                padding: 0.45rem 0.4rem !important;
                font-size: 0.78rem;
                gap: 0.25rem;
            }
        }

        /* Nombre de usuario en navbar: truncar con ellipsis, nunca desborda */
        .navbar-nav .nav-user-name {
            display: inline-block;
            max-width: 120px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            vertical-align: middle;
        }

        @media (min-width: 1200px) and (max-width: 1399px) {
            .navbar-nav .nav-user-name {
                max-width: 90px;
            }
        }

        @media (min-width: 992px) and (max-width: 1199px) {

            /* En pantallas medianas solo icono, nombre oculto */
            .navbar-nav .nav-user-name {
                display: none;
            }
        }

        /* Solo iconos en pantallas pequeñas */
        @media (min-width: 992px) and (max-width: 1199px) {
            .navbar-nav .nav-link {
                padding: 0.5rem 0.65rem !important;
            }

            .navbar-nav .nav-link .nav-text {
                display: none;
            }

            .navbar-nav .nav-link i {
                font-size: 1.1rem;
            }

            /* Tooltip al hover cuando solo hay iconos */
            .navbar-nav .nav-link[data-tooltip]:hover::after {
                content: attr(data-tooltip);
                position: absolute;
                bottom: -35px;
                left: 50%;
                transform: translateX(-50%);
                background: rgba(0, 0, 0, 0.9);
                color: white;
                padding: 0.3rem 0.6rem;
                border-radius: 6px;
                font-size: 0.75rem;
                white-space: nowrap;
                z-index: 1000;
                pointer-events: none;
            }
        }

        .navbar-nav .nav-link:hover {
            background: rgba(102, 126, 234, 0.1);
            color: #667eea !important;
            transform: translateY(-1px);
        }

        .navbar-nav .nav-link.active {
            background: var(--primary-gradient);
            color: white !important;
            box-shadow: var(--shadow-soft);
        }

        .navbar-nav .nav-link.active:hover {
            background: var(--primary-gradient-hover);
            transform: translateY(-1px);
        }

        /* Dropdown mejorado con JavaScript personalizado - CORREGIDO */
        .navbar-nav .dropdown {
            position: relative;
            height: 100%;
            display: flex;
            align-items: center;
        }

        .navbar-nav .dropdown-toggle {
            cursor: pointer;
        }

        .navbar-nav .dropdown-toggle::after {
            content: '\f107';
            font-family: 'Font Awesome 5 Free';
            font-weight: 900;
            font-size: 0.65rem;
            margin-left: 0.2rem;
            transition: transform 0.3s ease;
            display: inline-block;
        }

        .navbar-nav .dropdown.show .dropdown-toggle::after {
            transform: rotate(180deg);
        }

        /* CORRECCIÓN PRINCIPAL: Dropdown menu con posicionamiento absoluto correcto */
        .dropdown-menu {
            position: absolute;
            top: calc(100% + 8px);
            right: 0;
            left: auto;
            z-index: 9999;
            display: none;
            min-width: 200px;
            padding: 0.5rem;
            margin: 0;
            border: none;
            box-shadow: var(--shadow-medium);
            border-radius: var(--border-radius-lg);
            background: var(--glass-bg);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            max-height: 400px;
            overflow-y: auto;
        }

        /* Para dropdowns que no están al final */
        .dropdown-menu:not(.dropdown-menu-end) {
            left: 0;
            right: auto;
        }

        /* Para asegurar que el dropdown del usuario se alinee correctamente */
        .navbar-nav>li:last-child .dropdown-menu,
        .dropdown-menu.dropdown-menu-end {
            right: 0;
            left: auto;
        }

        .dropdown.show .dropdown-menu {
            display: block;
            animation: dropdownFadeIn 0.3s ease;
        }

        @keyframes dropdownFadeIn {
            from {
                opacity: 0;
                transform: translateY(-10px);
            }

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

        .dropdown-item {
            color: #2c3e50;
            padding: 0.75rem 1.25rem;
            font-weight: 500;
            border-radius: 8px;
            margin: 0.25rem 0;
            transition: var(--transition-smooth);
            display: flex;
            align-items: center;
            gap: 0.5rem;
            text-decoration: none;
            cursor: pointer;
        }

        .dropdown-item:hover {
            background: rgba(102, 126, 234, 0.1);
            color: #667eea;
            transform: translateX(4px);
        }

        .dropdown-item.active {
            background: rgba(102, 126, 234, 0.15);
            color: #667eea;
            font-weight: 600;
        }

        .dropdown-divider {
            height: 1px;
            margin: 0.5rem 0;
            background: rgba(0, 0, 0, 0.1);
        }

        /* Cabecera del dropdown del usuario con el nombre del médico */
        .dropdown-user-header {
            display: flex;
            align-items: center;
            gap: 0.6rem;
            padding: 0.75rem 1rem 0.5rem;
            color: #2c3e50;
            font-weight: 700;
            font-size: 0.9rem;
            letter-spacing: 0.01em;
            background: linear-gradient(135deg, rgba(102, 126, 234, 0.08), rgba(118, 75, 162, 0.08));
            border-radius: 10px;
            margin: 0 0.25rem;
        }

        .dropdown-user-header i {
            font-size: 1.25rem;
            color: #667eea;
            flex-shrink: 0;
        }

        .dropdown-user-header .dropdown-user-name {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            max-width: 200px;
        }

        /* Botón de usuario (solo ícono) destacado en el navbar */
        .navbar-nav .nav-user-toggle {
            background: rgba(102, 126, 234, 0.08);
            border-radius: 50%;
            width: 36px;
            height: 36px;
            padding: 0 !important;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            margin-left: 0.35rem;
        }

        .navbar-nav .nav-user-toggle i {
            font-size: 1.1rem;
            color: #667eea;
        }

        .navbar-nav .nav-user-toggle::after {
            display: none !important;
        }

        .navbar-nav .nav-user-toggle:hover {
            background: rgba(102, 126, 234, 0.18);
        }

        /* Asegurar que el contenedor del navbar permita overflow visible en Y,
           pero nunca en X para evitar scroll horizontal.
           NOTA: usar `overflow-x: clip` (no `hidden`) porque `hidden` fuerza
           `overflow-y` a `auto` por acoplamiento CSS y recorta los dropdowns
           que cuelgan debajo del navbar. `clip` no tiene ese acoplamiento. */
        .navbar-desktop .container-fluid {
            position: relative;
            overflow-x: clip;
            overflow-y: visible;
            max-width: 100%;
        }

        /* Solución específica para la página de chat */
        .chat-page .navbar-desktop,
        .chat-page .navbar-spacer {
            display: none !important;
            height: 0 !important;
            padding: 0 !important;
            margin: 0 !important;
            overflow: hidden !important;
        }

        .chat-page main {
            margin-top: 0 !important;
            padding-top: 0 !important;
        }

        /* Botón hamburguesa para móviles - posición como en chat.css */
        .mobile-menu-trigger {
            display: none;
            position: fixed;
            bottom: calc(var(--mobile-input-height) + 20px);
            right: 1rem;
            width: 48px;
            height: 48px;
            background: #0d6efd;
            color: white;
            border: none;
            border-radius: 50%;
            box-shadow: var(--shadow-strong);
            z-index: 1040;
            cursor: pointer;
            transition: var(--transition-smooth);
            align-items: center;
            justify-content: center;
            font-size: 1rem;
        }

        .mobile-menu-trigger:hover {
            background: #0a58ca;
            transform: scale(1.1);
        }

        .mobile-menu-trigger.active {
            background: #4f46e5;
            transform: scale(1.1) rotate(90deg);
        }

        /* Modal de menú flotante - adaptativo como chat.css */
        .floating-menu {
            display: none;
            position: fixed;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.75);
            z-index: 1030;
            opacity: 0;
            transition: opacity 0.3s ease;
            backdrop-filter: blur(5px);
        }

        .floating-menu.show {
            opacity: 1;
        }

        .floating-menu-content {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 85%;
            max-width: 320px;
            background-color: white;
            border-radius: 15px;
            padding: 1.5rem;
            box-shadow: 0 5px 25px rgba(0, 0, 0, 0.3);
            animation: menuModalSlideIn 0.3s ease-out;
            max-height: 90vh;
            overflow-y: auto;
        }

        /* Adaptativo para móviles como en chat.css */
        @media (max-width: 640px) {
            .floating-menu-content {
                border-radius: 20px 20px 0 0;
                max-width: 100%;
                max-height: 100vh;
                margin-top: auto;
                width: 100%;
                transform: translate(-50%, 0);
                top: auto;
                bottom: 0;
                left: 50%;
            }

            .floating-menu-header {
                padding: 1.25rem 0 0.75rem;
            }
        }

        @media (max-width: 480px) {
            .floating-menu-content {
                width: 100%;
                left: 0;
                right: 0;
                transform: none;
                border-radius: 20px 20px 0 0;
            }
        }

        @keyframes menuModalSlideIn {
            from {
                opacity: 0;
                transform: translate(-50%, -50%) scale(0.9);
            }

            to {
                opacity: 1;
                transform: translate(-50%, -50%) scale(1);
            }
        }

        @media (max-width: 640px) {
            @keyframes menuModalSlideIn {
                from {
                    opacity: 0;
                    transform: translate(-50%, 100%);
                }

                to {
                    opacity: 1;
                    transform: translate(-50%, 0);
                }
            }
        }

        .floating-menu-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 1rem;
            padding-bottom: 0.5rem;
            border-bottom: 1px solid #dee2e6;
        }

        .floating-menu-brand {
            display: flex;
            align-items: center;
            gap: 10px;
            font-weight: 600;
            font-size: 1.1rem;
            color: #333;
        }

        .floating-menu-brand img {
            height: 30px;
        }

        .floating-menu-close {
            background: none;
            border: none;
            font-size: 1.2rem;
            color: #6c757d;
            cursor: pointer;
            transition: var(--transition-smooth);
            width: 30px;
            height: 30px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
        }

        .floating-menu-close:hover {
            color: #3b82f6;
            background: #f0f4ff;
        }

        .floating-menu-nav {
            list-style: none;
            padding: 0;
            margin: 0 0 1rem 0;
        }

        .floating-menu-item {
            margin-bottom: 0.5rem;
        }

        .floating-menu-link {
            display: flex;
            align-items: center;
            padding: 0.75rem;
            color: #333;
            text-decoration: none;
            border-radius: 8px;
            transition: all 0.2s ease;
        }

        .floating-menu-link:hover,
        .floating-menu-link:focus {
            background-color: #f8f9fa;
            color: #0d6efd;
        }

        .floating-menu-link.active {
            background-color: #e7f1ff;
            color: #0d6efd;
            font-weight: 500;
        }

        .floating-menu-link i {
            margin-right: 10px;
            width: 24px;
            text-align: center;
        }

        .floating-menu-divider {
            height: 1px;
            background-color: #dee2e6;
            margin: 0.5rem 0;
        }

        .floating-menu-footer {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding-top: 0.5rem;
            border-top: 1px solid #dee2e6;
        }

        .floating-menu-footer .text-muted {
            font-size: 0.85rem;
        }

        .floating-menu-footer .btn {
            font-size: 0.8rem;
            padding: 0.4rem 0.8rem;
        }

        /* Responsive - Mostrar hamburguesa solo en móviles */
        @media (max-width: 992px) {
            .navbar-desktop {
                display: none !important;
            }

            .navbar-spacer {
                display: none !important;
            }

            .mobile-menu-trigger {
                display: flex !important;
            }

            body {
                background: #f5f7f9;
            }
        }

        @media (min-width: 992px) {
            .mobile-menu-trigger {
                display: none !important;
            }

            .floating-menu {
                display: none !important;
            }
        }

        /* Flash-messages — diseño minimalista profesional */
        .flash-messages {
            position: fixed;
            top: 20px;
            right: 20px;
            z-index: 1080;
            max-width: 380px;
            width: calc(100% - 40px);
            display: flex;
            flex-direction: column;
            gap: 10px;
            pointer-events: none;
        }

        .flash-messages .alert {
            position: relative;
            display: flex;
            align-items: center;
            gap: 12px;
            margin: 0;
            padding: 14px 44px 14px 16px;
            background: #ffffff;
            border: 1px solid rgba(15, 23, 42, 0.06);
            border-left: 3px solid transparent;
            border-radius: 10px;
            box-shadow: 0 6px 24px rgba(15, 23, 42, 0.08),
                        0 2px 6px rgba(15, 23, 42, 0.04);
            color: #0f172a;
            font-size: 0.9rem;
            font-weight: 500;
            line-height: 1.4;
            letter-spacing: 0.005em;
            backdrop-filter: none;
            -webkit-backdrop-filter: none;
            pointer-events: auto;
            animation: flashSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
        }

        .flash-messages .alert::before {
            content: "";
            flex-shrink: 0;
            width: 22px;
            height: 22px;
            border-radius: 50%;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-size: 0.72rem;
            font-weight: 700;
            font-family: -apple-system, "Segoe UI", system-ui, sans-serif;
            line-height: 1;
        }

        .flash-messages .alert-success {
            border-left-color: #10b981;
        }

        .flash-messages .alert-success::before {
            content: "✓";
            color: #059669;
            background: rgba(16, 185, 129, 0.12);
        }

        .flash-messages .alert-danger {
            border-left-color: #ef4444;
        }

        .flash-messages .alert-danger::before {
            content: "✕";
            color: #dc2626;
            background: rgba(239, 68, 68, 0.12);
        }

        .flash-messages .alert-warning {
            border-left-color: #f59e0b;
            color: #0f172a;
        }

        .flash-messages .alert-warning::before {
            content: "!";
            color: #d97706;
            background: rgba(245, 158, 11, 0.14);
        }

        .flash-messages .alert-info {
            border-left-color: #3b82f6;
        }

        .flash-messages .alert-info::before {
            content: "i";
            color: #2563eb;
            background: rgba(59, 130, 246, 0.12);
            font-style: italic;
            font-family: Georgia, "Times New Roman", serif;
        }

        .flash-messages .alert-primary {
            border-left-color: #6366f1;
        }

        .flash-messages .alert-primary::before {
            content: "i";
            color: #4f46e5;
            background: rgba(99, 102, 241, 0.12);
            font-style: italic;
            font-family: Georgia, "Times New Roman", serif;
        }

        .flash-messages .alert .btn-close {
            position: absolute;
            top: 50%;
            right: 10px;
            transform: translateY(-50%);
            width: 22px;
            height: 22px;
            padding: 0;
            margin: 0;
            background: transparent;
            border: 0;
            border-radius: 6px;
            opacity: 0.4;
            transition: opacity 0.18s ease, background-color 0.18s ease;
            background-size: 10px;
        }

        .flash-messages .alert .btn-close:hover,
        .flash-messages .alert .btn-close:focus {
            opacity: 0.9;
            background-color: rgba(15, 23, 42, 0.06);
            box-shadow: none;
        }

        @keyframes flashSlideIn {
            from {
                transform: translateX(20px);
                opacity: 0;
            }
            to {
                transform: translateX(0);
                opacity: 1;
            }
        }

        .flash-messages .alert.fade:not(.show) {
            opacity: 0;
            transform: translateX(20px);
            transition: opacity 0.25s ease, transform 0.25s ease;
        }

        @media (max-width: 576px) {
            .flash-messages {
                top: 12px;
                right: 12px;
                left: 12px;
                width: auto;
                max-width: none;
            }

            .flash-messages .alert {
                font-size: 0.875rem;
                padding: 12px 40px 12px 14px;
            }
        }

        /* Footer original - espaciado corregido */
        .footer {
            padding: 0.5rem 0;
            margin-top: auto;
            background-color: #f8f9fa;
            border-top: 1px solid #e9ecef;
            font-size: 0.8rem;
        }

        .footer a {
            color: #0d6efd;
            text-decoration: none;
        }

        .footer a:hover {
            text-decoration: underline;
        }

        /* Ocultar footer en páginas específicas */
        .chat-page .footer,
        .login-page .footer {
            display: none !important;
        }

        /* Dark mode improvements */
        @media (prefers-color-scheme: dark) {
            :root {
                --glass-bg: rgba(30, 30, 30, 0.95);
                --glass-border: rgba(255, 255, 255, 0.1);
            }

            body {
                background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
                color: #e9ecef;
            }

            .navbar-brand {
                color: #e9ecef !important;
            }

            .navbar-nav .nav-link {
                color: #e9ecef !important;
            }

            .floating-menu-content {
                background-color: #2c3e50;
                color: #e9ecef;
            }

            .floating-menu-brand {
                color: #e9ecef;
            }

            .floating-menu-link {
                color: #e9ecef;
            }

            .floating-menu-link:hover {
                background-color: rgba(102, 126, 234, 0.2);
                color: #667eea;
            }
        }

        /* Mejoras adicionales de accesibilidad */
        @media (prefers-reduced-motion: reduce) {
            * {
                animation-duration: 0.01ms !important;
                animation-iteration-count: 1 !important;
                transition-duration: 0.01ms !important;
            }
        }

        /* ================================================================
           RESPONSIVE BASELINE — Asegura que TODO el layout se ajuste
           correctamente en móvil, tablet y desktop sin overflow horizontal
           ================================================================ */

        /* Box model coherente en todo el documento */
        *,
        *::before,
        *::after {
            box-sizing: border-box;
        }

        html {
            width: 100%;
            max-width: 100%;
            overflow-x: hidden;
            -webkit-text-size-adjust: 100%;
            -ms-text-size-adjust: 100%;
        }

        body {
            width: 100%;
            max-width: 100vw;
        }

        /* Main fluido: nunca debe rebasar el ancho de la pantalla.
           min-width: 0 es crítico en flexbox para que los hijos
           con contenido largo no fuercen overflow. */
        main {
            width: 100%;
            max-width: 100%;
            min-width: 0;
            overflow-x: hidden;
        }

        /* Contenedores Bootstrap fluidos por defecto en pantallas chicas */
        .container,
        .container-fluid,
        .container-sm,
        .container-md,
        .container-lg,
        .container-xl,
        .container-xxl {
            width: 100%;
            max-width: 100%;
            padding-left: clamp(0.75rem, 2vw, 1.5rem);
            padding-right: clamp(0.75rem, 2vw, 1.5rem);
        }

        /* Restaurar max-width Bootstrap solo en breakpoints grandes */
        @media (min-width: 1200px) {
            .container {
                max-width: 1140px;
            }
        }

        @media (min-width: 1400px) {
            .container {
                max-width: 1320px;
            }
        }

        /* Multimedia y embeds totalmente responsivos */
        img,
        video,
        iframe,
        embed,
        object,
        canvas,
        svg,
        picture {
            max-width: 100%;
            height: auto;
        }

        iframe,
        embed,
        object {
            border: 0;
        }

        /* Tablas con scroll horizontal cuando no caben */
        .table-responsive,
        .table-wrapper {
            width: 100%;
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
        }

        table {
            max-width: 100%;
        }

        /* Bloques de código/preformateado: scroll interno, no romper layout */
        pre,
        code {
            max-width: 100%;
            overflow-x: auto;
            word-wrap: break-word;
        }

        pre {
            white-space: pre;
            -webkit-overflow-scrolling: touch;
        }

        /* Romper palabras largas (URLs, IDs) en lugar de desbordar */
        p,
        li,
        td,
        th,
        dd,
        dt,
        blockquote,
        h1,
        h2,
        h3,
        h4,
        h5,
        h6 {
            overflow-wrap: break-word;
            word-wrap: break-word;
        }

        /* Forms responsivos: inputs y selects nunca más anchos que su padre */
        input,
        textarea,
        select,
        button {
            max-width: 100%;
        }

        /* ===== Tablet (768px – 991px) ===== */
        @media (max-width: 992px) {
            .footer {
                text-align: center;
                padding: 0.75rem 0.5rem;
            }

            .footer .row>[class*="col-"] {
                margin-bottom: 0.25rem;
            }

            .flash-messages {
                top: 14px;
                right: 14px;
                left: 14px;
                width: auto;
                max-width: none;
            }
        }

        /* ===== Móvil (≤ 640px) ===== */
        @media (max-width: 640px) {
            body {
                font-size: 0.95rem;
            }

            main {
                padding-left: 0;
                padding-right: 0;
            }

            .footer p {
                font-size: 0.75rem;
            }

            .navbar-brand img {
                height: 26px;
            }
        }

        /* ===== Móvil pequeño (≤ 480px) ===== */
        @media (max-width: 480px) {
            :root {
                --border-radius-lg: 12px;
                --border-radius-xl: 18px;
            }

            .floating-menu-content {
                padding: 1rem;
            }

            .floating-menu-brand {
                font-size: 1rem;
            }

            .floating-menu-link {
                padding: 0.65rem 0.5rem;
            }
        }

        /* ===== Móvil muy pequeño (≤ 360px) ===== */
        @media (max-width: 360px) {
            body {
                font-size: 0.9rem;
            }

            .mobile-menu-trigger {
                width: 44px;
                height: 44px;
                right: 0.75rem;
            }
        }

        /* Soporte para "notch" / safe-area en iOS */
        @supports (padding: max(0px)) {
            body {
                padding-left: env(safe-area-inset-left);
                padding-right: env(safe-area-inset-right);
            }

            .mobile-menu-trigger {
                right: max(1rem, env(safe-area-inset-right));
                bottom: max(calc(var(--mobile-input-height) + 20px), calc(env(safe-area-inset-bottom) + 20px));
            }
        }

        /* En la página de chat el main ocupa toda la pantalla sin padding extra */
        .chat-page main {
            padding: 0 !important;
        }

        /* ================================================================
           BLOQUE FINAL ANTI-OVERFLOW — Evita scroll-x en TODO el sitio.
           Estas reglas van ÚLTIMO para ganar la cascada CSS.
           ================================================================ */

        /* Nivel raíz: nunca scroll horizontal */
        html {
            overflow-x: hidden !important;
            max-width: 100vw !important;
        }

        /* Body: fluido y sin scroll-x.
           Se necesita !important para superar reglas de Bootstrap o
           de templates hijas que puedan setear overflow explícitamente. */
        body {
            overflow-x: hidden !important;
            max-width: 100vw !important;
            /* width:100% ya establecido arriba */
        }

        /* Cualquier contenedor de nivel de página */
        .container,
        .container-fluid,
        .container-sm,
        .container-md,
        .container-lg,
        .container-xl,
        .container-xxl,
        main,
        #content,
        .page-wrapper,
        .app-content,
        .dashboard-container {
            max-width: 100% !important;
            overflow-x: hidden;
        }

        /* La navbar jamás desborda en X.
           Usar `overflow-x: clip` en lugar de `hidden` para no forzar
           `overflow-y` a `auto` — si fuera `auto`, los dropdowns quedarían
           recortados al caer fuera del navbar. */
        .navbar,
        .navbar-desktop,
        .navbar-desktop .container-fluid {
            max-width: 100vw;
            overflow-x: clip;
        }

        /* Tablas admin/listas: scroll interno, nunca desborda la ventana */
        .table-responsive-wrapper,
        .admin-table-container {
            overflow-x: auto;
            max-width: 100%;
        }

        /* Cualquier elemento flex/grid que pueda ser demasiado ancho */
        .row {
            margin-left: 0;
            margin-right: 0;
            max-width: 100%;
        }

        /* Debug helper (comentar en producción): */
        /* * { outline: 1px solid red !important; } */

/* ========== Bloque 2 desde base.html ========== */

/* ============================================================
       MODAL COMPLETAR PERFIL — Adaptativo a viewport (sin scroll)
       ============================================================ */
        .perfil-completar-overlay {
            position: fixed;
            inset: 0;
            background: rgba(10, 15, 30, 0.88);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            z-index: 999999;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 14px;
            overflow: hidden;
            animation: pcFadeIn 0.35s ease-out;
        }

        @keyframes pcFadeIn {
            from {
                opacity: 0;
            }

            to {
                opacity: 1;
            }
        }

        .perfil-completar-modal {
            background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
            border: 1px solid rgba(96, 165, 250, 0.3);
            border-radius: 20px;
            max-width: 540px;
            width: 100%;
            max-height: calc(100vh - 28px);
            max-height: calc(100dvh - 28px);
            display: flex;
            flex-direction: column;
            overflow: hidden;
            box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
            animation: pcSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        }

        @keyframes pcSlideUp {
            from {
                transform: translateY(30px) scale(0.96);
                opacity: 0;
            }

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

        .perfil-completar-header {
            padding: 22px 28px 14px 28px;
            text-align: center;
            border-bottom: 1px solid rgba(255, 255, 255, 0.08);
            flex-shrink: 0;
        }

        .perfil-completar-icon {
            width: 56px;
            height: 56px;
            border-radius: 50%;
            margin: 0 auto 10px auto;
            background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
            color: #ffffff;
            box-shadow: 0 10px 30px rgba(59, 130, 246, 0.4);
        }

        .perfil-completar-header h2 {
            color: #ffffff;
            font-size: 1.22rem;
            font-weight: 700;
            margin: 0 0 6px 0;
            letter-spacing: -0.3px;
        }

        .perfil-completar-lead {
            color: rgba(255, 255, 255, 0.72);
            font-size: 0.82rem;
            line-height: 1.5;
            margin: 0;
        }

        .perfil-completar-lead strong {
            color: #93c5fd;
            font-weight: 600;
        }

        .perfil-completar-body {
            padding: 16px 28px 20px 28px;
            overflow-y: auto;
            flex: 1 1 auto;
            min-height: 0;
        }

        .pc-row-title {
            display: grid;
            grid-template-columns: 128px 1fr;
            gap: 10px;
            margin-bottom: 10px;
        }

        .pc-field {
            margin-bottom: 10px;
        }

        .pc-field label {
            display: block;
            color: rgba(255, 255, 255, 0.85);
            font-size: 0.78rem;
            font-weight: 600;
            margin-bottom: 5px;
            letter-spacing: 0.2px;
        }

        .pc-field label i {
            margin-right: 6px;
            color: #60a5fa;
            width: 14px;
        }

        .pc-field>input,
        .pc-field>select {
            width: 100%;
            padding: 10px 12px;
            background: rgba(255, 255, 255, 0.06);
            border: 1.5px solid rgba(255, 255, 255, 0.15);
            border-radius: 10px;
            color: #ffffff;
            font-size: 0.9rem;
            font-family: inherit;
            transition: all 0.2s;
            box-sizing: border-box;
        }

        .pc-field>input:focus,
        .pc-field>select:focus {
            outline: none;
            background: rgba(255, 255, 255, 0.1);
            border-color: #60a5fa;
            box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
        }

        .pc-field>input::placeholder {
            color: rgba(255, 255, 255, 0.35);
        }

        .pc-field>select {
            appearance: none;
            -webkit-appearance: none;
            background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
            background-repeat: no-repeat;
            background-position: right 12px center;
            background-size: 13px;
            padding-right: 34px;
            cursor: pointer;
        }

        .pc-field>select option {
            background: #1e293b;
            color: #ffffff;
        }

        .pc-field small {
            display: block;
            font-size: 0.7rem;
            color: rgba(255, 255, 255, 0.5);
            margin-top: 3px;
            font-style: italic;
        }

        .pc-field.pc-prefilled>input,
        .pc-field.pc-prefilled>select,
        .pc-field.pc-prefilled .pc-phone-group {
            border-color: rgba(34, 197, 94, 0.35);
            background: rgba(34, 197, 94, 0.06);
        }

        /* ─── Phone group unificado (pais + numero en una caja) ─── */
        .pc-phone-group {
            display: flex;
            flex-direction: row;
            flex-wrap: nowrap;
            align-items: stretch;
            width: 100%;
            background: rgba(255, 255, 255, 0.06);
            border: 1.5px solid rgba(255, 255, 255, 0.15);
            border-radius: 10px;
            transition: all 0.2s;
            overflow: hidden;
        }

        .pc-phone-group:hover {
            border-color: rgba(96, 165, 250, 0.45);
        }

        .pc-phone-group:focus-within {
            background: rgba(255, 255, 255, 0.1);
            border-color: #60a5fa;
            box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
        }

        .pc-phone-prefix-wrapper {
            flex: 0 0 108px;
            min-width: 108px;
            max-width: 108px;
            border-right: 1px solid rgba(96, 165, 250, 0.25);
            display: flex;
            align-items: center;
        }

        .pc-phone-prefix-wrapper select {
            width: 100%;
            height: 42px;
            padding: 0 24px 0 12px;
            background-color: transparent;
            background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2393c5fd' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
            background-repeat: no-repeat;
            background-position: right 8px center;
            background-size: 11px;
            border: none;
            border-radius: 0;
            color: #ffffff;
            font-size: 0.88rem;
            font-weight: 600;
            font-family: inherit;
            appearance: none;
            -webkit-appearance: none;
            cursor: pointer;
            outline: none;
            box-shadow: none;
            box-sizing: border-box;
            letter-spacing: 0.01em;
        }

        .pc-phone-prefix-wrapper select:focus {
            outline: none;
            box-shadow: none;
        }

        .pc-phone-prefix-wrapper select option {
            background: #1e293b;
            color: #ffffff;
            padding: 8px 12px;
            font-size: 0.9rem;
        }

        .pc-phone-group>input[type="tel"] {
            flex: 1 1 auto;
            width: auto;
            min-width: 0;
            height: 42px;
            padding: 0 14px;
            background: transparent !important;
            border: none !important;
            border-radius: 0 !important;
            box-shadow: none !important;
            color: #ffffff;
            font-size: 0.9rem;
            font-family: inherit;
            box-sizing: border-box;
        }

        .pc-phone-group>input[type="tel"]::placeholder {
            color: rgba(255, 255, 255, 0.35);
        }

        .pc-phone-group>input[type="tel"]:focus {
            outline: none;
            background: transparent !important;
            box-shadow: none !important;
            border: none !important;
        }

        .pc-feedback {
            margin: 8px 0 0 0;
            padding: 0;
            font-size: 0.82rem;
            border-radius: 8px;
            transition: all 0.2s;
        }

        .pc-feedback:not(:empty) {
            padding: 9px 12px;
            margin: 10px 0;
        }

        .pc-feedback.error {
            background: rgba(239, 68, 68, 0.15);
            color: #fecaca;
            border: 1px solid rgba(239, 68, 68, 0.4);
        }

        .pc-feedback.success {
            background: rgba(34, 197, 94, 0.15);
            color: #bbf7d0;
            border: 1px solid rgba(34, 197, 94, 0.4);
        }

        .pc-submit {
            width: 100%;
            padding: 12px 20px;
            margin-top: 6px;
            background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
            border: none;
            border-radius: 12px;
            color: #ffffff;
            font-size: 0.95rem;
            font-weight: 700;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            transition: all 0.25s;
            box-shadow: 0 8px 20px rgba(59, 130, 246, 0.35);
            font-family: inherit;
        }

        .pc-submit:hover:not(:disabled) {
            transform: translateY(-2px);
            box-shadow: 0 12px 26px rgba(59, 130, 246, 0.45);
        }

        .pc-submit:disabled {
            opacity: 0.6;
            cursor: not-allowed;
        }

        .pc-privacy {
            margin: 12px 0 0 0;
            text-align: center;
            font-size: 0.72rem;
            color: rgba(255, 255, 255, 0.45);
        }

        .pc-privacy i {
            margin-right: 4px;
            color: #10b981;
        }

        /* ============================================================
       VIEWPORT HEIGHT — Compactacion progresiva
       ============================================================ */
        @media (max-height: 760px) {
            .perfil-completar-header {
                padding: 18px 26px 12px 26px;
            }

            .perfil-completar-icon {
                width: 50px;
                height: 50px;
                font-size: 1.35rem;
                margin-bottom: 8px;
            }

            .perfil-completar-header h2 {
                font-size: 1.12rem;
                margin-bottom: 5px;
            }

            .perfil-completar-lead {
                font-size: 0.78rem;
                line-height: 1.45;
            }

            .perfil-completar-body {
                padding: 13px 26px 17px 26px;
            }

            .pc-row-title {
                margin-bottom: 8px;
                gap: 9px;
            }

            .pc-field {
                margin-bottom: 8px;
            }

            .pc-field label {
                font-size: 0.75rem;
                margin-bottom: 4px;
            }

            .pc-field>input,
            .pc-field>select {
                padding: 9px 11px;
                font-size: 0.87rem;
            }

            .pc-phone-prefix-wrapper select {
                height: 38px;
                font-size: 0.85rem;
            }

            .pc-phone-group>input[type="tel"] {
                height: 38px;
                font-size: 0.87rem;
            }

            .pc-field small {
                font-size: 0.67rem;
                margin-top: 2px;
            }

            .pc-submit {
                padding: 10px 18px;
                font-size: 0.9rem;
            }

            .pc-privacy {
                font-size: 0.68rem;
                margin-top: 9px;
            }
        }

        @media (max-height: 660px) {
            .perfil-completar-header {
                padding: 14px 22px 9px 22px;
            }

            .perfil-completar-icon {
                width: 44px;
                height: 44px;
                font-size: 1.2rem;
                margin-bottom: 6px;
            }

            .perfil-completar-header h2 {
                font-size: 1.02rem;
                margin-bottom: 3px;
            }

            .perfil-completar-lead {
                font-size: 0.72rem;
                line-height: 1.35;
            }

            .perfil-completar-body {
                padding: 10px 22px 14px 22px;
            }

            .pc-row-title {
                margin-bottom: 6px;
                gap: 8px;
            }

            .pc-field {
                margin-bottom: 6px;
            }

            .pc-field small {
                display: none;
            }

            .pc-field label {
                font-size: 0.72rem;
                margin-bottom: 3px;
            }

            .pc-field>input,
            .pc-field>select {
                padding: 8px 10px;
                font-size: 0.84rem;
            }

            .pc-phone-prefix-wrapper {
                flex: 0 0 100px;
                min-width: 100px;
                max-width: 100px;
            }

            .pc-phone-prefix-wrapper select {
                height: 35px;
                font-size: 0.82rem;
                padding: 0 22px 0 10px;
            }

            .pc-phone-group>input[type="tel"] {
                height: 35px;
                font-size: 0.85rem;
                padding: 0 12px;
            }

            .pc-submit {
                padding: 9px 16px;
                font-size: 0.88rem;
                margin-top: 4px;
            }

            .pc-privacy {
                margin-top: 7px;
                font-size: 0.66rem;
            }
        }

        @media (max-height: 580px) {
            .perfil-completar-header {
                padding: 10px 20px 6px 20px;
                border-bottom: none;
            }

            .perfil-completar-icon {
                display: none;
            }

            .perfil-completar-header h2 {
                font-size: 0.95rem;
                margin-bottom: 2px;
            }

            .perfil-completar-lead {
                display: none;
            }

            .perfil-completar-body {
                padding: 8px 20px 12px 20px;
            }

            .pc-field {
                margin-bottom: 5px;
            }

            .pc-field label {
                font-size: 0.68rem;
                margin-bottom: 2px;
            }

            .pc-field>input,
            .pc-field>select {
                padding: 6px 9px;
                font-size: 0.8rem;
            }

            .pc-phone-prefix-wrapper select {
                height: 32px;
            }

            .pc-phone-group>input[type="tel"] {
                height: 32px;
            }

            .pc-submit {
                padding: 8px 14px;
                font-size: 0.85rem;
            }

            .pc-privacy {
                display: none;
            }
        }

        /* ============================================================
       VIEWPORT WIDTH — Mobile
       ============================================================ */
        @media (max-width: 560px) {
            .perfil-completar-overlay {
                padding: 10px;
            }

            .perfil-completar-header {
                padding: 18px 20px 12px 20px;
            }

            .perfil-completar-header h2 {
                font-size: 1.1rem;
            }

            .perfil-completar-lead {
                font-size: 0.78rem;
            }

            .perfil-completar-body {
                padding: 14px 20px 18px 20px;
            }

            .pc-row-title {
                grid-template-columns: 1fr;
                gap: 0;
                margin-bottom: 0;
            }

            .pc-row-title .pc-field {
                margin-bottom: 10px;
            }

            .perfil-completar-icon {
                width: 50px;
                height: 50px;
                font-size: 1.35rem;
            }

            .pc-phone-prefix-wrapper {
                flex: 0 0 100px;
                min-width: 100px;
                max-width: 100px;
            }
        }

        /* Bloqueo total: no hay scroll del body cuando el modal está abierto */
        body.pc-modal-open {
            overflow: hidden !important;
        }
