:root {
  --bg: #0b1118;
  --panel: #111a24;
  --panel-2: #0f1721;
  --line: #263545;
  --line-soft: #1b2835;
  --text: #e7edf4;
  --muted: #8c9bab;
  --red: #e23b3b;
  --red-soft: #351a1e;
  --green: #12a06a;
  --green-soft: #123025;
  --yellow: #d7a642;
  --blue: #3f8cff;
  --input: #0a121b;
}

* {
  box-sizing: border-box;
}

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

body {
  color: var(--text);
  background: var(--bg);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.terminal {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.terminal-top {
  min-height: 64px;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: 320px minmax(420px, 1fr) 250px;
  gap: 14px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: #0c141d;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  object-fit: contain;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: #ffffff;
}

.brand strong,
.brand span,
.quote-name span,
.quote-name small,
.quote-cell span,
.mini-stats span,
.account-main span,
.account-main small,
.field span,
.auto-row span,
.strategy-grid span,
.clock-box span,
.clock-box strong {
  display: block;
}

.brand strong {
  font-size: 18px;
  line-height: 1.25;
}

.brand span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.stock-search {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(140px, 170px) 84px;
  gap: 10px;
  align-items: end;
}

.stock-search label,
.field,
.params-grid label {
  display: grid;
  gap: 5px;
}

.stock-search label span,
.field span,
.params-grid label span {
  color: var(--muted);
  font-size: 12px;
}

input,
select {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--text);
  background: var(--input);
  outline: none;
}

select option {
  color: #111827;
  background: #ffffff;
}

#tradeDate {
  color: #f8fafc;
  background: #101b26;
}

#tradeDate option {
  color: #111827;
  background: #ffffff;
}

input:focus,
select:focus {
  border-color: var(--blue);
}

