:root {
    /* Colors */
    --bg-body: #0a0a0f;
    --bg-card: rgba(30, 30, 40, 0.6);
    --bg-sidebar: rgba(20, 20, 25, 0.95);
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #10b981;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --border-color: rgba(255, 255, 255, 0.1);
    --danger-color: #ef4444;
    --warning-color: #f59e0b;

    /* Effects */
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --backdrop-blur: blur(10px);

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 70px;
    --border-radius: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-body);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    background-image:
        radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.15) 0%, transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.15) 0%, transparent 25%);
    min-height: 100vh;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: #fff;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
}

a {
    text-decoration: none;
    color: var(--primary-color);
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-hover);
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border: var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: var(--border-radius);
}

/* Layout Wrapper */
.wrapper {
    display: flex;
    min-height: 100vh;
}

/* Main Content - Adjusted for hidden sidebar by default */
.main-content {
    margin-left: 0;
    width: 100%;
    padding: var(--spacing-lg);
    padding-top: calc(var(--header-height) + var(--spacing-lg));
    transition: margin-left 0.3s ease;
}

/* Sidebar - Hidden by default on ALL screens */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    border-right: var(--glass-border);
    backdrop-filter: blur(20px);
    transition: transform 0.3s ease;
    transform: translateX(-100%);
    /* ALWAYS hidden initially */
    box-shadow: 5px 0 20px rgba(0, 0, 0, 0.5);
    /* Shadow for when active */
}

.sidebar.active {
    transform: translateX(0);
}

/* Header - Full width by default */
.top-header {
    height: var(--header-height);
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    /* Full width */
    background: rgba(10, 10, 15, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: var(--glass-border);
    display: flex;
    align-items: center;
    padding: 0 var(--spacing-lg);
    justify-content: space-between;
    z-index: 90;
    transition: left 0.3s ease;
}

/* Responsive Menu Elements - Always visible now */
.menu-toggle {
    display: block;
    /* Always show toggle */
    font-size: 1.75rem;
    color: var(--text-main);
    cursor: pointer;
    margin-right: 15px;
    transition: color 0.2s;
}

.menu-toggle:hover {
    color: var(--primary-color);
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 95;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(3px);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Marquee Styles */
.marquee-container {
    flex: 1;
    overflow: hidden;
    margin: 0 20px;
    display: flex;
    align-items: center;
}

.marquee-container marquee {
    color: #fff;
    font-weight: 500;
    font-size: 1rem;
    width: 100%;
}

/* Responsive adjustments for Header elements */
@media (max-width: 991px) {
    .marquee-container {
        margin: 0 10px;
        /* Smaller margin on mobile */
    }

    .marquee-container marquee {
        font-size: 0.9rem;
        /* Slightly smaller text on mobile */
    }

    /* Any specific mobile adjustments if needed, but core layout is now universal */
}

/* Cards */
.card {
    background: var(--bg-card);
    border: var(--glass-border);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    backdrop-filter: blur(5px);
}

.stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent 0%, rgba(255, 255, 255, 0.03) 100%);
    pointer-events: none;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    margin: var(--spacing-xs) 0;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Forms */
.form-control {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    color: #fff;
    font-size: 1rem;
    transition: all 0.2s;
    appearance: none;
    /* Helps with consistent styling */
    -webkit-appearance: none;
    -moz-appearance: none;
}

/* Fix for Select Dropdowns */
select.form-control {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
    padding-right: 2.5rem;
    /* Space for the arrow */
}

/* Ensure options have dark background */
select.form-control option {
    background-color: #1e293b;
    /* Dark background matching theme */
    color: #fff;
    /* White text */
}

/* For some browsers that don't respect the above (like older Chrome/Windows UI), force better fallback */
select:-internal-list-box option:checked {
    background-color: var(--primary-color) !important;
    color: #fff !important;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(30, 41, 59, 0.8);
    /* Slightly less transparent on focus */
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

/* Tables */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: var(--spacing-md);
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: var(--spacing-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Responsive */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .top-header {
        left: 0;
    }
}

/* Grid System */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-lg);
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-lg);
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--spacing-lg);
}

/* Icons */
.icon-lg {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-right: var(--spacing-md);
}

/* Utility Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

.text-success {
    color: var(--secondary-color);
}

.text-danger {
    color: var(--danger-color);
}

.text-warning {
    color: var(--warning-color);
}

/* Status Cards & Elements */
.card-total {
    border-left: 4px solid var(--primary-color);
}

.card-vencendo {
    border-left: 4px solid var(--warning-color);
}

.card-vencidos {
    border-left: 4px solid var(--danger-color);
}

.status-vencido {
    background: rgba(239, 68, 68, 0.1) !important;
    border-left: 3px solid var(--danger-color) !important;
}

.status-proximo {
    background: rgba(245, 158, 11, 0.1) !important;
    border-left: 3px solid var(--warning-color) !important;
}

.status-ok {
    background: rgba(16, 185, 129, 0.1) !important;
    border-left: 3px solid var(--secondary-color) !important;
}

.alert {
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border-color: rgba(239, 68, 68, 0.2);
}

/* Responsive Menu Elements */
.menu-toggle {
    display: none;
    font-size: 1.75rem;
    color: var(--text-main);
    cursor: pointer;
    margin-right: 15px;
    transition: color 0.2s;
}

.menu-toggle:hover {
    color: var(--primary-color);
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 95;
    /* Below sidebar (100) but above header (90) - Wait, header is 90. Sidebar is 100. */
    /* We want overlay ABOVE header but BELOW sidebar?
       Actually, on mobile:
       Sidebar (100) > Overlay (95) > Header (90).
       This ensures sidebar slides OVER everything, overlay dims everything else including header.
    */
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(3px);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Improve Sidebar look on mobile & Desktop */
.sidebar {
    width: 280px;
    background: #0f172a;
    /* Solid dark color for better contrast */
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.5);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
}

.sidebar.active {
    transform: translateX(0);
}

.nav-menu {
    list-style: none;
    padding: 10px 15px;
    /* Add padding to container */
    overflow-y: auto;
    flex: 1;
}

.nav-item {
    margin-bottom: 8px;
    /* Spacing between items */
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    /* Separator line */
    padding-bottom: 8px;
}

.nav-item:last-child {
    border-bottom: none;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: 8px;
    color: #cbd5e1;
    /* Light grey text */
    font-weight: 500;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.02);
    /* Subtle card background */
}

.nav-link:hover,
.nav-link.active {
    background: rgba(99, 102, 241, 0.15);
    /* Primary color low opacity */
    color: #fff;
    transform: translateX(5px);
    /* Interaction movement */
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.nav-link i {
    font-size: 1.3rem;
    margin-right: 15px;
    color: var(--primary-color);
    filter: drop-shadow(0 0 5px rgba(99, 102, 241, 0.4));
    /* Glow effect on icons */
}

/* Specific Mobile Adjustments */
@media (max-width: 991px) {
    .menu-toggle {
        display: block;
    }

    .top-header {
        left: 0;
        width: 100%;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }
}