/* ========== 缠论×波浪 分析工具 样式 ========== */
:root {
  --bg: #0d1117;
  --bg2: #111826;
  --card: #151d2b;
  --border: #232e42;
  --text: #dbe4f0;
  --muted: #7d8ba1;
  --accent: #3b82f6;
  --up: #ef4444;      /* A股红涨 */
  --down: #22c55e;    /* 绿跌 */
  --amber: #fbbf24;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-size: 13px; overflow: auto;
}
#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- 顶栏 ---------- */
.topbar {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 8px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; }
.logo {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6); color: #fff;
  font-weight: 700; padding: 3px 9px; border-radius: 6px; font-size: 14px;
}
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: .5px; }
.controls { display: flex; gap: 8px; align-items: center; }
.suggest-wrap { position: relative; }
#codeInput {
  background: #0b1220; border: 1px solid var(--border); color: var(--text);
  padding: 7px 12px; border-radius: 6px; width: 200px; font-size: 14px; outline: none;
}
#codeInput:focus { border-color: var(--accent); }
.suggest-list {
  position: absolute; top: 100%; left: 0; right: 0; margin-top: 2px; z-index: 60;
  background: #0b1220; border: 1px solid var(--border); border-radius: 6px;
  max-height: 280px; overflow-y: auto; display: none; box-shadow: 0 6px 18px rgba(0,0,0,.5);
}
.suggest-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 12px; cursor: pointer; font-size: 13px; gap: 12px;
}
.suggest-item .nm { color: var(--text); }
.suggest-item .cd { color: var(--muted); font-size: 12px; font-family: Consolas, monospace; }
.suggest-item:hover, .suggest-item.active { background: #1a2740; }
.suggest-item .cd { flex-shrink: 0; }
#periodSelect {
  background: #0b1220; border: 1px solid var(--border); color: var(--text);
  padding: 7px 8px; border-radius: 6px; outline: none; font-size: 13px;
}
#analyzeBtn {
  background: var(--accent); color: #fff; border: none; padding: 8px 20px;
  border-radius: 6px; font-size: 14px; cursor: pointer; font-weight: 600;
}
#analyzeBtn:hover { filter: brightness(1.15); }
#analyzeBtn:disabled { opacity: .5; cursor: wait; }
.btn-accent { background: var(--accent); color: #fff; border: none; cursor: pointer; }
.btn-accent:hover { filter: brightness(1.15); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.chip {
  background: #0b1220; border: 1px solid var(--border); color: var(--muted);
  padding: 4px 10px; border-radius: 20px; cursor: pointer; font-size: 12px;
}
.chip:hover { color: var(--text); border-color: var(--accent); }
.chip.active { color: var(--amber); border-color: var(--amber); }

/* ---------- 行情条 ---------- */
#quoteBar {
  display: flex; align-items: center; gap: 16px; padding: 8px 16px;
  background: var(--card); border-bottom: 1px solid var(--border); font-size: 14px;
}
.q-name { font-size: 18px; font-weight: 700; }
.q-code, .q-level, .q-date { color: var(--muted); font-size: 12px; }
.q-price { font-size: 22px; font-weight: 700; }
.q-chg { font-size: 14px; font-weight: 600; padding: 2px 8px; border-radius: 4px; }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--muted); }
.q-loading { color: var(--amber); margin-left: auto; display: none; font-size: 13px; }
.q-loading.show { display: inline; }

/* ---------- 主体 ---------- */
.main { flex: 1; display: flex; min-height: 0; }
.chart-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#chart { flex: 1; min-height: 0; }
.legend-note { padding: 4px 12px; color: var(--muted); font-size: 11px; border-top: 1px solid var(--border); }

/* ---------- 左右拖拽分割条 ---------- */
#splitter {
  width: 7px; flex-shrink: 0; cursor: col-resize;
  background: transparent; position: relative; z-index: 5;
  transition: background .15s;
}
#splitter:hover, #splitter.active { background: rgba(59,130,246,.3); }
#splitter::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 2px; height: 44px; background: #2a3852; border-radius: 1px;
}
#splitter:hover::after { background: #60a5fa; }

