:root {
    --primary: #1e40af;       
    --primary-hover: #1e3a8a;
    --sidebar-bg: #0f172a;   
    --text-dark: #334155;    
    --text-light: #f8fafc;   
    --bg-body: #f1f5f9;     
    --green: #10b981;         
    --red-danger: #ef4444;  
    --gold-accent: #f59e0b;   
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Roboto', Helvetica, Arial, sans-serif;
    margin: 0;
    background-color: var(--bg-body);
    color: var(--text-dark);
}

#login-screen {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--sidebar-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5000;
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    border-top: 6px solid var(--primary);
}

.login-card h2 {
    color: var(--sidebar-bg);
    margin-bottom: 5px;
}

.login-hint {
    background: #f1f5f9;
    padding: 10px;
    border-radius: 6px;
    font-size: 13px;
    color: #64748b;
    margin-bottom: 25px;
    border: 1px dashed #cbd5e1;
}

.login-hint strong {
    color: var(--primary);
}

.container {
    display: flex;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

.btn-menu {
    display: none;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--sidebar-bg);
    padding: 0;
    margin-right: 15px;
}

.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--text-light);
    padding: 20px;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 1000;
    flex-shrink: 0;
    height: 100%;
    overflow-y: auto;
}

.sidebar h2 {
    margin-bottom: 30px;
    text-align: center;
    font-size: 22px;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 20px;
    font-weight: 700;
}

.user-mini-profile {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.avatar-circle {
    width: 60px;
    height: 60px;
    background: rgba(255,255,255,0.1);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
    font-weight: bold;
    font-size: 24px;
    border: 2px solid var(--primary);
}

.nav-link {
    color: #94a3b8; 
    text-decoration: none;
    padding: 12px 15px;
    display: block;
    margin-bottom: 8px;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-size: 15px;
}

.nav-link:hover, .nav-link.active {
    background-color: var(--primary);
    color: white;
    font-weight: 500;
    transform: translateX(5px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.btn-logout {
    margin-top: auto;
    background: transparent;
    border: 1px solid #334155;
    color: #94a3b8;
    padding: 12px;
    cursor: pointer;
    border-radius: 5px;
    transition: 0.3s;
    margin-bottom: 20px;
}

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

.main-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    position: relative;
    width: 100%;
}

header {
    display: flex;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 15px;
}

header h1 {
    font-size: 24px;
    color: var(--sidebar-bg);
    margin: 0;
    font-weight: 700;
}

.seccion-oculta { display: none; }
.seccion-activa { display: block; animation: fadeIn 0.4s ease-in-out; }

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

.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 35px;
}

.card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    text-align: center;
    border-top: 4px solid var(--primary);
}

.card h3 {
    margin: 0;
    font-size: 13px;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 1px;
    font-weight: 600;
}

.card p {
    margin: 10px 0 5px;
    font-size: 28px;
    font-weight: 700;
    color: var(--sidebar-bg);
    word-wrap: break-word;
}

.table-container {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
    max-width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

thead tr {
    background-color: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
}

th {
    padding: 15px;
    text-align: left;
    color: #475569;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

td {
    padding: 12px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    font-size: 14px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 4px 6px rgba(30, 64, 175, 0.25);
    white-space: nowrap;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-action {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    color: white;
    margin-right: 5px;
}

.btn-add { background: var(--green); }
.btn-sell { background: #334155; }

.btn-loss {
    background: var(--gold-accent);
}

.btn-loss:hover {
    background: #d97706;
}

.btn-delete {
    background: white;
    color: var(--red-danger);
    border: 1px solid var(--red-danger);
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 6px;
    font-size: 12px;
    font-weight: bold;
}

.btn-small-text {
    font-size: 11px;
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    text-decoration: underline;
    margin-top: 5px;
}

.config-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

input, select {
    width: 100%;
    padding: 12px;
    margin: 8px 0 20px 0;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 16px;
    background-color: #f8fafc;
}

.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.6);
    z-index: 2000;
    backdrop-filter: blur(4px);
    overflow-y: auto;
    padding: 10px;
}

.modal-content {
    background: white;
    margin: 10vh auto;
    padding: 25px;
    width: 100%;
    max-width: 400px;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    position: relative;
    border-top: 6px solid var(--primary);
}

.close {
    position: absolute;
    right: 15px;
    top: 10px;
    cursor: pointer;
    font-size: 32px;
    color: #94a3b8;
    background: #f1f5f9;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    text-align: center;
    line-height: 38px;
    transition: 0.2s;
}

.close:hover { 
    color: var(--red-danger); 
    background: #e2e8f0;
}

.overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 900;
    transition: opacity 0.3s;
}

@media (max-width: 768px) {
    .container {
        display: block;
        height: auto;
        overflow: auto;
    }

    .btn-menu {
        display: block;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        width: 80%;
        max-width: 280px;
        box-shadow: 5px 0 15px rgba(0,0,0,0.3);
    }

    .sidebar.active {
        left: 0;
        transform: none;
    }

    .overlay.active {
        display: block;
    }

    .main-content {
        padding: 15px;
        width: 100%;
    }

    header h1 {
        font-size: 20px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .stats-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .card {
        padding: 15px;
    }

    .table-container {
        padding: 10px;
        margin-bottom: 80px;
    }
    
    .config-card {
        padding: 15px;
    }

    .modal-content {
        margin: 15% auto;
        width: 90%;
        padding: 20px;
    }
}