:root {
    /* Premium Color Palette (Dark Theme) */
    --bg-dark: #0a0a0f;
    --bg-darker: #050508;
    --surface-glass: rgba(255, 255, 255, 0.03);
    --surface-glass-hover: rgba(255, 255, 255, 0.08);
    --border-glass: rgba(255, 255, 255, 0.05);
    
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-tertiary: #71717a;
    
    --accent-blue: #3b82f6;
    --accent-blue-glow: rgba(59, 130, 246, 0.4);
    --accent-purple: #8b5cf6;
    --accent-purple-glow: rgba(139, 92, 246, 0.4);
    
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    
    /* Layout & Spacing */
    --sidebar-width: 280px;
    --header-height: 80px;
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;
    
    /* Transitions */
    --transition-smooth: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    background-color: var(--bg-darker);
    color: var(--text-primary);
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
}

/* Dynamic Animated Background */
.bg-mesh {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background: 
        radial-gradient(circle at 15% 50%, var(--accent-blue-glow) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, var(--accent-purple-glow) 0%, transparent 50%);
    filter: blur(100px);
    opacity: 0.6;
    animation: mesh-pulse 15s ease-in-out infinite alternate;
}

@keyframes mesh-pulse {
    0% { transform: scale(1) translate(0, 0); }
    50% { transform: scale(1.1) translate(2%, 2%); }
    100% { transform: scale(0.9) translate(-2%, -2%); }
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--surface-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.glass-button {
    background: var(--surface-glass);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.glass-button:hover {
    background: var(--surface-glass-hover);
    border-color: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--accent-blue-glow);
}

.glass-input, .glass-select {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    outline: none;
    transition: var(--transition-fast);
    font-size: 0.95rem;
}

.glass-input:focus, .glass-select:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.glass-select option {
    background: var(--bg-dark);
    color: var(--text-primary);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    padding: 1.5rem;
    border-right: 1px solid var(--border-glass);
    border-radius: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-glass);
    margin-bottom: 2rem;
}

.brand-icon {
    font-size: 1.8rem;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 8px var(--accent-blue-glow));
}

.brand-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: var(--transition-smooth);
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.nav-item i {
    font-size: 1.2rem;
    transition: var(--transition-fast);
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: linear-gradient(to bottom, var(--accent-blue), var(--accent-purple));
    transform: scaleY(0);
    transition: var(--transition-smooth);
    border-radius: 0 4px 4px 0;
}

.nav-item:hover {
    background: var(--surface-glass-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.1), transparent);
    color: var(--text-primary);
}

.nav-item.active::before {
    transform: scaleY(1);
}

.nav-item.active i {
    color: var(--accent-blue);
    text-shadow: 0 0 10px var(--accent-blue-glow);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-glass);
}

.server-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Main Content Area */
.main-wrapper {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-header {
    height: var(--header-height);
    padding: 0 3rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 90;
    background: rgba(10, 10, 15, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-glass);
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.content-area {
    padding: 2.5rem 3rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    animation: fade-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fade-up {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards & Metrics */
.metrics-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.metric-card {
    padding: 1.75rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    transition: var(--transition-smooth);
}

.metric-card:hover {
    transform: translateY(-5px);
    background: var(--surface-glass-hover);
}

.metric-content h4 {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.metric-value {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}

.metric-icon-wrap {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.icon-blue { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.icon-green { background: var(--success-bg); color: var(--success); }
.icon-purple { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }
.icon-red { background: var(--danger-bg); color: var(--danger); }
.icon-yellow { background: var(--warning-bg); color: var(--warning); }

/* Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
}

.modern-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.5rem;
}

.modern-table th {
    text-align: left;
    padding: 1rem 1.5rem;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border-glass);
}

.modern-table tbody tr {
    background: rgba(255, 255, 255, 0.02);
    transition: var(--transition-fast);
}

.modern-table tbody tr:hover {
    background: var(--surface-glass-hover);
    transform: scale(1.005);
}

.modern-table td {
    padding: 1.25rem 1.5rem;
    vertical-align: middle;
    border-top: 1px solid transparent;
    border-bottom: 1px solid transparent;
}

.modern-table td:first-child {
    border-left: 1px solid transparent;
    border-top-left-radius: var(--radius-sm);
    border-bottom-left-radius: var(--radius-sm);
}

.modern-table td:last-child {
    border-right: 1px solid transparent;
    border-top-right-radius: var(--radius-sm);
    border-bottom-right-radius: var(--radius-sm);
}

.modern-table tbody tr:hover td {
    border-color: var(--border-glass);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16,185,129,0.2); }
.badge-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245,158,11,0.2); }
.badge-info { background: rgba(59,130,246,0.1); color: var(--accent-blue); border: 1px solid rgba(59,130,246,0.2); }
.badge-neutral { background: rgba(255,255,255,0.05); color: var(--text-secondary); border: 1px solid rgba(255,255,255,0.1); }

/* Typography Helpers */
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-secondary); }
.text-accent { color: var(--accent-blue); }
.font-mono { font-family: 'JetBrains Mono', 'Courier New', Courier, monospace; }

/* Dashboard Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.chart-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.chart-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.chart-wrapper {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Toolbar (Filters) */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-bar {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 0 1rem;
    flex-grow: 1;
    max-width: 400px;
    transition: var(--transition-fast);
}

.search-bar:focus-within {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.search-bar i {
    color: var(--text-secondary);
}

.search-bar input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    padding: 0.75rem 0.5rem;
    width: 100%;
}

/* Progress bar for critical stock */
.progress-bg {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 1s ease-in-out;
}

/* Responsive */
@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: var(--transition-smooth);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-wrapper {
        margin-left: 0;
    }
    .top-header {
        padding: 0 1.5rem;
    }
    .content-area {
        padding: 1.5rem;
    }
}

/* Print Styles */
@media print {
    body, .app-container, .main-wrapper, .content-area {
        background-color: white !important;
        color: black !important;
    }
    
    .bg-mesh, .sidebar, .toolbar, .glass-button, button, .user-profile {
        display: none !important;
    }
    
    .top-header {
        position: static !important;
        background: transparent !important;
        border-bottom: 1px solid #000 !important;
        padding: 0 !important;
        height: auto !important;
        margin-bottom: 20px !important;
    }
    
    .page-title {
        color: black !important;
        -webkit-text-fill-color: black !important;
        background: none !important;
    }
    
    .main-wrapper {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    
    .content-area {
        padding: 0 !important;
    }
    
    .glass-panel, .metric-card {
        border: 1px solid #ccc !important;
        background: transparent !important;
        backdrop-filter: none !important;
        box-shadow: none !important;
    }
    
    .metric-value, .metric-content h4, .text-primary, .text-secondary {
        color: black !important;
    }
    
    .modern-table {
        width: 100% !important;
        border-collapse: collapse !important;
    }
    
    .modern-table th, .modern-table td {
        border: 1px solid #ddd !important;
        padding: 8px !important;
        color: black !important;
        background: transparent !important;
    }
    
    .modern-table tbody tr {
        background: transparent !important;
    }
    
    .badge {
        border: 1px solid #666 !important;
        color: black !important;
        background: transparent !important;
    }
    
    /* Ensure charts fit if any */
    .chart-wrapper {
        break-inside: avoid;
    }
}
