:root {
  --bg: #f3f5f7;
  --panel: #ffffff;
  --soft: #f5f6f8;
  --line: #edf0f3;
  --line-strong: #dfe4ea;
  --text: #12161c;
  --muted: #8c939d;
  --green: #2ec38a;
  --green-dark: #18b979;
  --red: #f2475d;
  --blue: #0799c9;
  --yellow: #f4b000;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
h1, h2, p { margin: 0; }

.terminal {
  --desk-height: 190px;
  height: 100vh;
  display: grid;
  grid-template-rows: 48px 80px minmax(220px, 1fr) var(--desk-height);
  gap: 4px;
  padding: 10px 8px 0;
  overflow: hidden;
}

body.module-desk-hidden .terminal {
  grid-template-rows: 48px 80px minmax(220px, 1fr) 0;
}

body.resizing-desk {
  cursor: row-resize;
  user-select: none;
}

.topbar {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 0 16px;
  border-radius: 8px;
  background: #050607;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  margin-right: 34px;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 6px solid #1f8cff;
  border-right-color: #20d09a;
}

.brand strong {
  font-size: 23px;
  line-height: 1;
  font-weight: 900;
}

.top-module {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  color: rgba(255, 255, 255, .68);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.top-module span {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(166, 255, 84, .12);
  color: #a7ff54;
  font-style: italic;
}

.top-module strong {
  color: rgba(255, 255, 255, .88);
  font-size: 14px;
  font-weight: 850;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  color: rgba(255, 255, 255, .72);
  font-size: 12px;
  white-space: nowrap;
}

.top-account-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  color: #fff;
}

.top-icon-btn {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 999px;
  background: rgba(255, 255, 255, .06);
  color: rgba(255, 255, 255, .82);
  font-size: 12px;
  font-weight: 850;
}

.top-account-btn span {
  color: #aeb6c2;
  font-size: 12px;
}

.top-account-btn strong {
  font-size: 13px;
  font-weight: 850;
}

.market-head {
  display: grid;
  grid-template-columns: 258px 138px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  min-width: 0;
  padding: 0 22px;
  background: var(--panel);
  border-radius: 8px;
  border: 1px solid var(--line);
}

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

.coin-badge {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
}

.instrument-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.instrument h1 {
  font-size: 21px;
  line-height: 1.05;
  letter-spacing: 0;
}

.instrument-row span {
  padding: 3px 8px;
  border-radius: 4px;
  background: #eef0f3;
  color: #8f969f;
  font-size: 12px;
  font-weight: 700;
}

.instrument p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.headline-price {
  color: var(--green);
  font-size: 24px;
  letter-spacing: 0;
  white-space: nowrap;
}

.head-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(74px, 1fr));
  gap: 18px;
  min-width: 0;
}

.head-metrics span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 5px;
  white-space: nowrap;
}

.head-metrics strong {
  display: block;
  font-size: 15px;
  line-height: 1.1;
  white-space: nowrap;
}

.market-tools {
  display: none;
  justify-content: flex-end;
  gap: 10px;
}

.desktop-muted-metric {
  display: none;
}

.market-tools button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: #9aa0a9;
  padding: 0;
}

.workspace {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 392px;
  gap: 6px;
  min-height: 0;
  overflow: hidden;
}

body.market-list-collapsed .workspace {
  grid-template-columns: 76px minmax(0, 1fr) 392px;
}

body.module-left-hidden .workspace {
  grid-template-columns: minmax(0, 1fr) 392px;
}

body.module-right-hidden .workspace {
  grid-template-columns: 260px minmax(0, 1fr);
}

body.market-list-collapsed.module-right-hidden .workspace {
  grid-template-columns: 76px minmax(0, 1fr);
}

body.module-left-hidden.module-right-hidden .workspace {
  grid-template-columns: minmax(0, 1fr);
}

body.module-left-hidden .market-list,
body.module-right-hidden .order-sidebar,
body.module-desk-hidden .bottom-panel {
  display: none;
}

.market-list, .chart-panel, .order-sidebar, .bottom-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  min-width: 0;
}

.market-list {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: 14px 12px 0;
  border-radius: 8px 0 0 8px;
  overflow: hidden;
}

.market-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 36px;
  padding: 0 4px 0 8px;
}

.market-list-head strong {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}

.module-hide-btn,
.market-list-head button {
  width: 30px;
  height: 30px;
  min-height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #f1f2f4;
  color: #6f7782;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  padding: 0;
}

.module-hide-btn:hover,
.market-list-head button:hover {
  background: #e8ecf1;
  color: #111820;
}

.watch-list {
  overflow: auto;
  min-height: 0;
  margin: 0 -6px;
  padding: 0 0 12px;
}

.ticker-card {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 12px 10px;
  color: var(--text);
  text-align: left;
}

