/* A股盯盘系统 · 深色主题
   配色遵循 A 股习惯：红涨绿跌 */

:root {
  color-scheme: dark;

  --bg: #0d1117;
  --bg-panel: #151b23;
  --bg-panel-2: #1a222c;
  --bg-hover: #212c38;
  --bg-active: #263341;
  --border: #232e3b;
  --border-light: #2d3a49;

  --text: #e6edf3;
  --text-dim: #9aa8b8;
  --text-mute: #64748b;

  --up: #f0463c;
  --up-bg: rgba(240, 70, 60, 0.12);
  --down: #24a35a;
  --down-bg: rgba(36, 163, 90, 0.12);
  --flat: #8b98a8;

  --accent: #3b82f6;
  --accent-dim: rgba(59, 130, 246, 0.15);
  --warn: #f59e0b;
  --scrollbar: #2f3d4d;
  --scrollbar-hover: #3d4d60;
  --chart-grid: #1e2836;
  --chart-axis: #64748b;
  --chart-pointer: #3d4d60;
  --chart-tooltip-bg: rgba(21, 27, 35, 0.96);
  --chart-zoom-bg: #131a22;

  --radius: 8px;
  --radius-sm: 5px;
  --mono: 'SF Mono', 'JetBrains Mono', Menlo, Consolas, 'Courier New', monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;

  --col-left-w: 268px;
  --col-right-w: 400px;
  --bottom-h: 232px;
}

:root[data-theme='light'] {
  color-scheme: light;

  --bg: #f4f7fb;
  --bg-panel: #ffffff;
  --bg-panel-2: #f8fafc;
  --bg-hover: #eef4fb;
  --bg-active: #e6f0ff;
  --border: #d9e2ee;
  --border-light: #c8d4e3;

  --text: #172033;
  --text-dim: #475569;
  --text-mute: #718096;

  --up: #d9291f;
  --up-bg: rgba(217, 41, 31, 0.1);
  --down: #15803d;
  --down-bg: rgba(21, 128, 61, 0.1);
  --flat: #64748b;

  --accent: #2563eb;
  --accent-dim: rgba(37, 99, 235, 0.13);
  --warn: #d97706;
  --scrollbar: #cbd5e1;
  --scrollbar-hover: #94a3b8;
  --chart-grid: #dce5f0;
  --chart-axis: #64748b;
  --chart-pointer: #94a3b8;
  --chart-tooltip-bg: rgba(255, 255, 255, 0.96);
  --chart-zoom-bg: #eef4fb;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-hover);
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  outline: none;
  transition: border-color 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.up {
  color: var(--up);
}
.down {
  color: var(--down);
}
.flat {
  color: var(--flat);
}

/* ---------------------------------------------------------------- 登录页 */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59, 130, 246, 0.12), transparent),
    var(--bg);
  overflow: auto;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 36px 32px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 19px;
  font-weight: 600;
}

.login-logo svg {
  width: 26px;
  height: 26px;
}

.login-sub {
  margin-bottom: 26px;
  color: var(--text-mute);
  font-size: 12px;
  text-align: center;
}

.login-field {
  position: relative;
  margin-bottom: 14px;
}

.login-field input {
  width: 100%;
  padding: 11px 42px 11px 13px;
  font-size: 14px;
  background: var(--bg);
  border-radius: var(--radius);
}

.login-eye {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  padding: 4px;
  color: var(--text-mute);
  line-height: 0;
}
.login-eye:hover {
  color: var(--text-dim);
}

.btn-primary {
  width: 100%;
  padding: 11px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  border-radius: var(--radius);
  transition: background 0.15s;
}
.btn-primary:hover:not(:disabled) {
  background: #2f6fd8;
}
.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.login-msg {
  margin-top: 14px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.6;
  border-radius: var(--radius-sm);
  display: none;
}
.login-msg.error {
  display: block;
  color: #ffb4ad;
  background: var(--up-bg);
  border: 1px solid rgba(240, 70, 60, 0.3);
}
.login-msg.warn {
  display: block;
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.login-tip {
  margin-top: 18px;
  color: var(--text-mute);
  font-size: 11px;
  text-align: center;
  line-height: 1.7;
}

/* ---------------------------------------------------------------- 主布局 */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 46px;
  padding: 0 14px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.brand svg {
  width: 19px;
  height: 19px;
  color: var(--accent);
}

.index-bar {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.index-bar::-webkit-scrollbar {
  display: none;
}

.index-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s;
}
.index-item:hover {
  background: var(--bg-hover);
}
.index-item .n {
  color: var(--text-dim);
  font-size: 12px;
}
.index-item .v {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
}
.index-item .p {
  font-family: var(--mono);
  font-size: 11px;
}

.market-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg-panel-2);
  border-radius: 20px;
  white-space: nowrap;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--flat);
  flex-shrink: 0;
}
.dot.live {
  background: var(--up);
  box-shadow: 0 0 0 0 rgba(240, 70, 60, 0.6);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  70% {
    box-shadow: 0 0 0 6px rgba(240, 70, 60, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(240, 70, 60, 0);
  }
}

.icon-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  flex-shrink: 0;
}
.icon-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}
.icon-btn svg {
  width: 17px;
  height: 17px;
}

