.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.market-terminal {
  display: grid;
  grid-template-rows: minmax(400px, 2fr) minmax(188px, 1fr);
  min-height: 600px;
  height: auto;
  max-height: none;
  margin-top: 0;
  overflow: hidden;
  background: #050505;
  box-shadow: var(--shadow);
}

.market-terminal .market-workspace {
  min-height: 0;
  height: auto;
  max-height: none;
  margin-top: 0;
  box-shadow: none;
}

.market-terminal .chart-wrap {
  min-height: 0;
}

.trading-activity {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  background: #050505;
  border: 1px solid var(--line-strong);
  border-top: 0;
}

.trading-activity-header {
  display: flex;
  min-height: 42px;
  align-items: stretch;
  justify-content: space-between;
  background: #080808;
  border-bottom: 1px solid var(--line-strong);
}

.trading-activity-tabs {
  display: flex;
  min-width: 0;
  align-items: stretch;
  padding: 0 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.trading-activity-tabs::-webkit-scrollbar {
  display: none;
}

.trading-activity-tabs button {
  position: relative;
  min-width: max-content;
  padding: 0 14px;
  color: #939393;
  background: transparent;
  border: 0;
  font-family: var(--font-display);
  font-size: 14px;
  cursor: pointer;
}

.trading-activity-tabs button::after {
  position: absolute;
  right: 13px;
  bottom: 0;
  left: 13px;
  height: 2px;
  content: "";
  background: transparent;
}

.trading-activity-tabs button:hover {
  color: #d7d7d7;
}

.trading-activity-tabs button[aria-selected="true"] {
  color: #ffffff;
  font-weight: 600;
}

.trading-activity-tabs button[aria-selected="true"]::after {
  background: #f2f2f2;
}

.trading-activity-context {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  color: var(--ink-soft);
  border-left: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: nowrap;
}

.trading-activity-context strong {
  color: #d6d6d6;
  font-weight: 500;
}

#trading-activity-state {
  color: #777777;
}

.trading-activity-context button {
  height: 26px;
  padding: 0 8px;
  color: #c9c9c9;
  background: #171717;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
}

.trading-activity-context button:hover {
  color: #ffffff;
  background: #222222;
}

.trading-activity-context button:disabled {
  cursor: wait;
  opacity: 0.5;
}

.trading-activity-body {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.trading-activity-table-wrap {
  width: 100%;
  height: 100%;
  min-width: 100%;
  overflow: auto;
  scrollbar-width: none;
}

.trading-activity-table-wrap::-webkit-scrollbar {
  display: none;
}

.trading-activity-table {
  width: 100%;
  min-width: 1440px;
  border-collapse: collapse;
  table-layout: fixed;
  font-family: var(--font-mono);
  font-size: 12px;
  border: 1px solid #242424;
}

.trading-activity-table th {
  position: sticky;
  z-index: 1;
  top: 0;
  height: 32px;
  padding: 0 9px;
  color: #777777;
  background: #0b0b0b;
  border-right: 1px solid #242424;
  border-bottom: 1px solid #242424;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
}

.trading-activity-table th:last-child,
.trading-activity-table td:last-child {
  border-right: 0;
}

.trading-activity-table th {
  position: sticky;
}

.trading-column-resizer {
  position: absolute;
  z-index: 2;
  top: 0;
  right: -4px;
  width: 9px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}

.trading-column-resizer::after {
  position: absolute;
  top: 6px;
  right: 4px;
  bottom: 6px;
  width: 1px;
  content: "";
  background: transparent;
}

.trading-column-resizer:hover::after,
.trading-column-resizer.is-dragging::after {
  background: #b8b8b8;
}

body.is-resizing-trading-column {
  cursor: col-resize;
  user-select: none;
}

.trading-activity-table td {
  height: 36px;
  padding: 5px 9px;
  overflow: hidden;
  color: #d4d4d4;
  border-right: 1px solid #202020;
  border-bottom: 1px solid #202020;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.trading-activity-table tbody tr:hover td {
  background: #101010;
}

.trading-activity-table tbody tr[data-backtest-target="true"] {
  cursor: pointer;
}

.trading-activity-table tbody tr.is-chart-target td {
  animation: chart-target-highlight 1.8s ease-out;
}

.trading-activity-table td.is-strong {
  color: #ffffff;
  font-weight: 600;
}

.trading-activity-table td.is-positive {
  color: var(--price-up);
}

.trading-activity-table td.is-negative {
  color: var(--price-down);
}

.trading-activity-table td.is-demo {
  color: #e5b94f;
}

.trading-activity-table td.is-muted {
  color: #777777;
}

.trading-activity-table td.is-buy,
.trading-activity-table td.is-live-order {
  color: var(--green);
}

.trading-activity-table td.is-sell {
  color: var(--red);
}

.trading-activity-table td.is-order-id {
  color: #8b8b8b;
}

.related-orders-trigger {
  min-height: 24px;
  padding: 0 8px;
  color: #d8d8d8;
  background: #151515;
  border: 1px solid #333333;
  border-radius: 2px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.related-orders-trigger:hover {
  color: #ffffff;
  background: #202020;
  border-color: #555555;
}

.position-action-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.position-action-group button {
  min-height: 26px;
  padding: 0 7px;
  color: #d4d4d4;
  background: #151515;
  border: 1px solid #303030;
  border-radius: 2px;
  font-family: var(--font-display);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.position-action-group button:hover {
  color: #ffffff;
  background: #202020;
  border-color: #4a4a4a;
}

.position-action-group button.is-danger {
  color: #ff7a87;
  border-color: rgba(240, 79, 95, 0.42);
}

.position-action-group button:disabled {
  cursor: wait;
  opacity: 0.48;
}

.trading-activity-table td.is-action-cell {
  padding-right: 4px;
  padding-left: 4px;
}

.order-action-group button {
  padding-right: 5px;
  padding-left: 5px;
}

.position-tpsl-dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  color: var(--ink);
  background: #080808;
  border: 1px solid #333333;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.72);
}

.position-tpsl-dialog::backdrop {
  background: rgba(0, 0, 0, 0.76);
}

.position-tpsl-shell header,
.position-tpsl-shell footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #262626;
}

.position-tpsl-shell header span {
  color: #777777;
  font-size: 12px;
}

.position-tpsl-shell h2 {
  margin: 3px 0 0;
  font-size: 18px;
}

.position-tpsl-shell button {
  min-height: 32px;
  padding: 0 12px;
  color: #d0d0d0;
  background: #151515;
  border: 1px solid #303030;
  border-radius: 2px;
  font-size: 13px;
  cursor: pointer;
}

.position-tpsl-shell button.is-primary {
  color: #050505;
  background: #f0f0f0;
  border-color: #f0f0f0;
  font-weight: 600;
}

.position-tpsl-summary,
.position-tpsl-hint,
.position-tpsl-message {
  margin: 0;
  padding: 12px 16px 0;
  color: #a7a7a7;
  font-family: var(--font-mono);
  font-size: 12px;
}

.position-tpsl-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 14px 16px 0;
}

