/* Signal Watch（行情分支）：纯行情 + 反转信号展示，无交易 UI。
   从交易台样式表精简重写：登录 / 顶栏 / 双合约双面板 K 线 / 悬浮窗 / toast。 */

:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --bg-raised: #f7f8fa;
  --panel: #ffffff;
  --line: #e6e8ec;
  --line-hot: #c9ced6;
  --text: #181a20;
  --muted: #616975;
  --dim: #8b93a1;
  --acid: #0ecb81;
  --acid-soft: rgba(14, 203, 129, 0.09);
  --red: #f6465d;
  --amber: #f0b90b;
  --display: "SF Pro Display", -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI",
    sans-serif;
  --body: "SF Pro Text", -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI",
    sans-serif;
  --mono: "SFMono-Regular", "Roboto Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--body);
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

/* ===== Login ===== */
.login-view {
  align-items: center;
  background: #f6f7f9;
  display: grid;
  justify-content: center;
  margin: 0 auto;
  max-width: 1920px;
  min-height: 100vh;
}

.login-card {
  animation: card-in 560ms 80ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  background: rgba(255, 255, 255, 0.93);
  border: 1px solid rgba(225, 228, 233, 0.9);
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(31, 38, 51, 0.12),
    0 2px 8px rgba(31, 38, 51, 0.04);
  justify-self: center;
  margin: 0;
  padding: 42px;
  width: clamp(320px, 25vw, 480px);
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.985);
  }
}

.login-card h2 {
  font-family: var(--display);
  font-size: 30px;
  margin: 0 0 24px;
  text-align: center;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 17px;
}

.field > span {
  color: #474e59;
  font-size: 12px;
  font-weight: 600;
}

.field input {
  color: var(--text);
  width: 100%;
  background: #f8f9fa;
  border: 1px solid #e1e4e8;
  border-radius: 11px;
  min-height: 48px;
  padding-inline: 14px;
  transition: background 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.field input:hover,
.field input:focus {
  background: #fff;
  border-color: rgba(11, 143, 106, 0.58);
  box-shadow: 0 0 0 3px rgba(11, 143, 106, 0.08);
}

.form-error {
  color: var(--red);
  font-size: 12px;
  min-height: 18px;
}

.primary-action {
  background: var(--acid);
  border: 0;
  border-radius: 11px;
  color: #fff;
  font-weight: 650;
  min-height: 48px;
}

.primary-action:disabled {
  background: #d9dfd9;
  color: #86928a;
  cursor: not-allowed;
}

.login-action {
  width: 100%;
}

.login-footnote {
  align-items: center;
  color: var(--dim);
  display: flex;
  font-size: 11px;
  gap: 8px;
  justify-content: center;
  margin-top: 18px;
}

.status-dot,
.connection-light {
  background: var(--dim);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(83, 98, 100, 0.12);
  display: inline-block;
  height: 6px;
  width: 6px;
}

.status-dot,
.connection-light.is-data {
  background: var(--acid);
  box-shadow: 0 0 0 3px var(--acid-soft), 0 0 12px rgba(39, 122, 70, 0.3);
}

/* ===== 顶栏 ===== */
.desk-header {
  border-bottom: 1px solid var(--line);
  display: flex;
  position: sticky;
  top: 0;
  z-index: 40;
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
  height: 64px;
  padding: 0 18px;
}

.desk-brand {
  align-items: center;
  color: inherit;
  display: flex;
  text-decoration: none;
  gap: 10px;
  min-width: 220px;
}

.brand-sigil {
  align-items: center;
  color: #fff;
  display: flex;
  font-family: var(--display);
  font-weight: 900;
  justify-content: center;
  background: linear-gradient(145deg, #087a5b, #12a87e);
  border-radius: 10px;
  box-shadow: 0 6px 14px rgba(11, 143, 106, 0.18);
  font-size: 16px;
  height: 34px;
  width: 34px;
}

.desk-brand strong {
  font-family: var(--display);
  font-size: 15px;
  font-weight: 680;
  letter-spacing: -0.015em;
  display: block;
}

.desk-brand small,
.connection-state small {
  color: var(--dim);
  font-size: 9px;
  font-weight: 500;
  margin-top: 2px;
  display: block;
}

.header-mode {
  align-items: center;
  display: flex;
  background: #fff8e7;
  border: 1px solid #f0dfb7;
  border-radius: 999px;
  color: #98640b;
  font-size: 10px;
  font-weight: 650;
  gap: 6px;
  height: 28px;
  margin-left: 12px;
  padding: 0 10px;
}

.mode-switch {
  background: #e5b035;
  border-radius: 999px;
  height: 8px;
  width: 8px;
}

.header-spacer {
  flex: 1;
}

.connection-state {
  align-items: center;
  display: flex;
  gap: 9px;
  padding: 0 13px;
}

.connection-state strong {
  font-size: 11px;
  font-weight: 620;
  margin-top: 2px;
  display: block;
}

.icon-button {
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 9px;
  font-size: 12px;
  height: 38px;
  margin-left: 4px;
  padding-inline: 12px;
  white-space: nowrap;
}

.icon-button:hover {
  color: var(--text);
  background: #f5f6f8;
}

/* ===== 双合约工作区（一屏两张 K 线图） ===== */
.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;
}

.symbol-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  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;
  font-variant-numeric: tabular-nums;
}