.theme-toggle .moon {
  display: none;
}
.theme-toggle.is-light .sun {
  display: none;
}
.theme-toggle.is-light .moon {
  display: block;
}

.badge {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 15px;
  color: #fff;
  text-align: center;
  background: var(--up);
  border-radius: 8px;
}

.main {
  display: flex;
  flex: 1;
  min-height: 0;
}

.col-left {
  position: relative;
  display: flex;
  flex-direction: column;
  width: var(--col-left-w);
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

.col-center {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.col-right {
  position: relative;
  display: flex;
  flex-direction: column;
  width: var(--col-right-w);
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  flex-shrink: 0;
}

html.chat-collapsed .col-right,
.col-right.collapsed {
  width: 0;
  max-width: 0;
  overflow: hidden;
  border-left: none;
  box-shadow: none;
}

html.chat-collapsed .sash[data-resize='right'],
.col-right.collapsed .sash[data-resize='right'] {
  display: none;
}

/* ---------------------------------------------------------------- 通用面板 */

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 34px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-head .actions {
  display: flex;
  gap: 3px;
}

.mini-btn {
  padding: 3px 8px;
  font-size: 11px;
  color: var(--text-mute);
  border-radius: 4px;
  transition: all 0.15s;
}
.mini-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}
.mini-btn.active {
  color: var(--accent);
  background: var(--accent-dim);
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 0 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tab {
  position: relative;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-mute);
  transition: color 0.15s;
  white-space: nowrap;
}
.tab:hover {
  color: var(--text-dim);
}
.tab.active {
  color: var(--text);
}
.tab.is-loading {
  color: var(--accent);
}
.tab.is-loading::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border: 1px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  vertical-align: 1px;
}
.tab.active::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}

.scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.empty {
  padding: 32px 16px;
  color: var(--text-mute);
  font-size: 12px;
  text-align: center;
  line-height: 1.8;
}

/* ---------------------------------------------------------------- 搜索 */

.search-box {
  position: relative;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-box input {
  width: 100%;
  padding: 6px 10px;
  font-size: 12px;
  background: var(--bg);
}

.search-drop {
  position: absolute;
  top: calc(100% - 4px);
  left: 10px;
  right: 10px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--bg-panel-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 50;
  display: none;
}
.search-drop.show {
  display: block;
}

.search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  cursor: pointer;
  transition: background 0.1s;
}
.search-item:hover,
.search-item.sel {
  background: var(--bg-hover);
}
.search-item .code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-mute);
}

/* ---------------------------------------------------------------- 自选股 */

.stock-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  padding: 7px 11px;
  border-bottom: 1px solid rgba(35, 46, 59, 0.6);
  cursor: pointer;
  transition: background 0.1s;
}
.stock-row:hover {
  background: var(--bg-hover);
}
.stock-row.active {
  background: var(--bg-active);
  box-shadow: inset 2px 0 0 var(--accent);
}

.stock-row .name {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stock-row .price {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  text-align: right;
}
.stock-row .code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-mute);
}
.stock-row .pct {
  font-family: var(--mono);
  font-size: 11px;
  text-align: right;
}

/* 价格变动时的闪烁提示 */
@keyframes flash-up {
  0% {
    background-color: var(--up-bg);
  }
  100% {
    background-color: transparent;
  }
}
@keyframes flash-down {
  0% {
    background-color: var(--down-bg);
  }
  100% {
    background-color: transparent;
  }
}
.flash-up {
  animation: flash-up 0.7s ease-out;
}
.flash-down {
  animation: flash-down 0.7s ease-out;
}

