:root {
    --app-sidebar-width: 15.5rem;
    --app-topbar-height: 3.25rem;
    --app-bg: #f1f5f9;
    --app-surface: #ffffff;
    --app-text: #0f172a;
    --app-muted: #64748b;
    --app-border: #e2e8f0;
    --app-accent: #2563eb;
    --app-accent-soft: #eff6ff;
    --app-sidebar-bg: #0f172a;
    --app-sidebar-text: #cbd5e1;
    --app-sidebar-active: #1e293b;
    --app-radius: 0.625rem;
    --app-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.04);
}

body.app-admin {
    background: var(--app-bg);
    color: var(--app-text);
    font-size: 0.9375rem;
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body.app-admin #main {
    padding-top: 0;
}

body.app-admin .app-topbar {
    flex-shrink: 0;
}

body.app-admin .app-shell {
    flex: 1 0 auto;
}

body.app-admin #footer {
    flex-shrink: 0;
    margin-top: 0;
    background: var(--app-surface);
    border-top: 1px solid var(--app-border);
    font-size: 0.8125rem;
}

body.app-admin #main {
    padding-top: 0;
}

body.app-admin main > .container,
body.app-admin .app-main-inner {
    max-width: 1400px;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--app-topbar-height);
    background: var(--app-surface);
    border-bottom: 1px solid var(--app-border);
    box-shadow: var(--app-shadow);
}

.app-topbar .navbar-brand {
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.02em;
    color: var(--app-text);
}

.app-shell {
    display: flex;
    align-items: stretch;
}

.app-sidebar {
    width: var(--app-sidebar-width);
    flex-shrink: 0;
    background: var(--app-sidebar-bg);
    color: var(--app-sidebar-text);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.app-sidebar .offcanvas-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-sidebar .offcanvas-title {
    color: #f8fafc;
    font-weight: 600;
}

.app-sidebar-nav {
    padding: 0.75rem 0.5rem 1.25rem;
}

.app-sidebar-section {
    margin-bottom: 1rem;
}

.app-sidebar-section-title {
    display: block;
    padding: 0.35rem 0.75rem;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #94a3b8;
}

.app-sidebar-link {
    display: block;
    padding: 0.5rem 0.75rem;
    margin: 0.125rem 0;
    border-radius: 0.5rem;
    color: var(--app-sidebar-text);
    text-decoration: none;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}

.app-sidebar-link:hover,
.app-sidebar-link:focus {
    color: #f8fafc;
    background: rgba(255, 255, 255, 0.06);
}

.app-sidebar-link.active {
    color: #f8fafc;
    background: var(--app-sidebar-active);
    box-shadow: inset 3px 0 0 var(--app-accent);
}

.app-main {
    flex: 1;
    min-width: 0;
    padding: 1.25rem 1.5rem 2.5rem;
}

.app-main .breadcrumb {
    font-size: 0.8125rem;
    margin-bottom: 1rem;
    --bs-breadcrumb-divider: "›";
}

.app-main .breadcrumb-item a {
    color: var(--app-muted);
    text-decoration: none;
}

.app-main .breadcrumb-item a:hover {
    color: var(--app-accent);
}

.app-main .breadcrumb-item.active {
    color: var(--app-text);
    font-weight: 500;
}

.app-page-header {
    margin-bottom: 1.25rem;
}

.app-page-header h1,
.app-main h1.h3 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
    color: var(--app-text);
}

.app-page-header .lead,
.app-main .text-muted.small {
    color: var(--app-muted) !important;
}

.app-main .card {
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
    background: var(--app-surface);
}

.app-main .card-header {
    background: #f8fafc;
    border-bottom: 1px solid var(--app-border);
    font-weight: 600;
}

.app-main .collapsible-card .card-header {
    background: #f8fafc;
}

.app-main .table {
    font-size: 0.875rem;
    margin-bottom: 0;
    --bs-table-bg: transparent;
}

.app-main .table > :not(caption) > * > * {
    padding: 0.65rem 0.85rem;
    border-bottom-color: var(--app-border);
}

.app-main .table thead th {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--app-muted);
    background: #f8fafc;
    border-bottom: 1px solid var(--app-border);
    white-space: nowrap;
}

.app-main .table-hover > tbody > tr:hover > * {
    background: #f8fafc;
}

.app-main code,
.app-main .user-select-all {
    font-size: 0.84em;
    color: #334155;
    background: #f1f5f9;
    border: 1px solid var(--app-border);
    border-radius: 0.35rem;
    padding: 0.1rem 0.35rem;
}

.app-main .badge {
    font-weight: 600;
    letter-spacing: 0.01em;
}

.app-main .btn-sm {
    font-weight: 600;
}

.app-main .alert {
    border-radius: var(--app-radius);
    border: 1px solid transparent;
}

.app-main dl.row {
    --bs-gutter-x: 1rem;
}

.app-main dl.row dt {
    color: var(--app-muted);
    font-weight: 600;
}

.app-main dl.row dd {
    color: var(--app-text);
}

.app-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.app-dashboard-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    background: var(--app-surface);
    box-shadow: var(--app-shadow);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.app-dashboard-card:hover,
.app-dashboard-card:focus {
    border-color: #93c5fd;
    transform: translateY(-1px);
    color: inherit;
}

.app-dashboard-card-title {
    font-weight: 700;
    font-size: 1rem;
}

.app-dashboard-card-desc {
    font-size: 0.8125rem;
    color: var(--app-muted);
    margin: 0;
}

.app-user-menu .nav-link,
.app-user-menu .btn-link.logout {
    color: var(--app-muted);
    font-size: 0.875rem;
    font-weight: 500;
}

.app-user-menu .btn-link.logout {
    padding: 0.375rem 0.75rem;
}

.app-user-menu .btn-link.logout:hover {
    color: var(--app-text);
}

body:not(.app-admin) main > .container {
    padding-top: 4.5rem;
}

@media (max-width: 991.98px) {
    .app-main {
        padding: 1rem;
    }

    .app-sidebar.offcanvas {
        --bs-offcanvas-width: min(18rem, 88vw);
    }
}

@media (min-width: 992px) {
    .app-sidebar.offcanvas-lg {
        position: sticky;
        top: var(--app-topbar-height);
        align-self: flex-start;
        max-height: calc(100vh - var(--app-topbar-height));
        height: auto;
        overflow-y: auto;
        transform: none !important;
        visibility: visible !important;
        z-index: auto;
    }
}
