/* Панель «Торговля» — верхнее меню в стиле TMM (слева, тёмный фон, активный блок) */

.trading-page {
  --trading-bar-bg: #161a22;
  --trading-bar-active: #1c2330;
  --trading-bar-hover: #1a2029;
  --trading-brand-green: #3dba6a;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
}

.trading-topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  height: 40px;
  background: var(--trading-bar-bg);
  border-bottom: 1px solid #232833;
}

.trading-topbar__inner {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  height: 100%;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
}

.trading-topbar__left {
  display: flex;
  align-items: stretch;
  min-width: 0;
  flex: 1 1 auto;
}

.trading-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  padding: 0 14px 0 12px;
  border-right: 1px solid #232833;
}

.trading-brand__mark {
  display: flex;
  align-items: center;
  color: var(--trading-brand-green);
  line-height: 0;
}

.trading-brand__icon {
  display: block;
}

.trading-brand__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.05;
}

.trading-brand__line {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--trading-brand-green);
  text-transform: uppercase;
}

.trading-nav {
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  flex: 0 1 auto;
  gap: 0;
  margin: 0;
  padding: 0;
}

.trading-nav__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  height: 100%;
  margin: 0;
  padding: 0 18px;
  border: none;
  border-radius: 0;
  outline: none;
  box-shadow: none;
  background: transparent;
  color: rgba(231, 234, 240, 0.92);
  font: inherit;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
}

.trading-nav__item:focus,
.trading-nav__item:focus-visible,
.trading-nav__item:active {
  outline: none;
  box-shadow: none;
}

.trading-nav__item:hover {
  background: var(--trading-bar-hover);
  color: #fff;
  filter: none;
}

.trading-nav__item.is-active {
  background: var(--trading-bar-active);
  color: #fff;
  filter: none;
}

.trading-nav__item.is-active:hover {
  background: var(--trading-bar-active);
}

.trading-topbar__wallet {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
  padding: 0 16px 0 20px;
  margin-left: auto;
  border-left: 1px solid #232833;
  font-variant-numeric: tabular-nums;
}

.trading-wallet__item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 5.5rem;
}

.trading-wallet__label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(231, 234, 240, 0.45);
  white-space: nowrap;
}

.trading-wallet__value {
  font-size: 13px;
  font-weight: 600;
  color: #e7eaf0;
  white-space: nowrap;
}

.trading-wallet__value.is-loading {
  color: rgba(231, 234, 240, 0.35);
}

.trading-wallet__value.is-error {
  color: #ef5350;
  font-size: 11px;
  font-weight: 500;
  max-width: 10rem;
  white-space: normal;
  text-align: right;
}

.trading-main {
  max-width: 1100px;
  margin: 0;
  padding: 24px 20px 48px;
}

.trading-panel {
  display: none;
  padding: 20px 0 32px;
}

.trading-panel.is-active {
  display: block;
}

.trading-panel__heading {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 600;
}

.trading-panel__stub {
  margin: 0;
  font-size: 14px;
  color: var(--fg);
  line-height: 1.5;
}

.trading-panel__stub--muted {
  color: var(--fg-dim);
  font-size: 13px;
}

/* —— Сделки: таблица в стиле TMM —— */
.trading-page:has(.trading-panel--trades.is-active) {
  overflow: hidden;
}

.trading-panel--trades {
  padding: 0;
  max-width: none;
}

.trading-main:has(.trading-panel--trades.is-active) {
  max-width: none;
  margin: 0;
  padding: 0;
  height: calc(100vh - 40px);
  overflow: hidden;
}

.trading-panel--trades.is-active {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.trade-deals {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
}

.trade-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  padding: 8px 12px;
  background: #12151c;
  border-bottom: 1px solid #232833;
}

.trade-toolbar__left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.trade-toolbar__period-wrap {
  position: relative;
}

.trade-toolbar__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid #2a3140;
  border-radius: 4px;
  background: #1a1f28;
  color: #e7eaf0;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.trade-toolbar__btn:hover {
  background: #222833;
  border-color: #3a4356;
}

.trade-toolbar__btn--primary {
  background: #2a4a8a;
  border-color: #3d7cf5;
}

