/* 超级量化 PWA · 移动优先 · 深色驾驶舱 */
:root {
  --bg: #0a0e17;
  --bg-card: #131a28;
  --bg-card-2: #1a2436;
  --border: #243049;
  --text: #e8edf6;
  --text-dim: #8a97ad;
  --accent: #3b82f6;
  --long: #16c784;
  --short: #ea3943;
  --warn: #f0a020;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  padding-top: calc(96px + var(--safe-top));
  padding-bottom: calc(64px + var(--safe-bottom));
  overflow-x: hidden;
}

/* 顶栏 */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: rgba(10, 14, 23, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.logo-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 12px var(--accent); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.badge { font-size: 12px; padding: 3px 9px; border-radius: 20px; font-weight: 600; }
.badge-demo { background: rgba(59,130,246,0.18); color: #6ea8fe; }
.badge-live { background: rgba(234,57,67,0.18); color: #ff6b75; }
.pause-btn {
  background: var(--short); color: #fff; border: none; border-radius: 20px;
  padding: 7px 14px; font-size: 13px; font-weight: 700; cursor: pointer;
  transition: transform 0.1s;
}
.pause-btn:active { transform: scale(0.94); }
.pause-btn.resumed { background: var(--long); }
.lang-btn {
  background: var(--bg-card-2); color: var(--text-dim); border: 1px solid var(--border);
  border-radius: 20px; padding: 5px 11px; font-size: 12px; font-weight: 700;
  cursor: pointer; transition: transform 0.1s;
}
.lang-btn:active { transform: scale(0.94); }

/* 风险横幅 */
.risk-banner {
  position: fixed; top: calc(52px + var(--safe-top)); left: 0; right: 0; z-index: 39;
  font-size: 11.5px; color: var(--warn); background: rgba(240,160,32,0.08);
  padding: 6px 16px; text-align: center; border-bottom: 1px solid rgba(240,160,32,0.15);
}

/* 主体 */
main { padding: 14px; max-width: 720px; margin: 0 auto; }
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.card-title { font-size: 13px; color: var(--text-dim); margin-bottom: 10px; font-weight: 600; }

/* 净值 / 大数字 */
.equity { font-size: 32px; font-weight: 800; letter-spacing: -0.5px; }
.equity-row { display: flex; align-items: baseline; justify-content: space-between; }
.pnl-pos { color: var(--long); } .pnl-neg { color: var(--short); }
.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.metric { background: var(--bg-card-2); border-radius: 10px; padding: 12px; }
.metric .v { font-size: 19px; font-weight: 700; }
.metric .k { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }

/* 共识仪表 */
.consensus-meter { display: flex; align-items: center; gap: 14px; }
.meter-ring {
  --pct: 0; --thresh: 90; width: 84px; height: 84px; border-radius: 50%; flex-shrink: 0;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--bg-card-2) 0);
  display: flex; align-items: center; justify-content: center; position: relative;
}
.meter-ring::before { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--bg-card); }
/* 28票阈值刻度线 */
.meter-ring::after {
  content: ""; position: absolute; width: 3px; height: 10px; background: var(--warn);
  top: 0; left: 50%; transform-origin: 50% 42px;
  transform: translateX(-50%) rotate(calc(var(--thresh) * 3.6deg));
}
.meter-ring.meter-pass { background: conic-gradient(var(--long) calc(var(--pct) * 1%), var(--bg-card-2) 0);
  box-shadow: 0 0 16px rgba(22,199,132,0.4); }
.meter-ring .meter-val { position: relative; font-weight: 800; font-size: 17px; }
.meter-info { flex: 1; }
.dir-tag { display: inline-block; padding: 3px 12px; border-radius: 8px; font-weight: 700; font-size: 14px; }
.dir-LONG { background: rgba(22,199,132,0.16); color: var(--long); }
.dir-SHORT { background: rgba(234,57,67,0.16); color: var(--short); }
.dir-NEUTRAL { background: rgba(138,151,173,0.16); color: var(--text-dim); }

/* Agent 思维流 */
.vote-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 0;
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.vote-row:last-child { border-bottom: none; }
.vote-fam { font-size: 10px; padding: 2px 6px; border-radius: 5px; flex-shrink: 0; width: 52px; text-align: center; }
.fam-quant { background: rgba(59,130,246,0.16); color: #6ea8fe; }
.fam-timeframe { background: rgba(155,89,242,0.16); color: #b18cff; }
.fam-llm { background: rgba(240,160,32,0.16); color: var(--warn); }
.vote-reason { flex: 1; color: var(--text-dim); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vote-dir { font-weight: 700; flex-shrink: 0; font-size: 12px; }
.thinking-flow { animation: fadein 0.4s; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 按钮 */
.btn {
  border: none; border-radius: 10px; padding: 13px 18px; font-size: 15px;
  font-weight: 700; cursor: pointer; transition: transform 0.1s, opacity 0.2s; width: 100%;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-danger { background: var(--short); color: #fff; }
.btn-ghost { background: var(--bg-card-2); color: var(--text); }
.btn-long { background: var(--long); color: #fff; }
.btn-short { background: var(--short); color: #fff; }
.btn-row { display: flex; gap: 10px; }

/* 输入 */
.input, .nl-input, .select {
  width: 100%; background: var(--bg-card-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 13px; color: var(--text); font-size: 15px; margin-bottom: 10px;
}
.input:focus, .nl-input:focus, .select:focus { outline: none; border-color: var(--accent); }
.field-label { font-size: 13px; color: var(--text-dim); display: block; margin-bottom: 6px; }

/* NL 聊天 */
.chat { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; min-height: 200px; }
.bubble { max-width: 82%; padding: 10px 13px; border-radius: 14px; font-size: 14px; }
.bubble-user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bubble-bot { align-self: flex-start; background: var(--bg-card-2); border-bottom-left-radius: 4px; }

/* Tab 栏 */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; background: rgba(10,14,23,0.96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border); padding-bottom: var(--safe-bottom);
}
.tab {
  flex: 1; background: none; border: none; color: var(--text-dim);
  padding: 9px 0 8px; font-size: 11px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tab.active { color: var(--accent); }
.tab-ico { font-size: 19px; }

/* 弹层 */
.modal-mask {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 22px; max-width: 360px; width: 100%; animation: fadein 0.2s; }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 10px; }
.modal-body { color: var(--text-dim); font-size: 14px; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

/* Toast */
.toast {
  position: fixed; bottom: calc(80px + var(--safe-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--bg-card-2); border: 1px solid var(--border); color: var(--text);
  padding: 11px 18px; border-radius: 24px; font-size: 13px; z-index: 70; animation: fadein 0.3s;
  max-width: 90%; text-align: center;
}

.empty { color: var(--text-dim); text-align: center; padding: 40px 0; font-size: 14px; }
.disclaimer { font-size: 11px; color: var(--text-dim); margin-top: 8px; line-height: 1.5; }
.skeleton { background: linear-gradient(90deg, var(--bg-card-2) 25%, var(--border) 50%, var(--bg-card-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; height: 16px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
