:root {
  --bg: #0B0C0E;
  --panel: #14161A;
  --row: #1E2126;
  --line: #2A2E35;
  --text: #E8E4DC;
  --muted: #8A8781;
  --amber: #C9A227;
  --up: #17B26A;
  --down: #E5484D;
  --font-display: 'Archivo', system-ui, sans-serif;
  --font-text: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --topbar-h: 64px;
  --radius: 3px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url(../assets/img/chart_backdrop.webp) center / cover no-repeat;
  opacity: 0.045;
  pointer-events: none;
  z-index: 0;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }
h1, h2, p { margin: 0; }

.app {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  flex: 0 0 var(--topbar-h);
  display: flex;
  align-items: stretch;
  background: #0E0F12;
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-right: 1px solid var(--line);
  flex: 0 0 auto;
  text-decoration: none;
}
.brand { gap: 10px; }
.brand-mark { position: relative; width: 18px; height: 27px; display: block; flex: 0 0 auto; }
.brand-mark i { position: absolute; bottom: 0; width: 4px; background: var(--amber); display: block; }
.brand-mark i::before,
.brand-mark i::after { content: ""; position: absolute; left: 50%; width: 1px; background: var(--amber); transform: translateX(-50%); }
.brand-mark i::before { bottom: 100%; height: 5px; }
.brand-mark i::after { top: 100%; height: 5px; }
.brand-mark i:nth-child(1) { left: 2px; height: 11px; }
.brand-mark i:nth-child(2) { left: 12px; height: 18px; }
.brand-word {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16.5px;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: var(--text);
  white-space: nowrap;
}

.ticker {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.ticker-btn {
  appearance: none;
  background: transparent;
  border: 0;
  border-left: 1px solid var(--line);
  border-bottom: 2px solid transparent;
  color: inherit;
  text-align: left;
  height: 100%;
  min-width: 0;
  padding: 0 11px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-content: center;
  transition: background-color 0.16s linear, border-color 0.16s linear;
}
.ticker-btn:first-child { border-left: 0; }
.ticker-btn:hover { background: rgba(232, 228, 220, 0.035); }
.ticker-btn.is-active { border-bottom-color: var(--amber); background: rgba(201, 162, 39, 0.045); }
.ticker-btn:focus-visible { outline: 1px solid var(--amber); outline-offset: -3px; }

.ticker-btn img {
  grid-row: 1 / span 2;
  width: 22px;
  height: 22px;
  align-self: center;
  object-fit: contain;
}

.ticker-symbol {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.055em;
  line-height: 1.2;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}
.ticker-btn.is-active .ticker-symbol { color: var(--amber); }

.ticker-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  margin-top: 2px;
}
.ticker-price {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: -0.015em;
  color: var(--text);
  white-space: nowrap;
}
.ticker-change {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 400;
  white-space: nowrap;
  color: var(--muted);
}
.ticker-change.pos { color: var(--up); }
.ticker-change.neg { color: var(--down); }

.sound-toggle {
  flex: 0 0 auto;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  transition: color 0.16s linear, background-color 0.16s linear;
}
.sound-toggle:hover { background: rgba(232, 228, 220, 0.035); color: var(--text); }
.sound-toggle:focus-visible { outline: 1px solid var(--amber); outline-offset: -3px; }
.sound-toggle.is-on { color: var(--amber); }
.sound-dot {
  width: 5px;
  height: 5px;
  background: var(--muted);
  display: block;
  transition: background-color 0.16s linear;
}
.sound-toggle.is-on .sound-dot { background: var(--amber); }

.terminal {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 300px;
  grid-template-rows: minmax(0, 1fr) clamp(180px, 24vh, 268px);
  gap: 10px;
  padding: 10px;
  height: calc(100dvh - var(--topbar-h));
}

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

.account { grid-column: 1; grid-row: 1; padding: 14px 16px; overflow: hidden; }
.chart-panel { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; overflow: hidden; background: #0B0C0E; }
.ticket { grid-column: 3; grid-row: 1; padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.positions { grid-column: 1 / -1; grid-row: 2; display: flex; flex-direction: column; overflow: hidden; }

.label {
  display: block;
  font-family: var(--font-text);
  font-weight: 500;
  font-size: 9.5px;
  line-height: 1.2;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 18px;
}
.panel-head h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text);
  white-space: nowrap;
}
.head-tag {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 2px 5px;
}
.head-icon {
  width: 15px;
  height: 15px;
  object-fit: contain;
  opacity: 0.9;
  flex: 0 0 auto;
}
.wallet-icon { width: 17px; height: 17px; }

