.page--trades {
  padding-bottom: 4.5rem;
}

.trades-shell {
  position: relative;
  isolation: isolate;
  width: min(calc(100% - 2.5rem), var(--max-content));
  margin: clamp(2rem, 3.4vw, 3rem) auto 0;
  display: grid;
  gap: 1.35rem;
}

.trades-toolbar,
.trades-ledger {
  border-color: var(--outline);
}

.trades-toolbar {
  position: relative;
  z-index: 40;
  overflow: visible;
  padding: 1.15rem 1.2rem 1.2rem;
}

.trades-toolbar__grid {
  display: grid;
  grid-template-columns:
    minmax(0, 2.2fr)
    minmax(13rem, 1.5fr)
    minmax(5.4rem, 0.58fr)
    minmax(5.6rem, 0.62fr)
    minmax(7rem, 0.8fr)
    minmax(6.2rem, 0.72fr)
    minmax(7.6rem, 0.84fr);
  gap: 0.75rem 0.85rem;
  align-items: end;
}

.trades-field {
  min-width: 0;
  align-self: stretch;
}

.trades-field--search {
  min-width: 14rem;
}

.trades-toolbar .search-field {
  gap: 0.46rem;
}

.trades-toolbar .search-field__label {
  min-height: 0.78rem;
  line-height: 1;
  padding-inline-start: 0.08rem;
}

.trades-toolbar .search-field__control {
  min-height: 2.95rem;
}

.trades-toolbar .search-field__control input,
.trades-toolbar .search-field__control select,
.trades-toolbar .detail-select__trigger {
  min-height: 2.95rem;
  padding-inline: 0.9rem;
}

.trades-toolbar .search-field__control--search {
  padding-left: 0;
}

.trades-toolbar .search-field__icon {
  width: 2.7rem;
}

.trades-toolbar .search-field__control--search input {
  padding-left: 0.12rem;
  padding-right: 0.9rem;
}

.trades-toolbar__submit {
  align-self: end;
  width: 100%;
  min-height: 2.95rem;
  border-radius: var(--radius-md);
  border: 0.5px solid rgba(140, 109, 24, 0.34);
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-deep) 100%);
  color: var(--gold-ink);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 0 1.15rem;
  box-shadow:
    inset 0 1px 0 rgba(255, 249, 214, 0.2),
    0 8px 18px rgba(212, 175, 55, 0.1);
  transition: transform 180ms ease, filter 180ms ease, box-shadow 180ms ease;
}

.trades-toolbar__submit:hover {
  transform: translateY(-1px);
  filter: brightness(1.015);
  box-shadow:
    inset 0 1px 0 rgba(255, 249, 214, 0.24),
    0 10px 20px rgba(212, 175, 55, 0.13);
}

.trades-ledger {
  overflow: hidden;
}

.trades-ledger__head,
.trades-ledger__footer {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1rem;
  padding: 1.15rem 1.2rem;
}

.trades-ledger__head {
  border-bottom: 0.5px solid rgba(77, 70, 53, 0.16);
}

.trades-ledger__title {
  display: grid;
  gap: 0;
}

.trades-ledger__title h1 {
  margin: 0;
  font-size: clamp(1.18rem, 1.55vw, 1.42rem);
  font-weight: 760;
  letter-spacing: -0.04em;
}

.trades-ledger__meta,
.trades-ledger__page {
  color: var(--text-dim);
  font-size: 0.74rem;
  padding-inline-start: 0.08rem;
}

.trades-ledger__meta,
.trades-ledger__page,
.trades-kpi__value,
.trade-market__price,
.trade-profit__percent,
.trade-profit__margin,
.trade-age {
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

.trades-ledger__body {
  position: relative;
}

.trades-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
  padding: 1rem 1.15rem 1.18rem;
  border-top: 0.5px solid rgba(77, 70, 53, 0.16);
  background:
    linear-gradient(180deg, rgba(22, 22, 23, 0.42), rgba(14, 14, 15, 0.16)),
    radial-gradient(circle at top left, rgba(242, 202, 80, 0.08), transparent 40%);
  align-items: stretch;
}

