:root {
    /* Corporate Colors - Professional */
    --corporate-red: #990F0C;
    --corporate-red-hover: #b51310;
    --corporate-red-light: rgba(153, 15, 12, 0.1);

    /* Professional Gray Scale */
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-400: #bdbdbd;
    --gray-500: #9e9e9e;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;
    --gray-900: #212121;

    /* Backgrounds - Balanced Palette */
    --bg-white: #ffffff;
    --bg-light: #f5f5f5;
    --bg-gray: #ececec;
    --bg-medium: #e4e4e4;
    --bg-sidebar: #1a1a1a;
    --bg-dark: #0f0f0f;

    /* Text - Professional Hierarchy */
    --text-primary: #212121;
    --text-secondary: #616161;
    --text-tertiary: #9e9e9e;
    --text-inverse: #ffffff;

    /* Borders & Dividers */
    --border-light: #eeeeee;
    --border-medium: #e0e0e0;
    --border-dark: #bdbdbd;

    /* Shadows - Soft & Premium SaaS Feel */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 18px 28px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 25px 40px -8px rgba(0, 0, 0, 0.1), 0 12px 15px -8px rgba(0, 0, 0, 0.05);

    /* Spacing - Generous & Balanced */
    --spacing-xs: 0.5rem;
    --spacing-sm: 0.75rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    --spacing-3xl: 4rem;
    --spacing-4xl: 6rem;

    /* Typography Scale */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    --text-5xl: 3rem;

    /* Border Radius - Modern / Rounded */
    --radius-none: 0;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Transitions - Smooth */
    --transition: all 0.2s ease;
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-white);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Outfit', 'Inter', sans-serif;
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-primary);
    letter-spacing: -0.015em;
}

/* Header - Clean & Professional */
.main-header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-light);
    height: 72px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-xs);
}

.header-content {
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1920px;
    margin: 0 auto;
    padding: 0 var(--spacing-2xl);
}

.logo-section {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.logo-icon {
    width: 42px;
    height: 42px;
    background: var(--corporate-red);
    color: var(--text-inverse);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-text h1 {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.01em;
}

.logo-text p {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-weight: 400;
    font-family: 'Inter', sans-serif;
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.date-display {
    background: var(--bg-gray);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-weight: 500;
    border: 1px solid var(--border-light);
}

.btn-icon {
    width: 40px;
    height: 40px;
    background: var(--bg-white);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--bg-gray);
    border-color: var(--border-dark);
    color: var(--text-primary);
}

/* Main Container */
.main-container {
    display: flex;
    max-width: 1920px;
    margin: 0 auto;
    min-height: calc(100vh - 72px);
}

/* Sidebar - Professional Dark */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--gray-800);
    padding: var(--spacing-xl) 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: sticky;
    top: 72px;
    height: calc(100vh - 72px);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-x: hidden;
    z-index: 100;
}

.sidebar.collapsed {
    width: 76px;
}

.sidebar.collapsed .version-info,
.sidebar.collapsed .nav-item span {
    display: none;
    opacity: 0;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: var(--spacing-md);
    margin: 0.2rem 0.5rem;
}

.sidebar.collapsed .nav-icon {
    margin: 0;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0 var(--spacing-md);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-md);
    color: var(--gray-400);
    text-decoration: none;
    font-weight: 500;
    font-size: var(--text-sm);
    transition: var(--transition);
    font-family: 'Inter', sans-serif;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-inverse);
}

.nav-item.active {
    background: var(--corporate-red);
    color: var(--text-inverse);
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: var(--spacing-md);
    text-align: center;
    border-top: 1px solid var(--gray-800);
}

/* Hide legacy profile elements in sidebar */
.sidebar-footer .user-profile,
.sidebar-footer #userProfile,
.sidebar-footer .user-info {
    display: none !important;
}

.version-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.version-info small {
    color: var(--gray-600);
    font-size: var(--text-xs);
}

/* Main Content - Sophisticated Gradient Background */
.main-content {
    flex: 1;
    background: linear-gradient(180deg, #e8e8e8 0%, #f0f0f0 100%);
    padding: var(--spacing-3xl) var(--spacing-2xl);
    overflow-y: auto;
}

.module {
    display: none;
}

.module.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

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

.module-header {
    margin-bottom: var(--spacing-3xl);
    max-width: 1400px;
}

.module-header h2 {
    font-size: var(--text-4xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.025em;
}

.module-description {
    font-size: var(--text-lg);
    color: var(--text-secondary);
    font-weight: 400;
    max-width: 600px;
}

/* Stats Grid - Premium Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-2xl);
    max-width: 1400px;
}

.stat-card {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    transition: var(--transition);
    box-shadow: var(--shadow-xs);
}

.stat-card:hover {
    border-color: var(--corporate-red);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 56px;
    height: 56px;
    background: var(--corporate-red-light);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 28px;
    height: 28px;
    color: var(--corporate-red);
}

.stat-content {
    flex: 1;
}

.stat-content h3 {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-family: 'Inter', sans-serif;
}

.stat-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-family: 'Outfit', sans-serif;
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

/* Charts - Clean & Professional */
.charts-grid,
.reportes-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: var(--spacing-lg);
    max-width: 1400px;
    margin-bottom: var(--spacing-2xl);
}

.chart-card {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-xs);
    display: flex;
    flex-direction: column;
}