/* ---------------------------------------------------------------- 个股头部 */

.stock-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 11px 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.sh-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.sh-title .name {
  font-size: 17px;
  font-weight: 600;
}
.sh-title .code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mute);
}

.sh-price {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.sh-price .p {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}
.sh-price .c {
  font-family: var(--mono);
  font-size: 13px;
}

.sh-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.sh-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sh-stat .k {
  font-size: 10px;
  color: var(--text-mute);
}
.sh-stat .v {
  font-family: var(--mono);
  font-size: 12px;
}

/* ---------------------------------------------------------------- 图表 */

.chart-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--bg-panel);
}

.chart-toolbar {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.chart-box {
  flex: 1;
  min-height: 160px;
}

.bottom-split {
  position: relative;
  display: flex;
  height: var(--bottom-h);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ---------------------------------------------------------------- 拖拽分隔条 */

.sash {
  position: absolute;
  z-index: 40;
  background: transparent;
  touch-action: none;
  user-select: none;
}
.sash::before {
  content: '';
  position: absolute;
  background: transparent;
  pointer-events: none;
  transition: background 0.12s, box-shadow 0.12s;
}
.sash-v {
  top: 0;
  bottom: 0;
  width: 7px;
  cursor: col-resize;
}
.sash-v::before {
  top: 0;
  bottom: 0;
  left: 3px;
  width: 1px;
}
.sash-h {
  left: 0;
  right: 0;
  height: 7px;
  cursor: row-resize;
}
.sash-h::before {
  left: 0;
  right: 0;
  top: 3px;
  height: 1px;
}
.sash[data-resize='left'] {
  right: -4px;
}
.sash[data-resize='right'] {
  left: -4px;
}
.sash[data-resize='bottom'] {
  top: -4px;
}
.sash:hover::before,
.sash.active::before {
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

body.is-resizing {
  user-select: none;
}
body.is-resizing-x {
  cursor: col-resize !important;
}
body.is-resizing-y {
  cursor: row-resize !important;
}
body.is-resizing canvas,
body.is-resizing iframe {
  pointer-events: none;
}

.bottom-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
}
.bottom-panel:last-child {
  border-right: none;
}

/* 五档盘口 */
.orderbook {
  padding: 6px 11px;
  font-family: var(--mono);
  font-size: 12px;
}
.ob-row {
  display: grid;
  grid-template-columns: 30px 1fr 62px;
  gap: 8px;
  padding: 2.5px 0;
  position: relative;
}
.ob-row .lbl {
  color: var(--text-mute);
}
.ob-row .vol {
  text-align: right;
  color: var(--text-dim);
}
.ob-bar {
  position: absolute;
  top: 1px;
  bottom: 1px;
  right: 0;
  border-radius: 2px;
  opacity: 0.14;
  pointer-events: none;
}
.ob-sep {
  display: flex;
  justify-content: space-between;
  margin: 5px 0;
  padding: 4px 0;
  border-top: 1px dashed var(--border-light);
  border-bottom: 1px dashed var(--border-light);
  color: var(--text-mute);
  font-size: 11px;
}

/* 逐笔成交 */
.ticks {
  padding: 0 11px 6px;
  font-family: var(--mono);
  font-size: 11.5px;
}
.tick-row {
  display: grid;
  grid-template-columns: 58px 1fr 52px;
  gap: 8px;
  padding: 2.5px 0;
}
.tick-row .t {
  color: var(--text-mute);
}
.tick-row .v {
  text-align: right;
}

/* 榜单表格 */
.rank-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.rank-table th {
  position: sticky;
  top: 0;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-mute);
  text-align: right;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  z-index: 1;
  white-space: nowrap;
}
.rank-table th:first-child,
.rank-table td:first-child {
  text-align: left;
}
.rank-table td {
  padding: 5px 8px;
  font-family: var(--mono);
  text-align: right;
  border-bottom: 1px solid rgba(35, 46, 59, 0.5);
  white-space: nowrap;
}
.rank-table tbody tr {
  cursor: pointer;
}
.rank-table tbody tr:hover {
  background: var(--bg-hover);
}
.rank-table .nm {
  font-family: var(--sans);
}

/* ---------------------------------------------------------------- 股池 */

.pool-summary {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}
.pool-summary .hint {
  color: var(--text-mute);
  white-space: nowrap;
}

.board-badge {
  display: inline-block;
  min-width: 30px;
  padding: 1px 5px;
  font-family: var(--mono);
  font-size: 11px;
  text-align: center;
  color: var(--text-mute);
  background: rgba(139, 152, 168, 0.14);
  border-radius: 3px;
}
.board-badge.hot {
  color: #fff;
  background: var(--up);
  font-weight: 600;
}

/* ---------------------------------------------------------------- 公司档案 */

.company-panel {
  padding: 4px 10px 12px;
}

.co-section + .co-section {
  margin-top: 14px;
}
.co-title {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 6px 0 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

.co-kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 14px;
  padding: 8px 0 2px;
  font-size: 12px;
}
.co-kv .k {
  color: var(--text-mute);
  white-space: nowrap;
}
.co-kv .v {
  color: var(--text);
  word-break: break-all;
}

.co-text {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.65;
  color: var(--text-dim);
}

.co-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 8px 0 2px;
}
.co-tag {
  padding: 2px 7px;
  font-size: 11px;
  color: var(--text-dim);
  background: rgba(139, 152, 168, 0.14);
  border-radius: 3px;
}