/* ---------- 右侧面板 ---------- */
.panel {
  width: 360px; min-width: 360px; overflow: auto; padding: 10px;
  background: var(--bg2); border-left: 1px solid var(--border);
}
.empty-tip { color: var(--muted); text-align: center; margin-top: 40%; line-height: 2; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 10px;
}
.card h3 {
  font-size: 13px; color: var(--amber); border-bottom: 1px solid var(--border);
  padding-bottom: 6px; margin-bottom: 8px; display: flex; align-items: center; gap: 6px;
}
.card h3 .tag { color: var(--muted); font-size: 11px; font-weight: 400; margin-left: auto; }
.row { display: flex; gap: 6px; margin-bottom: 4px; line-height: 1.6; }
.row .k { color: var(--muted); min-width: 62px; flex-shrink: 0; }
.row .v { flex: 1; }
.hl { color: var(--amber); font-weight: 600; }
.act-box {
  background: linear-gradient(135deg, rgba(59,130,246,.18), rgba(139,92,246,.12));
  border: 1px solid var(--accent); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px;
}
.act-box .act { font-size: 16px; font-weight: 700; color: #fff; }
/* 级别冲突提示：橙=小级别买点落在大级别下跌结构（只能当反弹）；蓝=小级别卖点属大级别上升中的回调 */
.xnote {
  display: flex; gap: 8px; align-items: flex-start;
  background: rgba(249, 115, 22, .10); border: 1px solid rgba(249, 115, 22, .55);
  border-left-width: 3px; border-radius: 6px; padding: 8px 10px; margin-bottom: 8px;
  font-size: 12px; line-height: 1.7; color: #fbd38d;
}
.xnote b { white-space: nowrap; color: #f97316; font-size: 12px; }
.xnote.xnote-buy { background: rgba(56, 189, 248, .08); border-color: rgba(56, 189, 248, .45); color: #bae6fd; }
.xnote.xnote-buy b { color: #38bdf8; }
.levels-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 6px 0; }
.lv { background: #0b1220; border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; }
.lv .t { color: var(--muted); font-size: 11px; margin-bottom: 2px; }
.lv .p { font-size: 15px; font-weight: 700; color: var(--down); }
.lv.red .p { color: var(--up); }
.sec-title { color: var(--muted); font-size: 11px; margin: 6px 0 3px; }
ul.disc { list-style: none; }
ul.disc li { padding-left: 14px; position: relative; line-height: 1.7; }
ul.disc li::before { content: "▸"; position: absolute; left: 0; color: var(--accent); }
table.mini { width: 100%; border-collapse: collapse; font-size: 12px; }
table.mini th, table.mini td { padding: 3px 5px; text-align: right; border-bottom: 1px solid #1b2740; white-space: nowrap; }
table.mini th { color: var(--muted); font-weight: 400; }
table.mini td:first-child, table.mini th:first-child { text-align: left; }
.foot { text-align: center; color: var(--muted); font-size: 11px; padding: 5px; border-top: 1px solid var(--border); }

/* ---------- 模拟炒股：横排三栏操作界面 ---------- */
.trade-wrap { max-width: 1700px; width: calc(100% - 24px); margin: 0 auto; padding: 0 12px 12px; }
/* 全屏模式：铺满整个视口，遮住顶栏/智能选股/分析区等一切其他界面 */
.trade-wrap.fullscreen {
  position: fixed; inset: 0; z-index: 900;
  width: 100%; max-width: none; margin: 0;
  padding: 10px 14px 18px;
  background: var(--bg);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.trade-wrap .card { border-radius: 10px; padding: 12px 14px; background: rgba(11,18,32,.6); border: 1px solid var(--border); }
.trade-wrap .card h3 { margin-bottom: 0; }
.trade-cols { display: flex; gap: 10px; flex-wrap: wrap; align-items: stretch; }
.trade-cols > div { border: 1px solid var(--border); border-radius: 8px; padding: 10px; background: #0b1220; }
.trade-col-buy { flex: 0 0 330px; min-width: 280px; }
.trade-col-pos { flex: 1 1 460px; min-width: 420px; }
.trade-col-his { flex: 1 1 380px; min-width: 360px; }
/* 窄视口：买入操作整行优先，持仓 + 流水并排第二行，避免横向滚动 */
@media (max-width: 1250px) {
  .trade-col-buy { flex: 1 1 100%; min-width: 0; }
  .trade-col-pos { flex: 1 1 55%; min-width: 400px; }
  .trade-col-his { flex: 1 1 40%; min-width: 340px; }
}
.trade-cols table { width: 100%; border-collapse: collapse; font-size: 12px; }
.trade-cols table th, .trade-cols table td { padding: 4px 5px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.05); white-space: nowrap; }
.trade-cols table th { color: var(--muted); font-weight: 400; font-size: 11px; position: sticky; top: 0; background: #0b1220; z-index: 1; }

/* ---------- 模拟炒股 · 数据分析弹窗 ---------- */
#statsModal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 9997; padding: 12px;
}
#statsModal .box {
  width: min(1100px, 94vw); max-height: 90vh; overflow: auto;
  background: #0d1526; border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.screener-wrap {
  max-width: 520px; margin: 0 auto 12px; padding: 0 12px;
}
.screener-wrap .card { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: rgba(11,18,32,.6); }
.screener-wrap .card h3 { margin: 0 0 10px; font-size: 14px; }
.screener-wrap .row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.screener-wrap .row .k { width: 36px; color: var(--muted); font-size: 12px; flex-shrink: 0; }
.screener-wrap .row .v { flex: 1; }
.screener-wrap table.mini { width: 100%; min-width: 0; white-space: normal; border-collapse: collapse; font-size: 12px; }
.screener-wrap table.mini th { color: var(--muted); font-weight: 600; text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--border); }
.screener-wrap table.mini td { padding: 5px 6px; border-bottom: 1px solid rgba(255,255,255,.05); color: var(--text); }
.screener-wrap table.mini tr:hover td { background: #1a2740; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #2a3852; border-radius: 4px; }

/* ---------- 响应式：窄视口下面板下移，图表占满宽度（保证最新K线直接可见） ---------- */
@media (max-width: 1100px) {
  .panel { width: 300px; min-width: 300px; }
}
@media (max-width: 760px) {
  .main { flex-direction: column; }
  #splitter { display: none; }
  .chart-wrap { flex: 0 0 55vh; }  /* 窄视口图表固定55vh，保证K线可读 */
  .panel { width: 100%; min-width: 0; flex: 1; border-left: none; border-top: 1px solid var(--border); }
  .chips { margin-left: 0; }
}
