/* Isolated prototype for #markettest. Existing #game-market styles are untouched. */

body.markettest-mode #hero,
body.markettest-mode #subgroupTabs,
body.markettest-mode .content-stage > .toolbar {
  display: none !important;
}

#markettestView {
  --mt-paper: #efe0bf;
  --mt-paper-light: #f8efd9;
  --mt-paper-row: rgba(255, 250, 234, 0.46);
  --mt-ink: #2c2118;
  --mt-muted: #75624d;
  --mt-blood: #812b25;
  --mt-blood-soft: rgba(129, 43, 37, 0.09);
  --mt-gold: #997344;
  --mt-line: rgba(88, 66, 42, 0.22);
  --mt-line-strong: rgba(88, 66, 42, 0.38);
  --mt-enchant: #6b477e;
  --mt-enchant-bg: rgba(107, 71, 126, 0.08);
  color: var(--mt-ink);
}

#markettestView.active {
  display: block;
}

.markettest-page {
  width: min(1680px, calc(100vw - 28px));
  margin: 0 auto 54px;
}

.markettest-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 14px;
  padding: 15px 17px;
  border: 1px solid var(--mt-line-strong);
  background: linear-gradient(180deg, rgba(248, 239, 217, 0.82), rgba(231, 211, 172, 0.7));
}

.markettest-heading .eyebrow {
  margin: 0 0 2px;
  color: var(--mt-blood);
}

.markettest-heading h2 {
  margin: 0 0 4px;
  color: var(--mt-ink);
  font-family: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  font-size: clamp(1.65rem, 2.3vw, 2.25rem);
  line-height: 1;
}

.markettest-heading p:last-child {
  margin: 0;
  color: var(--mt-muted);
  font-size: 0.9rem;
}

.markettest-freshness {
  flex: 0 0 auto;
  max-width: 390px;
  color: var(--mt-muted);
  font-size: 0.76rem;
  text-align: right;
}

.markettest-controls {
  display: grid;
  grid-template-columns: auto minmax(240px, 1fr) auto auto auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

.markettest-tabs {
  display: flex;
  align-self: stretch;
  border: 1px solid var(--mt-line-strong);
  background: rgba(255, 251, 236, 0.5);
}

.markettest-tabs button,
.markettest-categories button,
.markettest-refresh {
  border: 0;
  background: transparent;
  color: var(--mt-muted);
  font: 700 0.82rem "EB Garamond", Georgia, serif;
  cursor: pointer;
}

.markettest-tabs button {
  min-width: 86px;
  padding: 8px 11px;
}

.markettest-tabs button.active {
  background: var(--mt-blood);
  color: #fff6e6;
}

.markettest-search,
.markettest-select {
  display: grid;
  gap: 3px;
  color: var(--mt-muted);
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
}

.markettest-search input,
.markettest-select select {
  min-height: 37px;
  border: 1px solid var(--mt-line-strong);
  border-radius: 0;
  padding: 6px 9px;
  background: rgba(255, 252, 239, 0.72);
  color: var(--mt-ink);
  font: 600 0.82rem "EB Garamond", Georgia, serif;
}

.markettest-refresh {
  min-height: 37px;
  border: 1px solid rgba(129, 43, 37, 0.34);
  padding: 7px 12px;
  background: rgba(129, 43, 37, 0.06);
  color: var(--mt-blood);
}

.markettest-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}

.markettest-categories button {
  border: 1px solid var(--mt-line);
  padding: 5px 9px;
  background: rgba(255, 251, 236, 0.42);
}

.markettest-categories button.active {
  border-color: rgba(129, 43, 37, 0.42);
  background: var(--mt-blood-soft);
  color: var(--mt-blood);
}

.markettest-status {
  min-height: 22px;
  margin: 0 0 5px;
  color: var(--mt-muted);
  font-size: 0.78rem;
}

.markettest-list-shell {
  overflow: hidden;
  border: 1px solid var(--mt-line-strong);
  background: rgba(240, 223, 188, 0.62);
}

.markettest-table-head,
.markettest-row-main {
  display: grid;
  grid-template-columns:
    minmax(500px, 1fr)
    82px
    138px
    132px
    68px
    48px;
  align-items: stretch;
}

.markettest-list-shell.is-auction .markettest-table-head,
.markettest-list-shell.is-auction .markettest-row-main {
  grid-template-columns:
    minmax(470px, 1fr)
    76px
    126px
    82px
    122px
    62px
    46px;
}

