/* ============ CSI 300 Industry Intelligence —— 专业终端暗色主题 ============ */
:root {
  --bg: #0d1117;
  --panel: #141a22;
  --panel-2: #1a212b;
  --border: #2a313d;
  --text: #d7dee8;
  --text-dim: #8a93a3;
  --text-faint: #5b6473;
  --accent: #d9a13c;          /* 终端琥珀色 */
  --up: #e5534b;              /* A股惯例：涨红 */
  --down: #3fb950;            /* 跌绿 */
  --ok: #57ab5a;
  --fail: #e5534b;
}

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

html, body { height: 100%; }
body {
  font-family: "Segoe UI", "Microsoft YaHei", -apple-system, sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------------- 顶栏 ---------------- */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 52px; padding: 0 16px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  flex: none;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-name {
  font-weight: 600; font-size: 14px; letter-spacing: 1.2px; color: var(--accent);
}
.brand-sub { font-size: 12px; color: var(--text-dim); }

/* ---------------- 顶部 Tab（业绩监控 / 重要股东监控） ---------------- */
.tabs { display: flex; gap: 6px; margin-left: 26px; }
.tab {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-dim); font-size: 13px; padding: 6px 16px;
  border-radius: 4px; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); border-color: #3a4657; }
.tab.active {
  background: rgba(217, 161, 60, .12); border-color: var(--accent);
  color: var(--accent); font-weight: 600;
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.last-updated { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.update-status { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.ui-build { font-size: 10px; color: var(--text-faint); font-variant-numeric: tabular-nums; letter-spacing: .02em; }

#btn-update {
  background: var(--accent); color: #14181f; border: none;
  font-size: 13px; font-weight: 600; padding: 7px 14px;
  border-radius: 4px; cursor: pointer; white-space: nowrap;
}
#btn-update:hover { filter: brightness(1.1); }
#btn-update:disabled { opacity: .55; cursor: default; }
#btn-update .icon { display: inline-block; margin-right: 2px; }
#btn-update.spinning .icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 更新状态面板 ---------------- */
.update-panel {
  position: absolute; top: 58px; right: 16px; z-index: 50;
  width: 420px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 8px 30px rgba(0,0,0,.45);
}
.update-panel.hidden { display: none; }
.update-panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 13px;
}
.panel-close {
  background: none; border: none; color: var(--text-dim);
  font-size: 16px; cursor: pointer; line-height: 1;
}
#update-steps { list-style: none; padding: 8px 14px 12px; }
#update-steps li {
  display: flex; gap: 10px; padding: 4px 0; font-size: 12.5px;
  align-items: baseline;
}
#update-steps .mark { width: 34px; flex: none; font-weight: 600; }
#update-steps li.ok   .mark { color: var(--ok); }
#update-steps li.fail .mark { color: var(--fail); }
#update-steps li.run  .mark { color: var(--accent); }
#update-steps li.pend .mark { color: var(--text-faint); }
#update-steps .detail { color: var(--text-dim); font-size: 12px; }

/* ---------------- 布局 ---------------- */
#layout, #holder-layout { display: flex; flex: 1; min-height: 0; }
#layout.hidden, #holder-layout.hidden { display: none; }

#sidebar, #holder-sidebar {
  width: 232px; flex: none; background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
#content, #holder-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#holder-grid, #stock-grid { flex: 1; min-height: 0; }

