:root {
  --bg-deep: #050a13;
  --bg-panel: rgba(10, 18, 34, 0.82);
  --bg-glass: rgba(13, 23, 42, 0.74);
  --border-holo: rgba(102, 204, 255, 0.24);
  --border-pink: rgba(255, 183, 197, 0.26);
  --tianyi: #66ccff;
  --ice-cyan: #56f2e0;
  --sakura: #ffb7c5;
  --neon-rose: #ff5e94;
  --gold: #ffd700;
  --mint: #1de9b6;
  --danger: #ff3366;
  --text-main: #eef5ff;
  --text-muted: #8fa3bf;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --radius-lg: 14px;
  --radius-md: 10px;
  --btn-min-h: 42px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 15% 10%, rgba(102, 204, 255, 0.09), transparent 40%),
              radial-gradient(circle at 88% 85%, rgba(255, 183, 197, 0.08), transparent 42%),
              var(--bg-deep);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

body[data-pointer="coarse"] {
  --btn-min-h: 46px;
}

/* ===== Passkey 全息锁屏 ===== */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--safe-top)) 18px calc(20px + var(--safe-bottom));
  background: radial-gradient(circle at 50% 25%, rgba(18, 38, 72, 0.72), rgba(4, 8, 16, 0.96));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.auth-overlay.hidden {
  display: none;
}

.auth-card {
  width: 100%;
  max-width: 430px;
  background: linear-gradient(165deg, rgba(14, 25, 47, 0.92), rgba(8, 14, 28, 0.95));
  border: 1px solid rgba(102, 204, 255, 0.35);
  border-radius: 20px;
  padding: 26px 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65), 0 0 32px rgba(102, 204, 255, 0.12);
}

.auth-logo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.auth-logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  border: 1px solid var(--border-holo);
}

.auth-title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.4px;
  background: linear-gradient(90deg, #66ccff, #56f2e0, #ffb7c5);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.device-detect-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(102, 204, 255, 0.1);
  border: 1px solid rgba(102, 204, 255, 0.25);
  color: var(--tianyi);
  margin-bottom: 16px;
}

.auth-warn {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 51, 102, 0.14);
  border: 1px solid rgba(255, 51, 102, 0.42);
  color: #ffd6e0;
  font-size: 12.5px;
  line-height: 1.5;
  margin-bottom: 14px;
}

.auth-primary-btn {
  width: 100%;
  min-height: 52px;
  border-radius: 13px;
  border: 1px solid rgba(86, 242, 224, 0.65);
  background: linear-gradient(135deg, rgba(16, 62, 92, 0.92), rgba(14, 92, 98, 0.88));
  color: #ffffff;
  font-size: 15.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(86, 242, 224, 0.22);
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}

.auth-primary-btn:active {
  transform: scale(0.985);
}

.auth-divider {
  margin: 16px 0 12px;
  border-top: 1px solid rgba(143, 163, 191, 0.16);
  padding-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.pin-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.holo-input {
  flex: 1;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(102, 204, 255, 0.28);
  background: rgba(5, 11, 22, 0.85);
  color: var(--text-main);
  font-size: 14px;
  outline: none;
}

.holo-input:focus {
  border-color: var(--ice-cyan);
  box-shadow: 0 0 0 2px rgba(86, 242, 224, 0.18);
}

.auth-secondary-btn {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 183, 197, 0.42);
  background: rgba(255, 183, 197, 0.12);
  color: var(--sakura);
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
}

.auth-msg {
  margin-top: 12px;
  font-size: 12.5px;
  min-height: 18px;
  color: var(--gold);
  line-height: 1.45;
}

/* ===== 主终端三档自适应骨架 ===== */
.app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

/* 顶部状态与合约栏 */
.top-bar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  padding: 6px 10px;
  background: rgba(8, 15, 29, 0.9);
  border-bottom: 1px solid rgba(102, 204, 255, 0.18);
}

.hb-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  background: rgba(29, 233, 182, 0.12);
  border: 1px solid rgba(29, 233, 182, 0.38);
  color: var(--mint);
}

.hb-pill.warn {
  background: rgba(255, 215, 0, 0.14);
  border-color: rgba(255, 215, 0, 0.45);
  color: var(--gold);
}

.hb-pill.dead {
  background: rgba(255, 51, 102, 0.22);
  border-color: rgba(255, 51, 102, 0.72);
  color: #ff809f;
  animation: pulseAlert 1.1s infinite;
}