.position-tpsl-fields label {
  display: grid;
  gap: 7px;
  color: #c7c7c7;
  font-size: 13px;
}

.order-amend-fields label[hidden] {
  display: none;
}

.position-tpsl-fields input {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  color: #ffffff;
  background: #111111;
  border: 1px solid #303030;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 14px;
}

.position-tpsl-fields input:focus {
  outline: 2px solid rgba(0, 192, 135, 0.28);
  border-color: #777777;
}

.position-tpsl-hint {
  color: #777777;
}

.position-tpsl-message {
  min-height: 30px;
  color: #f04f5f;
}

.position-tpsl-shell footer {
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
  border-top: 1px solid #262626;
  border-bottom: 0;
}

.related-orders-dialog {
  width: min(860px, calc(100vw - 32px));
  padding: 0;
  color: var(--ink);
  background: #080808;
  border: 1px solid #333333;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.72);
}

.related-orders-dialog::backdrop {
  background: rgba(0, 0, 0, 0.76);
}

.related-orders-shell header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #262626;
}

.related-orders-shell header span {
  color: #777777;
  font-size: 12px;
}

.related-orders-shell h2 {
  margin: 3px 0 0;
  font-size: 18px;
}

.related-orders-shell button {
  min-height: 32px;
  padding: 0 12px;
  color: #d0d0d0;
  background: #151515;
  border: 1px solid #303030;
  border-radius: 2px;
  font-size: 13px;
  cursor: pointer;
}

.related-orders-summary {
  margin: 0;
  padding: 12px 16px;
  color: #a7a7a7;
  border-bottom: 1px solid #262626;
  font-family: var(--font-mono);
  font-size: 12px;
}

.related-orders-table-wrap {
  max-height: min(56vh, 520px);
  overflow: auto;
}

.related-orders-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
}

.related-orders-table th,
.related-orders-table td {
  padding: 9px 10px;
  overflow-wrap: anywhere;
  text-align: center;
  border-right: 1px solid #262626;
  border-bottom: 1px solid #262626;
}

.related-orders-table th:last-child,
.related-orders-table td:last-child {
  border-right: 0;
}

.related-orders-table th {
  position: sticky;
  z-index: 1;
  top: 0;
  color: #a7a7a7;
  background: #101010;
  font-weight: 500;
}

.related-orders-table td.is-positive,
.related-orders-table td.is-live-order {
  color: var(--green);
}

.related-orders-table td.is-muted {
  color: #858585;
}

.related-orders-table td.is-negative {
  color: var(--red);
}

.related-orders-table td {
  color: #d8d8d8;
}

.related-orders-table td.is-order-id {
  color: #9e9e9e;
}

.related-orders-table td.is-muted {
  color: #666666;
}

@keyframes chart-target-highlight {
  0%, 35% {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.13);
    box-shadow: inset 0 1px #686868, inset 0 -1px #686868;
  }
  100% {
    background: transparent;
    box-shadow: inset 0 1px transparent, inset 0 -1px transparent;
  }
}

.trading-activity-empty {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 6px;
  padding: 18px;
  text-align: center;
}

.trading-activity-empty[hidden] {
  display: none;
}

.trading-activity-empty strong {
  color: #b8b8b8;
  font-size: 14px;
  font-weight: 500;
}

.trading-activity-empty span {
  max-width: min(720px, 90%);
  color: #6f6f6f;
  font-family: var(--font-mono);
  font-size: 12px;
}

@media (max-width: 800px) {
  .market-terminal {
    display: block;
    min-height: 0;
    height: auto;
    max-height: none;
    margin-top: 8px;
    overflow: visible;
  }

  .market-terminal .market-workspace {
    margin-top: 0;
  }

  .trading-activity {
    min-height: 240px;
  }

  .trading-activity-context span {
    display: none;
  }
}

@media (max-width: 520px) {
  .trading-activity-header {
    min-height: 44px;
  }

  .trading-activity-tabs {
    padding-inline: 3px;
  }

  .trading-activity-tabs button {
    padding-inline: 10px;
  }

  .trading-activity-tabs button::after {
    right: 9px;
    left: 9px;
  }

  .trading-activity-context {
    padding-inline: 8px;
  }
}
