* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

:root {
    --primary-color: #1B7F37;
    --primary-light: #2E9E4B;
    --primary-dark: #156B2D;
    --secondary-color: #5D2E1F;
    --accent-color: #8FB339;
    --background: #f8f9f6;
    --surface: #ffffff;
    --text-primary: #2C2C2C;
    --text-secondary: #5D2E1F;
    --border-color: #e2e5dc;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    min-height: 100vh;
    color: var(--text-primary);
}

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, rgba(27, 127, 55, 0.4), rgba(93, 46, 31, 0.35)),
                url('nogales.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    position: relative;
}

.login-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(248, 250, 252, 0.05);
    pointer-events: none;
}

.login-box {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    padding: 48px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1);
    width: 100%;
    max-width: 460px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    z-index: 1;
}

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.login-logo-img {
    height: 80px;
    width: auto;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.1));
}

.login-box h1 {
    color: var(--primary-color);
    margin-bottom: 8px;
    font-size: 32px;
    text-align: center;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.login-box h2 {
    color: var(--text-secondary);
    margin-bottom: 36px;
    font-size: 15px;
    text-align: center;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.2s ease;
    background: var(--surface);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    border-radius: 10px;
    padding: 14px;
    font-size: 16px;
    letter-spacing: 0.02em;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(27, 127, 55, 0.4);
}

.btn-secondary {
    background: var(--primary-color);
    color: white;
    width: auto;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.btn-secondary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    color: var(--secondary-color);
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
    cursor: pointer;
}

.btn-logout:hover {
    background: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
}

.btn-logout svg {
    width: 18px;
    height: 18px;
}

.error-message {
    color: #dc2626;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: #fef2f2;
    border-radius: 8px;
    font-size: 14px;
    border-left: 3px solid #dc2626;
}

.error-message:empty {
    display: none;
    margin: 0;
    padding: 0;
}

.demo-credentials {
    margin-top: 32px;
    padding: 20px;
    background: var(--background);
    border-radius: 10px;
    font-size: 13px;
    border: 1px solid var(--border-color);
}

.demo-credentials p {
    margin-bottom: 8px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.demo-credentials code {
    background: var(--surface);
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    color: var(--primary-color);
    font-weight: 600;
    border: 1px solid var(--border-color);
}

.dashboard-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--background);
    position: relative;
    max-width: 100vw;
    overflow-x: hidden;
}

.dashboard-header {
    background: var(--surface);
    color: var(--text-primary);
    padding: 16px 24px;
    box-shadow: var(--shadow-md);
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.header-logo {
    display: flex;
    align-items: center;
}

.logo-img {
    height: 60px;
    width: auto;
}

.username-text {
    flex: 1;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.sidebar {
    position: fixed;
    left: 0;
    top: 93px;
    width: 220px;
    height: calc(100vh - 93px);
    background: transparent;
    padding: 24px 0;
    z-index: 100;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 16px;
}

.sidebar-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: none;
    background: var(--surface);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: left;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.sidebar-btn:hover {
    background: var(--surface);
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.sidebar-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.sidebar-btn .btn-icon {
    font-size: 22px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-btn .btn-icon svg {
    width: 22px;
    height: 22px;
    stroke: var(--secondary-color);
    transition: stroke 0.2s ease;
}

.sidebar-btn.active .btn-icon svg {
    stroke: white;
}

.sidebar-btn .btn-text {
    flex: 1;
    font-weight: 600;
}

.dashboard-main {
    flex: 1;
    padding: 32px 24px;
    max-width: calc(100vw - 220px);
    width: 100%;
    margin: 0 auto;
    margin-left: 220px;
    margin-top: 93px;
    transition: margin-left 0.3s;
    overflow-x: hidden;
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    gap: 20px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 15px;
    color: var(--text-secondary);
    font-weight: 500;
}

.reports-container {
    display: grid;
    gap: 80px;
}

.report-section {
    background: var(--surface);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    margin-bottom: 60px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    scroll-margin-top: 140px;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.5s ease forwards;
}

.report-section:nth-child(1) {
    animation-delay: 0.1s;
}

.report-section:nth-child(2) {
    animation-delay: 0.2s;
}

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

.report-section:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.report-section h2 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.report-section h2:before {
    content: '';
    width: 4px;
    height: 24px;
    background: var(--primary-color);
    border-radius: 2px;
}

.report-wrapper {
    width: 100%;
    border-radius: 0;
    overflow: hidden;
    background: var(--background);
    border: 1px solid var(--border-color);
    position: relative;
    height: 500px;
}

.powerbi-report {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.dashboard-footer {
    background: var(--surface);
    padding: 20px 24px;
    text-align: center;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    width: 100%;
    position: relative;
    z-index: 50;
}

.dashboard-footer p {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

@media (max-width: 768px) {
    /* Header ordenado: logo izquierda, usuario centro, logout derecha */
    .header-content {
        flex-wrap: nowrap;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
    }

    .header-logo {
        order: 1;
        flex-shrink: 0;
    }

    .logo-img {
        height: 36px;
    }

    .username-text {
        order: 2;
        flex: 1;
        text-align: center;
        font-size: 13px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .btn-logout {
        order: 3;
        padding: 6px;
        flex-shrink: 0;
    }

    .btn-logout span {
        display: none;
    }

    .btn-secondary {
        padding: 6px 12px;
        font-size: 12px;
    }

    /* Espacio para que el contenido no quede debajo del header fijo */
    .dashboard-container {
        padding-top: 60px;
    }

    .dashboard-header {
        padding: 8px 12px;
    }

    /* Ocultar sidebar en móvil */
    .sidebar {
        display: none;
    }

    .dashboard-main {
        margin-left: 0;
        margin-top: 0;
        padding: 8px;
        max-width: 100vw;
    }

    /* Reportes con altura proporcional */
    .report-wrapper {
        min-height: 200px;
        height: 60vh;
        max-height: 250px;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }

    .powerbi-report {
        width: 100% !important;
        height: 100% !important;
        transform: none !important;
        position: relative !important;
    }

    .report-section {
        padding: 8px;
        margin-bottom: 16px;
    }

    .report-section h2 {
        font-size: 14px;
        margin-bottom: 8px;
    }

    .report-section h2:before {
        width: 16px;
    }

    .reports-container {
        gap: 16px;
    }
}
