:root {
    --admin-sidebar-width: 252px;
    --admin-sidebar-collapsed-width: 72px;
    --admin-header-height: 66px;
}

.dashboard {
    display: flex;
    min-height: 100vh;
    background: var(--gray-50);
}

.sidebar {
    width: var(--admin-sidebar-width);
    background: var(--white);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: width 0.25s ease, transform 0.25s ease;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.38);
    z-index: 95;
}

.sidebar-backdrop.active {
    display: block;
}

.sidebar-header {
    min-height: var(--admin-header-height);
    padding: 0 0.85rem 0 1rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    background: var(--white);
    flex-shrink: 0;
    justify-content: space-between;
    gap: 0.65rem;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    font-size: 1.22rem;
    font-weight: 700;
    color: var(--primary-blue);
}

.sidebar-logo i {
    font-size: 1.45rem;
    width: 32px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-logo img {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border-radius: 7px;
    object-fit: contain;
}

.sidebar-logo span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-collapse-btn {
    width: 34px;
    height: 34px;
    border: 1px solid #d8e1ec;
    border-radius: 10px;
    background: #fff;
    color: var(--gray-600);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.sidebar-collapse-btn:hover {
    background: var(--light-blue);
    color: var(--primary-blue);
    border-color: #bfdbfe;
}

.sidebar-nav {
    flex: 1;
    min-height: 0;
    padding: 0.7rem 0.6rem;
    overflow-y: auto;
    overflow-x: visible;
}

.nav-group {
    position: relative;
    margin-bottom: 0.28rem;
}

.nav-group-header {
    width: 100%;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.55rem;
    min-height: 42px;
    padding: 0.65rem 0.7rem;
    border-radius: 10px;
    color: var(--gray-700);
    font-size: 0.94rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.nav-group-header:hover,
.nav-group-header.active {
    background: var(--light-blue);
    color: var(--primary-blue);
}

.nav-group-main {
    display: flex;
    align-items: center;
    gap: 0.62rem;
    min-width: 0;
}

.nav-group-main i {
    font-size: 1rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.nav-group-main span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.group-arrow {
    font-size: 0.85rem;
    transition: transform 0.3s;
}

.nav-group.open .group-arrow {
    transform: rotate(180deg);
}

.nav-submenu {
    display: none;
    margin-top: 0.22rem;
    padding-left: 0.9rem;
}

.nav-group.open .nav-submenu {
    display: block;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 36px;
    padding: 0.55rem 0.8rem 0.55rem 1rem;
    color: var(--gray-700);
    font-weight: 500;
    transition: all 0.3s;
    border-radius: 9px;
    font-size: 0.9rem;
}

.nav-item[hidden],
.nav-item.permission-hidden,
.nav-group[hidden] {
    display: none !important;
}

.nav-item:hover,
.nav-item.active {
    background: var(--light-blue);
    color: var(--primary-blue);
}

.nav-item.active {
    box-shadow: inset 3px 0 0 var(--primary-blue);
}

.sidebar-footer {
    padding: 0.65rem 0;
    border-top: 1px solid var(--gray-200);
    background: var(--white);
    flex-shrink: 0;
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    color: var(--gray-600);
    font-weight: 500;
    transition: all 0.3s;
}

.logout-btn:hover {
    background: var(--gray-100);
    color: #dc2626;
}

.main-content {
    flex: 1;
    margin-left: var(--admin-sidebar-width);
    padding-top: var(--admin-header-height);
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
    overflow-x: hidden;
    transition: margin-left 0.25s ease;
}

.topbar {
    height: var(--admin-header-height);
    min-height: var(--admin-header-height);
    max-height: var(--admin-header-height);
    padding: 0 1rem;
    background: var(--white);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    position: fixed;
    top: 0;
    left: var(--admin-sidebar-width);
    right: 0;
    z-index: 90;
    box-sizing: border-box;
    transition: left 0.25s ease;
}

.topbar-main {
    height: 100%;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    gap: 0.24rem;
    overflow: hidden;
}

.topbar-toolbar {
    height: 34px;
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.mobile-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    border: 1px solid #d8e1ec;
    border-radius: 10px;
    background: #fff;
    color: #344054;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.mobile-menu-btn:focus,
.mobile-menu-btn:active {
    outline: none;
    color: #344054;
    background: #fff;
}

.sidebar.open ~ .main-content .mobile-menu-btn {
    opacity: 0;
    pointer-events: none;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-height: 34px;
    margin-left: auto;
}

.project-runtime-meta {
    display: inline-flex;
    align-items: center;
    align-self: center;
    gap: 0.42rem;
    max-width: min(52vw, 620px);
    padding: 0.14rem;
    border: 1px solid #dbeafe;
    border-radius: 999px;
    background: linear-gradient(135deg, #f8fbff 0%, #eef7ff 100%);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.08);
}

.runtime-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
    padding: 0.24rem 0.5rem;
    border-radius: 999px;
    color: #1d4ed8;
    font-size: 0.74rem;
    font-weight: 700;
    line-height: 1;
    background: rgba(255, 255, 255, 0.75);
    white-space: nowrap;
}

.runtime-pill i {
    font-size: 0.78rem;
    color: #2563eb;
}

.runtime-pill span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.runtime-pill.accent {
    color: #047857;
    background: rgba(236, 253, 245, 0.9);
}

.runtime-pill.accent i {
    color: #059669;
}

.icon-btn {
    position: relative;
    background: none;
    border: none;
    font-size: 1.08rem;
    color: var(--gray-600);
    cursor: pointer;
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s;
}

.icon-btn:hover {
    color: var(--primary-blue);
}

.badge {
    position: absolute;
    top: 0;
    right: 0;
    background: #ef4444;
    color: var(--white);
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
}

.user-menu {
    border: 0;
    background: transparent;
    padding: 0.1rem 0.28rem;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 32px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.18s ease;
}

.user-menu:hover {
    background: #f1f6ff;
    transform: translateY(-1px);
}

.user-avatar {
    width: 30px;
    height: 30px;
    background: var(--light-blue);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-blue);
    overflow: hidden;
    font-weight: 800;
    flex: 0 0 auto;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-name {
    font-weight: 600;
    color: var(--gray-800);
    font-size: 0.92rem;
}

.content {
    padding: 0;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.content-frame-wrap {
    padding: 0;
    min-width: 0;
    width: 100%;
    overflow-x: hidden;
}

.tabbar-list {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    height: 24px;
    min-height: 24px;
    min-width: 0;
    width: 100%;
    overflow-x: auto;
    padding: 0;
}

.tabbar-list::-webkit-scrollbar {
    height: 6px;
}

.tabbar-list::-webkit-scrollbar-thumb {
    background: #d8e1ec;
    border-radius: 999px;
}

.tab-item {
    height: 22px;
    padding: 0 0.42rem 0 0.55rem;
    border-radius: 8px;
    border: 1px solid #e5edf6;
    background: #eef2f7;
    color: #667085;
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.25s;
}

.tab-item:hover {
    background: #e5edf8;
    color: #344054;
}

.tab-item.active {
    background: #fff;
    border-color: #d8e1ec;
    color: #2563eb;
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.08);
}

.tab-title {
    max-width: 132px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.8rem;
}

.tab-close {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 0;
    background: transparent;
    color: currentColor;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.75;
}

.tab-close:hover {
    background: rgba(37, 99, 235, 0.12);
    opacity: 1;
}

.content-frame {
    display: block;
    width: 100%;
    max-width: 100%;
    min-height: calc(100vh - var(--admin-header-height));
    border: 0;
    border-radius: 0;
    background: #f4f7fb;
    box-shadow: none;
}

body.sidebar-collapsed {
    --admin-sidebar-width: var(--admin-sidebar-collapsed-width);
}

body.sidebar-collapsed .sidebar {
    width: var(--admin-sidebar-collapsed-width);
}

body.sidebar-collapsed .sidebar-logo span,
body.sidebar-collapsed .nav-group-main span,
body.sidebar-collapsed .group-arrow,
body.sidebar-collapsed .logout-btn span {
    display: none;
}

body.sidebar-collapsed .sidebar-header {
    padding: 0 0.5rem;
    justify-content: center;
    flex-direction: column;
    gap: 0.35rem;
}

body.sidebar-collapsed .sidebar-logo {
    justify-content: center;
}

body.sidebar-collapsed .sidebar-collapse-btn i {
    transform: rotate(180deg);
}

body.sidebar-collapsed .sidebar-nav {
    padding: 0.6rem 0.45rem;
}

body.sidebar-collapsed .nav-group-header {
    justify-content: center;
    padding: 0;
    min-height: 42px;
}

body.sidebar-collapsed .nav-group-main {
    justify-content: center;
}

body.sidebar-collapsed .nav-submenu,
body.sidebar-collapsed .nav-group.open .nav-submenu {
    display: none;
}

body.sidebar-collapsed .nav-group:hover .nav-submenu {
    position: fixed;
    left: calc(var(--admin-sidebar-collapsed-width) + 8px);
    top: auto;
    display: grid;
    min-width: 150px;
    margin-top: -42px;
    padding: 0.45rem;
    border: 1px solid #e5edf6;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.16);
    z-index: 180;
}

body.sidebar-collapsed .nav-item {
    padding: 0.55rem 0.7rem;
    box-shadow: none;
}

body.sidebar-collapsed .logout-btn {
    justify-content: center;
    padding: 0.75rem 0;
}

.notification-popover {
    display: none;
    position: fixed;
    top: calc(var(--admin-header-height) - 18px);
    right: 20px;
    width: 360px;
    max-height: 500px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    flex-direction: column;
    overflow: hidden;
    z-index: 200;
}

.notification-popover.active {
    display: flex;
}

.notif-header-bar {
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notif-title {
    font-weight: 700;
    color: #1e293b;
}

.notif-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mark-all-read-btn {
    background: none;
    border: none;
    color: #3b82f6;
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    font-weight: 500;
}

.mark-all-read-btn:hover {
    color: #2563eb;
    text-decoration: underline;
}

.close-notif-btn {
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.notification-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 0;
}

.notif-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
}

.notif-item.unread {
    background: #eff6ff;
    border-left: 4px solid #3b82f6;
}

.notif-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    gap: 1rem;
}

.notif-date {
    font-size: 12px;
    color: #94a3b8;
    flex-shrink: 0;
}

.notif-content {
    color: #475569;
    font-size: 13px;
    line-height: 1.6;
}

.loading-state,
.empty-state {
    padding: 20px;
    text-align: center;
    color: #94a3b8;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--white);
}

.stat-icon.blue {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.stat-icon.green {
    background: linear-gradient(135deg, #10b981, #059669);
}

.stat-icon.orange {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.stat-icon.purple {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.stat-info {
    flex: 1;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-800);
    line-height: 1;
}

.stat-label {
    color: var(--gray-600);
    margin-top: 0.25rem;
}

.quick-actions {
    margin-bottom: 2rem;
}

.quick-actions h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--gray-800);
}

.actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.action-card {
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all 0.3s;
}

.action-card:hover {
    border-color: var(--primary-blue);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.action-card i {
    font-size: 2rem;
    color: var(--primary-blue);
}

.action-card span {
    font-weight: 600;
    color: var(--gray-700);
}

.recent-activity {
    background: var(--white);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.recent-activity h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--gray-800);
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    border-radius: 8px;
    transition: background 0.3s;
}

.activity-item:hover {
    background: var(--gray-50);
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--white);
    flex-shrink: 0;
}

.activity-icon.blue {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.activity-icon.green {
    background: linear-gradient(135deg, #10b981, #059669);
}

.activity-icon.orange {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.activity-icon.purple {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.activity-content {
    flex: 1;
}

.activity-text {
    color: var(--gray-800);
    margin-bottom: 0.25rem;
}

.activity-time {
    color: var(--gray-600);
    font-size: 0.875rem;
}

@media (max-width: 768px) {
    body.sidebar-collapsed {
        --admin-sidebar-width: 252px;
    }

    body.sidebar-collapsed .sidebar {
        width: var(--admin-sidebar-width);
    }

    body.sidebar-collapsed .sidebar-logo span,
    body.sidebar-collapsed .nav-group-main span,
    body.sidebar-collapsed .group-arrow,
    body.sidebar-collapsed .logout-btn span {
        display: inline;
    }

    body.sidebar-collapsed .sidebar-header {
        padding: 0 0.85rem 0 1rem;
        justify-content: space-between;
        flex-direction: row;
        gap: 0.65rem;
    }

    body.sidebar-collapsed .sidebar-collapse-btn {
        display: none;
    }

    body.sidebar-collapsed .nav-submenu {
        position: static;
        display: none;
        margin-top: 0.22rem;
        padding-left: 0.9rem;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    body.sidebar-collapsed .nav-group.open .nav-submenu {
        display: block;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding-top: var(--admin-header-height);
    }

    .mobile-menu-btn {
        display: inline-flex;
    }
}

@media (max-width: 768px) {
    .topbar {
        height: var(--admin-header-height);
        min-height: var(--admin-header-height);
        max-height: var(--admin-header-height);
        left: 0;
        padding: 0 1rem;
    }

    .topbar-main {
        height: 100%;
        min-height: 0;
        padding: 0;
        gap: 0.24rem;
    }

    .topbar-toolbar {
        width: 100%;
        height: 34px;
        min-height: 34px;
    }

    .tabbar-list {
        min-width: 0;
        padding-bottom: 0.15rem;
    }

    .topbar-actions {
        min-height: auto;
        gap: 0.65rem;
    }

    .project-runtime-meta {
        max-width: 46vw;
    }

    .runtime-pill {
        padding: 0.28rem 0.48rem;
        font-size: 0.72rem;
    }

    .runtime-pill i {
        display: none;
    }

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

    .actions-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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