* {
    box-sizing: border-box;
}

:root {
    --primary: #10b981;
    --primary-dark: #059669;
    --secondary: #6366f1;
    --danger: #f43f5e;
    --success: #10b981;
    --warning: #f59e0b;
    --info: #0ea5e9;
    --bg-light: #f8fafc;
    --bg-dark: #0b0f1a;
    --card-bg-light: #ffffff;
    --card-bg-dark: #161e2e;
    --text-light: #334155;
    --text-dark: #cbd5e1;
    --sidebar-w: 210px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-light);
    font-size: 0.85rem;
    line-height: 1.4;
    transition: var(--transition);
}

body.dark-mode {
    background-color: var(--bg-dark);
    color: var(--text-dark);
}

.app-container {
    min-height: 100vh;
}

/* Sidebar - Ultra Compact Pure White */
.sidebar {
    width: var(--sidebar-w);
    background: #ffffff;
    color: var(--text-light);
    padding: 0.85rem 0.5rem;
    position: fixed;
    height: 100vh;
    z-index: 100;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #f1f5f9;
}

body.dark-mode .sidebar {
    background: var(--card-bg-dark);
    border-right: 1px solid #1e293b;
    color: var(--text-dark);
}

.nav-logo {
    font-size: 0.85rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    padding: 0.4rem 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: #1e293b;
    letter-spacing: -0.04em;
}

body.dark-mode .nav-logo {
    color: #fff;
}

.nav-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item {
    margin-bottom: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.65rem;
    color: #64748b;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 500;
    transition: var(--transition);
}

.nav-link:hover {
    background: #f8fafc;
    color: var(--primary);
}

body.dark-mode .nav-link:hover {
    background: rgba(255,255,255,0.05);
}

.nav-link.active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--primary);
    font-weight: 600;
}

.nav-link i {
    width: 14px;
    text-align: center;
    font-size: 0.8rem;
}

/* Forms & UI Elements */
.form-group {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-light);
}

.form-input {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.85rem;
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Main Content Layout */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 2.5rem 3rem;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
}

body.dark-mode .top-bar {
    border-bottom-color: #1e293b;
}

/* Compact Cards */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.main-stats-grid {
    grid-template-columns: 2fr 1fr;
}

@media (max-width: 1024px) {
    .main-stats-grid {
        grid-template-columns: 1fr;
    }
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    text-decoration: none;
    justify-content: center;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }

.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: white; }

.card {
    background: white;
    border-radius: 16px;
    border: 1px solid #f1f5f9;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

body.dark-mode .card {
    background: var(--card-bg-dark);
    border-color: #1e293b;
}

.card-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: #94a3b8;
    margin-bottom: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.card-value {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

/* Widgets */
.stat-pill {
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 700;
}

.health-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
}

th {
    padding: 0.5rem;
    text-align: left;
    color: #64748b;
    font-size: 0.75rem;
    text-transform: uppercase;
    border-bottom: 1px solid #e2e8f0;
}

td {
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.8rem;
}

/* Buttons */
.btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    border-radius: 4px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

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

/* Utilities */
.text-xs { font-size: 0.7rem; }
.text-muted { color: #64748b; }
.alert { font-size: 0.8rem; padding: 0.75rem; border-radius: 6px; }

/* Responsive Adjustments */
.hidden-mobile {
    display: inline-block;
}

@media (max-width: 768px) {
    .hidden-mobile {
        display: none !important;
    }
}
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    z-index: 1000;
    padding: 0 1rem;
    align-items: center;
    justify-content: space-between;
}

body.dark-mode .mobile-header {
    background: var(--card-bg-dark);
    border-bottom-color: #1e293b;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 95;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 1024px) {
    :root {
        --sidebar-w: 240px;
    }

    .sidebar {
        left: calc(-1 * var(--sidebar-w));
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 20px 0 25px -5px rgba(0,0,0,0.1);
    }

    .sidebar.active {
        transform: translateX(var(--sidebar-w));
    }

    .main-content {
        margin-left: 0 !important;
        padding: 1.5rem !important;
        padding-top: 5rem !important; /* Spacing for mobile header */
    }

    .mobile-header {
        display: flex;
    }

    .sidebar-overlay {
        display: block;
    }

    .top-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .top-bar > div:last-child {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }
}

@media (max-width: 768px) {
    .grid {
        grid-template-columns: 1fr;
    }

    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }

    .card {
        padding: 1rem;
    }

    .top-bar h2 {
        font-size: 1.1rem;
    }
    
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
    }
    
    .table-compact thead {
        display: none;
    }
    .table-compact tbody, .table-compact tr, .table-compact td {
        display: block;
        width: 100%;
    }
    .table-compact tr {
        margin-bottom: 0.75rem;
        border: 1px solid #f1f5f9;
        border-radius: 8px;
        padding: 0.5rem;
    }
    body.dark-mode .table-compact tr {
        border-color: #1e293b;
    }
    .table-compact td {
        text-align: right;
        padding: 0.5rem;
        border-bottom: 1px solid #f8fafc;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    body.dark-mode .table-compact td {
        border-bottom-color: #1e293b;
    }
    .table-compact td:last-child {
        border-bottom: none;
    }
    .table-compact td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #64748b;
        text-align: left;
    }
    
    .btn {
        width: auto;
        padding: 0.5rem 0.85rem;
    }
}

@media (max-width: 480px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .top-bar > div:last-child {
        gap: 0.5rem;
    }
    
    .top-bar .btn {
        flex: 1;
        font-size: 0.7rem;
    }
}
