:root {
  --bg: #0b0e11;
  --bg-elev: #12161c;
  --bg-panel: #151a21;
  --line: #1e2630;
  --text: #eaecef;
  --muted: #848e9c;
  --accent: #f0b90b;
  --up: #0ecb81;
  --down: #f6465d;
  --input: #0f141a;
  --danger: #f6465d;
  font-family: "IBM Plex Sans", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(240, 185, 11, 0.08), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(14, 203, 129, 0.05), transparent 50%),
    var(--bg);
}

/*
 * 手机横屏兜底：JS 会写 #root 行内样式；此处仅约束 html/body。
 * 安卓 Chrome 普通页需「全屏 + orientation.lock」才能系统级锁竖屏。
 */
html.phone-portrait-lock.phone-landscape,
html.phone-portrait-lock.phone-landscape body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

html.phone-portrait-lock.phone-landscape body {
  position: fixed;
  inset: 0;
}

.portrait-lock-hint {
  position: fixed;
  left: 50%;
  bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 10000;
  margin: 0;
  padding: 10px 16px;
  border: 1px solid rgba(240, 185, 11, 0.45);
  border-radius: 999px;
  background: rgba(11, 14, 17, 0.92);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

button,
input {
  font: inherit;
}

.mono {
  font-family: "IBM Plex Mono", monospace;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr;
}

/* 与 crypto_monitor .container 同口径：标题 / 导航 / 资金卡 / 内容同宽 */
.app-container {
  width: 100%;
  max-width: min(1440px, 94vw);
  margin: 0 auto;
  padding: 0 clamp(8px, 1.5vw, 20px) 28px;
  box-sizing: border-box;
}

.app-header-block {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 14px 0 8px;
  /* 不 sticky：透明背景吸顶时会与下方资金条文字重叠 */
  position: relative;
  z-index: 1;
  background: transparent;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
  white-space: nowrap;
  min-width: 0;
  font-size: clamp(16px, 1.35vw, 20px);
  background: transparent;
}

.brand-machine {
  margin-left: 0.15em;
  font-weight: 700;
  color: var(--accent);
}

.brand-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.brand-actions .meta {
  color: var(--muted);
  font-size: 12px;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  background: transparent;
}

.top-nav a {
  padding: 8px 12px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.top-nav a:hover {
  color: var(--text);
  background: transparent;
}

.top-nav a.active {
  background: transparent;
  border: none;
  color: var(--accent);
}

.funds-bar-shell {
  border: none;
  background: transparent;
  margin: 0 0 12px;
}

@media (max-width: 900px) {
  .funds-bar-shell {
    display: none;
  }
}

.funds-bar-inner {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 10px 14px;
  box-sizing: border-box;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.funds-bar {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  padding: 4px 0 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  align-items: stretch;
  min-height: 56px;
}

.funds-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  min-width: 72px;
  padding: 4px 8px;
  border-right: 1px solid var(--line);
  text-align: center;
}

.funds-item:first-child {
  padding-left: 4px;
}

.funds-item:last-child {
  border-right: none;
  padding-right: 4px;
}

.funds-item--primary .funds-value {
  color: var(--accent);
  font-size: 1.02rem;
  font-weight: 700;
}

.funds-label {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.2;
  margin-bottom: 6px;
  white-space: nowrap;
}

.funds-value {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  color: var(--text);
}

.funds-dual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.funds-value--sub {
  font-size: 0.95rem;
  font-weight: 600;
}

.funds-item--pnl .funds-value {
  font-variant-numeric: tabular-nums;
}

.funds-rules {
  padding: 6px 0 0;
  border-top: 1px solid rgba(30, 38, 48, 0.85);
  margin-top: 6px;
}

.funds-rules-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.funds-rules-toggle:hover {
  color: var(--text);
}

.funds-rules-chevron {
  font-size: 11px;
  opacity: 0.85;
}

.funds-rules-body {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.plan-rules-fold {
  margin: 0 0 10px;
}

.plan-rules-fold details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-panel);
  padding: 8px 12px;
}

.plan-rules-fold summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  user-select: none;
}