.markettest-table-head {
  min-height: 50px;
  border-bottom: 2px solid rgba(129, 43, 37, 0.2);
  background: rgba(248, 239, 217, 0.78);
  color: var(--mt-blood);
  font-family: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  font-size: 0.79rem;
  font-weight: 800;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.markettest-table-head > span {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  text-align: center;
}

.markettest-table-head > span:first-child {
  justify-content: flex-start;
  text-align: left;
}

.markettest-table-head .markettest-bids-head {
  display: none;
}

.markettest-list-shell.is-auction .markettest-bids-head {
  display: block;
}

.markettest-row {
  border-bottom: 1px solid var(--mt-line);
  background: var(--mt-paper-row);
}

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

.markettest-row-main {
  min-height: 104px;
}

.markettest-row-main > * {
  min-width: 0;
}

.markettest-item {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 11px;
  align-items: start;
  padding: 10px 12px;
}

.markettest-art {
  position: relative;
  display: grid;
  width: 68px;
  height: 68px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--mt-line-strong);
  border-radius: 10px;
  background: var(--quality-bg, rgba(153, 115, 68, 0.16));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.markettest-art img {
  width: 62px;
  height: 62px;
  border-radius: 8px;
  object-fit: contain;
}

.markettest-art-placeholder {
  color: var(--mt-gold);
  font: 800 1.45rem/1 Georgia, serif;
}

.markettest-copy {
  min-width: 0;
}

.markettest-item-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 5px 8px;
  margin-bottom: 3px;
}

.markettest-item-title {
  color: var(--mt-ink);
  font-family: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  font-size: 1.02rem;
  font-weight: 800;
  line-height: 1.06;
}

.markettest-item-meta {
  color: var(--mt-muted);
  font-size: 0.69rem;
  font-weight: 650;
}

.markettest-offer-badge {
  display: inline-block;
  border: 1px solid rgba(129, 43, 37, 0.25);
  padding: 2px 5px;
  background: rgba(129, 43, 37, 0.05);
  color: var(--mt-blood);
  font-size: 0.61rem;
  font-weight: 750;
}

.markettest-summary {
  display: grid;
  gap: 4px;
  margin-top: 5px;
}

.markettest-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px 10px;
}

.markettest-stat {
  display: flex;
  min-width: 0;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  border-bottom: 1px dotted rgba(88, 66, 42, 0.16);
  padding: 1px 0 2px;
  font-size: 0.7rem;
  line-height: 1.2;
}

.markettest-stat span {
  min-width: 0;
  color: var(--mt-muted);
  overflow-wrap: anywhere;
}

.markettest-stat strong {
  flex: 0 0 auto;
  color: var(--mt-blood);
  font-weight: 800;
  white-space: nowrap;
}

.markettest-enchants {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px 10px;
  margin-top: 2px;
  padding: 4px 6px;
  border-left: 2px solid rgba(107, 71, 126, 0.55);
  background: var(--mt-enchant-bg);
}

.markettest-enchant {
  display: flex;
  min-width: 0;
  gap: 5px;
  align-items: baseline;
  font-size: 0.68rem;
  line-height: 1.22;
}

.markettest-enchant::before {
  content: "✦";
  flex: 0 0 auto;
  color: var(--mt-enchant);
}

.markettest-enchant span {
  min-width: 0;
  color: #614d67;
  overflow-wrap: anywhere;
}

.markettest-enchant strong {
  flex: 0 0 auto;
  color: var(--mt-enchant);
  white-space: nowrap;
}

.markettest-effect {
  padding: 4px 6px;
  border-left: 2px solid rgba(129, 43, 37, 0.35);
  background: rgba(255, 252, 239, 0.48);
  color: var(--mt-ink);
  font-size: 0.7rem;
  line-height: 1.32;
  overflow-wrap: anywhere;
}

.markettest-effect b {
  margin-right: 5px;
  color: var(--mt-blood);
}

.markettest-empty-summary {
  color: var(--mt-muted);
  font-size: 0.67rem;
  font-style: italic;
}

.markettest-metric {
  display: flex;
  min-width: 0;
  min-height: 100%;
  align-items: center;
  justify-content: center;
  padding: 9px 8px;
  border-left: 1px solid rgba(88, 66, 42, 0.12);
  color: var(--mt-ink);
  font-size: 0.82rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  text-align: center;
}

.markettest-price {
  flex-direction: column;
  color: var(--mt-blood);
  font-family: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  font-size: 1rem;
  font-weight: 800;
  white-space: nowrap;
}

.markettest-quantity,
.markettest-durability,
.markettest-rune-count,
.markettest-bids {
  white-space: nowrap;
}

.markettest-price small {
  display: block;
  margin-top: 2px;
  color: var(--mt-muted);
  font-family: "EB Garamond", Georgia, serif;
  font-size: 0.58rem;
  font-weight: 600;
  line-height: 1.15;
}

.markettest-bids {
  display: none;
}

.markettest-list-shell.is-auction .markettest-bids {
  display: block;
}

.markettest-toggle {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  justify-self: center;
  border: 1px solid rgba(129, 43, 37, 0.34);
  background: rgba(255, 252, 239, 0.62);
  color: var(--mt-blood);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.markettest-toggle span {
  position: absolute;
  transform: translate(12px, -12px);
  min-width: 16px;
  border-radius: 999px;
  padding: 1px 3px;
  background: var(--mt-blood);
  color: white;
  font-size: 0.52rem;
}

.markettest-detail {
  padding: 0 12px 11px 80px;
}

.markettest-detail[hidden] {
  display: none;
}

.markettest-detail-inner {
  display: grid;
  gap: 9px;
  border-top: 1px solid var(--mt-line);
  padding-top: 9px;
}

.markettest-detail-section h4 {
  margin: 0 0 5px;
  color: var(--mt-blood);
  font-family: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  font-size: 0.86rem;
}

.markettest-detail-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px 9px;
}