.ticker-card.active { background: #eff1f3; }

.ticker-card .pair {
  font-weight: 780;
  font-size: 15px;
  min-width: 0;
}

.ticker-card .pair::before {
  content: "★";
  color: var(--yellow);
  margin-right: 8px;
  font-size: 17px;
}

.ticker-card .pair small {
  display: block;
  margin-left: 26px;
  color: #949ba5;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.3;
}

.ticker-card .price {
  grid-column: 2;
  grid-row: 1;
  font-weight: 780;
  font-size: 16px;
}

.ticker-card .change {
  grid-column: 2;
  grid-row: 2;
  font-size: 14px;
  text-align: right;
}

body.market-list-collapsed .market-list {
  padding: 12px 8px 0;
}

body.market-list-collapsed .market-list-head {
  justify-content: center;
  padding: 0;
}

body.market-list-collapsed .market-list-head strong {
  display: none;
}

body.market-list-collapsed .watch-list {
  margin: 0;
}

body.market-list-collapsed .ticker-card {
  min-height: 62px;
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 2px;
  padding: 8px 4px;
}

body.market-list-collapsed .ticker-card .pair {
  font-size: 0;
}

body.market-list-collapsed .ticker-card .pair::before {
  margin: 0;
  font-size: 18px;
}

body.market-list-collapsed .ticker-card .pair small {
  display: none;
}

body.market-list-collapsed .ticker-card .price {
  grid-column: 1;
  grid-row: 2;
  font-size: 10px;
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.market-list-collapsed .ticker-card .change {
  grid-column: 1;
  grid-row: 3;
  font-size: 10px;
  text-align: center;
}

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

.chart-panel {
  display: grid;
  grid-template-rows: 48px 48px minmax(0, 1fr);
  position: relative;
  overflow: hidden;
}

.chart-tabs, .chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 0 22px;
}

.tab {
  border: 0;
  background: transparent;
  padding: 13px 10px 10px;
  font-weight: 780;
  color: #858d98;
}

.tab.active {
  color: var(--text);
  border-bottom: 4px solid #0d0f12;
}

.tv-toggle {
  display: none;
  align-items: center;
  gap: 10px;
  font-weight: 780;
}

.chart-toolbar {
  justify-content: flex-start;
  gap: 10px;
  color: var(--muted);
  overflow: hidden;
  min-width: 0;
}

input, select, button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 6px 10px;
}

.timeframe-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.timeframe-tabs button,
.icon-btn,
#refreshMarketBtn,
#historyStatusBtn {
  min-height: 32px;
  border: 0;
  background: transparent;
  color: #737c88;
  border-radius: 4px;
  font-weight: 650;
  white-space: nowrap;
}

.timeframe-tabs button { min-width: 44px; }

.timeframe-tabs .active {
  background: #eff1f4;
  color: #14181e;
}

.chart-toolbar select,
.chart-toolbar input {
  display: none;
}

.tool-separator {
  width: 1px;
  height: 22px;
  background: var(--line-strong);
  margin-left: auto;
  flex: 0 0 1px;
}

.icon-btn {
  display: none;
}

#lastRefresh {
  font-size: 12px;
  color: #9aa1ab;
  white-space: nowrap;
  display: none;
}

#historyStatusBtn {
  background: #eff1f4;
  color: #14181e;
  padding: 6px 12px;
}

.chart-wrap {
  position: relative;
  height: 100%;
  min-height: 0;
  background: #fff;
  overflow: hidden;
  padding-bottom: 22px;
}

.chart-label {
  position: absolute;
  z-index: 2;
  top: 14px;
  left: 22px;
  display: flex;
  gap: 12px;
  color: #8b929c;
  font-size: 18px;
  pointer-events: none;
}

.chart-label strong {
  color: var(--green-dark);
  font-weight: 500;
}

.chart-live-state {
  position: static;
  margin-left: 4px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(25, 184, 122, .1);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 850;
  max-width: 190px;
  flex: 0 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-live-state.stale {
  background: rgba(240, 93, 93, .1);
  color: var(--red);
}

.drag-price-line {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  top: 0;
  height: 0;
  border-top: 1px dashed rgba(29, 124, 216, .72);
  cursor: ns-resize;
  touch-action: none;
}

.drag-price-line.locked {
  cursor: default;
}

.drag-price-line.locked::before {
  display: none;
}

.drag-price-line::before {
  content: "";
  position: absolute;
  left: -7px;
  top: -7px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #1d7cd8;
  box-shadow: 0 1px 5px rgba(17, 24, 39, .2);
}

.tp-line {
  border-top-color: rgba(32, 185, 120, .8);
}

.tp-line::before {
  border-color: var(--green-dark);
}

.sl-line {
  border-top-color: rgba(242, 71, 93, .8);
}

.sl-line::before {
  border-color: var(--red);
}

.drag-price-caption,
.drag-price-value {
  position: absolute;
  top: -15px;
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  user-select: none;
}

.drag-price-caption {
  left: 12px;
  color: #1d7cd8;
  background: rgba(255, 255, 255, .86);
}

.drag-price-value {
  right: 0;
  background: #1d7cd8;
  color: #fff;
}

.tp-line .drag-price-caption {
  color: var(--green-dark);
}

.tp-line .drag-price-value {
  background: var(--green-dark);
}

.sl-line .drag-price-caption {
  color: var(--red);
}

.sl-line .drag-price-value {
  background: var(--red);
}

.position-entry-line {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  top: 0;
  height: 0;
  display: none;
  border-top: 1px dashed rgba(18, 24, 34, .58);
  pointer-events: none;
}

.position-entry-caption,
.position-entry-value {
  position: absolute;
  top: -15px;
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
  user-select: none;
}

.position-entry-caption {
  left: 12px;
  color: #111820;
  background: rgba(255, 255, 255, .88);
}

.position-entry-value {
  right: 0;
  color: #fff;
  background: #111820;
}

.active-position-panel {
  position: absolute;
  z-index: 5;
  top: 52px;
  left: 66px;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: min(520px, calc(100% - 120px));
  padding: 10px 12px;
  border: 1px solid #dbe5f1;
  border-radius: 8px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 10px 28px rgba(15, 23, 42, .12);
}

.active-position-panel strong {
  display: block;
  color: #111820;
  font-size: 13px;
  font-weight: 900;
}

.active-position-panel span {
  display: block;
  margin-top: 2px;
  color: #7b8490;
  font-size: 12px;
  font-weight: 760;
}

.active-position-panel button {
  flex: 0 0 auto;
  border: 0;
  border-radius: 999px;
  background: #f1f3f6;
  color: #1475e1;
  font-size: 12px;
  font-weight: 850;
  padding: 7px 10px;
}

#priceChart {
  width: 100%;
  height: calc(100% - 22px);
}