.clock-box {
  display: grid;
  justify-items: end;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.clock-box strong {
  color: #b9c7d8;
  font-weight: 600;
}

.btn,
.quick-row button,
.tab {
  min-height: 34px;
  border-radius: 3px;
  color: var(--text);
  background: #1b2a39;
  cursor: pointer;
  font-weight: 700;
}

.btn:hover,
.quick-row button:hover,
.tab:hover {
  filter: brightness(1.1);
}

.btn:disabled,
button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.primary {
  background: var(--blue);
}

.quote-strip {
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) minmax(150px, 0.8fr) repeat(5, minmax(90px, 0.55fr));
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.quote-name,
.quote-price,
.quote-cell {
  min-height: 72px;
  padding: 10px 14px;
  border-right: 1px solid var(--line-soft);
  display: grid;
  align-content: center;
  gap: 4px;
}

.quote-name span,
.quote-name small,
.quote-cell span {
  color: var(--muted);
  font-size: 12px;
}

.quote-name strong {
  font-size: 20px;
}

.quote-price strong {
  font-size: 34px;
  line-height: 1;
}

.quote-price span {
  font-size: 14px;
}

.quote-cell strong {
  font-size: 16px;
}

.signal-cell strong {
  color: var(--yellow);
}

.terminal-grid {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  grid-template-rows: minmax(440px, 1fr) 240px;
  gap: 1px;
  background: var(--line);
}

.market-panel,
.trade-panel,
.bottom-panel {
  min-width: 0;
  min-height: 0;
  background: var(--panel);
}

.market-panel {
  padding: 12px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h1,
.panel-head h2,
.panel-head p {
  margin: 0;
}

.panel-head h1 {
  font-size: 18px;
}

.panel-head h2 {
  font-size: 15px;
}

.panel-head p,
.panel-head span {
  color: var(--muted);
  font-size: 12px;
}

.market-head {
  margin-bottom: 10px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.chart-legend span {
  height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-candle {
  width: 10px;
  height: 17px;
  display: inline-block;
  border-radius: 2px;
}

.up-candle {
  background: var(--red);
}

.down-candle {
  background: var(--green);
}

.legend-line {
  width: 24px;
  height: 3px;
  border-radius: 99px;
  display: inline-block;
  background: var(--blue);
}

.legend-badge {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 2px;
  color: #fff;
  font-style: normal;
  font-size: 12px;
  font-weight: 900;
}

.buy-badge {
  background: var(--red);
}

.sell-badge {
  background: var(--green);
}

canvas {
  width: 100%;
  height: 100%;
  min-height: 420px;
  display: block;
  border: 1px solid var(--line);
  background: #090f16;
}

.trade-panel {
  padding: 10px;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  gap: 10px;
  overflow: auto;
}

.trade-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #0c141d;
}

.decision-line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.decision-line strong {
  font-size: 17px;
  line-height: 1.35;
}

.decision-card p {
  margin: 10px 0 0;
  color: #b4c0cc;
  font-size: 13px;
  line-height: 1.55;
}

.decision-badge {
  min-width: 58px;
  padding: 7px 9px;
  border-radius: 3px;
  text-align: center;
  color: #fff;
  font-weight: 900;
}

.decision-badge.buy,
.decision-badge.hold {
  background: var(--red);
}

.decision-badge.sell {
  background: var(--green);
}

.decision-badge.wait,
.decision-badge.watch {
  background: var(--yellow);
  color: #111827;
}

.mini-stats,
.account-main,
.strategy-grid {
  display: grid;
  gap: 8px;
}

.mini-stats {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 12px;
}

.mini-stats div,
.account-main div,
.strategy-grid div {
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  background: #09111a;
}

.mini-stats span,
.account-main span,
.account-main small,
.strategy-grid span {
  color: var(--muted);
  font-size: 12px;
}

.mini-stats strong,
.account-main strong,
.strategy-grid strong {
  display: block;
  margin-top: 5px;
  font-size: 15px;
}

.compact {
  margin-bottom: 10px;
  align-items: center;
}

.account-main {
  grid-template-columns: repeat(2, 1fr);
}

.account-main div:first-child {
  grid-column: 1 / -1;
}

.account-main div:first-child strong {
  font-size: 26px;
}

.quick-row {
  margin: 9px 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.date-grid {
  margin-top: 9px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.quick-row button {
  min-height: 30px;
  color: #cbd8e6;
  font-size: 12px;
}

.order-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.buy {
  background: var(--red);
}

.sell {
  background: var(--green);
}

.strategy {
  width: 100%;
  margin-top: 8px;
  color: #111827;
  background: var(--yellow);
}

.reset {
  width: 100%;
  margin-top: 8px;
  background: #37495d;
}

.auto-row {
  height: 34px;
  margin-top: 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.switch input {
  display: none;
}

.switch i {
  width: 42px;
  height: 22px;
  display: block;
  position: relative;
  border-radius: 99px;
  background: #384858;
}

.switch i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s ease;
}

.switch input:checked + i {
  background: var(--blue);
}

.switch input:checked + i::after {
  transform: translateX(20px);
}

.bottom-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-rows: 42px minmax(0, 1fr);
}

.tabs {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: #0c141d;
}

.tab {
  min-width: 86px;
  height: 42px;
  border-radius: 0;
  border-right: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
}

.tab.active {
  color: var(--text);
  background: #162231;
}

.tab-page {
  min-height: 0;
  display: none;
  overflow: auto;
  padding: 10px;
}

.tab-page.active {
  display: block;
}

.positions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.position-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #0c141d;
}

.position-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.position-title strong {
  font-size: 16px;
}

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

.position-row {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.position-row strong {
  display: block;
  margin-top: 4px;
}

.empty {
  padding: 18px;
  border: 1px dashed var(--line);
  color: var(--muted);
  background: #0c141d;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  position: sticky;
  top: 0;
  color: var(--muted);
  background: #101a25;
  z-index: 1;
}

.tag {
  display: inline-block;
  min-width: 42px;
  padding: 3px 6px;
  border-radius: 3px;
  color: #fff;
  text-align: center;
  font-weight: 900;
}

.tag.buy {
  background: var(--red);
}

.tag.sell {
  background: var(--green);
}

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

.section-title {
  margin: 2px 0 8px;
  color: #d8e6f4;
  font-size: 14px;
  font-weight: 800;
}

.section-title + .strategy-grid {
  margin-bottom: 14px;
}

.account-sync-grid div {
  border-color: #28405a;
  background: #0e1a26;
}

.rule-grid {
  margin-bottom: 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.rule-grid div {
  padding: 10px;
  border: 1px solid #33485f;
  border-radius: 4px;
  background: #0c141d;
}

.rule-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.rule-grid strong {
  display: block;
  margin-top: 6px;
  color: #d8e6f4;
  font-size: 13px;
  line-height: 1.55;
  white-space: normal;
}

.params-box {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #0c141d;
}

.params-box summary {
  padding: 10px;
  cursor: pointer;
  color: #c6d4e3;
  font-weight: 700;
}

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

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

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

.ai {
  width: 110px;
  background: var(--blue);
}

.ai-text {
  min-height: 128px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: #cdd8e4;
  background: #0c141d;
  line-height: 1.7;
  white-space: pre-wrap;
}

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

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

.neutral {
  color: var(--yellow);
}

@media (max-width: 1180px) {
  .terminal-top {
    grid-template-columns: 1fr;
  }

  .stock-search {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 92px;
  }

  .clock-box {
    justify-items: start;
  }

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

  .terminal-grid {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(430px, 60vh) auto 260px;
  }

  .trade-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto;
  }
}

@media (max-width: 720px) {
  .terminal-top,
  .market-panel,
  .trade-panel {
    padding: 10px;
  }

  .trade-panel,
  .mini-stats,
  .account-main,
  .strategy-grid,
  .rule-grid,
  .date-grid,
  .params-grid {
    grid-template-columns: 1fr;
  }

  .stock-search {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 76px;
    gap: 8px;
  }

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

  .quote-name {
    grid-column: span 2;
  }

  .quote-name,
  .quote-price,
  .quote-cell {
    min-height: 56px;
    padding: 8px 10px;
  }

  .quote-name strong {
    font-size: 17px;
  }

  .quote-price strong {
    font-size: 28px;
  }

  .chart-legend {
    justify-content: flex-start;
  }

  .terminal-grid {
    grid-template-rows: 480px auto 320px;
  }

  .position-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 460px) {
  .stock-search {
    grid-template-columns: 1fr;
  }

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

  .quote-name,
  .quote-price {
    grid-column: 1 / -1;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    min-width: 0;
    flex: 1;
    padding: 0 4px;
    font-size: 12px;
  }
}
