:root {
  --bg: #0e1320;
  --panel: #171e2e;
  --panel-2: #1e2740;
  --border: #273352;
  --text: #e8ecf4;
  --text-dim: #8b96ad;
  --up: #f05252;      /* A股红涨 */
  --down: #2fbf71;    /* A股绿跌 */
  --accent: #4f8cff;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  min-height: 100vh;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 20px 32px;
  background: linear-gradient(135deg, #131b2e 0%, #0e1320 100%);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}
.brand h1 { font-size: 22px; letter-spacing: 1px; }
.brand p { color: var(--text-dim); font-size: 12px; margin-top: 4px; }

.add-bar { display: flex; gap: 10px; }
.add-bar input {
  width: 260px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
  letter-spacing: 2px;
  outline: none;
  transition: border-color .2s;
}
.add-bar input:focus { border-color: var(--accent); }
.btn-primary {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: filter .2s;
}
.btn-primary:hover { filter: brightness(1.15); }

/* ---------- 统计 ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 24px 32px 0;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  text-align: center;
}
.stat-card .num { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat-card .label { color: var(--text-dim); font-size: 12px; }

/* ---------- 贵金属行情 ---------- */
.gold-wrap { padding: 24px 32px 0; }
.gold-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.gold-title .gold-sub { font-size: 12px; color: var(--text-dim); font-weight: 400; }
.gold-panel {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.gold-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
}
.gold-head { display: flex; justify-content: space-between; align-items: baseline; }
.gold-name { font-size: 14px; font-weight: 600; }
.gold-unit { font-size: 11px; color: var(--text-dim); }
.gold-price-row { display: flex; align-items: baseline; gap: 10px; margin: 8px 0 2px; }
.gold-price { font-size: 26px; font-weight: 800; font-family: Consolas, monospace; }
.gold-change { font-size: 13px; font-weight: 600; font-family: Consolas, monospace; }
.gold-cny-row { display: flex; align-items: baseline; gap: 10px; margin: 0 0 8px; }
.gold-cny { font-size: 15px; font-weight: 600; color: #ffb43c; font-family: Consolas, monospace; }
.gold-cny-change { font-size: 12px; font-family: Consolas, monospace; }
.gold-unit-inline { font-size: 11px; color: var(--text-dim); font-weight: 400; }
.gold-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12px;
  color: var(--text-dim);
}
.gold-meta b { color: var(--text); font-family: Consolas, monospace; font-weight: 600; }
.gold-time { margin-left: auto; }
.gold-empty { color: var(--text-dim); font-size: 13px; padding: 10px 0; }

/* ---------- 全球股指 ---------- */
.indices-wrap { padding: 24px 32px 0; }
.indices-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.indices-title .indices-sub { font-size: 12px; color: var(--text-dim); font-weight: 400; }
.indices-panel {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.indices-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
}
.indices-head { display: flex; justify-content: space-between; align-items: baseline; }
.indices-name { font-size: 14px; font-weight: 600; }
.indices-src { font-size: 11px; color: var(--text-dim); }
.indices-price-row { display: flex; align-items: baseline; gap: 10px; margin: 8px 0 8px; }
.indices-price { font-size: 26px; font-weight: 800; font-family: Consolas, monospace; }
.indices-change { font-size: 13px; font-weight: 600; font-family: Consolas, monospace; }
.indices-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12px;
  color: var(--text-dim);
}
.indices-meta b { color: var(--text); font-family: Consolas, monospace; font-weight: 600; }
.indices-time { margin-left: auto; }
.indices-empty { color: var(--text-dim); font-size: 13px; padding: 10px 0; }

/* ---------- 基金卡片 ---------- */
.fund-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding: 24px 32px;
}
.fund-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  cursor: pointer;
  transition: transform .15s, border-color .15s;
  position: relative;
}
.fund-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.fund-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.fund-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.fund-name { font-size: 15px; font-weight: 600; line-height: 1.4; }
.fund-code {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 4px;
  font-family: Consolas, monospace;
}
.del-btn {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.del-btn:hover { color: var(--up); border-color: var(--up); }

.pct-main { margin: 14px 0 12px; display: flex; align-items: baseline; gap: 8px; }
.pct-main .pct { font-size: 34px; font-weight: 800; }
.pct-main .sub { font-size: 13px; color: var(--text-dim); }

.fund-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; font-size: 12px; }
.fund-meta .item { display: flex; justify-content: space-between; }
.fund-meta .k { color: var(--text-dim); }
.fund-meta .v { font-family: Consolas, monospace; }
.fund-badge { font-size: 11px; padding: 1px 8px; border-radius: 10px; margin-left: 6px; }
.badge-calc { background: rgba(79,140,255,.15); color: #7fb0ff; }
.badge-cover { background: rgba(255,180,60,.12); color: #ffb43c; }
.badge-etf { background: rgba(180,120,255,.15); color: #b478ff; }

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

/* ---------- 详情 ---------- */
.detail { padding: 0 32px 30px; }
.detail-head {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.detail-head .big-pct { font-size: 40px; font-weight: 800; }
.detail-head .meta { color: var(--text-dim); font-size: 13px; line-height: 1.9; }
.detail-head .meta b { color: var(--text); font-family: Consolas, monospace; }

.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.chart-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}
.chart-box h3 { font-size: 14px; margin-bottom: 10px; color: var(--text-dim); font-weight: 500; }
.chart { width: 100%; height: 320px; }

.hold-table-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 20px;
}
.hold-table-box h3 { font-size: 14px; margin-bottom: 12px; color: var(--text-dim); font-weight: 500; }
.hold-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.hold-table th, .hold-table td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.hold-table th { color: var(--text-dim); font-weight: 500; }
.hold-table td:first-child, .hold-table th:first-child { text-align: left; }
.hold-table td:nth-child(2), .hold-table th:nth-child(2) { text-align: left; }
.hold-table tr:last-child td { border-bottom: none; }
.hold-table .weight-bar {
  display: inline-block;
  height: 6px;
  border-radius: 3px;
  background: var(--accent);
  vertical-align: middle;
  margin-left: 8px;
}

/* ---------- 空态 & 提示 ---------- */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-dim);
  padding: 80px 0;
  font-size: 15px;
}
.toast {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  background: #2b2436;
  color: #ffd6d6;
  border: 1px solid #ff6b6b;
  padding: 10px 22px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 99;
  box-shadow: 0 6px 24px rgba(0,0,0,.4);
  animation: fadeIn .2s;
}
.toast.ok { background: #14281d; color: #b8f0cf; border-color: #2fbf71; }
@keyframes fadeIn { from { opacity: 0; transform: translateX(-50%) translateY(-8px);} to { opacity: 1; } }

footer.tip {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 20px 0 30px;
  border-top: 1px solid var(--border);
}

.hidden { display: none !important; }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .charts { grid-template-columns: 1fr; }
  .topbar { padding: 16px; }
  .fund-grid, .detail, .gold-wrap, .indices-wrap { padding-left: 16px; padding-right: 16px; }
}
