:root {
  color-scheme: dark;
  --bg: #0c0f14;
  --panel: #141922;
  --panel-2: #10151d;
  --line: #283140;
  --muted: #8d99aa;
  --text: #eef3f8;
  --green: #25c38a;
  --red: #ff646d;
  --amber: #e3b341;
  --blue: #5aa7ff;
  --cyan: #50d5d8;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(80, 213, 216, 0.05), transparent 320px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #1a212c;
  color: var(--text);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: #506075;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  width: min(1780px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

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

.brand-lockup { display: flex; align-items: center; gap: 10px; }
.brand-lockup > img { width: 38px; height: 38px; border: 1px solid #2e4052; border-radius: 8px; }
.brand-lockup h1 span {
  color: var(--cyan);
}

h2 {
  font-size: 15px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-button {
  min-height: 38px;
  border-color: #3b5069;
  padding: 0 13px;
  color: #dcecff;
  font-size: 12px;
}

.user-chip {
  display: flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #111821;
}

.user-chip > button:first-child {
  display: grid;
  grid-template-columns: 28px auto;
  grid-template-rows: 17px 14px;
  min-height: 40px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 4px 9px 4px 5px;
  text-align: left;
}

.user-chip > button:first-child > span {
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  align-self: center;
  border-radius: 50%;
  background: #214e55;
  color: #b7fbff;
  font-weight: 800;
}

.user-chip b { font-size: 12px; }
.user-chip small { color: var(--muted); font-size: 10px; }
.user-chip > .icon-button { min-height: 40px; border-width: 0 0 0 1px; border-radius: 0; }
.logout-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.logout-button:hover { color: #ff8e97; background: #29171d; }
.info-button { border-radius: 50%; font-family: Georgia, serif; font-weight: 800; }

.primary {
  background: linear-gradient(180deg, #2c8dff, #1763c7);
  border-color: #3d95ff;
  font-weight: 800;
  padding: 0 18px;
}

.secondary {
  background: #192331;
  border-color: #3b5069;
  color: #dcecff;
  font-weight: 750;
  padding: 0 16px;
}

.danger {
  background: #26151a;
  border-color: #5b2730;
  color: #ffc4c8;
  padding: 0 16px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  box-shadow: var(--shadow);
  width: 100%;
}

.status-strip > div,
.account-grid > div {
  min-width: 0;
  background: var(--panel);
  padding: 13px 14px;
}

.status-strip span,
.account-grid span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.status-strip strong,
.account-grid strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
}

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

.market-column {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.trading-sidebar {
  display: grid;
  gap: 14px;
  min-width: 0;
  align-items: start;
  align-content: start;
}

.chart-panel,
.account-overview,
.order-ticket,
.trade-log-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.chart-panel {
  min-width: 0;
  overflow: hidden;
}

.chart-toolbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 56px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.ohlc,
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  color: var(--muted);
  font-size: 13px;
}

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

.chart-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.chart-icon-btn {
  position: relative;
  width: 30px;
  min-height: 30px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.has-tooltip { position: relative; }

.has-tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  left: 50%;
  width: max-content;
  max-width: 190px;
  transform: translateX(-50%);
  border: 1px solid #3a4658;
  border-radius: 5px;
  background: #0b1017;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
  padding: 6px 8px;
  color: #dfe8f2;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.25;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.has-tooltip:hover::after,
.has-tooltip:focus-visible::after {
  opacity: 1;
}

.zoom-label {
  width: 43px;
  color: var(--muted);
  text-align: center;
  font-size: 11px;
}

.indicator-menu {
  position: relative;
}

.indicator-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.indicator-button[aria-expanded="true"] {
  border-color: #4d9be8;
  background: #234263;
}

.indicator-popover {
  position: absolute;
  z-index: 8;
  top: calc(100% + 7px);
  right: 0;
  width: 182px;
  overflow: hidden;
  border: 1px solid #3a4658;
  border-radius: 7px;
  background: #151b24;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.48);
  padding: 6px;
}

.indicator-popover label {
  display: grid;
  grid-template-columns: 18px 14px 1fr;
  align-items: center;
  gap: 7px;
  border-radius: 5px;
  padding: 8px 7px;
  color: #dce4ee;
  cursor: pointer;
  font-size: 12px;
}

.indicator-popover label:hover {
  background: #202936;
}

.indicator-popover input {
  margin: 0;
  accent-color: var(--blue);
}

.swatch {
  display: block;
  width: 13px;
  height: 3px;
  border-radius: 2px;
}

.swatch.sma { background: var(--amber); }
.swatch.ema { background: var(--blue); }
.swatch.vwap { background: var(--cyan); }
.swatch.bb { background: #bd8cff; }
.swatch.rsi { background: #ff9f43; }

.ohlc b {
  color: var(--text);
}

.legend span::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 3px;
  margin-right: 6px;
  vertical-align: middle;
  border-radius: 2px;
}

.legend-candle::before { background: var(--green); }
.legend-sma::before { background: var(--amber); }
.legend-ema::before { background: var(--blue); }
.legend-vwap::before { background: var(--cyan); }
.legend-bb::before { background: #bd8cff; }
.legend-rsi::before { background: #ff9f43; }

[data-legend][hidden],
[hidden] {
  display: none !important;
}

.chart-wrap {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: minmax(310px, 46vh) 118px;
  min-height: 470px;
  cursor: crosshair;
  user-select: none;
  touch-action: none;
}

.chart-wrap.has-rsi {
  grid-template-rows: minmax(280px, 39vh) 104px 92px;
}

.chart-wrap.dragging {
  cursor: grabbing;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#priceCanvas {
  background: #0f141c;
}

#volumeCanvas {
  border-top: 1px solid var(--line);
  background: #0f141c;
}

#rsiCanvas {
  border-top: 1px solid var(--line);
  background: #0f141c;
}

.chart-tooltip {
  position: absolute;
  z-index: 3;
  width: 232px;
  pointer-events: none;
  border: 1px solid #3a4658;
  border-radius: 6px;
  background: rgba(12, 15, 20, 0.94);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  padding: 9px 10px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.55;
}

.chart-tooltip .tooltip-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  color: var(--muted);
}

.chart-tooltip .tooltip-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px 10px;
}

.chart-tooltip .tooltip-indicators {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px 10px;
  margin-top: 6px;
  border-top: 1px solid #303a49;
  padding-top: 5px;
  color: var(--muted);
}

.chart-tooltip b {
  color: var(--text);
  font-weight: 700;
}

.chart-tooltip .value-up { color: var(--green); }
.chart-tooltip .value-down { color: var(--red); }
.chart-tooltip .value-sma { color: var(--amber); }
.chart-tooltip .value-ema { color: var(--blue); }
.chart-tooltip .value-vwap { color: var(--cyan); }
.chart-tooltip .value-boll { color: #bd8cff; }
.chart-tooltip .value-rsi { color: #ff9f43; }
.chart-tooltip .value-drawing { color: #f3c969; }

.chart-hint {
  position: absolute;
  right: 76px;
  bottom: 10px;
  pointer-events: none;
  color: rgba(141, 153, 170, 0.72);
  font-size: 11px;
}

.control-group {
  background: var(--panel);
  padding: 12px;
}

.account-overview {
  z-index: 4;
  overflow: hidden;
  background: var(--panel);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .24);
}

.order-ticket {
  min-width: 0;
}

.account-overview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
  padding: 0 11px;
  border-bottom: 1px solid var(--line);
  background: #111821;
}

.account-overview-head span {
  color: var(--cyan);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.account-hero {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 1px;
  background: var(--line);
}

.account-hero > div {
  min-width: 0;
  background: linear-gradient(180deg, #182434, #131b27);
  padding: 10px 11px;
}

.account-hero span,
.position-focus span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
}

.account-hero strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

.position-focus {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 1px;
  padding: 0;
  background: var(--line);
}

.position-focus > div {
  min-width: 0;
  background: #121923;
  padding: 8px 10px;
}

.position-focus > div:first-child {
  background: #142235;
}

.position-focus strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

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

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 9px;
}

.segmented button.active {
  background: #234263;
  border-color: #4d9be8;
}

.range-row {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}

.wide {
  width: 100%;
}

.field {
  display: grid;
  gap: 5px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.field input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0d1219;
  color: var(--text);
  padding: 0 11px;
}

.quick-row,
.trade-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.position-sizer {
  margin-bottom: 8px;
  border: 1px solid #334054;
  border-radius: 7px;
  background: #0f151e;
  padding: 8px;
}

.sizer-head,
.sizer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sizer-head { margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.sizer-head strong { color: var(--text); font-size: 15px; }
.size-presets { grid-template-columns: repeat(5, 1fr); margin-bottom: 8px; }
.size-presets button { min-width: 0; min-height: 29px; padding: 0 4px; font-size: 11px; }
.sizer-foot { color: #aab7c8; font-size: 11px; }
.sizer-foot small { color: var(--muted); font-size: 10px; }

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

.buy {
  background: #10271f;
  border-color: #245c49;
  color: #a8f0d2;
  font-weight: 800;
}

.sell {
  background: #2a1519;
  border-color: #67313a;
  color: #ffd1d5;
  font-weight: 800;
}

.muted {
  color: #d7dee8;
}

.message {
  min-height: 34px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.account-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  padding: 0;
  background: var(--line);
}

.account-overview .account-grid > div {
  padding: 7px 9px;
}

.account-overview .account-grid span {
  margin-bottom: 3px;
  font-size: 10px;
}

.account-overview .account-grid strong {
  font-size: 12px;
}

.account-grid strong {
  font-size: 15px;
}

.trade-log-panel {
  margin-top: 16px;
  padding: 14px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-weight: 700;
  background: var(--panel-2);
}

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

tbody tr:last-child td {
  border-bottom: 0;
}

.empty {
  color: var(--muted);
  text-align: center;
}

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

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

.result-dialog {
  width: min(720px, calc(100% - 28px));
  border: 1px solid #354154;
  border-radius: 8px;
  background: #141922;
  color: var(--text);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.62);
  padding: 0;
}

.result-dialog::backdrop {
  background: rgba(4, 7, 10, 0.76);
  backdrop-filter: blur(3px);
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 15px;
  border-bottom: 1px solid var(--line);
}

.result-head h2 {
  font-size: 20px;
}

.icon-button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.result-hero {
  display: grid;
  justify-items: center;
  padding: 26px 20px 22px;
  background: #10151d;
}

.result-hero span,
.result-grid span {
  color: var(--muted);
  font-size: 12px;
}

.result-hero strong {
  margin-top: 5px;
  font-size: 38px;
  letter-spacing: 0;
}

.result-hero small {
  margin-top: 3px;
  font-size: 15px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.result-grid > div {
  display: grid;
  gap: 5px;
  min-width: 0;
  background: var(--panel);
  padding: 14px;
}

.result-grid > div:last-child:nth-child(3n + 2) {
  grid-column: span 2;
}

.result-grid strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}

.result-reason {
  margin: 0;
  padding: 14px 22px 0;
  color: var(--muted);
  font-size: 13px;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 18px 22px 22px;
}

@media (max-width: 1350px) {
  .workspace {
    grid-template-columns: minmax(600px, 1fr) minmax(310px, 340px);
  }

  .account-overview { box-shadow: var(--shadow); }

  .position-focus {
    grid-template-columns: 1.2fr .8fr;
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 1500px);
    padding-top: 14px;
  }

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

  .top-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .status-strip {
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
  }

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

  .trading-sidebar { grid-column: 1; }

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

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

  .chart-tools {
    width: 100%;
    justify-content: space-between;
  }

  .chart-wrap {
    grid-template-rows: 380px 120px;
    min-height: 500px;
  }


  .chart-wrap.has-rsi {
    grid-template-rows: 320px 110px 105px;
    min-height: 535px;
  }

  .chart-hint {
    display: none;
  }

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

  .result-grid > div:last-child:nth-child(3n + 2) {
    grid-column: auto;
  }
}

/* Pro replay controls and journal */
body { background: var(--bg); }
button, input, select, textarea { font: inherit; }
.training-stats { display: flex; align-items: center; gap: 18px; color: var(--muted); font-size: 12px; }
.training-stats b { margin-left: 4px; color: var(--text); }
.sample-filters { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; width: 100%; margin: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); padding: 10px; }
.sample-filters label { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.sample-filters .checkbox-filter { grid-template-columns: 16px 1fr; }
.sample-filters .checkbox-filter input { width: 15px; height: 15px; accent-color: var(--blue); }
select, textarea { border: 1px solid var(--line); border-radius: 6px; outline: none; background: #0d1219; color: var(--text); }
select { min-width: 0; height: 34px; padding: 0 8px; }
.segmented.compact { display: flex; margin: 0; }
.segmented.compact button { min-width: 38px; min-height: 30px; padding: 0 8px; font-size: 11px; }
.indicator-popover { width: 238px; }
.indicator-popover label { grid-template-columns: 18px 14px 1fr auto; }
.mini-input { width: 45px !important; height: 26px !important; border: 1px solid var(--line); border-radius: 4px; background: #0d1219; color: var(--text); padding: 0 5px !important; }
.chart-icon-btn.active { border-color: var(--amber); color: var(--amber); background: #2a2415; }
.replay-bar { display: grid; grid-template-columns: auto auto minmax(160px, 1fr); align-items: center; gap: 12px; border-top: 1px solid var(--line); background: var(--panel-2); padding: 10px 12px; }
.replay-bar > button { min-height: 34px; padding: 0 10px; }
.play-button { width: 42px; padding: 0; color: var(--cyan); font-weight: 800; }
.next-tick-button { width: 38px; padding: 0 !important; color: #dcecff; font-size: 17px; line-height: 1; }
.auto-controls { display: flex; align-items: center; gap: 7px; justify-self: start; }
.auto-controls > span { color: var(--muted); font-size: 11px; }
.progress-meter { display: grid; grid-template-columns: minmax(120px, 1fr) auto; align-items: center; gap: 9px; min-width: 0; }
.progress-meter input:disabled { opacity: .86; cursor: default; }
.progress-meter span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.order-type { grid-template-columns: repeat(3, 1fr); }
.risk-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; margin-bottom: 10px; color: var(--muted); font-size: 12px; }
.risk-row input { width: 54px; height: 34px; border: 1px solid var(--line); border-radius: 6px; background: #0d1219; color: var(--text); padding: 0 6px; }
.risk-row button { min-height: 34px; padding: 0 9px; }
.risk-preview { margin: 2px 0 10px; border-left: 3px solid var(--amber); background: #1d1b15; padding: 8px 9px; color: #e8d69d; font-size: 12px; }
.close-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.close-row button { min-height: 34px; padding: 0 5px; font-size: 11px; }
.activity-panel { margin-top: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: var(--shadow); padding: 14px; }
.activity-tabs { display: flex; align-items: center; gap: 5px; margin-bottom: 10px; }
.activity-tabs button { min-height: 34px; padding: 0 14px; }
.activity-tabs button.active { border-color: #4d9be8; background: #234263; }
.activity-tabs span { margin-left: auto; color: var(--muted); font-size: 12px; }
.table-action { min-height: 28px; padding: 0 8px; font-size: 11px; }
.leaderboard-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
.leaderboard-toolbar > div:first-child { display: grid; gap: 3px; }
.leaderboard-toolbar strong { font-size: 14px; }
.leaderboard-toolbar span { color: var(--muted); font-size: 11px; }
.leaderboard-head, .leaderboard-row { display: grid; grid-template-columns: minmax(210px, 1.4fr) minmax(120px, .8fr) minmax(120px, .8fr) minmax(110px, .7fr); align-items: center; gap: 14px; }
.leaderboard-head { border-bottom: 1px solid var(--line); padding: 8px 13px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.leaderboard-list { display: grid; }
.leaderboard-row { min-height: 58px; border-bottom: 1px solid rgba(40, 49, 64, .75); padding: 8px 13px; background: var(--panel-2); }
.leaderboard-row.is-me { border-left: 3px solid var(--cyan); background: #111d26; }
.leader-player { display: grid; grid-template-columns: 34px 34px minmax(0, 1fr); align-items: center; gap: 9px; }
.leader-rank { color: var(--muted); font-size: 12px; font-weight: 800; text-align: center; }
.leader-rank.podium { color: var(--amber); font-size: 15px; }
.leader-avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 6px; background: #213142; color: #dcecff; font-size: 12px; font-weight: 800; }
.leader-player > span:last-child { display: grid; min-width: 0; }
.leader-player b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.leader-player small, .leader-metric small { color: var(--muted); font-size: 10px; }
.leader-metric { display: grid; gap: 2px; font-size: 12px; }
.leader-metric strong { font-size: 13px; }
.recent-results { display: grid; }
.recent-result-row { display: grid; grid-template-columns: minmax(190px, 1.35fr) repeat(4, minmax(92px, .7fr)) minmax(74px, .45fr); align-items: center; gap: 14px; min-height: 62px; border-bottom: 1px solid rgba(40, 49, 64, .75); background: var(--panel-2); padding: 9px 13px; }
.recent-result-row.is-clickable { cursor: pointer; }
.recent-result-row.is-clickable:hover { background: #182230; }
.recent-result-row > div { display: grid; gap: 2px; min-width: 0; }
.recent-result-row span, .recent-result-row small { color: var(--muted); font-size: 10px; }
.recent-result-row strong, .recent-result-row b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.recent-session b { color: #dcecff; }
.recent-action { justify-items: end; }
.recent-action button { min-height: 30px; padding: 0 9px; font-size: 11px; }
.result-dialog { width: min(980px, calc(100% - 28px)); max-height: calc(100vh - 28px); overflow: auto; }
.result-hero { display: flex; align-items: center; justify-content: center; gap: 26px; }
.result-hero > div:last-child { display: grid; justify-items: center; }
.score-ring { display: grid; place-items: center; width: 82px; height: 82px; border: 5px solid var(--cyan); border-radius: 50%; background: #121b22; }
.score-ring strong { margin: 0; font-size: 28px; }
.score-ring span { color: var(--muted); font-size: 10px; }
.result-actions { grid-template-columns: repeat(3, 1fr); }
.journal-section { display: grid; grid-template-columns: minmax(240px, .9fr) 1.1fr; gap: 14px; padding: 16px 22px 0; }
.journal-section img { width: 100%; min-height: 160px; border: 1px solid var(--line); border-radius: 6px; background: #0f141c; object-fit: contain; }
.journal-fields { display: grid; gap: 12px; }
.journal-fields label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; }
.journal-fields textarea { width: 100%; resize: vertical; padding: 9px; line-height: 1.5; }
.tag-options { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-options button { min-height: 30px; padding: 0 9px; font-size: 11px; }
.tag-options button.active { border-color: var(--amber); background: #2a2415; color: #ffe5a3; }
.order-dialog { width: min(520px, calc(100% - 28px)); border: 1px solid #354154; border-radius: 8px; background: var(--panel); color: var(--text); padding: 0; }
.order-dialog::backdrop { background: rgba(4, 7, 10, .72); }
.order-detail { padding: 18px 22px 22px; }
.order-detail dl { display: grid; grid-template-columns: 130px 1fr; gap: 1px; margin: 0; background: var(--line); }
.order-detail dt, .order-detail dd { margin: 0; background: var(--panel-2); padding: 10px; overflow-wrap: anywhere; }
.order-detail dt { color: var(--muted); }

.auth-dialog {
  position: relative;
  width: min(470px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  border: 1px solid #354154;
  border-radius: 8px;
  background: #121822;
  color: var(--text);
  padding: 24px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .55);
}

.auth-dialog::backdrop { background: rgba(4, 7, 10, .82); }
.auth-brand { padding-right: 34px; }
.auth-brand h2 { font-size: 22px; }
.auth-brand > p:last-child { margin: 7px 0 18px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.auth-tabs { grid-template-columns: 1fr 1fr; margin-bottom: 16px; }
.auth-form { display: grid; gap: 11px; }
.auth-form label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.auth-form input { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 6px; outline: none; background: #0c1118; color: var(--text); padding: 0 10px; }
.auth-form input:focus { border-color: #4d9be8; }
.auth-form label small { color: #687587; font-size: 10px; }
.auth-form .terms-check { display: grid; grid-template-columns: 16px 1fr; align-items: start; gap: 8px; line-height: 1.5; }
.terms-check input { width: 15px; height: 15px; margin-top: 2px; accent-color: var(--blue); }
.terms-check button, .site-footer button { border: 0; min-height: 0; background: transparent; padding: 0; color: #78baff; font-size: inherit; }
.terms-check button:hover, .site-footer button:hover { color: #b9dcff; text-decoration: underline; }
.auth-name-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.auth-message { min-height: 18px; margin: 12px 0 0; color: var(--red); font-size: 12px; }
.auth-close { position: absolute; top: 14px; right: 14px; }

.dashboard-dialog { width: min(1120px, calc(100% - 28px)); max-height: calc(100vh - 28px); overflow: auto; border: 1px solid #354154; border-radius: 8px; background: #10161f; color: var(--text); padding: 0; }
.dashboard-dialog::backdrop { background: rgba(4, 7, 10, .82); }
.dashboard-body { display: grid; gap: 14px; padding: 16px 20px 22px; }
.dashboard-summary { display: grid; grid-template-columns: minmax(220px, .7fr) 1.3fr; align-items: center; gap: 18px; border-bottom: 1px solid var(--line); padding: 0 0 16px; }
.dashboard-identity { display: flex; align-items: center; gap: 12px; }
.dashboard-identity > span { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 8px; background: #234263; color: #e7f5ff; font-size: 22px; font-weight: 800; }
.dashboard-identity > div { display: grid; gap: 4px; }
.dashboard-identity strong { font-size: 19px; }
.dashboard-identity small, .dashboard-section-head span { color: var(--muted); font-size: 11px; }
.dashboard-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.dashboard-stats > div { display: grid; gap: 4px; border-left: 2px solid #2d3b4d; padding: 5px 9px; }
.dashboard-stats span { color: var(--muted); font-size: 10px; }
.dashboard-stats strong { font-size: 15px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(310px, .55fr); gap: 14px; align-items: start; }
.dashboard-settings { display: grid; gap: 14px; }
.dashboard-section { border: 1px solid var(--line); border-radius: 7px; background: var(--panel-2); padding: 14px; }
.dashboard-section-head { display: flex; justify-content: space-between; margin-bottom: 12px; }
.dashboard-section-head h3 { margin: 0 0 3px; font-size: 14px; }
.dashboard-history { min-width: 0; }
.dashboard-history .recent-result-row { grid-template-columns: minmax(170px, 1.2fr) repeat(4, minmax(78px, .65fr)) minmax(70px, .45fr); padding-inline: 9px; }
.recent-journal { grid-column: 1 / -1; display: grid; gap: 6px; border-top: 1px solid var(--line); padding-top: 9px; }
.recent-journal > span { display: flex; flex-wrap: wrap; gap: 5px; }
.recent-journal i { border: 1px solid #3b5168; border-radius: 4px; background: #172331; padding: 2px 6px; color: #a9d4f5; font-size: 10px; font-style: normal; }
.recent-journal p { margin: 0; color: #aebac8; font-size: 11px; line-height: 1.5; white-space: pre-wrap; }
.form-message { min-height: 16px; margin: 0; color: var(--cyan); font-size: 11px; }
.dashboard-api-button { width: 100%; margin-top: 10px; }

@media (max-width: 900px) { .dashboard-summary, .dashboard-grid { grid-template-columns: 1fr; } .dashboard-stats { grid-template-columns: repeat(5, minmax(100px, 1fr)); overflow-x: auto; } }

.api-dialog {
  width: min(620px, calc(100% - 24px));
  border: 1px solid #354154;
  border-radius: 8px;
  background: #121822;
  color: var(--text);
  padding: 0;
}

.api-dialog::backdrop { background: rgba(4, 7, 10, .78); }

.info-dialog { width: min(720px, calc(100% - 24px)); max-height: calc(100vh - 24px); overflow: auto; border: 1px solid #354154; border-radius: 8px; background: #111822; color: var(--text); padding: 0; }
.info-dialog::backdrop { background: rgba(4, 7, 10, .8); }
.info-body { display: grid; grid-template-columns: 158px minmax(0, 1fr); min-height: 430px; }
.info-nav { display: grid; align-content: start; gap: 3px; border-right: 1px solid var(--line); background: #0d131b; padding: 14px 10px; }
.info-nav button { min-height: 38px; border-color: transparent; background: transparent; text-align: left; }
.info-nav button.active { border-color: #385a78; background: #182b3c; color: #bfe1ff; }
.info-body > section { padding: 24px; }
.info-body h3 { margin: 0 0 14px; font-size: 18px; }
.info-body p { margin: 0 0 14px; color: #b1bdcb; font-size: 13px; line-height: 1.75; }
.simulation-notice { display: grid; gap: 5px; border-left: 3px solid var(--amber); background: #211d13; padding: 12px 14px; }
.simulation-notice strong { color: #ffe09a; }
.simulation-notice span { color: #c9b986; font-size: 12px; line-height: 1.5; }
.info-rules { display: grid; grid-template-columns: 110px 1fr; gap: 1px; margin: 0; background: var(--line); }
.info-rules dt, .info-rules dd { margin: 0; background: var(--panel-2); padding: 11px; font-size: 12px; line-height: 1.55; }
.info-rules dt { color: #8fcaff; font-weight: 700; }
.info-rules dd { color: #b1bdcb; }
.site-footer { display: flex; align-items: center; justify-content: space-between; width: min(100% - 40px, 1500px); margin: 18px auto 26px; color: #687587; font-size: 11px; }
.site-footer > div { display: flex; gap: 16px; }
.feedback-dialog { width: min(520px, calc(100% - 24px)); border: 1px solid #354154; border-radius: 8px; background: #111822; color: var(--text); padding: 0; }
.feedback-dialog::backdrop { background: rgba(4, 7, 10, .8); }
.feedback-form { display: grid; gap: 14px; padding: 18px 22px 22px; }
.feedback-form label { display: grid; grid-template-columns: 1fr auto; gap: 7px; color: var(--muted); font-size: 12px; }
.feedback-form label span { color: #687587; font-size: 10px; }
.feedback-form input, .feedback-form textarea { grid-column: 1 / -1; width: 100%; border: 1px solid var(--line); border-radius: 6px; outline: none; background: #0c1118; padding: 10px; color: var(--text); font: inherit; }
.feedback-form textarea { resize: vertical; line-height: 1.5; }
.feedback-form input:focus, .feedback-form textarea:focus { border-color: #4d9be8; }
.api-key-body { display: grid; gap: 14px; padding: 18px 22px 22px; }
.api-key-status { display: grid; gap: 4px; border-left: 3px solid var(--cyan); background: #0e151d; padding: 12px 14px; }
.api-key-status span, .api-key-status small { color: var(--muted); font-size: 11px; }
.api-key-status strong { font-size: 15px; }
.api-key-reveal { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 8px; }
.api-key-reveal label { display: grid; gap: 6px; color: #ffd68a; font-size: 11px; }
.api-key-reveal input { width: 100%; height: 40px; border: 1px solid #68552d; border-radius: 6px; background: #0c1118; color: #fff0c7; padding: 0 10px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.api-key-reveal button { min-height: 40px; }
.api-key-message { min-height: 17px; margin: 0; color: var(--muted); font-size: 12px; }
.api-key-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.api-key-actions > * { min-height: 38px; }
.button-link { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 7px; background: #1a212c; padding: 0 13px; color: var(--text); text-decoration: none; font-size: 12px; }
.button-link:hover { border-color: #506075; }

@media (max-width: 1100px) {
  .sample-filters { grid-template-columns: repeat(3, 1fr); }
  .status-strip strong { font-size: 14px; }
  .workspace { grid-template-columns: 1fr; }
  .trading-sidebar { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); }
}

@media (max-width: 820px) {
  .training-stats { justify-content: space-between; }
  .sample-filters { grid-template-columns: 1fr 1fr; width: 100%; }
  .trading-sidebar { grid-template-columns: 1fr; }
  .replay-bar { grid-template-columns: 1fr auto; }
  .auto-controls, .progress-meter { grid-column: 1 / -1; }
  .auto-controls { flex-wrap: wrap; }
  .journal-section { grid-template-columns: 1fr; }
  .result-actions { grid-template-columns: 1fr; }
  .leaderboard-head { display: none; }
  .leaderboard-row { grid-template-columns: 1fr 1fr; }
  .leader-player { grid-column: 1 / -1; }
  .recent-result-row { grid-template-columns: repeat(2, 1fr); }
  .recent-session { grid-column: 1 / -1; }
}

@media (max-width: 520px) {
  .sample-filters, .field-grid { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr; }
  .chart-actions { flex-wrap: wrap; }
  .top-actions { grid-template-columns: repeat(2, 1fr); }
  .user-chip { min-width: 0; }
  .auth-name-row { grid-template-columns: 1fr; }
  .api-key-reveal { grid-template-columns: 1fr; }
  .api-key-actions { display: grid; grid-template-columns: 1fr; }
  .status-strip strong { font-size: 15px; }
  .info-body { grid-template-columns: 1fr; }
  .info-nav { grid-template-columns: repeat(2, 1fr); border-right: 0; border-bottom: 1px solid var(--line); }
  .site-footer { align-items: flex-start; flex-direction: column; gap: 10px; }
  .leaderboard-toolbar { align-items: stretch; flex-direction: column; }
  .leaderboard-row { grid-template-columns: 1fr; }
  .leader-player { grid-column: auto; }
  .recent-result-row { grid-template-columns: 1fr; }
  .recent-session { grid-column: auto; }
}

@media (max-width: 720px) {
  .workspace { grid-template-columns: 1fr; }
  .chart-panel, .trading-sidebar, .account-overview, .order-ticket { grid-column: 1; }
}

/* Algorithm API documentation */
.docs-body { background: #0b0f15; color: var(--text); }
.docs-topbar { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; gap: 14px; min-height: 58px; border-bottom: 1px solid var(--line); background: rgba(11, 15, 21, .96); padding: 0 24px; backdrop-filter: blur(10px); }
.docs-brand { color: var(--text); text-decoration: none; font-size: 19px; font-weight: 800; }
.docs-brand b { color: var(--cyan); }
.docs-topbar > span { border-left: 1px solid var(--line); padding-left: 14px; color: var(--muted); font-size: 12px; }
.docs-topbar nav { display: flex; gap: 16px; margin-left: auto; }
.docs-topbar nav a { color: #b8c8d9; text-decoration: none; font-size: 12px; }
.docs-topbar nav a:hover { color: var(--cyan); }
.docs-layout { display: grid; grid-template-columns: 230px minmax(0, 920px); justify-content: center; gap: 42px; width: min(1220px, calc(100% - 32px)); margin: 0 auto; }
.docs-nav { position: sticky; top: 80px; display: grid; align-content: start; gap: 3px; height: calc(100vh - 100px); overflow: auto; border-right: 1px solid var(--line); padding: 30px 22px 30px 0; }
.docs-nav strong { margin-bottom: 8px; font-size: 13px; }
.docs-nav span { margin: 16px 0 5px; color: #657386; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.docs-nav a { border-radius: 5px; padding: 6px 8px; color: #9cabbc; text-decoration: none; font-size: 12px; }
.docs-nav a:hover { background: #141d28; color: var(--text); }
.docs-content { min-width: 0; padding: 52px 0 100px; }
.docs-intro { padding-bottom: 38px; }
.docs-intro h1 { max-width: 720px; font-size: 42px; }
.docs-intro > p:last-of-type { max-width: 720px; color: #a7b4c4; font-size: 16px; line-height: 1.7; }
.docs-base { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; margin-top: 22px; border: 1px solid #334153; border-radius: 7px; background: #101720; padding: 10px 12px; }
.docs-base span { color: var(--muted); font-size: 11px; }
.docs-base code { overflow: hidden; color: #b7f5f7; text-overflow: ellipsis; white-space: nowrap; }
.docs-base button { min-height: 30px; padding: 0 10px; font-size: 11px; }
.docs-section { border-top: 1px solid var(--line); padding: 40px 0 10px; scroll-margin-top: 72px; }
.docs-section h2 { margin-bottom: 14px; font-size: 24px; }
.docs-section p, .docs-section li { color: #aab6c5; font-size: 14px; line-height: 1.7; }
.docs-section ul { display: grid; gap: 6px; padding-left: 20px; }
.docs-section code { border-radius: 4px; background: #151e29; padding: 2px 5px; color: #c7e9eb; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
.docs-section pre { overflow: auto; border: 1px solid #2c3747; border-radius: 7px; background: #090d12; padding: 16px 18px; }
.docs-section pre code { background: transparent; padding: 0; color: #c5d1df; font-size: 12px; line-height: 1.65; }
.docs-section table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 12px; }
.docs-section th, .docs-section td { border-bottom: 1px solid var(--line); padding: 10px 11px; text-align: left; vertical-align: top; }
.docs-section th { background: #111821; color: #8290a2; font-size: 10px; text-transform: uppercase; }
.docs-section td { color: #b6c2d0; }
.docs-flow { display: flex; align-items: center; gap: 9px; overflow: auto; margin: 20px 0; }
.docs-flow span { min-width: 150px; border: 1px solid #334153; border-radius: 6px; background: #111821; padding: 12px; color: #dce6f1; font-size: 12px; line-height: 1.5; text-align: center; }
.docs-flow i { color: var(--cyan); font-style: normal; }
.endpoint-title { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.endpoint-title > code { background: transparent; padding: 0; color: #e7edf5; font-size: 13px; }
.method { min-width: 52px; border-radius: 4px; padding: 5px 7px; font-size: 9px; font-weight: 900; text-align: center; }
.method.get { background: #14304b; color: #8dccff; }
.method.post { background: #15392d; color: #8ce7c1; }
.method.delete { background: #421f27; color: #ffabb1; }
.docs-callout { display: grid; grid-template-columns: 130px 1fr; gap: 12px; margin: 16px 0; border-left: 3px solid var(--amber); background: #1c1911; padding: 12px 14px; color: #d9cda9; font-size: 12px; line-height: 1.6; }

@media (max-width: 820px) {
  .docs-topbar { padding: 0 12px; }
  .docs-topbar > span { display: none; }
  .docs-layout { display: block; width: min(100% - 24px, 920px); }
  .docs-nav { display: none; }
  .docs-content { padding-top: 34px; }
  .docs-intro h1 { font-size: 32px; }
  .docs-base { grid-template-columns: 1fr auto; }
  .docs-base span { grid-column: 1 / -1; }
  .docs-callout { grid-template-columns: 1fr; }
}
