/* 手机端（/m）专属样式。令牌与基础组件在 /shared/theme.css。 */

html, body { height: 100%; }

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

/* ---------------------------------------------------------------- 顶栏 */
.statusbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(6px + var(--safe-t)) 14px 6px;
  background: rgba(12,14,17,.92);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: 12px;
  color: var(--text-dim);
  z-index: 20;
}

.sb-left, .sb-right { display: flex; align-items: center; gap: 7px; min-width: 0; }
.sb-sep { width: 1px; height: 10px; background: var(--line); }

.dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-mute); flex: 0 0 auto;
}
.dot.live   { background: var(--ok);   box-shadow: 0 0 0 3px rgba(48,164,108,.16); }
.dot.hot    { background: var(--up);   box-shadow: 0 0 0 3px rgba(229,72,77,.16); animation: pulse 1.8s infinite; }
.dot.cold   { background: var(--text-mute); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(229,72,77,.16); }
  50%      { box-shadow: 0 0 0 5px rgba(229,72,77,.06); }
}

#sb-clock { color: var(--text-mute); font-size: 11px; }

.conn {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-mute); flex: 0 0 auto;
  transition: background .2s;
}
.conn[data-state="open"]  { background: var(--ok); }
.conn[data-state="auth"]  { background: var(--warn); }
.conn[data-state="retry"] { background: var(--warn); animation: blink 1s infinite; }
.conn[data-state="closed"]{ background: #4a5361; }
@keyframes blink { 50% { opacity: .25; } }

/* ---------------------------------------------------------------- 告警条 */
.alertbar {
  flex: 0 0 auto;
  padding: 8px 14px;
  font-size: 12px;
  line-height: 1.4;
  border-bottom: 1px solid transparent;
}
.alertbar.warn {
  background: rgba(245,166,35,.1);
  border-bottom-color: rgba(245,166,35,.22);
  color: #f0b855;
}
.alertbar.danger {
  background: rgba(229,72,77,.11);
  border-bottom-color: rgba(229,72,77,.24);
  color: #f07a7d;
}
.alertbar b { font-weight: 600; }

/* ---------------------------------------------------------------- 内容区 */
.view {
  flex: 1 1 auto;
  /* min-height:0 不能省。flex item 默认 min-height:auto，会被内容顶开，
     导致「内容超出却不产生内部滚动条」，页面看起来卡在顶部滚不动。
     overflow-y:auto 在多数浏览器里已隐含这条，但显式写出来更稳。 */
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 12px calc(20px + var(--safe-b));
  scroll-behavior: smooth;
}

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 2px 2px 12px;
}
.page-title { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.page-sub { font-size: 12px; color: var(--text-mute); }

/* ---------------------------------------------------------------- 底栏 */
.tabs {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(18,22,28,.96);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 20;
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 6px;
  color: var(--text-mute);
  font-size: 10.5px;
  transition: color .15s;
}
.tab svg { width: 21px; height: 21px; fill: currentColor; }
.tab.active { color: var(--text); }
.tab.active svg { fill: var(--accent); }
.tab:active { opacity: .7; }

/* ---------------------------------------------------------------- 账户大卡 */
.hero {
  background: linear-gradient(160deg, #1a2230 0%, #14181e 62%);
  border: 1px solid #26313f;
  border-radius: 14px;
  padding: 16px;
}
.hero-label { font-size: 12px; color: var(--text-mute); margin-bottom: 6px; }
.hero-value {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.15;
}
.hero-value small { font-size: 15px; font-weight: 500; margin-left: 3px; color: var(--text-dim); }
.hero-foot {
  display: flex;
  gap: 18px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.hero-foot div { min-width: 0; }
.hero-foot .k { font-size: 11px; color: var(--text-mute); }
.hero-foot .v { font-size: 14px; font-weight: 500; margin-top: 2px; }

/* ---------------------------------------------------------------- 三格计数 */
.tri { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.tri-cell {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
}
.tri-cell .v { font-size: 19px; font-weight: 600; line-height: 1.2; }
.tri-cell .k { font-size: 11px; color: var(--text-mute); margin-top: 2px; }

/* ---------------------------------------------------------------- 指数条 */
.idx-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 4px;
  margin: 0 -2px;
  scrollbar-width: none;
}
.idx-strip::-webkit-scrollbar { display: none; }
.idx {
  flex: 0 0 auto;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  min-width: 96px;
}
.idx .k { font-size: 11px; color: var(--text-mute); }
.idx .p { font-size: 14px; font-weight: 500; margin-top: 1px; }
.idx .c { font-size: 11px; margin-top: 1px; }

/* ---------------------------------------------------------------- 信号条目 */
.sig-list { display: flex; flex-direction: column; gap: 8px; }

.sig {
  position: relative;
  display: block;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px 11px 14px;
  overflow: hidden;
}
.sig::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--text-mute);
}
.sig[data-kind="S1"]::before { background: var(--up); }
.sig[data-kind="S2"]::before { background: var(--accent); }
.sig[data-kind="S3"]::before { background: var(--warn); }
.sig[data-kind="S4"]::before { background: var(--down); }
.sig[data-status="CONFIRMED"] { border-color: rgba(229,72,77,.28); }
.sig[data-status="INVALIDATED"] { opacity: .68; }

.sig-top { display: flex; align-items: center; gap: 7px; }
.sig-name { font-size: 15px; font-weight: 500; }
.sig-code { font-size: 11px; color: var(--text-mute); font-variant-numeric: tabular-nums; }
.sig-price { margin-left: auto; font-size: 15px; font-weight: 600; }

.sig-mid {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
  font-size: 11.5px;
  color: var(--text-dim);
  flex-wrap: wrap;
}
.sig-note {
  margin-top: 7px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.45;
}
.sig-meta {
  margin-top: 7px;
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-mute);
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------- 时间轴 */
.tl { position: relative; padding-left: 18px; }
.tl::before {
  content: "";
  position: absolute;
  left: 4px; top: 6px; bottom: 6px;
  width: 1px;
  background: var(--line);
}
.tl-item { position: relative; padding-bottom: 14px; font-size: 12px; color: var(--text-dim); }
.tl-item::before {
  content: "";
  position: absolute;
  left: -18px; top: 5px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--line);
  border: 1px solid var(--bg);
}
.tl-item[data-level="WARN"]::before  { background: var(--warn); }
.tl-item[data-level="ERROR"]::before { background: var(--danger); }
.tl-item[data-level="FATAL"]::before { background: var(--danger); }
.tl-time { color: var(--text-mute); font-size: 11px; margin-right: 6px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- 持仓卡 */
.pos {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
}
.pos.breach { border-color: rgba(229,72,77,.42); background: rgba(229,72,77,.05); }
.pos-top { display: flex; align-items: baseline; gap: 7px; }
.pos-name { font-size: 15px; font-weight: 500; }
.pos-pnl { margin-left: auto; text-align: right; }
.pos-pnl .a { font-size: 15px; font-weight: 600; }
.pos-pnl .b { font-size: 11px; }

.pos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 11px;
  padding-top: 11px;
  border-top: 1px solid var(--line-soft);
}
.pos-grid .k { font-size: 10.5px; color: var(--text-mute); }
.pos-grid .v { font-size: 13px; margin-top: 1px; font-variant-numeric: tabular-nums; }