.order-sidebar {
  display: flex;
  flex-direction: column;
  padding: 18px 20px;
  border-radius: 0 8px 8px 0;
  overflow: auto;
}

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

#hideDeskBtn {
  flex: 0 0 auto;
}

.order-sidebar.real-trade-enabled {
  box-shadow: inset 4px 0 0 var(--red);
  background: linear-gradient(90deg, rgba(247, 67, 91, .055), #fff 34%);
}

.account-card-head,
.gate-account-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.account-card-head {
  min-height: 58px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #f6f8fa;
}

.account-card-head strong {
  display: block;
  font-size: 18px;
  font-weight: 900;
  color: #10151c;
}

.account-card-head span,
.gate-account-line span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.gate-account-line strong {
  display: block;
  color: #111820;
  font-size: 13px;
  font-weight: 900;
}

.text-action {
  min-height: 0;
  border: 1px solid #dfe5ec;
  border-radius: 999px;
  background: #fff;
  color: #1d7cd8;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 850;
}

.login-form,
.bind-form {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.login-form input,
.bind-form input,
.bind-form select {
  width: 100%;
  min-height: 34px;
  background: #fff;
}

.login-form button,
.bind-form button {
  width: 100%;
  border: 0;
  background: #111820;
  color: #fff;
  font-weight: 780;
}

.gate-bind {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.account-live-meta {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8fafc;
  color: #6f7782;
  font-size: 12px;
  line-height: 1.45;
}

.account-modal-card .bind-form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #dfe5ec;
}

.account-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: start end;
  padding: 68px 26px 24px;
  background: rgba(15, 18, 24, .42);
}

.account-modal-card {
  position: relative;
  width: min(360px, calc(100vw - 32px));
  padding: 18px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .24);
}

.account-modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  border: 0;
  background: transparent;
  color: #8c939d;
  font-size: 26px;
  line-height: 1;
}

.hidden { display: none !important; }

.leverage {
  margin: 0 0 18px;
  font-weight: 780;
}

.quote-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 50px;
  margin-bottom: 16px;
}

.quote-buttons button {
  border: 0;
  min-height: 58px;
  background: #f3f4f6;
  color: #9aa1ab;
}

.quote-buttons .buy {
  color: var(--green-dark);
}

.quote-buttons .buy.active {
  background: #eafff5;
  border: 1px solid var(--green-dark);
}

.quote-buttons .sell {
  color: var(--red);
}

.quote-buttons .sell.active {
  background: #fff1f3;
  border: 1px solid var(--red);
}

.quote-buttons .sell strong { color: var(--red); }
.quote-buttons strong { font-size: 16px; }

.trade-mode {
  display: flex;
  gap: 24px;
  margin: 2px 0 10px;
}

.trade-mode button {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #8b929c;
  font-weight: 780;
  padding: 0 0 8px;
}

.trade-mode .active {
  color: var(--text);
  border-bottom: 4px solid #0d0f12;
}

label {
  display: block;
  margin: 0 0 8px;
  color: #8b929c;
  font-weight: 650;
  font-size: 13px;
}

label input, label select {
  margin-top: 6px;
  width: 100%;
  min-height: 38px;
  background: #f1f2f4;
  border-color: transparent;
}

.order-form-section {
  padding: 10px;
  border-radius: 10px;
  background: #fbfcfd;
  border: 1px solid #edf1f5;
  margin-bottom: 10px;
}

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

.available-size {
  margin: -4px 0 12px;
  color: #8b929c;
  font-size: 13px;
  font-weight: 650;
  text-align: right;
}

.available-size.warning {
  color: var(--red);
}

.price-field.hidden { display: none; }

.checkline {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #6f7782;
}

.checkline input {
  width: auto;
  min-height: auto;
  margin: 0;
}

.account-lines {
  display: grid;
  gap: 8px;
  margin: 10px 0 14px;
  padding: 0;
  border-radius: 10px;
  background: transparent;
}

.summary-group {
  display: grid;
  gap: 7px;
  padding: 10px;
  border-radius: 10px;
  background: #f8fafc;
}

.summary-title {
  color: #111820;
  font-size: 12px;
  font-weight: 900;
}

.summary-group div:not(.summary-title) {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  font-size: 12px;
}

.account-lines span,
.summary-group span { color: #8b929c; }

.account-lines strong,
.summary-group strong {
  min-width: 0;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#riskRewardRatio.good {
  color: var(--green-dark);
}

#riskRewardRatio.warn {
  color: var(--red);
}

.real-trade-switch {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin: 6px 0 12px;
  color: #6f7782;
  font-size: 13px;
  font-weight: 720;
}

.real-trade-switch input {
  width: 16px;
  height: 16px;
  accent-color: var(--red);
}

.real-trade-switch:has(input:checked) {
  color: var(--red);
}

.submit {
  width: 100%;
  border: 0;
  min-height: 48px;
  border-radius: 24px;
  background: var(--green);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
}

.order-sidebar.is-buy .submit {
  background: var(--green);
}

.order-sidebar.is-sell .submit {
  background: var(--red);
}

.order-sidebar.real-trade-enabled .submit {
  box-shadow: 0 0 0 3px rgba(247, 67, 91, .16);
}

.submit:disabled {
  background: #cfd5dd;
  cursor: not-allowed;
}

.desk-action:disabled,
.position-desk-tools button:disabled,
.position-modal-confirm:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.bottom-panel {
  display: grid;
  grid-template-rows: 10px 46px minmax(0, 1fr);
  border-radius: 0 0 8px 8px;
  overflow: hidden;
}

