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

/* ===== 默认主题：暗夜极客 ===== */
[data-theme="dark-neon"],
:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-card: #1a1f2e;
  --bg-hover: #262c3a;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #5a6070;
  --accent-blue: #58a6ff;
  --accent-cyan: #39d2c0;
  --accent-green: #3fb950;
  --accent-red: #f85149;
  --accent-orange: #f79018;
  --accent-purple: #bc8cff;
  --border-color: #30363d;
  --border-light: #21262d;
  --up-color: #f23645;
  --down-color: #00c853;
  --shadow-color: rgba(0,0,0,0.3);
  --scrollbar-bg: #30363d;
  --panel-width: 720px;
  --nav-height: 56px;
  --ma5-color: #f5a623;
  --ma10-color: #4fc3f7;
  --ma20-color: #ab47bc;
  --ma30-color: #66bb6a;
}

/* ===== 主题：极简白 ===== */
[data-theme="minimal-white"] {
  --bg-primary: #f5f7fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f0f2f5;
  --bg-card: #ffffff;
  --bg-hover: #f0f2f5;
  --text-primary: #1a2332;
  --text-secondary: #6b7a8f;
  --text-muted: #a0aec0;
  --accent-blue: #3b82f6;
  --accent-cyan: #0ea5e9;
  --accent-green: #22c55e;
  --accent-red: #ef4444;
  --accent-orange: #f59e0b;
  --accent-purple: #8b5cf6;
  --border-color: #e2e8f0;
  --border-light: #e2e8f0;
  --up-color: #ef4444;
  --down-color: #22c55e;
  --shadow-color: rgba(0,0,0,0.06);
  --scrollbar-bg: #cbd5e1;
  --ma5-color: #f59e0b;
  --ma10-color: #3b82f6;
  --ma20-color: #8b5cf6;
  --ma30-color: #22c55e;
}

/* ===== 主题：科技蓝 ===== */
[data-theme="tech-blue"] {
  --bg-primary: #0a1628;
  --bg-secondary: #0f1d35;
  --bg-tertiary: #152a4a;
  --bg-card: #112240;
  --bg-hover: #1a3360;
  --text-primary: #ccd6f6;
  --text-secondary: #8892b0;
  --text-muted: #495670;
  --accent-blue: #64ffda;
  --accent-cyan: #57cbff;
  --accent-green: #64ffda;
  --accent-red: #ff6b6b;
  --accent-orange: #ffd166;
  --accent-purple: #b388ff;
  --border-color: #1d3461;
  --border-light: #1d3461;
  --up-color: #ff6b6b;
  --down-color: #64ffda;
  --shadow-color: rgba(0,0,0,0.4);
  --scrollbar-bg: #1d3461;
  --ma5-color: #ffd166;
  --ma10-color: #57cbff;
  --ma20-color: #b388ff;
  --ma30-color: #64ffda;
}

/* ===== 主题：莫兰迪灰 ===== */
[data-theme="morandi"] {
  --bg-primary: #f0ece4;
  --bg-secondary: #faf6ee;
  --bg-tertiary: #e8e3da;
  --bg-card: #ffffff;
  --bg-hover: #e8e3da;
  --text-primary: #4a4a4a;
  --text-secondary: #8a8a8a;
  --text-muted: #b0b0b0;
  --accent-blue: #7a9eb3;
  --accent-cyan: #8ebdb6;
  --accent-green: #9cb78c;
  --accent-red: #c97e7e;
  --accent-orange: #c9a96e;
  --accent-purple: #9e8db5;
  --border-color: #d6d0c4;
  --border-light: #e0dcd0;
  --up-color: #c97e7e;
  --down-color: #7a9eb3;
  --shadow-color: rgba(0,0,0,0.04);
  --scrollbar-bg: #d6d0c4;
  --ma5-color: #c9a96e;
  --ma10-color: #7a9eb3;
  --ma20-color: #9e8db5;
  --ma30-color: #9cb78c;
}