.plan-rules-fold summary:hover {
  color: var(--text);
}

.plan-rules-body {
  margin: 8px 0 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}

.plan-rules-body p {
  margin: 0 0 4px;
}

.plan-rules-body p:last-child {
  margin-bottom: 0;
}

.plan-rules-k {
  display: inline-block;
  min-width: 2.2em;
  margin-right: 6px;
  color: var(--text);
  font-weight: 600;
  opacity: 0.85;
}

.open-cap-row {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 14px;
}

.open-cap-sep {
  color: var(--muted);
  font-weight: 500;
}

.open-cap-ok {
  color: #0ecb81;
}

.open-cap-bad {
  color: #f6465d;
}

.topnav {
  display: none;
}

.brand-mark,
.login-brand-mark {
  flex-shrink: 0;
  border-radius: 6px;
  object-fit: cover;
  background: #1a1a1a;
}

.login-brand-mark {
  border-radius: 10px;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0;
}

.tab {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.status-running {
  color: #0ecb81 !important;
  font-weight: 700;
}

.status-stopped {
  color: var(--muted) !important;
}

.topnav .spacer {
  flex: 1;
}

.topnav .meta {
  color: var(--muted);
  font-size: 12px;
  margin-right: 8px;
}

.page {
  padding: 4px 0 0;
  max-width: none;
  margin: 0;
  width: 100%;
}

.brand-short {
  display: none;
}

.nav-label-short {
  display: none;
}

.bottom-nav {
  display: none;
}

.plan-mobile-hero {
  display: none;
}

.plan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

@media (max-width: 900px) {
  .app-container {
    padding: 0 12px calc(72px + env(safe-area-inset-bottom, 0px));
  }

  .app-header-block {
    padding-top: 10px;
  }

  .brand-full {
    display: none;
  }

  .brand-short {
    display: inline;
  }

  .top-nav {
    display: none;
  }

  .nav-label-full {
    display: none;
  }

  .nav-label-short {
    display: inline;
  }

  .page {
    padding: 4px 0 0;
  }

  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    border-top: 1px solid var(--line);
    background: rgba(11, 14, 17, 0.96);
    backdrop-filter: blur(10px);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    text-decoration: none;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
  }

  .bottom-nav-item.active {
    color: var(--accent);
    background: rgba(240, 185, 11, 0.08);
  }

  .plan-desktop-head {
    display: none;
  }

  .plan-mobile-hero {
    display: block;
    margin: 0 0 12px;
    padding: 14px 14px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background:
      linear-gradient(160deg, rgba(240, 185, 11, 0.08), transparent 55%),
      var(--bg-panel);
  }

  .plan-mobile-hero-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
  }

  .plan-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid var(--line);
  }

  .plan-pill-on {
    color: #0ecb81;
    border-color: rgba(14, 203, 129, 0.45);
    background: rgba(14, 203, 129, 0.12);
  }

  .plan-pill-off {
    color: var(--muted);
  }

  .plan-pill-pause {
    color: #f0b90b;
    border-color: rgba(240, 185, 11, 0.45);
    background: rgba(240, 185, 11, 0.12);
  }

  .plan-pill-muted {
    color: var(--muted);
    font-weight: 600;
  }

  .plan-mobile-phase {
    margin-left: auto;
    color: var(--text);
    font-size: 13px;
  }

  .plan-mobile-hero-pnl {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .plan-mobile-pnl-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  .plan-mobile-label {
    color: var(--muted);
    font-size: 12px;
  }

  .plan-mobile-pnl-num {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.02em;
  }

  .plan-mobile-countdown {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.25;
  }

  .plan-mobile-sub {
    color: var(--muted);
    font-size: 12px;
  }

  .plan-mobile-err {
    margin-top: 10px;
    font-size: 12px;
    color: var(--danger);
    line-height: 1.4;
    word-break: break-word;
  }

  .plan-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .plan-actions .btn {
    min-height: 44px;
    width: 100%;
  }

  .plan-actions .btn.danger {
    grid-column: 1 / -1;
  }

  .plan-actions .meta {
    grid-column: 1 / -1;
  }

  .topnav-user {
    max-width: 6em;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topnav-logout {
    padding: 8px 10px;
    min-height: 40px;
  }

  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }

  .tab {
    flex: 0 0 auto;
    padding: 10px 12px;
    min-height: 44px;
  }

  .settings-subtabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }

  .settings-actions .btn {
    min-height: 44px;
  }
}

