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

:root {
  --bg-primary: #0a0a14;
  --bg-card: #12121f;
  --bg-card-hover: #1a1a2e;
  --accent-up: #00d9a3;
  --accent-down: #ff4d6d;
  --accent-primary: #6366f1;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: rgba(255, 255, 255, 0.06);
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 40px;
}

/* 顶部导航 */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 0 4px;
}

.app-title {
  font-size: 22px;
  font-weight: 700;
  background: linear-gradient(90deg, #818cf8, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* 搜索框 */
.search-box {
  position: relative;
  margin-bottom: 16px;
}

.search-box input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: all 0.2s;
}

.search-box input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 18px;
}

/* 刷新栏 */
.refresh-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 0 4px;
}

.auto-refresh {
  font-size: 13px;
  color: var(--text-muted);
}

.refresh-btn {
  padding: 8px 18px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.refresh-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.refresh-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* 卡片通用 */
.card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.1);
}

/* 指数卡片 */
.indices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.index-mini {
  background: var(--bg-card);
  border-radius: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.index-mini:hover {
  border-color: rgba(255, 255, 255, 0.1);
}

.index-mini-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.index-mini-name {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.index-mini-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(0, 217, 163, 0.1);
  color: var(--accent-up);
}

.index-mini-badge.down {
  background: rgba(255, 77, 109, 0.1);
  color: var(--accent-down);
}

.index-mini-price {
  font-size: 22px;
  font-weight: 700;
  font-family: 'SF Mono', 'Roboto Mono', monospace;
  margin-bottom: 6px;
}

.index-mini-change {
  font-size: 13px;
  font-weight: 600;
}

/* 主指数卡片 */
.index-card {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
  border: none;
  position: relative;
  overflow: hidden;
}

.index-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

.index-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  position: relative;
}

.index-name {
  font-size: 16px;
  font-weight: 600;
  color: #c7d2fe;
}

.market-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(0, 217, 163, 0.15);
  color: var(--accent-up);
}

.market-badge.closed {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.index-price-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
  position: relative;
}

.index-price {
  font-size: 40px;
  font-weight: 800;
  font-family: 'SF Mono', 'Roboto Mono', monospace;
  letter-spacing: -0.5px;
}

.index-change-group {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.change-value {
  font-size: 18px;
  font-weight: 600;
}

.change-percent {
  font-size: 14px;
  padding: 4px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 600;
}

.index-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
}

.index-meta span {
  font-size: 12px;
  color: #a5b4fc;
}

.index-meta span b {
  color: #e0e7ff;
  font-weight: 600;
  margin-left: 4px;
}

.update-time {
  margin-top: 12px;
  font-size: 12px;
  color: #818cf8;
  text-align: right;
  position: relative;
}

/* 颜色 */
.up { color: var(--accent-up); }
.down { color: var(--accent-down); }

/* 算法选择栏 */
.algo-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding: 0 4px;
}

.algo-label {
  font-size: 13px;
  color: var(--text-muted);
}

.algo-group {
  display: flex;
  gap: 6px;
}