.divider {
  height: 1px;
  background: var(--line);
  margin: 10px 0;
  flex: 0 0 auto;
}

.price {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "zero" 1;
  white-space: nowrap;
}
.price .last { opacity: 0.7; }
.price .flash-u { animation: digit-up 0.22s ease-out; }
.price .flash-d { animation: digit-down 0.22s ease-out; }

.pos { color: var(--up); }
.neg { color: var(--down); }
.flat { color: var(--text); }

@keyframes digit-up { 0% { color: var(--up); } 100% { color: inherit; } }
@keyframes digit-down { 0% { color: var(--down); } 100% { color: inherit; } }

.account .panel-head { margin-bottom: 14px; }

.stat { margin-bottom: 11px; }
.stat .label { margin-bottom: 4px; }
.stat .value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "zero" 1;
  font-weight: 600;
  font-size: 23px;
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--text);
}
.stat-balance .value { font-size: 29px; }
.stat .pnl-value { font-size: 23px; }

.stat-mobile-margin { display: none; }
.inert-value { color: var(--muted); opacity: 0.55; }

.locked { opacity: 0.34; user-select: none; pointer-events: none; }
.locked-title { margin-bottom: 8px; }
.lock-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 7px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
}
.lock-row b { font-weight: 400; color: var(--text); }

.pnl-value.is-live { animation: pnl-pulse 1.5s ease-in-out infinite; }
@keyframes pnl-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.62; } }

.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 14px 6px;
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
}
.instrument { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pair-emblem { width: 42px; height: 42px; object-fit: contain; flex: 0 0 auto; }
.pair-emblem.is-switching { animation: chart-in 0.22s ease-out; }
.instrument-text { min-width: 0; }
.instrument h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--text);
}
.instrument p {
  margin-top: 3px;
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quote-strip { display: flex; align-items: flex-start; gap: 20px; flex: 0 0 auto; }
.quote { display: flex; flex-direction: column; gap: 4px; }
.quote .label { font-size: 8.5px; }
.quote-value { font-size: 13px; font-weight: 600; color: var(--text); }

.tf-row {
  display: flex;
  align-items: stretch;
  gap: 1px;
  padding: 0 10px;
  border-top: 1px solid rgba(42, 46, 53, 0.55);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
  overflow-x: auto;
  scrollbar-width: none;
}
.tf-row::-webkit-scrollbar { display: none; }
.tf-btn {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-feature-settings: "zero" 1;
  font-size: 11px;
  font-weight: 500;
  padding: 7px 10px 6px;
  white-space: nowrap;
  transition: color 0.16s linear, border-color 0.16s linear;
}
.tf-btn:hover { color: var(--text); }
.tf-btn.is-active { color: var(--text); border-bottom-color: var(--amber); }
.tf-btn:focus-visible { outline: 1px solid var(--amber); outline-offset: -2px; }

.chart-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: #0B0C0E;
}
.chart-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url(../assets/img/chart_backdrop.webp) center / cover no-repeat;
  opacity: 0.26;
  pointer-events: none;
}
.chart-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.chart-wrap.is-switching canvas { animation: chart-in 0.22s ease-out; }
@keyframes chart-in { 0% { opacity: 0.35; } 100% { opacity: 1; } }

.ticket .panel-head { padding: 12px 14px 0; margin-bottom: 10px; flex: 0 0 auto; }
.ticket-scroll { padding: 0 14px 4px; flex: 1 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: none; }
.ticket-scroll::-webkit-scrollbar { display: none; }
.field-block { flex: 0 0 auto; }
.field-block .label { margin-bottom: 6px; }