.trade-toolbar__btn--primary:hover {
  background: #3258a0;
}

.trade-toolbar__caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid rgba(231, 234, 240, 0.55);
}

.trade-ticker-combo {
  position: relative;
  width: 140px;
}

.trade-ticker-combo__input {
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border: 1px solid #2a3140;
  border-radius: 4px;
  background: #1a1f28;
  color: #e7eaf0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.trade-ticker-combo__input::placeholder {
  color: rgba(231, 234, 240, 0.45);
  font-weight: 400;
}

.trade-ticker-combo__input:focus {
  outline: none;
  border-color: #3d7cf5;
  box-shadow: 0 0 0 1px rgba(61, 124, 245, 0.35);
}

.trade-ticker-combo__list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 300;
  min-width: 100%;
  max-height: 220px;
  margin: 0;
  padding: 4px 0;
  overflow: auto;
  list-style: none;
  border: 1px solid #2a3140;
  border-radius: 6px;
  background: #1a1f28;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.trade-ticker-combo__list[hidden] {
  display: none !important;
}

.trade-ticker-combo__item {
  padding: 7px 12px;
  font-size: 12px;
  color: #e7eaf0;
  cursor: pointer;
  white-space: nowrap;
}

.trade-ticker-combo__item:hover,
.trade-ticker-combo__item.is-highlighted {
  background: #252d3a;
}

.trade-ticker-combo__item.is-selected {
  color: #3d7cf5;
}

.trade-toolbar__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-left: auto;
  padding: 0;
  border: 1px solid #2a3140;
  border-radius: 4px;
  background: #1a1f28;
  color: rgba(231, 234, 240, 0.75);
  cursor: pointer;
}

.trade-toolbar__icon-btn:hover {
  color: #e7eaf0;
  background: #222833;
}

.trade-period-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 300;
  min-width: 200px;
  padding: 6px 0;
  border: 1px solid #2a3140;
  border-radius: 6px;
  background: #1a1f28;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.trade-period-menu__item {
  display: block;
  width: 100%;
  padding: 8px 14px;
  border: none;
  background: transparent;
  color: #e7eaf0;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.trade-period-menu__item:hover,
.trade-period-menu__item.is-active {
  background: #252d3a;
  color: #fff;
}

.trade-period-menu__custom {
  padding: 10px 12px 8px;
  border-top: 1px solid #2a3140;
}

.trade-period-menu__field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: rgba(231, 234, 240, 0.7);
}

.trade-period-menu__field input {
  flex: 1;
  height: 28px;
  padding: 0 8px;
  border: 1px solid #2a3140;
  border-radius: 4px;
  background: #12151c;
  color: #e7eaf0;
  font-size: 12px;
}

.trade-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.55);
}

.trade-modal-backdrop[hidden] {
  display: none !important;
}

.trade-modal {
  width: 100%;
  max-width: 360px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  border: 1px solid #2a3140;
  border-radius: 8px;
  background: #1a1f28;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.trade-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #2a3140;
}

.trade-modal__title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #e7eaf0;
}

.trade-modal__close {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: rgba(231, 234, 240, 0.6);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.trade-modal__close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #e7eaf0;
}

.trade-modal__body {
  flex: 1;
  overflow: auto;
  padding: 12px 16px;
}

.trade-modal__footer {
  padding: 12px 16px;
  border-top: 1px solid #2a3140;
  text-align: right;
}

.trade-columns-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 13px;
  color: #e7eaf0;
  cursor: pointer;
}

.trade-columns-item input {
  width: 16px;
  height: 16px;
  accent-color: #3d7cf5;
}

.trade-deals-th-inner {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
}

.trade-deals-th-drag {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  padding: 2px 1px;
  color: rgba(231, 234, 240, 0.35);
  cursor: grab;
  touch-action: none;
}

.trade-deals-th-drag:hover {
  color: rgba(231, 234, 240, 0.7);
}

.trade-deals-th-drag.is-dragging,
.trade-deals-th--movable.is-dragging {
  opacity: 0.5;
}

.trade-deals-th-drag.is-dragging {
  cursor: grabbing;
}

.trade-deals-th-drag__icon {
  display: block;
}

.trade-deals-th--movable.is-drag-over {
  box-shadow: inset 0 -2px 0 #3d7cf5;
}

