/* /stock page: in-game market (exchange-style layout). Loaded after styles.css, pages.css and community.css. */
.market-page {
  --mk-up: #38d864;
  --mk-down: #f6465d;
}

.mk-section { padding-top: 1.6rem; }

.mk-banner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(250, 204, 21, 0.35);
  background: rgba(250, 204, 21, 0.08);
  border-radius: var(--radius-sm);
  color: var(--gold);
  font-size: 0.9rem;
}

.mk-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 1.1rem;
  align-items: start;
}

/* ---------- market list ---------- */
.mk-markets {
  padding: 0;
  overflow: hidden;
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 110px);
}
.mk-markets-head { padding: 1rem 1rem 0.75rem; display: grid; gap: 0.6rem; border-bottom: 1px solid var(--border); }
.mk-markets-head h2 { margin: 0; font-family: var(--font-display); font-size: 1.15rem; }
.mk-search { width: 100%; }
.mk-cat-select {
  width: 100%;
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 0.9rem;
}
.mk-cat-select:disabled { opacity: 0.5; }
.mk-sell-filter { display: flex; width: 100%; }
.mk-sell-filter button { flex: 1; }
.mk-tag {
  display: inline-block; margin-right: 0.35rem; padding: 0 0.35rem; border-radius: 999px; font-style: normal; font-size: 0.64rem;
  font-weight: 700; letter-spacing: 0.02em; color: var(--text-muted); background: rgba(255, 255, 255, 0.07); vertical-align: 1px;
}
.mk-link-btn { display: block; margin: 0.6rem auto 0; background: none; border: 0; color: var(--gold); font-weight: 700; cursor: pointer; }
.mk-link-btn:hover { text-decoration: underline; }

.mk-list-head,
.mk-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px 66px;
  align-items: center;
  gap: 0.5rem;
}
.mk-list-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-surface);
  padding: 0.5rem 1rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.mk-sort {
  display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0; background: none; border: 0; cursor: pointer;
  font: inherit; letter-spacing: inherit; text-transform: inherit; color: var(--text-dim); transition: color 0.15s;
}
.mk-list-head .mk-sort:nth-child(n + 2) { justify-self: end; }
.mk-sort:hover, .mk-sort:focus-visible { color: var(--text-main); }
.mk-sort.active { color: var(--text-main); }
.mk-sort-arrows path { fill: currentColor; opacity: 0.3; transition: opacity 0.15s; }
.mk-sort:hover .mk-sort-arrows path { opacity: 0.55; }
.mk-sort-arrows.asc .up, .mk-sort-arrows.desc .down { opacity: 1; fill: var(--emerald); }
.mk-list {
  position: relative;
  overflow-y: auto;
  flex: 1;
  min-height: 200px;
  overscroll-behavior: contain; /* the page does not scroll when the list reaches its end */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}
.mk-list:hover { scrollbar-color: rgba(255, 255, 255, 0.3) transparent; }
/* Older Chromium / Safari (no scrollbar-color) */
.mk-list::-webkit-scrollbar { width: 8px; }
.mk-list::-webkit-scrollbar-track { background: transparent; }
.mk-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
.mk-list::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, 0.32); }
.mk-row {
  width: 100%;
  padding: 0.55rem 1rem;
  background: none;
  border: 0;
  border-left: 2px solid transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.mk-row:hover { background: var(--bg-card-hover); }
.mk-row.active { background: var(--bg-elevated); border-left-color: var(--emerald); }
.mk-row-name { display: flex; align-items: center; gap: 0.55rem; min-width: 0; }
.mk-row-name > span:last-child { display: grid; min-width: 0; line-height: 1.25; }
.mk-row-name strong { font-size: 0.86rem; }
.mk-row-name small { color: var(--text-dim); font-size: 0.74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk-row-price { display: grid; justify-items: end; font-size: 0.84rem; font-variant-numeric: tabular-nums; }
.mk-spark { margin-top: 2px; }
.mk-spark-empty { display: block; height: 20px; }
.mk-row .mk-chg { text-align: right; }
.mk-list-note { padding: 1.4rem 1rem; color: var(--text-muted); font-size: 0.9rem; text-align: center; }
.mk-list-foot { display: flex; align-items: center; gap: 0.4rem; padding: 0.55rem 1rem; border-top: 1px solid var(--border); color: var(--text-dim); font-size: 0.75rem; }

.mk-ticker-badge {
  display: inline-grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.mk-ticker-badge.sm { width: 30px; height: 30px; font-size: 0.6rem; }
.mk-ticker-badge.md { width: 38px; height: 38px; font-size: 0.7rem; }
.mk-ticker-badge.lg { width: 48px; height: 48px; font-size: 0.85rem; }

.mk-chg { font-size: 0.82rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.market-page .up { color: var(--mk-up); }
.market-page .down { color: var(--mk-down); }
.mk-chg.flat { color: var(--text-dim); }

/* ---------- main panel ---------- */
.mk-main { display: grid; gap: 1.1rem; min-width: 0; }

.mk-pick { padding: 2.4rem 1.6rem; text-align: center; }
.mk-pick h2 { margin: 0 0 0.4rem; font-family: var(--font-display); }
.mk-pick p { margin: 0 auto 1.3rem; color: var(--text-muted); max-width: 520px; }
.mk-quick { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.55rem; }
.mk-quick-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem 0.35rem 0.35rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-main);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}
.mk-quick-chip:hover { border-color: var(--border-strong); }

.mk-head {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 1rem 2rem;
  padding: 1.1rem 1.3rem;
}
.mk-head-id { display: flex; align-items: center; gap: 0.8rem; }
.mk-head-id h2 { margin: 0; font-family: var(--font-display); font-size: 1.35rem; }
.mk-head-id h2 span { color: var(--text-muted); font-weight: 600; font-size: 1rem; }
.mk-head-id small { color: var(--text-dim); font-size: 0.78rem; }
.mk-head-price { display: grid; line-height: 1.2; }
.mk-head-price strong { font-size: 1.75rem; font-variant-numeric: tabular-nums; }
.mk-head-stats { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.6rem 1.5rem; }
.mk-head-stats div { display: grid; font-size: 0.86rem; font-variant-numeric: tabular-nums; }
.mk-head-stats span { color: var(--text-dim); font-size: 0.72rem; }
.mk-stock-stat { min-width: 150px; }
.mk-stock-bar { display: block; height: 4px; margin-top: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.mk-stock-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--mk-down), var(--gold), var(--mk-up)); }

