/* 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 { color: var(--muted); font-size: 12px; }
.gsearch-wrap { margin-left: auto; }
.gsearch-wrap input {
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 12px; font-size: 13px; width: 250px;
}
.gsearch-wrap input:focus { outline: 1px solid var(--accent); }
a.logout { color: var(--muted); font-size: 12px; cursor: pointer; }
a.logout:hover { color: var(--down); }
.alert-form { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.alert-form input, .alert-form select {
  background: var(--surface); color: var(--ink); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 13px;
}
.tg-status { background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 12px; font-size: 13px; color: var(--ink-2); }
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; }
nav.tabs .agent-link { color: #39d98a; padding: 9px 14px; white-space: nowrap;
  border-bottom: 2px solid transparent; }
nav.tabs .agent-link:hover { background: var(--surface-2); color: #72e7ad; }

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; }
.sr-tag { position: absolute; right: 2px; font-size: 10px; line-height: 16px; padding: 0 5px;
  border-radius: 3px; pointer-events: auto; color: #fff; opacity: .85; z-index: 2; }
.sr-tag.res { background: rgba(208, 59, 59, .75); }
.sr-tag.sup { background: rgba(12, 163, 12, .75); }
.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; }

/* ---- KOL ---- */
.kol-layout { display: grid; grid-template-columns: 340px 1fr; gap: 14px; align-items: start; }
@media (max-width: 900px) { .kol-layout { grid-template-columns: 1fr; } }
.kol-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.kol-chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px;
  padding: 4px 12px; font-size: 13px; color: var(--ink-2); display: inline-flex; gap: 6px; align-items: center; }
.kol-chip a { color: var(--accent); }
.kol-chip .x { cursor: pointer; color: var(--muted); }
.kol-chip .x:hover { color: var(--down); }
.kol-chip.pending { opacity: .55; }
.tweet { padding: 10px 0; border-bottom: 1px solid var(--grid); }
.tweet:last-child { border-bottom: none; }
.tweet .h { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.tweet .h b { color: var(--ink-2); }
.tweet .b { font-size: 13px; margin-top: 3px; line-height: 1.6; word-break: break-word; }
.tweet .b .ct { color: var(--accent); font-weight: 600; cursor: pointer; }
.tweet .m { color: var(--muted); font-size: 12px; margin-top: 3px; }
.kfilter { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.kfilter button { background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-2);
  border-radius: 6px; padding: 4px 12px; cursor: pointer; font-size: 12px; }
.kfilter button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---- 财报 ---- */
.earn-day { margin-bottom: 18px; }
.earn-day h3 { font-size: 14px; margin: 0 0 8px; color: var(--ink-2); }
.earn-day h3 .today-tag { color: var(--accent); font-size: 12px; margin-left: 8px; }
.badge { display: inline-block; font-size: 11px; border-radius: 4px; padding: 0 6px; margin-left: 6px;
  border: 1px solid var(--border); color: var(--muted); }
.badge.bmo { color: var(--accent-2); border-color: var(--accent-2); }
.badge.amc { color: var(--accent-3); border-color: var(--accent-3); }
.badge.star { color: var(--accent-2); border-color: var(--accent-2); }
.badge.kol { color: var(--accent); border-color: var(--accent); }
.badge.bull { color: var(--up); border-color: var(--up); cursor: help; }
.badge.bear { color: var(--down); border-color: var(--down); cursor: help; }
tr.bull-row { background: rgba(12, 163, 12, 0.06); }
.bull-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.bull-card { background: var(--surface); border: 1px solid var(--up); border-radius: 10px; padding: 12px 14px; }
.bull-card .bh { display: flex; gap: 10px; align-items: baseline; margin-bottom: 6px; }
.bull-card .bh .sym { font-size: 16px; }
.bull-card .score { color: var(--up); font-weight: 700; }
.breasons { margin: 0; padding: 0 0 0 4px; list-style: none; }
.breasons li { font-size: 12px; color: var(--ink-2); padding: 2px 0 2px 16px; position: relative; }
.breasons li::before { content: "✓"; position: absolute; left: 0; color: var(--up); }
.bwarn { font-size: 12px; color: var(--accent-2); margin-top: 6px; }

/* ---- 个股综合评估 ---- */
.assess-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .assess-cols { grid-template-columns: 1fr; } }
.assess-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.brisks { margin: 0; padding: 0 0 0 4px; list-style: none; }
.brisks li { font-size: 12px; color: var(--ink-2); padding: 2px 0 2px 16px; position: relative; }
.brisks li::before { content: "!"; position: absolute; left: 2px; color: var(--down); font-weight: 700; }
.rating-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--baseline); max-width: 480px; }
.rating-legend { display: flex; gap: 12px; flex-wrap: wrap; color: var(--ink-2); font-size: 12px; margin-top: 4px; }
.rating-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; }