.co-link {
  display: inline-block;
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--accent);
  text-decoration: none;
}
.co-link:hover {
  text-decoration: underline;
}

/* 档案里的表格是只读的，去掉榜单那套点击态 */
.co-table {
  margin-top: 4px;
}
.co-table tbody tr {
  cursor: default;
}
.co-table tbody tr:hover {
  background: none;
}
.co-table th:first-child,
.co-table td:first-child {
  position: sticky;
  left: 0;
  background: var(--bg-panel);
}

.co-list {
  padding-top: 4px;
}
.co-item {
  padding: 7px 0;
  border-bottom: 1px solid rgba(35, 46, 59, 0.5);
}
.co-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}
.co-item-head .d {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-mute);
}
.co-item-body {
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-dim);
}

.flow-wrap {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

/* 数据源降级等需要让用户知情、但不算错误的提示 */
.panel-notice {
  flex: none;
  padding: 5px 10px;
  font-size: 11px;
  color: var(--warn);
  background: rgba(217, 147, 42, 0.1);
  border-bottom: 1px solid rgba(217, 147, 42, 0.25);
}

.panel-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
  min-height: 120px;
  color: var(--text-mute);
  font-size: 12px;
}
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 板块热力图 */
.heatmap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 4px;
  padding: 10px;
}
.heat-cell {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-height: 52px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.12s;
}
.heat-cell:hover {
  transform: scale(1.04);
  z-index: 2;
}
.heat-cell .n {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.heat-cell .p {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
}

/* ---------------------------------------------------------------- AI 面板 */

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 40px;
  padding: 0 11px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
}
.chat-title svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  min-height: 0;
}

.msg {
  margin-bottom: 16px;
}

.msg-user {
  display: flex;
  justify-content: flex-end;
}
.msg-user .bubble {
  max-width: 84%;
  padding: 8px 12px;
  background: var(--accent);
  border-radius: 12px 12px 3px 12px;
  color: #fff;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-ai .bubble {
  color: var(--text);
  word-break: break-word;
}

.msg-imgs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-end;
  margin-bottom: 5px;
}
.msg-imgs img {
  max-width: 130px;
  max-height: 130px;
  border-radius: 7px;
  border: 1px solid var(--border-light);
  cursor: zoom-in;
  object-fit: cover;
}

.think-box {
  margin-bottom: 8px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.think-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-mute);
  cursor: pointer;
  user-select: none;
}
.think-head:hover {
  color: var(--text-dim);
}
.think-head .arrow {
  transition: transform 0.15s;
}
.think-box.open .think-head .arrow {
  transform: rotate(90deg);
}
.think-content {
  display: none;
  max-height: 260px;
  overflow-y: auto;
  padding: 0 10px 9px;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--text-dim);
  white-space: pre-wrap;
}
.think-box.open .think-content {
  display: block;
}

.tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0 4px 5px 0;
  padding: 3px 9px;
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.tool-chip svg {
  width: 11px;
  height: 11px;
  color: var(--accent);
}
.tool-chip.done svg {
  color: var(--down);
}