.bottom-resizer {
  position: relative;
  z-index: 6;
  height: 10px;
  cursor: row-resize;
  background: #f8fafc;
  border-top: 1px solid #d8dde5;
  border-bottom: 1px solid var(--line);
  touch-action: none;
}

.bottom-resizer::before {
  content: "";
  display: block;
  width: 72px;
  height: 4px;
  margin: 2px auto 0;
  border-radius: 999px;
  background: #bfc7d1;
}

.bottom-resizer:hover::before {
  background: #7c8795;
}

.trade-desk-head {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}

.trade-desk-tabs {
  display: flex;
  align-items: stretch;
  gap: 22px;
  min-width: 0;
  overflow-x: auto;
  height: 100%;
}

.trade-desk-tabs button {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: #7b838e;
  font-size: 14px;
  font-weight: 780;
  white-space: nowrap;
  padding: 0 0 2px;
}

.trade-desk-tabs button.active {
  color: var(--text);
  border-bottom-color: #0d0f12;
}

#refreshTradfiDeskBtn {
  border: 0;
  background: transparent;
  color: #6f7782;
  font-weight: 760;
  white-space: nowrap;
}

#hideDeskBtn {
  margin-left: auto;
}

.trade-desk-table {
  min-height: 0;
  overflow: auto;
}

.desk-row {
  display: grid;
  grid-template-columns: repeat(var(--desk-cols, 8), minmax(104px, 1fr));
  align-items: center;
  min-width: calc(var(--desk-cols, 8) * 104px);
  min-height: 34px;
  border-bottom: 1px solid var(--line);
  color: #7c8490;
  font-size: 13px;
}

.desk-row.header {
  position: sticky;
  top: 0;
  z-index: 1;
  min-height: 36px;
  background: #fbfcfd;
  color: #8e96a1;
  font-weight: 720;
}

.desk-row span {
  padding: 0 14px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.desk-row strong {
  color: var(--text);
}

.desk-action {
  width: fit-content;
  min-width: 54px;
  height: 26px;
  border: 0;
  border-radius: 999px;
  background: #f2f3f5;
  color: #15191f;
  font-size: 12px;
  font-weight: 780;
  padding: 0 14px;
}

.desk-action.danger {
  color: #15191f;
  background: #f2f3f5;
}

.desk-action.link {
  min-width: 0;
  padding: 0;
  background: transparent;
  color: #1475e1;
}

.orders-board {
  min-width: 1180px;
}

.order-row {
  display: grid;
  grid-template-columns: 150px 120px 170px 130px 170px 190px 160px 110px;
  align-items: center;
  min-height: 66px;
  border-bottom: 1px solid var(--line);
  color: #141820;
  font-size: 13px;
}

.order-row.header {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 38px;
  background: #fbfcfd;
  color: #8e96a1;
  font-weight: 720;
}

.order-row > span,
.order-row > div {
  min-width: 0;
  padding: 0 18px;
}

.order-symbol strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 850;
}

.order-symbol span {
  display: inline-flex;
  height: 20px;
  align-items: center;
  padding: 0 7px;
  border-radius: 5px;
  background: #eef1f4;
  color: #8b929c;
  font-weight: 780;
}

.order-side {
  font-weight: 900;
}

.order-side.long { color: var(--green-dark); }
.order-side.short { color: var(--red); }

.order-edit {
  margin-left: 6px;
  color: #8b929c !important;
}

.order-tpsl {
  display: grid;
  gap: 3px;
  font-weight: 760;
}

.order-tpsl .tp { color: var(--green-dark); }
.order-tpsl .sl { color: var(--red); }

.order-history-board {
  min-width: 1320px;
}

.order-history-row {
  grid-template-columns: 150px 110px 120px 110px 150px 120px 160px 200px 200px;
}

.order-status {
  display: inline-flex;
  min-width: 58px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #f1f3f6;
  color: #8b929c;
  font-size: 12px;
  font-weight: 820;
}

.order-status.done {
  background: rgba(25, 184, 122, .10);
  color: var(--green-dark);
}

.order-status.cancelled {
  background: #f1f3f6;
  color: #8b929c;
}

.order-status.pending {
  background: rgba(20, 117, 225, .10);
  color: #1475e1;
}

.positions-board {
  min-width: 1260px;
}

.position-row {
  display: grid;
  grid-template-columns: 145px 92px 118px 118px 126px 112px 134px 124px 134px 120px 92px 178px;
  align-items: center;
  min-height: 78px;
  border-bottom: 1px solid var(--line);
  color: #141820;
  font-size: 13px;
}

.position-row:not(.header) {
  cursor: pointer;
}

.position-row:not(.header):hover,
.position-row.active {
  background: #f8fafc;
}

.position-row.active {
  box-shadow: inset 3px 0 0 #1475e1;
}

.position-row.header {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 36px;
  background: #fbfcfd;
  color: #8e96a1;
  font-weight: 720;
}

.position-row > span,
.position-row > div {
  padding: 0 14px;
  min-width: 0;
}

.position-symbol strong {
  display: inline-block;
  margin-bottom: 4px;
  color: #141820;
  font-size: 14px;
}

.active-position-badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: #e8f2ff;
  color: #1475e1;
  font-size: 11px;
  font-weight: 850;
  vertical-align: 1px;
}

.position-side-line {
  display: flex;
  align-items: center;
  gap: 5px;
}

.position-side-line.long { border-left: 3px solid var(--green); padding-left: 7px; }
.position-side-line.short { border-left: 3px solid var(--red); padding-left: 7px; }

