:root {
    /* Base Themes: Dark (Default) */
    --bg-main: #0b0f19;
    --bg-sidebar: #131b2e;
    --bg-card: #131b2e;
    --bg-input: #0b0f19;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.08);
    --glass: rgba(255, 255, 255, 0.03);
    
    /* Semantic Colors */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #10b981;
    --danger: #ef4444;
    
    /* Shadows & Radii */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

/* Light Theme Overrides */
[data-theme="light"] {
    --bg-main: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #f1f5f9;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: rgba(0, 0, 0, 0.08);
    --glass: rgba(0, 0, 0, 0.02);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    padding: 1.5rem;
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 2.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    letter-spacing: -0.025em;
}

.nav-links {
    list-style: none;
    flex-grow: 1;
}

.nav-links li {
    margin-bottom: 0.375rem;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    font-weight: 500;
    font-size: 0.9375rem;
    transition: all 0.2s ease;
}

.nav-links a:hover {
    background-color: var(--glass);
    color: var(--text-main);
}

.nav-links a.active {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

/* Main Content */
.main-content {
    margin-left: 260px;
    flex-grow: 1;
    padding: 2.5rem;
    width: calc(100% - 260px);
    transition: padding 0.3s ease, margin-left 0.3s ease;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    gap: 1rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

h1 {
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

/* Theme & Menu Toggles */
.icon-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    width: 42px;
    height: 42px;
    border-radius: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

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

.sidebar-toggle {
    display: none;
}

/* Dashboard Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.stat-card h3 {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-card .value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.stat-card.profit .value { color: var(--secondary); }
.stat-card.stock .value { color: var(--primary); }

/* Table Container */
.content-card {
    background: var(--bg-card);
    padding: 1.75rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

/* DataTables themed */
.dataTables_wrapper { 
    color: var(--text-main); 
    font-size: 0.9rem;
}

.dataTables_length select { 
    background: var(--bg-input); 
    color: var(--text-main); 
    border: 1px solid var(--border); 
    border-radius: 0.375rem;
    padding: 0.375rem 0.5rem;
    outline: none;
}

table.dataTable {
    margin: 1.25rem 0 !important;
    border-collapse: collapse !important;
    width: 100% !important;
}

table.dataTable thead th {
    background-color: var(--glass);
    color: var(--text-muted) !important;
    border-bottom: 2px solid var(--border) !important;
    padding: 0.875rem 1rem !important;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

table.dataTable tbody td {
    padding: 1rem !important;
    border-bottom: 1px solid var(--border) !important;
    color: var(--text-main);
    vertical-align: middle;
}

table.dataTable tbody tr {
    transition: background-color 0.2s ease;
}

table.dataTable tbody tr:hover {
    background-color: var(--glass) !important;
}

.dataTables_filter input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s ease;
}

.dataTables_filter input:focus {
    border-color: var(--primary);
}

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9375rem;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary { 
    background-color: var(--primary); 
    color: white; 
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.2);
}

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

.btn-secondary { 
    background: var(--glass); 
    color: var(--text-main); 
    border: 1px solid var(--border); 
}

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

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--bg-card);
    padding: 2.25rem;
    border-radius: 1.25rem;
    width: 90%;
    max-width: 600px;
    border: 1px solid var(--border);
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: scaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.form-control {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    color: var(--text-main);
    outline: none;
    font-size: 0.9375rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus { 
    border-color: var(--primary); 
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    z-index: 999;
    transition: opacity 0.3s ease;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleUp {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Responsive Media Queries */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 1.25rem;
    }
    
    .sidebar-toggle {
        display: flex;
    }
    
    .header-top {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 1.75rem;
    }
    
    .header-actions {
        width: 100%;
        justify-content: space-between;
        margin-top: 0.75rem;
    }
    
    .user-info {
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    h1 { font-size: 1.5rem; }
    .stats-grid { grid-template-columns: 1fr; }
    .content-card { padding: 1rem; }
}