:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --ink: #17202a;
  --muted: #687385;
  --line: #d8dee7;
  --panel: #ffffff;
  --blue: #2563eb;
  --green: #059669;
  --red: #dc2626;
  --amber: #d97706;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 24px;
  background: #111827;
  color: white;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 700;
}

h2 {
  font-size: 15px;
}

.topbar p {
  margin-top: 4px;
  color: #cbd5e1;
  font-size: 13px;
}

button {
  height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  background: #f59e0b;
  color: #111827;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab {
  height: 34px;
  background: #374151;
  color: #e5e7eb;
}

.tab.active {
  background: #f59e0b;
  color: #111827;
}

.secondary {
  background: #e5e7eb;
}

.tinyBtn {
  height: 28px;
  padding: 0 10px;
  border-radius: 4px;
  font-size: 12px;
}

.linkButton {
  height: auto;
  padding: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 800;
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable::after {
  content: " ↕";
  color: var(--muted);
  font-weight: 400;
}

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  padding: 18px;
}

.panel,
.chartShell,
.tableShell,
.strategyBox,
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.controls {
  align-self: start;
  padding: 16px;
}

label {
  position: relative;
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.inlineControl {
  grid-template-columns: 18px 1fr;
  align-items: center;
  color: var(--ink);
}

.inlineControl input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.suggestions {
  position: absolute;
  z-index: 10;
  top: 58px;
  left: 0;
  right: 0;
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  box-shadow: 0 12px 32px rgba(17, 24, 39, 0.12);
}

.suggestion {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  cursor: pointer;
  color: var(--ink);
  font-size: 13px;
}

.suggestion:hover {
  background: #eef2ff;
}

.suggestion span {
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: white;
  font-size: 14px;
}

input,
select {
  height: 36px;
  padding: 0 10px;
}

textarea {
  min-height: 220px;
  resize: vertical;
  padding: 10px;
  font-family: Consolas, "Courier New", monospace;
  line-height: 1.45;
}

.workspace {
  min-width: 0;
  display: grid;
  gap: 18px;
}

.tabView {
  display: none;
  min-width: 0;
  gap: 18px;
}

.tabView.active {
  display: grid;
}

.actionBar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-start;
}

.quantToolbar {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.quantActions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.quantControls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}

.quantControls label,
.quantActions label {
  margin-bottom: 0;
}

.compactCheck {
  min-height: 42px;
  padding: 0 10px;
}

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

.riskNotice {
  padding: 12px 14px;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-size: 13px;
  font-weight: 700;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.metric {
  padding: 14px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 20px;
}

.strategyBox {
  padding: 14px 16px;
}

.strategyBox p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

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

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

.chartShell,
.tableShell,
.tradePanel {
  padding: 16px;
  min-width: 0;
}

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

.tickerPanel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.tickerPanel div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.tickerPanel strong {
  display: block;
  font-size: 22px;
  line-height: 1.15;
}

.tickerPanel span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.miniChart {
  display: block;
  width: 100%;
  height: 260px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  cursor: grab;
  user-select: none;
}

.miniChart:active {
  cursor: grabbing;
}

.tradeGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.tradeGrid label {
  margin-bottom: 0;
}

.tradeTables {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tradeTables .tableWrap {
  width: 100%;
}

.statusLine {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.progressTrack {
  width: 100%;
  height: 8px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ebf2;
}

.progressBar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #10b981);
  transition: width 0.25s ease;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef4ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.chartHeader {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

#chartHint {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.chartTools {
  display: flex;
  gap: 8px;
}

.chartTools button {
  height: 30px;
  padding: 0 10px;
  background: #e5e7eb;
  color: #111827;
  font-size: 12px;
}

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

.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  border-radius: 50%;
}

.legend .price {
  background: var(--blue);
}

.legend .maFast {
  background: #7c3aed;
}

.legend .bollBand {
  background: rgba(124, 58, 237, 0.45);
}

.legend .maSlow {
  background: #0f766e;
}

.legend .equity {
  background: var(--amber);
}

.legend .buy {
  background: var(--green);
}

.legend .sell {
  background: var(--red);
}

.legend .closeTrade {
  background: transparent;
  border: 2px solid var(--amber);
}

canvas {
  display: block;
  max-width: 100%;
  width: 100%;
  height: 440px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
  cursor: grab;
  user-select: none;
}

canvas:active {
  cursor: grabbing;
}

.tableWrap {
  overflow: auto;
  max-height: 360px;
  margin-top: 12px;
}

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

.configBlock {
  max-height: 360px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

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

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
}

th:nth-child(2),
td:nth-child(2),
th:last-child,
td:last-child {
  text-align: left;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 520px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #111827;
  color: white;
  box-shadow: 0 12px 32px rgba(17, 24, 39, 0.2);
}

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

  .metrics {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .quantGrid {
    grid-template-columns: 1fr;
  }
}