.position-side-badge,
.position-leverage-badge {
  height: 20px;
  padding: 1px 7px;
  border-radius: 5px;
  font-weight: 850;
  line-height: 18px;
}

.position-side-badge.long {
  color: var(--green-dark);
  background: #e9fbf4;
}

.position-side-badge.short {
  color: var(--red);
  background: #fff1f3;
}

.position-leverage-badge {
  color: #8f96a0;
  background: #f0f1f3;
}

.position-money.positive { color: var(--green-dark); }
.position-money.negative { color: var(--red); }

.position-share {
  color: #8b929c;
  font-weight: 800;
  margin-left: 4px;
}

.position-tpsl {
  display: flex;
  align-items: center;
  gap: 10px;
}

.position-tpsl-values {
  display: grid;
  gap: 2px;
  font-weight: 760;
}

.position-tpsl-values .tp { color: var(--green-dark); }
.position-tpsl-values .sl { color: var(--red); }

.position-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.position-desk-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  white-space: nowrap;
  color: #141820;
  font-size: 13px;
  font-weight: 650;
}

.position-desk-tools label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.position-desk-tools input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.position-desk-tools button {
  border: 0;
  background: transparent;
  color: #1475e1;
  font-weight: 800;
  padding: 0;
}

#clearActivePositionBtn {
  color: #7b838e;
}

.history-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 1180px;
  padding: 14px 14px;
  border-bottom: 1px solid var(--line);
}

.history-filter-bar button,
.history-filter-bar .history-date-range {
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: #f2f3f5;
  color: #15191f;
  font-size: 13px;
  font-weight: 760;
  padding: 0 14px;
}

.history-filter-bar button.active {
  background: #fff;
  border: 1px solid #141820;
}

.history-filter-bar .history-date-range {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: #141820;
}

.history-filter-bar .reset {
  background: transparent;
  color: #8b929c;
  padding: 0 4px;
}

.history-board {
  min-width: 1180px;
}

.position-history-board {
  min-width: 1340px;
}

.history-desk-row {
  display: grid;
  align-items: center;
  min-height: 72px;
  border-bottom: 1px solid var(--line);
  color: #141820;
  font-size: 13px;
}

.history-desk-row.position-history {
  grid-template-columns: 150px 100px 120px 180px 140px 140px 130px 180px 180px 80px;
}

.history-desk-row.order-history {
  grid-template-columns: 136px 96px 118px 112px 112px 122px 122px 112px 160px 80px;
}

.history-desk-row.header {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 38px;
  background: #fbfcfd;
  color: #8e96a1;
  font-weight: 720;
}

.history-desk-row > span,
.history-desk-row > div {
  padding: 0 14px;
  min-width: 0;
}

.history-symbol strong {
  display: block;
  margin-bottom: 6px;
  color: #141820;
}

.history-pnl strong {
  display: block;
  text-decoration: underline dotted rgba(120, 128, 140, .5);
  text-underline-offset: 4px;
}

.history-pnl .rate {
  display: block;
  margin-top: 3px;
}

.direction-text.long,
.history-pnl.positive { color: var(--green-dark); }

.direction-text.short,
.history-pnl.negative { color: var(--red); }

.history-status {
  display: inline-flex;
  min-width: 72px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #f1f3f6;
  color: #8b929c;
  font-size: 12px;
  font-weight: 820;
}

.history-status.done {
  background: rgba(25, 184, 122, .10);
  color: var(--green-dark);
}

.history-status.pending {
  background: rgba(20, 117, 225, .10);
  color: #1475e1;
}

.desk-empty {
  height: 100%;
  min-height: 90px;
  display: grid;
  place-items: center;
  color: #9aa1ab;
  font-size: 14px;
}

.desk-debug {
  display: block;
  height: 100%;
  padding: 12px 14px;
}

.floating-panel-toggle {
  position: fixed;
  z-index: 14;
  left: 18px;
  bottom: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 118px;
  min-height: 36px;
  border: 0;
  border-radius: 999px;
  background: #111820;
  color: #fff;
  font-size: 13px;
  font-weight: 850;
  padding: 0 14px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, .22);
}

.floating-panel-toggle span {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  font-size: 16px;
  line-height: 1;
}

.floating-panel-toggle.right {
  left: auto;
  right: 18px;
}

.floating-panel-toggle.left-panel {
  bottom: 62px;
}

.position-tabs {
  height: 49px;
  display: flex;
  align-items: center;
  gap: 22px;
  font-weight: 780;
  color: #777f89;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.position-tabs .active {
  color: var(--text);
  border-bottom: 4px solid #0d0f12;
  padding-bottom: 14px;
}

.position-tabs label {
  margin-left: auto;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.position-table {
  display: grid;
  grid-template-columns: repeat(12, minmax(84px, 1fr));
  gap: 0;
  color: #9aa1ab;
  font-size: 13px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

pre {
  margin: 0;
  height: 74px;
  overflow: auto;
  color: #8b929c;
  background: transparent;
  font-size: 12px;
  white-space: pre-wrap;
}

.hidden { display: none !important; }

.hidden-actions {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.history-drawer {
  position: fixed;
  right: 410px;
  bottom: 18px;
  width: min(680px, calc(100vw - 460px));
  max-height: min(520px, calc(100vh - 150px));
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, .16);
  z-index: 30;
}

.history-drawer.hidden { display: none; }

.history-head,
.history-actions,
.history-summary {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-head {
  justify-content: space-between;
}

.history-head strong {
  display: block;
  font-size: 16px;
}

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

#closeHistoryBtn {
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #f1f2f4;
  color: #6f7782;
  font-size: 20px;
}

.history-actions button {
  border: 0;
  background: #eff1f4;
  font-weight: 700;
  white-space: nowrap;
}

.history-actions #repairHistoryBtn {
  background: var(--green);
  color: #fff;
}

.history-actions #rebuildCurrentHistoryBtn {
  background: #e8f1ff;
  color: #1475e1;
}