/* 重要股东列表 */
.holder-cat {
  padding: 8px 8px 2px; font-size: 10.5px; letter-spacing: 1px;
  color: var(--text-faint); font-weight: 600;
  display: flex; align-items: center; gap: 4px; cursor: pointer;
  user-select: none;
}
.holder-cat:hover { color: var(--text-dim); }
.holder-cat .cat-caret {
  display: inline-block; width: 10px; font-size: 9px;
  transition: transform .12s ease; color: var(--text-faint);
}
.holder-cat.collapsed .cat-caret { transform: rotate(-90deg); }
.holder-cat-items { display: block; }
.holder-cat-section.collapsed .holder-cat-items { display: none; }
.holder-foot {
  padding: 10px 12px 14px; font-size: 10.5px; line-height: 1.5;
  color: var(--text-faint); border-top: 1px solid var(--border); margin-top: 8px;
}
.holder-item { padding-left: 12px; }
.holder-inc {
  font-size: 10.5px; color: #3fb950; margin-left: 6px;
  border: 1px solid rgba(63,185,80,.4); border-radius: 3px; padding: 0 3px;
}
.holder-item.active .holder-inc { border-color: var(--accent); color: var(--accent); }
/* 「重要股东增持」列：内容统一用绿色（与「业绩变化·改善」同色 #3fb950） */
.holder-line { line-height: 1.45; white-space: nowrap; color: #3fb950; }
.holder-line.holder-new { color: #3fb950; }

/* 该列内容为多个块级 div，AG Grid 的 line-height 居中会失效 → 用 flex 垂直居中 */
#holder-grid .ag-cell.cell-holders {
  display: flex !important;
  flex-direction: column;
  justify-content: center;
  line-height: 1.45;
  padding-top: 3px;
  padding-bottom: 3px;
}
.cell-holder-wrap { padding: 3px 0; }
.sidebar-head {
  padding: 10px 14px 6px; font-size: 11px; letter-spacing: 1.5px;
  color: var(--text-faint); font-weight: 600;
}
.sidebar-search { padding: 0 10px 8px; }
.sidebar-search input {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-radius: 4px; padding: 6px 9px; font-size: 12.5px;
  outline: none;
}
.sidebar-search input:focus { border-color: var(--accent); }
#industry-tree { flex: 1; overflow-y: auto; padding: 4px 6px 10px; }
/* 重要股东列表同样需要独立滚动，否则超出侧栏高度的分组会被 body 的 overflow:hidden 裁掉、无法看到 */
#holder-list { flex: 1; overflow-y: auto; padding: 4px 6px 10px; }
.tree-group, .tree-sub {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 8px; border-radius: 4px; cursor: pointer;
  user-select: none; gap: 6px;
}
.tree-group { color: var(--text); font-weight: 600; font-size: 13px; margin-top: 2px; }
.tree-sub   { color: var(--text-dim); font-size: 12.5px; padding-left: 24px; }
.tree-group:hover, .tree-sub:hover { background: var(--panel-2); }
.tree-node.active { background: #223041; color: var(--accent); }
.tree-caret {
  width: 10px; flex: none; color: var(--text-faint);
  transition: transform .12s; font-size: 10px;
}
.tree-group.collapsed .tree-caret { transform: rotate(-90deg); }
.tree-children.collapsed { display: none; }
.tree-count {
  font-size: 11px; color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.tree-sub.active .tree-count { color: var(--accent); }
.sidebar-foot {
  padding: 8px 14px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-faint);
}

#content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.content-head {
  display: flex; align-items: baseline; gap: 12px;
  padding: 10px 16px 6px; flex: none;
}
.current-view { font-size: 15px; font-weight: 600; color: var(--text); }
.view-count { font-size: 12px; color: var(--text-dim); }

/* ---------------- AG Grid ---------------- */
#stock-grid { flex: 1; min-height: 0; }
/* 用 ID 提升优先级：AG Grid v31 运行时会注入同名主题 <style>，同级规则会被其覆盖回亮色 */
#stock-grid.ag-theme-balham {
  --ag-background-color: var(--bg);
  --ag-foreground-color: var(--text);
  --ag-header-background-color: var(--panel);
  --ag-header-foreground-color: var(--text-dim);
  --ag-border-color: var(--border);
  --ag-row-border-color: #1d232d;
  --ag-odd-row-background-color: #10151c;
  --ag-row-hover-color: #1a222d;
  --ag-selected-row-background-color: #223041;
  --ag-balham-active-color: var(--accent);
  --ag-header-column-resize-handle-color: var(--border);
  --ag-header-column-resize-handle-hover-color: var(--accent);
  --ag-font-size: 12.5px;
  --ag-row-height: 30px;
  --ag-header-height: 34px;
  --ag-cell-horizontal-padding: 10px;
}
.ag-header-cell-label { justify-content: space-between; }
.ag-cell { font-variant-numeric: tabular-nums; }

.col-code  { color: var(--text-dim); font-family: Consolas, monospace; font-size: 12px; }
.col-name  { font-weight: 600; }
.num       { text-align: right; }
.cell-up   { color: var(--up) !important; }
.cell-down { color: var(--down) !important; }
.cell-loss { color: var(--text-faint) !important; }
.cell-dash { color: var(--text-faint) !important; }
.cell-improve { color: #3fb950 !important; font-weight: 600; }  /* 业绩改善=绿 */
.cell-slow    { color: #d9a13c !important; font-weight: 600; }  /* 业绩放缓=黄 */
.ind-tag {
  display: inline-block; background: #1f2733; border: 1px solid #2c3846;
  color: #9fb4cc; border-radius: 3px; padding: 0 5px; margin-right: 4px;
  font-size: 11px; line-height: 17px;
}
.report-tag { color: var(--text-faint); font-size: 11px; }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a313d; border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }
