:root {
    --shell-top-height: 48px;
    --shell-sidebar-width: 232px;
    --shell-bg: #f5f7fa;
    --shell-top-bg: #1f242b;
    --shell-sidebar-bg: #30363d;
    --shell-sidebar-muted: #8f9aa6;
    --shell-sidebar-text: #d9dee5;
    --shell-sidebar-hover: rgba(255, 255, 255, 0.07);
    --shell-sidebar-active: #3d5f92;
    --shell-sidebar-active-border: #75a7ff;
}

/* 全站壳层：顶栏 + 侧栏 + 主内容区 */
body {
    background-color: var(--shell-bg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    padding: 0;
}

/* 顶栏（全宽，位于侧栏之上） */
.app-top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--shell-top-height);
    background: var(--shell-top-bg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 1100;
    display: flex;
    align-items: center;
    padding: 0 1.15rem;
    box-sizing: border-box;
}
.app-top-nav .top-nav-brand {
    color: #fff;
    font-weight: 650;
    font-size: 0.98rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: 0;
    min-width: var(--shell-sidebar-width);
}

.app-top-nav .top-nav-brand i {
    color: #b9c2cc;
    font-size: 1.05rem;
}
.app-top-nav .top-nav-brand:hover {
    color: #fff;
    opacity: 0.9;
}

/* 汉堡菜单按钮（默认隐藏，移动端显示） */
.app-top-nav .sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: #b9c2cc;
    font-size: 1.35rem;
    cursor: pointer;
    padding: 0.25rem 0.45rem;
    margin-right: 0.65rem;
    border-radius: 0.35rem;
    line-height: 1;
    flex-shrink: 0;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.app-top-nav .sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* 侧栏遮罩层（移动端） */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* 移动端侧栏展开时锁定背景滚动 */
body.sidebar-open {
    overflow: hidden;
}

/* 侧栏：紧贴顶栏下方 */
nav.sidebar {
    position: fixed;
    left: 0;
    width: var(--shell-sidebar-width);
    top: var(--shell-top-height) !important;
    height: calc(100vh - var(--shell-top-height)) !important;
    padding: 0.75rem 0.7rem 1rem;
    background-color: var(--shell-sidebar-bg);
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
}

nav.sidebar .nav.flex-column {
    gap: 0.1rem;
}

nav.sidebar .nav-section-title {
    color: var(--shell-sidebar-muted);
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.08em;
    list-style: none;
    margin: 1rem 0 0.4rem;
    padding: 0 0.7rem;
}

nav.sidebar .nav-section-title:first-child {
    margin-top: 0.15rem;
}

nav.sidebar .nav-link {
    color: var(--shell-sidebar-text) !important;
    min-height: 2.45rem;
    padding: 0.5rem 0.7rem;
    border: none;
    border-radius: 0.45rem;
    border-left: 3px solid transparent;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none !important;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

nav.sidebar .nav-link i:first-of-type,
nav.sidebar .nav-link > i.bi:not(.ms-auto) {
    width: 1.2rem;
    text-align: center;
    flex-shrink: 0;
    opacity: 0.85;
    font-size: 1.05rem;
}

nav.sidebar .nav-link span {
    overflow: hidden;
    text-overflow: ellipsis;
}

nav.sidebar .nav-link:hover {
    color: #fff !important;
    background-color: var(--shell-sidebar-hover);
}

nav.sidebar .nav-link:focus-visible {
    color: #fff !important;
    box-shadow: inset 0 0 0 2px rgba(110, 168, 254, 0.5);
    outline: none;
}

nav.sidebar .nav-link.active {
    color: #fff !important;
    background-color: var(--shell-sidebar-active);
    border-left-color: var(--shell-sidebar-active-border);
    box-shadow: inset 0 0 0 1px rgba(117, 167, 255, 0.14);
    font-weight: 650;
}

nav.sidebar .nav-link.active i {
    opacity: 1;
}

nav.sidebar .nav-link.disabled {
    color: #6c757d !important;
    pointer-events: none;
    opacity: 0.65;
}

nav.sidebar .nav-divider {
    height: 1px;
    margin: 0.65rem 0.4rem;
    background-color: rgba(255, 255, 255, 0.12);
    border: none;
    list-style: none;
}

/* 主内容区 */
.main-content {
    margin-left: var(--shell-sidebar-width);
    padding: 2rem;
    margin-top: var(--shell-top-height);
    box-sizing: border-box;
    min-height: calc(100vh - var(--shell-top-height));
}

@media (max-width: 768px) {
    /* 显示汉堡按钮 */
    .app-top-nav .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .app-top-nav .top-nav-brand {
        min-width: unset;
    }
    /* 侧栏滑入/滑出 */
    nav.sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1001;
    }
    nav.sidebar.show {
        transform: translateX(0);
    }
    /* 主内容区全宽 */
    .main-content {
        margin-left: 0;
        padding: 1rem;
        margin-top: var(--shell-top-height);
    }
    /* 触控友好：加大导航项点击区域 */
    nav.sidebar .nav-link {
        min-height: 2.8rem;
        font-size: 0.95rem;
    }
    nav.sidebar .nav-section-title {
        font-size: 0.72rem;
    }
}

/* 子菜单 */
.has-submenu .submenu {
    background-color: #2c3136;
    padding-left: 0;
    list-style: none;
    margin: 0;
}

.has-submenu .submenu .nav-link {
    padding-left: 2.75rem;
    font-size: 0.875rem;
    color: #b8c0ca !important;
}

.has-submenu .submenu .nav-link:hover {
    color: #fff !important;
}

.has-submenu .submenu .nav-link.active {
    color: #fff !important;
    background-color: rgba(13, 110, 253, 0.18);
    border-left-color: #6ea8fe;
}

.submenu-toggle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.submenu-toggle .bi-chevron-down {
    transition: transform 0.3s ease;
    font-size: 0.72rem;
    opacity: 0.75;
    margin-left: auto;
}

.submenu-toggle[aria-expanded="true"] .bi-chevron-down:last-child {
    transform: rotate(180deg);
}

.submenu-toggle[aria-expanded="true"] {
    background-color: rgba(255, 255, 255, 0.08);
    color: #fff !important;
}
