*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

input, textarea { user-select: text; -webkit-user-select: text; }

:root {
    --bg: #f5f7fa;
    --bg-white: #ffffff;
    --bg-dark: #1a1d29;
    --border: #e8ecf1;
    --border-dark: #2d3344;
    --primary: #4f6ef7;
    --primary-light: #eef1fe;
    --text: #2c3e50;
    --text-light: #8392a5;
    --success: #10b981;
    --danger: #ef4444;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

.hidden { display: none !important; }

/* ===== 登录页 ===== */
#login-page {
    min-height: 100vh;
    display: flex;
}

.login-container {
    display: flex;
    width: 100%;
}

.login-left {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-video {
    position: absolute;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    transform: translate(-50%, -50%);
    object-fit: cover;
    z-index: 1;
}

.login-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 2;
}

.login-brand {
    position: relative;
    z-index: 3;
    text-align: center;
    color: #fff;
}

.login-brand img {
    width: 120px;
    height: 120px;
    border-radius: 24px;
    margin-bottom: 32px;
    box-shadow: 0 0 60px rgba(79, 110, 247, 0.6), 0 0 30px rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.login-brand h1 {
    font-size: 42px;
    font-weight: 700;
    margin-bottom: 16px;
    text-shadow: 0 0 20px rgba(0,0,0,0.8), 0 0 40px rgba(79, 110, 247, 0.5);
    letter-spacing: 4px;
}

.login-brand p {
    font-size: 18px;
    opacity: 1;
    text-shadow: 0 0 15px rgba(0,0,0,0.8);
    letter-spacing: 2px;
}

.login-right {
    width: 480px;
    background: url('beijing.jpg') center/cover no-repeat;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 60px;
    position: relative;
}

.login-right::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.96);
}

.login-right > * {
    position: relative;
    z-index: 1;
}

.login-form-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.login-form-desc {
    color: var(--text-light);
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 8px;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border 0.2s, box-shadow 0.2s;
}

.form-group input:focus, .form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group input::placeholder { color: var(--text-light); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #3d5bd9; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: transparent; color: var(--text-light); padding: 8px 12px; }
.btn-ghost:hover { color: var(--text); background: var(--bg); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 13px; }

.error-message { color: var(--danger); font-size: 13px; text-align: center; margin-top: 16px; }

.login-footer {
    margin-top: 24px;
    text-align: center;
}

.contact-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-light);
    text-decoration: none;
    font-size: 13px;
    padding: 8px 16px;
    border-radius: 6px;
    transition: all 0.2s;
}

.contact-link:hover {
    color: #0088cc;
    background: rgba(0, 136, 204, 0.08);
}

.contact-link svg { flex-shrink: 0; }

/* ===== 主界面 ===== */
#main-page { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-dark);
}

.sidebar-logo { width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; }

.sidebar-brand { display: flex; flex-direction: column; overflow: hidden; }

.brand-name {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
}

.brand-slogan {
    font-size: 11px;
    color: #6b7280;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.sidebar-nav { flex: 1; padding: 20px 16px; }

.nav-section { margin-bottom: 24px; }

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    color: #5a6578;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0 12px;
    margin-bottom: 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    color: #6b7280;
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: all 0.2s;
    font-size: 14px;
    position: relative;
}

.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item:hover { color: #d1d5db; background: rgba(255,255,255,0.04); }

.nav-item.active {
    color: var(--primary);
    background: transparent;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.nav-item.active svg { color: var(--primary); }

.sidebar-footer { padding: 20px; border-top: 1px solid var(--border-dark); }

.user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    margin-bottom: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
}

.user-card span { color: #fff; font-size: 14px; }

#logout-btn {
    width: 100%;
    justify-content: center;
    background: rgba(255,255,255,0.05);
    color: #9ca3af;
    border: none;
    padding: 10px;
}

#logout-btn:hover { background: rgba(239,68,68,0.15); color: var(--danger); }

/* ===== 主内容 ===== */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
    background: url('beijing.jpg') center/cover no-repeat fixed;
    position: relative;
}

.main-content::before {
    content: '';
    position: fixed;
    top: 0;
    left: 260px;
    right: 0;
    bottom: 0;
    background: rgba(247, 248, 250, 0.96);
    z-index: 0;
}