.panel-head .trend-badge {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.01em;
  margin-left: auto;
  white-space: nowrap;
}

/* ===== 图表 ===== */
.chart-toolbar {
  align-items: center;
  border-bottom: 1px solid var(--line);
  color: var(--dim);
  display: flex;
  font-family: var(--mono);
  padding: 0 16px;
  background: #fafbfc;
  font-size: 11px;
  min-height: 32px;
  overflow-x: auto;
  white-space: nowrap;
}

.chart-toolbar .chart-tools {
  align-items: center;
  display: flex;
  flex-direction: row;
  flex-shrink: 0;
}

/* 币安式纯文字标签：无边框无底色，选中项加粗深色。 */
.tool-button {
  -webkit-tap-highlight-color: transparent;
  background: transparent;
  border: none;
  color: var(--dim);
  font-weight: 500;
  font-size: 12px;
  min-height: 24px;
  padding-inline: 8px;
}

.tool-button.is-active {
  color: var(--text);
  font-weight: 700;
}

.tool-button:disabled {
  cursor: default;
  opacity: 0.42;
}

/* 「最新」按钮兼作「已在最新」状态指示，保持可读。 */
.tool-button[data-chart-latest]:disabled {
  opacity: 1;
}

.chart-stage {
  position: relative;
  height: 520px;
  overflow: hidden;
}

.chart-container {
  display: block;
  height: 100%;
  position: relative;
  width: 100%;
  z-index: 2;
}

/* 图例悬浮在 K 线图左上角（币安式），不拦截鼠标事件；EMA 一行、唐奇安一行。 */
.chart-legends {
  display: flex;
  flex-direction: column;
  gap: 2px;
  left: 8px;
  pointer-events: none;
  position: absolute;
  top: 6px;
  z-index: 3;
}

.chart-legends-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.chart-legends span {
  align-items: center;
  display: flex;
  color: var(--muted);
  font-size: 11px;
  gap: 6px;
}

