:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.4);
    --bg-dark: #020617;
    /* Darker Slate */
    --radius-sm: 10px;
    --radius-lg: 20px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --text-main: #f8fafc;
    --text-highlight: #ffffff;
}

/* Global Readability Overrides */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
}

.fallback-bg {
    background: radial-gradient(circle at 50% 50%, #1e1b4b 0%, #020617 100%);
}

/* Typography Overrides for Dark Mode */
h1,
h2,
h3,
h4,
h5,
h6,
b,
strong,
.fw-bold {
    color: var(--text-highlight) !important;
}

p,
span,
label,
td,
th {
    color: var(--text-main);
}

.text-muted,
.text-light-emphasis {
    color: rgba(255, 255, 255, 0.6) !important;
}

/* Card Styling */
.card {
    background: rgba(30, 41, 59, 0.45) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4) !important;
    transition: var(--transition);
}

.card:hover {
    border-color: rgba(99, 102, 241, 0.25) !important;
    transform: translateY(-4px);
    background: rgba(30, 41, 59, 0.55) !important;
}

/* Sidebar Refinement */
.sidebar-container {
    background: #020617 !important;
    border-right: 1px solid rgba(255, 255, 255, 0.05) !important;
}

.sidebar-container .nav-link {
    border-radius: var(--radius-sm) !important;
    margin: 4px 16px !important;
    padding: 12px 18px !important;
    color: rgba(255, 255, 255, 0.7) !important;
    font-weight: 500 !important;
    transition: var(--transition) !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    border: 1px solid transparent !important;
}

.sidebar-container .nav-link:hover {
    background: rgba(255, 255, 255, 0.05) !important;
    color: #ffffff !important;
}

.sidebar-container .nav-link.active {
    background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%) !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    box-shadow: 0 4px 15px var(--primary-glow) !important;
}

.sidebar-container .nav-link.active i {
    color: #ffffff !important;
}

/* Stat Box Icons */
.stat-icon-box {
    width: 48px;
    height: 48px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--primary);
}

/* Button Refinement */
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #4338ca 100%) !important;
    border: none !important;
    padding: 10px 24px !important;
    border-radius: var(--radius-sm) !important;
    font-weight: 600 !important;
    box-shadow: 0 4px 15px var(--primary-glow) !important;
    transition: var(--transition) !important;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 25px var(--primary-glow) !important;
}

/* Table Design */
.table {
    color: var(--text-main) !important;
    border-color: rgba(255, 255, 255, 0.05) !important;
    background-color: transparent !important;
}

.table thead th {
    background: transparent !important;
    color: rgba(255, 255, 255, 0.4) !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    padding: 20px !important;
    border: none !important;
}

.table tbody td {
    background-color: transparent !important;
    padding: 18px 20px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03) !important;
    color: var(--text-main) !important;
}

.table-hover tbody tr:hover {
    background: rgba(255, 255, 255, 0.03) !important;
}

/* Form Controls */
.form-control,
.form-select {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
    border-radius: var(--radius-sm) !important;
    padding: 12px 16px !important;
}

.form-control:focus,
.form-select:focus {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1) !important;
}

.form-control::placeholder {
    color: rgba(255, 255, 255, 0.3) !important;
}

/* Fix for native select options and date inputs in dark mode */
select option {
    background-color: #0f172a !important;
    /* Deep Slate */
    color: #ffffff !important;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    opacity: 0.6;
    cursor: pointer;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* Badge Styling */
.badge-outline-primary {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    border: 1px solid rgba(99, 102, 241, 0.3);
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 600;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Aggressive Tom Select Dark Theme Overrides */
.ts-wrapper.single .ts-control,
.ts-wrapper.single.input-active .ts-control {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
    border-radius: var(--radius-sm) !important;
    padding: 12px 16px !important;
    box-shadow: none !important;
}

.ts-wrapper.single.input-active .ts-control {
    border-color: var(--primary) !important;
}

.ts-control input {
    color: #ffffff !important;
    background: transparent !important;
}

.ts-dropdown {
    background: #0f172a !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: var(--radius-sm) !important;
    color: #ffffff !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8) !important;
}

.ts-dropdown .option {
    background: transparent !important;
    color: #ffffff !important;
    padding: 10px 16px !important;
}

.ts-dropdown .active {
    background: var(--primary) !important;
    color: #ffffff !important;
}

/* Fix for the white highlight box in dropdown */
.ts-dropdown .option.selected,
.ts-dropdown .option.active {
    background-color: var(--primary) !important;
    color: #ffffff !important;
}

.ts-control .item {
    color: #ffffff !important;
}

/* Force dark bg on the search input itself inside TS */
.ts-wrapper.single .ts-control input {
    background: transparent !important;
    color: #ffffff !important;
}