/* ===== AITrade v9.5 - 视觉增强版 ===== */

/* --- 基础 --- */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #0d1117; color: #c9d1d9; }
#app { display: flex; flex-direction: column; min-height: 100vh; }

/* --- 导航栏（玻璃拟态） --- */
#nav { 
  display: flex; align-items: center; padding: 0 16px; height: 48px; 
  background: rgba(22, 27, 34, 0.9); backdrop-filter: blur(12px);
  border-bottom: 1px solid #30363d; gap: 4px; position: sticky; top: 0; z-index: 100;
}
.logo { font-weight: bold; color: #58a6ff; margin-right: 16px; font-size: 14px; }
.nav-btn { background: none; border: none; color: #8b949e; padding: 6px 12px; cursor: pointer; font-size: 13px; border-radius: 4px; transition: all 0.15s; }
.nav-btn:hover { color: #c9d1d9; background: #21262d; }
.nav-btn.active { color: #58a6ff; background: rgba(88,166,255,0.1); }

.mode-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 3px;
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.mode-badge.live { background: #da363333; color: #f85149; }
.mode-badge.paper { background: #23863633; color: #3fb950; }
.mode-badge::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.mode-badge.live::before { background: #f85149; }
.mode-badge.paper::before { background: #3fb950; }

#main { flex: 1; padding: 16px; overflow-y: auto; }
.panel { display: none; }
.panel.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* --- 工具栏 --- */
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.btn { background: #21262d; border: 1px solid #30363d; color: #c9d1d9; padding: 4px 10px; cursor: pointer; font-size: 12px; border-radius: 4px; transition: all 0.15s; }
.btn:hover { background: #30363d; border-color: #484f58; }
.btn-primary { background: #238636; border-color: #238636; color: #fff; }
.btn-primary:hover { background: #2ea043; }
.btn-small { padding: 2px 8px; font-size: 11px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.last-update { font-size: 11px; color: #6e7681; margin-left: auto; }

/* --- 卡片增强 --- */
.card { background: #161b22; border: 1px solid #30363d; border-radius: 8px; padding: 14px; margin-bottom: 12px; transition: all 0.2s; }
.card:hover { border-color: #484f58; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.card-title { font-size: 13px; font-weight: 600; color: #8b949e; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }

/* --- 统计数字 --- */
.stats-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.stat-item { background: #161b22; border: 1px solid #30363d; border-radius: 8px; padding: 12px 16px; min-width: 110px; transition: all 0.2s; }
.stat-item:hover { border-color: #484f58; }
.stat-label { font-size: 11px; color: #6e7681; }
.stat-value { font-size: 24px; font-weight: 600; margin-top: 4px; }
.stat-value.up { color: #3fb950; }
.stat-value.down { color: #f85149; }

/* --- 实时价格 --- */
.price-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.price-item { background: #161b22; border: 1px solid #30363d; border-radius: 8px; padding: 10px 16px; transition: all 0.2s; }
.price-item:hover { border-color: #484f58; }
.price-item .coin { font-size: 11px; color: #6e7681; display: block; margin-bottom: 2px; }
.price-item .px { font-size: 20px; font-weight: 600; color: #e6edf3; }

/* --- 表格 --- */
.table-wrapper { overflow-y: auto; max-height: 60vh; position: relative; overflow-x: auto; scrollbar-width: thin; scrollbar-color: #30363d #0d1117; }
.table-wrapper::-webkit-scrollbar { height: 6px; width: 6px; }
.table-wrapper::-webkit-scrollbar-thumb { background: #30363d; border-radius: 3px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead { position: sticky; top: 0; z-index: 1; }
thead th { background: #161b22; text-align: left; padding: 8px 8px; color: #6e7681; border-bottom: 2px solid #30363d; font-weight: 500; white-space: nowrap; }
td { padding: 6px 8px; border-bottom: 1px solid #21262d; white-space: nowrap; }
tr:hover td { background: #1c2128; }

/* --- 价格闪烁 --- */
@keyframes flash-green { 0% { background: rgba(63, 185, 80, 0.3); } 100% { background: transparent; } }
@keyframes flash-red { 0% { background: rgba(248, 81, 73, 0.3); } 100% { background: transparent; } }
.flash-up { animation: flash-green 1s ease-out; }
.flash-down { animation: flash-red 1s ease-out; }

/* --- 刷新状态 --- */
.refresh-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.refresh-dot.ok { background: #3fb950; }
.refresh-dot.loading { background: #d29922; animation: pulse 1s infinite; }
.refresh-dot.error { background: #f85149; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* --- 强平价警告 --- */
.liq-warning { color: #f85149; font-weight: bold; }

/* --- 徽章 --- */
.badge { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 11px; font-weight: 500; }
.badge-green { background: #23863633; color: #3fb950; }
.badge-red { background: #da363333; color: #f85149; }
.badge-blue { background: #1f6feb33; color: #58a6ff; }
.badge-gray { background: #30363d; color: #8b949e; }
.badge-yellow { background: #9e6a0333; color: #d29922; }
.badge-purple { background: #a371f733; color: #d2a8ff; }
.qty-changed { color: #d29922; font-weight: 600; }

/* --- 策略状态 --- */
.model-grid { display: flex; flex-direction: column; gap: 8px; }
.model-item { display: flex; align-items: center; gap: 12px; padding: 8px; background: #0d1117; border-radius: 4px; }
.model-name { font-weight: 600; min-width: 50px; }
.model-desc { font-size: 11px; color: #c9d1d9; flex: 1; }
.stat-num { font-weight: bold; color: #f0f6fc; }
.pnl-up { color: #3fb950 !important; }
.pnl-down { color: #f85149 !important; }
.pnl-mid { color: #d29922 !important; }

/* --- 错误栏 --- */
#error-bar { background: #da3633; color: #fff; padding: 8px 16px; font-size: 13px; }
#error-bar.hidden { display: none; }

/* --- 分页 --- */
.pagination { display: flex; align-items: center; gap: 4px; margin-top: 8px; font-size: 12px; }
.pagination button { min-width: 28px; }
.pagination .current { color: #58a6ff; }

/* --- 持仓路径表格 --- */
.path-table th, .path-table td { font-size: 11px; padding: 4px 6px; }
.path-table .up { color: #3fb950; }
.path-table .down { color: #f85149; }
.path-table .action-badge { display: inline-block; padding: 1px 4px; border-radius: 3px; font-size: 10px; font-weight: 500; }
.action-hold { background: #30363d; color: #8b949e; }
.action-partial_tp { background: #23863633; color: #3fb950; }
.action-trail_sl { background: #9e6a0333; color: #d29922; }
.action-pyramid { background: #a371f733; color: #d2a8ff; }
.action-sl_adjust { background: #da363333; color: #f85149; }
.action-tp_adjust { background: #1f6feb33; color: #58a6ff; }
.action-stop_loss { background: #da363333; color: #f85149; }
.action-take_profit { background: #23863633; color: #3fb950; }
.action-trail_stop { background: #9e6a0333; color: #d29922; }
.action-time_stop { background: #30363d; color: #8b949e; }
.action-structure_exit { background: #8957e533; color: #bc8cff; }
.action-close { background: #30363d; color: #8b949e; }
.action-open { background: #23863633; color: #3fb950; }

/* --- 模态框（修复版） --- */
.modal { display: none; position: fixed; z-index: 100; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); align-items: center; justify-content: center; }
.modal.active { display: flex; }
.modal-content { background: #161b22; border: 1px solid #30363d; border-radius: 8px; padding: 20px; max-width: 90vw; max-height: 90vh; overflow-y: auto; position: relative; }
.modal-close { position: absolute; right: 12px; top: 8px; font-size: 24px; cursor: pointer; color: #8b949e; }
.modal-close:hover { color: #c9d1d9; }
.detail-section { margin-bottom: 16px; }
.detail-section h4 { color: #8b949e; font-size: 13px; margin-bottom: 8px; }
.detail-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.detail-table th, .detail-table td { padding: 6px 8px; border-bottom: 1px solid #21262d; text-align: left; }
.detail-table th { color: #6e7681; font-weight: 500; background: #0d1117; }
.intent-cell { font-size: 11px; line-height: 1.4; }
.regime { color: #d29922; }
.muted { color: #6e7681; font-size: 12px; }
.error { color: #f85149; }
.sub-line { font-size: 11px; color: #6e7681; margin-top: 4px; }
.tag { display: inline-block; padding: 1px 5px; border-radius: 3px; background: #21262d; margin-right: 4px; font-size: 11px; }

/* --- 通知动画 --- */
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- 筛选输入框 --- */
.filter-input, .filter-select { background: #21262d; border: 1px solid #30363d; color: #c9d1d9; padding: 4px 8px; font-size: 12px; border-radius: 4px; outline: none; height: 28px; }
.filter-input::placeholder { color: #6e7681; }
.filter-input:focus, .filter-select:focus { border-color: #58a6ff; }

/* --- 响应式 --- */
@media (max-width: 768px) {
  #nav { flex-wrap: wrap; height: auto; padding: 8px; }
  .nav-btn { font-size: 12px; padding: 4px 8px; }
  .stats-row { gap: 8px; }
  .stat-item { min-width: 80px; padding: 8px 12px; }
  .stat-value { font-size: 18px; }
  .price-row { gap: 8px; }
  .table-wrapper { max-height: 50vh; }
  table { font-size: 11px; }
  td, th { padding: 4px 6px; }
  .toolbar { flex-wrap: wrap; }
  .last-update { margin-left: 0; width: 100%; margin-top: 4px; }
}

/* --- 新增：图表容器 --- */
.chart-wrap { background: #161b22; border: 1px solid #30363d; border-radius: 8px; padding: 16px; margin-bottom: 12px; }
.chart-title { font-size: 13px; font-weight: 600; color: #8b949e; margin-bottom: 12px; }
.chart-canvas { width: 100%; height: 220px; }

/* --- 新增：延迟柱状图 --- */
.latency-chart { display: flex; align-items: flex-end; gap: 3px; height: 60px; padding: 8px 0; }
.latency-bar { flex: 1; border-radius: 2px; min-height: 4px; transition: height 0.3s ease; }

/* --- 新增：审计日志表格 --- */
.audit-table { font-size: 11px; }
.audit-table th { background: #0d1117; padding: 6px 8px; color: #6e7681; border-bottom: 1px solid #30363d; text-align: left; }
.audit-table td { padding: 4px 8px; border-bottom: 1px solid #21262d; }
