.admin-layout {
    display: flex;
    min-height: 100vh;
    height: auto;
}

.sidebar {
    width: 260px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 24px;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

/* 切换按钮容器 - 桌面模式下隐藏 */
.sidebar-toggle-container {
    display: none;
}

.sidebar-header {
    text-align: center;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-close-btn {
    display: none;
}

.sidebar-header .logo {
    font-size: clamp(2.5rem, 5vw, 3rem);
    margin-bottom: 12px;
}

.sidebar-header h2 {
    font-size: clamp(1.3rem, 3vw, 1.5rem);
    color: var(--text-primary);
    line-height: 1.2;
}

.sidebar-nav {
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px;
    border-radius: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    margin-bottom: 8px;
    transition: all 0.3s ease;
    min-height: 44px;
    white-space: nowrap;
}

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

.nav-item.active {
    background: var(--gradient-primary);
    color: white;
}

.sidebar-footer {
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

#admin-manage-link {
    display: none;
}

#admin-manage-link.show-for-super-admin {
    display: flex;
}

.logout-btn {
    color: var(--error-color);
}

.logout-btn:hover {
    background: var(--error-color-alpha-20);
    color: var(--error-color);
}

.main-content {
    flex: 1;
    padding: 32px;
    min-width: 0;
    margin-left: 260px;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    gap: 16px;
    flex-wrap: wrap;
}

.content-header h1 {
    font-size: clamp(1.5rem, 3.5vw, 2rem);
    color: var(--text-primary);
    line-height: 1.2;
    font-weight: 700;
}

.user-info {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: clamp(0.9rem, 2vw, 1rem);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.role-0 {
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    color: #fff;
}

.role-1 {
    background: linear-gradient(135deg, #0891b2 0%, #06b6d4 100%);
    color: #fff;
}

.role-2 {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    color: #fff;
}

.username-text {
    color: var(--text-primary);
}

.container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.login-card {
    max-width: 440px;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: clamp(32px, 6vw, 48px) clamp(24px, 5vw, 40px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: slideUp 0.5s ease;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-icon {
    font-size: clamp(2.5rem, 5vw, 3rem);
    margin-bottom: 16px;
}

.login-header h1 {
    font-size: clamp(1.5rem, 4vw, 1.75rem);
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.2;
}

.login-header p {
    color: var(--text-secondary);
    font-size: clamp(0.9rem, 2vw, 0.95rem);
}

.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.btn-block {
    width: 100%;
}

.login-footer {
    margin-top: 32px;
    text-align: center;
}

.login-footer p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.footer-divider {
    color: var(--border-color);
    margin: 0 4px;
}

.register-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.register-link:hover {
    text-decoration: underline;
    opacity: 0.8;
}

.switch-form {
    margin-top: 16px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.switch-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    margin-left: 4px;
}

.switch-link:hover {
    text-decoration: underline;
}

.back-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.back-link:hover {
    text-decoration: underline;
}

.dashboard {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 100%;
    overflow-x: hidden;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    max-width: 100%;
}

.stat-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: clamp(16px, 4vw, 24px);
    display: flex;
    align-items: center;
    gap: clamp(12px, 3vw, 20px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    min-width: 0;
}

.stat-icon {
    font-size: clamp(2rem, 5vw, 3rem);
    width: clamp(50px, 12vw, 70px);
    height: clamp(50px, 12vw, 70px);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color-alpha-15);
    border-radius: 16px;
    flex-shrink: 0;
}

.stat-content {
    flex: 1;
    min-width: 0;
}

.stat-number {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.2;
}

.stat-label {
    color: var(--text-secondary);
    font-size: clamp(0.85rem, 2vw, 0.95rem);
    line-height: 1.3;
}

.quick-actions {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

@media (min-width: 1025px) and (max-width: 1440px) {
    .sidebar {
        width: 230px;
    }
    
    .main-content {
        padding: 24px;
        margin-left: 230px;
    }
}

@media (max-width: 1024px) {
    .admin-layout {
        flex-direction: row;
    }
    
    .sidebar {
        width: 200px;
        padding: 16px;
    }
    
    .sidebar-nav {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding-bottom: 8px;
    }
    
    .nav-item {
        white-space: nowrap;
        margin-bottom: 8px;
        padding: 12px 14px;
        font-size: 14px;
        min-width: auto;
    }
    
    .sidebar-footer {
        display: block;
    }
    
    .main-content {
        padding: 24px 16px;
        margin-left: 200px;
    }
    
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .content-header h1 {
        font-size: clamp(1.5rem, 3.5vw, 1.75rem);
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .quick-actions {
        flex-direction: column;
        gap: 12px;
    }
    
    .login-card {
        padding: clamp(28px, 5vw, 40px) clamp(20px, 4vw, 32px);
    }
}

@media (max-width: 768px) {
    .admin-layout {
        flex-direction: row;
    }
    
    .sidebar {
        width: 180px;
        padding: 12px;
    }
    
    .nav-item {
        padding: 10px 12px;
        font-size: 13px;
        gap: 8px;
    }
    
    .sidebar-nav {
        gap: 6px;
    }
    
    .container {
        padding: 20px 16px;
    }
    
    .login-card {
        padding: clamp(24px, 5vw, 32px) clamp(16px, 4vw, 24px);
    }
    
    .login-header h1 {
        font-size: clamp(1.35rem, 4vw, 1.5rem);
    }
    
    .stat-card {
        padding: clamp(14px, 3vw, 20px);
        gap: clamp(10px, 3vw, 16px);
    }
    
    .stat-icon {
        font-size: clamp(1.8rem, 4.5vw, 2.5rem);
        width: clamp(45px, 11vw, 60px);
        height: clamp(45px, 11vw, 60px);
    }
    
    .stat-number {
        font-size: clamp(1.4rem, 3.5vw, 1.75rem);
    }
    
    .main-content {
        padding: 16px 12px;
        margin-left: 180px;
    }
    
    .content-header {
        margin-bottom: 20px;
    }
}

@media (max-width: 480px) {
    .admin-layout {
        flex-direction: row;
    }
    
    .sidebar {
        width: 160px;
        padding: 8px;
    }
    
    .nav-item {
        padding: 12px 14px;
        font-size: 12px;
        gap: 6px;
    }
    
    .sidebar-nav {
        gap: 4px;
    }
    
    .nav-item span:first-child {
        font-size: 16px;
    }
    
    .login-card {
        padding: clamp(20px, 5vw, 24px) clamp(14px, 4vw, 20px);
    }
    
    .login-header h1 {
        font-size: clamp(1.25rem, 4vw, 1.35rem);
    }
    
    .stat-card {
        padding: clamp(12px, 3vw, 16px);
        gap: clamp(8px, 2.5vw, 12px);
    }
    
    .stat-icon {
        font-size: clamp(1.6rem, 4vw, 2rem);
        width: clamp(40px, 10vw, 50px);
        height: clamp(40px, 10vw, 50px);
    }
    
    .stat-number {
        font-size: clamp(1.25rem, 3.5vw, 1.5rem);
    }
    
    .stat-label {
        font-size: clamp(0.8rem, 2vw, 0.85rem);
    }
    
    .main-content {
        padding: 12px 8px;
        margin-left: 160px;
    }
    
    .content-header h1 {
        font-size: clamp(1.2rem, 3.5vw, 1.35rem);
    }
}

/* ========================================
   移动端侧边栏模式（≤768px）
   ======================================== */
@media (max-width: 768px) {
    .mobile-sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        height: 100vh;
        width: 260px;
        padding: 0;
        z-index: 1001;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(20px);
    }
    
    .mobile-sidebar.sidebar-expanded {
        left: 0;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    }
    
    .mobile-sidebar .sidebar-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 20px;
        border-bottom: 1px solid #f3f4f6;
        background: var(--gradient-primary);
    }
    
    .mobile-sidebar .sidebar-header .logo {
        font-size: 1.5rem;
        margin-bottom: 0;
    }
    
    .mobile-sidebar .sidebar-header h2 {
        display: block;
        color: #fff;
        font-size: 16px;
        font-weight: 600;
        margin: 0;
        flex: 1;
        margin-left: 12px;
    }
    
    .mobile-sidebar .sidebar-close-btn {
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.2);
        border: none;
        border-radius: 8px;
        cursor: pointer;
        color: #fff;
        font-size: 20px;
        transition: all 0.2s;
    }
    
    .mobile-sidebar .sidebar-close-btn:hover {
        background: rgba(255, 255, 255, 0.3);
    }
    
    .mobile-sidebar .sidebar-toggle-container {
        display: none;
    }
    
    .mobile-sidebar .sidebar-nav {
        display: none;
        padding: 12px;
        overflow-y: auto;
        max-height: calc(100vh - 140px);
    }
    
    .mobile-sidebar.sidebar-expanded .sidebar-nav {
        display: block;
    }
    
    .mobile-sidebar .sidebar-footer {
        display: none;
        padding: 12px;
        border-top: 1px solid #f3f4f6;
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: #f9fafb;
    }
    
    .mobile-sidebar.sidebar-expanded .sidebar-footer {
        display: block;
    }
    
    .mobile-sidebar .nav-item {
        display: flex;
        align-items: center;
        padding: 12px 16px;
        margin-bottom: 4px;
        border-radius: 10px;
        font-size: 14px;
        gap: 12px;
        color: #374151;
        transition: all 0.2s;
    }
    
    .mobile-sidebar .nav-item:hover {
        background: var(--primary-color-alpha-15);
    }
    
    .mobile-sidebar .nav-item.active {
        background: var(--gradient-primary);
        color: #fff;
        box-shadow: var(--shadow-primary);
    }
    
    .mobile-sidebar .nav-item span:first-child {
        font-size: 1.2rem;
        flex-shrink: 0;
        width: 24px;
        text-align: center;
    }
    
    .mobile-sidebar ~ .main-content {
        margin-left: 0;
        padding: 16px 12px;
        padding-top: 70px;
    }
    
    body.sidebar-overlay::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    body.sidebar-overlay.sidebar-expanded::before {
        opacity: 1;
        visibility: visible;
    }
    
    .mobile-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 56px;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 16px;
        z-index: 999;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    }
    
    .mobile-header-left {
        display: flex;
        align-items: center;
        gap: 12px;
    }
    
    .mobile-menu-btn {
        width: 40px;
        height: 40px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 5px;
        background: transparent;
        border: none;
        border-radius: 10px;
        cursor: pointer;
        transition: all 0.2s;
    }
    
    .mobile-menu-btn:hover {
        background: #f3f4f6;
    }
    
    .mobile-menu-btn span {
        display: block;
        width: 20px;
        height: 2px;
        background: #374151;
        border-radius: 2px;
        transition: all 0.3s ease;
    }
    
    .mobile-menu-btn.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .mobile-menu-btn.active span:nth-child(2) {
        opacity: 0;
    }
    
    .mobile-menu-btn.active span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }
    
    .mobile-header-title {
        font-size: 16px;
        font-weight: 600;
        color: #374151;
    }
    
    .mobile-header-right {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    
    .mobile-user-avatar {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: var(--gradient-primary);
        display: flex;
        align-items: center;
        justify-content: center;
        color: #fff;
        font-size: 14px;
        font-weight: 600;
    }
}

/* 小屏手机优化（≤480px） */
@media (max-width: 480px) {
    .mobile-sidebar {
        width: 240px;
    }
    
    .mobile-sidebar .sidebar-header {
        padding: 12px 16px;
    }
    
    .mobile-sidebar .sidebar-header h2 {
        font-size: 14px;
    }
    
    .mobile-sidebar .nav-item {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .mobile-header {
        height: 52px;
        padding: 0 12px;
    }
    
    .mobile-menu-btn {
        width: 36px;
        height: 36px;
    }
    
    .mobile-header-title {
        font-size: 15px;
    }
    
    .mobile-sidebar ~ .main-content {
        padding: 12px 8px;
        padding-top: 64px;
    }
    
    .content-header h1 {
        font-size: clamp(1.2rem, 3.5vw, 1.35rem) !important;
    }
    
    .user-info {
        font-size: clamp(0.85rem, 2vw, 0.9rem) !important;
    }
    
    .card h2 {
        font-size: clamp(1.125rem, 2.5vw, 1.375rem) !important;
    }
    
    .card h3 {
        font-size: clamp(1rem, 2.5vw, 1.1rem) !important;
    }
    
    /* 调小按钮字体 */
    .btn {
        font-size: clamp(12px, 2.8vw, 13px) !important;
    }
    
    /* 调小表格字体 */
    .id-code-table th,
    .id-code-table td {
        font-size: clamp(9px, 2vw, 10px) !important;
    }
}


