:root {
  color-scheme: dark;
  --bg: #101112;
  --bg-raised: #161819;
  --panel: #1c1f20;
  --panel-soft: #222628;
  --text: #eef2f0;
  --muted: #9aa6a1;
  --line: #303637;
  --line-strong: #465052;
  --accent: #21a67a;
  --accent-strong: #45c092;
  --amber: #d8a23a;
  --good: #31c97b;
  --bad: #f0645f;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.auth-pending .shell {
  display: none;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: var(--bg);
}

.auth-screen.is-hidden {
  display: none;
}

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  font-size: 24px;
}

.auth-message {
  min-height: 20px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.shell {
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(26px, 3.5vw, 38px);
  font-weight: 780;
}

h2 {
  font-size: 15px;
  font-weight: 760;
}

.status {
  min-width: 96px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg-raised);
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.control-button {
  width: auto;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg-raised);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.control-button.start {
  border-color: rgba(49, 201, 123, 0.55);
  color: var(--good);
}

.control-button.stop {
  border-color: rgba(216, 162, 58, 0.6);
  color: var(--amber);
}

.control-button.close-all {
  border-color: rgba(240, 100, 95, 0.65);
  color: var(--bad);
}

.control-button:hover {
  background: var(--panel-soft);
}

.control-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 14px;
  align-items: start;
}

.app-layout.news-disabled {
  grid-template-columns: minmax(0, 1fr);
}

.app-layout.news-collapsed {
  grid-template-columns: minmax(0, 1fr) 56px;
}

.workspace {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

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

.controls {
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 28px);
  overflow: auto;
  padding: 16px;
}

form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

fieldset {
  display: grid;
  gap: 11px;
  min-width: 0;
  margin: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-raised);
}

legend {
  padding: 0 6px;
  color: var(--amber);
  font-size: 12px;
  font-weight: 760;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

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

input,
select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  color: var(--text);
  font: inherit;
  background: #121414;
}

input::placeholder {
  color: #6f7b76;
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(33, 166, 122, 0.16);
}

.inline-input-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  align-items: center;
  gap: 0;
}

.inline-input-action input {
  border-radius: 7px 0 0 7px;
  border-right: 0;
}

.inline-input-action input:focus {
  position: relative;
  z-index: 1;
}

.inline-save-button {
  width: 58px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 7px 7px 0;
  background: rgba(33, 166, 122, 0.18);
  color: var(--accent-strong);
  font-size: 12px;
}

.inline-save-button:hover {
  border-color: var(--accent);
  background: rgba(33, 166, 122, 0.26);
}

