
/* ===== 全局 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, 'Microsoft YaHei', 'PingFang SC', sans-serif;
    background: #0d1117;
    color: #c9d1d9;
    min-height: 100vh;
}
a { color: #58a6ff; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== 布局 ===== */
.app-container { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
    width: 220px; background: #161b22;
    border-right: 1px solid #30363d;
    display: flex; flex-direction: column;
    padding: 16px 0;
    position: fixed; height: 100vh; overflow-y: auto;
    z-index: 100;
}
.sidebar-logo {
    padding: 12px 20px; font-size: 18px; font-weight: bold;
    color: #58a6ff; border-bottom: 1px solid #30363d; margin-bottom: 8px;
}
.sidebar-logo span { color: #f0883e; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px; color: #8b949e; cursor: pointer;
    transition: all 0.15s; font-size: 14px;
}
.nav-item:hover, .nav-item.active {
    color: #fff; background: rgba(56,139,253,0.1);
    border-right: 3px solid #58a6ff;
}
.nav-icon { font-size: 18px; width: 24px; text-align: center; }

/* 主内容区 */
.main-content { margin-left: 220px; flex: 1; padding: 24px; max-width: calc(100vw - 220px); }

/* ===== 卡片 ===== */
.card {
    background: #161b22; border: 1px solid #30363d;
    border-radius: 8px; padding: 20px; margin-bottom: 20px;
}
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid #21262d;
}
.card-title { font-size: 16px; font-weight: 600; color: #e6edf3; }
.card-badge {
    display: inline-block; padding: 2px 10px; border-radius: 12px;
    font-size: 12px; font-weight: 500;
}
.badge-green { background: rgba(35,134,54,0.3); color: #3fb950; }
.badge-red { background: rgba(218,54,51,0.3); color: #f85149; }
.badge-blue { background: rgba(56,139,253,0.15); color: #58a6ff; }
.badge-yellow { background: rgba(187,128,9,0.3); color: #d29922; }
.badge-gray { background: rgba(110,118,129,0.2); color: #8b949e; }

/* ===== 统计卡片网格 ===== */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px; margin-bottom: 24px;
}
.stat-card {
    background: linear-gradient(135deg, #1c2128 0%, #161b22 100%);
    border: 1px solid #30363d; border-radius: 10px; padding: 18px;
    position: relative; overflow: hidden;
}
.stat-card::after {
    content: ''; position: absolute; top: 0; right: 0;
    width: 80px; height: 80px; border-radius: 50%;
    opacity: 0.05;
}
.stat-card.profit::after { background: #3fb950; top: -20px; right: -20px; }
.stat-card.loss::after { background: #f85149; top: -20px; right: -20px; }
.stat-label { font-size: 13px; color: #8b949e; margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 700; }
.stat-value.up { color: #3fb950; }
.stat-value.down { color: #f85149; }
.stat-change { font-size: 12px; margin-top: 4px; }
.stat-change.up { color: #3fb950; }
.stat-change.down { color: #f85149; }

/* ===== 表格 ===== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    background: #21262d; color: #8b949e; font-size: 12px;
    font-weight: 500; text-align: left; padding: 10px 14px;
    border-bottom: 1px solid #30363d; white-space: nowrap;
}
.data-table td {
    padding: 11px 14px; border-bottom: 1px solid #21262d;
    font-size: 13px; vertical-align: middle;
}
.data-table tr:hover { background: rgba(56,139,253,0.04); }
.data-table .code-col { font-family: monospace; color: #58a6ff; font-weight: 600; }
.data-table .name-col { color: #e6edf3; }
.data-table .num-col { text-align: right; font-family: monospace; }
.data-table .up { color: #3fb950; }
.data-table .down { color: #f85149; }

/* ===== 按钮 ===== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 16px; border-radius: 6px; font-size: 13px;
    font-weight: 500; cursor: pointer; border: 1px solid transparent;
    transition: all 0.15s; white-space: nowrap;
}
.btn-primary { background: #238636; color: #fff; border-color: #238636; }
.btn-primary:hover { background: #2ea043; }
.btn-danger { background: #da3633; color: #fff; border-color: #da3633; }
.btn-danger:hover { background: #f85149; }
.btn-outline {
    background: transparent; color: #c9d1d9;
    border-color: #30363d;
}
.btn-outline:hover { background: rgba(240,246,252,0.06); border-color: #8b949e; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== Tab切换 ===== */
.tabs { display: flex; gap: 0; border-bottom: 1px solid #30363d; margin-bottom: 20px; }
.tab {
    padding: 10px 20px; font-size: 14px; color: #8b949e;
    cursor: pointer; border-bottom: 2px solid transparent;
    transition: all 0.15s; user-select: none;
}
.tab:hover { color: #c9d1d9; }
.tab.active { color: #58a6ff; border-bottom-color: #58a6ff; }

/* ===== 策略工坊 - 因子选择器 ===== */
.factor-panel {
    display: grid; grid-template-columns: 260px 1fr; gap: 20px;
}
.factor-category-list {
    background: #0d1117; border-radius: 8px;
    border: 1px solid #30363d; overflow: hidden;
}
.factor-cat-item {
    padding: 10px 16px; font-size: 13px; cursor: pointer;
    border-left: 3px solid transparent; transition: all 0.15s;
    display: flex; justify-content: space-between;
}
.factor-cat-item:hover { background: rgba(56,139,253,0.06); }
.factor-cat-item.active {
    background: rgba(56,139,253,0.1); border-left-color: #58a6ff; color: #58a6ff;
}
.factor-cat-count { font-size: 11px; color: #6e7681; }

.factor-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
}
.factor-chip {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 12px; background: #21262d; border: 1px solid #30363d;
    border-radius: 6px; font-size: 12px; cursor: pointer;
    transition: all 0.15s; user-select: none;
}
.factor-chip:hover { border-color: #58a6ff; background: rgba(56,139,253,0.08); }
.factor-chip.selected {
    background: rgba(56,139,253,0.15); border-color: #58a6ff; color: #58a6ff;
}
.factor-chip .chip-type {
    font-size: 10px; padding: 1px 5px; border-radius: 3px;
    background: #30363d; color: #8b949e;
}
.factor-chip.selected .chip-type { background: rgba(56,139,253,0.2); }

/* 条件编辑行 */
.condition-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; background: #0d1117; border: 1px solid #30363d;
    border-radius: 6px; margin-bottom: 8px;
}
.condition-row select, .condition-row input {
    background: #161b22; color: #c9d1d9; border: 1px solid #30363d;
    border-radius: 4px; padding: 6px 10px; font-size: 13px;
}
.condition-row select:focus, .condition-row input:focus {
    outline: none; border-color: #58a6ff;
}

/* ===== 策略卡片 ===== */
.strategy-card {
    background: #0d1117; border: 1px solid #30363d;
    border-radius: 10px; padding: 18px; cursor: pointer;
    transition: all 0.2s; position: relative; overflow: hidden;
}
.strategy-card:hover { border-color: #58a6ff; transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
.strategy-card-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 10px; }
.strategy-name { font-size: 16px; font-weight: 600; color: #e6edf3; }
.strategy-desc { font-size: 12px; color: #8b949e; line-height: 1.5; margin-bottom: 12px; }
.strategy-stats { display: flex; gap: 16px; flex-wrap: wrap; }
.strategy-stat { font-size: 12px; }
.strategy-stat-label { color: #6e7681; }
.strategy-stat-value { color: #c9d1d9; font-weight: 600; font-family: monospace; }
.strategy-stat-value.up { color: #3fb950; }
.strategy-stat-value.down { color: #f85149; }

/* ===== 图表区域 ===== */
.chart-container {
    width: 100%; height: 300px; position: relative;
    background: #0d1117; border-radius: 8px; border: 1px solid #30363d;
}
.chart-placeholder {
    display: flex; align-items: center; justify-content: center;
    height: 100%; color: #6e7681; font-size: 14px;
}

/* ===== 收益曲线模拟 ===== */
.pnl-chart {
    display: flex; align-items: flex-end; gap: 2px;
    height: 200px; padding: 10px 0;
}
.pnl-bar {
    flex: 1; background: linear-gradient(to top, #238636, #3fb950);
    border-radius: 2px 2px 0 0; min-width: 3px;
    transition: opacity 0.15s;
}
.pnl-bar:hover { opacity: 0.8; }
.pnl-bar.negative { background: linear-gradient(to top, #da3633, #f85149); }

/* ===== 持仓饼图 ===== */
.pie-chart {
    width: 180px; height: 180px; border-radius: 50%;
    margin: 0 auto; position: relative;
    background: conic-gradient(#238636 0% 65%, #58a6ff 65% 85%, #d29922 85% 100%);
}
.pie-center {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 90px; height: 90px; background: #161b22;
    border-radius: 50%; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
}
.pie-center-label { font-size: 11px; color: #6e7681; }
.pie-center-value { font-size: 18px; font-weight: 700; color: #e6edf3; }

/* ===== 风控面板 ===== */
.risk-gauge {
    width: 160px; height: 80px; position: relative;
    margin: 0 auto;
}
.risk-level-safe { color: #3fb950; }
.risk-level-warning { color: #d29922; }
.risk-level-danger { color: #f85149; }
.risk-level-fuse { color: #da3633; animation: pulse 1.5s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== Modal弹窗 ===== */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0;
    width: 100%; height: 100%; background: rgba(0,0,0,0.6);
    z-index: 1000; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
    background: #161b22; border: 1px solid #30363d;
    border-radius: 12px; width: 700px; max-height: 80vh;
    overflow-y: auto; padding: 24px;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid #30363d;
}
.modal-title { font-size: 18px; font-weight: 600; }
.modal-close {
    background: none; border: none; color: #8b949e;
    font-size: 24px; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: #fff; }

/* ===== Toast通知 ===== */
.toast-container {
    position: fixed; top: 20px; right: 20px; z-index: 2000;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    padding: 12px 20px; border-radius: 8px; font-size: 13px;
    background: #161b22; border: 1px solid #30363d;
    color: #c9d1d9; animation: slideIn 0.3s ease;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.toast.success { border-color: #238636; }
.toast.error { border-color: #da3633; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== 分页 ===== */
.pagination { display: flex; justify-content: center; gap: 4px; margin-top: 16px; }
.page-btn {
    padding: 6px 12px; background: #21262d; border: 1px solid #30363d;
    border-radius: 4px; color: #8b949e; cursor: pointer; font-size: 12px;
}
.page-btn:hover, .page-btn.active { background: #30363d; color: #fff; }

/* ===== 空状态 ===== */
.empty-state {
    text-align: center; padding: 60px 20px; color: #6e7681;
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state-text { font-size: 14px; }

/* ===== 响应式 ===== */
@media (max-width: 1200px) {
    .factor-panel { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-logo { font-size: 0; }
    .nav-item span { display: none; }
    .main-content { margin-left: 60px; padding: 16px; }
}
