:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #1f2733;
  --muted: #8a94a6;
  --line: #e8ecf2;
  --brand: #2f6df0;
  --up: #e54545;   /* 涨 = 红 */
  --down: #1aa260; /* 跌 = 绿 */
  --shadow: 0 2px 10px rgba(31, 39, 51, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.layout { display: flex; min-height: 100vh; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: 200px;
  flex: 0 0 200px;
  background: #1f2733;
  color: #cfd6e0;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.brand {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  line-height: 1.35;
  margin-bottom: 22px;
  letter-spacing: 1px;
}
.nav { display: flex; flex-direction: column; gap: 8px; }
.nav-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: #cfd6e0;
  text-align: left;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-btn:hover { background: rgba(255,255,255,.08); }
.nav-btn.active {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}
.legend {
  margin-top: auto;
  font-size: 12px;
  color: #9aa4b2;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-left: 8px; }
.dot.up { background: var(--up); }
.dot.down { background: var(--down); }

/* ---------- 主区域 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h1 { margin: 0; font-size: 22px; }
.sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.hint { color: var(--muted); font-size: 12px; max-width: 320px; text-align: right; }

.content { padding: 24px 28px 60px; }

/* ---------- 今日价格卡片 ---------- */
.today-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 30px;
}
.today-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.tc-name { font-size: 14px; color: var(--muted); }
.tc-value { font-size: 26px; font-weight: 700; margin: 6px 0 2px; }
.tc-date { font-size: 12px; color: var(--muted); }
.tc-chg { font-size: 14px; font-weight: 600; margin-top: 6px; }
.tc-prev { font-size: 11px; color: var(--muted); margin-top: 2px; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--muted); }

/* ---------- 指标图表 ---------- */
.ind-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px 8px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.ind-section h2 { font-size: 17px; margin: 0 0 12px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-box { border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.chart-title { font-size: 13px; color: var(--muted); padding: 4px 6px; }
.chart { width: 100%; height: 320px; }

/* ---------- 区间查询与计算 ---------- */
.calc-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 30px;
  box-shadow: var(--shadow);
}
.calc-title { font-size: 17px; font-weight: 600; margin-bottom: 12px; }
.calc-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; }
.calc-field { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; }
.calc-field select, .calc-field input {
  font-size: 14px; color: var(--ink);
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; min-width: 150px;
}
.calc-btn {
  appearance: none; border: none; cursor: pointer;
  background: var(--brand); color: #fff; font-size: 14px; font-weight: 600;
  padding: 9px 20px; border-radius: 8px;
}
.calc-btn:hover { filter: brightness(1.05); }
.calc-presets { margin-top: 12px; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.calc-presets button {
  appearance: none; cursor: pointer; font-size: 13px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 5px 12px; border-radius: 16px;
}
.calc-presets button:hover { border-color: var(--brand); color: var(--brand); }
.calc-hl { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; font-size: 13px; color: var(--ink); cursor: pointer; }
.calc-result {
  margin-top: 14px; display: flex; flex-wrap: wrap; gap: 22px;
  font-size: 14px; color: var(--ink); align-items: baseline;
}
.calc-result b { font-size: 17px; font-weight: 700; }
.calc-result .cr-avg { color: var(--brand); }
.calc-result .cr-empty { color: var(--muted); }

@media (max-width: 900px) {
  .sidebar { width: 140px; flex-basis: 140px; }
  .chart-grid { grid-template-columns: 1fr; }
  .content { padding: 18px; }
  .calc-field select, .calc-field input { min-width: 120px; }
}