.trades-kpi {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0.38rem;
  align-content: stretch;
  padding: 0.95rem 1rem 0.98rem;
  border-radius: calc(var(--radius-md) + 0.08rem);
  border: 0.5px solid rgba(77, 70, 53, 0.18);
  background:
    linear-gradient(180deg, rgba(29, 29, 30, 0.72), rgba(17, 17, 18, 0.48)),
    rgba(15, 15, 16, 0.38);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.trades-kpi__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.trades-kpi--freshness .trades-kpi__head {
  justify-content: flex-start;
}

.trades-kpi__eyebrow {
  color: var(--text-dim);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.trades-kpi__value {
  margin: 0;
  display: block;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  font-weight: 780;
  letter-spacing: -0.05em;
  line-height: 0.96;
  text-wrap: balance;
}

.trades-kpi__note {
  color: var(--text-muted);
  font-size: 0.74rem;
  line-height: 1.45;
  min-height: 2.1em;
}

.trades-kpi__note:empty {
  visibility: hidden;
}

.trades-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.55rem;
  padding: 0.18rem 0.58rem;
  border-radius: 999px;
  border: 0.5px solid rgba(77, 70, 53, 0.26);
  background: rgba(19, 19, 20, 0.72);
  color: var(--text-dim);
  font-size: 0.62rem;
  font-weight: 820;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.trades-status-pill.is-live {
  border-color: rgba(78, 222, 163, 0.34);
  background: rgba(78, 222, 163, 0.14);
  color: var(--green);
}

.trades-status-pill.is-warm {
  border-color: rgba(242, 202, 80, 0.34);
  background: rgba(242, 202, 80, 0.14);
  color: var(--gold);
}

.trades-status-pill.is-cold {
  border-color: rgba(190, 184, 168, 0.24);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

.trades-status-pill.is-stale {
  border-color: rgba(255, 143, 143, 0.3);
  background: rgba(255, 143, 143, 0.12);
  color: #ffb4b4;
}

.trades-table-wrap {
  overflow-x: auto;
}

.trades-table {
  width: 100%;
  min-width: 78rem;
  border-collapse: collapse;
  table-layout: fixed;
}

.trades-table thead th:nth-child(1),
.trade-row td:nth-child(1) {
  width: 34%;
}

.trades-table thead th:nth-child(2),
.trade-row td:nth-child(2),
.trades-table thead th:nth-child(3),
.trade-row td:nth-child(3) {
  width: 15%;
}

.trades-table thead th:nth-child(4),
.trade-row td:nth-child(4) {
  width: 18%;
}

.trades-table thead th:nth-child(5),
.trade-row td:nth-child(5) {
  width: 10%;
}

.trades-table thead th {
  padding: 0.95rem 1.2rem;
  border-bottom: 0.5px solid rgba(77, 70, 53, 0.16);
  color: var(--text-dim);
  font-size: 0.62rem;
  font-weight: 760;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-align: left;
}

.trades-table thead th:last-child {
  width: 4.5rem;
  text-align: right;
}

.trades-table__sort {
  white-space: nowrap;
}

.trades-table__sort-button {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  transition: color 160ms ease, transform 160ms ease;
}

.trades-table__sort-button:hover,
.trades-table__sort-button:focus-visible {
  color: var(--text);
}

.trades-table__sort-button:focus-visible {
  outline: none;
}

.trades-table__sort-button:focus-visible .trades-table__sort-indicator,
.trades-table__sort-button:hover .trades-table__sort-indicator {
  border-color: rgba(242, 202, 80, 0.28);
  background: rgba(242, 202, 80, 0.12);
}

.trades-table__sort.is-active,
.trades-table__sort-button.is-active {
  color: var(--text);
}

.trades-table__sort-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1rem;
  min-height: 1.1rem;
  border-radius: 999px;
  border: 0.5px solid rgba(77, 70, 53, 0.18);
  background: rgba(255, 255, 255, 0.03);
  color: var(--gold);
  font-size: 0.56rem;
  line-height: 1;
}

.trades-table__sort.is-active .trades-table__sort-indicator,
.trades-table__sort-button.is-active .trades-table__sort-indicator {
  border-color: rgba(242, 202, 80, 0.3);
  background: rgba(242, 202, 80, 0.14);
  color: var(--gold);
}

.trade-row {
  transition: background-color 160ms ease;
}

.trade-row:hover {
  background: rgba(255, 255, 255, 0.018);
}

.trade-row td {
  padding: 0.92rem 1rem;
  border-bottom: 0.5px solid rgba(77, 70, 53, 0.1);
  vertical-align: middle;
}

.trade-row:last-child td {
  border-bottom: 0;
}

.trade-item {
  display: flex;
  align-items: center;
  gap: 0.78rem;
  min-width: 0;
}

.trade-item__icon {
  position: relative;
  flex: 0 0 auto;
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 0.72rem;
  overflow: hidden;
  border: 0.5px solid rgba(77, 70, 53, 0.26);
  background:
    radial-gradient(circle at top right, rgba(242, 202, 80, 0.1), transparent 48%),
    rgba(14, 14, 15, 0.86);
}

.trade-item__icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.trade-item__badge {
  position: absolute;
  right: 0.28rem;
  bottom: 0.28rem;
  min-width: 1.8rem;
  padding: 0.1rem 0.32rem;
  border-radius: 999px;
  background: rgba(242, 202, 80, 0.9);
  color: var(--gold-ink);
  font-size: 0.58rem;
  font-weight: 820;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-align: center;
  box-shadow: 0 6px 14px rgba(212, 175, 55, 0.16);
}

.trade-item__copy {
  display: grid;
  gap: 0.16rem;
  min-width: 0;
}

.trade-item__copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.92rem;
  font-weight: 720;
}

.trade-item__copy small {
  color: var(--text-dim);
  font-size: 0.69rem;
  font-weight: 620;
  letter-spacing: 0.03em;
}

.trade-market {
  display: grid;
  gap: 0.16rem;
  min-width: 0;
  width: 100%;
}

.trade-market__price {
  font-size: 0.96rem;
  font-weight: 740;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.trade-market__price--sell,
.trade-market--sell .trade-market__price {
  color: var(--green);
}

.trade-market__city {
  display: block;
  color: var(--text-dim);
  font-size: 0.68rem;
  font-weight: 620;
  letter-spacing: 0.03em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trade-profit {
  display: grid;
  gap: 0.4rem;
  min-width: 11.5rem;
  width: 100%;
}

.trade-profit__head {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
}

.trade-profit__percent {
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0.74;
  white-space: nowrap;
}

.trade-profit__track {
  height: 0.24rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.trade-profit__fill {
  height: 100%;
  min-width: 0.75rem;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(78, 222, 163, 0.78), var(--green));
  box-shadow: 0 0 6px rgba(78, 222, 163, 0.12);
}

.trade-profit__fill.is-negative {
  background: linear-gradient(90deg, rgba(255, 143, 143, 0.8), #ff8f8f);
  box-shadow: 0 0 6px rgba(255, 143, 143, 0.12);
}

.trade-profit__margin {
  margin-left: auto;
  text-align: right;
  font-size: 1rem;
  font-weight: 780;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.trade-age {
  white-space: nowrap;
  font-size: 0.81rem;
  font-weight: 700;
}

.trade-action {
  display: flex;
  justify-content: flex-end;
}

.trade-action .icon-button {
  width: 2.4rem;
  height: 2.4rem;
}

.trade-action .icon-button .icon-svg {
  width: 1.1rem;
  height: 1.1rem;
}

.gate-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    linear-gradient(180deg, rgba(12, 12, 13, 0.26), rgba(12, 12, 13, 0.72)),
    rgba(19, 19, 20, 0.44);
  backdrop-filter: blur(4px);
}

.gate-card {
  width: min(100%, 25rem);
  padding: 1.35rem;
  border-radius: var(--radius-lg);
  border: 0.5px solid rgba(77, 70, 53, 0.26);
  background: rgba(20, 20, 21, 0.92);
  box-shadow: var(--shadow-soft);
  text-align: center;
}

.gate-card__eyebrow {
  display: block;
  margin-bottom: 0.55rem;
  color: var(--text-dim);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.trades-kpi--freshness .trades-status-pill {
  display: none;
}

.gate-card strong {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--gold);
  font-size: 1.05rem;
  font-weight: 820;
}

.gate-card p {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.trades-ledger__body.is-locked .trades-table-wrap {
  filter: blur(2px);
}

.trades-ledger__footer {
  border-top: 0.5px solid rgba(77, 70, 53, 0.16);
}

.trades-ledger__pager {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.trades-pager__button {
  min-height: 2.15rem;
  padding: 0 0.9rem;
  border-radius: 999px;
  border: 0.5px solid rgba(77, 70, 53, 0.28);
  background: rgba(14, 14, 15, 0.7);
  color: rgba(229, 226, 227, 0.72);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: color 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.trades-pager__button:hover:not(:disabled) {
  color: var(--gold);
  border-color: rgba(212, 175, 55, 0.32);
}

.trades-pager__button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

@media (max-width: 1180px) {
  .trades-toolbar__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .trades-field--search,
  .trades-toolbar__submit {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .trades-shell {
    width: min(calc(100% - 1.5rem), var(--max-content));
  }

  .trades-kpi-row {
    grid-template-columns: 1fr;
  }

  .trades-ledger__head,
  .trades-ledger__footer {
    flex-direction: column;
    align-items: stretch;
  }

}

@media (max-width: 680px) {
  .trades-toolbar__grid {
    grid-template-columns: 1fr;
  }

  .trades-kpi__head {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .trades-table {
    min-width: 58rem;
  }
}