/* ---- AI 深度解读 ---- */
.ai-loading { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 18px; text-align: center; color: var(--ink-2); line-height: 1.8; }
.ai-report { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 6px 18px 14px; line-height: 1.75; font-size: 13.5px; color: var(--ink-2); }
.ai-report .ai-h { color: var(--ink); font-size: 15px; margin: 14px 0 6px; padding-left: 9px;
  border-left: 3px solid var(--accent); }
.ai-report h4 { color: var(--ink); font-size: 13.5px; margin: 10px 0 4px; }
.ai-report p { margin: 6px 0; }
.ai-report .ai-ul { margin: 4px 0; padding-left: 20px; }
.ai-report code { background: var(--page); border-radius: 4px; padding: 0 5px; }
#pane-ibkr code { background: var(--page); border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 6px; font-size: 12px; user-select: all; }

/* 策略台 */
.perf-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 8px; }
@media (max-width: 800px) { .perf-cols { grid-template-columns: 1fr; } }
.perf-block { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.perf-block h3 { font-size: 14px; margin: 0 0 8px; color: var(--ink-2); }
.perf-block .cards { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.perf-block .card { padding: 8px 10px; }
.perf-block .card .v { font-size: 17px; }
.activity { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); overflow: hidden; }
.act-row { display: flex; gap: 10px; align-items: baseline; padding: 7px 14px; border-bottom: 1px solid var(--grid); font-size: 13px; }
.act-row:last-child { border-bottom: none; }
.act-ic { flex: none; }
.act-tm { flex: none; color: var(--muted); font-size: 12px; width: 88px; }
.act-tx { color: var(--ink-2); white-space: pre-wrap; word-break: break-word; }

/* AI 助手 */
.chat-box { max-width: 860px; }
.chat-msgs { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px;
  max-height: calc(100vh - 300px); overflow-y: auto; padding: 4px; }
.chat-msg { border-radius: 12px; padding: 10px 14px; font-size: 13.5px; line-height: 1.75;
  max-width: 92%; overflow-wrap: break-word; }
.chat-msg.user { align-self: flex-end; background: var(--accent); color: #fff; white-space: pre-wrap; }
.chat-msg.assistant { align-self: flex-start; background: var(--surface);
  border: 1px solid var(--border); }
.chat-msg.assistant .ai-report { font-size: 13.5px; }
.chat-msg .m { font-size: 11px; opacity: .6; margin-top: 4px; }
.chat-form { display: flex; gap: 10px; align-items: flex-end; }
.chat-form textarea { flex: 1; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; color: var(--ink); padding: 10px 12px; font: inherit; font-size: 13.5px;
  resize: vertical; min-height: 44px; max-height: 200px; }
.chat-form textarea:focus { outline: 1px solid var(--accent); }
.ai-report b { color: var(--ink); }

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; }
  /* 页签换行铺开:横向滚动在手机上没有滚动条提示,后面的页签形同隐藏 */
  nav.tabs { flex-wrap: wrap; }
  nav.tabs button { padding: 7px 10px; font-size: 13px; }
  .chat-msgs { max-height: none; }
  .chat-msg { max-width: 100%; }
  .chat-form textarea { min-width: 0; }
}