.gauge { margin-top: 11px; }
.gauge-bar {
  position: relative;
  height: 5px;
  border-radius: 3px;
  background: #232a34;
  overflow: hidden;
}
.gauge-fill { position: absolute; inset: 0 auto 0 0; border-radius: 3px; }
.gauge-fill.safe { background: linear-gradient(90deg, #2a7f5c, var(--up)); }
.gauge-fill.breach { background: var(--danger); }
.gauge-cap { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--text-mute); margin-top: 4px; }

/* ---------------------------------------------------------------- 个股详情 */
.stock-head { display: flex; align-items: flex-end; gap: 10px; margin: 0 2px 12px; }
.stock-head .nm { font-size: 19px; font-weight: 600; }
.stock-head .cd { font-size: 11.5px; color: var(--text-mute); padding-bottom: 2px; }
.stock-head .px { margin-left: auto; text-align: right; }
.stock-head .px .a { font-size: 24px; font-weight: 600; line-height: 1.1; }
.stock-head .px .b { font-size: 12px; }

.chart-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 4px 4px;
  position: relative;
}
#minute-chart { display: block; width: 100%; height: 232px; }
.chart-empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text-mute);
  background: var(--bg-elev);
  border-radius: var(--radius);
}

.legend {
  display: flex; gap: 12px; flex-wrap: wrap;
  padding: 6px 10px 2px;
  font-size: 10.5px; color: var(--text-mute);
}
.legend i { display: inline-block; width: 14px; height: 0; margin-right: 4px; vertical-align: middle; border-top-width: 1px; border-top-style: solid; }