.algo-btn {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.algo-btn:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.algo-btn.active {
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* 三算法对比条 */
.estimate-comparison {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 10px 0 0;
  margin-bottom: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}

.est-comp-item {
  font-weight: 500;
  white-space: nowrap;
}

.est-comp-divider {
  color: var(--text-muted);
  opacity: 0.3;
}

/* 排序栏 */
.sort-bar {
  display: flex;
  gap: 10px;
  margin: 16px 0;
  overflow-x: auto;
  padding-bottom: 4px;
}

.sort-item {
  padding: 8px 18px;
  border-radius: 24px;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.sort-item:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.sort-item.active {
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* 基金列表 */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 20px 4px 14px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
}

.fund-count {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 4px 12px;
  border-radius: 12px;
}

.fund-card {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
  position: relative;
  overflow: hidden;
}

.fund-card::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent-primary);
  opacity: 0;
  transition: opacity 0.2s;
}

.fund-card:hover::after {
  opacity: 1;
}

.fund-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.fund-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.fund-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.fund-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fund-code {
  font-size: 12px;
  color: var(--text-muted);
  font-family: monospace;
}

.fund-tags {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 12px;
}

.tag {
  padding: 3px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
}

.tag.estimate {
  background: rgba(0, 217, 163, 0.12);
  color: var(--accent-up);
}

/* 基金数据三列 */
.fund-data {
  display: flex;
  justify-content: space-between;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.data-col {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.data-col.center {
  align-items: center;
}

.data-col.right {
  align-items: flex-end;
}

.data-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-value {
  font-size: 20px;
  font-weight: 700;
  font-family: 'SF Mono', 'Roboto Mono', monospace;
}

.data-change {
  font-size: 13px;
  margin-top: 4px;
  font-weight: 500;
}

.data-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* 近期表现 */
.performance-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.perf-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.perf-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.perf-value {
  font-size: 13px;
  font-weight: 600;
}

/* 加载和空状态 */
.loading, .empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 错误框 */
.error-box {
  background: rgba(255, 77, 109, 0.08);
  border: 1px solid rgba(255, 77, 109, 0.2);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #fda4af;
}

.error-box b {
  color: #fff;
  display: block;
  margin-bottom: 6px;
}

/* 详情页 */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 16px;
  transition: color 0.2s;
}

.back-link:hover {
  color: var(--text-secondary);
}

.nav-row {
  display: flex;
  gap: 12px;
}

.nav-block {
  flex: 1;
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 18px;
  border: 1px solid var(--border);
}

.nav-block.estimate {
  border-color: rgba(99, 102, 241, 0.3);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.05));
}

.nav-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.nav-value {
  display: block;
  font-size: 32px;
  font-weight: 700;
  font-family: 'SF Mono', 'Roboto Mono', monospace;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.nav-change {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

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

.up-bg {
  background: rgba(0, 217, 163, 0.12);
  color: var(--accent-up);
}

.down-bg {
  background: rgba(255, 77, 109, 0.12);
  color: var(--accent-down);
}

/* 三算法对比 */
.algo-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg-primary);
  border-radius: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.algo-row:last-child {
  margin-bottom: 0;
}

.algo-row.active {
  border-color: rgba(99, 102, 241, 0.4);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.05));
}

.algo-name {
  font-size: 13px;
  font-weight: 600;
  min-width: 70px;
}

.algo-name.conservative {
  color: #60a5fa;
}

.algo-name.balanced {
  color: #a78bfa;
}

.algo-name.aggressive {
  color: #f472b6;
}

.algo-nav {
  font-size: 18px;
  font-weight: 700;
  font-family: 'SF Mono', 'Roboto Mono', monospace;
}

.algo-change {
  font-size: 14px;
  font-weight: 600;
}

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

/* 关联指数 */
.link-index {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
}

.link-name {
  font-size: 15px;
  font-weight: 500;
}

.link-status {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.link-status.trading {
  color: var(--accent-up);
}

.link-price {
  font-size: 28px;
  font-weight: 700;
  font-family: 'SF Mono', 'Roboto Mono', monospace;
}

.link-change {
  font-size: 14px;
  font-weight: 600;
}

/* 历史表现网格 */
.perf-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.perf-cell {
  width: calc(33.33% - 7px);
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
}

.perf-cell .perf-label {
  font-size: 11px;
  color: var(--text-muted);
}

.perf-cell .perf-value {
  font-size: 15px;
  font-weight: 700;
}

.perf-value.plain {
  color: var(--text-secondary);
  font-size: 13px;
}

/* 净值历史 */
.history-header {
  display: flex;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.history-header span {
  flex: 1;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.history-header span:first-child {
  text-align: left;
}

.history-header span:last-child {
  text-align: right;
}

.history-row {
  display: flex;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: background 0.1s;
}

.history-row:hover {
  background: rgba(255, 255, 255, 0.02);
}

.history-row span {
  flex: 1;
  text-align: center;
  font-size: 14px;
}

.history-row .hist-date {
  text-align: left;
  color: var(--text-secondary);
}

.history-row .hist-nav,
.history-row .hist-acc {
  font-family: 'SF Mono', 'Roboto Mono', monospace;
}

.history-row .hist-change {
  text-align: right;
  font-weight: 600;
}

/* 响应式 */
@media (max-width: 480px) {
  .indices-grid {
    grid-template-columns: 1fr;
  }
  .index-price {
    font-size: 32px;
  }
  .perf-cell {
    width: calc(50% - 5px);
  }
}
