/* ============================================================
   数据驿站 · 大盘星图（A股热力图）—— 复刻 dapan.net 大盘云图
   结构：
   - 左侧侧栏（logo + 市场切换 + 板块筛选 + 工具）
   - 右侧主体（顶栏统计 + 涨跌幅图例色带 + 全屏 treemap）
   配色：深色 #0f1319 · 红涨 #d32e32 · 绿跌 #1fb546
   ============================================================ */

:root {
  --st-bg: #0f1319;
  --st-card: #141a24;
  --st-card2: #171e2a;
  --st-border: #1f2734;
  --st-border2: #2a3444;
  --st-ink: #e8eef7;
  --st-ink-2: #9aa8bd;
  --st-ink-3: #5f7089;
  --st-up: rgb(211, 46, 50);
  --st-down: rgb(31, 181, 70);
  --st-flat: #7a8aa8;
  --st-brand: #ef4444;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--st-bg);
  color: var(--st-ink);
  min-height: 100vh;
}

.star-body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
}

/* ---------------- 整体布局：左侧栏 + 右主体 ---------------- */
.star-shell {
  display: flex;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ---------------- 左侧侧栏 ---------------- */
.star-aside {
  flex: 0 0 200px;
  width: 200px;
  display: flex;
  flex-direction: column;
  background: var(--st-card);
  border-right: 1px solid var(--st-border);
  overflow: hidden;
}

.star-aside-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 8px 12px;
  border-bottom: 1px solid var(--st-border);
  gap: 2px;
}
.star-aside-brand .b1 {
  font-size: 22px; font-weight: 800; letter-spacing: .02em; color: #fff;
}
.star-aside-brand .b2 {
  font-size: 12px; color: var(--st-brand); letter-spacing: .06em;
}

/* 市场切换（A股/港股/ETF/可转债） */
.star-tabs {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--st-border);
}
.star-tabs a {
  display: flex; align-items: center; justify-content: center;
  height: 36px; font-size: 11px; font-weight: 600; color: var(--st-ink-2);
  text-decoration: none; transition: color .15s;
}
.star-tabs a.on { background: var(--st-brand); color: #fff; }
.star-tabs a:hover { color: var(--st-ink); }

/* 最近刷新 */
.star-refresh {
  display: flex; align-items: center; justify-content: space-between;
  margin: 8px 8px 4px; padding: 5px 8px;
  border: 1px solid var(--st-border); border-radius: 4px;
  font-size: 10px; color: var(--st-ink-3);
}
.star-refresh .updating { display: inline-flex; align-items: center; gap: 4px; color: var(--st-ink-2); font-weight: 600; }
.star-refresh .spin {
  width: 8px; height: 8px; border: 1.5px solid var(--st-brand);
  border-top-color: transparent; border-radius: 50%;
  animation: stspin 1s linear infinite;
}
@keyframes stspin { to { transform: rotate(360deg); } }

/* 板块筛选列表 */
.star-filters {
  flex: 1; overflow-y: auto; padding: 4px 6px 12px;
}
.star-filter {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 7px 9px; margin-bottom: 2px;
  background: transparent; border: 1px solid var(--st-border); border-radius: 4px;
  color: var(--st-ink); font-size: 12px; text-align: left; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.star-filter:hover { background: var(--st-card2); }
.star-filter.on { border-color: var(--st-brand); background: rgba(239,68,68,.12); }
.star-filter .lbl { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.star-filter .val { font-weight: 600; tabular-nums; color: var(--st-ink-3); }
.star-filter .val.up { color: var(--st-up); }
.star-filter .val.down { color: var(--st-down); }

/* 侧栏底部工具按钮 */
.star-aside-tools {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  padding: 8px; border-top: 1px solid var(--st-border);
}
.star-aside-tools button {
  height: 28px; border: 1px solid var(--st-border); border-radius: 4px;
  background: var(--st-card); color: var(--st-ink-2);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: color .12s, border-color .12s;
}
.star-aside-tools button:hover { color: var(--st-ink); border-color: var(--st-border2); }
.star-aside-tools button svg { width: 14px; height: 14px; }

/* ---------------- 右侧主体 ---------------- */
.star-main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* 顶栏 */
.star-bar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--st-border);
  background: var(--st-bg);
  flex-wrap: wrap;
}
.star-stats { display: flex; gap: 20px; align-items: baseline; }
.star-stat { display: flex; align-items: baseline; gap: 6px; font-size: 13px; }
.star-stat b { font-size: 18px; font-weight: 700; tabular-nums; }
.star-stat span { color: var(--st-ink-3); font-size: 12px; }
.star-stat.up b { color: var(--st-up); }
.star-stat.down b { color: var(--st-down); }
.star-stat.flat b { color: var(--st-flat); }

/* 图例色带 */
.star-legend {
  display: flex; align-items: center; gap: 10px; margin-left: auto;
  flex: 0 0 auto;
}
.star-legend-bar {
  position: relative; width: 220px; height: 12px; border-radius: 6px;
  background: linear-gradient(to right,
    rgb(33,168,71) 0%, rgb(35,159,72) 12.5%, rgb(36,150,73) 25%,
    rgb(38,139,74) 37.5%, rgb(72,79,92) 50%, rgb(157,66,70) 62.5%,
    rgb(171,61,65) 75%, rgb(183,56,60) 87.5%, rgb(194,52,56) 100%);
}
.star-legend-labels {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: space-between; padding: 0 4px;
  font-size: 8px; font-weight: 600; color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.55); pointer-events: none;
}
.star-legend-tip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--st-ink-3);
}
.star-legend-tip svg { width: 11px; height: 11px; }