.card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 800px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.kv:last-child {
  border-bottom: 0;
}

.kv > span:first-child {
  color: var(--muted);
  flex: 0 0 auto;
  min-width: 5.5em;
}

.kv > span:last-child {
  text-align: right;
  min-width: 0;
}

.kv-residuals {
  align-items: flex-start;
}

.kv-residuals > span:first-child {
  padding-top: 2px;
}

.residual-list {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  min-width: 0;
  max-width: min(100%, 28em);
}

.residual-item {
  text-align: right;
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .kv-residuals {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .residual-list {
    align-items: stretch;
    max-width: none;
  }

  .residual-item {
    text-align: left;
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
  }
}

.trade-list {
  padding-top: 4px;
  padding-bottom: 4px;
}

/* 电脑端表格；手机端保持卡片列表 */
.trade-list-desktop {
  display: none;
}

.trade-list-mobile {
  display: block;
}

.trade-table-card {
  padding: 12px 14px 10px;
  margin-bottom: 12px;
}

.trade-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.trade-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.trade-table th,
.trade-table td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  vertical-align: middle;
}

.trade-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}

.trade-table-row {
  cursor: pointer;
}

.trade-table-row:hover td {
  background: rgba(240, 185, 11, 0.06);
}

.trade-table-id {
  font-weight: 600;
}

.trade-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 0 4px;
}

.trade-pager-info {
  color: var(--muted);
  font-size: 13px;
}

@media (min-width: 901px) {
  .trade-list-desktop {
    display: block;
  }

  .trade-list-mobile {
    display: none;
  }
}

.trade-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 12px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.trade-row:last-child {
  border-bottom: 0;
}

.trade-row-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1 1 auto;
}

.trade-row-id {
  color: var(--text);
  font-weight: 600;
}

.trade-row-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  word-break: break-word;
}

.trade-row-times {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  word-break: break-word;
}

