:root {
    --app-sidebar-width: 240px;
    --app-sidebar-bg: #0f172a;
    --app-sidebar-fg: #cbd5e1;
    --app-sidebar-fg-active: #ffffff;
    --app-sidebar-active-bg: rgba(255, 255, 255, 0.08);
    --app-topbar-height: 56px;
    --app-content-bg: #f6f7fb;
    --bs-link-color: #2563eb;
    --bs-link-hover-color: #1d4ed8;
}

:root[data-bs-theme="dark"] {
    --app-sidebar-bg: #0b1120;
    --app-content-bg: #0f172a;
}

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--app-content-bg);
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--app-sidebar-width);
    background: var(--app-sidebar-bg);
    color: var(--app-sidebar-fg);
    display: flex;
    flex-direction: column;
    padding: 1rem 0.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
    transition: margin-left 0.2s ease;
}

.app-sidebar .brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
    font-weight: 600;
    padding: 0.5rem 0.75rem 1rem;
    letter-spacing: 0.02em;
}

.app-sidebar .brand i {
    font-size: 1.25rem;
    color: #60a5fa;
}

.app-sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--app-sidebar-fg);
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    margin: 0.1rem 0;
    font-size: 0.925rem;
}

.app-sidebar .nav-link:hover {
    background: var(--app-sidebar-active-bg);
    color: var(--app-sidebar-fg-active);
}

.app-sidebar .nav-link.active {
    background: var(--app-sidebar-active-bg);
    color: var(--app-sidebar-fg-active);
    font-weight: 500;
}

.app-sidebar .nav-link i {
    width: 1rem;
    text-align: center;
    opacity: 0.9;
}

.sidebar-footer {
    margin-top: auto;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    height: var(--app-topbar-height);
    background: var(--bs-body-bg);
    border-bottom: 1px solid var(--bs-border-color);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-title {
    font-weight: 600;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.app-content {
    padding: 1.25rem;
    flex: 1;
}

.card {
    border-radius: 0.75rem;
    border-color: var(--bs-border-color);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--bs-border-color);
    font-weight: 500;
}

.stat-card .stat-label {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    color: var(--bs-secondary-color);
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 0.25rem;
}

.sidebar-toggle { display: none; }

@media (max-width: 768px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 20;
        margin-left: calc(-1 * var(--app-sidebar-width));
    }
    .app-shell.sidebar-open .app-sidebar {
        margin-left: 0;
    }
    .sidebar-toggle { display: inline-flex; }
}

.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e0e7ff 0%, #f6f7fb 100%);
    padding: 2rem 1rem;
}

:root[data-bs-theme="dark"] .auth-body {
    background: linear-gradient(135deg, #0b1120 0%, #0f172a 100%);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bs-body-bg);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.12);
}

.auth-brand {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-brand i {
    font-size: 2rem;
    color: #2563eb;
}

.auth-brand h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0.5rem 0 0.25rem;
}

.error-screen {
    text-align: center;
    padding: 3rem 1rem;
}

.error-code {
    font-size: 3rem;
    font-weight: 700;
    color: var(--bs-secondary-color);
}

code {
    color: inherit;
    background: var(--bs-tertiary-bg);
    padding: 0.1rem 0.35rem;
    border-radius: 0.25rem;
    font-size: 0.85em;
}

.search-col {
    width: 280px;
    max-width: 100%;
}