.legend-value {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.legend-value.ema20 { color: #f0b90b; }
.legend-value.ema50 { color: #e843b9; }
.legend-value.ema200 { color: #e94b71; }
.legend-value.donchian { color: #5096ad; }
.legend-value.day-range { color: var(--dim); }
.legend-value.supertrend-up { color: #0ecb81; }
.legend-value.supertrend-down { color: #f6465d; }

.chart-watermark {
  left: 50%;
  pointer-events: none;
  position: absolute;
  text-align: center;
  top: 33%;
  transform: translate(-50%, -50%);
  z-index: 1;
  opacity: 0.032;
}

.chart-watermark strong {
  display: block;
  letter-spacing: -0.06em;
  font-family: var(--display);
  font-size: clamp(60px, 7vw, 104px);
  font-weight: 720;
}

.chart-watermark span {
  font-size: 10px;
  letter-spacing: 0.12em;
}

/* 币安式最新价标签：价格轴旁的彩色方块，上行最新价、下行 K 线倒计时；
   宽度由 JS 对齐到价格轴列宽，左缘与价格轴竖线齐平。 */
.chart-price-tag {
  align-items: center;
  background: var(--acid);
  border-radius: 3px;
  box-sizing: border-box;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  font-family: var(--mono);
  gap: 0;
  padding: 3px 4px;
  pointer-events: none;
  position: absolute;
  right: 0;
  top: 4px;
  z-index: 3;
}

.chart-price-tag.is-down {
  background: var(--red);
}

/* 24h 高/低点标签：淡灰色小方块，横向「标签 + 数值」，锚定图表左缘，
   纵坐标跟随各自的 price line。 */
.chart-day-range-tag {
  align-items: baseline;
  background: #848e9c;
  flex-direction: row;
  gap: 3px;
  left: 0;
  opacity: 0.9;
  padding: 1px 4px;
  right: auto;
}

.chart-price-tag strong {
  font-size: 10px;
  font-weight: 600;
  line-height: 1.3;
}

.chart-price-tag span {
  font-size: 9px;
  line-height: 1.3;
  opacity: 0.92;
}

.chart-tooltip {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 4px 14px rgba(24, 26, 32, 0.12);
  color: var(--text);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.5;
  max-width: 280px;
  padding: 8px 10px;
  pointer-events: none;
  position: absolute;
  z-index: 5;
}

.chart-tooltip[hidden] {
  display: none;
}

.chart-tooltip-time {
  color: var(--muted);
  margin-bottom: 4px;
}

.chart-tooltip-grid {
  display: grid;
  gap: 1px 8px;
  grid-template-columns: auto 1fr;
}

.chart-tooltip-grid span {
  color: var(--muted);
}

.chart-tooltip-grid strong {
  font-weight: 600;
  text-align: right;
}

.chart-tooltip-reversal {
  border-top: 1px solid var(--line);
  font-weight: 600;
  margin-top: 6px;
  padding-top: 6px;
}

.chart-tooltip-reversal.is-long {
  color: var(--acid);
}

.chart-tooltip-reversal.is-short {
  color: var(--red);
}

.chart-tooltip-factors {
  border-top: 1px dashed var(--line);
  display: grid;
  gap: 2px;
  margin-top: 4px;
  padding-top: 4px;
}

.chart-tooltip-factor {
  display: grid;
  gap: 6px;
  grid-template-columns: auto 1fr auto;
}

.chart-tooltip-factor span {
  color: var(--muted);
}

.chart-tooltip-factor strong {
  font-weight: 500;
}

.chart-tooltip-factor.is-long strong {
  color: var(--acid);
}

.chart-tooltip-factor.is-short strong {
  color: var(--red);
}

.chart-tooltip-factor.is-unavailable strong,
.chart-tooltip-factor em {
  color: var(--dim);
}

.chart-tooltip-factor em {
  font-style: normal;
  text-align: right;
}

/* ===== Toast ===== */
.toast-region {
  display: grid;
  pointer-events: none;
  position: fixed;
  width: min(360px, calc(100vw - 36px));
  z-index: 100;
  bottom: 20px;
  gap: 9px;
  right: 20px;
}

.toast {
  animation: toast-in 260ms ease both;
  display: grid;
  position: relative;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 12px;
  box-shadow: 0 18px 46px rgba(31, 38, 51, 0.16);
  gap: 5px;
  padding: 14px 16px;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
}

.toast::before {
  background: var(--acid);
  border-radius: 50%;
  content: "";
  height: 7px;
  position: absolute;
  right: 14px;
  top: 14px;
  width: 7px;
}

.toast.is-error::before {
  background: var(--red);
}

.toast strong {
  font-size: 12px;
  padding-right: 16px;
}

.toast span {
  color: var(--muted);
  font-size: 10px;
}

/* ===== 响应式：≤1050px 单列堆叠，两面板均分视口高 ===== */
@media (max-width: 1050px) {
  .dual-workspace {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    /* 撑满：100dvh − 顶栏 64px − 工作区上下 padding 24px（vh 兜底老引擎）。 */
    min-height: calc(100vh - 88px);
    min-height: calc(100dvh - 88px);
  }

  .chart-stage {
    flex: 1;
    height: auto;
    min-height: 240px;
  }
}

@media (max-width: 760px) {
  .desk-header {
    gap: 10px;
    height: 54px;
    padding: 0 10px;
  }

  .desk-brand {
    min-width: 0;
  }

  .desk-brand small,
  .header-mode,
  .connection-state small {
    display: none;
  }

  .dual-workspace {
    gap: 8px;
    padding: 8px;
    min-height: calc(100vh - 70px);
    min-height: calc(100dvh - 70px);
  }
}