.mk-chart-card { padding: 0.9rem 1rem 1rem; }
.mk-toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 0.6rem; }
.mk-seg { display: inline-flex; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; }
.mk-seg button {
  background: none;
  border: 0;
  border-radius: 6px;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
}
.mk-seg button:hover:not(:disabled) { color: var(--text-main); }
.mk-seg button.active { background: var(--bg-elevated); color: var(--text-main); }
.mk-seg button:disabled { opacity: 0.35; cursor: not-allowed; }

.mk-chart-card { min-width: 0; }
.mk-chart { width: 100%; min-width: 0; position: relative; overflow: hidden; }
.mk-chart svg { display: block; max-width: 100%; cursor: crosshair; user-select: none; }
.mk-chart-legend { display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; font-size: 0.78rem; color: var(--text-dim); margin: 0 0 0.3rem 0.2rem; font-variant-numeric: tabular-nums; }
.mk-chart-legend b { font-weight: 600; color: var(--text-main); }
.mk-chart-legend b.up { color: var(--mk-up); }
.mk-chart-legend b.down { color: var(--mk-down); }
.mk-legend-time { color: var(--text-muted); }
.mk-grid { stroke: rgba(255, 255, 255, 0.06); }
.mk-axis { fill: var(--text-dim); font-size: 11px; font-variant-numeric: tabular-nums; }
.mk-axis-last { fill: #06110a; font-weight: 700; }
.mk-crosshair line { stroke: rgba(255, 255, 255, 0.35); stroke-dasharray: 4 4; }
.mk-chart-empty { display: grid; place-items: center; text-align: center; padding: 1rem; color: var(--text-muted); font-size: 0.92rem; border: 1px dashed var(--border); border-radius: var(--radius-sm); }
.mk-stale { margin: 0.6rem 0 0; color: var(--gold); font-size: 0.82rem; }

.mk-activity { padding: 1.1rem 1.2rem; }
.mk-activity-head h3 { margin: 0; font-family: var(--font-display); }
.mk-activity-head p { margin: 0.2rem 0 0.8rem; color: var(--text-muted); font-size: 0.85rem; }
.mk-table td { font-variant-numeric: tabular-nums; }
.mk-side { display: inline-block; padding: 0.12rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.mk-side.buy { color: var(--mk-up); background: rgba(56, 216, 100, 0.12); }
.mk-side.sell { color: var(--mk-down); background: rgba(246, 70, 93, 0.12); }
.mk-side.mixed { color: var(--text-muted); background: rgba(255, 255, 255, 0.06); }

@media (max-width: 1100px) {
  .mk-head { grid-template-columns: auto 1fr; }
  .mk-head-stats { grid-column: 1 / -1; justify-content: flex-start; }
}

@media (max-width: 920px) {
  .mk-layout { grid-template-columns: minmax(0, 1fr); }
  .mk-markets { position: static; max-height: 420px; }
}

@media (max-width: 560px) {
  .mk-head { grid-template-columns: 1fr; }
  .mk-list-head, .mk-row { grid-template-columns: minmax(0, 1fr) 96px 58px; }
  .mk-spark { display: none; }
}

/* item icons (MARKET_ICON_URL, 128-512 px images shown small), in place of the ticker badge */
.mk-item-icon { background: rgba(255, 255, 255, 0.06); border-radius: 8px; }
.mk-item-icon img { width: 80%; height: 80%; object-fit: contain; }
