:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f0f2f6;
  --border: #e1e5ec;
  --text: #121826;
  --muted: #667085;
  --accent: #2f6fed;
  --green: #12a36b;
  --red: #e0453a;
  --warn: #d48806;
  --grid: rgba(18, 24, 38, 0.06);
  --vwap: #c77d10;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f17; --surface: #121826; --surface-2: #1a2232; --border: #232c3d;
    --text: #e6eaf2; --muted: #8b95a8; --accent: #5b8cff; --green: #22c27f; --red: #ff5a4f;
    --warn: #f0b429; --grid: rgba(230, 234, 242, 0.06); --vwap: #f0b429;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0f17; --surface: #121826; --surface-2: #1a2232; --border: #232c3d;
  --text: #e6eaf2; --muted: #8b95a8; --accent: #5b8cff; --green: #22c27f; --red: #ff5a4f;
  --warn: #f0b429; --grid: rgba(230, 234, 242, 0.06); --vwap: #f0b429;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}
/* 红涨绿跌（A股习惯） */
:root { --up: var(--green); --down: var(--red); }
:root[data-colors="cn"] { --up: var(--red); --down: var(--green); }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h2 { font-size: 15px; margin: 0; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.r { text-align: right; }
.up { color: var(--up); }
.down { color: var(--down); }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; }
.gap { gap: 8px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 24px;
  padding: 10px clamp(16px, 2vw, 40px); background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; white-space: nowrap; }
.logo { width: 22px; height: 22px; border-radius: 5px; display: block; flex: none; }
.nav { display: flex; gap: 4px; overflow-x: auto; }
.nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.nav a:hover { color: var(--text); background: var(--surface-2); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.session { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.open { background: var(--up); box-shadow: 0 0 0 3px color-mix(in srgb, var(--up) 25%, transparent); }
.dot.ext { background: var(--warn); }

/* 占满浏览器宽度，两侧边距随窗口缩放 */
main { width: 100%; padding: 20px clamp(16px, 2vw, 40px) 40px; display: flex; flex-direction: column; gap: 20px; }
.grid { display: grid; gap: 20px; }
.grid.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.grid.market { grid-template-columns: clamp(300px, 24%, 460px) minmax(0, 1fr); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.tag { font-size: 11px; color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 50%, transparent); padding: 1px 8px; border-radius: 999px; }

/* Buttons & inputs */
.btn {
  border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 8px;
  padding: 8px 14px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--down); }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; padding: 2px 6px; border-radius: 6px; }
.icon-btn:hover { color: var(--down); background: var(--surface-2); }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; margin-top: 4px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); border-color: var(--accent); }
label { font-size: 12px; color: var(--muted); }
textarea { resize: vertical; }

/* Risk banner */

