/* ustocks 暗色金融面板 —— 色板取自 dataviz 参考实例(dark) */
:root {
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #222221;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;   /* 系列1 蓝 */
  --accent-2: #c98500; /* 系列3 黄 */
  --accent-3: #9085e9; /* 系列5 紫 */
  --up: #0ca30c;
  --down: #d03b3b;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }

/* ---- 头部 ---- */
header {
  padding: 14px 20px 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.brand h1 { font-size: 20px; margin: 0; font-weight: 700; }
.brand .sub { color: var(--muted); font-size: 12px; }
.freshness { margin-left: auto; color: var(--muted); font-size: 12px; }
nav.tabs { display: flex; gap: 2px; margin-top: 10px; overflow-x: auto; }
nav.tabs button {
  appearance: none; border: none; background: transparent; color: var(--ink-2);
  padding: 9px 14px; font-size: 14px; cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
nav.tabs button:hover { color: var(--ink); background: var(--surface-2); }
nav.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

main { padding: 18px 20px 60px; max-width: 1500px; margin: 0 auto; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
h2 { font-size: 16px; margin: 22px 0 10px; font-weight: 600; }
h2:first-child { margin-top: 0; }
.hint { color: var(--muted); font-size: 12px; }
.error-box { color: var(--down); padding: 12px; }

/* ---- 卡片 ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; position: relative;
}
.card .k { color: var(--muted); font-size: 12px; }
.card .v { font-size: 22px; font-weight: 700; margin-top: 2px; }
.card .d { font-size: 13px; margin-top: 2px; }
.card canvas.spark { position: absolute; right: 10px; bottom: 8px; opacity: .9; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--muted); }

/* ---- 涨跌宽度条 ---- */
.breadth-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin: 6px 0 4px; background: var(--baseline); }
.breadth-bar .seg-up { background: var(--up); }
.breadth-bar .seg-down { background: var(--down); }
.breadth-legend { display: flex; gap: 16px; color: var(--ink-2); font-size: 12px; }
.breadth-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

/* ---- 表格 ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 12px; text-align: right; white-space: nowrap; }
th:first-child, td:first-child, th.l, td.l { text-align: left; }
thead th {
  color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--grid);
  position: sticky; top: 0; background: var(--surface); cursor: pointer; user-select: none;
}
thead th.sorted { color: var(--ink); }
tbody tr { border-bottom: 1px solid var(--grid); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num { font-variant-numeric: tabular-nums; }
.sym { color: var(--accent); font-weight: 600; cursor: pointer; }
.name-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }

/* ---- 筛选行 ---- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.filters input[type=text], .filters select {
  background: var(--surface); color: var(--ink); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; font-size: 13px;
}
.filters input[type=text]:focus, .filters select:focus { outline: 1px solid var(--accent); }
button.btn {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 8px 14px; font-size: 13px; cursor: pointer;
}
button.btn:hover { filter: brightness(1.1); }
button.btn.ghost { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border); }
button.btn.danger { background: transparent; color: var(--down); border: 1px solid var(--border); padding: 4px 10px; }

/* ---- 热力图 ---- */
.heatmap { display: flex; flex-direction: column; gap: 14px; }
.hm-sector { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.hm-sector h3 { margin: 0 0 8px; font-size: 13px; color: var(--ink-2); font-weight: 600; display: flex; gap: 10px; align-items: baseline; }
.hm-sector h3 .chg { font-size: 12px; }
.hm-tiles { display: flex; flex-wrap: wrap; gap: 2px; }
.hm-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 3px; cursor: pointer; color: #fff; min-width: 34px; min-height: 34px;
  padding: 2px; overflow: hidden;
}
.hm-tile:hover { outline: 2px solid var(--ink); z-index: 2; }
.hm-tile .s { font-weight: 700; font-size: 12px; line-height: 1.2; }
.hm-tile .c { font-size: 10px; opacity: .95; line-height: 1.2; }
.hm-legend { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.hm-legend .sw { width: 26px; height: 12px; border-radius: 2px; }

/* ---- 宏观 ---- */
.macro-group { margin-bottom: 20px; }
.macro-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.macro-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.macro-card .head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.macro-card .head .nm { font-weight: 600; }
.macro-card .head .val { font-variant-numeric: tabular-nums; font-weight: 700; }
.macro-card .meta { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.macro-card canvas { width: 100% !important; height: 120px !important; }

/* ---- 情绪 ---- */
.senti-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.senti-box { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.senti-box h3 { margin: 0 0 8px; font-size: 14px; }
.post { padding: 8px 0; border-bottom: 1px solid var(--grid); }
.post:last-child { border-bottom: none; }
.post .t { font-size: 13px; }
.post .m { color: var(--muted); font-size: 12px; margin-top: 2px; }
.trend-item { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--grid); align-items: baseline; }
.trend-item:last-child { border-bottom: none; }
.trend-item .rank { color: var(--muted); width: 22px; font-variant-numeric: tabular-nums; }
.trend-item .nm { color: var(--ink-2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trend-item .w { color: var(--muted); font-size: 12px; }

/* ---- 弹窗 ---- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 100;
  display: none; align-items: flex-start; justify-content: center; padding: 4vh 16px;
}
.modal-mask.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  width: 100%; max-width: 900px; max-height: 92vh; overflow-y: auto; padding: 18px 20px;
}
.modal .mhead { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.modal .mhead h3 { margin: 0; font-size: 20px; }
.modal .mhead .px { font-size: 20px; font-weight: 700; }
.modal .mhead .close { margin-left: auto; cursor: pointer; color: var(--muted); font-size: 22px; background: none; border: none; }
.range-btns { display: flex; gap: 6px; margin: 12px 0 8px; }
.range-btns button {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-2);
  border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 12px;
}
.range-btns button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.modal .chart-box { height: 300px; position: relative; }
.modal .chart-box canvas { width: 100% !important; height: 100% !important; }
.fund-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; margin-top: 14px; }
.fund-grid .fg { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.fund-grid .fg .k { color: var(--muted); font-size: 11px; }
.fund-grid .fg .v { font-size: 14px; font-weight: 600; margin-top: 1px; }
.signals { margin: 12px 0 0; padding: 0; list-style: none; }
.signals li { padding: 4px 0 4px 18px; position: relative; color: var(--ink-2); font-size: 13px; }
.signals li::before { content: "◆"; position: absolute; left: 0; color: var(--accent); font-size: 10px; top: 7px; }
.desc { color: var(--ink-2); font-size: 13px; margin-top: 12px; line-height: 1.6; }
.stream-stat { display: flex; gap: 14px; margin: 10px 0 4px; font-size: 13px; }
.msg { padding: 7px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }
.msg:last-child { border-bottom: none; }
.msg .u { color: var(--muted); font-size: 12px; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; margin-left: 6px; border: 1px solid var(--border); }
.tag.bull { color: var(--up); border-color: var(--up); }
.tag.bear { color: var(--down); border-color: var(--down); }

/* ---- 自选 ---- */
.watch-add { display: flex; gap: 10px; margin-bottom: 14px; }
.watch-add input {
  background: var(--surface); color: var(--ink); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; font-size: 14px; width: 200px; text-transform: uppercase;
}

/* ---- 板块条形 ---- */
.sector-chart-box { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px; height: 380px; margin-bottom: 14px; }
.sector-chart-box canvas { width: 100% !important; height: 100% !important; }

footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; padding: 14px 20px 30px; max-width: 1500px; margin: 0 auto; line-height: 1.8; }

.loading { color: var(--muted); padding: 24px; text-align: center; }
@media (max-width: 700px) {
  main { padding: 12px 10px 40px; }
  .modal { padding: 14px; }
}