/* 工具按钮（全屏/重置等） */
.star-bar-tools { display: flex; gap: 6px; margin-left: auto; flex: 0 0 auto; }
.star-bar-tools button {
  width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent;
  color: var(--st-ink-3); display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: color .12s, background .12s;
}
.star-bar-tools button:hover { color: var(--st-ink); background: rgba(255,255,255,.05); }
.star-bar-tools button svg { width: 15px; height: 15px; }

/* 热力图容器（canvas） */
.star-map {
  position: relative; flex: 1; min-height: 0;
  background: var(--st-bg); overflow: hidden;
  cursor: grab;
}
.star-map.dragging { cursor: grabbing; }
.star-map canvas { display: block; }
.star-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--st-ink-3); font-size: 13px;
}

/* ---------------- 悬浮弹窗（个股 K 线 + 行业排行） ---------------- */
.star-tip {
  position: absolute; z-index: 50; width: 340px; max-width: 90vw;
  background: var(--st-card2); border: 1px solid var(--st-border2); border-radius: 10px;
  box-shadow: 0 18px 48px rgba(0,0,0,.5); overflow: hidden; pointer-events: auto;
  font-size: 12px;
}
.star-tip-hd {
  display: flex; align-items: baseline; gap: 8px; padding: 10px 12px 8px;
  border-bottom: 1px solid var(--st-border);
}
.star-tip-name { font-size: 14px; font-weight: 700; color: #fff; }
.star-tip-code { font-size: 11px; color: var(--st-ink-3); }
.star-tip-pct { margin-left: auto; font-size: 14px; font-weight: 700; tabular-nums; }
.star-tip-pct.up { color: var(--st-up); }
.star-tip-pct.down { color: var(--st-down); }
.star-tip-kline { padding: 8px 10px; }
.star-tip-kline canvas { display: block; width: 100%; height: 120px; }
.star-tip-tabs {
  display: flex; gap: 0; padding: 0 10px; border-bottom: 1px solid var(--st-border);
}
.star-tip-tabs button {
  padding: 6px 10px; font-size: 11px; color: var(--st-ink-3); background: transparent; border: 0;
  border-bottom: 2px solid transparent; cursor: pointer;
}
.star-tip-tabs button.on { color: var(--st-ink); border-bottom-color: var(--st-brand); font-weight: 600; }
.star-tip-list { max-height: 220px; overflow-y: auto; padding: 4px 0; }
.star-tip-row {
  display: flex; align-items: center; gap: 8px; padding: 5px 12px;
  cursor: pointer; transition: background .1s;
}
.star-tip-row:hover, .star-tip-row.on { background: rgba(255,255,255,.05); }
.star-tip-row .rk { width: 18px; text-align: center; font-size: 11px; color: var(--st-ink-3); flex: none; }
.star-tip-row .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--st-ink); }
.star-tip-row .pc { width: 52px; text-align: right; font-weight: 600; tabular-nums; }
.star-tip-row .pc.up { color: var(--st-up); }
.star-tip-row .pc.down { color: var(--st-down); }
.star-tip-hint {
  padding: 5px 12px 8px; font-size: 10px; color: var(--st-ink-3);
  border-top: 1px solid var(--st-border); line-height: 1.6;
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 768px) {
  .star-aside {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 40;
    transform: translateX(-100%); transition: transform .25s ease; width: 220px;
  }
  .star-aside.open { transform: translateX(0); }
  .star-legend-bar { width: 120px; }
  .star-stats { gap: 10px; }
  .star-stat b { font-size: 15px; }
}
