/* ============================================
 * Dashboard 主样式表
 * 从 dashboard.html 内联样式抽取
 * v3.8.0 — 2026-02-16
 * ============================================ */

/* === 基础变量和全局样式 === */
:root {
    --bg-dark: #0b1120;
    --card-bg: rgba(15, 23, 42, 0.9);
    --card-border: rgba(148, 163, 184, 0.08);
    --card-hover: rgba(30, 41, 59, 0.85);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --accent: #38bdf8;
    --accent-purple: #6366f1;
    --accent-blue: #1d4ed8;
    --positive: #4ade80;
    --negative: #f87171;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: radial-gradient(circle at top, var(--accent-blue) 0%, var(--bg-dark) 40%);
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-primary);
    min-height: 100vh;
}

/* === 导航栏 === */
.nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 40px;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 20px;
    color: var(--text-primary);
    text-decoration: none;
}

.nav-brand span {
    font-size: 14px;
    color: var(--text-secondary);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 18px;
}

.nav-time {
    font-size: 14px;
    color: var(--text-secondary);
}

.refresh-btn {
    background: linear-gradient(135deg, var(--accent), var(--accent-purple));
    color: var(--bg-dark);
    border: none;
    padding: 10px 18px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.refresh-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(99, 102, 241, 0.45);
}

/* === 布局容器 === */
.dashboard-wrapper {
    max-width: 1320px;
    margin: 0 auto;
    padding: 30px 40px 60px;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 20px;
    margin-bottom: 28px;
}

.header-row h1 {
    margin: 0;
    font-size: 30px;
    font-weight: 600;
}

.header-row p {
    margin: 6px 0 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.auto-refresh {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* === 指标卡片 === */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 28px;
}

.metric-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 18px;
    padding: 18px 20px;
    transition: background 0.2s ease, transform 0.2s ease;
    position: relative;
    overflow: hidden;
}

.metric-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.08), rgba(99, 102, 241, 0.05));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
}

.metric-card:hover::after {
    opacity: 1;
}

