:root {
  --bg-dark: #1a1a2e;
  --bg-panel: #16213e;
  --bg-card: #0f3460;
  --accent: #e94560;
  --green: #00da3c;
  --red: #ec0000;
  --text: #e0e0e0;
  --text-dim: #888;
  --border: #2a2a4a;
  --info: #4fc3f7;
  --warning: #ffb74d;
  --danger: #ef5350;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
}

.app { display: flex; flex-direction: column; height: 100vh; }

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

.header h1 { font-size: 18px; font-weight: 600; }

.header-right { display: flex; align-items: center; gap: 12px; }

.stock-select {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 14px;
  cursor: pointer;
}

.period-btns { display: flex; gap: 4px; }

.period-btn {
  background: var(--bg-card);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.period-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.status-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.status-badge.trading { background: var(--green); color: #000; }
.status-badge.closed { background: var(--text-dim); color: #fff; }

.main { display: flex; flex: 1; overflow: hidden; }

.chart-area {
  flex: 1;
  min-width: 0;
  padding: 10px;
  display: flex;
  flex-direction: column;
}

.chart-container { width: 100%; flex: 1; min-height: 400px; }

.sidebar {
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 10px 10px 0;
  overflow-y: auto;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
}

.panel h3 {
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--text-dim);
}

.signal-list, .alert-list { max-height: 200px; overflow-y: auto; }

.signal-item, .alert-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.signal-item:last-child, .alert-item:last-child { border-bottom: none; }

.signal-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.signal-dot.info { background: var(--info); }
.signal-dot.warning { background: var(--warning); }
.signal-dot.danger { background: var(--danger); }

.signal-text { flex: 1; line-height: 1.3; }
.signal-time { color: var(--text-dim); font-size: 11px; white-space: nowrap; }

.overview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.overview-table th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 500;
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
}

.overview-table td {
  padding: 6px;
  border-bottom: 1px solid var(--border);
}

.overview-table tr:last-child td { border-bottom: none; }

.price-up { color: var(--red); }
.price-down { color: var(--green); }

.signal-count {
  display: inline-block;
  background: var(--accent);
  color: white;
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 11px;
  min-width: 18px;
  text-align: center;
}

.signal-count.zero { background: var(--text-dim); }

/* === AI 样式 === */
.ai-badge {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  vertical-align: middle;
  animation: aiGlow 2s ease-in-out infinite;
}
.ai-badge-sm {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 8px;
}
@keyframes aiGlow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.btn-ai-diagnose {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
}
.btn-ai-diagnose:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102,126,234,0.4);
}
.btn-ai-diagnose:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* AI 诊断面板 */
.ai-diagnose-panel {
  background: #1a1a2e;
  border-top: 2px solid #667eea;
  padding: 16px;
  max-height: 50vh;
  overflow-y: auto;
}
.ai-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.ai-panel-header h3 {
  margin: 0;
  color: #e0e0e0;
  font-size: 15px;
}
.ai-panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ai-time {
  color: #888;
  font-size: 11px;
}
.btn-close {
  background: none;
  border: 1px solid #444;
  color: #aaa;
  border-radius: 4px;
  cursor: pointer;
  padding: 2px 8px;
  font-size: 12px;
}
.btn-close:hover {
  background: #333;
  color: #fff;
}

.ai-content {
  color: #d0d0d0;
  font-size: 13px;
  line-height: 1.8;
}
.ai-content h1, .ai-content h2, .ai-content h3, .ai-content h4 {
  color: #667eea;
  margin: 12px 0 6px;
}
.ai-content h1 { font-size: 16px; }
.ai-content h2 { font-size: 15px; }
.ai-content h3 { font-size: 14px; }
.ai-content h4 { font-size: 13px; }
.ai-content strong { color: #ffa726; }
.ai-content ul, .ai-content ol { padding-left: 20px; }
.ai-content li { margin: 4px 0; }
.ai-content code { background: #2a2a4a; padding: 1px 5px; border-radius: 3px; font-size: 12px; }
.ai-content blockquote { border-left: 3px solid #667eea; padding-left: 12px; margin: 8px 0; color: #aaa; }

.ai-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #888;
  font-size: 13px;
  padding: 16px;
}
.loading-dots { display: flex; gap: 4px; }
.loading-dots span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #667eea;
  animation: dotPulse 1.4s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* AI 对话面板 */
.chat-panel { display: flex; flex-direction: column; }
.chat-messages { flex: 1; max-height: 280px; overflow-y: auto; padding: 8px 0; }
.chat-welcome { color: #666; font-size: 12px; text-align: center; padding: 20px 0; }
.chat-msg {
  margin: 6px 0; padding: 8px 10px; border-radius: 8px;
  font-size: 12px; line-height: 1.6; max-width: 95%; word-break: break-word;
}
.chat-msg.user {
  background: #2a3a5c; color: #e0e0e0;
  margin-left: auto; border-bottom-right-radius: 2px;
}
.chat-msg.assistant {
  background: #1e2a3a; color: #d0d0d0;
  margin-right: auto; border-bottom-left-radius: 2px;
}
.chat-msg.assistant strong { color: #ffa726; }
.chat-input-area {
  display: flex; gap: 6px; padding-top: 8px;
  border-top: 1px solid #2a2a4a;
}
.chat-input {
  flex: 1; background: #12122a; border: 1px solid #333;
  color: #e0e0e0; padding: 6px 10px; border-radius: 6px;
  font-size: 12px; outline: none;
}
.chat-input:focus { border-color: #667eea; }
.btn-chat-send {
  background: #667eea; color: #fff; border: none;
  padding: 6px 14px; border-radius: 6px; cursor: pointer;
  font-size: 12px; font-weight: 600;
}
.btn-chat-send:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-chat-send:hover { background: #5a6fd6; }

.btn-mini-ai {
  background: none; border: 1px solid #667eea; color: #667eea;
  padding: 1px 6px; border-radius: 4px; cursor: pointer; font-size: 10px;
}
.btn-mini-ai:hover { background: #667eea; color: #fff; }

@media (max-width: 900px) {
  .main { flex-direction: column; }
  .sidebar { width: 100%; max-height: 300px; }
  .chart-container { min-height: 350px; }
  .ai-diagnose-panel { max-height: 40vh; }
  .chat-messages { max-height: 200px; }
}
