:root {
    --bg-dark: #0f172a;
    --bg-panel: rgba(30, 41, 59, 0.7);
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.5);
    --accent: #10b981;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(148, 163, 184, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    background-image:
        radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.15) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.1) 0%, transparent 20%);
    min-height: 100vh;
    /* IMPORTANTE: Permitir scroll nativo siempre */
    overflow-y: auto;
    overflow-x: hidden;
}

/* =========================================
   DESKTOP LAYOUT (Robust Fixed Sidebar)
   ========================================= */
.dashboard-container {
    display: block;
    /* No grid, no flex complexities */
    width: 100%;
    min-height: 100vh;
}

/* Sidebar: Siempre fija a la izquierda */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    /* Ocupa toda la altura de ventana */
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 2rem 1rem;
    z-index: 1000;
    overflow-y: auto;
    /* Scroll interno si el menú es muy alto */
}

/* Contenido Principal: Empujado a la derecha */
.main-content {
    margin-left: 260px;
    /* Espacio para el sidebar */
    width: calc(100% - 260px);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 50px;
    /* Espacio al final para scroll cómodo */
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 3rem;
    padding-left: 1rem;
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.menu-item.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    border-color: rgba(59, 130, 246, 0.2);
}

.menu-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    justify-content: space-between;
}

.badge {
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-top: 20px;
}

.avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.info {
    display: flex;
    flex-direction: column;
}

.name {
    font-size: 0.9rem;
    font-weight: 500;
}

.role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Header & View Container */
.top-bar {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    border-bottom: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.8);
    /* Semi transparente sticky? No, dejemoslo normal */
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--accent);
    background: rgba(16, 185, 129, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent);
}

#view-container {
    padding: 2rem;
    /* Quitar overflow interno para usar el del body */
    overflow: visible;
}

/* Components */
.glass-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    backdrop-filter: blur(12px);
}

.input-section {
    max-width: 600px;
    margin: 0 auto 3rem auto;
}

.input-section h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 1rem;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.1);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary), #2563eb);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* Stats */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: 12px;
    text-align: center;
}

.stat .value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat .value.success {
    color: var(--accent);
}

.stat .label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Grid Results */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.company-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
}

.card-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.company-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.company-address {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.email-preview {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    border-left: 3px solid var(--accent);
}

.email-subject {
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-main);
}

/* Loader */
.hidden {
    display: none !important;
}

#loader {
    text-align: center;
    padding: 3rem;
}

.scanner {
    height: 4px;
    width: 200px;
    background: var(--bg-dark);
    margin: 0 auto 2rem auto;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.scanner::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 50%;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    animation: scan 1.5s infinite linear;
}

@keyframes scan {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(200%);
    }
}

.agent-steps {
    list-style: none;
    max-width: 300px;
    margin: 0 auto;
    text-align: left;
}

.agent-steps li {
    padding: 8px 0;
    color: var(--text-muted);
}

.agent-steps li.active {
    color: var(--primary);
    font-weight: 500;
}

/* Mobile Utilities */
.mobile-toggle {
    display: none;
}

/* =========================================
   MOBILE RESPONSIVE (Max 768px)
   ========================================= */
@media (max-width: 768px) {

    /* 1. Main Content Full Width */
    .main-content {
        margin-left: 0;
        width: 100%;
        padding-top: 70px;
    }

    /* 2. Sidebar Hidden off-screen */
    .sidebar {
        left: -100%;
        width: 85%;
        max-width: 300px;
        transition: left 0.3s ease;
        box-shadow: 10px 0 50px rgba(0, 0, 0, 0.5);
    }

    /* Activate Sidebar */
    .sidebar.active {
        left: 0;
    }

    /* 3. Mobile Toggle Button */
    .mobile-toggle {
        display: flex;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 2000;
        width: 45px;
        height: 45px;
        background: var(--primary);
        border: none;
        border-radius: 12px;
        color: white;
        font-size: 1.2rem;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
        cursor: pointer;
    }

    /* 4. Adjust Layouts to Stack */
    .top-bar {
        justify-content: flex-end;
        padding-right: 15px;
    }

    .top-bar h1 {
        display: none;
    }

    .cards-grid {
        grid-template-columns: 1fr;
    }

    .stats-bar {
        grid-template-columns: 1fr;
    }

    .input-section {
        padding: 0 1rem;
    }

    /* Force Scroll */
    body {
        overflow-y: auto !important;
    }
}
/* =========================================
   MOBILE BRANDING FIX
   ========================================= */
/* Default: Hide mobile brand on Desktop */
.mobile-brand {
    display: none;
}

@media (max-width: 768px) {
    /* Show Mobile Brand */
    .mobile-brand {
        display: flex;
        align-items: center;
        gap: 10px;
        position: absolute;
        left: 70px; /* Space for the hamburger button */
        top: 50%;
        transform: translateY(-50%);
    }

    .mobile-brand img {
        height: 32px;
        width: auto;
    }

    .mobile-brand span {
        font-weight: 700;
        font-size: 1.2rem;
        color: var(--text-main);
    }
    
    /* Ensure Header has relative positioning for absolute child */
    .top-bar {
        position: relative; 
        justify-content: flex-end; /* Keep status on right */
    }
}



/* TABLES */
.table-container { overflow-x: auto; margin-top: 20px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.data-table th { text-align: left; padding: 12px 15px; background: rgba(255,255,255,0.05); color: var(--text-secondary); font-weight: 500; }
.data-table td { padding: 12px 15px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.data-table tr:hover { background: rgba(255,255,255,0.02); }
/* RISK BADGES */
.badge.risk-high { background: rgba(239, 68, 68, 0.2); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.5); }
.badge.risk-medium { background: rgba(245, 158, 11, 0.2); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.5); }
/* UTILS */
.header-split { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.btn-primary.small { padding: 8px 16px; font-size: 0.9rem; }