:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --radius: 0.75rem;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    line-height: 1.5;
}

a {
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.grid {
    display: grid;
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 {
    gap: 0.25rem;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-3 {
    gap: 0.75rem;
}

.gap-4 {
    gap: 1rem;
}

.gap-6 {
    gap: 1.5rem;
}

.hidden {
    display: none;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Navigation specific */
.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.52rem 1rem;
    border-radius: 0.5rem;
    color: #4b5563;
    font-weight: 500;
}

.nav-link:hover,
.nav-link.active {
    background: #fff;
    color: var(--primary);
    box-shadow: var(--shadow);
}

.nav-link svg {
    width: 20px;
    height: 20px;
}

/* Avatar */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: #e5e7eb;
}

.container {
    max-width: 1800px !important;
    margin: 0 auto;
    padding: 0 1rem;
    width: 100%;
}

/* Global Responsive Layouts for Grids */
@media (max-width: 1400px) {
    /* Handle 4-column layouts -> 3-column */
    main.container > div[style*="grid-template-columns: 240px minmax(450px, 1fr) 280px 280px"],
    main.container > div[style*="grid-template-columns: 280px 1fr 340px 240px"] {
        grid-template-columns: 240px 1fr 280px !important;
    }
    main.container > div[style*="grid-template-columns: 240px minmax(450px, 1fr) 280px 280px"] > div:nth-child(4),
    main.container > div[style*="grid-template-columns: 280px 1fr 340px 240px"] > div:nth-child(4) {
        display: none !important;
    }
}

@media (max-width: 1200px) {
    /* Collapse to 2 columns */
    main.container > div[style*="grid-template-columns: 240px minmax(450px, 1fr) 280px 280px"],
    main.container > div[style*="grid-template-columns: 280px 1fr 340px 240px"],
    main.container > div[style*="grid-template-columns: 280px 1fr 320px"],
    main.container > div[style*="grid-template-columns: 280px 1fr 350px"],
    main.container > div[style*="grid-template-columns: 280px 1fr 340px"],
    main.container > div[style*="grid-template-columns: 240px minmax(450px, 1fr) 280px"] {
        grid-template-columns: 240px 1fr !important;
    }
    
    main.container > div[style*="grid-template-columns: 240px minmax(450px, 1fr) 280px 280px"] > div:nth-child(3),
    main.container > div[style*="grid-template-columns: 280px 1fr 340px 240px"] > div:nth-child(3),
    main.container > div[style*="grid-template-columns: 280px 1fr 320px"] > div:nth-child(3),
    main.container > div[style*="grid-template-columns: 280px 1fr 350px"] > div:nth-child(3),
    main.container > div[style*="grid-template-columns: 280px 1fr 340px"] > div:nth-child(3),
    main.container > div[style*="grid-template-columns: 240px minmax(450px, 1fr) 280px"] > div:nth-child(3) {
        display: none !important;
    }
}

@media (max-width: 992px) {
    /* Collapse to 1 column for mobile and tablet */
    main.container > div[style*="display: grid"] {
        grid-template-columns: 1fr !important;
    }

    /* Transform the sidebar into a horizontal scrolling row on mobile */
    aside[style*="position: sticky"] {
        position: static !important;
        height: auto !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        padding-bottom: 0.5rem !important;
        margin-bottom: 1rem !important;
        width: 100% !important;
    }
    
    aside[style*="position: sticky"] > nav {
        flex-direction: row !important;
        gap: 0.5rem !important;
        overflow-x: auto !important;
        padding-bottom: 5px !important;
        display: flex !important;
    }

    /* Keep the links looking nice and don't shrink them */
    aside[style*="position: sticky"] > nav .nav-link {
        flex-shrink: 0 !important;
        padding: 0.5rem 0.75rem !important;
        background: #fff;
    }

    /* Hide the avatar card in the sidebar on mobile to save space */
    aside[style*="position: sticky"] > .card {
        display: none !important;
    }
    
    /* Make top header responsive */
    header .container > div:nth-child(2) {
        display: none !important; /* Hide search bar on very small screens to fit logo and actions */
    }
}