/* ===== 主题：赛博朋克 ===== */
[data-theme="cyberpunk"] {
  --bg-primary: #0a0a0f;
  --bg-secondary: #120e1a;
  --bg-tertiary: #1c1630;
  --bg-card: #150f24;
  --bg-hover: #221a40;
  --text-primary: #e0e0ff;
  --text-secondary: #8880b0;
  --text-muted: #5a5080;
  --accent-blue: #00f0ff;
  --accent-cyan: #00ffc8;
  --accent-green: #39ff14;
  --accent-red: #ff0040;
  --accent-orange: #ff6a00;
  --accent-purple: #bf00ff;
  --border-color: #2a1f50;
  --border-light: #1c1630;
  --up-color: #ff0040;
  --down-color: #00ffc8;
  --shadow-color: rgba(191,0,255,0.15);
  --scrollbar-bg: #2a1f50;
  --ma5-color: #ff6a00;
  --ma10-color: #00f0ff;
  --ma20-color: #bf00ff;
  --ma30-color: #39ff14;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  transition: background 0.3s, color 0.3s;
}

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

/* 顶部导航 */
.top-nav {
  height: var(--nav-height);
  display: flex;
  align-items: center;
  padding: 0 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  gap: 24px;
  flex-shrink: 0;
  transition: background 0.3s, border-color 0.3s;
}

.nav-brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-blue);
  white-space: nowrap;
}

.nav-tabs {
  display: flex;
  gap: 4px;
}

.nav-tab {
  padding: 8px 20px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 15px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
  font-weight: 500;
}

.nav-tab:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav-tab.active {
  background: var(--accent-blue);
  color: #fff;
}

.nav-search {
  margin-left: auto;
}

.nav-search input {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 12px;
  color: var(--text-primary);
  font-size: 14px;
  width: 200px;
  outline: none;
  transition: border-color 0.2s, background 0.3s, color 0.3s;
}

.nav-search input:focus {
  border-color: var(--accent-blue);
}

/* 主布局 */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* 内容卡片 */
.content-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 16px;
  overflow: hidden;
  transition: background 0.3s, border-color 0.3s;
}

.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-secondary);
  transition: border-color 0.3s;
}

.card-body {
  padding: 0;
}

/* 表格样式 */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  padding: 10px 16px;
  text-align: left;
  font-weight: 500;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  position: sticky;
  top: 0;
  z-index: 1;
  transition: background 0.3s, border-color 0.3s;
}

.data-table td {
  padding: 10px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border-light);
  transition: border-color 0.3s;
}

.data-table tr:hover {
  background: var(--bg-hover);
}

/* 涨幅榜表格 */
.data-table-gainers th {
  white-space: nowrap;
}

.data-table-gainers td {
  vertical-align: middle;
}

