:root {
  color-scheme: dark;
  --bg: #0a0d0f;
  --panel: #101518;
  --panel-2: #151b1f;
  --panel-3: #1b2328;
  --text: #eef4f1;
  --muted: #8c9a96;
  --line: #263137;
  --line-strong: #3b4a52;
  --green: #39d98a;
  --red: #ff5f6d;
  --amber: #e7b85c;
  --blue: #68a7ff;
  --left-width: 31%;
  --right-width: 33%;
  --left-track: minmax(0, var(--left-width));
  --center-track: minmax(0, 1fr);
  --right-track: minmax(0, var(--right-width));
  --gutter: clamp(16px, 2.4vw, 26px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  overflow: hidden;
}

button {
  font: inherit;
}

.workspace {
  display: grid;
  grid-template-columns: var(--left-track) var(--gutter) var(--center-track) var(--gutter) var(--right-track);
  height: 100dvh;
  min-height: 0;
  padding: 10px;
}

.panel {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel);
}

.bots-panel {
  border-radius: 8px 0 0 8px;
}

.trades-panel {
  border-radius: 0;
}

.charts-panel {
  border-radius: 0 8px 8px 0;
}

.gutter {
  position: relative;
  min-width: 0;
  cursor: col-resize;
}

.gutter::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: var(--line-strong);
}

.gutter:hover::after {
  background: var(--blue);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

h1,
h2,
p {
  margin: 0;
}

h1,
h2 {
  font-size: 17px;
  line-height: 1.1;
  letter-spacing: 0;
}

.eyebrow,
.label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
}

.mono {
  font-variant-numeric: tabular-nums;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.status-stack {
  display: grid;
  justify-items: end;
  gap: 4px;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
}

.status-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

.portfolio-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.portfolio-strip > div {
  min-width: 0;
  padding: 10px 12px;
  border-right: 1px solid var(--line);
}

.portfolio-strip > div:last-child {
  border-right: 0;
}

.portfolio-strip strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(18px, 2.6vw, 30px);
  line-height: 1;
  white-space: nowrap;
}

.bot-list-head,
.bot-row {
  display: grid;
  grid-template-columns: minmax(90px, 1.25fr) minmax(46px, 0.5fr) minmax(48px, 0.45fr) minmax(64px, 0.55fr);
  gap: 8px;
  align-items: center;
}

.bot-list-head {
  padding: 9px 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.bot-list {
  height: calc(100% - 153px);
  overflow: auto;
}

.bot-row {
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

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

.bot-name {
  min-width: 0;
}

.bot-name strong,
.bot-name span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bot-name span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.ticker-pill {
  justify-self: start;
  padding: 4px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #0c1012;
  font-size: 12px;
  font-weight: 900;
}

.num {
  font-variant-numeric: tabular-nums;
  font-weight: 850;
}

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

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

.flat {
  color: var(--muted);
}

.panel-metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.panel-metrics span,
.range-button {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0c1012;
}

.selected-bot-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.selected-bot-title {
  min-width: 0;
}

.selected-bot-title strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 22px;
}

.selected-bot-title span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.bot-stats {
  display: grid;
  grid-auto-flow: column;
  gap: 10px;
  text-align: right;
}

.bot-stats div {
  min-width: 70px;
}

.bot-stats strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  white-space: nowrap;
}

.trade-table {
  height: calc(100% - 143px);
  overflow: hidden;
}

.trade-row {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) 54px 48px 64px 64px 70px 48px;
  gap: 8px;
  align-items: center;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}

.trade-head {
  color: var(--muted);
  background: #0c1012;
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.trade-body {
  height: calc(100% - 34px);
  overflow: auto;
}

.trade-body .trade-row {
  font-size: 13px;
}

.side {
  font-weight: 950;
}

.side.long {
  color: var(--green);
}

.side.short {
  color: var(--red);
}

.range-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.range-button {
  min-width: 38px;
  color: var(--muted);
  cursor: pointer;
}

.range-button.is-active {
  color: var(--text);
  border-color: var(--blue);
  background: #142033;
}

.chart-block {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.main-chart {
  min-height: 214px;
}

.chart-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.chart-title strong {
  color: var(--text);
}

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
}

.top-charts {
  display: grid;
  gap: 8px;
  height: calc(100dvh - 306px);
  min-height: 0;
  overflow: auto;
}

.mini-chart {
  display: grid;
  grid-template-columns: minmax(70px, 0.7fr) minmax(120px, 1.4fr) minmax(58px, 0.45fr);
  gap: 8px;
  align-items: center;
  min-height: 46px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0c1012;
}

.mini-chart-title {
  min-width: 0;
}

.mini-chart-title strong,
.mini-chart-title span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-chart-title span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.mini-chart canvas {
  height: 28px;
}

@media (max-width: 700px) {
  body {
    overflow: auto;
  }

  .workspace {
    display: block;
    height: auto;
    min-height: 100dvh;
    padding: 8px;
  }

  .gutter {
    display: none;
  }

  .panel {
    min-height: 70dvh;
    margin-bottom: 8px;
    border-radius: 8px;
  }

  .bot-list {
    height: 52dvh;
  }

  .trade-table,
  .top-charts {
    height: auto;
    max-height: 52dvh;
  }
}