.chart-card h3 {
    font-size: var(--text-base);
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-card canvas {
    max-height: 250px !important;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 100px;
    right: var(--spacing-xl);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.toast {
    background: var(--bg-white);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg) var(--spacing-xl);
    box-shadow: var(--shadow-lg);
    min-width: 320px;
    animation: slideIn 0.3s ease;
}

.toast.success {
    border-left: 4px solid #4caf50;
}

.toast.error {
    border-left: 4px solid var(--corporate-red);
}

.toast.info {
    border-left: 4px solid #2196f3;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 1200px) {
    .main-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        top: 0;
        border-right: none;
        border-bottom: 1px solid var(--gray-800);
    }

    .nav-menu {
        flex-direction: row;
        overflow-x: auto;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: var(--spacing-xl);
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .module-header h2 {
        font-size: var(--text-3xl);
    }
}

/* User Menu Panel - Premium Floating Design */
.user-menu-panel {
    position: fixed;
    background: var(--bg-white);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 280px;
    z-index: 2000;
    overflow: hidden;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

.user-menu-header {
    background: var(--bg-gray);
    padding: var(--spacing-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    border-bottom: 1px solid var(--border-light);
}

.user-avatar {
    width: 48px;
    height: 48px;
    background: var(--corporate-red);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-info strong {
    font-size: var(--text-base);
    color: var(--text-primary);
}

.user-role-badge {
    font-size: var(--text-xs);
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
    width: fit-content;
    margin-top: 4px;
}

.role-superadmin {
    background: #fee2e2;
    color: #991b1b;
}

.role-operario {
    background: #dcfce7;
    color: #166534;
}

.user-menu-body {
    padding: var(--spacing-md);
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.user-menu-footer {
    padding: var(--spacing-md);
    background: var(--gray-50);
    border-top: 1px solid var(--border-light);
}

.btn-logout {
    background: var(--corporate-red);
    color: white;
    border: none;
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
    width: 100%;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: var(--text-sm);
}

.btn-logout:hover {
    background: var(--corporate-red-hover);
    box-shadow: var(--shadow-md);
}

/* ==============================================================
   UI KITS: Buttons, Inputs, Tables, Badges (Added in UI/UX Update)
   ============================================================== */

/* --- Forms & Inputs --- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem 1.5rem;
}

.full-width {
    grid-column: 1 / -1;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: var(--spacing-md);
}

.form-group label {
    font-weight: 500;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: var(--text-base);
    color: var(--text-primary);
    background-color: var(--bg-white);
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02) inset;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--corporate-red);
    box-shadow: 0 0 0 3px var(--corporate-red-light);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

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

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--corporate-red) 0%, #b51310 100%);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(153, 15, 12, 0.2), 0 2px 4px -1px rgba(153, 15, 12, 0.1);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #a8100d 0%, #ca1411 100%);
    box-shadow: 0 6px 10px -1px rgba(153, 15, 12, 0.3), 0 2px 4px -1px rgba(153, 15, 12, 0.2);
}

.btn-secondary {
    background: var(--bg-white);
    color: var(--text-secondary);
    border: 1px solid var(--border-dark);
}

.btn-secondary:hover {
    background: var(--bg-gray);
    color: var(--text-primary);
    border-color: var(--text-tertiary);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.2);
}

.btn-success:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: 0 6px 10px -1px rgba(16, 185, 129, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 6px 10px -1px rgba(239, 68, 68, 0.3);
}

/* --- Data Tables --- */
.table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    background: var(--bg-white);
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: left;
}

.data-table th, .data-table td {
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    font-size: var(--text-sm);
}

.data-table th {
    background: var(--bg-gray);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.75rem;
    border-bottom: 2px solid var(--border-medium);
}

.data-table tbody tr {
    transition: background-color 0.15s ease;
}

.data-table tbody tr:hover {
    background-color: rgba(153, 15, 12, 0.02);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* --- Badges & Progress --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
}

.code-badge {
    background-color: var(--corporate-red-light);
    color: var(--corporate-red);
    padding: 3px 8px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.8em;
    font-weight: 600;
    border: 1px solid rgba(153, 15, 12, 0.2);
}

.progress-bar-mini {
    width: 60px;
    height: 6px;
    background-color: var(--bg-gray);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill-mini {
    height: 100%;
    background-color: var(--corporate-red);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Clean Cards */
.form-card {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--spacing-2xl);
    box-shadow: var(--shadow-sm);
}