.main-content > * {
    position: relative;
    z-index: 1;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.page-header h2 { font-size: 22px; font-weight: 600; }

.content-page { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===== 统计卡片 ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

.stat-card {
    background: var(--bg-white);
    border-radius: 14px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg { width: 24px; height: 24px; }
.stat-icon.blue { background: #eef4ff; color: #4f6ef7; }
.stat-icon.green { background: #ecfdf5; color: #10b981; }
.stat-icon.purple { background: #f5f3ff; color: #8b5cf6; }
.stat-icon.orange { background: #fff7ed; color: #f59e0b; }

.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 14px; color: var(--text-light); margin-top: 4px; }

/* ===== 表格 ===== */
.table-container {
    background: var(--bg-white);
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    overflow: hidden;
}

.data-table { width: 100%; border-collapse: collapse; }

.data-table th, .data-table td {
    padding: 16px 20px;
    text-align: left;
}

.data-table th {
    background: var(--bg);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.data-table td {
    border-top: 1px solid var(--border);
    font-size: 14px;
}

.data-table tbody tr:hover { background: #fafbfc; }

.data-table code {
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 12px;
    background: var(--bg);
    padding: 4px 8px;
    border-radius: 4px;
    color: var(--text-light);
}

/* ===== 标签 ===== */
.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge.active, .badge.online { background: #ecfdf5; color: #059669; }
.badge.disabled, .badge.offline { background: #f3f4f6; color: #6b7280; }
.badge.admin { background: #f5f3ff; color: #7c3aed; }
.badge.user { background: #eef4ff; color: #4f6ef7; }
.badge.expired { background: #fef2f2; color: #dc2626; }
.badge.warning { background: #fffbeb; color: #d97706; }

/* ===== 操作按钮 ===== */
.action-btns { display: flex; gap: 8px; }

.action-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.15s;
}

.action-btn:hover { border-color: var(--primary); color: var(--primary); }
.action-btn.danger:hover { border-color: var(--danger); color: var(--danger); background: #fef2f2; }
.action-btn.warning:hover { border-color: #d97706; color: #d97706; background: #fffbeb; }
.action-btn.success:hover { border-color: #059669; color: #059669; background: #ecfdf5; }
.action-btn svg { width: 16px; height: 16px; }

/* ===== 分页 ===== */
.pagination { display: flex; justify-content: center; gap: 6px; padding: 24px; }

.pagination button {
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
}

.pagination button:hover:not(:disabled):not(.active) { border-color: var(--primary); color: var(--primary); }
.pagination button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== 弹窗 ===== */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.4); }

.modal-content {
    position: relative;
    background: var(--bg-white);
    border-radius: 16px;
    width: 100%;
    max-width: 460px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    animation: modalIn 0.2s ease;
}

.modal-small { max-width: 400px; }

@keyframes modalIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 18px; font-weight: 600; }

.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    border-radius: 8px;
}

.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-close svg { width: 20px; height: 20px; }
.modal-content form { padding: 24px; }
.modal-content > p { padding: 24px; color: var(--text-light); }
.modal-footer { display: flex; justify-content: flex-end; gap: 12px; padding-top: 8px; }

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    padding: 14px 24px;
    background: var(--bg-dark);
    color: #fff;
    border-radius: 10px;
    font-size: 14px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    z-index: 2000;
    animation: toastIn 0.25s ease;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(12px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ===== 空状态 ===== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-light); }
.empty-state svg { width: 56px; height: 56px; margin-bottom: 16px; opacity: 0.3; }
.empty-state p { font-size: 15px; }

/* ===== 设置页 ===== */
.settings-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.settings-card {
    background: var(--bg-white);
    border-radius: 14px;
    padding: 28px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.settings-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.settings-card > p {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 24px;
}

.settings-card .form-group { margin-bottom: 18px; }
.settings-card .btn { margin-top: 8px; }

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.info-row:last-child { border-bottom: none; }

.info-label {
    color: var(--text-light);
    font-size: 14px;
}

.info-value {
    font-size: 14px;
    font-weight: 500;
}

.api-copy-row {
    margin-top: 16px;
}

.api-label {
    display: block;
    color: var(--text-light);
    font-size: 13px;
    margin-bottom: 8px;
}

.api-value-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
}

.api-value {
    flex: 1;
    font-family: monospace;
    font-size: 14px;
    color: var(--primary);
    word-break: break-all;
    user-select: text;
}

.api-input {
    flex: 1;
    font-family: monospace;
    font-size: 14px;
    color: var(--text);
    background: transparent;
    border: none;
    outline: none;
    padding: 0;
}

.btn-copy {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-copy:hover {
    background: var(--primary-dark);
}

.btn-copy svg {
    width: 14px;
    height: 14px;
}

/* ===== 响应式设计 ===== */

/* 移动端菜单按钮 */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1001;
    width: 44px;
    height: 44px;
    background: var(--bg-dark);
    border: none;
    border-radius: 12px;
    color: #fff;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.mobile-menu-btn svg { width: 22px; height: 22px; }

/* 侧边栏遮罩层 */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

/* 大屏幕 */
@media (min-width: 1201px) {
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

/* 中等屏幕 */
@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .settings-container { grid-template-columns: 1fr; }
}

/* 平板 */
@media (max-width: 900px) {
    .login-left { display: none; }
    .login-right { width: 100%; padding: 40px 30px; }
    
    .sidebar { 
        width: 260px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 100;
    }
    
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    
    .mobile-menu-btn { display: flex; }
    
    .main-content { 
        margin-left: 0; 
        padding: 80px 20px 20px;
    }
    
    .main-content::before { left: 0; }
    
    .stats-grid { grid-template-columns: 1fr; gap: 16px; }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .page-header h2 { font-size: 20px; }
    
    /* 表格响应式 */
    .table-container { overflow-x: auto; }
    
    .data-table th, .data-table td { 
        padding: 12px;
        white-space: nowrap;
        min-width: 100px;
    }
    
    .data-table th:first-child,
    .data-table td:first-child { 
        position: sticky; 
        left: 0; 
        background: var(--bg-white);
        z-index: 1;
    }
    
    .action-btns { flex-wrap: wrap; gap: 6px; }
    
    /* 弹窗适配 */
    .modal { padding: 16px; }
    .modal-content { max-width: 100%; border-radius: 12px; }
    .modal-header { padding: 20px; }
    .modal-content form { padding: 20px; }
    .form-row { grid-template-columns: 1fr; }
    
    /* 设置页 */
    .settings-card { padding: 20px; }
    .api-value-box { flex-direction: column; gap: 12px; align-items: stretch; }
    .btn-copy { justify-content: center; }
}

/* 小屏手机 */
@media (max-width: 480px) {
    .login-right { padding: 30px 20px; }
    .login-form-title { font-size: 20px; }
    
    .form-group input { padding: 14px 12px; font-size: 16px; }
    
    .btn { padding: 14px 20px; font-size: 15px; }
    
    .main-content { padding: 70px 16px 16px; }
    
    .stat-card { padding: 18px; gap: 14px; }
    .stat-icon { width: 46px; height: 46px; }
    .stat-icon svg { width: 20px; height: 20px; }
    .stat-value { font-size: 24px; }
    .stat-label { font-size: 13px; }
    
    .data-table th, .data-table td { 
        padding: 10px 8px;
        font-size: 13px;
    }
    
    .badge { padding: 4px 10px; font-size: 11px; }
    
    .action-btn { width: 32px; height: 32px; }
    .action-btn svg { width: 14px; height: 14px; }
    
    .pagination { gap: 4px; padding: 16px; }
    .pagination button { min-width: 32px; height: 32px; font-size: 13px; }
    
    .modal-header h3 { font-size: 16px; }
    .modal-close { width: 32px; height: 32px; }
    
    .settings-card h3 { font-size: 16px; }
    
    .toast { 
        left: 16px; 
        right: 16px; 
        transform: none;
        text-align: center;
    }
    
    @keyframes toastIn { 
        from { opacity: 0; transform: translateY(12px); } 
        to { opacity: 1; transform: translateY(0); } 
    }
}

/* 触摸设备优化 */
@media (hover: none) {
    .btn:active { transform: scale(0.98); }
    .nav-item:active { background: rgba(255,255,255,0.08); }
    .action-btn:active { transform: scale(0.95); }
    
    /* 增大触摸目标 */
    .nav-item { min-height: 48px; }
    .action-btn { min-width: 44px; min-height: 44px; }
}
