:root {
    /* --- ZINC PALETTE (Premium Dark) --- */
    --bg-app: #09090b;
    /* Zinc 950 */
    --bg-surface: #18181b;
    --border-subtle: #3f3f46;
    /* Zinc 700 - Lighter for visibility */
    /* Zinc 800 */
    --border-strong: #52525b;
    /* Zinc 600 */

    /* --- BRAND ACCENTS --- */
    --brand-primary: #f8fafc;
    /* Zinc 50 (Text) */
    --brand-blue: #38bdf8;
    /* Sky 400 */
    --brand-purple: #c084fc;
    /* Purple 400 */
    --brand-pink: #f472b6;
    /* Pink 400 */

    --gradient-primary: linear-gradient(135deg, #38bdf8 0%, #c084fc 100%);
    --gradient-hover: linear-gradient(135deg, #0ea5e9 0%, #a855f7 100%);
    --gradient-surface: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0) 100%);

    /* --- TEXT --- */
    --text-primary: #ffffff;
    /* Pure White */
    --text-secondary: #e4e4e7;
    /* Zinc 200 - Very Light Gray */
    --text-muted: #a1a1aa;
    /* Zinc 400 */
    --text-on-brand: #000000;

    /* --- METRICS --- */
    --sidebar-width: 280px;
    /* Wider for better hierarchy */
    --header-height: 80px;

    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    --font-heading: 'Aspekta', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-body: 'Mona Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* --- RESET & BASE --- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-app);
    /* Livelier Background - Increased Opacity */
    background-image:
        radial-gradient(circle at 10% 20%, rgba(56, 189, 248, 0.15), transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(192, 132, 252, 0.15), transparent 40%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6,
.h1,
.h2,
.h3,
.h4,
.h5,
.h6 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: -0.025em;
    margin-bottom: 0.75em;
}

a {
    color: var(--brand-blue);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--brand-purple);
}

/* --- UTILITIES --- */
.text-primary {
    color: var(--text-primary) !important;
}

.text-secondary {
    color: var(--text-secondary) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.bg-surface {
    background-color: var(--bg-surface) !important;
}

.bg-app {
    background-color: var(--bg-app) !important;
}

.bg-surface-hover {
    background-color: var(--bg-surface-hover) !important;
}

.text-main {
    color: var(--text-primary) !important;
}

.hover-text-main:hover {
    color: var(--text-primary) !important;
}

.border {
    border-color: var(--border-subtle) !important;
}

.border-top {
    border-top-color: var(--border-subtle) !important;
}

.border-bottom {
    border-bottom-color: var(--border-subtle) !important;
}

.rounded-3 {
    border-radius: var(--radius-md) !important;
}

.rounded-4 {
    border-radius: var(--radius-lg) !important;
}

.shadow-sm {
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
}

.shadow {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
}

.shadow-lg {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
}

/* Custom Gradient Text */
.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

.bg-gradient-primary {
    background: var(--gradient-primary) !important;
}

.text-xs {
    font-size: 0.75rem !important;
}

.text-sm {
    font-size: 0.875rem !important;
}

/* --- COMPONENTS: CARDS --- */
.card {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    /* Force text color */
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-subtle);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    margin-bottom: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    /* Force text color */
    letter-spacing: -0.01em;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    background-color: transparent;
    border-top: 1px solid var(--border-subtle);
    padding: 1rem 1.5rem;
}

/* --- COMPONENTS: BUTTONS --- */
.btn {
    font-weight: 500;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--gradient-primary);
    color: var(--text-on-brand);
    border: none;
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.25);
}

.btn-primary:hover {
    background: var(--gradient-hover);
    box-shadow: 0 6px 16px rgba(56, 189, 248, 0.35);
    transform: translateY(-1px);
    color: var(--text-on-brand);
}

.btn-secondary,
.btn-white {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
    border-color: var(--border-subtle);
}

.btn-secondary:hover,
.btn-white:hover {
    background: var(--border-subtle);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.btn-outline-secondary {
    background: transparent;
    border-color: var(--border-subtle);
    color: var(--text-secondary);
}

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

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-color: transparent;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* --- COMPONENTS: FORMS --- */
.form-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-control,
.form-select {
    background-color: var(--bg-app);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    transition: all 0.2s ease;
}

.form-control:disabled,
.form-control[readonly] {
    background-color: var(--bg-surface-hover);
    color: var(--text-muted);
    opacity: 0.7;
    border-color: var(--border-subtle);
}

.form-control:focus,
.form-select:focus {
    background-color: var(--bg-app);
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
    color: var(--text-primary);
    outline: none;
}

.form-control::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

/* --- COMPONENTS: TABLES (Clean) --- */
.table {
    --bs-table-bg: transparent;
    margin-bottom: 0;
}

.table thead th {
    background-color: rgba(255, 255, 255, 0.02);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.85rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    border-top: none;
}

.table tbody td {
    padding: 1rem 1.5rem;
    vertical-align: middle;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    background-color: transparent;
    font-size: 0.9rem;
}

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

.table-hover tbody tr:hover td {
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

/* --- COMPONENTS: SIDEBAR (Premium) --- */
.sidebar {
    width: var(--sidebar-width) !important;
    min-width: var(--sidebar-width) !important;
    max-width: var(--sidebar-width) !important;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    background-color: rgba(9, 9, 11, 0.98);
    /* Deep Zinc with slight transparency */
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    box-sizing: border-box;
    backdrop-filter: blur(10px);
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.02), transparent);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.75rem;
    /* Horizontal padding for floating items */
}

