:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a1f2e;
    --bg-sidebar: #0d1321;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.3);
    --accent-secondary: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border: #1e293b;
    --border-light: #334155;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.6);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* 粒子背景 */
.particles-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.35;
}
.particle {
    position: absolute;
    border-radius: 50%;
    background: var(--accent);
    animation: floatUp linear infinite;
}
@keyframes floatUp {
    0% { transform: translateY(100vh) scale(0); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 0.6; }
    100% { transform: translateY(-10vh) scale(1.2); opacity: 0; }
}

/* 加载界面 */
.loading-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--bg-primary);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}
.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.loading-ring {
    width: 80px; height: 80px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, var(--accent), var(--accent-secondary), var(--accent), transparent 60%);
    animation: spinRing 1.2s linear infinite;
    position: relative;
}
.loading-ring::before {
    content: '';
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    background: var(--bg-primary);
}
.loading-ring::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, var(--accent), transparent 70%);
    filter: blur(12px);
    animation: spinRing 1.2s linear infinite;
    z-index: -1;
}
@keyframes spinRing { to { transform: rotate(360deg); } }
.loading-text {
    margin-top: 32px;
    font-size: 15px;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    animation: pulseText 1.8s ease-in-out infinite;
}
@keyframes pulseText {
    0%,100% { opacity: 0.5; }
    50% { opacity: 1; }
}
.loading-dots::after {
    content: '';
    animation: dots 1.6s steps(4, end) infinite;
}
@keyframes dots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
    100% { content: ''; }
}

/* 登录界面 */
.login-container {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 8888;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #111827 0%, #0a0e17 70%);
    transition: opacity 0.5s ease, visibility 0.5s ease;
}
.login-container.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 48px 40px;
    width: 420px;
    max-width: 92vw;
    box-shadow: var(--shadow-lg), 0 0 60px var(--accent-glow);
    position: relative;
    z-index: 1;
    backdrop-filter: blur(10px);
}
.login-card::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 20px;
    padding: 1px;
    background: linear-gradient(135deg, var(--accent), transparent 40%, var(--accent-secondary));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}
.login-icon {
    width: 56px; height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    font-size: 26px;
    box-shadow: 0 0 30px var(--accent-glow);
}
.login-title {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.02em;
    margin-bottom: 6px;
}
.login-subtitle {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 32px;
}
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}
.form-group input {
    width: 100%;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 15px;
    transition: var(--transition);
    outline: none;
    font-family: inherit;
}
.form-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-group input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-login {
    width: 100%;
    padding: 14px;
    border-radius: var(--radius-sm);
    border: none;
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.03em;
    transition: var(--transition);
    font-family: inherit;
}
.btn-login:hover {
    box-shadow: 0 0 24px var(--accent-glow);
    transform: translateY(-1px);
}
.btn-login:active { transform: scale(0.98); }
.login-error {
    text-align: center;
    color: var(--danger);
    font-size: 13px;
    margin-top: 12px;
    min-height: 20px;
}

/* 仪表盘主容器 */
.app-container {
    display: none;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}
.app-container.active { display: flex; }

/* 侧边栏 */
.sidebar {
    width: 240px;
    min-width: 240px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 10;
}
.sidebar-logo {
    padding: 0 20px 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    gap: 10px;
}
.logo-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
    animation: pulseDot 2s ease-in-out infinite;
}
@keyframes pulseDot {
    0%,100% { box-shadow: 0 0 10px var(--accent); }
    50% { box-shadow: 0 0 22px var(--accent), 0 0 40px var(--accent-glow); }
}
.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 12px;
}
.nav-item {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid transparent;
}
.nav-item:hover {
    background: rgba(255,255,255,0.03);
    color: var(--text-primary);
}
.nav-item.active {
    background: rgba(59,130,246,0.12);
    color: var(--accent);
    border-color: rgba(59,130,246,0.3);
    box-shadow: 0 0 16px rgba(59,130,246,0.08);
}
.nav-item.locked {
    opacity: 0.45;
    cursor: not-allowed;
}
.nav-icon { width: 20px; text-align: center; font-size: 15px; }
.nav-lock { margin-left: auto; font-size: 11px; opacity: 0.6; }
.sidebar-footer {
    padding: 16px 20px 0;
    border-top: 1px solid var(--border);
    margin-top: auto;
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}
.status-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

