:root {
  --bg: #101214;
  --panel: #171a1d;
  --panel-border: #2a2f34;
  --text: #f2f1ec;
  --muted: #9aa0a6;
  --accent: #29d3a0;
  --accent-2: #f4c542;
  --danger: #ee5c5c;
  --shadow: 0 16px 44px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", "PingFang SC", "Helvetica Neue", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #111315 0%, #191713 100%);
}

[hidden] {
  display: none !important;
}

.shell {
  width: min(1160px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.auth-shell {
  width: min(1080px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 56px 0;
}

.auth-layout {
  display: grid;
  grid-template-columns: 1.1fr minmax(340px, 420px);
  gap: 24px;
  align-items: stretch;
}

.auth-hero {
  position: relative;
  overflow: hidden;
  padding: 36px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background:
    radial-gradient(circle at top right, rgba(41, 211, 160, 0.18), transparent 28%),
    radial-gradient(circle at bottom left, rgba(244, 197, 66, 0.16), transparent 24%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  box-shadow: var(--shadow);
}

.auth-card {
  min-height: 100%;
}

.auth-login-card {
  padding: 28px;
  border-radius: 18px;
}

.auth-copy {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.6;
}

.auth-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.auth-pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 13px;
}

.auth-links {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.auth-hint {
  color: var(--muted);
  font-size: 13px;
}

.text-trigger {
  padding: 0;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-trigger:hover {
  color: var(--text);
  transform: none;
}

.auth-status {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  line-height: 1.6;
}

.auth-status.is-pending {
  color: var(--accent-2);
  border-color: rgba(244, 197, 66, 0.45);
  background: rgba(244, 197, 66, 0.08);
}

.auth-status.is-success {
  color: var(--accent);
  border-color: rgba(41, 211, 160, 0.45);
  background: rgba(41, 211, 160, 0.08);
}

.auth-status.is-danger {
  color: var(--danger);
  border-color: rgba(238, 92, 92, 0.45);
  background: rgba(238, 92, 92, 0.08);
}

.api-bound-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid rgba(41, 211, 160, 0.24);
  border-radius: 12px;
  background: rgba(41, 211, 160, 0.08);
}

.api-bound-card strong {
  font-size: 18px;
}

.api-bound-card .connection-copy {
  margin: 0;
}

.register-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.64);
}

.register-modal[hidden] {
  display: none;
}

.register-card {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  background:
    radial-gradient(circle at top right, rgba(41, 211, 160, 0.14), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02)),
    var(--panel);
  box-shadow: var(--shadow);
}

.hero,
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  margin-bottom: 20px;
}

.hero-side {
  display: grid;
  justify-items: end;
  gap: 12px;
}

.account-card {
  min-width: 220px;
  padding: 16px 18px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.account-card span,
.account-card small {
  color: var(--muted);
}

.account-card strong,
.account-card small {
  display: block;
  margin-top: 6px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 38px;
  line-height: 1.05;
}

.subtitle {
  margin-top: 12px;
  max-width: 720px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.hero-status {
  min-width: 180px;
  align-self: flex-start;
  text-align: center;
  padding: 16px 20px;
  border-radius: 8px;
  background: rgba(154, 160, 166, 0.12);
  color: var(--muted);
  font-weight: 700;
}

.hero-status.is-hot {
  background: rgba(0, 194, 168, 0.16);
  color: #86ffe6;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
}

.chip.is-online {
  border-color: rgba(41, 211, 160, 0.5);
  color: var(--accent);
}

.grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 20px;
}

.simple-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 20px;
  align-items: start;
}

.top-overview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
}

.balance-top-panel {
  padding-bottom: 18px;
}

.compact-strip {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.market-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 0;
}

.top-overview .market-strip {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-self: stretch;
}

.fold-stack {
  display: grid;
  gap: 16px;
  margin-top: 4px;
}

.fold-panel {
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: var(--shadow);
}

.fold-panel > summary {
  cursor: pointer;
  list-style: none;
  padding: 16px 18px;
  color: var(--text);
  font-weight: 700;
}

.fold-panel > summary::-webkit-details-marker {
  display: none;
}

.fold-panel > summary::after {
  content: "展开";
  float: right;
  color: var(--muted);
  font-weight: 400;
}

.fold-panel[open] > summary::after {
  content: "收起";
}

.fold-body {
  padding: 0 16px 16px;
}

.flat-panel {
  box-shadow: none;
  border-radius: 10px;
}

.income-tile {
  background: linear-gradient(180deg, rgba(41, 211, 160, 0.12) 0%, rgba(255, 255, 255, 0.04) 100%);
}

.price-tile {
  padding: 18px;
  background: #171a1d;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}

.price-tile span,
.pnl-card span,
.pnl-card small {
  color: var(--muted);
}

.price-tile strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  color: var(--text);
}

.price-tile.total strong {
  color: var(--accent);
}

.lower {
  margin-top: 20px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  padding: 24px;
}

