/* Trader Desk v2 样式：单用户双交易对纯信号版（无图表）。
   布局：顶栏 + 双面板（信号卡/持仓条/操作）+ 联动浮动条；H5 一屏为目标。 */
:root {
  --line: #e6e8eb;
  --dim: #848e9c;
  --text: #1e2329;
  --up: #0ecb81;
  --down: #f6465d;
  --up-soft: rgba(14, 203, 129, 0.1);
  --down-soft: rgba(246, 70, 93, 0.1);
  --warn-bg: #fef6d8;
  --warn-text: #8a6d00;
  --acid: #127a52;
  --acid-soft: rgba(18, 122, 82, 0.14);
  --panel-radius: 12px;
}
* { box-sizing: border-box; margin: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: #f7f8fa;
  color: var(--text);
  font-size: 14px;
}
button { font: inherit; }
/* 作者样式的 display（如 .login-view 的 flex）会压过 UA 的 [hidden] 规则，
   导致 JS 置 hidden 后元素视觉不消失（v2 重写曾丢此守卫——登录后登录框
   残留在屏幕上）。全局显式补回。 */
[hidden] { display: none !important; }
.is-up { color: var(--up); }
.is-down { color: var(--down); }
.is-flat { color: #616975; }

/* ===== 登录页 ===== */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: min(380px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--panel-radius);
  padding: 28px 24px;
  box-shadow: 0 12px 40px rgba(30, 35, 41, 0.08);
}
.login-card h2 { margin-bottom: 18px; }
.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  color: var(--dim);
  font-size: 12px;
  margin-bottom: 4px;
}
.field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  background: #fff;
}
.field.checkbox { display: flex; align-items: center; gap: 8px; }
.field.checkbox input { width: auto; }
.field.checkbox > span { margin: 0; color: var(--text); font-size: 13px; }
.form-error { color: var(--down); font-size: 12px; min-height: 16px; }
.primary-action {
  width: 100%;
  border: none;
  border-radius: 8px;
  background: var(--acid);
  color: #fff;
  font-weight: 700;
  padding: 10px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  gap: 8px;
}
.login-footnote {
  margin-top: 14px;
  color: var(--dim);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--up);
  display: inline-block;
}

/* ===== 顶栏 ===== */
.desk-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
}
.desk-brand {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--text);
}
.brand-sigil {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--acid); color: #fff; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.desk-brand strong, .desk-brand small { display: block; }
.desk-brand small { color: var(--dim); font-size: 11px; }
.header-spacer { flex: 1; }
.connection-state, .account-button, .header-account-pnl {
  display: flex; align-items: center; gap: 6px;
}
.connection-state small, .account-button small, .header-account-pnl small {
  display: block; color: var(--dim); font-size: 11px;
}
.connection-state strong, .account-button strong, .header-account-pnl strong {
  display: block; font-size: 13px;
}
.header-account-pnl { text-align: right; }
.connection-light {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--dim);
  flex-shrink: 0;
}
.connection-light.is-on { background: var(--up); }
.connection-light.is-off { background: var(--down); }
.icon-button {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 6px 12px; color: var(--text); cursor: pointer;
}

/* ===== 双交易对工作区 ===== */
.workspace-hint {
  margin: 12px 12px 0; padding: 12px 16px;
  background: #fff; border: 1px dashed var(--line);
  border-radius: var(--panel-radius); color: var(--dim);
  max-width: 1920px; box-sizing: border-box;
}
.workspace-hint.is-error { color: var(--down); border-color: var(--down); }
.dual-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px; padding: 12px;
  max-width: 1920px; margin: 0 auto;
  align-items: start;
}
@media (max-width: 1050px) {
  .dual-workspace { grid-template-columns: minmax(0, 1fr); }
}
.symbol-panel {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--panel-radius); overflow: hidden;
  display: flex; flex-direction: column; min-width: 0;
}

/* 面板头：标的（今日涨跌）最新价 ……徽标右置 */
.panel-head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.panel-head .sym { font-size: 17px; font-weight: 800; letter-spacing: 0.2px; }
.panel-head .day-inline { color: var(--dim); font-size: 12px; }
.panel-head .last { font-size: 16px; font-weight: 800; }
.panel-head .badge { font-weight: 700; margin-left: auto; white-space: nowrap; }

/* 信号区：最新一条冻结信号（唯一决策输入） */
.signal-zone { padding: 8px 12px; border-bottom: 1px solid var(--line); }
.signal-latest {
  border-radius: 10px; padding: 8px 10px;
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  background: #f0f1f3;
  min-height: 34px;
}
.signal-latest.is-short { background: var(--down-soft); }
.signal-latest.is-long { background: var(--up-soft); }
.signal-latest .dir { font-size: 15px; font-weight: 800; }
.signal-latest .dir.is-short { color: var(--down); }
.signal-latest .dir.is-long { color: var(--up); }
.signal-latest .time { color: var(--dim); font-size: 11px; }
.signal-latest .factors { font-size: 12px; font-weight: 700; }
.signal-latest .empty { color: var(--dim); font-size: 12px; }

