:root {
  --bg: #080b0f;
  --panel: #131922;
  --panel-2: #181f2a;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f5f7fa;
  --muted: #9aa4b2;
  --gold: #f0b90b;
  --gold-2: #fcd535;
  --green: #0ecb81;
  --red: #f6465d;
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: linear-gradient(180deg, #080b0f 0%, #101722 100%);
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.auto-shell {
  width: min(1440px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 10px 0 28px;
}

.auto-topbar {
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  border: 1px solid rgba(240, 185, 11, 0.18);
  border-radius: 8px;
  background: rgba(19, 25, 34, 0.94);
}

.auto-brand {
  min-width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.auto-brand span {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  color: #0b0e11;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  font-weight: 900;
}

.auto-brand strong {
  font-size: 16px;
}

.connection-pill {
  min-width: 74px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-size: 13px;
  font-weight: 800;
}

.connection-pill.online {
  color: #06130d;
  border-color: transparent;
  background: var(--green);
}

.connection-pill.error {
  color: #fff;
  border-color: transparent;
  background: var(--red);
}

.market-band {
  display: grid;
  grid-template-columns: minmax(230px, 0.5fr) minmax(500px, 1fr) minmax(220px, 0.38fr);
  gap: 12px;
  align-items: stretch;
  margin-top: 12px;
}

.pair-title,
.price-board,
.panel,
.control-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(19, 25, 34, 0.84);
}

.pair-title {
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 16px 18px;
}

.pair-title span,
.panel-head span,
.summary-grid span,
fieldset legend {
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

.pair-title h1,
.panel-head h2 {
  margin: 0;
  line-height: 1.05;
}

.pair-title h1 {
  font-size: clamp(24px, 3.2vw, 42px);
}

.pair-title small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.price-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.price-board article,
.summary-grid article {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-right: 1px solid var(--line);
}

.price-board article:last-child,
.summary-grid article:last-child {
  border-right: 0;
}

.price-board span,
.summary-grid span {
  color: var(--muted);
  letter-spacing: 0;
}

.price-board strong {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: clamp(17px, 2vw, 28px);
}

.up {
  color: var(--green);
}

.down {
  color: var(--red);
}

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

.panel {
  min-width: 0;
  padding: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin-top: 4px;
  font-size: 19px;
}

.interval-tabs,
.quick-buttons,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.interval-tabs button,
.ghost-button,
.quick-buttons button,
.secondary-button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.interval-tabs button.active,
.interval-tabs button:hover,
.ghost-button:hover,
.quick-buttons button:hover {
  color: #0b0e11;
  border-color: transparent;
  background: var(--gold-2);
}

.order-table {
  display: grid;
  gap: 6px;
  overflow-x: auto;
}

.order-row {
  min-width: 1080px;
  display: grid;
  grid-template-columns: 150px 150px 130px 140px 132px 74px 150px minmax(130px, 1fr);
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.order-header {
  min-height: 34px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
  font-weight: 900;
}

.trailing-help {
  min-width: 1080px;
  padding: 8px 10px;
  border: 1px solid rgba(252, 213, 53, 0.18);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(252, 213, 53, 0.055);
  font-size: 13px;
  line-height: 1.4;
}

.order-row strong {
  color: var(--text);
  font-size: 14px;
}

.order-row em {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
}

.order-row em .status-main {
  color: inherit;
  font-size: 13px;
}

.order-row em .status-sub {
  color: var(--muted);
  font-weight: 700;
}

.order-row.is-running {
  border-color: rgba(14, 203, 129, 0.36);
  background: rgba(14, 203, 129, 0.08);
}

.order-row.is-running em {
  color: var(--green);
}

.order-row.is-pending {
  border-color: rgba(252, 213, 53, 0.34);
  background: rgba(252, 213, 53, 0.06);
}

.order-row.is-pending em {
  color: var(--gold-2);
}

.order-row.is-market em {
  color: var(--green);
}

.order-row.is-error {
  border-color: rgba(246, 70, 93, 0.42);
  background: rgba(246, 70, 93, 0.08);
}

.order-row.is-error em {
  color: var(--red);
}

.order-row.is-uncertain {
  border-color: rgba(252, 213, 53, 0.5);
  background: rgba(252, 213, 53, 0.1);
}

.order-row.is-uncertain em {
  color: var(--gold-2);
}

.order-row.is-stopped em {
  color: var(--muted);
}

input {
  width: 100%;
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  padding: 0 12px;
  color: var(--text);
  background: #0b0f15;
  outline: none;
}

input:focus {
  border-color: rgba(252, 213, 53, 0.76);
  box-shadow: 0 0 0 3px rgba(252, 213, 53, 0.12);
}

.mini-check {
  display: inline-grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.mini-check input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  accent-color: var(--gold);
}

.leverage-pill {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(252, 213, 53, 0.2);
  border-radius: 7px;
  color: var(--gold-2);
  background: rgba(252, 213, 53, 0.08);
  font-size: 13px;
}

.stop-cell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 6px;
  align-items: center;
}

.stop-cell button {
  min-height: 36px;
  border: 1px solid rgba(252, 213, 53, 0.24);
  border-radius: 7px;
  color: #0b0e11;
  background: var(--gold-2);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.row-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.primary-button,
.danger-button,
.secondary-button {
  min-height: 36px;
  border-radius: 7px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 900;
}

.primary-button {
  border: 0;
  color: #0b0e11;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
}

.danger-button {
  border: 0;
  color: #ffffff;
  background: var(--red);
}

.summary-panel {
  margin-top: 0;
}

.summary-panel .panel-head strong {
  color: var(--gold-2);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.025);
}

.summary-grid strong {
  font-size: 14px;
  line-height: 1.45;
}

.risk-note {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.control-card {
  display: grid;
  align-content: center;
  gap: 10px;
  padding: 12px;
}

.run-state {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.run-state span,
.account-strip span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.run-state strong {
  color: var(--gold-2);
}

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

.full-button {
  width: 100%;
}

.account-strip {
  display: grid;
  grid-template-columns: 0.7fr repeat(4, 1fr);
  gap: 0;
  margin-top: 12px;
  padding: 0;
  overflow: hidden;
}

.account-strip article {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-right: 1px solid var(--line);
}

.account-strip article:last-child {
  border-right: 0;
}

.account-strip strong {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 15px;
}

.bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.55fr);
  gap: 12px;
  margin-top: 12px;
}

.trade-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 10px 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.trade-section-head:first-of-type {
  margin-top: 0;
}

.trade-section-head strong {
  color: var(--gold-2);
  font-family: "JetBrains Mono", Consolas, monospace;
}

.position-list,
.open-order-list {
  display: grid;
  gap: 8px;
}

.position-card,
.open-order-card,
.empty-position {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.position-card.is-long,
.open-order-card.is-long {
  border-color: rgba(14, 203, 129, 0.38);
  background: rgba(14, 203, 129, 0.075);
}

.position-card.is-short,
.open-order-card.is-short {
  border-color: rgba(246, 70, 93, 0.42);
  background: rgba(246, 70, 93, 0.075);
}

.position-card header,
.open-order-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.position-card header strong,
.open-order-card header strong {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
}

.position-card header span,
.open-order-card header span,
.empty-position {
  color: var(--muted);
  font-size: 13px;
}

.side-badge {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  white-space: nowrap;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;
}

.is-long .side-badge {
  color: #04130b;
  background: var(--green);
}

.is-short .side-badge {
  color: #ffffff;
  background: var(--red);
}

.side-word {
  font-weight: 1000;
}

.side-word-long {
  color: #0ecb81;
}

.side-word-short {
  color: #ff4d63;
}

.is-long .side-badge .side-word-long {
  color: #042016;
}

.is-short .side-badge .side-word-short {
  color: #ffffff;
}

.position-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.position-metrics div {
  display: grid;
  gap: 4px;
}

.position-metrics span {
  color: var(--muted);
  font-size: 12px;
}

.position-metrics b {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 13px;
}

@media (max-width: 980px) {
  .market-band,
  .workspace-grid,
  .bottom-grid {
    grid-template-columns: 1fr;
  }

  .price-board,
  .summary-grid,
  .account-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .price-board article:nth-child(2),
  .account-strip article:nth-child(2),
  .account-strip article:nth-child(4),
  .summary-grid article:nth-child(2),
  .summary-grid article:nth-child(4),
  .summary-grid article:nth-child(6) {
    border-right: 0;
  }
}

@media (max-width: 620px) {
  .auto-shell {
    width: min(100vw, calc(100vw - 20px));
  }

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

  .auto-brand {
    justify-content: center;
  }

  .market-band,
  .workspace-grid {
    gap: 12px;
  }

  .pair-title,
  .panel {
    padding: 14px;
  }

  .price-board,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .price-board article,
  .summary-grid article {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .price-board article:last-child,
  .summary-grid article:last-child {
    border-bottom: 0;
  }

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

  .ghost-button {
    width: 100%;
  }
}