.sources {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.sources .st {
  margin-bottom: 5px;
  font-size: 11px;
  color: var(--text-mute);
}
.source-link {
  display: block;
  margin-bottom: 3px;
  font-size: 11.5px;
  color: var(--text-dim);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.source-link:hover {
  color: var(--accent);
}

/* Markdown 渲染 */
.md h1,
.md h2,
.md h3,
.md h4 {
  margin: 12px 0 6px;
  font-size: 14px;
  font-weight: 600;
}
.md h1 {
  font-size: 16px;
}
.md p {
  margin: 6px 0;
}
.md ul,
.md ol {
  margin: 6px 0;
  padding-left: 20px;
}
.md li {
  margin: 2px 0;
}
.md code {
  padding: 1px 5px;
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-panel-2);
  border-radius: 3px;
}
.md pre {
  margin: 8px 0;
  padding: 10px;
  overflow-x: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.md pre code {
  padding: 0;
  background: none;
}
.md table {
  width: 100%;
  margin: 8px 0;
  border-collapse: collapse;
  font-size: 12px;
}
.md th,
.md td {
  padding: 5px 8px;
  text-align: left;
  border: 1px solid var(--border);
}
.md th {
  background: var(--bg-panel-2);
  font-weight: 600;
}
.md blockquote {
  margin: 8px 0;
  padding: 4px 12px;
  color: var(--text-dim);
  border-left: 3px solid var(--border-light);
}
.md a {
  color: var(--accent);
}
.md strong {
  font-weight: 600;
  color: #fff;
}

.chat-input-wrap {
  padding: 9px 11px 11px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-opts {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 7px;
  flex-wrap: wrap;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  font-size: 11px;
  color: var(--text-mute);
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: all 0.15s;
}
.toggle:hover {
  color: var(--text-dim);
  border-color: var(--border-light);
}
.toggle.on {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: rgba(59, 130, 246, 0.35);
}
.toggle svg {
  width: 12px;
  height: 12px;
}

.chat-attach {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 7px;
}
.attach-item {
  position: relative;
  width: 52px;
  height: 52px;
}
.attach-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid var(--border-light);
}
.attach-del {
  position: absolute;
  top: -5px;
  right: -5px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  font-size: 11px;
  line-height: 1;
  color: #fff;
  background: #444f5c;
  border: 1px solid var(--bg-panel);
  border-radius: 50%;
}
.attach-del:hover {
  background: var(--up);
}

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 7px;
}

.chat-input {
  flex: 1;
  max-height: 130px;
  min-height: 38px;
  padding: 9px 11px;
  font-size: 13px;
  line-height: 1.45;
  background: var(--bg);
  border-radius: var(--radius);
  resize: none;
  overflow-y: auto;
}

.send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  color: #fff;
  background: var(--accent);
  border-radius: var(--radius);
  flex-shrink: 0;
  transition: background 0.15s;
}
.send-btn:hover:not(:disabled) {
  background: #2f6fd8;
}
.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.send-btn svg {
  width: 17px;
  height: 17px;
}