.history-actions #cleanupHistorySourcesBtn {
  background: #fff4e5;
  color: #9a5b00;
}

.history-actions button:disabled {
  background: #d9dee5;
  color: #8a929d;
  cursor: not-allowed;
}

.history-summary {
  flex-wrap: wrap;
  color: #8a929d;
  font-size: 12px;
}

.history-summary strong {
  color: var(--text);
}

.history-quality {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.history-quality-card {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.history-quality-card span,
.history-quality-card em {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-quality-card strong {
  display: block;
  overflow: hidden;
  margin: 4px 0 2px;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-table {
  overflow: auto;
  min-height: 0;
  border-top: 1px solid var(--line);
}

.history-row {
  display: grid;
  grid-template-columns: 64px 58px 58px 70px minmax(104px, 1fr) minmax(104px, 1fr) 74px;
  gap: 10px;
  align-items: center;
  min-height: 40px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.history-row.header {
  position: sticky;
  top: 0;
  background: #fff;
  color: var(--muted);
  font-weight: 700;
  z-index: 1;
}

.history-row strong {
  font-size: 13px;
}

@media (max-width: 1200px) {
  .history-drawer {
    left: 18px;
    right: 18px;
    width: auto;
    max-height: min(560px, calc(100vh - 130px));
  }
}

@media (max-width: 760px) {
  .history-quality {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-actions {
    flex-wrap: wrap;
  }
}

.history-badge {
  justify-self: start;
  padding: 3px 8px;
  border-radius: 999px;
  background: #edf8f3;
  color: var(--green-dark);
  font-weight: 800;
}

.history-badge.warn {
  background: #fff2f4;
  color: var(--red);
}

.position-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .48);
}

.position-modal-card {
  position: relative;
  width: min(680px, calc(100vw - 32px));
  padding: 34px 38px 32px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .25);
}

.position-modal-close {
  position: absolute;
  top: 22px;
  right: 26px;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: #9aa1ab;
  font-size: 34px;
  line-height: 30px;
  padding: 0;
}

.position-modal h2 {
  margin: 0 0 34px;
  font-size: 30px;
  line-height: 1;
}

.position-modal-symbol {
  margin-bottom: 22px;
  color: #11151b;
  font-size: 24px;
  font-weight: 880;
}

.position-modal-symbol .long { color: var(--green-dark); }
.position-modal-symbol .short { color: var(--red); }

.position-modal-summary {
  display: grid;
  gap: 12px;
  margin-bottom: 24px;
}

.position-modal-summary div,
.position-modal-line {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  color: #8b929c;
  font-size: 17px;
  font-weight: 720;
}

.position-modal-summary strong,
.position-modal-line strong {
  color: #11151b;
}

.position-modal-field {
  margin: 20px 0;
}

.position-modal-field label {
  display: block;
  margin-bottom: 8px;
  color: #8b929c;
  font-size: 17px;
  font-weight: 760;
}

.position-modal-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  height: 58px;
  padding: 0 14px;
  border-radius: 8px;
  background: #f1f2f4;
}

.position-modal-input input {
  min-width: 0;
  border: 0;
  background: transparent;
  color: #11151b;
  font-size: 20px;
  font-weight: 780;
  outline: none;
}

.position-modal-input span {
  font-size: 18px;
  font-weight: 850;
}

.position-modal-estimate {
  margin-top: 8px;
  text-align: right;
  color: #8b929c;
  font-size: 15px;
  font-weight: 720;
}

.position-modal-estimate.positive { color: var(--green-dark); }
.position-modal-estimate.negative { color: var(--red); }

.position-modal-warning {
  margin: 18px 0 8px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fff6e6;
  color: #9a6100;
  font-size: 15px;
  font-weight: 760;
}

.position-close-slider {
  margin: 26px 0 22px;
}

.position-close-slider input[type="range"] {
  width: 100%;
  accent-color: #30343a;
}

.position-close-marks {
  display: flex;
  justify-content: space-between;
  color: #9aa1ab;
  font-size: 14px;
  font-weight: 720;
}

.position-modal-error {
  min-height: 22px;
  color: var(--red);
  font-weight: 720;
}

.position-modal-confirm {
  width: 100%;
  height: 58px;
  margin-top: 10px;
  border: 0;
  border-radius: 999px;
  background: #2f3339;
  color: #fff;
  font-size: 20px;
  font-weight: 850;
}

.confirm-modal,
.settings-modal,
.layout-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 6, 7, .54);
}

.confirm-card,
.settings-card,
.layout-card {
  position: relative;
  width: min(520px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 28px 90px rgba(0, 0, 0, .28);
}

.confirm-card {
  padding: 28px;
}

.confirm-close,
.settings-close,
.layout-close {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 30px;
  height: 30px;
  min-height: 30px;
  border: 0;
  background: transparent;
  color: #9aa1ab;
  font-size: 28px;
  line-height: 1;
  padding: 0;
}

.confirm-kicker {
  width: fit-content;
  margin-bottom: 12px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(247, 67, 91, .1);
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
}

.confirm-card h2 {
  margin: 0 36px 18px 0;
  font-size: 24px;
  line-height: 1.2;
}

.confirm-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 14px;
  border-radius: 12px;
  background: #f8fafc;
}

.confirm-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  color: #8b929c;
  font-size: 14px;
  font-weight: 760;
}

.confirm-row strong {
  color: #111820;
  text-align: right;
}

.confirm-warning {
  margin-top: 14px;
  color: #8b4a00;
  font-size: 13px;
  font-weight: 780;
}

