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

        :root {
            --azul-profundo: #0E2586;
            --azul-claro: #3498db;
            --marron-oscuro: #4E110B;
            --verde-scout: #00853F;
            --amarillo: #FFD100;
            --rojo: #E31837;
            --gris-fondo: #f4f7f9;
            --gris-claro: #e2e8f0;
            --blanco: #ffffff;
            --texto-oscuro: #2d3748;
            --texto-claro: #718096;
            --border-color: #cbd5e0;
            --color-manada: #FFD100;
            --color-tropa: #00853F;
            --color-compania: #00853F;
            --color-pioneros: #0055A5;
            --color-caminantes: #E31837;
            --sidebar-width: 280px;
            --sidebar-collapsed-width: 75px;
            --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            --shadow: 0 4px 20px rgba(0,0,0,0.08);
            --shadow-hover: 0 10px 30px rgba(0,0,0,0.12);
        }

        body {
            margin: 0; padding: 0;
            font-family: 'Poppins', 'Segoe UI', Tahoma, sans-serif;
            background: var(--gris-fondo); overflow: hidden; display: flex; height: 100vh;
        }

        #app-container { display: flex; width: 100%; height: 100%; }

        /* --- SIDEBAR --- */
        .sidebar {
            width: var(--sidebar-width);
            background: var(--azul-profundo); color: white;
            height: 100%; display: flex; flex-direction: column;
            transition: var(--transition); position: relative; z-index: 100; flex-shrink: 0;
            box-shadow: 4px 0 15px rgba(0,0,0,0.1);
        }
        .sidebar.collapsed { width: var(--sidebar-collapsed-width); }

        .sidebar-header {
            padding: 18px 14px 16px; text-align: center; border-bottom: 1px solid rgba(255,255,255,0.1);
            overflow: hidden; flex-shrink: 0;
        }
        .sidebar-header img { width: 72px; height: auto; transition: var(--transition); display: block; margin: 0 auto 8px; }
        .sidebar.collapsed .sidebar-header img { width: 42px; margin-bottom: 0; }
        .sidebar-header h2 { margin: 0 0 3px; font-size: 0.88rem; font-weight: 700; line-height: 1.3; white-space: normal; word-break: break-word; transition: var(--transition); }
        .sidebar-header p { margin: 0; font-size: 0.71rem; color: #aaa; white-space: normal; line-height: 1.4; transition: var(--transition); }
        .sidebar.collapsed .sidebar-header h2, .sidebar.collapsed .sidebar-header p { opacity: 0; height: 0; overflow: hidden; margin: 0; }

        .nav-menu { flex-grow: 1; overflow-y: auto; overflow-x: hidden; padding-top: 10px; }
        .nav-menu::-webkit-scrollbar { width: 5px; }
        .nav-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }

        .nav-item {
            display: flex; align-items: center; padding: 12px 20px; color: rgba(255,255,255,0.7);
            text-decoration: none; cursor: pointer; transition: var(--transition);
            white-space: nowrap; border-left: 4px solid transparent;
        }
        .nav-item.oculto-permiso { display: none; }
        .nav-item i:first-child { width: 30px; font-size: 1.2rem; text-align: center; margin-right: 15px; }
        .nav-item:hover, .nav-item.active { background: rgba(255,255,255,0.1); color: white; border-left-color: var(--azul-claro); }
        .sidebar.collapsed .nav-item span, .sidebar.collapsed .toggle-icon { display: none; }

        .submenu { background: rgba(0,0,0,0.2); display: none; flex-direction: column; }
        .submenu.open { display: flex; }
        .submenu-item {
            padding: 10px 20px 10px 65px; font-size: 0.85rem; color: rgba(255,255,255,0.6);
            cursor: pointer; transition: var(--transition); white-space: nowrap; border-left: 2px solid transparent;
        }
        .submenu-item:hover, .submenu-item.active { color: white; background: rgba(255,255,255,0.05); border-left-color: var(--azul-claro); }
        .sidebar.collapsed .submenu { display: none !important; }

        /* --- MAIN CONTENT & TOPBAR --- */
        .main-content { flex-grow: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }
        
        .topbar {
            background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px);
            height: 70px; display: flex; align-items: center; justify-content: space-between;
            padding: 0 25px; box-shadow: var(--shadow); z-index: 90;
        }
        .topbar-left { display: flex; align-items: center; gap: 20px; flex: 1; }
        .sidebar-toggle { font-size: 1.4rem; cursor: pointer; color: var(--texto-oscuro); transition: 0.2s; }
        .sidebar-toggle:hover { color: var(--azul-claro); transform: scale(1.1); }

        /* --- OMNIBOX (BUSCADOR GLOBAL) --- */
        .search-container { position: relative; width: 320px; transition: var(--transition); z-index: 101; }
        .search-container.focused { width: 480px; }
        
        .search-bar {
            display: flex; align-items: center; background: #f0f2f5; padding: 10px 18px;
            border-radius: 30px; border: 2px solid transparent; transition: var(--transition);
        }
        .search-container.focused .search-bar { background: white; border-color: var(--azul-claro); box-shadow: 0 4px 20px rgba(52, 152, 219, 0.25); }
        .search-bar i { color: #888; margin-right: 12px; font-size: 1.1rem; transition: 0.2s; }
        .search-container.focused .search-bar i.fa-search { color: var(--azul-claro); }
        .search-bar input {
            border: none; background: transparent; outline: none; width: 100%;
            font-family: inherit; font-size: 0.95rem; color: var(--texto-oscuro);
        }
        .search-shortcut {
            background: #e1e4e8; color: #555; font-size: 0.7rem; padding: 4px 8px;
            border-radius: 6px; font-weight: 700; pointer-events: none; transition: 0.2s;
        }
        .search-container.focused .search-shortcut { opacity: 0; display: none; }

        .search-results {
            position: absolute; top: calc(100% + 10px); left: 0; width: 100%;
            background: rgba(255, 255, 255, 0.98); backdrop-filter: blur(10px);
            border-radius: 15px; box-shadow: 0 15px 40px rgba(0,0,0,0.15);
            display: none; flex-direction: column; overflow: hidden; border: 1px solid #eaeaea;
            max-height: 450px; overflow-y: auto;
        }
        .search-results.active { display: flex; animation: slideDown 0.2s ease-out; }
        .search-category { background: #f8fafc; padding: 10px 15px; font-size: 0.75rem; font-weight: 700; color: var(--texto-claro); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid #eaeaea; }
        .search-item { padding: 12px 15px; display: flex; align-items: center; gap: 15px; cursor: pointer; transition: background 0.2s; border-bottom: 1px solid #f0f0f0; }
        .search-item:last-child { border-bottom: none; }
        .search-item:hover { background: #f0f7ff; }
        .search-item-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: white; font-size: 1rem; flex-shrink: 0; }
        .icon-joven { background: linear-gradient(135deg, var(--verde-scout), #2ecc71); }
        .icon-adulto { background: linear-gradient(135deg, var(--azul-profundo), var(--azul-claro)); }
        .icon-evento { background: linear-gradient(135deg, #e67e22, #f39c12); }
        .search-item-title { font-size: 0.95rem; font-weight: 600; color: var(--texto-oscuro); margin: 0; }
        .search-item-subtitle { font-size: 0.75rem; color: var(--texto-claro); margin: 3px 0 0; }
        .search-loading, .search-empty { padding: 30px 20px; text-align: center; color: var(--texto-claro); font-size: 0.95rem; }
        .search-loading i { color: var(--azul-claro); animation: spin 1s linear infinite; margin-bottom: 15px; font-size: 2rem; }
        @keyframes spin { 100% { transform: rotate(360deg); } }

        .global-overlay {
            position: fixed; top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(14, 37, 134, 0.2); backdrop-filter: blur(3px);
            z-index: 95; display: none; transition: opacity 0.3s; opacity: 0; pointer-events: none;
        }
        .global-overlay.active { display: block; opacity: 1; }

        /* --- TOPBAR ACTIONS --- */
        .topbar-actions { display: flex; align-items: center; gap: 15px; }
        
        .action-btn {
            width: 40px; height: 40px; border-radius: 50%; background: #f0f2f5;
            display: flex; align-items: center; justify-content: center; color: var(--texto-oscuro);
            cursor: pointer; transition: all 0.2s; position: relative; border: none;
        }
        .action-btn:hover { background: var(--azul-claro); color: white; transform: translateY(-2px); box-shadow: var(--shadow); }
        .badge-dot { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; background: #e74c3c; border-radius: 50%; border: 2px solid white; transition: opacity 0.3s; opacity: 0; }

        /* --- NOTIFICACIONES DROPDOWN --- */
        .notif-section { position: relative; }
        .notif-dropdown {
            position: absolute; top: calc(100% + 15px); right: -10px; width: 340px;
            background: rgba(255, 255, 255, 0.98); backdrop-filter: blur(15px);
            border-radius: 16px; box-shadow: 0 15px 40px rgba(0,0,0,0.15);
            display: none; flex-direction: column; z-index: 1000; border: 1px solid rgba(0,0,0,0.05);
            animation: slideDown 0.2s ease-out; cursor: default;
        }
        .notif-dropdown.active { display: flex; }
        .notif-header { padding: 15px 20px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; }
        .notif-header h3 { margin: 0; font-size: 1rem; color: var(--azul-profundo); }
        .notif-header span { font-size: 0.75rem; color: var(--azul-claro); cursor: pointer; font-weight: 600; transition: 0.2s; }
        .notif-header span:hover { text-decoration: underline; color: var(--azul-profundo); }
        .notif-body { max-height: 380px; overflow-y: auto; padding: 0; }
        .notif-body::-webkit-scrollbar { width: 5px; }
        .notif-body::-webkit-scrollbar-thumb { background: #ddd; border-radius: 10px; }
        .notif-item { padding: 15px 20px; display: flex; gap: 15px; cursor: pointer; transition: background 0.2s; border-bottom: 1px solid #f9f9f9; }
        .notif-item:hover { background: #f0f7ff; }
        .notif-item.unread { background: #f8fbff; }
        .notif-item.unread .notif-title { font-weight: 700; color: var(--azul-profundo); }
        .notif-item.unread .notif-time { color: var(--azul-claro); font-weight: 600; }
        .notif-icon { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 1.1rem; }
        .notif-content { flex: 1; overflow: hidden; }
        .notif-title { margin: 0; font-size: 0.85rem; color: var(--texto-oscuro); line-height: 1.3; }
        .notif-time { margin: 5px 0 0; font-size: 0.7rem; color: var(--texto-claro); }
        .notif-footer { padding: 12px; text-align: center; border-top: 1px solid #eee; font-size: 0.85rem; color: var(--azul-claro); cursor: pointer; font-weight: 600; border-radius: 0 0 16px 16px; transition: 0.2s; }
        .notif-footer:hover { background: #f0f7ff; }

        /* --- PERFIL DE USUARIO & AVATAR --- */
        .user-section { position: relative; z-index: 100; margin-left: 10px; padding-left: 15px; border-left: 1px solid #eee; }
        .user-trigger {
            display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 6px 12px;
            border-radius: 40px; transition: background 0.2s; border: 1px solid transparent;
        }
        .user-trigger:hover { background: #f8f9fa; border-color: #e1e4e8; }
        
        .avatar-img-container {
            width: 42px; height: 42px; border-radius: 50%; overflow: hidden;
            box-shadow: 0 2px 5px rgba(0,0,0,0.15); display: flex; align-items: center; justify-content: center;
            background: linear-gradient(135deg, var(--azul-profundo), var(--azul-claro)); color: white; font-weight: bold;
        }
        .avatar-img-container img { width: 100%; height: 100%; object-fit: cover; display: none; }

        .user-info-text { text-align: right; }
        .user-info-text p { margin: 0; line-height: 1.2; }
        .user-name { font-weight: 700; color: var(--azul-profundo); font-size: 0.95rem; }
        .user-role { font-size: 0.75rem; color: var(--texto-claro); }

        .user-dropdown {
            position: absolute; top: calc(100% + 15px); right: 0; width: 320px;
            background: rgba(255, 255, 255, 0.98); backdrop-filter: blur(15px);
            border-radius: 16px; box-shadow: 0 15px 40px rgba(0,0,0,0.15);
            display: none; flex-direction: column; z-index: 1000; border: 1px solid rgba(0,0,0,0.05);
            overflow: hidden; animation: slideDown 0.2s ease-out;
        }
        .user-dropdown.active { display: flex; }
        
        .dropdown-header {
            background: url('https://i.imgur.com/MpmoQR3.jpeg') center/cover; padding: 30px 20px 20px;
            position: relative; color: white; text-align: center;
        }
        .dropdown-header::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(14, 37, 134, 0.85); }
        .dropdown-header-content { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; }
        
        .big-avatar-container {
            width: 70px; height: 70px; border-radius: 50%; overflow: hidden;
            border: 3px solid rgba(255,255,255,0.4); background-clip: padding-box;
            background: white; display: flex; align-items: center; justify-content: center;
            color: var(--azul-profundo); font-size: 1.8rem; font-weight: bold; margin-bottom: 12px;
            box-shadow: 0 4px 10px rgba(0,0,0,0.2);
        }
        .big-avatar-container img { width: 100%; height: 100%; object-fit: cover; display: none; }

        .dropdown-badges { display: flex; gap: 5px; margin-top: 8px; justify-content: center; }
        .badge { background: rgba(255,255,255,0.2); padding: 4px 10px; border-radius: 12px; font-size: 0.7rem; backdrop-filter: blur(4px); border: 1px solid rgba(255,255,255,0.3); }
        .badge.active-status { background: var(--verde-scout); border: none; }

        .dropdown-body { padding: 10px 0; }
        .user-dropdown .item { padding: 12px 20px; display: flex; align-items: center; gap: 15px; color: var(--texto-oscuro); text-decoration: none; cursor: pointer; font-size: 0.95rem; transition: background 0.2s; }
        .user-dropdown .item i { font-size: 1.1rem; width: 20px; text-align: center; color: var(--texto-claro); }
        .user-dropdown .item:hover { background: #f4f7f9; }
        .user-dropdown .item:hover i { color: var(--azul-claro); }
        .user-dropdown .item.danger:hover { background: #fee2e2; color: #dc2626; }
        .user-dropdown .item.danger:hover i { color: #dc2626; }

        /* --- VIEWS E IFRAMES --- */
        .view-content { display: none; padding: 20px; height: calc(100vh - 70px); box-sizing: border-box; }
        .view-content.active { display: block; animation: fadeIn 0.3s; }
        @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
        iframe { width: 100%; height: 100%; border: none; border-radius: 1rem; background: white; box-shadow: 0 4px 15px rgba(0,0,0,0.05); }

        
        .btn { padding: 14px 24px; border-radius: 30px; border: none; cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.15); transition: all 0.2s; font-family: inherit; }
        .btn:hover { transform: translateY(-3px); box-shadow: 0 8px 25px rgba(0,0,0,0.2); }
        .btn:active { transform: translateY(0); }
        .btn-primary { background: linear-gradient(135deg, var(--azul-claro), #2980b9); color: white; }
        .btn-secondary { background: var(--texto-oscuro); color: white; }

        /* --- MODALES & AVATAR UPLOAD --- */
        .modal-overlay {
            position: fixed; top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(0,0,0,0.5); backdrop-filter: blur(8px);
            display: none; align-items: center; justify-content: center; z-index: 2000;
        }
        .modal {
            background: white; padding: 40px; border-radius: 24px; width: 90%; max-width: 450px;
            box-shadow: 0 25px 50px rgba(0,0,0,0.25); position: relative;
            animation: slideUpModal 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }
        @keyframes slideUpModal { from { opacity: 0; transform: translateY(30px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
        
        .modal h3 { margin: 0 0 5px 0; color: var(--azul-profundo); font-size: 1.5rem; }
        .modal .close-btn { position: absolute; top: 20px; right: 20px; width: 32px; height: 32px; background: #f0f2f5; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; color: #888; font-size: 1rem; transition: 0.2s; }
        .modal .close-btn:hover { background: #e1e4e8; color: #333; transform: rotate(90deg); }
        
        .form-group { margin-bottom: 20px; }
        .form-group label { display: block; margin-bottom: 8px; font-size: 0.9rem; font-weight: 600; color: var(--texto-oscuro); }
        .form-group input {
            width: 100%; padding: 12px 15px; border: 2px solid #e1e4e8; border-radius: 12px;
            box-sizing: border-box; transition: border-color 0.2s; font-family: inherit; font-size: 0.95rem;
        }
        .form-group input:focus { outline: none; border-color: var(--azul-claro); box-shadow: 0 0 0 3px rgba(52,152,219,0.1); }

        /* Edición de Avatar */
        .avatar-upload-zone {
            display: flex; flex-direction: column; align-items: center; margin-bottom: 25px;
        }
        .avatar-edit-circle {
            width: 100px; height: 100px; border-radius: 50%; background: #f0f2f5;
            position: relative; cursor: pointer; overflow: hidden; border: 3px solid white;
            box-shadow: 0 5px 15px rgba(0,0,0,0.1); display: flex; align-items: center; justify-content: center;
            font-size: 2.5rem; color: var(--azul-claro); font-weight: bold;
        }
        .avatar-edit-circle img { width: 100%; height: 100%; object-fit: cover; display: none; }
        .avatar-edit-overlay {
            position: absolute; top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(0,0,0,0.5); color: white; display: flex; flex-direction: column;
            align-items: center; justify-content: center; opacity: 0; transition: 0.2s; font-size: 0.8rem; font-weight: 600;
        }
        .avatar-edit-circle:hover .avatar-edit-overlay { opacity: 1; }

        /* --- TOAST NOTIFICATIONS --- */
        #toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
        .toast {
            min-width: 280px; padding: 15px 20px; border-radius: 12px; background: white;
            box-shadow: 0 10px 30px rgba(0,0,0,0.15); display: flex; align-items: center; gap: 15px;
            animation: slideInRight 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
            border-left: 5px solid transparent; font-size: 0.95rem; color: var(--texto-oscuro);
        }
        .toast.success { border-left-color: var(--verde-scout); }
        .toast.success i { color: var(--verde-scout); font-size: 1.2rem; }
        .toast.error { border-left-color: #e74c3c; }
        .toast.error i { color: #e74c3c; font-size: 1.2rem; }
        .toast.info { border-left-color: #3498db; }
        .toast.info i { color: #3498db; font-size: 1.2rem; }
        @keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
        @keyframes fadeOutRight { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

    
        /* ════ RESPONSIVE MÓVIL — comportamiento app nativa ════ */
        .sidebar-backdrop {
            display: none; position: fixed; inset: 0;
            background: rgba(0,0,0,0.5); z-index: 99;
            opacity: 0; transition: opacity 0.25s;
        }
        .bottom-nav { display: none; }

        @media (max-width: 768px) {
            /* Sidebar → drawer oculto por defecto */
            .sidebar {
                position: fixed; top: 0; left: 0; bottom: 0;
                transform: translateX(-100%);
                transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
                width: min(300px, 84vw) !important;
                z-index: 1000;
                box-shadow: none;
            }
            .sidebar.mobile-open {
                transform: translateX(0);
                box-shadow: 6px 0 30px rgba(0,0,0,0.35);
            }
            .sidebar.collapsed { width: min(300px, 84vw) !important; }
            .sidebar.collapsed .nav-item span,
            .sidebar.collapsed .toggle-icon { display: inline; }
            .sidebar.collapsed .sidebar-header h2,
            .sidebar.collapsed .sidebar-header p { opacity: 1; height: auto; }

            .sidebar-backdrop.visible { display: block; opacity: 1; }

            /* Topbar compacta */
            .topbar { padding: 8px 12px !important; }
            .search-shortcut { display: none !important; }

            /* Contenido a pantalla completa + espacio para bottom nav */
            .main-content { width: 100vw !important; padding-bottom: 62px !important; }
            .view-content { padding-bottom: 62px !important; }
            .view-content iframe { height: calc(100vh - 120px) !important; }

            /* ── Bottom Navigation estilo app ── */
            .bottom-nav {
                display: flex; position: fixed; bottom: 0; left: 0; right: 0;
                height: 60px; background: var(--azul-profundo);
                z-index: 900; justify-content: space-around; align-items: stretch;
                box-shadow: 0 -3px 12px rgba(0,0,0,0.18);
                padding-bottom: env(safe-area-inset-bottom, 0);
            }
            .bnav-item {
                flex: 1; display: flex; flex-direction: column;
                align-items: center; justify-content: center; gap: 3px;
                color: rgba(255,255,255,0.55); cursor: pointer;
                font-size: 0.62rem; font-weight: 600;
                transition: color 0.18s; -webkit-tap-highlight-color: transparent;
                border: none; background: none; font-family: inherit;
            }
            .bnav-item i { font-size: 1.15rem; }
            .bnav-item.act { color: white; }
            .bnav-item.act i { color: var(--amarillo, #FFD100); }
            .bnav-item:active { transform: scale(0.93); }

            /* Ocultar botón Contraer Menú en móvil (no aplica) */
            #nav-contraer-menu, .nav-item[onclick*="toggleSidebarColapso"] { display: none; }
        }

        @media (max-width: 768px) {
            /* ── FAB central flotante en bottom nav ── */
            .bnav-fab {
                position: relative; flex: 1; display: flex; flex-direction: column;
                align-items: center; justify-content: flex-end; padding-bottom: 5px;
                border: none; background: none; font-family: inherit; cursor: pointer;
                color: rgba(255,255,255,0.75); font-size: 0.62rem; font-weight: 700;
                -webkit-tap-highlight-color: transparent;
            }
            .bnav-fab .fab-circle {
                position: absolute; top: -22px;
                width: 54px; height: 54px; border-radius: 50%;
                background: linear-gradient(135deg, #FFD100, #f59e0b);
                display: flex; align-items: center; justify-content: center;
                box-shadow: 0 6px 18px rgba(245,158,11,.45), 0 0 0 5px var(--azul-profundo);
                color: #0E2586; font-size: 1.35rem;
                transition: transform .15s;
            }
            .bnav-fab:active .fab-circle { transform: scale(.9); }
            .bnav-fab span { margin-top: 2px; }
        }
