/* ===== 全局变量 ===== */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d28;
    --bg-card: #1e2230;
    --bg-hover: #252a3a;
    --border: #2d3142;
    --text-primary: #e4e6eb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --gold: #f0b90b;
    --gold-light: #fcd535;
    --gold-dark: #d4a017;
    --green: #2ecc71;
    --red: #e74c3c;
    --blue: #3b82f6;
    --purple: #8b5cf6;
    --radius: 10px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* ===== Reset ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
}
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== 登录页 ===== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f1117 0%, #1a1d28 50%, #0f1117 100%);
}
.login-container { width: 100%; max-width: 400px; padding: 20px; }
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px 32px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-logo {
    width: 64px; height: 64px;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; font-weight: 800; color: #000;
    margin: 0 auto 16px;
}
.login-header h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-header p { font-size: 12px; color: var(--text-muted); }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 500; }
.form-group input {
    width: 100%; padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 15px;
    transition: border-color 0.2s;
}
.form-group input:focus { outline: none; border-color: var(--gold); }
.login-error {
    background: rgba(231,76,60,0.15);
    border: 1px solid rgba(231,76,60,0.3);
    color: var(--red);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}
.login-btn {
    width: 100%; padding: 14px;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    color: #000; font-weight: 700; font-size: 16px;
    border: none; border-radius: 8px; cursor: pointer;
    transition: opacity 0.2s;
}
.login-btn:hover { opacity: 0.9; }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.login-footer { text-align: center; margin-top: 24px; font-size: 12px; color: var(--text-muted); }

/* ===== 布局 ===== */
.layout { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
    width: 220px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}
.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px;
}
.sidebar-logo {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 800; color: #000;
}
.sidebar-title { font-size: 15px; font-weight: 700; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 20px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.nav-item.active {
    background: var(--bg-hover);
    color: var(--gold);
    border-left-color: var(--gold);
}
.nav-icon { width: 20px; text-align: center; font-size: 16px; }
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    font-size: 12px;
}
.sidebar-user { color: var(--text-secondary); margin-bottom: 8px; }
.logout-btn {
    color: var(--red);
    cursor: pointer;
    font-size: 13px;
}
.logout-btn:hover { text-decoration: underline; }

/* 主内容 */
.main-content {
    flex: 1;
    margin-left: 220px;
    padding: 24px 32px;
    min-width: 0;
}
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.page-header p { color: var(--text-muted); font-size: 13px; }

/* ===== 卡片 ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}
.card-title {
    font-size: 15px; font-weight: 600;
    margin-bottom: 16px;
    display: flex; align-items: center; justify-content: space-between;
}

/* 统计卡片网格 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: transform 0.15s, border-color 0.15s;
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--gold); }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 800; }
.stat-value.gold { color: var(--gold); }
.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }
.stat-value.blue { color: var(--blue); }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===== 表格 ===== */
.table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead { background: var(--bg-secondary); }
th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    white-space: nowrap;
}
tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child td { border-bottom: none; }

/* 标签/徽章 */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge-active { background: rgba(46,204,113,0.15); color: var(--green); }
.badge-triggered { background: rgba(240,185,11,0.15); color: var(--gold); }
.badge-deleted { background: rgba(231,76,60,0.15); color: var(--red); }
.badge-up, .badge-above { background: rgba(231,76,60,0.15); color: var(--red); }
.badge-down, .badge-below { background: rgba(46,204,113,0.15); color: var(--green); }
.badge-bullish { background: rgba(231,76,60,0.15); color: var(--red); }
.badge-bearish { background: rgba(46,204,113,0.15); color: var(--green); }
.badge-oscillate { background: rgba(139,92,246,0.15); color: var(--purple); }

/* 筛选栏 */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}
.filter-bar select, .filter-bar input {
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
}
.filter-bar select:focus, .filter-bar input:focus { outline: none; border-color: var(--gold); }
.filter-btn {
    padding: 8px 16px;
    background: var(--gold);
    color: #000;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.filter-btn:hover { opacity: 0.9; }

/* 分页 */
.pagination {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 20px;
    align-items: center;
}
.pagination button {
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
}
.pagination button:hover { border-color: var(--gold); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination button.current { background: var(--gold); color: #000; border-color: var(--gold); }
.pagination .page-info { color: var(--text-muted); font-size: 13px; margin: 0 8px; }

/* 进度条 */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 4px;
}
.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

/* 图表条 */
.bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.bar-label { width: 80px; font-size: 13px; color: var(--text-secondary); text-align: right; }
.bar-track { flex: 1; height: 24px; background: var(--bg-secondary); border-radius: 4px; overflow: hidden; position: relative; }
.bar-fill { height: 100%; border-radius: 4px; display: flex; align-items: center; padding-left: 8px; font-size: 12px; font-weight: 600; color: #000; }

/* 配置页 */
.config-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}
.config-item:last-child { border-bottom: none; }
.config-info { flex: 1; }
.config-key { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.config-desc { font-size: 12px; color: var(--text-muted); }
.config-value-wrap { display: flex; align-items: center; gap: 8px; }
.config-input {
    width: 360px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: monospace;
}
.config-save-btn {
    padding: 8px 16px;
    background: var(--gold);
    color: #000;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

/* Toast */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 9999;
    animation: slideIn 0.3s ease;
}
.toast-success { background: rgba(46,204,113,0.2); border: 1px solid var(--green); color: var(--green); }
.toast-error { background: rgba(231,76,60,0.2); border: 1px solid var(--red); color: var(--red); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* 加载中 */
.loading { text-align: center; padding: 40px; color: var(--text-muted); }
.loading-spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 两列布局 */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 768px) {
    .two-col { grid-template-columns: 1fr; }
    .sidebar { transform: translateX(-220px); }
    .main-content { margin-left: 0; }
}

/* 链接样式 */
.link { color: var(--gold); cursor: pointer; }
.link:hover { text-decoration: underline; }

/* 用户详情弹窗 */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 90%; max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 28px;
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.modal-close { float: right; cursor: pointer; color: var(--text-muted); font-size: 20px; }
