:root {
    /* --- Premium Color Palette (Dark Theme Base) --- */
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-glass: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-primary: #3b82f6;
    /* Blue */
    --accent-secondary: #8b5cf6;
    /* Violet */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    /* --- Glassmorphism --- */
    --glass-blur: blur(12px);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --shadow-premium: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);

    /* --- Layout --- */
    --sidebar-width: 260px;
    --header-height: 70px;
    --radius: 12px;

    /* --- Theme Transition --- */
    --theme-transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* --- Light Theme --- */
.theme-light {
    --bg-dark: #f1f5f9;
    --bg-card: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.9);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --glass-border: 1px solid rgba(0, 0, 0, 0.1);
    --shadow-premium: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

/* --- Base --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* --- Layout Structure --- */
.app-container {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
    padding-top: calc(var(--header-height) + 2rem);
    transition: margin-left 0.3s ease;
    /* Prevent flex items from overflowing horizontally */
    min-width: 0;
    overflow-x: hidden;
}

/* --- Components: Sidebar (Moved from inline) --- */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: var(--glass-border);
    z-index: 200;
    padding: 2rem;
    overflow-y: auto;
    transition: width 0.3s ease;
}

.brand {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0;
    margin: 0;
}

.nav-item>a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all 0.2s;
    font-weight: 500;
}

.nav-item>a:hover,
.nav-item>a.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.1), transparent);
    color: var(--accent-primary);
    box-shadow: -2px 0 0 0 var(--accent-primary);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.nav-section {
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    opacity: 0.7;
    padding-left: 1rem;
}

.nav-submenu {
    list-style: none;
    padding-left: 1rem;
    margin-top: 0.25rem;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-submenu.open {
    max-height: 500px;
    /* Arbitrary large number for transition */
}

.nav-submenu li a {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: all 0.2s;
    opacity: 0.8;
}

.nav-submenu li a:hover,
.nav-submenu li a.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
    opacity: 1;
}

.chevron {
    margin-left: auto;
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.chevron.rotated {
    transform: rotate(180deg);
}

/* --- Components: Cards --- */
.glass-card {
    background: var(--bg-glass);
    backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-premium);
    margin-bottom: 1.5rem;
}

/* --- Components: Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
    gap: 0.5rem;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

/* --- Components: Forms --- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.5);
    border: var(--glass-border);
    border-radius: var(--radius);
    color: var(--text-primary);
    transition: border-color 0.2s, background-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: rgba(15, 23, 42, 0.8);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* --- Utilities --- */
.grid {
    display: grid;
    width: 100%;
}

.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 768px) {

    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }
}

.gap-4 {
    gap: 1rem;
}

.gap-8 {
    gap: 2rem;
}

.hidden {
    display: none !important;
}

.text-gradient {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.text-secondary {
    color: var(--text-secondary) !important;
}

.bg-danger {
    background-color: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.bg-success {
    background-color: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.bg-primary {
    background-color: rgba(59, 130, 246, 0.2);
    color: var(--accent-primary);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
        padding: 1rem;
        padding-top: calc(var(--header-height) + 1rem);
    }

    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-sidebar.show {
        transform: translateX(0);
    }

    .app-sidebar.show {
        transform: translateX(0);
    }
}

/* --- Premium Scrollbars (Webkit) --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    transition: background 0.3s;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* --- Responsive Table Wrapper --- */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    /* Smooth native scrolling on supported devices */
    -webkit-overflow-scrolling: touch;
    /* Ensure scrollbar doesn't overlap content */
    padding-bottom: 0.5rem;
    position: relative;
    /* Optional: custom border on scroll */
}

/* Fix for table cells */
table {
    width: 100%;
    /* Ensure table takes full width of container */
    border-collapse: collapse;
    white-space: nowrap;
    /* Prevent wrapping unless explicitly allowed */
}