:root {
            --primary-color: var(--primary-color, #2c3e50);
            --secondary-color: var(--secondary-color, #3498db);
            --accent-color: var(--accent-color, #1abc9c);
            --success-color: var(--success-color, #2ecc71);
            --warning-color: var(--warning-color, #f39c12);
            --danger-color: var(--danger-color, #e74c3c);
            --light-gray: var(--light-gray, #f8f9fa);
            --medium-gray: var(--medium-gray, #e9ecef);
            --dark-gray: var(--dark-gray, #6c757d);
            --shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
            --shadow-hover: 0 5px 15px rgba(0, 0, 0, 0.1);
            --transition: all 0.3s ease;
            --border-radius: 8px;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
        }

        body {
            background: #f8fafc;
            min-height: 100vh;
            color: #333;
            line-height: 1.6;
        }

        /* ========== 导航栏 ========== */
        .navbar {
            background: white;
            box-shadow: var(--shadow);
            padding: 0 2rem;
            position: sticky;
            top: 0;
            z-index: 1000;
            animation: slideDown 0.4s ease;
        }

        .navbar-container {
            max-width: 1200px;
            margin: 0 auto;
            display: flex;
            justify-content: space-between;
            align-items: center;
            height: 70px;
            gap: 1rem;
        }

        .logo {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            color: var(--primary-color, #2c3e50);
            text-decoration: none;
            font-weight: 600;
            font-size: 1.25rem;
            flex-shrink: 0;
        }

        .logo i {
            color: var(--secondary-color, #3498db);
            font-size: 1.5rem;
        }

        .nav-links {
            display: flex;
            gap: 0.75rem;
            align-items: center;
            flex-wrap: nowrap;
            flex: 1;
            justify-content: center;
        }

        .nav-link {
            color: var(--primary-color, #2c3e50);
            text-decoration: none;
            padding: 0.6rem 1rem;
            border-radius: var(--radius);
            transition: var(--transition);
            font-weight: 500;
            position: relative;
            font-size: 1rem;
            white-space: nowrap;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .nav-link:hover {
            background: var(--light-gray, #f8f9fa);
            color: var(--secondary-color, #3498db);
        }

        .nav-link.active {
            color: var(--secondary-color, #3498db);
        }

        .nav-link.active::after {
            content: '';
            position: absolute;
            bottom: -5px;
            left: 50%;
            transform: translateX(-50%);
            width: 5px;
            height: 5px;
            background: var(--secondary-color, #3498db);
            border-radius: 50%;
        }

        /* 导航图标大小调整 */
        .nav-link i,
        .nav-dropdown-toggle i:not(.fa-chevron-down) {
            font-size: 1.05rem;
        }

        /* 下拉菜单 */
        .nav-dropdown {
            position: relative;
        }

        .nav-dropdown-toggle {
            color: var(--primary-color, #2c3e50);
            text-decoration: none;
            padding: 0.6rem 1rem;
            border-radius: var(--radius);
            transition: var(--transition);
            font-weight: 500;
            display: flex;
            align-items: center;
            gap: 0.5rem;
            cursor: pointer;
            background: none;
            border: none;
            font-size: 1rem;
            white-space: nowrap;
        }

        .nav-dropdown-toggle:hover {
            background: var(--light-gray, #f8f9fa);
            color: var(--secondary-color, #3498db);
        }

        .nav-dropdown-toggle i.fa-chevron-down {
            font-size: 0.8rem;
            transition: var(--transition);
        }

        .nav-dropdown-menu {
            position: absolute;
            top: 100%;
            left: 0;
            background: white;
            box-shadow: var(--shadow-hover);
            border-radius: var(--radius);
            min-width: 180px;
            display: none;
            z-index: 1001;
            overflow: hidden;
            margin-top: 5px;
            opacity: 0;
            transform: translateY(-10px);
            transition: opacity 0.2s ease, transform 0.2s ease;
            pointer-events: none;
        }

        /* 新增：用JS控制的class样式 */
        .nav-dropdown.open .nav-dropdown-toggle i.fa-chevron-down {
            transform: rotate(180deg);
        }

        .nav-dropdown.open .nav-dropdown-menu {
            display: block !important;
            opacity: 1 !important;
            transform: translateY(0) !important;
            pointer-events: auto !important;
        }

        /* 悬停区域的CSS控制 */
        .nav-dropdown-hover-area {
            position: absolute;
            top: 100%;
            left: 0;
            width: 100%;
            height: 15px;
            background: transparent;
            pointer-events: none;
            z-index: 1000;
        }

        .nav-dropdown.open .nav-dropdown-hover-area {
            pointer-events: auto;
        }

        .nav-dropdown-item {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.8rem 1rem;
            color: var(--primary-color, #2c3e50);
            text-decoration: none;
            transition: var(--transition);
            border-bottom: 1px solid var(--medium-gray, #e9ecef);
            font-size: 0.95rem;
        }

        .nav-dropdown-item:last-child {
            border-bottom: none;
        }

        .nav-dropdown-item:hover {
            background: var(--light-gray, #f8f9fa);
            color: var(--secondary-color, #3498db);
        }

        .nav-dropdown-item.active {
            color: var(--secondary-color, #3498db);
            background: rgba(52, 152, 219, 0.1);
        }

        /* 用户信息区域 */
        .user-info {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            color: var(--dark-gray, #6c757d);
            flex-shrink: 0;
        }

        .user-badge {
            background: var(--light-gray, #f8f9fa);
            padding: 0.4rem 0.9rem;
            border-radius: 20px;
            font-size: 0.9rem;
            display: flex;
            align-items: center;
            gap: 0.3rem;
        }

        .user-badge i {
            color: var(--secondary-color, #3498db);
        }

        .logout-btn {
            background: var(--secondary-color, #3498db);
            color: white;
            border: none;
            padding: 0.6rem 1.1rem;
            border-radius: var(--radius);
            cursor: pointer;
            transition: var(--transition);
            font-weight: 500;
            display: flex;
            align-items: center;
            gap: 0.4rem;
            font-size: 0.9rem;
        }

        .logout-btn:hover {
            background: #2980b9;
            transform: translateY(-2px);
        }

        /* 主要内容区域 */
        .main-container {
            max-width: 1200px;
            margin: 2rem auto;
            padding: 0 2rem;
            animation: fadeIn 0.6s ease;
        }

        /* 卡片 */
        .card {
            background: white;
            border-radius: var(--radius);
            box-shadow: var(--shadow);
            padding: 2rem;
            margin-bottom: 2rem;
            transition: var(--transition);
            overflow: hidden;
        }

        .card:hover {
            box-shadow: var(--shadow-hover);
        }

        .card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1.5rem;
            padding-bottom: 1rem;
            border-bottom: 1px solid var(--medium-gray, #e9ecef);
        }

        .card-title {
            color: var(--primary-color, #2c3e50);
            font-size: 1.5rem;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }

        .card-title i {
            color: var(--secondary-color, #3498db);
        }

        /* 按钮 */
        .btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
            padding: 0.75rem 1.5rem;
            border: none;
            border-radius: var(--radius);
            cursor: pointer;
            font-weight: 500;
            transition: var(--transition);
            text-decoration: none;
            font-size: 0.95rem;
        }

        .btn-primary {
            background: var(--secondary-color, #3498db);
            color: white;
        }

        .btn-primary:hover {
            background: #2980b9;
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
        }

        .btn-success {
            background: var(--success-color, #2ecc71);
            color: white;
        }

        .btn-outline {
            background: transparent;
            border: 2px solid var(--secondary-color, #3498db);
            color: var(--secondary-color, #3498db);
        }

        .btn-outline:hover {
            background: var(--secondary-color, #3498db);
            color: white;
        }

        /* 全局按钮字体不加粗：默认 font-medium（500），与模板一致 */
        button { font-weight: 500; }

        /* 表单 */
        .form-group {
            margin-bottom: 1.5rem;
        }

        .form-label {
            display: block;
            margin-bottom: 0.5rem;
            font-weight: 500;
            color: var(--primary-color, #2c3e50);
        }

        .form-control {
            width: 100%;
            padding: 0.75rem 1rem;
            border: 1px solid var(--medium-gray, #e9ecef);
            border-radius: var(--radius);
            font-size: 1rem;
            transition: var(--transition);
        }

        .form-control:focus {
            outline: none;
            border-color: var(--secondary-color, #3498db);
            box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
        }

        /* 表格 */
        .table-container {
            overflow-x: auto;
            border-radius: var(--radius);
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
        }

        .table {
            width: 100%;
            border-collapse: collapse;
            min-width: 800px;
        }

        .table thead {
            background: var(--primary-color, #2c3e50);
            color: white;
        }

        .table th {
            padding: 1rem;
            text-align: center;
            font-weight: 600;
            white-space: nowrap;
        }

        .table tbody tr {
            border-bottom: 1px solid var(--medium-gray, #e9ecef);
            transition: var(--transition);
        }

        .table tbody tr:hover {
            background: rgba(52, 152, 219, 0.05);
        }

        .table td {
            padding: 1rem;
            vertical-align: middle;
        }

        /* 统计卡片 */
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 1.5rem;
            margin: 2rem 0;
        }

        .stat-card {
            background: white;
            border-radius: var(--radius);
            padding: 1.5rem;
            box-shadow: var(--shadow);
            transition: var(--transition);
            display: flex;
            align-items: center;
            gap: 1.5rem;
        }

        .stat-card:hover {
            transform: translateY(-5px);
            box-shadow: var(--shadow-hover);
        }

        .stat-icon {
            width: 60px;
            height: 60px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
            color: white;
        }

        .stat-icon.students {
            background: var(--gradient-students);
        }

        .stat-icon.scores {
            background: var(--gradient-scores);
        }

        .stat-info h3 {
            font-size: 2rem;
            font-weight: 700;
            color: var(--primary-color, #2c3e50);
            margin-bottom: 0.25rem;
        }

        .stat-info p {
            color: var(--dark-gray, #6c757d);
            font-size: 0.9rem;
        }

        /* 消息提示 */
        .alert {
            padding: 1rem 1.5rem;
            border-radius: var(--radius);
            margin-bottom: 1.5rem;
            display: flex;
            align-items: center;
            gap: 1rem;
            animation: slideInRight 0.5s ease;
        }

        .alert-success {
            background: rgba(46, 204, 113, 0.1);
            border-left: 4px solid var(--success-color, #2ecc71);
            color: #27ae60;
        }

        .alert-danger {
            background: rgba(231, 76, 60, 0.1);
            border-left: 4px solid var(--danger-color, #e74c3c);
            color: #c0392b;
        }

        .alert-info {
            background: rgba(52, 152, 219, 0.1);
            border-left: 4px solid var(--secondary-color, #3498db);
            color: #2980b9;
        }

        /* 动画 */
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }

        @keyframes slideDown {
            from { transform: translateY(-100%); }
            to { transform: translateY(0); }
        }

        @keyframes slideInRight {
            from { transform: translateX(20px); opacity: 0; }
            to { transform: translateX(0); opacity: 1; }
        }

        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.05); }
            100% { transform: scale(1); }
        }

        /* 加载动画 */
        .loading {
            display: inline-block;
            width: 20px;
            height: 20px;
            border: 3px solid var(--medium-gray, #e9ecef);
            border-top-color: var(--secondary-color, #3498db);
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }

        @keyframes spin {
            to { transform: rotate(360deg); }
        }

        /* ========== 响应式设计 ========== */

        /* 中等屏幕（1024px-1200px） */
        @media (max-width: 1200px) {
            .nav-links {
                gap: 0.5rem;
            }

            .nav-link,
            .nav-dropdown-toggle {
                padding: 0.5rem 0.8rem;
                font-size: 0.95rem;
                gap: 0.3rem;
            }

            .logo span {
                display: none;
            }

            .logo {
                gap: 0;
            }

            .user-badge span {
                max-width: 100px;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
            }
        }

        /* 平板屏幕（768px-1024px） */
        @media (max-width: 1024px) {
            .navbar {
                padding: 0 1rem;
            }

            .navbar-container {
                height: auto;
                padding: 0.75rem 0;
                flex-wrap: wrap;
                gap: 0.75rem;
            }

            .logo {
                order: 1;
            }

            .nav-links {
                order: 3;
                width: 100%;
                margin-top: 0.5rem;
                justify-content: center;
                overflow-x: auto;
                gap: 0.3rem;
                padding-bottom: 5px;
                scrollbar-width: thin;
                scrollbar-color: var(--medium-gray, #e9ecef) transparent;
            }

            .nav-links::-webkit-scrollbar {
                height: 3px;
            }

            .nav-links::-webkit-scrollbar-track {
                background: transparent;
            }

            .nav-links::-webkit-scrollbar-thumb {
                background: var(--medium-gray, #e9ecef);
                border-radius: 3px;
            }

            .nav-link,
            .nav-dropdown-toggle {
                flex-shrink: 0;
                padding: 0.6rem 0.7rem;
                font-size: 0.95rem;
            }

            .nav-dropdown-menu {
                position: fixed;
                top: auto;
                left: 50%;
                transform: translateX(-50%);
                width: 90%;
                max-width: 300px;
            }

            .user-info {
                order: 2;
                margin-left: auto;
            }
        }

        /* 大手机屏幕（576px-768px） */
        @media (max-width: 768px) {
            .main-container {
                padding: 0 1rem;
            }

            .card {
                padding: 1.5rem;
            }

            .nav-link span,
            .nav-dropdown-toggle span {
                display: none;
            }

            .nav-link,
            .nav-dropdown-toggle {
                padding: 0.6rem;
                min-width: 48px;
                justify-content: center;
                font-size: 0;
            }

            .nav-link i,
            .nav-dropdown-toggle i {
                font-size: 1.1rem;
                margin: 0;
            }

            .nav-dropdown-toggle i.fa-chevron-down {
                display: none;
            }

            .user-badge span {
                display: none;
            }

            .logout-btn span {
                display: none;
            }

            .logout-btn {
                padding: 0.6rem;
                min-width: 48px;
                justify-content: center;
            }

            .stats-grid {
                grid-template-columns: 1fr;
            }
        }

        /* 小手机屏幕（小于576px） */
        @media (max-width: 576px) {
            .logo i {
                font-size: 1.2rem;
            }

            .nav-link,
            .nav-dropdown-toggle {
                padding: 0.5rem;
                min-width: 44px;
            }

            .nav-link i,
            .nav-dropdown-toggle i {
                font-size: 1rem;
            }

            .user-badge {
                padding: 0.4rem 0.6rem;
            }

            .logout-btn {
                padding: 0.5rem;
                min-width: 44px;
            }

            .card-header {
                flex-direction: column;
                align-items: flex-start;
                gap: 1rem;
            }

            .card-title {
                font-size: 1.25rem;
            }
        }

        /* 超小屏幕（小于400px） */
        @media (max-width: 400px) {
            .navbar {
                padding: 0 0.75rem;
            }

            .main-container {
                padding: 0 0.75rem;
            }

            .card {
                padding: 1.25rem;
            }

            .nav-links {
                gap: 0.2rem;
            }

            .nav-link,
            .nav-dropdown-toggle {
                padding: 0.45rem;
                min-width: 40px;
            }

            .nav-link i,
            .nav-dropdown-toggle i {
                font-size: 0.95rem;
            }
        }

/* ========== 弹窗样式（与 teacher_query .modal-card 规范统一） ========== */
        .modal-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.5);
            backdrop-filter: blur(4px);
            z-index: 9999;
            align-items: center;
            justify-content: center;
            padding: 20px;
            animation: fadeInOverlay 0.25s ease;
        }
        .modal-overlay.active,
        .modal-overlay.show {
            display: flex;
        }
        .modal-dialog {
            max-width: 520px;
            width: 100%;
            margin: 0;
        }
        .modal-content {
            background: white;
            border-radius: 12px;
            box-shadow: 0 20px 60px rgba(0,0,0,0.25);
            overflow: hidden;
            max-height: 90vh;
            display: flex;
            flex-direction: column;
        }
        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 14px 24px;
            background: #f8fafc;
            border-bottom: 1px solid #e5e7eb;
            flex-shrink: 0;
        }
        .modal-title {
            font-size: 1rem;
            font-weight: 600;
            margin: 0;
            color: #1e293b;
        }
        .modal-body {
            padding: 20px 24px;
            color: #1f2937;
            line-height: 1.8;
            overflow-y: auto;
        }
        .modal-footer {
            display: flex;
            justify-content: flex-end;
            gap: 10px;
            padding: 12px 24px 18px;
            border-top: 1px solid #e5e7eb;
            flex-shrink: 0;
        }
        .close {
            background: none;
            border: none;
            font-size: 1.5rem;
            cursor: pointer;
            opacity: 0.5;
            padding: 0 0.5rem;
            color: #1e293b;
            line-height: 1;
        }
        .close:hover {
            opacity: 0.8;
        }
        @keyframes fadeInOverlay {
            from { opacity: 0; }
            to { opacity: 1; }
        }
        @keyframes slideUpModal {
            from { opacity: 0; transform: translateY(20px) scale(0.97); }
            to { opacity: 1; transform: translateY(0) scale(1); }
        }
        #confirmClearBtn:not(:disabled) {
            opacity: 1 !important;
        }
        #confirmClearBtn:not(:disabled):hover {
            background: #c82333 !important;
        }


/* ===== Sidebar layout (reconstructed to match base.html markup) ===== */
.app-layout { display: flex; min-height: 100vh; }

/* 仅已登录（存在侧边栏）时为其让出 240px；未登录页（登录/注册）不偏移，避免内容被挤向右侧 */
.app-layout.has-sidebar .main-content { margin-left: 240px; }

.sidebar {
    width: 240px; flex: 0 0 240px;
    background: #ffffff; color: #2c3e50;
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0;
    overflow: visible; z-index: 100;
    border-right: 1px solid #e6ebf2;
    box-shadow: 2px 0 12px rgba(20, 40, 80, .06);
}
.sidebar-brand {
    display: flex; align-items: center; gap: .6rem;
    padding: 1.1rem 1.2rem; font-size: 1.15rem; font-weight: 700;
    border-bottom: 1px solid #e6ebf2;
}
.sidebar-brand img { width: 32px; height: 32px; border-radius: 6px; }
.sidebar-nav {
    flex: 1;
    padding: .6rem .75rem;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 116, 139, .35) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, .32);
    border-radius: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, .5);
}
.sidebar-section {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
    color: #94a3b8; padding: .9rem .6rem .35rem;
}
.sidebar-link {
    display: flex; align-items: center; gap: .7rem;
    padding: .6rem .8rem; margin-bottom: .15rem;
    height: 2.6rem; box-sizing: border-box; line-height: 1.3;
    color: #475569; text-decoration: none;
    border-radius: .5rem; font-size: .92rem;
    white-space: nowrap; overflow: hidden;
    transition: background .15s, color .15s;
}
.sidebar-link:hover { background: #f1f5f9; color: #1e293b; }
.sidebar-link.active { background: #eaf3fd; color: #3498db; font-weight: 600; }
.sidebar-link-danger { color: #e74c3c; }
.sidebar-link-danger:hover { background: #fdeaea; color: #e74c3c; }

/* 教师端侧栏 —— 参考「阅卷蜂」极简白侧栏：icon+文字水平并排，200px 宽 */
.app-layout.nav-compact .sidebar {
    width: 200px; flex: 0 0 200px;
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    box-shadow: none;
    transition: width .28s cubic-bezier(.22,1,.36,1);
}
.app-layout.nav-compact .main-content { margin-left: 200px; padding: 1.5rem 1.5em 1.5rem 1.5em; }
.app-layout.nav-compact .sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    height: 60px; padding: 0 16px;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 700; font-size: 1.1rem; color: #0f172a;
}
.app-layout.nav-compact .sidebar-brand img {
    width: 34px; height: 34px; border-radius: 8px;
    box-shadow: 0 2px 8px rgba(52,152,219,.18);
}
.app-layout.nav-compact .sidebar-brand span {
    white-space: nowrap; overflow: hidden;
}
.app-layout.nav-compact .sidebar-nav {
    flex: 1; padding: 12px 10px;
    display: flex; flex-direction: column; gap: 4px;
    overflow-y: auto;
}
.app-layout.nav-compact .sidebar-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 8px;
    color: #475569; text-decoration: none;
    font-size: .88rem; font-weight: 500;
    white-space: nowrap; overflow: hidden;
    transition: background .15s, color .15s;
}
.app-layout.nav-compact .sidebar-link i {
    font-size: 1.1rem; flex: 0 0 20px; text-align: center;
}
.app-layout.nav-compact .sidebar-link:hover { background: #f1f5f9; color: #1e293b; }
.app-layout.nav-compact .sidebar-link.active { background: #eaf3fd; color: #3498db; font-weight: 600; }
.app-layout.nav-compact .sidebar-section {
    padding: .9rem .6rem .3rem; font-size: .72rem;
    letter-spacing: .06em; color: #94a3b8; text-transform: uppercase;
}
/* 用户卡：200px 足够显示头像+姓名 */
.app-layout.nav-compact .sidebar-footer { padding: .75rem 10px; border-top: 1px solid #e2e8f0; }
.app-layout.nav-compact .user-card { gap: 8px; }
.app-layout.nav-compact .user-avatar { width: 32px; height: 32px; font-size: .82rem; }
.app-layout.nav-compact .user-meta { display: flex; flex-direction: column; }
.app-layout.nav-compact .user-name { font-size: .85rem; font-weight: 600; }
.app-layout.nav-compact .user-role { font-size: .72rem; color: #94a3b8; }
.app-layout.nav-compact .user-caret { font-size: .7rem; }

/* 侧栏折叠按钮（桌面）：位于品牌标识右侧，点击收成图标轨 */
.sidebar-collapse-btn {
    margin-left: auto;
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; padding: 0;
    border: none; background: transparent; cursor: pointer;
    color: #64748b; border-radius: 8px; font-size: .95rem; line-height: 1;
    transition: background .15s ease, color .15s ease;
}
.sidebar-collapse-btn:hover { background: #f1f5f9; color: #1e293b; }
.sidebar-collapse-btn:focus-visible { outline: 2px solid #3498db; outline-offset: 2px; }

/* 折叠态：侧栏收成 64px 图标轨，主内容区相应让出 */
.app-layout.sidebar-collapsed .sidebar,
.app-layout.nav-compact.sidebar-collapsed .sidebar { width: 64px; flex-basis: 64px; }
.app-layout.sidebar-collapsed .main-content,
.app-layout.nav-compact.sidebar-collapsed .main-content { margin-left: 64px; }
.app-layout.sidebar-collapsed .sidebar { transition: width .28s cubic-bezier(.22,1,.36,1); }
.app-layout.sidebar-collapsed .main-content { transition: margin-left .28s cubic-bezier(.22,1,.36,1); }
.app-layout.sidebar-collapsed .sidebar-brand { flex-direction: column; align-items: center; justify-content: flex-start; gap: 0; height: auto; padding: 1rem 0; }
.app-layout.sidebar-collapsed .sidebar-brand img { display: none; }
.app-layout.sidebar-collapsed .sidebar-collapse-btn { margin-left: 0; width: 30px; height: 30px; }
.app-layout.sidebar-collapsed .sidebar-brand span,
.app-layout.sidebar-collapsed .sidebar-link span,
.app-layout.sidebar-collapsed .sidebar-section,
.app-layout.sidebar-collapsed .user-meta,
.app-layout.sidebar-collapsed .user-caret { display: none; }
.app-layout.sidebar-collapsed .sidebar-nav { padding-left: 0; padding-right: 0; scrollbar-gutter: auto; }
.app-layout.sidebar-collapsed .sidebar-link { justify-content: center; padding-left: 0; padding-right: 0; }
.app-layout.sidebar-collapsed .sidebar-link i { margin: 0; flex: 0 0 auto; }
.app-layout.sidebar-collapsed .user-card { justify-content: center; }
.app-layout.sidebar-collapsed .sidebar-collapse-btn i { transform: rotate(180deg); }
/* 折叠态（64px 图标轨）：账户菜单向右弹出为正常宽度浮层，底部对齐卡片、向上展开，避免被窄轨挤压或溢出屏幕，姓名标识（头像）仍可点击展开 */
.app-layout.sidebar-collapsed .user-menu {
    left: calc(100% + .5rem); right: auto; width: 200px;
    top: auto; bottom: 0; transform: translateY(8px);
}
.app-layout.sidebar-collapsed .user-card[aria-expanded="true"] .user-menu { transform: translateY(0); }

.sidebar-footer { padding: .8rem .9rem; border-top: 1px solid #e6ebf2; }
.user-card { display: flex; align-items: center; gap: .6rem; }
.user-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--secondary-color, #3498db); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.user-meta { line-height: 1.2; }
.user-name { font-weight: 600; font-size: .9rem; }
.user-role { font-size: .75rem; color: #94a3b8; }
.sidebar-logout {
    display: flex; align-items: center; gap: .55rem;
    margin-top: .6rem; padding: .5rem .7rem;
    color: #64748b; text-decoration: none;
    border-radius: .5rem; font-size: .88rem;
}
.sidebar-logout:hover { background: #f1f5f9; color: #1e293b; }

/* ===== 全局消息弹窗（替代各页面内联 flash 横幅） ===== */
.toast-container {
    position: fixed; top: 1.1rem; right: 1.1rem; z-index: 9999;
    display: flex; flex-direction: column; gap: .6rem;
    max-width: min(360px, calc(100vw - 2rem)); pointer-events: none;
}
.toast {
    --toast-color: #3498db;
    display: flex; align-items: flex-start; gap: .6rem;
    background: #fff; border: 1px solid #e7ebf0; border-left: 4px solid var(--toast-color);
    border-radius: 10px; padding: .8rem .9rem; box-shadow: 0 10px 28px rgba(44,62,80,.16);
    color: #2c3e50; font-size: .9rem; line-height: 1.45;
    opacity: 0; transform: translateX(24px); transition: opacity .28s ease, transform .28s ease;
    pointer-events: auto; max-width: 100%;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-icon { color: var(--toast-color); margin-top: .12rem; flex: none; font-size: 1rem; }
.toast-msg { flex: 1; word-break: break-word; }
.toast-close {
    background: none; border: none; color: #9aa3af; font-size: 1.15rem; line-height: 1;
    cursor: pointer; padding: 0 .1rem; flex: none; transition: color .15s ease;
}
.toast-close:hover { color: #2c3e50; }

/* ===== 账户菜单：用户卡片可点击下拉（功能①） ===== */
.user-card {
    cursor: pointer;
    position: relative;
    padding: .35rem .4rem;
    border-radius: .6rem;
    transition: background .15s ease;
}
.user-card:hover { background: rgba(255,255,255,.06); }
.user-card:focus-visible { outline: 2px solid var(--secondary-color, #3498db); outline-offset: 2px; }
.user-caret {
    margin-left: auto;
    font-size: .7rem;
    color: rgba(255,255,255,.5);
    transition: transform .2s ease;
}
.user-card[aria-expanded="true"] .user-caret { transform: rotate(180deg); }
/* 视觉隐藏但仍可被屏幕阅读器读取（供表单 label 等） */
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
/* 用户菜单项支持 button 语义（替代 javascript:void(0) 链接） */
/* 用户菜单项：a 与 button 完全统一，杜绝控件类型错位（图标定宽、文字弹性左对齐） */

.user-menu {
    position: absolute;
    left: .4rem; right: .4rem; bottom: calc(100% + .4rem);
    background: #fff;
    color: var(--primary-color, #2c3e50);
    border-radius: .6rem;
    box-shadow: 0 10px 30px rgba(0,0,0,.25);
    padding: .4rem;
    opacity: 0; visibility: hidden; transform: translateY(6px);
    transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
    z-index: 50;
}
.user-card[aria-expanded="true"] .user-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.user-menu-info { padding: .5rem .6rem .55rem; border-bottom: 1px solid #eef1f5; margin-bottom: .35rem; }
.user-menu-name { font-weight: 700; font-size: .9rem; }
.user-menu-role { font-size: .72rem; color: var(--dark-gray, #6c757d); }
.user-menu-item, button.user-menu-item {
    display: flex; align-items: center; justify-content: flex-start; gap: .55rem;
    width: 100%; box-sizing: border-box; margin: 0;
    padding: .5rem .6rem; border: none; border-radius: .45rem; background: none;
    font-family: inherit; font-size: .86rem; font-weight: 400; line-height: 1.4;
    color: var(--primary-color, #2c3e50); text-align: left; text-decoration: none; cursor: pointer;
}
.user-menu-item:hover, button.user-menu-item:hover { background: #f1f5fb; color: var(--secondary-color, #3498db); }
.user-menu-item i, button.user-menu-item i { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 1.1rem; width: 1.1rem; color: var(--secondary-color, #3498db); }
.user-menu-item span, button.user-menu-item span { flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main-content { margin-left: 0; flex: 1; padding: 1.5rem; overflow-y: auto; min-width: 0; }

/* ===== 移动端：侧边栏改为抽屉式，修复固定 240px 在窄屏吃掉半屏的响应式缺陷 ===== */
.sidebar-toggle { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 1024px) {
    .sidebar-collapse-btn { display: none; }
    .app-layout.has-sidebar .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
        z-index: 200;
    }
    .app-layout.has-sidebar.sidebar-open .sidebar {
        transform: translateX(0);
    }
    .app-layout.has-sidebar .main-content {
        margin-left: 0;
        padding-top: 4.5rem;
    }
    .sidebar-toggle {
        display: inline-flex;
        position: fixed;
        top: 1rem;
        left: 1rem;
        z-index: 300;
        width: 42px;
        height: 42px;
        align-items: center;
        justify-content: center;
        background: #fff;
        color: var(--primary-color, #2c3e50);
        border: 1px solid rgba(0, 0, 0, 0.08);
        border-radius: 10px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
        cursor: pointer;
        font-size: 1.1rem;
    }
    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 150;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }
    .app-layout.sidebar-open .sidebar-backdrop {
        opacity: 1;
        visibility: visible;
    }
    /* 移动端：账户菜单项加大点按区域、统一对齐，避免 a/button 两类控件错位 */
    .user-menu { left: .6rem; right: .6rem; }
    button.user-menu-item, .user-menu-item {
        align-items: center;
        padding: .7rem .65rem;
        min-height: 44px;
        font-size: .92rem;
    }
    .user-menu-item i { font-size: 1rem; }
}

/* 全站表格统一规范：所有表头与单元格内容居中（强制覆盖各组件默认值，保证整站一致） */
table th, table td { text-align: center !important; vertical-align: middle !important; }