.metric-label {
    color: var(--text-secondary);
    font-size: 13px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.summary-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.metric-value {
    margin-top: 10px;
    font-size: 30px;
    font-weight: 600;
    color: var(--text-primary);
}

.metric-sub {
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* === 面板布局 === */
.layout-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.panel {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(8px);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.panel-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

.time-switch {
    display: flex;
    gap: 10px;
}

.inline-switch {
    display: inline-flex;
    gap: 8px;
}

.table-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.filter-group {
    display: flex;
    gap: 10px;
}

.filter-group input,
.filter-group select {
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 10px;
    padding: 8px 12px;
    color: var(--text-primary);
}

.pagination {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pagination button,
.export-btn {
    background: rgba(56, 189, 248, 0.18);
    border: 1px solid rgba(56, 189, 248, 0.4);
    color: var(--text-primary);
    border-radius: 10px;
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination button:hover,
.export-btn:hover {
    background: rgba(56, 189, 248, 0.3);
}

/* === 时间芯片和图表区域 === */
.time-chip {
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-secondary);
    border-radius: 18px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 52px;
    letter-spacing: 0.03em;
}

.time-chip .period-number {
    font-size: 16px;
    font-weight: 600;
    line-height: 18px;
}

.time-chip .period-unit {
    font-size: 12px;
    line-height: 14px;
}

.time-chip.active {
    border-color: transparent;
    color: var(--bg-dark);
    background: linear-gradient(135deg, var(--accent), var(--accent-purple));
    box-shadow: 0 12px 24px rgba(99, 102, 241, 0.35);
    transform: translateY(-1px);
}

.chart-area {
    position: relative;
    height: 380px;
}

/* === 表格基础样式 === */
.table-wrapper {
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.12);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: rgba(148, 163, 184, 0.08);
}

th, td {
    padding: 14px 16px;
    font-size: 13px;
    text-align: left;
    color: var(--text-secondary);
}

th {
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

tbody tr {
    transition: background 0.2s ease;
    border-bottom: 1px solid rgba(148, 163, 184, 0.06);
}

tbody tr:hover {
    background: rgba(56, 189, 248, 0.05);
}

tbody td.positive {
    color: var(--positive);
}

tbody td.negative {
    color: var(--negative);
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    background: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
}

.tag.long {
    background: rgba(74, 222, 128, 0.12);
    color: var(--positive);
}

.tag.short {
    background: rgba(248, 113, 113, 0.12);
    color: var(--negative);
}

/* === v3.4.0: Performance Scorer 平仓过程标签 === */
.tag.tp1 {
    background: rgba(74, 222, 128, 0.15);
    color: #86efac;
}
.tag.tp2 {
    background: rgba(74, 222, 128, 0.25);
    color: #4ade80;
}
.tag.tp3 {
    background: rgba(34, 197, 94, 0.35);
    color: #22c55e;
}
.tag.tp4 {
    background: rgba(22, 163, 74, 0.6);
    color: #ffffff;
    font-weight: 600;
}

/* v3.4.5: TP+止损组合类型 */
.tag.tp1-sl {
    background: rgba(251, 191, 36, 0.15);
    color: #fcd34d;
}
.tag.tp2-sl {
    background: rgba(163, 230, 53, 0.2);
    color: #a3e635;
}
.tag.tp3-sl {
    background: rgba(74, 222, 128, 0.25);
    color: #4ade80;
}

/* v3.4.6: 保本止损和完全止损 */
.tag.be-sl {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}
.tag.full-sl {
    background: rgba(248, 113, 113, 0.25);
    color: #f87171;
    font-weight: 600;
}
.tag.sl {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}
.tag.only-sl {
    background: rgba(248, 113, 113, 0.2);
    color: #f87171;
}
.tag.manual {
    background: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
}
.tag.unknown {
    background: rgba(148, 163, 184, 0.1);
    color: #64748b;
}

/* === 分数显示样式（v3.4.0 / v3.5.8 扩展） === */
.score {
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}
.score.neutral {
    background: rgba(100, 116, 139, 0.2);
    color: #94a3b8;
}
/* 负分区: 5个层级 (danger5最深 → warning最浅) */
.score.danger5 {
    background: rgba(220, 38, 38, 0.3);
    color: #dc2626;  /* 深红 -70以下 */
}
.score.danger4 {
    background: rgba(239, 68, 68, 0.25);
    color: #ef4444;  /* 红 -50~-70 */
}
.score.danger3 {
    background: rgba(248, 113, 113, 0.2);
    color: #f87171;  /* 浅红 -30~-50 */
}
.score.danger {
    background: rgba(248, 113, 113, 0.2);
    color: #f87171;  /* 兼容旧版 */
}
.score.warning {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;  /* 橙黄 -10~-30 */
}
/* 正分区: 4个层级 (good1最浅 → good4最深) */
.score.good1 {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;  /* 浅绿 10~30 */
}
.score.good2 {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;  /* 绿 30~50 */
}
.score.good3 {
    background: rgba(16, 185, 129, 0.25);
    color: #10b981;  /* 翠绿 50~70 */
}
.score.good4 {
    background: rgba(5, 150, 105, 0.3);
    color: #059669;  /* 深绿 70以上 */
}
.score.good {
    background: rgba(74, 222, 128, 0.2);
    color: #4ade80;  /* 兼容旧版 */
}

.neutral {
    color: #64748b;
}

/* === v3.4.9: 分数变化带框样式 === */
.score-change {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
    min-width: 32px;
    text-align: center;
}
.score-change.positive {
    background: rgba(74, 222, 128, 0.15);
    border: 1px solid rgba(74, 222, 128, 0.4);
    color: #4ade80;
}
.score-change.negative {
    background: rgba(248, 113, 113, 0.15);
    border: 1px solid rgba(248, 113, 113, 0.4);
    color: #f87171;
}
.score-change.neutral {
    background: rgba(100, 116, 139, 0.15);
    border: 1px solid rgba(100, 116, 139, 0.4);
    color: #64748b;
}

/* === v3.3.13: PENDING_PNL 获取中状态 === */
tbody td.pending {
    color: #f59e0b;
    font-style: italic;
}

tbody tr.pending-row {
    background: rgba(245, 158, 11, 0.05);
}

tbody tr.pending-row:hover {
    background: rgba(245, 158, 11, 0.1);
}

.pending {
    color: #f59e0b;
    font-style: italic;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* === v2.14.0: 入场指标徽章 === */
.indicators-badge {
    display: inline-block;
    font-size: 11px;
    padding: 2px 6px;
    background: rgba(148, 163, 184, 0.15);
    border-radius: 4px;
    color: var(--text-secondary);
    font-family: 'Consolas', 'Monaco', monospace;
    white-space: nowrap;
}

/* v3.2.0: 12个入场指标单行横向显示，固定宽度对齐 */
.ind-grid {
    display: inline-flex;
    flex-wrap: nowrap;
    gap: 0;
    font-size: 11px;
    font-family: 'Consolas', 'Monaco', monospace;
    white-space: nowrap;
}
.ind-i {
    display: inline-block;
    width: 90px;
    color: var(--text-secondary);
    white-space: nowrap;
}
.ind-i b {
    color: var(--text-primary);
    font-weight: 600;
    margin-left: 1px;
}

/* v3.4.0: 第二行指标行样式 */
.indicator-row {
    background: rgba(30, 41, 59, 0.3) !important;
}
.indicator-row:hover {
    background: rgba(30, 41, 59, 0.5) !important;
}
.indicator-cell {
    padding: 5px 12px !important;
    white-space: nowrap;
}
.indicator-label {
    color: var(--text-secondary);
    margin-right: 6px;
    font-size: 11px;
}
.position-history-table tbody tr.main-row td {
    border-bottom: none;
}
.position-history-table tbody tr.indicator-row td {
    border-bottom: 1px solid var(--card-border);
}

/* === 小卡片 === */
.mini-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.mini-card {
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(148, 163, 184, 0.08);
    border-radius: 14px;
    padding: 12px 14px;
}

.mini-card .label {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.06em;
}

.mini-card .amount {
    margin-top: 6px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(148, 163, 184, 0.15);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 10px;
}

.progress-bar span {
    display: block;
    height: 100%;
    background: linear-gradient(135deg, var(--accent), var(--accent-purple));
    border-radius: 999px;
}

.empty-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-secondary);
}

/* === 响应式布局 === */
@media (max-width: 1200px) {
    .layout-grid {
        grid-template-columns: 1fr;
    }
    .metrics-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .nav-bar {
        flex-wrap: wrap;
        gap: 16px;
        padding: 16px 20px;
    }
    .nav-brand span {
        display: none; /* 隐藏副标题节省空间 */
    }
    .dashboard-wrapper {
        padding: 16px 12px 50px;
    }
    .header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr); /* 2列布局 */
        gap: 12px;
    }
    .metric-card {
        padding: 14px;
    }
    .metric-card .label {
        font-size: 11px;
    }
    .metric-card .value {
        font-size: 18px;
    }
    .panel {
        padding: 14px;
        border-radius: 12px;
    }
    .panel-title {
        font-size: 14px;
    }
    .chart-area {
        height: 240px;
    }
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    table {
        font-size: 12px;
        min-width: 600px;
    }
    .filter-bar {
        flex-direction: column;
        gap: 10px;
    }
    .filter-bar select,
    .filter-bar input {
        width: 100%;
    }
}

/* 超小屏幕适配 */
@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr; /* 单列 */
    }
    .nav-actions {
        flex-wrap: wrap;
        gap: 8px;
    }
    .chart-tabs .tab {
        padding: 6px 10px;
        font-size: 11px;
    }
}

