:root {
    /* Colors */
    --color-bg: #020617;
    --color-surface: #0f172a;
    --color-surface-hover: #1e293b;
    --color-primary: #3b82f6;
    --color-secondary: #e11d48;
    /* Alarm Red */
    --color-accent: #06b6d4;
    --color-text-main: #f1f5f9;
    --color-text-muted: #94a3b8;
    --color-border: #1e293b;
    --color-success: #22c55e;
    --color-warning: #eab308;
    --color-danger: #ef4444;

    --z-sidebar: 1000;
    --z-modal: 2000;

    /* Typography */
    --font-main: 'Inter', sans-serif;

    /* Spacing */
    --sidebar-width: 260px;
    --header-height: 70px;
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 2rem;
    --spacing-lg: 4rem;

    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.05);
    --shadow-glow: 0 0 15px rgba(59, 130, 246, 0.5);
    --shadow-glow-red: 0 0 15px rgba(225, 29, 72, 0.5);

    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --radius-full: 9999px;

    /* Custom Scrollbar */
    --scrollbar-width: 10px;
    --scrollbar-track: #0f172a;
    --scrollbar-thumb: #1e293b;
    --scrollbar-thumb-hover: #334155;
}

/* Custom Scrollbar Styles */
::-webkit-scrollbar {
    width: var(--scrollbar-width);
    height: var(--scrollbar-width);
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--radius-full);
    border: 2px solid var(--scrollbar-track);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--color-bg);
    color: var(--color-text-main);
    font-family: var(--font-main);
    line-height: 1.6;
    overflow: hidden;
    /* App-like feel */
    height: 100vh;
    display: flex;
}

.mobile-only {
    display: none !important;
}

.desktop-only {
    display: initial;
}

/* Utilities */
.text-gradient {
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.text-danger {
    color: var(--color-danger);
}

.text-warning {
    color: var(--color-warning);
}

.text-success {
    color: var(--color-success);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-size: 0.9rem;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    color: white;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.5);
}

.btn-danger {
    background: linear-gradient(135deg, var(--color-secondary), #ef4444);
    color: white;
    box-shadow: 0 2px 10px rgba(225, 29, 72, 0.3);
}

.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(225, 29, 72, 0.5);
}

.btn-warning {
    background: linear-gradient(135deg, #fbbf24, #d97706);
    color: white;
    box-shadow: 0 2px 10px rgba(251, 191, 36, 0.3);
}

.btn-warning:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(251, 191, 36, 0.5);
}


.btn-icon {
    padding: 0.5rem;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--color-text-muted);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    width: 34px;
    height: 34px;
}

.btn-icon:hover {
    background: var(--color-surface-hover);
    color: white;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

/* Layout */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    z-index: 20;
}

.logo-area {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 1.25rem;
    font-weight: 800;
}

.logo-area i {
    margin-right: 0.5rem;
    color: var(--color-text-main);
}

.nav-menu {
    flex: 1;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--color-text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.2s;
    font-weight: 500;
}

.nav-item i {
    width: 24px;
    margin-right: 0.75rem;
    text-align: center;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--color-primary);
}

.nav-item.active {
    background: rgba(59, 130, 246, 0.15);
    font-weight: 600;
}

.nav-item.danger-zone {
    margin-top: auto;
    color: var(--color-danger);
}

.nav-item.danger-zone:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    background: radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(225, 29, 72, 0.05) 0%, transparent 40%);
}

.top-bar {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    border-bottom: 1px solid var(--color-border);
    background: rgba(2, 6, 23, 0.8);
    backdrop-filter: blur(8px);
}

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    padding: 0.25rem 0.75rem;
    background: rgba(34, 197, 94, 0.1);
    color: var(--color-success);
    border-radius: var(--radius-full);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: currentColor;
    border-radius: 50%;
    box-shadow: 0 0 5px currentColor;
}

/* Content Area */
.content-area {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

/* Modules */
.module {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.module.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    backdrop-filter: blur(5px);
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

th {
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Inputs */
input,
select {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--color-primary);
}

/* Modern Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 2rem;
    gap: 2rem;
}

.tab-link {
    padding: 1rem 0;
    color: var(--color-text-muted);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tab-link:hover {
    color: var(--color-text-main);
}

.tab-link.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    vertical-align: middle;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--color-surface-hover);
    transition: .4s;
    border-radius: 34px;
    border: 1px solid var(--color-border);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.slider_dash_bells {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--color-surface-hover);
    transition: .4s;
    border-radius: 34px;
    border: 1px solid var(--color-border);
}

.slider_dash_bells:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 5px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider_dash_bells {
    background-color: var(--color-success);
    border-color: var(--color-success);
}

input:checked+.slider_dash_bells:before {
    transform: translateX(18px);
}

input:checked+.slider {
    background-color: var(--color-success);
    border-color: var(--color-success);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--color-success);
}

input:checked+.slider:before {
    transform: translateX(24px);
}

/* Badge */
.badge {
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--color-surface-hover);
    color: var(--color-text-main);
    display: inline-block;
}

@media (max-width: 768px) {
    .mobile-only {
        display: flex !important;
    }

    .desktop-only {
        display: none !important;
    }

    /* Sidebar Mobile Overlay */
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        width: 280px;
        transition: 0.3s ease;
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
        z-index: var(--z-sidebar);
    }

    .sidebar.active {
        left: 0;
    }

    .top-bar-mobile-toggle {
        display: flex !important;
        align-items: center;
        gap: 1rem;
    }

    .nav-menu {
        flex-direction: column;
        padding: 1.5rem 1rem;
    }

    .nav-item {
        flex-direction: row;
        padding: 0.8rem 1rem;
        font-size: 0.95rem;
        gap: 0.75rem;
    }

    .nav-text {
        display: block;
    }

    .main-content {
        height: 100vh;
        width: 100%;
    }

    .content-area {
        padding: 1rem;
    }

    /* Grids Stacking */
    .grid-stack-mobile {
        grid-template-columns: 1fr !important;
    }

    /* Smaller spacing on cards */
    .card {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    /* Tables horizontal scroll */
    .table-container {
        margin: 0 -1rem;
        width: calc(100% + 2rem);
        padding: 0 1rem;
    }

    /* Mobile specific adjustments */
    body {
        overflow: auto;
        /* Allow scrolling for long lists */
    }

    /* Modal Responsiveness */
    .modal-box {
        padding: 1.5rem 1rem;
    }

    .perm-grid-row {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
        padding-bottom: 1rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .perm-grid-header {
        display: none !important;
    }

    .perm-sub-options {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.toast {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--color-border);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    color: var(--color-text-main);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 400px;
    animation: slideIn 0.3s ease-out;
    font-weight: 500;
}

.toast.success {
    border-left: 4px solid var(--color-success);
}

.toast.error {
    border-left: 4px solid var(--color-danger);
}

.toast.info {
    border-left: 4px solid var(--color-primary);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Custom Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 0;
    overflow-y: auto;
    animation: fadeIn 0.2s ease-out;
}

.modal-box {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.2s ease-out;
    margin: auto 0;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--color-text-main);
}

.modal-message {
    color: var(--color-text-muted);
    margin-bottom: 2rem;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Tab Buttons (Sub-tabs) */
.tabs-nav {
    display: flex;
    gap: 1rem;
    background: rgba(15, 23, 42, 0.6);
    padding: 0.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    width: fit-content;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 0.6rem 1.2rem;
    color: var(--color-text-muted);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    font-family: var(--font-main);
}

.tab-btn:hover {
    color: var(--color-text-main);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    background: var(--color-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}