@keyframes pulseAlert {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.hb-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.sym-select, .period-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.holo-select {
  height: 31px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid rgba(102, 204, 255, 0.32);
  background: rgba(9, 18, 35, 0.95);
  color: var(--text-main);
  font-size: 12.5px;
  font-weight: 700;
}

.per-btn {
  height: 29px;
  min-width: 34px;
  padding: 0 7px;
  border-radius: 7px;
  border: 1px solid rgba(143, 163, 191, 0.2);
  background: rgba(13, 23, 42, 0.65);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.per-btn.active {
  border-color: var(--tianyi);
  background: rgba(102, 204, 255, 0.18);
  color: #ffffff;
}

.mode-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(102, 204, 255, 0.14);
  color: var(--tianyi);
  border: 1px solid rgba(102, 204, 255, 0.28);
}

.mode-tag.headless {
  background: rgba(255, 215, 0, 0.13);
  color: var(--gold);
  border-color: rgba(255, 215, 0, 0.34);
}

.device-badge {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  height: 29px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid rgba(102, 204, 255, 0.24);
  background: rgba(13, 24, 44, 0.78);
  color: var(--text-main);
  font-size: 11.5px;
  cursor: pointer;
}

/* 战术直断与 60% 强平血条横幅 */
.verdict-strip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 10px;
  background: linear-gradient(90deg, rgba(12, 24, 46, 0.92), rgba(15, 19, 36, 0.92));
  border-bottom: 1px solid rgba(102, 204, 255, 0.15);
  font-size: 12px;
}

.verdict-strip[data-tint="1"] {
  border-left: 3px solid var(--ice-cyan);
}
.verdict-strip[data-tint="-1"] {
  border-left: 3px solid var(--neon-rose);
}
.verdict-strip[data-tint="2"] {
  border-left: 3px solid var(--gold);
}

.verdict-main {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.liq-mini-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  font-size: 11px;
}

.liq-bar-bg {
  width: 68px;
  height: 7px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.liq-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #00e676, #56f2e0);
  transition: width 0.25s ease;
}

