/* ===================================================================
   看盘站点样式 —— 深色专业风格，向 TradingView 靠
   =================================================================== */

:root {
  --bg: #0e1117;
  --bg-panel: #161b22;
  --bg-hover: #1c2330;
  --bg-active: #21283a;
  --border: #262d3a;
  --text: #d6dae2;
  --text-dim: #8b95a5;
  --text-faint: #5a6373;

  --up: #ef5350;
  --down: #26a69a;
  --up-bg: rgba(239, 83, 80, 0.12);
  --down-bg: rgba(38, 166, 154, 0.12);

  --accent: #4a9eff;
  --warn: #f0a020;
  --danger: #e0533d;
  --ok: #3fb950;

  --zone: #c0392b;
  --grid: #1e242f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
               "PingFang SC", Roboto, sans-serif;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  background: var(--bg-hover);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  transition: background 0.12s;
}
button:hover { background: var(--bg-active); }
button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

input, select {
  font-family: inherit;
  font-size: inherit;
  background: var(--bg-panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }

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

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

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

.brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
  color: var(--text);
}
.brand span { color: var(--accent); }

.nav { display: flex; gap: 4px; }
.nav a {
  padding: 5px 12px;
  border-radius: 4px;
  color: var(--text-dim);
  text-decoration: none;
}
.nav a:hover { background: var(--bg-hover); color: var(--text); }
.nav a.active { background: var(--bg-active); color: var(--text); font-weight: 600; }

.spacer { flex: 1; }

.status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-faint);
}
.dot.live { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.dot.stale { background: var(--warn); }
.dot.dead { background: var(--danger); }

/* ------------------------------------------------------------ 表格 */

.table-wrap {
  flex: 1;
  overflow: auto;
  position: relative;
}

table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

table.grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  padding: 7px 10px;
  text-align: right;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
table.grid thead th:hover { color: var(--text); background: var(--bg-hover); }
table.grid thead th.l { text-align: left; }
table.grid thead th .arrow { color: var(--accent); margin-left: 2px; }

table.grid tbody td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--grid);
  text-align: right;
  white-space: nowrap;
}
table.grid tbody td.l { text-align: left; }

table.grid tbody tr:hover { background: var(--bg-hover); cursor: pointer; }
table.grid tbody tr.kicked { opacity: 0.42; }
table.grid tbody tr.kicked:hover { opacity: 0.75; }

.code { color: var(--text-faint); font-size: 11.5px; }
.name { color: var(--text); }

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

.badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  line-height: 1.5;
}
.badge.os { background: rgba(74, 158, 255, 0.15); color: #6bb3ff; }
.badge.ob { background: rgba(224, 83, 61, 0.18); color: #ff7d63; }
.badge.nt { color: var(--text-faint); }
.badge.kick { background: rgba(139, 149, 165, 0.14); color: var(--text-dim); }

.industry-tag {
  color: var(--text-dim);
  font-size: 11.5px;
}

/* ------------------------------------------------------------ 详情页 */

.detail {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.detail-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chart-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  flex-wrap: wrap;
}

.sym-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.sym-name { font-size: 16px; font-weight: 700; }
.sym-code { color: var(--text-dim); font-size: 12px; }
.sym-price { font-size: 20px; font-weight: 700; }
.sym-pct { font-size: 13px; font-weight: 600; }

.seg { display: flex; gap: 0; }
.seg button {
  border-radius: 0;
  border-right: none;
  padding: 4px 11px;
}
.seg button:first-child { border-radius: 4px 0 0 4px; }
.seg button:last-child { border-radius: 0 4px 4px 0; border-right: 1px solid var(--border); }

.chart-area { flex: 1; position: relative; min-height: 0; overflow: hidden; }
#chart { width: 100%; height: 100%; position: relative; }
/* 左侧成交量直方图 canvas 叠在图表之上，不拦截鼠标 */
/* 左侧面板 canvas 由 JS 动态插入，层级在 #chart 之上 */

.detail-side {
  width: 340px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--bg-panel);
  overflow-y: auto;
  padding: 12px;
}

.panel-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 14px 0 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}
.panel-title:first-child { margin-top: 0; }

.kv { display: flex; justify-content: space-between; padding: 3px 0; font-size: 12.5px; }
.kv .k { color: var(--text-dim); }
.kv .v { color: var(--text); font-weight: 500; }

.zone-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 3px;
  font-size: 12px;
  cursor: pointer;
}
.zone-row:hover { background: var(--bg-hover); }
.zone-row.cur { background: rgba(192, 57, 43, 0.16); }
.zone-bar {
  height: 5px;
  border-radius: 2px;
  background: var(--zone);
  opacity: 0.65;
  flex-shrink: 0;
}

.empty {
  padding: 40px;
  text-align: center;
  color: var(--text-faint);
}

/* ------------------------------------------------------------ 看板 */

.board {
  flex: 1;
  overflow: auto;
  padding: 14px;
}
.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}
.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.card-name { font-weight: 600; font-size: 13.5px; }
.card-n { color: var(--text-faint); font-size: 11.5px; }

.card-stats { display: flex; gap: 12px; font-size: 11.5px; color: var(--text-dim); }
.card-stats b { font-weight: 600; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button { padding: 5px 14px; }

.mini-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  display: flex;
  margin-top: 8px;
}
.mini-bar .u { background: var(--up); }
.mini-bar .d { background: var(--down); }

/* ------------------------------------------------------------ 滚动条 */

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: #2c3545;
  border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover { background: #3a4558; }

/* ------------------------------------------------------------ 加载 */

.loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(14, 17, 23, 0.85);
  z-index: 100;
  color: var(--text-dim);
  font-size: 14px;
}
.loading.hidden { display: none; }

.spin {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ 窄屏 */

@media (max-width: 900px) {
  .detail { flex-direction: column; }
  .detail-side { width: auto; border-left: none; border-top: 1px solid var(--border); max-height: 40vh; }
  .topbar { flex-wrap: wrap; gap: 8px; }
  .detail-side { padding: 8px; }
}