/* === 系统监控面板 === */
.system-monitor-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 16px;
}

.monitor-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 16px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.monitor-card:hover {
    transform: translateY(-2px);
    border-color: rgba(148, 163, 184, 0.18);
}

.monitor-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.monitor-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-healthy { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.status-degraded { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.status-unhealthy { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.status-unknown { background: rgba(107, 114, 128, 0.2); color: #6b7280; }

.monitor-stat {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--card-border);
    font-size: 13px;
}

.monitor-stat:last-child { border-bottom: none; }
.monitor-stat-label { color: var(--text-secondary); }
.monitor-stat-value { color: var(--text-primary); font-weight: 500; }

.rate-bar {
    height: 6px;
    background: var(--card-border);
    border-radius: 3px;
    margin-top: 8px;
    overflow: hidden;
}

.rate-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.rate-bar-fill.low { background: #10b981; }
.rate-bar-fill.medium { background: #f59e0b; }
.rate-bar-fill.high { background: #ef4444; }

@media (max-width: 1024px) {
    .system-monitor-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .system-monitor-grid {
        grid-template-columns: 1fr;
    }
}

/* === 趋势过滤器历史列表 === */
.filter-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 4px;
}
.filter-history-list::-webkit-scrollbar {
    width: 4px;
}
.filter-history-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
}
.filter-history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: rgba(255,255,255,0.04);
    border-radius: 8px;
    font-size: 0.85rem;
    transition: background 0.2s;
}
.filter-history-item:hover {
    background: rgba(255,255,255,0.08);
}
.filter-history-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}
.filter-history-type {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}
.filter-history-detail {
    flex: 1;
    color: var(--text-secondary);
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.filter-history-time {
    color: #64748b;
    font-size: 0.75rem;
    white-space: nowrap;
    flex-shrink: 0;
}

/* === v3.8.2: 连接状态指示器 === */
.conn-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-left: 8px;
    vertical-align: middle;
    transition: background 0.3s ease;
}
.conn-online { background: var(--positive); box-shadow: 0 0 6px rgba(74,222,128,0.6); }
.conn-degraded { background: #fbbf24; box-shadow: 0 0 6px rgba(251,191,36,0.6); }
.conn-offline { background: var(--negative); box-shadow: 0 0 6px rgba(248,113,113,0.6); animation: pulse 1.5s infinite; }

/* === v3.8.2: 持仓盈亏闪烁动画 === */
@keyframes flashGreen {
    0% { background: transparent; }
    30% { background: rgba(74, 222, 128, 0.25); }
    100% { background: transparent; }
}
@keyframes flashRed {
    0% { background: transparent; }
    30% { background: rgba(248, 113, 113, 0.25); }
    100% { background: transparent; }
}
td.flash-green { animation: flashGreen 1.2s ease-out; }
td.flash-red { animation: flashRed 1.2s ease-out; }

/* === v3.8.2: 刷新倒计时进度条 === */
.refresh-progress-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}
.refresh-progress {
    width: 120px;
    height: 4px;
    background: rgba(148, 163, 184, 0.15);
    border-radius: 2px;
    overflow: hidden;
}
.refresh-progress-fill {
    height: 100%;
    background: linear-gradient(135deg, var(--accent), var(--accent-purple));
    border-radius: 2px;
    transition: width 1s linear;
}

/* === v3.8.2: 盈亏日历热力图 === */
.heatmap-grid {
    display: flex;
    gap: 3px;
    overflow-x: auto;
    padding-bottom: 8px;
}
.heatmap-grid::-webkit-scrollbar { height: 4px; }
.heatmap-grid::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
.heatmap-week-labels {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex-shrink: 0;
}
.heatmap-wlabel {
    width: 20px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--text-secondary);
}
.heatmap-week {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.heatmap-cell {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    position: relative;
    cursor: default;
    transition: transform 0.15s;
}
.heatmap-cell:hover {
    transform: scale(1.4);
    z-index: 2;
}
.heatmap-cell.empty {
    background: transparent !important;
}
.heatmap-cell .heatmap-date {
    display: none;
}
.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    font-size: 11px;
    color: var(--text-secondary);
}
.heatmap-legend-bar {
    width: 120px;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--negative) 0%, rgba(148,163,184,0.2) 50%, var(--positive) 100%);
}