.trade-hold-note {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.trade-hold-summary {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.trade-hold-basis {
  margin-left: 6px;
  color: var(--muted);
  font-size: 12px;
}

.trade-detail-hint {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 12px;
  line-height: 1.45;
}

.trade-pnl-block {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(4px);
}

.modal-dialog {
  width: min(560px, 100%);
  max-height: min(86vh, 820px);
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

/* 策略机交易记录详情：加宽，减少换行 */
.modal-dialog.trade-detail-modal {
  width: min(920px, 100%);
  max-height: min(90vh, 960px);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-close {
  flex: 0 0 auto;
  min-height: 40px;
}

.modal-body {
  padding: 14px 16px 18px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 900px) {
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal-dialog {
    width: 100%;
    max-height: min(88vh, 900px);
    border-radius: 14px 14px 0 0;
  }

  .modal-head {
    padding: 12px 14px;
  }

  .modal-body {
    padding: 12px 14px calc(18px + env(safe-area-inset-bottom, 0px));
  }
}

.trade-row-pnl {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex: 0 1 auto;
  min-width: 6.5em;
  max-width: 46%;
  font-size: 13px;
  line-height: 1.35;
  text-align: right;
}

.trade-row-reason {
  color: var(--muted);
  word-break: break-word;
}

@media (max-width: 900px) {
  .trade-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    min-height: 44px;
  }

  .trade-row-pnl {
    align-items: flex-start;
    max-width: none;
    min-width: 0;
    text-align: left;
  }

  .trade-fill.kv {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }

  .trade-fill.kv > span:first-child {
    min-width: 0;
    color: var(--text);
  }

  .trade-fill.kv > span:last-child {
    text-align: left;
    color: var(--muted);
    font-size: 13px;
  }
}

/* 计划页：上排策略|持仓顶底对齐；下排行情同列宽对齐 */
.plan-shell {
  --plan-cols: minmax(280px, 1fr) minmax(320px, 1.15fr);
  --plan-gap: 12px;
  display: flex;
  flex-direction: column;
  gap: var(--plan-gap);
  margin-bottom: 12px;
}

.plan-board,
.plan-market {
  display: grid;
  grid-template-columns: var(--plan-cols);
  gap: var(--plan-gap);
  min-width: 0;
}

.plan-board {
  align-items: stretch;
}

.plan-panel-title {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.plan-strategy {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  box-sizing: border-box;
}

.plan-metrics {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.plan-metrics .kv {
  min-width: 0;
}

.plan-positions {
  display: flex;
  flex-direction: column;
  gap: var(--plan-gap);
  height: 100%;
  min-height: 0;
  min-width: 0;
}

.plan-positions .pos-card,
.plan-positions .pos-empty {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-sizing: border-box;
}

.pos-countdown {
  flex: 0 0 auto;
  font-size: 0.82rem;
  font-weight: 600;
  color: #e8ecf4;
  white-space: nowrap;
  margin-left: auto;
}

@media (max-width: 960px) {
  .plan-shell {
    --plan-cols: 1fr;
  }

  .plan-positions .pos-card,
  .plan-positions .pos-empty {
    flex: 0 0 auto;
  }

  /* 合约名与倒计时上下排，避免长 inst_id 被挤成竖排 */
  .pos-card-head {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .pos-card-symbol {
    width: 100%;
  }

  .pos-card-symbol strong {
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.35;
  }

  .pos-countdown {
    margin-left: 0;
    width: auto;
    align-self: flex-start;
  }
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-box {
  width: min(420px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.login-box h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.35;
}

.login-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.login-box p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
}

.login-box .err {
  margin-bottom: 14px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

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

.field input,
.field select {
  background: var(--input);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  width: 100%;
  min-height: 42px;
}

.field input:focus,
.field select:focus {
  border-color: rgba(240, 185, 11, 0.55);
}

/* Settings: 与顶栏资金卡同宽（由 .app-container 约束） */
.settings-page {
  width: 100%;
  max-width: none;
}

.settings-card {
  width: 100%;
  max-width: none;
}

.settings-card-narrow {
  max-width: none;
}

.settings-lead {
  color: var(--muted);
  margin: 0 0 16px;
  line-height: 1.5;
  font-size: 13px;
}

.settings-subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.settings-subtab {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--input);
  color: var(--muted);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

.settings-subtab:hover {
  color: var(--text);
  border-color: #2a3441;
}

.settings-subtab.active {
  color: #111;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.settings-ok {
  color: var(--up);
  margin-bottom: 12px;
}

.settings-section {
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.settings-section:last-of-type {
  border-bottom: 0;
}

.settings-section h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: none;
}

.settings-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 18px;
}

.settings-fields .field {
  margin-bottom: 12px;
}

.settings-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.settings-rules {
  margin: 4px 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input);
}

.settings-rules-toggle {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.settings-rules-toggle:hover {
  color: var(--text);
}

.settings-rules.open .settings-rules-toggle {
  color: var(--text);
  border-bottom: 1px solid var(--line);
}

.settings-rules-chevron {
  color: var(--muted);
  font-size: 12px;
}

.settings-rules-body {
  padding: 10px 12px 12px;
}

.settings-rules-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.settings-rules-list li + li {
  margin-top: 6px;
}

.settings-actions {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.backup-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.backup-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  width: 100%;
  box-sizing: border-box;
}

.backup-list-row:last-child {
  border-bottom: none;
}

.backup-list-name {
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-all;
  font-size: 13px;
  line-height: 1.4;
}

.backup-list-meta {
  color: var(--muted);
  font-weight: 400;
}

/* 电脑端：一屏最多约 5 行，超出滚动 */
@media (min-width: 901px) {
  .backup-list {
    max-height: calc(5 * 48px);
    overflow-y: auto;
  }
}

@media (min-width: 700px) {
  .settings-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .settings-fields {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.settings-xfer-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 12px 14px;
  align-items: end;
}

.settings-xfer-row .field {
  margin-bottom: 0;
  min-width: 0;
}

.settings-xfer-action {
  display: flex;
  align-items: flex-end;
  padding-bottom: 1px;
}

@media (max-width: 900px) {
  .settings-xfer-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-xfer-action {
    grid-column: 1 / -1;
  }
}

@media (max-width: 699px) {
  .settings-fields .field {
    margin-bottom: 14px;
  }

  .field input,
  .field select {
    min-height: 44px;
    font-size: 16px; /* 避免 iOS 自动缩放 */
  }
}

.btn {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--accent);
  color: #111;
  font-weight: 600;
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.btn.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn.danger:hover:not(:disabled) {
  background: rgba(246, 70, 93, 0.12);
}

.btn.btn-running,
.btn.btn-running:disabled {
  background: rgba(14, 203, 129, 0.16);
  color: #0ecb81;
  border: 1px solid #0ecb81;
  opacity: 1;
  cursor: default;
}

.btn.block {
  width: 100%;
}

.err {
  color: var(--danger);
  font-size: 13px;
  margin: 0 0 12px;
}

.hint {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.tag.up {
  color: var(--up);
  border-color: rgba(14, 203, 129, 0.35);
}

.tag.down {
  color: var(--down);
  border-color: rgba(246, 70, 93, 0.35);
}

/* OKX-style position cards (copied/adapted from crypto_monitor instance_page) */
.pos-embed-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

@media (max-width: 800px) {
  .pos-embed-grid {
    grid-template-columns: 1fr;
  }
}

.pos-card {
  background: #141923;
  border: 1px solid #2a3348;
  border-radius: 10px;
  padding: 12px 14px;
}

.pos-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.pos-card-symbol {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.pos-card-symbol strong {
  font-size: 0.95rem;
  color: #fff;
  font-weight: 600;
  word-break: break-all;
}

.pos-side-badge {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.2;
}

.pos-side-long {
  background: #253a6e;
  color: #6eb5ff;
}

.pos-side-short {
  background: #4a2230;
  color: #ff8a8a;
}

.pos-meta {
  font-size: 0.74rem;
  color: #8b95a8;
  line-height: 1.45;
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 0;
}

.pos-meta-item {
  display: inline-flex;
  align-items: center;
}

.pos-meta-item:not(:last-child)::after {
  content: "|";
  margin: 0 8px;
  color: #3d4659;
}

.pos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 14px;
}

.pos-cell-wide {
  grid-column: 1 / -1;
}

.pos-countdown-urgent {
  color: #ffb020 !important;
}

@media (max-width: 520px) {
  .pos-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1400px) {
  .pos-embed-grid {
    gap: 14px;
  }
}

.pos-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.pos-label {
  font-size: 0.72rem;
  color: #7d8799;
}

.pos-value {
  font-size: 0.88rem;
  color: #e8ecf4;
  font-weight: 500;
  line-height: 1.25;
}

.pos-empty {
  padding: 18px;
  text-align: center;
  color: #8892b0;
  font-size: 0.85rem;
  background: #141923;
  border: 1px dashed #2a3348;
  border-radius: 10px;
}

.pos-pnl-profit {
  color: #7ee787 !important;
}

.pos-pnl-loss {
  color: #ff8b8b !important;
}