/* Scrollbar polish */
.sidebar-content::-webkit-scrollbar {
    width: 4px;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 4px;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    color: var(--text-secondary);
    font-weight: 500;
    border: 1px solid transparent;
    /* Replaces border-left */
    border-radius: var(--radius-sm);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 2px;
    font-size: 0.9rem;
}

.sidebar .nav-link i {
    font-size: 1.1rem;
    color: var(--text-muted);
    transition: color 0.2s;
}

.sidebar .nav-link:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.05);
    transform: translateX(2px);
}

.sidebar .nav-link:hover i {
    color: var(--brand-blue);
}

.sidebar .nav-link.active {
    color: var(--text-primary);
    background: rgba(56, 189, 248, 0.1);
    /* Low opacity brand blue */
    border-color: rgba(56, 189, 248, 0.2);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.sidebar .nav-link.active i {
    color: var(--brand-blue);
}

.sidebar .section-label {
    padding: 1.5rem 1rem 0.5rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 700;
    pointer-events: none;
}

/* --- LAYOUT: MAIN --- */
.main-content {
    margin-left: var(--sidebar-width) !important;
    padding: 2.5rem;
    min-height: 100vh;
    background-color: transparent;
    /* Transparent to show body mesh */
}

/* --- COMPONENTS: BADGES --- */
.badge {
    padding: 0.35em 0.8em;
    font-weight: 600;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    letter-spacing: 0.02em;
}

/* Subtle Badges (Pinterest/Modern style) */
.badge.bg-primary {
    background: rgba(56, 189, 248, 0.15) !important;
    color: #38bdf8 !important;
}

.badge.bg-success {
    background: rgba(34, 197, 94, 0.15) !important;
    color: #4ade80 !important;
}

.badge.bg-warning {
    background: rgba(234, 179, 8, 0.15) !important;
    color: #facc15 !important;
}

.badge.bg-danger {
    background: rgba(239, 68, 68, 0.15) !important;
    color: #f87171 !important;
}

.badge.bg-info {
    background: rgba(168, 85, 247, 0.15) !important;
    color: #c084fc !important;
}

.badge.bg-secondary {
    background: var(--bg-surface-hover) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-subtle);
}

/* --- COMPONENTS: MODALS (Glass) --- */
.modal-content {
    background-color: rgba(24, 24, 27, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    /* More rounded */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(16px);
}

.modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 1.25rem 1.5rem;
}

.modal-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding: 1.25rem 1.5rem;
    background: rgba(0, 0, 0, 0.2);
}

.btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
    opacity: 0.5;
    transition: opacity 0.2s;
}

.btn-close:hover {
    opacity: 1;
}

/* Dropdown Menu Fix */
.dropdown-menu {
    background-color: #18181b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-radius: var(--radius-md);
    padding: 0.5rem;
}

.dropdown-item {
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.dropdown-divider {
    border-top-color: rgba(255, 255, 255, 0.05);
    margin: 0.5rem 0;
}

/* --- COMPONENTS: ALERTS --- */
.alert {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    border-radius: var(--radius-md);
}

.alert-info {
    border-left: 4px solid var(--brand-blue);
}

.alert-success {
    border-left: 4px solid #22c55e;
}

.alert-warning {
    border-left: 4px solid #eab308;
}

.alert-danger {
    border-left: 4px solid #ef4444;
}

/* --- OVERRIDES & HELPERS --- */
.bg-light,
.bg-white {
    background-color: var(--bg-surface) !important;
}

.text-dark {
    color: var(--text-primary) !important;
}

.btn-light {
    border-color: var(--border-subtle);
    color: var(--text-secondary);
    background: transparent;
}

/* Dashboard Specifics */
.stat-card-clean {
    position: relative;
    padding: 1.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stat-card-clean .icon-box {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 1rem;
    background: var(--bg-surface-hover);
    color: var(--text-secondary);
}

.stat-card-clean .value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.stat-card-clean .label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* --- MOBILE SIDEBAR TOGGLE --- */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1050;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

.sidebar-toggle:hover {
    background: var(--bg-surface-hover);
    border-color: var(--brand-blue);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1035;
    backdrop-filter: blur(4px);
}

/* --- RESPONSIVE: TABLET & MOBILE --- */
@media (max-width: 992px) {
    .sidebar-toggle {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .sidebar-overlay {
        display: block;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 1.5rem;
        padding-top: 4.5rem;
        /* Space for hamburger button */
    }

    /* Responsive tables */
    .table-responsive-auto {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .card-body {
        padding: 1rem;
    }

    /* Stack form rows */
    .row .col-md-6,
    .row .col-md-4,
    .row .col-md-3 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

@media (max-width: 576px) {
    .main-content {
        padding: 1rem;
        padding-top: 4rem;
    }

    h1,
    .h1,
    .h3 {
        font-size: 1.25rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }

    .d-flex.justify-content-between {
        flex-direction: column;
        gap: 0.75rem;
    }

    /* Make modals full-width on mobile */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
}