.trade-deals-th-inner .trade-deals-th-btn {
  min-width: 0;
}

.trade-deals__scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border-top: 1px solid #232833;
  scrollbar-width: thin;
}

.trade-deals-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.trade-deals-table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 10px 12px;
  background: #12151c;
  border-bottom: 1px solid #232833;
  color: rgba(231, 234, 240, 0.55);
  font-size: 11px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}

.trade-deals-th-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.trade-deals-th-btn:hover {
  color: #e7eaf0;
}

.trade-deals-th-btn:focus-visible {
  outline: 1px solid #3d7cf5;
  outline-offset: 2px;
  border-radius: 2px;
}

.trade-deals-th__label {
  pointer-events: none;
}

.trade-deals-table tbody tr.is-open {
  background: #181e28;
}

.trade-deals-table tbody tr.is-open:hover {
  background: #1c2330;
}

.trade-deals-excursion {
  font-size: 11px;
  font-weight: 600;
  color: rgba(231, 234, 240, 0.85);
}

.trade-deals-sort {
  position: relative;
  flex-shrink: 0;
  width: 8px;
  height: 12px;
  pointer-events: none;
}

.trade-deals-sort::before,
.trade-deals-sort::after {
  content: '';
  position: absolute;
  left: 0;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  opacity: 0.3;
}

.trade-deals-sort::before {
  top: 0;
  border-bottom: 5px solid #8b93a7;
}

.trade-deals-sort::after {
  bottom: 0;
  border-top: 5px solid #8b93a7;
}

.trade-deals-th-btn.is-sorted-asc .trade-deals-sort::before {
  opacity: 1;
  border-bottom-color: #3d7cf5;
}

.trade-deals-th-btn.is-sorted-asc .trade-deals-sort::after {
  opacity: 0.15;
}

.trade-deals-th-btn.is-sorted-desc .trade-deals-sort::after {
  opacity: 1;
  border-top-color: #3d7cf5;
}

.trade-deals-th-btn.is-sorted-desc .trade-deals-sort::before {
  opacity: 0.15;
}

.trade-deals-table tbody tr:first-child td {
  padding-top: 14px;
}

.trade-deals-table tbody tr {
  background: #161a22;
  border-left: 3px solid transparent;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.trade-deals-table tbody tr:hover {
  background: #1a1f28;
  border-left-color: #3d7cf5;
}

.trade-deals-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #1e232d;
  color: #e7eaf0;
  vertical-align: middle;
  white-space: nowrap;
}

.trade-deals-table__col-expand {
  width: 36px;
  padding-left: 14px !important;
  padding-right: 0 !important;
}

.trade-deals-expand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: rgba(231, 234, 240, 0.4);
  cursor: pointer;
}

.trade-deals-expand:hover {
  color: rgba(231, 234, 240, 0.85);
  background: rgba(255, 255, 255, 0.06);
}

.trade-deals-expand svg {
  display: block;
  width: 14px;
  height: 14px;
}

.trade-deals-expand.is-expanded {
  color: #3d7cf5;
  background: rgba(61, 124, 245, 0.12);
}

.trade-deals-detail td {
  padding: 0 !important;
  border-bottom: 1px solid #232833;
  background: #12151c;
  white-space: normal;
}

.trade-deals-detail__panel {
  padding: 12px 14px 16px;
}

.trade-deals-detail__cols {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 14px;
  align-items: stretch;
  min-height: 360px;
}

.trade-deals-detail__chart-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.trade-deals-detail__side-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.trade-detail-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.trade-detail-chart-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.trade-detail-chart-title--long {
  color: #3dba6a;
}

.trade-detail-chart-title--short {
  color: #ef5350;
}

.trade-detail-tf-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.trade-detail-tf-btn {
  height: 24px;
  padding: 0 8px;
  border: 1px solid #2a3140;
  border-radius: 3px;
  background: #1a1f28;
  color: rgba(231, 234, 240, 0.65);
  font-size: 11px;
  cursor: pointer;
}

.trade-detail-tf-btn:hover {
  color: #e7eaf0;
  border-color: #3a4356;
}