.liq-bar-fill.warn { background: linear-gradient(90deg, #ff9800, #ffd700); }
.liq-bar-fill.danger { background: linear-gradient(90deg, #ff1744, #ff5e94); }

/* 核心工作区网格 */
.workspace-grid {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.charts-column {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.canvas-stage {
  flex: 1;
  min-height: 150px;
  position: relative;
  overflow: hidden;
}

.chart-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.sub-stage {
  height: 24%;
  min-height: 105px;
  border-top: 1px solid rgba(102, 204, 255, 0.16);
  position: relative;
}

.sub-stage.hidden {
  display: none;
}

.pane-label {
  position: absolute;
  top: 5px;
  left: 8px;
  z-index: 12;
  pointer-events: none;
  font-size: 11px;
  font-weight: 700;
  color: rgba(226, 238, 255, 0.86);
  background: rgba(6, 12, 24, 0.68);
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid rgba(102, 204, 255, 0.18);
}

.snap-live-btn {
  position: absolute;
  right: 76px;
  bottom: 10px;
  z-index: 20;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(102, 204, 255, 0.5);
  background: rgba(8, 18, 36, 0.88);
  color: var(--tianyi);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.snap-live-btn.hidden {
  display: none;
}

/* 手机竖屏分栏切换条 */
.mobile-view-tabs {
  flex-shrink: 0;
  display: flex;
  gap: 4px;
  padding: 5px 8px;
  background: rgba(7, 13, 26, 0.94);
  border-top: 1px solid rgba(102, 204, 255, 0.16);
  overflow-x: auto;
}

.m-tab {
  flex: 1;
  min-width: max-content;
  padding: 6px 9px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(16, 28, 50, 0.62);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.m-tab.active {
  border-color: rgba(102, 204, 255, 0.45);
  background: rgba(102, 204, 255, 0.16);
  color: #ffffff;
}

/* 右侧/抽屉式战术与实盘交易舱 */
.side-dock {
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(10, 18, 34, 0.96), rgba(6, 11, 22, 0.98));
  border-top: 1px solid rgba(102, 204, 255, 0.22);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px;
  overflow-y: auto;
}

.panel-card {
  background: rgba(12, 22, 41, 0.72);
  border: 1px solid rgba(102, 204, 255, 0.17);
  border-radius: var(--radius-md);
  padding: 9px 10px;
}

.panel-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 800;
  color: var(--tianyi);
  margin-bottom: 7px;
}

/* 交易控制按钮与输入 */
.quote-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 12px;
  margin-bottom: 7px;
  font-variant-numeric: tabular-nums;
}

.q-bid { color: var(--ice-cyan); font-weight: 800; }
.q-ask { color: var(--sakura); font-weight: 800; }
.q-last { color: var(--gold); font-weight: 800; font-size: 13.5px; }

.order-form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 7px;
}

.field-box {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.field-box label {
  font-size: 10.5px;
  color: var(--text-muted);
}

.field-box input, .field-box select {
  height: 34px;
  width: 100%;
  padding: 0 7px;
  border-radius: 8px;
  border: 1px solid rgba(102, 204, 255, 0.25);
  background: rgba(5, 10, 20, 0.9);
  color: var(--text-main);
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.buy-sell-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 6px;
}

.btn-buy, .btn-sell {
  min-height: var(--btn-min-h);
  border-radius: 11px;
  font-size: 14.5px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.15;
  transition: transform 0.1s ease, opacity 0.15s ease;
}

.btn-buy {
  border: 1px solid rgba(86, 242, 224, 0.75);
  background: linear-gradient(145deg, rgba(10, 88, 96, 0.92), rgba(14, 52, 82, 0.94));
  color: #e8fffb;
  box-shadow: 0 4px 16px rgba(86, 242, 224, 0.18);
}

.btn-sell {
  border: 1px solid rgba(255, 94, 148, 0.75);
  background: linear-gradient(145deg, rgba(108, 22, 58, 0.92), rgba(72, 18, 46, 0.94));
  color: #ffeaf1;
  box-shadow: 0 4px 16px rgba(255, 94, 148, 0.18);
}

.btn-buy:disabled, .btn-sell:disabled, .quick-act-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-sub-hint {
  font-size: 10px;
  font-weight: 600;
  opacity: 0.85;
  margin-top: 2px;
}

.quick-actions-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.quick-act-btn {
  min-height: 35px;
  border-radius: 8px;
  border: 1px solid rgba(143, 163, 191, 0.28);
  background: rgba(16, 28, 52, 0.85);
  color: var(--text-main);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.quick-act-btn.be {
  border-color: rgba(29, 233, 182, 0.45);
  color: var(--mint);
}

.quick-act-btn.flatten {
  border-color: rgba(255, 51, 102, 0.55);
  background: rgba(92, 16, 38, 0.65);
  color: #ff94af;
}

/* 14项诊断列表与持仓列表 */
.hud-table {
  display: grid;
  grid-template-columns: 66px 1fr;
  gap: 4px 8px;
  font-size: 11.5px;
  line-height: 1.38;
}

.hud-k {
  color: var(--text-muted);
  font-weight: 600;
}

.hud-v {
  color: var(--text-main);
  font-weight: 600;
  word-break: break-word;
}

.pos-item, .ord-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(7, 13, 26, 0.78);
  border: 1px solid rgba(102, 204, 255, 0.14);
  margin-bottom: 5px;
  font-size: 11.5px;
}

.tag-long { color: var(--ice-cyan); font-weight: 800; }
.tag-short { color: var(--neon-rose); font-weight: 800; }
.pnl-pos { color: #00e676; font-weight: 800; }
.pnl-neg { color: #ff4d79; font-weight: 800; }

.mini-btn {
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid rgba(102, 204, 255, 0.3);
  background: rgba(16, 32, 60, 0.85);
  color: var(--text-main);
  font-size: 11px;
  cursor: pointer;
}

/* 双层盘口光谱条 */
.dom-meter {
  margin-bottom: 6px;
}

.dom-meter-lbl {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 3px;
}

.dom-meter-track {
  height: 7px;
  border-radius: 99px;
  background: rgba(255, 94, 148, 0.35);
  overflow: hidden;
}

.dom-meter-bid {
  height: 100%;
  background: linear-gradient(90deg, #2196f3, #56f2e0);
}

/* 吐司通知与确认弹窗 */
.toast-box {
  position: fixed;
  top: calc(54px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 950;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(10, 22, 42, 0.95);
  border: 1px solid var(--tianyi);
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.toast-box.hidden {
  opacity: 0;
}

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 920;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(3, 7, 15, 0.76);
  backdrop-filter: blur(8px);
}

.modal-mask.hidden {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 380px;
  background: rgba(12, 22, 42, 0.97);
  border: 1px solid rgba(102, 204, 255, 0.4);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.7);
}

/* ===== 三档设备与分辨率布局精准响应 ===== */

/* 档位 1：手机竖屏单手大拇指舱 (默认 < 768px 竖屏) */
body[data-layout="mobile-portrait"] .side-dock {
  max-height: 45vh;
}
body[data-layout="mobile-portrait"] .desktop-only {
  display: none !important;
}

/* 档位 2：平板 / 手机横屏 / 折叠屏展开 (768px ~ 1199px 或横屏) */
body[data-layout="tablet-split"] .workspace-grid {
  flex-direction: row;
}
body[data-layout="tablet-split"] .charts-column {
  flex: 1 1 65%;
}
body[data-layout="tablet-split"] .side-dock {
  flex: 0 0 330px;
  max-height: none;
  border-top: none;
  border-left: 1px solid rgba(102, 204, 255, 0.2);
}
body[data-layout="tablet-split"] .mobile-view-tabs {
  display: flex;
}

/* 档位 3：笔记本 / PC 宽屏全息四屏工作台 (>= 1200px) */
body[data-layout="desktop-holo"] .workspace-grid {
  flex-direction: row;
}
body[data-layout="desktop-holo"] .charts-column {
  flex: 1 1 72%;
}
body[data-layout="desktop-holo"] .sub-stage {
  display: block !important;
  height: 21%;
}
body[data-layout="desktop-holo"] .mobile-view-tabs {
  display: none;
}
body[data-layout="desktop-holo"] .side-dock {
  flex: 0 0 365px;
  max-height: none;
  border-top: none;
  border-left: 1px solid rgba(102, 204, 255, 0.22);
}