.lot-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.lot-btn {
  appearance: none;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--row);
  color: var(--text);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "zero" 1;
  font-size: 11.5px;
  transition: border-color 0.13s linear, color 0.13s linear, background-color 0.13s linear;
}
.lot-btn:hover { border-color: #454a53; }
.lot-btn.is-active { border-color: var(--amber); color: var(--amber); background: rgba(201, 162, 39, 0.055); }
.lot-btn:focus-visible { outline: 1px solid var(--amber); outline-offset: 1px; }

.custom-lot {
  width: 100%;
  height: 30px;
  margin-top: 6px;
  padding: 0 9px;
  background: var(--row);
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11.5px;
  outline: none;
  transition: border-color 0.13s linear;
}
.custom-lot::placeholder { color: var(--muted); opacity: 0.8; }
.custom-lot:focus { border-color: var(--amber); }
.custom-lot.is-active { border-color: var(--amber); color: var(--amber); }

.field-pair { margin-top: 10px; flex: 0 0 auto; }
.field-pair .label { margin: 0 0 5px; }
.field-pair .label + .text-field + .label { margin-top: 9px; }
.text-field {
  width: 100%;
  height: 30px;
  padding: 0 9px;
  background: #17191d;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11.5px;
  opacity: 0.42;
  cursor: not-allowed;
}

.current-block { flex: 0 0 auto; }
.current-block .label { margin-bottom: 4px; }
.current-value { display: block; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  padding: 10px 14px 12px;
  flex: 0 0 auto;
}

.trade-btn {
  position: relative;
  appearance: none;
  border: 0;
  border-radius: var(--radius);
  height: 70px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: transform 0.08s linear, filter 0.13s linear;
}
.trade-btn.buy { background: var(--up); }
.trade-btn.sell { background: var(--down); }
.trade-btn:hover { filter: brightness(1.06); }
.trade-btn:active { transform: translateY(1px); }
.trade-btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

.sell .trade-icon { transform: translateX(-50%) rotate(180deg); }
.trade-icon {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 17px;
  height: 17px;
  object-fit: contain;
  filter: brightness(0) invert(1);
  opacity: 0.95;
}
.trade-word {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.11em;
  line-height: 1;
  margin-top: 15px;
}
.trade-price {
  margin-top: 3px;
  font-size: 10.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.86);
}
.ring {
  position: absolute;
  inset: 0;
  border: 2px solid var(--amber);
  opacity: 0;
  pointer-events: none;
}
.trade-btn.ping .ring { animation: press-ring 0.32s ease-out; }
@keyframes press-ring {
  0% { opacity: 0.9; transform: scale(0.98); }
  100% { opacity: 0; transform: scale(1.045); }
}

.positions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  background: var(--panel);
}
.positions-head .panel-head { min-height: 20px; }
.count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  margin-left: 1px;
}
.close-all {
  appearance: none;
  border: 1px solid var(--amber);
  background: transparent;
  color: var(--amber);
  border-radius: 2px;
  padding: 6px 11px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 9.5px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  transition: background-color 0.13s linear, color 0.13s linear, border-color 0.13s linear, opacity 0.13s linear;
}
.close-all:hover:not(:disabled) { background: rgba(201, 162, 39, 0.09); }
.close-all:focus-visible { outline: 1px solid var(--amber); outline-offset: 2px; }
.close-all:disabled { border-color: var(--line); color: var(--muted); opacity: 0.45; cursor: default; }