.trade-detail-tf-btn.is-active {
  color: #e7eaf0;
  border-color: #3d7cf5;
  background: rgba(61, 124, 245, 0.15);
}

.trade-detail-chart-wrap {
  flex: 1;
  min-height: 320px;
  position: relative;
  border: 1px solid #232833;
  border-radius: 6px;
  overflow: hidden;
  background: #0f1115;
}

.trade-detail-chart {
  width: 100%;
  height: 100%;
  min-height: 320px;
}

.trade-detail-chart-status {
  position: absolute;
  left: 12px;
  bottom: 10px;
  margin: 0;
  font-size: 12px;
  color: rgba(231, 234, 240, 0.55);
  pointer-events: none;
}

.trade-detail-chart-status.is-error {
  color: #ef5350;
}

.trade-detail-summary-wrap {
  flex-shrink: 0;
}

.trade-detail-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 10px 12px;
  border: 1px solid #232833;
  border-radius: 6px;
  background: #1a1f28;
  font-size: 12px;
}

.trade-detail-summary__item {
  white-space: nowrap;
}

.trade-detail-summary__label {
  color: rgba(231, 234, 240, 0.5);
}

.trade-detail-summary__lock {
  opacity: 0.85;
}

.trade-detail-orders-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid #232833;
  border-radius: 6px;
  background: #1a1f28;
}

.trade-detail-orders-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.trade-detail-orders-table th {
  position: sticky;
  top: 0;
  padding: 8px 10px;
  background: #12151c;
  border-bottom: 1px solid #232833;
  color: rgba(231, 234, 240, 0.45);
  font-size: 10px;
  font-weight: 600;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.trade-detail-orders-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #1e232d;
  color: #e7eaf0;
}

.trade-detail-orders__side {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.trade-detail-orders__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.trade-detail-orders__side--entry .trade-detail-orders__dot {
  background: #3d7cf5;
}

.trade-detail-orders__side--exit .trade-detail-orders__dot {
  background: #f0b429;
}

.trade-detail-orders__empty,
.trade-detail-error {
  margin: 0;
  padding: 16px 12px;
  font-size: 12px;
  color: rgba(231, 234, 240, 0.5);
}

.trade-detail-error {
  color: #ef5350;
}

@media (max-width: 1100px) {
  .trade-deals-detail__cols {
    grid-template-columns: 1fr;
  }
  .trade-detail-chart-wrap {
    min-height: 280px;
  }
}

.trade-deals-ticker {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.trade-deals-dt {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.25;
  white-space: normal;
}

.trade-deals-dt__date {
  font-size: 11px;
  color: rgba(231, 234, 240, 0.5);
}

.trade-deals-dt__time {
  font-size: 12px;
  color: #e7eaf0;
}

.trade-deals-price {
  font-weight: 500;
}

.trade-deals-duration {
  color: rgba(231, 234, 240, 0.85);
}

.trade-deals-side {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.trade-deals-side--long {
  color: #3dba6a;
}

.trade-deals-side--short {
  color: #ef5350;
}

.trade-deals-pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
}

.trade-deals-pill--loss {
  background: rgba(183, 28, 28, 0.45);
  color: #ffcdd2;
}

.trade-deals-pill--gain {
  background: rgba(27, 94, 32, 0.45);
  color: #c8e6c9;
}

.trade-deals-pill--flat {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(231, 234, 240, 0.75);
}

.trade-deals-leverage {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #e7eaf0;
}

.trade-deals-leverage__lock {
  color: #f0b429;
  line-height: 0;
}

.trade-deals-leverage__lock svg {
  width: 14px;
  height: 14px;
}

.trade-deals__status {
  margin: 0;
  padding: 16px 20px;
  font-size: 13px;
  color: var(--fg-dim);
}

.trade-deals__status.is-error {
  color: #ef5350;
}

.trade-deals-table tbody tr.is-empty td {
  padding: 32px 20px;
  text-align: center;
  color: var(--fg-dim);
  border: none;
}

@media (max-width: 640px) {
  .trading-topbar {
    height: auto;
    min-height: 40px;
  }
  .trading-topbar__inner {
    flex-wrap: nowrap;
  }
  .trading-nav__item {
    padding: 0 14px;
    font-size: 12px;
  }
}