.chat-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  color: var(--text);
  text-align: left;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, background 0.15s;
}
.chat-history-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}
.chat-history-item .src {
  min-width: 38px;
  padding: 2px 7px;
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  border-radius: 999px;
  background: rgba(139, 152, 168, 0.14);
}
.chat-history-item .src.qq {
  color: #7dd3fc;
  background: rgba(14, 165, 233, 0.16);
}
.chat-history-item .src.web {
  color: var(--accent);
  background: var(--accent-dim);
}
.chat-history-item .main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.chat-history-item .title,
.chat-history-item .time {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-history-item .title {
  font-size: 13px;
  font-weight: 600;
}
.chat-history-item .time {
  font-size: 11px;
  color: var(--text-mute);
}

.typing::after {
  content: '▋';
  margin-left: 1px;
  animation: blink 1s step-end infinite;
  color: var(--accent);
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* ---------------------------------------------------------------- 弹层 */

.modal-mask {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  z-index: 200;
  padding: 20px;
}
.modal-mask.show {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 520px;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.modal.wide {
  max-width: 780px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.btn {
  padding: 7px 16px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.btn-ghost {
  color: var(--text-dim);
  border: 1px solid var(--border-light);
}
.btn-ghost:hover {
  color: var(--text);
  background: var(--bg-hover);
}
.btn-blue {
  color: #fff;
  background: var(--accent);
}
.btn-blue:hover {
  background: #2f6fd8;
}
.btn-red {
  color: #ffb4ad;
  border: 1px solid rgba(240, 70, 60, 0.35);
}
.btn-red:hover {
  background: var(--up-bg);
}

.form-row {
  margin-bottom: 13px;
}
.form-row label {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--text-dim);
}
.form-row input,
.form-row select {
  width: 100%;
  padding: 8px 11px;
}
.form-hint {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-mute);
  line-height: 1.6;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}

.qq-bind-box {
  margin-bottom: 14px;
}
.qq-bind-card {
  padding: 11px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.qq-bind-head,
.qq-bind-item,
.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.qq-bind-head,
.qq-bind-item {
  justify-content: space-between;
}
.panel-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}
.qq-bind-card .li-t,
.qq-bind-item .li-t {
  font-size: 13px;
  margin-bottom: 2px;
}
.qq-bind-card .li-s,
.qq-bind-item .li-s {
  font-size: 11px;
  color: var(--text-mute);
  line-height: 1.7;
}
.bind-code {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 9px 0;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg);
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-sm);
}
.bind-code strong {
  font-family: var(--mono);
  font-size: 18px;
  color: var(--accent);
  letter-spacing: 2px;
}
.qq-bind-list {
  margin-top: 9px;
}
.qq-bind-item {
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
.qq-bind-item.off {
  opacity: 0.55;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  margin-bottom: 6px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.list-item .li-main {
  flex: 1;
  min-width: 0;
}
.list-item .li-t {
  font-size: 13px;
  margin-bottom: 2px;
}
.list-item .li-s {
  font-size: 11px;
  color: var(--text-mute);
}
.list-item.off {
  opacity: 0.5;
}

/* ---------------------------------------------------------------- 全部股票 */

.stock-catalog-modal {
  max-width: 860px;
}

.stock-catalog-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 560px;
  overflow: hidden;
}

.stock-catalog-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.stock-catalog-toolbar input {
  flex: 1;
  padding: 8px 11px;
}

.stock-catalog-toolbar span,
.stock-catalog-pager {
  color: var(--text-mute);
  font-size: 12px;
  white-space: nowrap;
}

.stock-catalog-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.stock-catalog-head,
.stock-catalog-row {
  display: grid;
  grid-template-columns: 96px 1fr 88px 94px;
  align-items: center;
  gap: 10px;
}

.stock-catalog-head {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 7px 11px;
  color: var(--text-mute);
  font-size: 11px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

.stock-catalog-row {
  padding: 8px 11px;
  border-bottom: 1px solid rgba(35, 46, 59, 0.5);
  cursor: pointer;
  transition: background 0.1s;
}
.stock-catalog-row:hover {
  background: var(--bg-hover);
}
.stock-catalog-row .code {
  font-family: var(--mono);
  color: var(--text-dim);
}
.stock-catalog-row .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stock-catalog-row .exchange {
  color: var(--text-mute);
  font-size: 12px;
}
.stock-catalog-row .action {
  text-align: right;
}
.stock-catalog-row .mini-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.stock-catalog-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

/* 通知 */
.toast-wrap {
  position: fixed;
  top: 56px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
  pointer-events: none;
}

.toast {
  min-width: 240px;
  max-width: 340px;
  padding: 10px 13px;
  font-size: 12.5px;
  line-height: 1.55;
  background: var(--bg-panel-2);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  animation: slide-in 0.22s ease-out;
  pointer-events: auto;
}
.toast.alert {
  border-left-color: var(--warn);
}
.toast.error {
  border-left-color: var(--up);
}
.toast .tt {
  margin-bottom: 2px;
  font-weight: 600;
}
.toast .ts {
  color: var(--text-dim);
  font-size: 11.5px;
}
@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
}

/* ---------------------------------------------------------------- 响应式 */

@media (max-width: 1400px) {
  :root {
    --col-right-w: 340px;
  }
}

@media (max-width: 1180px) {
  :root {
    --col-left-w: 216px;
  }
  .sh-stats {
    display: none;
  }
}

@media (max-width: 900px) {
  :root {
    --col-left-w: 180px;
  }
  .col-right {
    position: fixed;
    top: 46px;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 420px;
    z-index: 100;
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.5);
  }
  html.chat-collapsed .col-right,
  .col-right.collapsed {
    width: 0;
    max-width: 0;
  }
  .sash[data-resize='right'] {
    display: none;
  }
  .index-bar .index-item:nth-child(n + 4) {
    display: none;
  }
}