.table-wrap { position: relative; flex: 1 1 auto; min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: #3A3F48 transparent; }
.table-wrap::-webkit-scrollbar { width: 6px; height: 6px; }
.table-wrap::-webkit-scrollbar-thumb { background: #3A3F48; }

.positions-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.positions-table th:nth-child(1) { width: 20%; }
.positions-table th:nth-child(2) { width: 8%; }
.positions-table th:nth-child(3) { width: 15%; }
.positions-table th:nth-child(4) { width: 15%; }
.positions-table th:nth-child(5) { width: 9%; }
.positions-table th:nth-child(6) { width: 14%; }
.positions-table th:nth-child(7) { width: 11%; }
.positions-table th:nth-child(8) { width: 48px; }

.positions-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel);
  padding: 7px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-family: var(--font-text);
  font-weight: 500;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.positions-table thead th.num { text-align: right; }
.positions-table thead th.act { padding-right: 14px; }

.positions-table tbody td {
  padding: 8px 14px;
  border-bottom: 1px solid rgba(42, 46, 53, 0.48);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "zero" 1;
  font-size: 11.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.positions-table tbody tr:hover { background: rgba(232, 228, 220, 0.022); }
.positions-table tbody tr:last-child td { border-bottom: 0; }

.cell-pair { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cell-pair img { width: 15px; height: 15px; object-fit: contain; flex: 0 0 auto; }
.cell-pair span { font-family: var(--font-display); font-weight: 600; font-size: 10.5px; letter-spacing: 0.045em; overflow: hidden; text-overflow: ellipsis; }
.cell-side { font-family: var(--font-display); font-weight: 600; font-size: 10px; letter-spacing: 0.08em; }
.cell-pnl { text-align: right; }
.cell-duration { color: var(--muted); }
.cell-close { padding-right: 14px; }

.row-close {
  appearance: none;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: border-color 0.13s linear, background-color 0.13s linear;
}
.row-close img { width: 10px; height: 10px; object-fit: contain; opacity: 0.72; }
.row-close:hover { border-color: var(--amber); background: rgba(201, 162, 39, 0.07); }
.row-close:hover img { opacity: 1; }
.row-close:focus-visible { outline: 1px solid var(--amber); outline-offset: 1px; }

.empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.01em;
  color: var(--muted);
  pointer-events: none;
}
.empty.is-hidden { display: none; }

.mobile-tradebar { display: none; }

@media (max-width: 1280px) {
  .terminal { grid-template-columns: 226px minmax(0, 1fr) 280px; }
  .quote-strip { gap: 14px; }
  .brand { padding: 0 13px; }
  .ticker-btn { padding: 0 8px; }
  .ticker-change { display: none; }
}

@media (max-width: 1080px) {
  .terminal { grid-template-columns: 204px minmax(0, 1fr) 260px; }
  .ticker { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .ticker-price { font-size: 11px; }
  .quote-strip { gap: 10px; }
  .quote-value { font-size: 12px; }
  .instrument h1 { font-size: 21px; }
  .pair-emblem { width: 36px; height: 36px; }
}

@media (max-width: 900px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100dvh; }
  .topbar { height: auto; flex: 0 0 auto; flex-wrap: wrap; position: sticky; top: 0; background: #0E0F12; }
  .brand { height: 46px; flex: 1 1 auto; border-right: 0; }
  .brand { gap: 8px; padding: 0 13px; }
  .brand-word { font-size: 14.5px; }
  .brand-mark { width: 16px; height: 23px; }
  .brand-mark i:nth-child(1) { left: 2px; height: 9px; }
  .brand-mark i:nth-child(2) { left: 10px; height: 15px; }
  .sound-toggle { height: 46px; }
  .ticker { order: 3; flex: 1 1 100%; display: flex; overflow-x: auto; scrollbar-width: none; border-top: 1px solid var(--line); }
  .ticker::-webkit-scrollbar { display: none; }
  .ticker-btn { flex: 0 0 132px; height: 44px; border-left: 1px solid var(--line); padding: 0 10px; }
  .ticker-btn:first-child { border-left: 0; }
  .ticker-change { display: inline; }

  .terminal {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 0;
    padding: 10px;
    gap: 10px;
  }
  .chart-panel { order: 1; height: 430px; flex: 0 0 auto; }
  .account { order: 2; flex: 0 0 auto; padding: 12px 14px; }
  .ticket { order: 3; flex: 0 0 auto; overflow: visible; }
  .ticket-scroll { overflow: visible; }
  .positions { order: 4; flex: 0 0 auto; min-height: 150px; max-height: 340px; }

  .account { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: 10px; align-items: start; }
  .account .panel-head { grid-column: 1 / -1; margin-bottom: 10px; }
  .account .stat { margin: 0; }
  .account .stat .label { font-size: 8.5px; letter-spacing: 0.1em; }
  .account .stat .value, .stat-balance .value, .stat .pnl-value { font-size: 13px; letter-spacing: -0.05em; }
  .account .divider, .account .locked { display: none; }
  .stat-mobile-margin { display: block; }

  .positions { max-height: none; }
  .table-wrap { overflow: visible; }

  .ticket .lot-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .ticket .field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
  .ticket .field-pair .label { grid-row: 1; }
  .ticket .field-pair .text-field { grid-row: 2; }
  .ticket .field-pair .label + .text-field + .label { margin-top: 0; }

  .positions-table th:nth-child(1) { width: 26%; }
  .positions-table th:nth-child(2) { width: 11%; }
  .positions-table th:nth-child(3) { width: 17%; }
  .positions-table th:nth-child(4) { width: 17%; }
  .positions-table th:nth-child(5) { width: 9%; }
  .positions-table th:nth-child(6) { width: 18%; }
  .positions-table th:nth-child(7) { width: 14%; }
  .positions-table th:nth-child(8) { width: 44px; }
}

@media (max-width: 760px) {
  :root { --topbar-h: 90px; }
  .terminal { padding: 8px; padding-bottom: 112px; gap: 8px; }
  .ticker-change { display: none; }
  .chart-panel { height: 380px; }
  .chart-head { flex-wrap: wrap; gap: 8px; padding: 9px 12px 6px; }
  .pair-emblem { width: 34px; height: 34px; }
  .instrument h1 { font-size: 20px; }
  .instrument p { font-size: 9.5px; }
  .quote-strip { width: 100%; justify-content: space-between; gap: 8px; padding-top: 2px; }
  .quote { flex-direction: row; align-items: baseline; gap: 5px; }
  .quote .label { font-size: 8px; }
  .quote-value { font-size: 11.5px; }
  .tf-row { padding: 0 8px; }
  .tf-btn { padding: 7px 9px 6px; font-size: 10.5px; }

  .account { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .account .stat .value, .stat-balance .value, .stat .pnl-value { font-size: 13px; }
  .account .stat .label { font-size: 7.5px; letter-spacing: 0.06em; }

  .ticket { padding: 0; overflow: visible; }
  .ticket .panel-head { padding: 12px 12px 0; }
  .ticket-scroll { padding: 0 12px 10px; overflow: visible; }
  .ticket .lot-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lot-btn, .custom-lot { height: 34px; }
  .ticket .field-pair { display: block; }
  .ticket .field-pair .label + .text-field + .label { margin-top: 9px; }
  .ticket .actions { display: none; }
  .current-value { font-size: 19px; }

  .positions { min-height: 140px; max-height: none; }
  .positions-head { padding: 8px 12px; }
  .positions-table { display: block; table-layout: auto; }
  .positions-table thead { display: none; }
  .positions-table tbody { display: block; }
  .positions-table tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 34px;
    grid-template-areas:
      "pair pair side close"
      "entry current lot close"
      "pnl pnl dur close";
    gap: 7px 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    position: relative;
  }
  .positions-table tbody tr:last-child { border-bottom: 0; }
  .positions-table tbody td {
    border: 0;
    padding: 0;
    font-size: 11px;
    overflow: visible;
    text-overflow: clip;
  }
  .positions-table tbody td::before {
    content: attr(data-label);
    display: block;
    font-family: var(--font-text);
    font-weight: 500;
    font-size: 7.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 2px;
  }
  .positions-table tbody td.cell-pair::before,
  .positions-table tbody td.cell-side::before,
  .positions-table tbody td.cell-close::before { display: none; }
  .cell-pair { grid-area: pair; font-size: 12px; }
  .cell-side { grid-area: side; text-align: right; padding-right: 2px; }
  .cell-entry { grid-area: entry; }
  .cell-current { grid-area: current; }
  .cell-lot { grid-area: lot; }
  .cell-pnl { grid-area: pnl; text-align: left; }
  .cell-duration { grid-area: dur; }
  .cell-close { grid-area: close; align-self: start; justify-self: end; padding-right: 0; }
  .row-close { width: 28px; height: 28px; }
  .empty { position: static; min-height: 92px; }

  .mobile-tradebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    background: #0E0F12;
    border-top: 1px solid var(--line);
  }
  .mobile-tradebar .trade-btn { height: 54px; border-radius: 2px; }
  .mobile-tradebar .trade-icon { top: 6px; width: 14px; height: 14px; }
  .mobile-tradebar .trade-word { font-size: 16px; margin-top: 13px; }
  .mobile-tradebar .trade-price { font-size: 9.5px; margin-top: 2px; }
}

@media (max-width: 380px) {
  .ticker-btn { flex-basis: 120px; }
  .account { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 9px; }
  .account .stat .value, .stat-balance .value, .stat .pnl-value { font-size: 17px; }
  .instrument h1 { font-size: 18px; }
}

@media (max-height: 700px) and (min-width: 901px) {
  .terminal { grid-template-rows: minmax(0, 1fr) 168px; }
  .stat { margin-bottom: 8px; }
  .stat-balance .value { font-size: 25px; }
  .stat .value, .stat .pnl-value { font-size: 20px; }
  .ticket .panel-head { padding: 9px 12px 0; margin-bottom: 7px; }
  .ticket-scroll { padding: 0 12px 2px; }
  .field-block .label { margin-bottom: 4px; }
  .lot-btn, .custom-lot, .text-field { height: 27px; }
  .custom-lot { margin-top: 4px; }
  .field-pair { margin-top: 7px; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; gap: 0 8px; }
  .field-pair .label:nth-child(1), .field-pair .label:nth-child(3) { grid-row: 1; margin-top: 0; margin-bottom: 4px; }
  .field-pair .label:nth-child(1) { grid-column: 1; }
  .field-pair .label:nth-child(3) { grid-column: 2; }
  .field-pair .text-field:nth-child(2) { grid-column: 1; grid-row: 2; }
  .field-pair .text-field:nth-child(4) { grid-column: 2; grid-row: 2; }
  .divider { margin: 7px 0; }
  .current-block .label { margin-bottom: 2px; }
  .current-value { font-size: 17px; }
  .actions { padding: 8px 12px 10px; gap: 7px; }
  .trade-btn { height: 56px; }
  .trade-btn .trade-icon { top: 6px; width: 14px; height: 14px; }
  .trade-btn .trade-word { font-size: 16px; margin-top: 12px; }
  .trade-btn .trade-price { font-size: 9.5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