/* Tables */
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.table th.r, .table td.r { text-align: right; }
.table td { padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
#watchTable tbody tr { cursor: pointer; }
#watchTable tbody tr:hover { background: var(--surface-2); }
#watchTable tbody tr.active { background: color-mix(in srgb, var(--accent) 10%, transparent); }
#watchTable td:first-child { font-weight: 600; }
.flash-up { animation: flashUp .6s; }
.flash-down { animation: flashDown .6s; }
@keyframes flashUp { from { background: color-mix(in srgb, var(--up) 25%, transparent); } }
@keyframes flashDown { from { background: color-mix(in srgb, var(--down) 25%, transparent); } }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.up { background: color-mix(in srgb, var(--up) 14%, transparent); }
.pill.down { background: color-mix(in srgb, var(--down) 14%, transparent); }
.table-scroll { overflow-x: auto; }
.add-symbol { display: flex; gap: 8px; margin-bottom: 8px; }
.add-symbol input { margin: 0; text-transform: uppercase; }

/* Chart */
.chart-meta { text-align: right; }
.price { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-wrap { position: relative; height: clamp(320px, 56vh, 820px); }
#chart, .chart-wrap canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
.crosshair-info {
  position: absolute; top: 6px; left: 8px; font-size: 12px; background: color-mix(in srgb, var(--surface) 90%, transparent);
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; pointer-events: none; font-variant-numeric: tabular-nums;
}
.levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 12px; }
.level { background: var(--surface-2); border-radius: 8px; padding: 6px 10px; }
.level .k { font-size: 11px; color: var(--muted); }
.level .v { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Forms */

/* KPIs */


/* Checklist */

.footer { text-align: center; padding: 0 24px 32px; }

@media (max-width: 1100px) {
  .grid.market { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 16px; }
  .nav { order: 3; width: 100%; }
  main { padding: 16px; gap: 16px; }
  .grid.two { grid-template-columns: 1fr; }
  .levels { grid-template-columns: repeat(3, 1fr); }
  .chart-wrap { height: clamp(280px, 48vh, 420px); }
  .hide-sm { display: none; }
  .session .muted { display: none; }
}
.tag.live { color: var(--green); border-color: color-mix(in srgb, var(--green) 50%, transparent); }
.tag.bad { color: var(--red); border-color: color-mix(in srgb, var(--red) 50%, transparent); }
.feed-error { color: var(--red); background: color-mix(in srgb, var(--red) 10%, transparent); border-radius: 8px; padding: 8px 10px; margin: 0 0 10px; word-break: break-word; }


/* K 线周期切换 */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12px; padding: 4px 10px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.seg button:hover:not(:disabled) { color: var(--text); }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.seg button:disabled { opacity: .4; cursor: not-allowed; }
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.chart-card .card-head { flex-wrap: wrap; }
.tf-seg { margin-right: 12px; }
.ln-key::before { content: ""; display: inline-block; width: 12px; height: 2px; border-radius: 2px; background: var(--c); vertical-align: 3px; margin-right: 4px; }
@media (max-width: 760px) { .tf-seg { order: 3; margin: 0; width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); } }

/* 查看任意一天 */
.date-nav { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.date-nav input { width: auto; margin: 0; padding: 4px 6px; font-size: 12px; }
.date-nav .icon-btn { font-size: 11px; padding: 4px 6px; }
.date-nav .icon-btn:hover:not(:disabled) { color: var(--text); }
.date-nav :disabled { opacity: .4; cursor: not-allowed; }
.date-nav .btn { margin-left: 4px; }
.tag.hist { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
@media (max-width: 760px) { .date-nav { order: 3; margin: 0; width: 100%; } .date-nav input { flex: 1; } }

/* K 线缩放 */
.chart-wrap canvas { touch-action: pan-y; }
.chart-wrap canvas.zoomed { cursor: grab; }
.chart-wrap canvas.zoomed:active { cursor: grabbing; }
.zoom-ctl { position: absolute; top: 6px; right: 64px; display: flex; gap: 4px; opacity: .55; transition: opacity .15s; }
.chart-wrap:hover .zoom-ctl, .zoom-ctl:focus-within { opacity: 1; }
.zoom-ctl button {
  min-width: 26px; height: 26px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px;
  background: color-mix(in srgb, var(--surface) 90%, transparent); color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
}
.zoom-ctl button:hover { background: var(--surface-2); }
.zoom-ctl button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (hover: none) { .zoom-ctl { opacity: 1; } }

/* 通用：新闻列表、代码芯片、标签 */
:root { --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; } }
:root[data-theme="dark"] { --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; }
.news-list { list-style: none; margin: 0; padding: 0; overflow: auto; }
.news-list li { padding: 9px 2px; border-bottom: 1px solid var(--border); }
.news-list li:last-child { border-bottom: 0; }
.news-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 3px; }
.news-head { color: var(--text); text-decoration: none; font-weight: 600; line-height: 1.45; }
.news-head:hover { color: var(--accent); text-decoration: underline; }
.sym-chip { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; cursor: pointer; }
.sym-chip:hover { border-color: var(--accent); color: var(--accent); }
.chip { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; margin: 1px 4px 1px 0; border: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.chip.topic { color: var(--muted); }
.chip.t-founder, .chip.t-insider { color: var(--s2); border-color: color-mix(in srgb, var(--s2) 45%, transparent); }
.chip.t-earnings, .chip.t-analyst { color: var(--s1); border-color: color-mix(in srgb, var(--s1) 45%, transparent); }
.chip.t-product, .chip.t-deal { color: var(--s3); border-color: color-mix(in srgb, var(--s3) 45%, transparent); }
.chip.t-legal { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, transparent); }
.cat-cell { white-space: normal !important; }
.table.compact td, .table.compact th { padding: 6px 6px; white-space: normal; }
.table.compact thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.nowrap { white-space: nowrap !important; }
.side-scroll { max-height: 320px; overflow: auto; }

/* 热点榜 */
.hot-tools { flex-wrap: wrap; justify-content: flex-end; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.deep-form { display: flex; gap: 6px; }
.deep-form input { margin: 0; width: 190px; text-transform: uppercase; }
.hot-scroll { max-height: clamp(360px, 60vh, 760px); overflow: auto; }
#hotTable thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
#hotTable th.sortable { cursor: pointer; user-select: none; }
.hot-row { cursor: pointer; }
.hot-row:hover { background: var(--surface-2); }
.hot-row.active { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.heatbar { display: inline-block; height: 8px; border-radius: 0 4px 4px 0; background: var(--accent); vertical-align: middle; }

/* 个股深挖 */
#deep { display: flex; flex-direction: column; gap: 20px; scroll-margin-top: 70px; }
.deep-empty p { margin: 6px 0 0; }
.deep-head { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.deep-head > div:first-child { flex: 1; min-width: 240px; }
.deep-sym { font-size: 26px; }
.deep-price { text-align: right; font-variant-numeric: tabular-nums; }
.verdict { display: grid; grid-template-columns: 220px minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.verdict-label { font-size: 30px; font-weight: 800; margin: 4px 0 10px; }
.gauge { position: relative; height: 10px; border-radius: 999px; background: linear-gradient(90deg, var(--down), var(--surface-2) 50%, var(--up)); margin-bottom: 8px; }
.gauge-mark { position: absolute; top: -4px; width: 4px; height: 18px; border-radius: 2px; background: var(--text); transform: translateX(-2px); }
.signals td { vertical-align: top; }
.sbar { position: relative; display: inline-block; width: 60px; height: 8px; border-radius: 999px; background: var(--surface-2); vertical-align: middle; }
.sbar-fill { position: absolute; top: 0; bottom: 0; border-radius: 999px; }
.sbar-fill.pos { background: var(--up); } .sbar-fill.neg { background: var(--down); }
.verdict-side h3 { font-size: 13px; margin: 0 0 6px; }
.ladder, .watch { list-style: none; margin: 0 0 14px; padding: 0; font-size: 13px; }
.ladder li { display: grid; grid-template-columns: 1fr auto 64px; gap: 8px; padding: 3px 6px; border-radius: 6px; }
.ladder li span:last-child { text-align: right; }
.ladder li.cur { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.watch li { padding: 4px 0 4px 14px; position: relative; color: var(--text); }
.watch li::before { content: "•"; position: absolute; left: 2px; color: var(--accent); }
.deep-grid h3 { font-size: 14px; margin: 0; }
.ret-tiles { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 10px; }
.tile { background: var(--surface-2); border-radius: 8px; padding: 6px 8px; }
.tile .k { font-size: 11px; color: var(--muted); }
.tile .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.spark { width: 100%; height: 70px; display: block; margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; font-size: 13px; margin-bottom: 8px; }
.kv > div { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--border); padding: 4px 0; }
.kv span { color: var(--muted); }
.kv b { font-variant-numeric: tabular-nums; text-align: right; }
.relchart, .hourly { width: 100%; height: auto; display: block; margin-bottom: 8px; }
.relchart text, .hourly text { fill: var(--muted); font-size: 10px; font-family: inherit; }
.relchart .ink { fill: var(--text); font-size: 11px; }
.relchart .grid-line { stroke: var(--grid); } .relchart .base-line, .hourly .base-line { stroke: var(--border); }
tr.me td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.topic-list { display: flex; flex-direction: column; gap: 4px; }
.topic-btn { display: grid; grid-template-columns: 120px 40px 1fr auto; align-items: center; gap: 8px; text-align: left; border: 1px solid transparent; background: none; color: var(--text); font: inherit; padding: 4px 6px; border-radius: 8px; cursor: pointer; }
.topic-btn:hover { background: var(--surface-2); }
.topic-btn.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.spike-tag { font-size: 11px; font-weight: 700; color: var(--s2); }
.deep-news { max-height: 520px; }
.sent { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); opacity: .5; }
.sent.s1 { background: var(--up); opacity: 1; } .sent.s-1 { background: var(--down); opacity: 1; }
.ptbar { position: relative; height: 10px; background: var(--surface-2); border-radius: 999px; margin: 10px 0 4px; }
.pt-range { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--accent) 35%, transparent); border-radius: 999px; }
.pt-mark { position: absolute; top: -4px; width: 3px; height: 18px; border-radius: 2px; transform: translateX(-1px); }
.pt-mark.avg { background: var(--accent); } .pt-mark.cur { background: var(--text); }
.ptlabels { display: flex; justify-content: space-between; margin-bottom: 10px; }
.rating-bar { display: flex; height: 22px; border-radius: 6px; overflow: hidden; font-size: 11px; font-weight: 600; margin-bottom: 10px; }
.rb { display: flex; align-items: center; justify-content: center; color: #fff; white-space: nowrap; overflow: hidden; }
.rb.buy { background: var(--up); } .rb.hold { background: var(--muted); } .rb.sell { background: var(--down); }
.next-earn { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; font-size: 13px; }
@media (max-width: 1200px) { .verdict { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .ret-tiles { grid-template-columns: repeat(4, 1fr); }
  .kv { grid-template-columns: 1fr; }
  .deep-form input { width: 140px; }
  .topic-btn { grid-template-columns: 110px 32px 1fr; }
  .topic-btn .spike-tag { grid-column: 1 / -1; }
}

.error { color: var(--down); margin: 10px 0 0; }

/* 每日焦点 */
#daily { scroll-margin-top: 70px; }
.daily-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.daily-sym { font-size: 26px; font-weight: 800; }
.daily-title { font-size: 17px; margin: 6px 0 4px; line-height: 1.45; }
.daily-snap { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.daily-sum { line-height: 1.75; margin: 12px 0; }
.daily-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }
.daily-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.daily-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 12px; }
.daily-box { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.daily-box h4 { margin: 0 0 8px; font-size: 14px; }
.daily-box p { margin: 0 0 10px; line-height: 1.6; }
.daily-box ul { margin: 0; padding-left: 18px; line-height: 1.65; font-size: 13.5px; }
.daily-box li { margin: 3px 0; }
.daily-box .table td, .daily-box .table th { background: transparent; }
.daily-box .ladder { padding-left: 0; }
.daily-more summary { cursor: pointer; font-weight: 600; margin: 4px 0; }
@media (max-width: 1000px) { .daily-grid, .daily-grid.three, .daily-grid.two { grid-template-columns: 1fr; } .daily-snap { align-items: flex-start; text-align: left; } }

/* 自选列表：删除按钮默认隐藏，鼠标移到该行或键盘聚焦时显示（触屏设备没有悬停，保持显示） */
@media (hover: hover) {
  #watchTable [data-remove] { opacity: 0; transition: opacity .12s; }
  #watchTable tbody tr:hover [data-remove], #watchTable [data-remove]:focus-visible { opacity: 1; }
}

.hot-row.inelig { opacity: .55; }
.ln-key.dash::before { height: 0; border-radius: 0; background: none; border-top: 2px dotted var(--c); }
.ext-line { margin-top: 2px; white-space: nowrap; }
.ext-sub { font-size: 11px; font-weight: 500; line-height: 1.2; margin-top: 1px; font-variant-numeric: tabular-nums; }

/* 自选拖拽排序 */
#watchTable td:first-child { position: relative; }
#watchTable .grip { position: absolute; left: -7px; top: 50%; width: 8px; height: 14px; margin-top: -7px; cursor: grab; touch-action: none; user-select: none;
  background-image: radial-gradient(circle, var(--muted) 1.1px, transparent 1.5px); background-size: 4px 4px; }
@media (hover: none) { #watchTable .grip::after { content: ""; position: absolute; inset: -12px -6px; } }
@media (hover: hover) {
  #watchTable .grip { opacity: 0; transition: opacity .12s; }
  #watchTable tbody tr:hover .grip { opacity: 1; }
}
#watchTable tbody tr.dragging { background: var(--surface-2); box-shadow: 0 2px 10px rgba(0, 0, 0, .18); position: relative; z-index: 1; }
#watchTable tbody tr.dragging td { opacity: .85; }
body.drag-sorting, body.drag-sorting * { cursor: grabbing !important; user-select: none; }
