*, *::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: #12141C;
    --bg-white: #1A1D29;
    --bg-dark: #0E1018;
    --border: #2A2D3E;
    --border-dark: #3A3D4E;
    --primary: #C9A84C;
    --primary-light: rgba(201,168,76,0.1);
    --primary-dark: #A07C2A;
    --text: #F0ECE0;
    --text-light: #8A8D9E;
    --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;
    background: radial-gradient(ellipse at center, #1E2030 0%, #0E1018 70%);
}

.login-video {
    display: none;
}

.login-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 40%, rgba(201,168,76,0.08) 0%, transparent 60%);
    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(201,168,76,0.4), 0 0 30px rgba(201,168,76,0.2);
    border: 2px solid rgba(201,168,76,0.3);
}

.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(201,168,76,0.3);
    letter-spacing: 4px;
    color: #C9A84C;
}

.login-brand p {
    font-size: 18px;
    opacity: 0.8;
    text-shadow: 0 0 15px rgba(0,0,0,0.8);
    letter-spacing: 2px;
    color: #8A8D9E;
}

.login-right {
    width: 480px;
    background: #1A1D29;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 60px;
    position: relative;
    border-left: 1px solid var(--border);
}

.login-right::before {
    display: none;
}

.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-light);
    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: #555869; }

.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: #12141C; font-weight: 600; }
.btn-primary:hover { background: #D4B85A; }
.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: rgba(255,255,255,0.05); }
.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: var(--primary);
    background: var(--primary-light);
}

.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;
    border-right: 1px solid var(--border);
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.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: var(--primary);
    line-height: 1.3;
}

.brand-slogan {
    font-size: 11px;
    color: #5A5D6E;
    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: #4A4D5E;
    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: var(--primary-light);
}

.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); }

.user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(201,168,76,0.06);
    border-radius: 10px;
    margin-bottom: 12px;
    border: 1px solid rgba(201,168,76,0.1);
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #12141C;
    font-weight: 600;
    font-size: 14px;
}

.user-card span { color: var(--text); 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: var(--bg);
    position: relative;
}

.main-content::before {
    display: none;
}

.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; color: var(--text); }

.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;
    border: 1px solid var(--border);
}

.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: rgba(201,168,76,0.12); color: #C9A84C; }
.stat-icon.green { background: rgba(16,185,129,0.12); color: #10b981; }
.stat-icon.purple { background: rgba(139,92,246,0.12); color: #8b5cf6; }
.stat-icon.orange { background: rgba(245,158,11,0.12); color: #f59e0b; }

.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.2; color: var(--text); }
.stat-label { font-size: 14px; color: var(--text-light); margin-top: 4px; }

/* ===== 表格 ===== */
.table-container {
    background: var(--bg-white);
    border-radius: 14px;
    border: 1px solid var(--border);
    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-dark);
    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;
    color: var(--text);
}

.data-table tbody tr:hover { background: rgba(201,168,76,0.04); }

.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: rgba(16,185,129,0.15); color: #34d399; }
.badge.disabled, .badge.offline { background: rgba(107,114,128,0.15); color: #9ca3af; }
.badge.admin { background: rgba(201,168,76,0.15); color: #C9A84C; }
.badge.user { background: rgba(99,102,241,0.15); color: #818cf8; }
.badge.expired { background: rgba(239,68,68,0.15); color: #f87171; }
.badge.warning { background: rgba(245,158,11,0.15); color: #fbbf24; }

/* ===== 操作按钮 ===== */
.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); background: var(--primary-light); }
.action-btn.danger:hover { border-color: var(--danger); color: #f87171; background: rgba(239,68,68,0.1); }
.action-btn.warning:hover { border-color: #d97706; color: #fbbf24; background: rgba(245,158,11,0.1); }
.action-btn.success:hover { border-color: #059669; color: #34d399; background: rgba(16,185,129,0.1); }
.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: #12141C; }
.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.6); }

.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.4);
    border: 1px solid var(--border);
    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; color: var(--text); }

.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: rgba(255,255,255,0.05); 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: #252840;
    color: var(--text);
    border-radius: 10px;
    font-size: 14px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
    z-index: 2000;
    border: 1px solid var(--border);
    animation: toastIn 0.25s ease;
}

.toast.success { background: var(--success); color: #fff; border-color: var(--success); }
.toast.error { background: var(--danger); color: #fff; border-color: 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;
    border: 1px solid var(--border);
}

.settings-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.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; color: var(--text); }

.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: #12141C;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-copy:hover { background: #D4B85A; }
.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: 1px solid var(--border);
    border-radius: 12px;
    color: var(--primary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.mobile-menu-btn svg { width: 22px; height: 22px; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    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;
    }

    .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; }
}