/* 持仓条 */
.position-strip {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px 10px; padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}
.position-strip span { display: block; color: var(--dim); font-size: 11px; }
.position-strip strong { font-size: 13px; }
.position-strip small { display: block; color: var(--dim); font-size: 11px; }

/* 面板内独立下单区 */
.order-row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 8px 12px;
}
.order-note { padding: 0 12px 8px; color: var(--dim); font-size: 11px; }
.btn {
  border: none; border-radius: 8px; padding: 8px 14px;
  font-weight: 700; cursor: pointer; color: #fff;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.long { background: var(--up); }
.btn.short { background: var(--down); }
.btn.close { background: var(--warn-bg); color: var(--warn-text); }
.btn.cancel { background: #fff; border: 1px solid var(--line); color: var(--dim); }

/* ===== 联动操作条（全局浮动底部居中；可拖动，双击复位） ===== */
.sync-bar {
  position: fixed;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 60;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  width: fit-content; max-width: 96vw;
  padding: 10px 14px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(30, 35, 41, 0.16);
  touch-action: none; user-select: none;
}
.sync-bar.is-dragging { transform: none; }
.sync-bar .sync-label { font-weight: 800; font-size: 13px; margin-right: 4px; cursor: grab; }
.sync-fields { display: flex; gap: 8px; align-items: center; }
.sync-field {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; padding: 6px 8px;
}
.sync-field .prefix { color: var(--dim); font-size: 12px; white-space: nowrap; }
.sync-field select { border: none; padding: 0; background: transparent; flex: 1; font: inherit; }
body.has-sync-bar { padding-bottom: 96px; }

/* ===== 弹窗 ===== */
.profile-dialog {
  border: 1px solid var(--line);
  border-radius: var(--panel-radius);
  padding: 0;
  width: min(440px, calc(100vw - 24px));
  box-shadow: 0 16px 48px rgba(30, 35, 41, 0.18);
}
.profile-dialog::backdrop { background: rgba(30, 35, 41, 0.32); }
.dialog-body { padding: 20px; }
.dialog-header h2 { font-size: 16px; }
.dialog-header { margin-bottom: 14px; }
.profile-subtitle { color: var(--dim); font-size: 12px; }
.profile-form .field input[type="number"],
.profile-form .field input:not([type]) {
  width: 100%;
}
.profile-toggles { margin: 6px 0 10px; }
.profile-security {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px 12px 4px;
  margin-bottom: 8px;
}
.profile-security legend { color: var(--dim); font-size: 12px; padding: 0 4px; }
/* 弹窗底部按钮区：显式「保存 / 取消」，Esc/点遮罩一律丢弃修改。 */
.dialog-actions { display: flex; gap: 8px; margin-top: 12px; }
.dialog-actions .primary-action { width: auto; flex: 1; }
.dialog-actions .btn.cancel { flex: 1; }

/* ===== Toast ===== */
.toast-region {
  position: fixed;
  right: 14px;
  top: 60px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, 90vw);
}
.toast {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--up);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 8px 24px rgba(30, 35, 41, 0.12);
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
}
.toast.is-error { border-left-color: var(--down); }
.toast strong { font-size: 13px; }
.toast span { color: var(--dim); }

/* ===== H5 适配 ===== */
@media (max-width: 760px) {
  .desk-header { gap: 10px; padding: 6px 10px; }
  /* 连接状态只留指示灯（绿=已连接 红=断开 灰=未知），文字全部隐藏。 */
  .desk-brand > span:last-child,
  .connection-state small,
  .connection-state > span:last-child,
  .account-button small,
  .account-button > span:last-child,
  .header-account-pnl small { display: none; }
  .dual-workspace { padding: 6px; gap: 6px; }
  .panel-head { padding: 6px 10px; }
  .signal-zone { padding: 6px 10px; }
  .signal-latest { padding: 6px 8px; }
  .position-strip { padding: 6px 10px; gap: 2px 10px; }
  .order-row { padding: 6px 10px; }
  .order-note { display: none; }
  .sync-bar {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    padding: 8px 10px;
  }
  .sync-bar .sync-label { display: none; }
  .sync-bar .sync-fields { display: flex; gap: 8px; flex: 1 1 100%; }
  .sync-bar .sync-fields .sync-field:first-child { flex: 1; }
  .sync-bar .sync-fields .sync-field:last-child { flex-shrink: 0; }
  .sync-bar .btn { flex: 1 1 0; padding: 8px 6px; }
  .order-row .btn { flex: 1 1 0; padding: 8px 6px; }
  body.has-sync-bar { padding-bottom: 130px; }
}