.data-table-gainers .num-col {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.data-table-gainers .num-col th {
  text-align: right;
}

.stock-name-cell {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.stock-sname {
  font-size: 12px;
  color: var(--text-muted);
}

.small-change {
  font-size: 12px;
  margin-left: 4px;
  font-weight: 500;
}

.reason-text {
  max-width: 260px;
  line-height: 1.5;
  font-size: 13px;
  color: var(--text-primary);
}

.detail-cell {
  max-width: 240px;
}

.catalyst-detail {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.no-detail {
  color: var(--text-muted);
  font-size: 12px;
}

.tag-sector {
  background: rgba(57, 210, 192, 0.15);
  color: var(--accent-cyan);
  white-space: nowrap;
}

.tag-time {
  background: rgba(88, 166, 255, 0.15);
  color: var(--accent-blue);
}

.tag-emotion {
  background: rgba(247, 144, 24, 0.15);
  color: var(--accent-orange);
}

.stock-link {
  color: var(--accent-blue);
  cursor: pointer;
  font-weight: 500;
}

.stock-link:hover {
  text-decoration: underline;
}

/* 涨幅榜代码/名称 加大加粗 */
.stock-link-lg {
  font-size: 15px;
  font-weight: 700;
}

.stock-name-cell-lg .stock-sname {
  font-size: 13px;
  font-weight: 600;
}

/* 数据来源标识 */
.data-source-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  white-space: nowrap;
}

.badge-live {
  color: var(--accent-green);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(63, 185, 80, 0.12);
  border: 1px solid rgba(63, 185, 80, 0.3);
}

.badge-cache {
  color: var(--accent-orange);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(247, 144, 24, 0.12);
  border: 1px solid rgba(247, 144, 24, 0.3);
}

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

.rank-badge {
  display: inline-block;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  margin-right: 4px;
}

.rank-1 { background: #d4af37; color: #000; }
.rank-2 { background: #a8a8a8; color: #000; }
.rank-3 { background: #cd7f32; color: #000; }

.tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  margin-right: 4px;
}

.tag-concept { background: rgba(88, 166, 255, 0.15); color: var(--accent-blue); }
.tag-bd { background: rgba(247, 144, 24, 0.15); color: var(--accent-orange); }

/* 右侧面板 */
.stock-panel {
  width: var(--panel-width);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s ease, background 0.3s, border-color 0.3s;
  overflow: hidden;
}

.stock-panel.hidden {
  display: none;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  transition: border-color 0.3s;
}

.stock-name {
  font-size: 18px;
  font-weight: 700;
}

.stock-code {
  font-size: 14px;
  color: var(--text-secondary);
  margin-left: 8px;
}

.panel-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.panel-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
}

.price-info {
  margin-bottom: 6px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
}

.current-price {
  font-size: 28px;
  font-weight: 700;
}

.price-change {
  font-size: 16px;
  margin-left: 12px;
}

/* 均线图例 + 主题切换行 */
.ma-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
  flex-shrink: 0;
  padding: 6px 0;
}

.ma-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.ma-dot {
  display: inline-block;
  width: 14px;
  height: 3px;
  border-radius: 2px;
}

.ma-dot-5  { background: var(--ma5-color); }
.ma-dot-10 { background: var(--ma10-color); }
.ma-dot-20 { background: var(--ma20-color); }
.ma-dot-30 { background: var(--ma30-color); }

/* 主题切换按钮 */
.theme-switch {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  transition: all 0.2s;
  white-space: nowrap;
}

.theme-switch:hover {
  color: var(--text-primary);
  border-color: var(--accent-blue);
}

/* 主题选择浮层 */
.theme-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 8px 24px var(--shadow-color);
  z-index: 200;
  min-width: 190px;
  display: none;
}

.theme-dropdown.show {
  display: block;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  transition: background 0.15s;
}

.theme-option:hover {
  background: var(--bg-hover);
}

.theme-option.active {
  background: rgba(88, 166, 255, 0.15);
}

.theme-preview {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  flex-shrink: 0;
}

/* 主题选择器容器 */
.theme-selector {
  position: relative;
}

/* 图表 */
.chart-container {
  flex: 1;
  width: 100%;
  min-height: 0;
  position: relative;
}

/* 滚动条 */
.content-area::-webkit-scrollbar,
.panel-body::-webkit-scrollbar {
  width: 6px;
}

.content-area::-webkit-scrollbar-track,
.panel-body::-webkit-scrollbar-track {
  background: transparent;
}

.content-area::-webkit-scrollbar-thumb,
.panel-body::-webkit-scrollbar-thumb {
  background: var(--scrollbar-bg);
  border-radius: 3px;
}

.content-area::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* 报告样式 */
.report-item {
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.2s;
}

.report-item:hover {
  background: var(--bg-hover);
}

.report-item:last-child {
  border-bottom: none;
}

.report-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.report-meta {
  font-size: 13px;
  color: var(--text-secondary);
}

.report-source {
  margin-left: 8px;
  padding: 2px 6px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  font-size: 12px;
}

/* 公告样式 */
.announcement-item {
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.2s;
}

.announcement-item:hover {
  background: var(--bg-hover);
}

.announcement-item:last-child {
  border-bottom: none;
}

.ann-title {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.ann-meta {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  gap: 16px;
}

.ann-tag {
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 12px;
  background: rgba(63, 185, 80, 0.15);
  color: var(--accent-green);
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

.loading::after {
  content: '...';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* 响应式 */
@media (max-width: 900px) {
  .stock-panel {
    position: fixed;
    right: 0;
    top: var(--nav-height);
    bottom: 0;
    width: 100%;
    z-index: 100;
  }
  .nav-search input {
    width: 120px;
  }
}