.confirm-actions,
.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.confirm-actions button,
.settings-actions button {
  min-width: 110px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: #eef2f7;
  color: #111820;
  font-weight: 900;
}

#confirmOkBtn,
#settingsSave,
#layoutSave {
  background: #145bd8;
  color: #fff;
}

.settings-card,
.layout-card {
  width: min(720px, calc(100vw - 32px));
  padding: 28px;
}

.layout-card {
  width: min(560px, calc(100vw - 32px));
}

.settings-head strong {
  display: block;
  font-size: 24px;
  font-weight: 900;
}

.settings-head span {
  display: block;
  margin-top: 4px;
  color: #8b929c;
  font-size: 13px;
  font-weight: 720;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 22px;
}

.settings-grid.single {
  grid-template-columns: 1fr;
}

.settings-section {
  padding: 16px;
  border: 1px solid #edf1f5;
  border-radius: 14px;
  background: #fbfcfd;
}

.settings-section h3 {
  margin: 0 0 14px;
  font-size: 15px;
}

.settings-section label:not(.settings-check) {
  display: grid;
  gap: 8px;
  margin: 12px 0;
  color: #8b929c;
  font-size: 13px;
  font-weight: 820;
}

.settings-section input:not([type="checkbox"]),
.settings-section select {
  width: 100%;
  height: 42px;
  border: 0;
  border-radius: 10px;
  background: #eef0f3;
  color: #111820;
  font-size: 15px;
  font-weight: 850;
  outline: none;
  padding: 0 12px;
}

.settings-section select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #111820 50%), linear-gradient(135deg, #111820 50%, transparent 50%);
  background-position: calc(100% - 18px) 18px, calc(100% - 12px) 18px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.settings-check {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 10px 0;
  color: #111820;
  font-size: 14px;
}

.settings-check input {
  width: 16px;
  min-height: 16px;
  margin: 0;
}