/* ---------------------------------------------------------------- 盘口 */
.book { display: grid; grid-template-columns: 1fr; gap: 1px; margin-top: 2px; }
.book-row {
  display: grid;
  grid-template-columns: 34px 1fr 1fr;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  font-size: 12px;
  position: relative;
  font-variant-numeric: tabular-nums;
}
.book-row .lv { color: var(--text-mute); font-size: 11px; }
.book-row .px { font-weight: 500; }
.book-row .vol { text-align: right; color: var(--text-dim); }
.book-bar {
  position: absolute;
  right: 8px; top: 4px; bottom: 4px;
  background: rgba(152,163,178,.08);
  border-radius: 2px;
  pointer-events: none;
}
.book-spread {
  text-align: center;
  font-size: 11px;
  color: var(--text-mute);
  padding: 5px 0;
  margin: 2px 0;
  border-top: 1px dashed var(--line);
  border-bottom: 1px dashed var(--line);
}

/* ---------------------------------------------------------------- 键值表 */
.kv { display: flex; flex-direction: column; }
.kv-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 2px;
  font-size: 13px;
  border-bottom: 1px solid var(--line-soft);
}
.kv-row:last-child { border-bottom: none; }
.kv-row .k { color: var(--text-dim); }
.kv-row .v { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- 筛选 chips */
.chips { display: flex; gap: 7px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  height: 30px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text-dim);
  font-size: 12.5px;
}
.chip.active { background: rgba(77,139,245,.14); border-color: rgba(77,139,245,.4); color: #9dc0ff; }

/* ---------------------------------------------------------------- 候选列表 */
.pool-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.pool-item + .pool-item { margin-top: 7px; }
.pool-main { min-width: 0; flex: 1 1 auto; }
.pool-nm { font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.pool-cd { font-size: 11px; color: var(--text-mute); font-variant-numeric: tabular-nums; }
.pool-meta { font-size: 11px; color: var(--text-mute); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }
.pool-px { text-align: right; flex: 0 0 auto; min-width: 68px; }
.pool-px .a { font-size: 14px; font-weight: 500; }
.pool-px .b { font-size: 11px; }

.search-box { position: relative; margin-bottom: 10px; }
.search-box input { padding-left: 34px; }
.search-box svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; fill: var(--text-mute);
}

.load-more {
  margin-top: 12px;
  width: 100%;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--text-dim);
  font-size: 12.5px;
  font-family: inherit;
}

/* ---------------------------------------------------------------- 样本提示 */
.sample {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-mute);
  background: var(--bg-elev);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
}
.sample b { color: var(--text-dim); font-weight: 500; }
.sample-gauge { flex: 1 1 auto; height: 3px; background: #232a34; border-radius: 2px; overflow: hidden; }
.sample-gauge i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }

/* ---------------------------------------------------------------- 登录 */
.login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(120% 90% at 50% 0%, #172031 0%, #0c0e11 58%);
  z-index: 120;
}
.login-card { width: 100%; max-width: 320px; }
.login-brand { font-size: 30px; font-weight: 600; letter-spacing: .06em; }
.login-sub { color: var(--text-mute); font-size: 12.5px; margin: 6px 0 26px; }
.login form { display: flex; flex-direction: column; gap: 10px; }
.login-err {
  min-height: 18px;
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--up);
  line-height: 1.5;
}
.login-hint { margin: 18px 0 0; font-size: 11px; color: var(--text-mute); line-height: 1.6; }

/* ---------------------------------------------------------------- 启动 */
.boot {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--bg);
  z-index: 200;
  transition: opacity .25s ease;
}
.boot.hide { opacity: 0; pointer-events: none; }
.boot-mark { font-size: 22px; letter-spacing: .22em; color: var(--text-dim); }
.boot-bar { width: 96px; height: 2px; background: #1e252e; border-radius: 1px; overflow: hidden; }
.boot-bar i {
  display: block; width: 34%; height: 100%;
  background: var(--accent);
  border-radius: 1px;
  animation: slide 1.1s ease-in-out infinite;
}
@keyframes slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}

/* ---------------------------------------------------------------- 协议告警 */
.banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: calc(8px + var(--safe-t)) 14px 8px;
  background: #46232a;
  border-bottom: 1px solid rgba(229,72,77,.4);
  color: #ffb3b6;
  font-size: 12px;
  line-height: 1.5;
  z-index: 210;
  text-align: center;
}
.banner a { color: #fff; text-decoration: underline; }

.hidden { display: none !important; }

/* ---------------------------------------------------------------- 协议告警占位 */
html.has-banner .app   { height: calc(100dvh - var(--banner-h, 0px)); margin-top: var(--banner-h, 0px); }
html.has-banner .login { padding-top: var(--banner-h, 0px); }
html.has-banner #boot  { padding-top: var(--banner-h, 0px); }
