/* ===== 金融终端暗色主题 ===== */
:root {
  --bg: #0a0e14;
  --bg-panel: #0f141c;
  --bg-hover: #151c26;
  --bg-cell: #10161f;
  --border: #1d2733;
  --border-strong: #2a3646;
  --text: #d5dde7;
  --text-dim: #8b98a9;
  --text-faint: #5b6776;
  --green: #3fb950;
  --red: #f85149;
  --amber: #d29922;
  --accent: #58a6ff;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ===== 头部 ===== */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border-strong);
  background: linear-gradient(180deg, #0d131b 0%, var(--bg) 100%);
  flex-wrap: wrap;
}

.site-header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.site-header .accent { color: var(--accent); font-family: var(--mono); }

.header-note {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 6px;
  font-family: var(--mono);
}

.header-meta {
  color: var(--text-faint);
  font-size: 11px;
  font-family: var(--mono);
  text-align: right;
  white-space: nowrap;
}

/* ===== 布局 ===== */
.layout {
  display: flex;
  min-height: calc(100vh - 130px);
}

.sidebar {
  width: 230px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  overflow-y: auto;
}

.side-section {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 10px 6px;
  font-family: var(--mono);
}

.side-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-left: 2px solid transparent;
  color: var(--text);
  padding: 8px 10px;
  cursor: pointer;
  border-radius: 0 6px 6px 0;
  font-size: 13px;
  transition: background 0.12s;
}

.side-item:hover { background: var(--bg-hover); }

.side-item.active {
  background: var(--bg-hover);
  border-left-color: var(--accent);
}

.side-item .fund-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-item .fund-total {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 1px;
}

.side-item.active .fund-total { color: var(--accent); }

.content {
  flex: 1;
  padding: 18px 24px 30px;
  min-width: 0;
  overflow-x: auto;
}

/* ===== 视图标题与控件 ===== */
.view-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.view-sub {
  color: var(--text-dim);
  font-size: 12px;
  margin-bottom: 16px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.search-input {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 13px;
  width: 240px;
  outline: none;
}

.search-input:focus { border-color: var(--accent); }

.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.toggle-label input { accent-color: var(--accent); }

.fund-stats {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}

.fund-stats b { color: var(--text); font-weight: 600; }

/* ===== 表格 ===== */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
  background: var(--bg-panel);
  max-height: calc(100vh - 260px);
}

table { border-collapse: collapse; width: 100%; }

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #121923;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

thead th.num, td.num { text-align: right; }

thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text); }
thead th .sort-arrow { color: var(--accent); margin-left: 3px; }

tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  white-space: nowrap;
}

tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child td { border-bottom: none; }

.num { font-family: var(--mono); }

.issuer-name { font-weight: 500; }
.issuer-cusip { color: var(--text-faint); font-size: 11px; font-family: var(--mono); margin-left: 6px; }

/* ===== 徽章与颜色 ===== */
.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.badge-put { background: rgba(248, 81, 73, 0.15); color: var(--red); border: 1px solid rgba(248, 81, 73, 0.4); }
.badge-call { background: rgba(63, 185, 80, 0.15); color: var(--green); border: 1px solid rgba(63, 185, 80, 0.4); }
.badge-new { background: rgba(88, 166, 255, 0.15); color: var(--accent); border: 1px solid rgba(88, 166, 255, 0.4); }
.badge-watch { background: rgba(210, 153, 34, 0.12); color: var(--amber); border: 1px solid rgba(210, 153, 34, 0.35); }

.pos { color: var(--green); }
.neg { color: var(--red); }
.flat { color: var(--text-dim); }
.dash { color: var(--text-faint); }

/* ===== 总览矩阵 ===== */
.matrix-wrap { border: 1px solid var(--border); border-radius: 8px; overflow: auto; background: var(--bg-panel); max-height: calc(100vh - 250px); }

.matrix th:first-child,
.matrix td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #121923;
  min-width: 170px;
}

.matrix thead th:first-child { z-index: 3; }
.matrix tbody td:first-child { background: var(--bg-panel); }
.matrix tbody tr:hover td:first-child { background: var(--bg-hover); }

.matrix td { text-align: right; font-family: var(--mono); font-size: 12px; vertical-align: top; }

.matrix thead th { text-align: right; font-size: 10px; max-width: 120px; }
.matrix thead th:first-child { text-align: left; }

.cell-value { display: block; font-size: 12px; }
.cell-qoq { display: block; font-size: 11px; margin-top: 1px; }
.cell-opt { color: var(--amber); font-size: 10px; margin-left: 3px; }

.sec-name { font-weight: 600; font-size: 13px; }
.sec-ticker { color: var(--text-dim); font-family: var(--mono); font-size: 11px; margin-left: 5px; }

.group-row td {
  background: #101822 !important;
  color: var(--amber);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-align: left !important;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-strong);
}

.legend { color: var(--text-faint); font-size: 11px; margin-top: 10px; font-family: var(--mono); }

/* ===== 页脚 ===== */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 10px 24px;
  color: var(--text-faint);
  font-size: 11px;
  font-family: var(--mono);
}

/* ===== 错误提示 ===== */
.error-box {
  border: 1px solid var(--red);
  border-radius: 8px;
  padding: 20px;
  color: var(--red);
  font-family: var(--mono);
  font-size: 13px;
  background: rgba(248, 81, 73, 0.06);
}

/* ===== 移动端 ===== */
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    display: flex;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px;
    gap: 4px;
  }
  .side-section { display: none; }
  .side-item { border-left: none; border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0; white-space: nowrap; }
  .side-item.active { border-bottom-color: var(--accent); }
  .content { padding: 14px; }
  .site-header { padding: 14px; }
  .header-meta { text-align: left; }
}