/* 主内容区 */
.main-content {
    flex: 1;
    padding: 28px 32px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.page-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.02em;
    margin-bottom: 4px;
}
.page-breadcrumb { font-size: 12px; color: var(--text-muted); }

.top-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}
.card:hover { border-color: var(--border-light); }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.indicator {
    width: 8px; height: 8px;
    border-radius: 50%;
}
.indicator.green { background: var(--success); box-shadow: 0 0 8px var(--success); }
.indicator.blue { background: var(--accent); box-shadow: 0 0 8px var(--accent); }

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 14px;
}
.info-row:last-of-type { border-bottom: none; }
.info-label { color: var(--text-muted); font-size: 13px; }
.info-value {
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}
.info-value.highlight { color: var(--accent); font-size: 18px; }

.btn-group {
    display: flex;
    gap: 12px;
    margin-top: 18px;
    flex-wrap: wrap; /* 允许按钮在窄屏换行 */
}
.btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
    font-family: inherit;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.btn:hover {
    border-color: var(--accent);
    background: rgba(59,130,246,0.08);
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent), #2563eb);
    border: none;
    color: #fff;
    font-weight: 600;
}
.btn-primary:hover { box-shadow: 0 0 20px var(--accent-glow); }
.btn-warning {
    background: linear-gradient(135deg, #d97706, #b45309);
    border: none;
    color: #fff;
    font-weight: 600;
}
.btn-warning:hover { box-shadow: 0 0 20px rgba(245,158,11,0.3); }

.bottom-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.chart-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.chart-tab {
    padding: 7px 16px;
    border-radius: 20px;
    border: 1px solid var(--border-light);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: var(--transition);
    font-family: inherit;
}
.chart-tab:hover { border-color: var(--accent); color: var(--text-primary); }
.chart-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.chart-wrapper {
    position: relative;
    width: 100%;
    height: 300px;
}
.chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

.table-scroll {
    max-height: 340px;
    overflow-y: auto;
    overflow-x: auto; /* 手机端表格可横向滚动 */
    -webkit-overflow-scrolling: touch;
}
.revenue-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 13px;
    min-width: 300px; /* 保证表格最小宽度，防止过度挤压 */
}
.revenue-table th {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.revenue-table td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    color: var(--text-primary);
}
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
}
.badge-success { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-pending { background: rgba(148,163,184,0.15); color: var(--text-muted); }

/* 模态框 */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-dialog {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    width: 400px;
    max-width: 92vw;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 16px; }
.modal-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 16px;
    outline: none;
    font-family: inherit;
}
.modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; }
.result-dialog { text-align: center; padding: 20px 0; }
.result-icon { font-size: 48px; margin-bottom: 16px; }
.result-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.result-message { font-size: 13px; color: var(--text-secondary); line-height: 1.6; }

/* Toast */
.toast {
    position: fixed;
    top: 24px; right: 24px;
    z-index: 10001;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 90vw;
}
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast.error { border-left: 3px solid var(--danger); }
.toast.success { border-left: 3px solid var(--success); }

/* ========== 响应式设计 ========== */
@media (max-width: 900px) {
    .top-cards {
        grid-template-columns: 1fr;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .sidebar {
        width: 200px;
        min-width: 200px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 60px;
        min-width: 60px;
        padding: 16px 0;
    }
    .sidebar-logo {
        justify-content: center;
        padding: 0 8px 16px;
        font-size: 0;
    }
    .sidebar-logo .logo-dot {
        margin: 0;
    }
    .nav-item span:not(.nav-icon) {
        display: none;
    }
    .nav-item {
        justify-content: center;
        padding: 14px;
    }
    .nav-lock {
        display: none;
    }
    .sidebar-footer {
        justify-content: center;
        font-size: 0;
    }
    .main-content {
        padding: 16px;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .chart-wrapper {
        height: 250px; /* 手机端图表高度适当缩小 */
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 32px 20px;
    }
    .login-title {
        font-size: 20px;
    }
    .login-subtitle {
        font-size: 12px;
        margin-bottom: 24px;
    }
    .form-group input {
        padding: 12px 14px;
    }
    .btn-login {
        padding: 12px;
    }
    .page-title {
        font-size: 18px;
    }
    .card {
        padding: 16px;
    }
    .bottom-card {
        padding: 16px;
    }
    .btn {
        padding: 8px 14px;
        font-size: 12px;
    }
    .toast {
        top: 12px;
        right: 12px;
        left: 12px;
        max-width: none;
    }
}