/* Market page layout */
.market-layout {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 20px;
  align-items: start;
}

/* ── Screener section ──────────────────────────────────────────────────────── */
.screener-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.screener-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.screener-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.screener-header-left h2 { font-size: 0.95rem; }

.screener-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.screener-table-wrap {
  overflow-x: auto;
  max-height: 620px;
  overflow-y: auto;
}

.screener-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.screener-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  text-align: left;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
  z-index: 1;
}

.screener-table thead th.sortable {
  cursor: pointer;
}
.screener-table thead th.sortable:hover { color: var(--text); }

.screener-row {
  cursor: pointer;
  transition: background 0.1s;
}
.screener-row:hover { background: var(--border); }
.screener-row.selected {
  background: rgba(96,165,250,0.08);
  border-left: 2px solid var(--blue);
}

.screener-row td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}
.screener-row:last-child td { border-bottom: none; }

/* Column widths & alignment */
.col-icon  { width: 36px; padding: 5px 8px !important; }
.col-name  { min-width: 130px; }
.col-price { width: 75px; text-align: right; font-variant-numeric: tabular-nums; }
.col-margin { width: 75px; text-align: right; font-variant-numeric: tabular-nums; }
.col-pct   { width: 58px; text-align: right; font-variant-numeric: tabular-nums; }
.col-cycle { width: 95px; text-align: right; font-variant-numeric: tabular-nums; }
.col-vol   { width: 68px; text-align: right; font-variant-numeric: tabular-nums; }
.col-limit { width: 52px; text-align: right; }

/* Right-align numeric column headers to match data */
.screener-table thead th.col-price,
.screener-table thead th.col-margin,
.screener-table thead th.col-pct,
.screener-table thead th.col-cycle,
.screener-table thead th.col-vol,
.screener-table thead th.col-limit { text-align: right; }

.item-row-name {
  display: inline;
  font-size: 13px;
  text-transform: capitalize;
}

.badge-members-sm {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  background: rgba(251,191,36,0.15);
  color: var(--gold);
  border: 1px solid rgba(251,191,36,0.25);
  border-radius: 3px;
  padding: 0 4px;
  margin-left: 5px;
  letter-spacing: 0.3px;
  vertical-align: middle;
}

/* ── Filters (shared with old browser) ─────────────────────────────────────── */
.browser-filters {
  display: flex;
  gap: 4px;
}
.browser-filters button {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 3px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
}
.browser-filters button.active { border-color: var(--blue); color: var(--blue); }
.browser-filters button:hover { color: var(--text); }

/* ── Top Movers sidebar ─────────────────────────────────────────────────────── */
.market-movers {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.browser-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.browser-header h2 { font-size: 0.95rem; }

.movers-list { overflow-y: auto; max-height: 580px; }

.mover-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.mover-row:last-child { border-bottom: none; }
.mover-row:hover { background: var(--border); }

.mover-info { flex: 1; min-width: 0; }
.mover-info .item-row-name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.mover-change {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ── Item icons ─────────────────────────────────────────────────────────────── */
.item-icon-sm { width: 24px; height: 24px; object-fit: contain; image-rendering: pixelated; flex-shrink: 0; }
.item-icon-lg { width: 40px; height: 40px; object-fit: contain; image-rendering: pixelated; flex-shrink: 0; }

/* ── Badge ──────────────────────────────────────────────────────────────────── */
.badge-members {
  background: rgba(251,191,36,0.15);
  color: var(--gold);
  border: 1px solid rgba(251,191,36,0.3);
  border-radius: 3px;
  font-size: 10px;
  padding: 1px 6px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* ── Price summary bar (item panel) ─────────────────────────────────────────── */
.price-summary {
  display: flex;
  gap: 0;
  margin-bottom: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.price-stat {
  flex: 1;
  padding: 10px 16px;
  border-right: 1px solid var(--border);
  text-align: center;
}
.price-stat:last-child { border-right: none; }
.price-stat-label { font-size: 10px; color: var(--muted); letter-spacing: 0.5px; margin-bottom: 4px; text-transform: uppercase; }
.price-stat-value { font-size: 16px; font-weight: 700; }
.price-stat-value.green { color: var(--green); }
.price-stat-value.red   { color: var(--red); }

/* ── Opportunity history table ──────────────────────────────────────────────── */
.opp-history { margin-top: 16px; }
.opp-history h3 { font-size: 0.9rem; margin-bottom: 10px; color: var(--muted); }

.opp-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.opp-table th { text-align: left; color: var(--muted); padding: 4px 8px; border-bottom: 1px solid var(--border); font-weight: 500; }
.opp-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.opp-table tr:last-child td { border-bottom: none; }
.opp-table tr:hover td { background: var(--border); }

.kind-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}
.kind-badge.flip       { background: rgba(74,222,128,0.15); color: var(--green); }
.kind-badge.alch_floor { background: rgba(251,191,36,0.15); color: var(--gold); }
.kind-badge.crash      { background: rgba(248,113,113,0.15); color: var(--red); }

/* ── Chart container ───────────────────────────────────────────────────────── */
#market-chart-container { width: 100%; height: 320px; margin-bottom: 10px; }

/* ── Utility ───────────────────────────────────────────────────────────────── */
.green { color: var(--green); }
.red   { color: var(--red); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

@media (max-width: 900px) {
  .market-layout { grid-template-columns: 1fr; }
  .col-cycle, .col-vol { display: none; }
  .screener-table thead th.col-cycle,
  .screener-table thead th.col-vol { display: none; }
}
