:root {
    --primary: #dc2626;
    --primary-dark: #b91c1c;
    --primary-light: #f87171;
    --secondary: #1c1917;
    --accent: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f5f5f4;
    --card: #ffffff;
    --text: #1c1917;
    --text-muted: #78716c;
    --border: #e7e5e4;
    --sidebar-w: 260px;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 24px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 40px rgba(0,0,0,.1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* LOGIN */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1c1917 0%, #292524 50%, #44403c 100%);
    position: relative;
    overflow: hidden;
}
.login-wrapper::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(220,38,38,.35), transparent 70%);
    top: -200px; right: -100px;
    border-radius: 50%;
}
.login-wrapper::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(239,68,68,.2), transparent 70%);
    bottom: -100px; left: -50px;
    border-radius: 50%;
}
.login-card {
    background: rgba(255,255,255,.05);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 20px;
    padding: 48px 40px;
    width: 420px;
    position: relative;
    z-index: 1;
}
.login-card h1 {
    color: #fff;
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 8px;
    text-align: center;
}
.login-card .subtitle {
    color: rgba(255,255,255,.5);
    text-align: center;
    margin-bottom: 32px;
    font-size: .9rem;
}
.login-card .logo-icon {
    width: 56px; height: 56px;
    background: linear-gradient(135deg, var(--primary), #991b1b);
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 20px;
    font-size: 1.5rem; color: #fff;
}
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    color: rgba(255,255,255,.7);
    font-size: .85rem;
    font-weight: 500;
    margin-bottom: 6px;
}
.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 10px;
    color: #fff;
    font-size: .95rem;
    transition: all .2s;
    outline: none;
}
.form-group input::placeholder { color: rgba(255,255,255,.3); }
.form-group input:focus {
    border-color: var(--primary-light);
    background: rgba(255,255,255,.12);
    box-shadow: 0 0 0 3px rgba(220,38,38,.25);
}
.btn-login {
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    margin-top: 8px;
}
.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(220,38,38,.4);
}
.alert {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: .875rem;
    font-weight: 500;
}
.alert-danger { background: rgba(239,68,68,.15); color: #fca5a5; border: 1px solid rgba(239,68,68,.2); }
.alert-success { background: rgba(16,185,129,.15); color: #6ee7b7; border: 1px solid rgba(16,185,129,.2); }

/* LAYOUT PRINCIPAL */
.app-layout { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-w);
    background: var(--secondary);
    color: #fff;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width .3s ease;
    overflow: hidden;
}
.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex; align-items: center; gap: 12px;
}
.sidebar-header .logo {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--primary), #991b1b);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.1rem;
    flex-shrink: 0;
}
.sidebar-header .brand { font-weight: 600; font-size: .95rem; line-height: 1.3; }
.sidebar-header .brand small { display: block; font-weight: 400; font-size: .7rem; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-section { margin-bottom: 24px; }
.nav-section-title {
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 0 12px;
    margin-bottom: 8px;
    font-weight: 600;
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: rgba(255,255,255,.65);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 500;
    transition: all .15s;
    margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item i { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.08);
}
.user-info {
    display: flex; align-items: center; gap: 10px;
}
.user-avatar {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem;
}
.user-details { flex: 1; }
.user-details .name { font-size: .85rem; font-weight: 600; }
.user-details .role { font-size: .7rem; color: var(--text-muted); }

/* MAIN CONTENT */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    transition: margin-left .3s ease;
}
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar h2 { font-size: 1.25rem; font-weight: 700; }
.topbar .breadcrumb { font-size: .8rem; color: var(--text-muted); }

.content-area { padding: 32px; }

/* CARDS */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}
.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: all .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card .stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 16px;
}
.stat-card .stat-icon.red { background: rgba(220,38,38,.1); color: var(--primary); }
.stat-card .stat-icon.green { background: rgba(16,185,129,.1); color: var(--success); }
.stat-card .stat-icon.orange { background: rgba(245,158,11,.1); color: var(--warning); }
.stat-card .stat-icon.cyan { background: rgba(6,182,212,.1); color: #06b6d4; }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; margin-bottom: 4px; }
.stat-card .stat-label { font-size: .85rem; color: var(--text-muted); }

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 24px;
}
.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 24px; }

/* MÓDULOS GRID */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}
.module-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    transition: all .25s;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.module-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}
.module-card .module-icon {
    width: 56px; height: 56px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
}
.module-card h4 { font-size: 1.05rem; font-weight: 600; }
.module-card p { font-size: .85rem; color: var(--text-muted); line-height: 1.5; }
.module-card .module-arrow {
    margin-top: auto;
    font-size: .85rem;
    color: var(--primary);
    font-weight: 600;
    display: flex; align-items: center; gap: 6px;
}

/* BUTTONS */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: .875rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all .15s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 6px 14px; font-size: .8rem; }
.btn-logout {
    background: rgba(220,38,38,.1);
    color: var(--primary);
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-size: .85rem;
    font-weight: 500;
    transition: all .15s;
}
.btn-logout:hover { background: rgba(220,38,38,.2); }

/* SIDEBAR TOGGLE */
.topbar-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 36px; height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    transition: all .2s;
}
.topbar-toggle:hover {
    background: var(--bg);
    color: var(--text);
    border-color: var(--text-muted);
}

.sidebar.hidden { transform: translateX(-100%); }
.main-content.expanded { margin-left: 0; }

/* RESPONSIVE */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .content-area { padding: 20px; }
    .topbar { padding: 16px 20px; }
}