button {
  height: 42px;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #06100d;
  font: inherit;
  font-weight: 820;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

.main-grid {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.divider {
  height: 1px;
  margin: 18px 0;
  background: var(--line);
}

.compact {
  margin-bottom: 2px;
}

.account-box {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  margin: 12px 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-raised);
}

.account-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.account-action-card {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121414;
}

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

.account-action-grid .secondary-button {
  width: 100%;
  min-width: 0;
  padding: 0 8px;
}

.account-action-grid .danger-button:last-child,
.account-action-grid .secondary-button:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.account-api-card {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121414;
}

.account-api-head {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.account-api-head strong {
  color: var(--accent-strong);
}

.strategy-state-card {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121414;
}

.running-strategy-list {
  grid-column: 1 / -1;
}

.strategy-state-card div {
  min-width: 0;
}

.strategy-state-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.strategy-state-card strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.strategy-tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 12px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.averaging-steps {
  display: grid;
  gap: 8px;
}

.averaging-head,
.averaging-row {
  display: grid;
  grid-template-columns: 58px 76px minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.averaging-head {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.field-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.strategy-tab {
  height: 32px;
  min-width: 0;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #121414;
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
  cursor: pointer;
  pointer-events: auto;
}

.strategy-tab:hover,
.strategy-tab.active {
  border-color: var(--accent);
  background: rgba(33, 166, 122, 0.16);
  color: var(--accent-strong);
}

.config-section-hidden {
  display: none;
}

.secondary-button {
  width: auto;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #121414;
  color: var(--text);
  font-size: 12px;
}

.secondary-button:hover {
  border-color: var(--accent);
  background: rgba(33, 166, 122, 0.14);
  color: var(--accent-strong);
}

.danger-button {
  border-color: rgba(240, 100, 95, 0.55);
  color: var(--bad);
}

.danger-button:hover {
  border-color: rgba(240, 100, 95, 0.85);
  background: rgba(240, 100, 95, 0.12);
  color: var(--bad);
}

.strategy-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  gap: 10px;
}

.rule-card {
  min-height: 180px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.rule-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.rule-card strong {
  color: var(--text);
}

.rule-line {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  margin-top: 8px;
}

.rule-line em {
  display: block;
  color: var(--muted);
  font-style: normal;
  font-size: 11px;
  line-height: 1.35;
}

.rule-line strong {
  display: block;
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(7, minmax(126px, 1fr));
  gap: 10px;
}

.metric {
  min-height: 88px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 22px;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.positive {
  color: var(--good);
}

.negative {
  color: var(--bad);
}

.warning {
  color: var(--warn);
}

.audit-message {
  display: grid;
  gap: 4px;
}

.audit-message strong {
  color: var(--text);
  font-size: 12px;
}

.audit-message span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.audit-tools {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(120px, 150px) minmax(150px, 190px) auto;
  gap: 10px;
  margin: 10px 0 12px;
}

.positions-panel {
  padding: 15px;
}

.position-list {
  display: grid;
  gap: 6px;
}

.empty-positions {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121414;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.position-card {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121414;
  overflow: hidden;
}

.position-summary {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  grid-template-columns: 16px minmax(160px, 1.35fr) repeat(5, minmax(78px, 1fr)) minmax(96px, auto);
  gap: 10px;
  align-items: center;
  width: 100%;
  height: auto;
  min-height: 54px;
  padding: 8px 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.position-summary-close {
  justify-self: end;
  min-width: 92px;
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
}

.position-summary:hover {
  background: rgba(255, 255, 255, 0.025);
}

.position-toggle {
  color: var(--muted);
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 120ms ease;
}

.position-card.is-expanded .position-toggle {
  transform: rotate(90deg);
}

.position-summary > span,
.position-kpi {
  min-width: 0;
}

.position-identity {
  display: grid;
  gap: 3px;
}

.position-identity strong {
  font-size: 14px;
  font-weight: 900;
}

.position-identity em {
  font-size: 12px;
  font-weight: 800;
  font-style: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.position-kpi small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 760;
}

.position-kpi strong {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.position-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 10px 12px 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.follow-account-list {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.follow-account-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
}

.follow-account-item input {
  width: auto;
}

.position-detail-head > div {
  min-width: 0;
}

.position-detail-head strong {
  color: var(--text);
  font-size: 13px;
}

.position-detail-head span {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.position-close-button {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.position-detail-head[hidden],
.position-grid[hidden],
.position-child-panel[hidden] {
  display: none !important;
}

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

.position-grid div {
  min-height: 62px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg-raised);
}

.position-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.position-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.position-child-panel {
  padding: 0 12px 12px;
}

.position-child-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.02);
}

.position-child-head strong {
  display: block;
  color: var(--text);
  font-size: 13px;
}

.position-child-head span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.position-child-totals {
  min-width: 220px;
  text-align: right;
}

.position-child-totals.warning strong,
.position-child-warning {
  color: var(--amber);
}

.position-child-warning,
.position-child-empty {
  margin-bottom: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg-raised);
  font-size: 12px;
  font-weight: 780;
}

.position-child-empty {
  color: var(--muted);
}

.position-child-table {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.position-child-row {
  display: grid;
  grid-template-columns: 76px minmax(150px, 1.5fr) repeat(4, minmax(88px, 1fr)) minmax(92px, auto);
  gap: 8px;
  align-items: center;
  min-height: 38px;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  background: var(--bg-raised);
  font-size: 12px;
  font-weight: 780;
}

.position-child-row:first-child {
  border-top: 0;
}

.position-child-row-head {
  min-height: 32px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 11px;
  font-weight: 860;
}

.position-child-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.position-child-close {
  height: 28px;
  padding: 0 8px;
  font-size: 11px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.chart-panel,
.table-panel {
  padding: 15px;
  min-width: 0;
}

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

.section-head h2 {
  color: var(--text);
}

.chart-title-group {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.symbol-picker-wrap {
  position: relative;
}

.symbol-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #121414;
  color: var(--text);
}

.symbol-popover {
  position: absolute;
  top: 42px;
  left: 0;
  z-index: 20;
  display: none;
  width: min(430px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.symbol-popover.open {
  display: block;
}

.symbol-popover-head {
  display: flex;
  justify-content: space-between;
  margin: 10px 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.symbol-list {
  display: grid;
  max-height: 340px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.symbol-row {
  display: grid;
  grid-template-columns: 1fr 92px 68px 82px;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  font-size: 12px;
}

.symbol-row:hover,
.symbol-row.is-selected {
  background: var(--panel-soft);
}

.live-price-card {
  display: grid;
  gap: 2px;
  min-width: 176px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #121414;
}

.live-price-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.live-price-card strong {
  color: var(--text);
  font-size: 20px;
  line-height: 1.1;
}

.live-price-card small {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.live-price-card.up strong {
  color: var(--good);
}

.live-price-card.down strong {
  color: var(--bad);
}

.chart-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
}

.tool-button {
  width: auto;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #121414;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.tool-button:hover,
.tool-button.active {
  border-color: var(--accent);
  background: rgba(33, 166, 122, 0.16);
  color: var(--accent-strong);
}

canvas {
  display: block;
  width: 100%;
  height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121414;
}

#kline-chart {
  height: 474px;
  cursor: grab;
}

#kline-chart:active {
  cursor: grabbing;
}

.table-wrap {
  overflow-x: auto;
}

.news-rail {
  position: sticky;
  top: 14px;
  height: calc(100vh - 28px);
  min-width: 0;
  padding: 15px;
  overflow: hidden;
}

.app-layout.news-disabled .news-rail {
  display: none;
}

.app-layout.news-collapsed .news-rail {
  padding: 10px;
}

.app-layout.news-collapsed .news-tabs,
.app-layout.news-collapsed .news-list,
.app-layout.news-collapsed #news-count {
  display: none;
}

.app-layout.news-collapsed .news-rail h2 {
  writing-mode: vertical-rl;
}

.news-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.news-tabs {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.news-tab {
  width: auto;
  height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #121414;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.news-tab.active {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: rgba(33, 166, 122, 0.14);
}

.news-list {
  display: grid;
  gap: 9px;
  max-height: calc(100vh - 138px);
  overflow: auto;
}

.news-item {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #121414;
  color: var(--text);
  text-decoration: none;
}

.news-item:hover {
  border-color: var(--line-strong);
  background: var(--panel-soft);
}

.news-meta,
.news-tags {
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
}

.news-title {
  color: var(--text);
  font-size: 13px;
  line-height: 1.38;
}

.news-title-cn {
  color: var(--accent-strong);
  font-size: 13px;
  line-height: 1.4;
}

.news-badge {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.news-badge.good {
  color: var(--good);
}

.news-badge.bad {
  color: var(--bad);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(0, 0, 0, 0.62);
}

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

.records-modal {
  width: min(1240px, 100%);
  max-height: min(760px, calc(100vh - 44px));
  padding: 15px;
  overflow: hidden;
}

.admin-modal {
  width: min(1060px, 100%);
  max-height: min(820px, calc(100vh - 44px));
  padding: 15px;
  overflow: auto;
}

.strategy-editor-modal {
  width: min(780px, 100%);
  max-height: min(880px, calc(100vh - 44px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 15px;
  overflow: hidden;
}

.strategy-editor-body {
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.strategy-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.strategy-editor-actions button {
  width: auto;
  min-width: 120px;
}

.admin-user-form {
  margin-top: 0;
  margin-bottom: 14px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-raised);
}

.admin-table-wrap {
  max-height: 330px;
  overflow: auto;
}

.records-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.record-stat {
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121414;
}

.record-stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.record-stat strong {
  display: block;
  margin-top: 8px;
  font-size: 18px;
}

.records-table-wrap {
  max-height: calc(100vh - 230px);
  overflow: auto;
}

details {
  max-width: 360px;
}

summary {
  cursor: pointer;
  color: var(--accent-strong);
}

pre {
  max-width: 520px;
  max-height: 260px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0d0f0f;
  color: var(--text);
  white-space: pre-wrap;
}

.market-tools {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 150px;
  gap: 8px;
  margin-bottom: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

th,
td {
  padding: 11px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 12px;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
  color: var(--muted);
  font-weight: 780;
}

td {
  color: var(--text);
}

@media (max-width: 1280px) {
  .app-layout,
  .workspace,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .news-rail {
    position: static;
    height: auto;
  }

  .controls {
    position: static;
    max-height: none;
  }

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

@media (max-width: 760px) {
  .shell {
    padding: 12px;
  }

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

  .section-head,
  .chart-title-group {
    align-items: flex-start;
    flex-direction: column;
  }

  .live-price-card {
    width: 100%;
  }

  .field-row,
  .metrics,
  .strategy-strip,
  .market-tools,
  .account-box,
  .account-actions,
  .account-action-grid,
  .account-api-card,
  .position-grid,
  .records-summary,
  .strategy-state-card {
    grid-template-columns: 1fr;
  }

  .position-summary {
    grid-template-columns: 16px minmax(0, 1fr) minmax(82px, 0.8fr) minmax(88px, auto);
  }

  .position-kpi:nth-of-type(4),
  .position-kpi:nth-of-type(5),
  .position-kpi:nth-of-type(6),
  .position-kpi:nth-of-type(7) {
    display: none;
  }

  .position-summary-close {
    min-width: 88px;
    padding: 0 8px;
    font-size: 11px;
  }

  .position-detail-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .position-child-head {
    flex-direction: column;
  }

  .position-child-totals {
    min-width: 0;
    text-align: left;
  }

  .position-child-table {
    overflow-x: auto;
  }

  .position-child-row {
    grid-template-columns: 70px minmax(140px, 1.4fr) repeat(4, minmax(82px, 1fr)) minmax(88px, auto);
    min-width: 760px;
  }

  .audit-tools {
    grid-template-columns: 1fr;
  }

  canvas,
  #kline-chart {
    height: 320px;
  }
}