.layout-module-list {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.layout-switch {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  padding: 14px;
  border: 1px solid #edf1f5;
  border-radius: 14px;
  background: #fbfcfd;
  cursor: pointer;
}

.layout-switch input {
  width: 17px;
  min-height: 17px;
  margin: 2px 0 0;
  accent-color: #145bd8;
}

.layout-switch span {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.layout-switch strong {
  color: #111820;
  font-size: 15px;
  font-weight: 900;
}

.layout-switch em {
  color: #8b929c;
  font-size: 13px;
  font-style: normal;
  font-weight: 720;
}

@media (max-width: 1500px) {
  .workspace { grid-template-columns: 240px minmax(0, 1fr) 360px; }
  body.market-list-collapsed .workspace { grid-template-columns: 72px minmax(0, 1fr) 360px; }
  body.module-left-hidden .workspace { grid-template-columns: minmax(0, 1fr) 360px; }
  body.module-right-hidden .workspace { grid-template-columns: 240px minmax(0, 1fr); }
  body.module-left-hidden.module-right-hidden .workspace { grid-template-columns: minmax(0, 1fr); }
  .head-metrics { grid-template-columns: repeat(4, minmax(74px, 1fr)); }
}

@media (min-width: 1800px) and (min-height: 850px) {
  .terminal {
    grid-template-rows: 56px 96px minmax(300px, 1fr) var(--desk-height);
    gap: 6px;
    padding: 12px 10px 0;
  }

  .topbar {
    padding: 0 20px;
  }

  .brand strong {
    font-size: 26px;
  }

  .top-module,
  .top-module strong {
    font-size: 16px;
  }

  .top-icon-btn,
  .top-account-btn {
    min-height: 38px;
    padding-inline: 16px;
  }

  .market-head {
    grid-template-columns: 300px 170px minmax(0, 1fr);
    padding: 0 28px;
  }

  .coin-badge {
    width: 48px;
    height: 48px;
    flex-basis: 48px;
    font-size: 16px;
  }

  .instrument h1 {
    font-size: 28px;
  }

  .headline-price {
    font-size: 32px;
  }

  .head-metrics {
    grid-template-columns: repeat(6, minmax(96px, 1fr));
    gap: 26px;
  }

  .head-metrics span {
    font-size: 14px;
  }

  .head-metrics strong {
    font-size: 18px;
  }

  .workspace {
    grid-template-columns: 300px minmax(0, 1fr) 420px;
    gap: 8px;
  }

  body.market-list-collapsed .workspace {
    grid-template-columns: 84px minmax(0, 1fr) 420px;
  }

  body.module-left-hidden .workspace {
    grid-template-columns: minmax(0, 1fr) 420px;
  }

  body.module-right-hidden .workspace {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .module-hide-btn,
  .market-list-head button,
  .top-icon-btn,
  .quote-buttons button,
  .mode-btn,
  .submit,
  .desk-action {
    min-height: 42px;
  }

  .ticker-card {
    min-height: 76px;
  }

  .order-sidebar {
    padding: 22px 24px;
  }
}

@media (pointer: coarse) {
  .top-icon-btn,
  .top-account-btn,
  .module-hide-btn,
  .market-list-head button,
  .timeframe-tabs button,
  .chart-tool-btn,
  .mode-btn,
  .quote-buttons button,
  .desk-action,
  .submit,
  .preset,
  .unit-select,
  .layout-option,
  .confirm-card button,
  .position-modal button {
    min-height: 44px;
  }

  .trade-desk-tabs button,
  .top-module span,
  .account-summary button {
    min-height: 38px;
  }

  .chart-live-state,
  .sync-status-pill {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
  }

  .line-handle {
    width: 26px;
    height: 26px;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }
}

@media (min-width: 1200px) and (pointer: coarse) {
  .terminal {
    gap: 6px;
    padding: 10px 8px 0;
  }

  .market-head {
    min-height: 92px;
  }

  .workspace {
    gap: 8px;
  }

  .bottom-panel {
    min-height: 220px;
  }
}

@media (max-width: 1080px) {
  html,
  body {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .terminal {
    min-height: 100vh;
    height: auto;
    grid-template-rows: auto auto auto auto;
    padding: 6px;
    overflow: visible;
  }

  body.module-desk-hidden .terminal {
    grid-template-rows: auto auto auto 0;
  }

  .topbar {
    min-height: 48px;
    padding: 0 10px;
    gap: 10px;
  }

  .brand {
    margin-right: 8px;
  }

  .brand strong {
    font-size: 20px;
  }

  .top-module {
    gap: 6px;
  }

  .top-module strong {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .top-actions {
    gap: 8px;
  }

  #serviceStatus,
  .top-account-btn span {
    display: none;
  }

  .top-icon-btn,
  .top-account-btn {
    min-height: 36px;
    padding: 0 12px;
  }

  .market-head,
  .workspace {
    min-height: 0;
  }

  .market-head {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    padding: 14px;
  }

  .headline-price {
    justify-self: end;
    font-size: 26px;
  }

  .head-metrics {
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, minmax(110px, 1fr));
    gap: 12px;
    margin-top: 8px;
  }

  .market-list,
  .chart-panel,
  .order-sidebar,
  .bottom-panel {
    margin-bottom: 6px;
    border-radius: 8px;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 6px;
    overflow: visible;
  }

  .market-list,
  .chart-panel,
  .order-sidebar {
    min-height: 0;
  }

  .chart-panel {
    order: 1;
    min-height: min(660px, calc(100vh - 210px));
  }

  .market-list {
    order: 2;
    max-height: 210px;
    padding: 12px 10px 8px;
    border-radius: 8px;
  }

  .watch-list {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    margin: 0;
    padding: 0 2px 10px;
    scroll-snap-type: x proximity;
  }

  .ticker-card {
    flex: 0 0 210px;
    min-height: 96px;
    scroll-snap-align: start;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    align-items: start;
    gap: 8px;
    padding: 12px;
  }

  .ticker-card .pair,
  .ticker-card .price,
  .ticker-card .change {
    grid-column: 1;
  }

  .ticker-card .pair {
    grid-row: 1;
    display: block;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .ticker-card .pair small {
    max-width: 100%;
    margin-left: 26px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .ticker-card .price {
    grid-row: 2;
    justify-self: end;
    font-size: 18px;
  }

  .ticker-card .change {
    grid-row: 3;
    justify-self: end;
    text-align: right;
  }

  .order-sidebar {
    order: 3;
    max-height: 100%;
    border-radius: 8px;
  }

  .bottom-panel {
    min-height: var(--desk-height);
  }

  .chart-toolbar { overflow-x: auto; }
}

@media (max-width: 760px) {
  .terminal {
    --desk-height: 240px;
    padding: 4px;
    gap: 4px;
  }

  .topbar {
    border-radius: 6px;
  }

  .brand-mark {
    width: 20px;
    height: 20px;
  }

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

  .top-module strong,
  #clock {
    display: none;
  }

  .top-module span {
    height: 30px;
    padding: 0 10px;
  }

  .market-head {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
  }

  .headline-price {
    justify-self: start;
    font-size: 30px;
  }

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

  .head-metrics span {
    font-size: 12px;
  }

  .head-metrics strong {
    font-size: 14px;
  }

  .desktop-muted-metric {
    display: none;
  }

  .chart-tabs {
    min-height: 42px;
    padding: 0 12px;
  }

  .chart-toolbar {
    padding: 8px 10px;
    gap: 12px;
  }

  .timeframe-tabs {
    min-width: max-content;
  }

  .timeframe-tabs button {
    min-height: 38px;
    padding: 0 12px;
  }

  .chart-panel {
    min-height: 520px;
  }

  .chart-label {
    left: 12px;
    top: 12px;
    font-size: 14px;
  }

  .chart-live-state {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .market-list {
    max-height: 188px;
    padding: 10px 8px 8px;
  }

  .watch-list {
    gap: 8px;
  }

  .market-list-head {
    height: 30px;
  }

  .market-list-head button {
    display: none;
  }

  .ticker-card {
    flex-basis: 178px;
    min-height: 102px;
    padding: 10px;
  }

  .ticker-card .pair {
    font-size: 14px;
  }

  .ticker-card .pair small {
    font-size: 11px;
  }

  .ticker-card .price {
    font-size: 16px;
  }

  .ticker-card .change {
    font-size: 13px;
  }

  .order-sidebar {
    padding: 14px 12px;
  }

  .quote-buttons {
    gap: 12px;
  }

  .row,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .trade-desk-head {
    gap: 10px;
    padding: 0 10px;
  }

  .position-desk-tools {
    margin-left: 0;
  }

  .position-desk-tools label {
    display: none;
  }

  .trade-desk-tabs {
    gap: 16px;
  }

  .trade-desk-table {
    overflow: auto;
  }

  .trade-desk-table table,
  .position-row,
  .order-row,
  .history-row {
    min-width: 760px;
  }

  .confirm-modal,
  .settings-modal,
  .layout-modal,
  .position-modal,
  .account-modal {
    padding: 10px;
    place-items: center;
  }

  .confirm-card,
  .settings-card,
  .layout-card,
  .position-modal-card,
  .account-modal-card {
    width: min(100%, calc(100vw - 20px));
    max-height: calc(100vh - 20px);
    padding: 22px;
    border-radius: 14px;
  }

  .position-modal h2 {
    font-size: 24px;
  }
}
