* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; }

/* 布局 */
.app { display: flex; min-height: 100vh; background: #f3f4f6; }

/* 侧边栏 */
.sidebar {
  width: 220px; background: #111827; color: #fff;
  padding: 16px; display: flex; flex-direction: column; flex-shrink: 0;
}
.brand { font-weight: 700; font-size: 18px; margin-bottom: 24px; padding: 4px 0; }
.nav-group { margin-bottom: 20px; }
.nav-group-title { font-size: 11px; text-transform: uppercase; color: #6b7280; margin-bottom: 6px; letter-spacing: 1px; }
.nav-btn {
  display: block; width: 100%; border: 0; border-radius: 10px; padding: 10px 12px;
  background: transparent; color: #d1d5db; text-align: left; cursor: pointer;
  font-size: 14px; margin-bottom: 2px; transition: background .15s;
}
.nav-btn:hover { background: #1f2937; color: #fff; }
.nav-btn.active { background: #2563eb; color: #fff; }

/* 主内容 */
.main { flex: 1; padding: 24px; overflow-y: auto; min-width: 0; }
.page { display: none; }
.page.active { display: block; }

/* 卡片 */
.card { background: #fff; border-radius: 16px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 16px; }
.card h2 { margin: 0 0 16px 0; font-size: 18px; }
.card h3 { margin: 16px 0 10px 0; font-size: 15px; color: #374151; }

/* 表单 */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
input, select {
  padding: 10px 12px; border-radius: 10px; border: 1px solid #e5e7eb;
  font-size: 14px; min-width: 200px; outline: none;
}
input:focus, select:focus { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.15); }
button {
  padding: 10px 16px; border-radius: 10px; border: 0;
  background: #2563eb; color: #fff; cursor: pointer; font-size: 14px;
  transition: background .15s;
}
button:hover { background: #1d4ed8; }
button:disabled { opacity: .6; cursor: not-allowed; }
.btn-secondary { background: #6b7280; }
.btn-secondary:hover { background: #4b5563; }
.hint { color: #6b7280; font-size: 13px; margin-top: 6px; }

/* 分析结果 */
pre {
  white-space: pre-wrap; background: #0b1020; color: #e5e7eb;
  padding: 16px; border-radius: 14px; overflow: auto; min-height: 120px;
  font-size: 13px; line-height: 1.6;
}

/* 表格 */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #e5e7eb; }
th { background: #f9fafb; font-weight: 600; color: #6b7280; font-size: 12px; text-transform: uppercase; }
tr:hover { background: #f9fafb; }

/* ========== 交易所分组 ========== */
.exchange-section {
  background: #fff;
  border-radius: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  overflow: hidden;
}

.exchange-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
  transition: background .15s;
  border-bottom: 1px solid #f3f4f6;
}
.exchange-header:hover { background: #f9fafb; }
.exchange-header:active { background: #f3f4f6; }

.exchange-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.exchange-header-icon { font-size: 20px; }
.exchange-header h3 { font-size: 15px; font-weight: 600; color: #111827; margin: 0; }
.exchange-count {
  font-size: 12px; color: #6b7280;
  background: #f3f4f6; padding: 2px 10px; border-radius: 10px;
  font-weight: 500;
}
.exchange-arrow {
  font-size: 12px; color: #9ca3af;
  transition: transform .2s ease;
}
.exchange-arrow.collapsed { transform: rotate(-90deg); }

.exchange-body {
  padding: 8px 16px 16px;
  transition: all .2s ease;
}
.exchange-body.hidden { display: none; }

/* 品种卡片网格 */
.variety-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px;
}

/* 品种卡片（新版 - 带展开） */
.variety-card {
  background: #f9fafb;
  border: 1px solid #f3f4f6;
  border-radius: 12px;
  overflow: hidden;
  transition: all .15s;
}
.variety-card:hover { border-color: #d1d5db; }

.variety-card-top {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  gap: 4px;
}

.variety-card-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  min-width: 0;
}
.variety-card-info:hover .variety-code { color: #2563eb; }

.variety-code {
  font-weight: 700;
  font-size: 13px;
  color: #111827;
  transition: color .15s;
}
.variety-name {
  color: #6b7280;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.expand-btn {
  background: transparent;
  border: 0;
  color: #9ca3af;
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: all .15s;
  flex-shrink: 0;
}
.expand-btn:hover {
  background: #e5e7eb;
  color: #374151;
}
.expand-btn .arrow-icon {
  display: inline-block;
  transition: transform .2s ease;
}
.expand-btn.expanded .arrow-icon { transform: rotate(180deg); }

/* K线缩略图容器 */
.kline-thumb {
  display: none;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  cursor: pointer;
  position: relative;
}
.kline-thumb.active { display: block; }

.kline-thumb-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: #9ca3af;
  font-size: 13px;
  gap: 8px;
}

.kline-thumb-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100px;
  color: #991b1b;
  font-size: 13px;
  gap: 8px;
}

/* 加载动画 */
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid #e5e7eb; border-top-color: #2563eb;
  border-radius: 50%; animation: spin .6s linear infinite;
}
.spinner-sm { width: 14px; height: 14px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 状态标签 */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.badge-bull { background: #dcfce7; color: #166534; }
.badge-bear { background: #fee2e2; color: #991b1b; }
.badge-neutral { background: #f3f4f6; color: #374151; }

/* 响应式 */
@media (max-width: 768px) {
  .sidebar { width: 60px; overflow: hidden; padding: 12px 8px; }
  .sidebar .brand, .sidebar .nav-group-title, .sidebar .nav-btn span { display: none; }
  .sidebar .nav-btn { text-align: center; padding: 8px; }
  .variety-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