.markettest-detail-stat {
  padding: 4px 6px;
  border: 1px solid var(--mt-line);
  background: rgba(255, 252, 239, 0.42);
  font-size: 0.68rem;
  line-height: 1.24;
}

.markettest-detail-stat b {
  color: var(--mt-blood);
}

.markettest-detail-section.is-enchant .markettest-detail-stat b {
  color: var(--mt-enchant);
}

.markettest-runes {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.markettest-rune {
  border: 1px solid var(--mt-line);
  padding: 4px 6px;
  background: rgba(255, 252, 239, 0.42);
  font-size: 0.67rem;
}

.markettest-offers-host .game-market-offers {
  margin: 0;
}

.markettest-pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 11px;
}

.markettest-pagination button {
  min-width: 34px;
  min-height: 31px;
  border: 1px solid var(--mt-line-strong);
  background: rgba(255, 251, 236, 0.58);
  color: var(--mt-blood);
  font: 750 0.75rem "EB Garamond", Georgia, serif;
  cursor: pointer;
}

.markettest-pagination button:disabled {
  opacity: 0.42;
  cursor: default;
}

@media (max-width: 1220px) {
  .markettest-table-head,
  .markettest-row-main {
    grid-template-columns: minmax(420px, 1fr) 68px 116px 102px 54px 40px;
  }

  .markettest-list-shell.is-auction .markettest-table-head,
  .markettest-list-shell.is-auction .markettest-row-main {
    grid-template-columns: minmax(390px, 1fr) 64px 108px 66px 96px 50px 38px;
  }

  .markettest-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .markettest-page {
    width: min(100%, calc(100vw - 16px));
  }

  .markettest-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .markettest-freshness {
    max-width: none;
    text-align: left;
  }

  .markettest-controls {
    grid-template-columns: 1fr 1fr;
  }

  .markettest-tabs,
  .markettest-search {
    grid-column: span 2;
  }

  .markettest-refresh {
    min-height: 35px;
  }

  .markettest-table-head {
    display: none;
  }

  .markettest-row-main,
  .markettest-list-shell.is-auction .markettest-row-main {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 8px 8px 6px;
  }

  .markettest-item {
    grid-column: 1 / -1;
    padding: 2px 2px 8px;
  }

  .markettest-metric {
    position: relative;
    padding: 18px 4px 3px;
    border-top: 1px solid var(--mt-line);
    font-size: 0.76rem;
  }

  .markettest-metric::before {
    position: absolute;
    top: 3px;
    left: 0;
    right: 0;
    color: var(--mt-muted);
    font-size: 0.53rem;
    font-weight: 700;
    text-transform: uppercase;
  }

  .markettest-quantity::before { content: "Кол-во"; }
  .markettest-price::before { content: "Цена"; }
  .markettest-bids::before { content: "Ставки"; }
  .markettest-durability::before { content: "Прочность"; }
  .markettest-rune-count::before { content: "Руны"; }

  .markettest-list-shell:not(.is-auction) .markettest-row-main {
    grid-template-columns: repeat(4, minmax(0, 1fr)) 38px;
  }

  .markettest-list-shell:not(.is-auction) .markettest-bids {
    display: none;
  }

  .markettest-toggle {
    align-self: end;
  }

  .markettest-detail {
    padding: 0 10px 10px;
  }

  .markettest-detail-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .markettest-page {
    width: calc(100vw - 8px);
    margin-bottom: 88px;
  }

  .markettest-heading {
    padding: 11px;
  }

  .markettest-controls {
    grid-template-columns: 1fr;
  }

  .markettest-tabs,
  .markettest-search {
    grid-column: 1;
  }

  .markettest-tabs button {
    flex: 1;
  }

  .markettest-categories {
    gap: 4px;
  }

  .markettest-categories button {
    padding: 4px 7px;
    font-size: 0.75rem;
  }

  .markettest-row-main,
  .markettest-list-shell.is-auction .markettest-row-main,
  .markettest-list-shell:not(.is-auction) .markettest-row-main {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .markettest-item {
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 8px;
  }

  .markettest-art {
    width: 54px;
    height: 54px;
    border-radius: 9px;
  }

  .markettest-art img {
    width: 49px;
    height: 49px;
    border-radius: 7px;
  }

  .markettest-item-title {
    font-size: 0.94rem;
  }

  .markettest-stat-grid,
  .markettest-enchants {
    grid-template-columns: 1fr;
  }

  .markettest-toggle {
    grid-column: 4;
    width: 29px;
    height: 29px;
  }

  .markettest-list-shell.is-auction .markettest-toggle {
    grid-column: 4;
  }

  .markettest-list-shell.is-auction .markettest-bids {
    display: none;
  }

  .markettest-detail-stats {
    grid-template-columns: 1fr;
  }
}