.pnl-panel {
  margin-top: 20px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.signal-number {
  margin-top: 24px;
  font-size: 72px;
  font-weight: 700;
  letter-spacing: 0;
}

.signal-copy {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.6;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 24px;
}

.trade-legs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.compact-legs {
  margin-top: 14px;
}

.compact-kpis {
  margin-top: 14px;
}

.mini-signal {
  margin-top: 12px;
}

.mini-signal strong {
  display: block;
  font-size: 44px;
  line-height: 1;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.pnl-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.pnl-card {
  min-height: 132px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.pnl-card strong {
  display: block;
  margin-top: 10px;
  font-size: 30px;
  color: var(--text);
}

.pnl-card small {
  display: block;
  margin-top: 10px;
  line-height: 1.5;
}

.total-card {
  background: rgba(41, 211, 160, 0.07);
}

.is-profit {
  color: var(--accent) !important;
}

.is-loss {
  color: var(--danger) !important;
}

.kpi,
.trade-legs div {
  padding: 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.kpi span,
.trade-legs span,
label,
.notes {
  color: var(--muted);
}

.kpi strong,
.trade-legs strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: 20px;
}

.action-status {
  margin: 16px 0 12px;
  padding: 12px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  line-height: 1.5;
}

.action-status.is-pending {
  color: var(--accent-2);
  border-color: rgba(244, 197, 66, 0.45);
  background: rgba(244, 197, 66, 0.08);
}

.action-status.is-success {
  color: var(--accent);
  border-color: rgba(41, 211, 160, 0.45);
  background: rgba(41, 211, 160, 0.08);
}

.action-status.is-muted {
  color: #d6d0c3;
}

.action-status.is-danger {
  color: var(--danger);
  border-color: rgba(238, 92, 92, 0.45);
  background: rgba(238, 92, 92, 0.08);
}

.mode-warning {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid rgba(244, 197, 66, 0.45);
  background: rgba(244, 197, 66, 0.08);
  color: #f6d77a;
  line-height: 1.5;
}

.mode-warning.is-danger {
  border-color: rgba(238, 92, 92, 0.45);
  background: rgba(238, 92, 92, 0.08);
  color: var(--danger);
}

.mode-warning.is-live {
  border-color: rgba(41, 211, 160, 0.45);
  background: rgba(41, 211, 160, 0.08);
  color: var(--accent);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  cursor: pointer;
  transition: transform 180ms ease, opacity 180ms ease;
}

button:hover {
  transform: translateY(-1px);
}

.primary {
  margin-top: 18px;
  width: 100%;
  background: var(--accent);
  color: #04111c;
  font-weight: 700;
}

.compact {
  margin-top: 0;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.danger {
  margin-top: 10px;
  width: 100%;
  background: rgba(238, 92, 92, 0.16);
  color: #ff9b9b;
  border: 1px solid rgba(238, 92, 92, 0.28);
  font-weight: 700;
}

.live {
  margin-top: 10px;
  width: 100%;
  background: #f4c542;
  color: #1b1200;
  font-weight: 800;
  box-shadow: 0 10px 26px rgba(244, 197, 66, 0.18);
}

.ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.logbox {
  margin: 16px 0 0;
  min-height: 160px;
  padding: 14px;
  border-radius: 8px;
  overflow: auto;
  background: #050c17;
  color: #9fe7d8;
  font-size: 12px;
}

form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 14px;
}

input[type="number"],
input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.connection-copy {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.balance-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.balance-card {
  padding: 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.balance-card span,
.balance-card small,
.balance-empty,
.balance-asset small {
  color: var(--muted);
}

.balance-card strong,
.balance-asset strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
}

.balance-assets {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.balance-asset,
.balance-empty {
  padding: 14px 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.balance-empty {
  line-height: 1.5;
}

.positions-panel {
  margin-bottom: 20px;
}

.positions-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.position-card,
.position-empty {
  padding: 14px 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.position-card {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.position-card strong,
.position-card small {
  display: block;
}

.position-card small,
.position-empty {
  color: var(--muted);
  line-height: 1.5;
}

.position-card .is-profit {
  color: var(--accent) !important;
}

.position-card .is-loss {
  color: var(--danger) !important;
}

.wide-note {
  grid-column: 1 / -1;
}

.switch {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
}

.notes {
  padding-left: 18px;
  line-height: 1.8;
}

.advanced {
  margin-top: 0;
}

.advanced summary {
  cursor: pointer;
  list-style: none;
  padding: 16px 18px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-weight: 700;
}

.advanced summary::-webkit-details-marker {
  display: none;
}

.advanced summary::after {
  content: "展开";
  float: right;
  color: var(--muted);
  font-weight: 400;
}

.advanced[open] summary::after {
  content: "收起";
}

.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.64);
}

.confirm-modal[hidden] {
  display: none;
}

.confirm-card {
  width: min(520px, 100%);
  padding: 26px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: #171a1d;
  box-shadow: var(--shadow);
}

.confirm-summary {
  margin-top: 14px;
  color: var(--text);
  line-height: 1.7;
}

.confirm-risk {
  margin-top: 16px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid rgba(244, 197, 66, 0.45);
  background: rgba(244, 197, 66, 0.08);
  color: #f6d77a;
  line-height: 1.6;
}

.confirm-risk.is-live {
  border-color: rgba(238, 92, 92, 0.55);
  background: rgba(238, 92, 92, 0.12);
  color: #ff9b9b;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

@media (max-width: 900px) {
  .auth-layout,
  .top-overview,
  .hero,
  .grid,
  .simple-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .action-row,
  .compact-strip {
    grid-template-columns: 1fr;
  }

  .hero-side {
    justify-items: stretch;
  }

  .kpis,
  .trade-legs,
  .market-strip,
  .pnl-grid,
  .position-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .auth-shell,
  .hero {
    padding: 20px;
  }

  h1 {
    font-size: 30px;
  }

  .signal-number {
    font-size: 52px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}
