/* Dark trading table in the spirit of Pulse: navy surfaces, orange accent, profit in green/red.
   No external fonts or assets. Wide screens get a dense grid; phones get one card per item. */
:root {
  color-scheme: dark;
  --bg: #0e1118;
  --surface: #131823;
  --surface-2: #171d2a;
  --raise: #1e2536;
  --hover: #151b27;
  --line: #242c3d;
  --line-soft: #1a202d;
  --text: #e7eaf1;
  --text-2: #b4bccb;
  --muted: #7d869a;
  --accent: #ff7a2f;
  --accent-2: #f2621a;
  --accent-soft: rgba(255, 122, 47, 0.14);
  --pos: #3fd68b;
  --pos-soft: rgba(63, 214, 139, 0.13);
  --neg: #ff6767;
  --neg-soft: rgba(255, 103, 103, 0.13);
  --warn: #f2b84b;
  --steam: #66c0f4;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* item | buy | Steam | via buy order | via lot | 7 days | last sale | updated.
     The numbers keep fixed widths, the item takes all the rest. */
  --cols: minmax(300px, 1fr) 128px 152px 126px 126px 144px 132px 116px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, select {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover:not(:disabled), select:hover { border-color: #33405a; background: var(--raise); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #1a0d05; font-weight: 600; }
button.primary:hover:not(:disabled) { background: #ff8b47; border-color: #ff8b47; }
button.danger { color: var(--neg); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover:not(:disabled) { color: var(--text); background: var(--surface-2); border-color: var(--line); }
.btn { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); color: var(--text); }
.btn:hover { text-decoration: none; border-color: #33405a; background: var(--raise); }

input, select { min-width: 0; }
input {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 9px;
}
input::placeholder { color: #5d6679; }
input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
button:focus-visible, select:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input.bad { border-color: var(--neg); }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }

.muted { color: var(--muted); }
.ok { color: var(--pos); }
.bad { color: var(--neg); }
.warn { color: var(--warn); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.paper { color: var(--muted); text-decoration: underline dotted; text-underline-offset: 3px; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.form-error { color: var(--neg); margin: 8px 0 0; }
.form-ok { color: var(--pos); }
.sep { color: var(--line); margin: 0 6px; }
.arrow { color: var(--accent); }
.btn-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }

/* --- top bar --- */
.top {
  display: flex;
  align-items: center;
  gap: 10px 18px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  min-height: 52px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: linear-gradient(135deg, #ff9a52, var(--accent-2));
  position: relative;
}
.brand-mark::after {
  content: ''; position: absolute; left: 8px; top: 8px; width: 8px; height: 8px;
  border-top: 2.5px solid #1a0d05; border-right: 2.5px solid #1a0d05; transform: rotate(45deg);
}
.page-title { color: var(--muted); font-weight: 600; }
.tabs { display: flex; gap: 2px; padding: 3px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.tab { background: transparent; border: 0; color: var(--muted); padding: 5px 14px; border-radius: 6px; font-weight: 600; }
.tab:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--accent-soft); color: var(--accent); }
.tab:disabled { opacity: 0.35; }
.status { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 200px; font-size: 12px; color: var(--text-2); }
.st { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line-soft); white-space: nowrap; }
.st .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.st-ok .dot { background: var(--pos); box-shadow: 0 0 0 3px var(--pos-soft); }
.st-warn .dot { background: var(--warn); }
.st-bad .dot { background: var(--neg); }
.st-bad { color: var(--neg); }
.user { display: flex; align-items: center; gap: 12px; white-space: nowrap; margin-left: auto; }
.user-name { color: var(--muted); }

.banner {
  background: rgba(242, 184, 75, 0.1);
  color: var(--warn);
  border-bottom: 1px solid rgba(242, 184, 75, 0.3);
  padding: 7px 16px;
  font-weight: 600;
}

/* --- table page layout: the grid scrolls under a fixed toolbar --- */
body.table-page { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.table-wrap { flex: 1; overflow: auto; min-height: 0; }

/* --- toolbar --- */
.toolbar { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding: 12px 16px; background: var(--bg); }
.count { font-size: 18px; font-weight: 700; white-space: nowrap; margin-right: 4px; }
.count-num { color: var(--accent); }
.count-num::before { content: '['; }
.count-num::after { content: ']'; }
.search { flex: 0 1 280px; min-width: 160px; }
.search input {
  width: 100%;
  padding-left: 30px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Ccircle cx='6' cy='6' r='4.5' fill='none' stroke='%237d869a' stroke-width='1.6'/%3E%3Cpath d='M9.5 9.5 13 13' stroke='%237d869a' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat 10px 50%;
}
.quick { display: flex; gap: 10px; flex-wrap: wrap; }
.qf { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.field { position: relative; display: inline-flex; align-items: center; }
.field input { width: 76px; padding-right: 22px; background: var(--surface); }
.field .unit { position: absolute; right: 8px; color: var(--muted); font-size: 12px; pointer-events: none; }
.toggle { display: inline-flex; align-items: center; gap: 7px; color: var(--text-2); cursor: pointer; white-space: nowrap; user-select: none; }
.sort-pick { display: none; }
.sort-pick select { background: var(--surface); max-width: 100%; }
.filters-btn { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; background: var(--surface); font-weight: 600; }
.filters-btn::before {
  content: ''; width: 14px; height: 14px; flex: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath d='M1.5 2.5h11L8.3 7.4v3.8l-2.6 1.3V7.4z' fill='none' stroke='%23b4bccb' stroke-width='1.4' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center;
}
.filters-btn.on { border-color: var(--accent); color: var(--accent); }
.badge-n { min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #1a0d05; font-size: 11px; line-height: 18px; text-align: center; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 16px 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 3px 6px 3px 10px; border-radius: 999px;
  background: var(--accent-soft); border: 1px solid rgba(255, 122, 47, 0.35); color: #ffc4a3; font-size: 12px;
}
.chip .x { color: var(--accent); font-size: 10px; width: 16px; text-align: center; }
.chip:hover:not(:disabled) { background: rgba(255, 122, 47, 0.24); border-color: var(--accent); }
.chip-reset { background: transparent; border-color: var(--line); color: var(--muted); padding-right: 10px; }
.load-error { margin: 0 16px 10px; color: var(--neg); }

/* --- the grid: never wider than the screen; narrower screens drop the least needed columns --- */
.ghead, .r { display: grid; grid-template-columns: var(--cols); }
.ghead {
  position: sticky; top: 0; z-index: 3;
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.h { display: flex; flex-direction: column; justify-content: center; gap: 3px; padding: 9px 12px; min-width: 0; }
.h-title { background: none; border: 0; padding: 0; color: var(--muted); font-weight: 600; font-size: 12px; text-align: inherit; white-space: nowrap; }
.h-title:hover:not(:disabled) { background: none; color: var(--text); }
.h.sorted .h-title { color: var(--text); }
.h .arr { color: var(--accent); }
.h-subs { display: inline-flex; gap: 4px; }
.h-sub { background: none; border: 1px solid transparent; border-radius: 4px; padding: 0 5px; font-size: 11px; color: var(--muted); }
.h-sub:hover:not(:disabled) { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.h-sub.on { color: var(--accent); border-color: rgba(255, 122, 47, 0.4); background: var(--accent-soft); }

.r {
  --row-bg: var(--bg);
  --tier: transparent;
  background: var(--row-bg);
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.r:hover { --row-bg: var(--hover); }
.r.open { --row-bg: var(--surface-2); }
.r.t-top { --tier: var(--pos); }
.r.t-good { --tier: rgba(63, 214, 139, 0.55); }
.r.t-ok { --tier: #3a4458; }
.r.t-neg { --tier: rgba(255, 103, 103, 0.6); }
.c { display: flex; flex-direction: column; justify-content: center; gap: 3px; padding: 12px 12px; min-width: 0; }
.c b { font-weight: 600; }
.c .sub { font-size: 11.5px; color: var(--muted); }
.c .sub.pos { color: rgba(63, 214, 139, 0.85); }
.c .sub.neg { color: rgba(255, 103, 103, 0.85); }
.c .big { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.pair { display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.pair i { font-style: normal; font-size: 11px; color: var(--muted); }

.h-sih, .h-steam, .h-pbuy, .h-psell, .h-week, .h-last, .h-age,
.c-sih, .c-steam, .c-pbuy, .c-psell, .c-week, .c-last, .c-age { align-items: flex-end; text-align: right; }
.h-pbuy, .c-pbuy, .h-psell, .c-psell { background: rgba(255, 255, 255, 0.015); }

/* A price opens the item on its market or in Steam. */
.plink { display: inline-flex; color: inherit; margin: -2px -5px; padding: 2px 5px; border-radius: 5px; }
.plink:hover { text-decoration: none; background: var(--raise); color: var(--accent); }
.plink:hover b, .plink:hover i { color: inherit; }
.c .sub.alt.plink { color: var(--muted); }
.c .sub.alt.plink:hover { color: var(--accent); }

/* The bar on the left edge of the item shows the profit tier. */
.c-item {
  flex-direction: row; align-items: center; justify-content: flex-start; gap: 12px;
  padding-left: 14px;
  box-shadow: inset 3px 0 0 var(--tier);
}
.pic {
  --rarity: #3a4458;
  width: 44px; height: 44px; flex: none; border-radius: 7px;
  background: radial-gradient(circle at 50% 120%, color-mix(in srgb, var(--rarity) 35%, transparent), transparent 70%), #161c28;
  border: 1px solid var(--line);
  border-bottom: 2px solid var(--rarity);
  display: grid; place-items: center; overflow: hidden;
}
.pic img { width: 40px; height: 40px; object-fit: contain; display: block; }
.noimg { width: 40px; height: 40px; }
.item-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
/* Long names wrap to a second line instead of being cut. */
.item-name {
  overflow: hidden; font-weight: 600; font-size: 14px; line-height: 1.3; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.icon { background: none; border: 0; padding: 4px; font-size: 17px; line-height: 1; color: #4d566a; border-radius: 6px; }
.icon:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.icon.fav.on { color: #ffc24a; }

.tag { margin-left: 4px; font-size: 10px; color: var(--warn); border: 1px solid rgba(242, 184, 75, 0.4); border-radius: 4px; padding: 0 4px; }
.badge {
  display: inline-block;
  font-size: 10.5px;
  line-height: 16px;
  padding: 0 6px;
  border-radius: 5px;
  white-space: nowrap;
  color: var(--text-2);
  background: rgba(125, 134, 154, 0.16);
}
.b-overpriced, .b-falling { color: #ffb3b3; background: var(--neg-soft); }
.b-low_sales { color: #ffd98c; background: rgba(242, 184, 75, 0.14); }
.b-wide_spread { color: #ffc29a; background: var(--accent-soft); }
.b-stale, .b-no_fx { color: var(--muted); background: rgba(125, 134, 154, 0.12); }
.b-sih_mismatch { color: #cdbdff; background: rgba(167, 139, 250, 0.15); }
.b-locked { color: #9fd8ff; background: rgba(102, 192, 244, 0.14); }

.empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 12px; }
.more { margin: 0; padding: 14px 16px 24px; color: var(--muted); text-align: center; }

/* --- expanded row --- */
.detail { background: var(--surface); border-bottom: 1px solid var(--line); }
.detail-inner { padding: 16px 18px 18px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 2.1fr) minmax(250px, 1.1fr) minmax(220px, 1fr); gap: 22px; }
.detail h4 { margin: 0 0 8px; font-size: 12px; color: var(--muted); font-weight: 600; }
.detail section > h4 ~ h4 { margin-top: 16px; }
.stats { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 8px; }
.stat { display: flex; flex-direction: column; }
.stat-l { font-size: 11px; color: var(--muted); }
.stat b { font-size: 14px; }
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: rgba(102, 192, 244, 0.35); }
.chart .bar:hover { fill: var(--steam); }
.chart .price-line { fill: none; stroke: var(--accent); stroke-width: 1.4; stroke-linejoin: round; opacity: 0.85; }
.chart .price-dot { fill: var(--accent); }
.chart .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.chart .base-line { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.chart-empty { padding: 24px 0; }
.book { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.book-side h4 { font-weight: 600; }
.levels { list-style: none; margin: 0; padding: 0; }
.lvl { position: relative; display: flex; justify-content: space-between; gap: 8px; padding: 2px 6px; border-radius: 4px; font-size: 12.5px; }
.lvl + .lvl { margin-top: 2px; }
.lvl .depth { position: absolute; right: 0; top: 0; bottom: 0; border-radius: 4px; }
.lvl.sell .depth { background: var(--neg-soft); }
.lvl.buy .depth { background: var(--pos-soft); }
.lvl.sell .lvl-price { color: #ff9a9a; }
.lvl.buy .lvl-price { color: #8fe7b8; }
.lvl-price, .lvl-qty { position: relative; }
.lvl-qty { color: var(--muted); }
.sales, .lots { list-style: none; margin: 0; padding: 0; }
.sales li { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; padding: 2px 0; font-size: 12.5px; }
.lots { display: flex; flex-wrap: wrap; gap: 4px; }
.lots li { padding: 2px 8px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line-soft); font-size: 12.5px; }
.d-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.d-admin { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.d-admin .hint { margin: 0; }

/* --- filter panel: a drawer on the right, the whole screen on a phone --- */
.scrim { position: fixed; inset: 0; background: rgba(5, 7, 12, 0.55); z-index: 20; }
.filters {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 21;
  width: min(440px, 100vw);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -24px 0 48px rgba(0, 0, 0, 0.35);
  animation: slide-in 0.18s ease-out;
}
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }
.filters-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.filters-head h2 { margin: 0; font-size: 16px; }
.close { font-size: 15px; padding: 4px 10px; }
.filters-body { flex: 1; overflow-y: auto; padding: 6px 18px 18px; overscroll-behavior: contain; }
.fl-group { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.fl-group:last-child { border-bottom: 0; }
.fl-group h3 { margin: 0 0 8px; font-size: 13px; color: var(--text); }
.fl-group .hint { margin: -4px 0 8px; }
.fl-list { display: flex; flex-direction: column; gap: 6px; }
.fl { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fl-label { color: var(--text-2); }
.fl-label .unit { color: var(--muted); margin-left: 5px; font-size: 12px; }
.fl-pair { display: flex; gap: 6px; flex: none; }
.fl-pair input { width: 92px; background: var(--bg); padding-right: 30px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; flex: none; }
.seg button { border: 0; border-radius: 0; background: transparent; color: var(--muted); padding: 4px 10px; font-size: 12px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed=true] { color: var(--text); background: var(--raise); }
.seg button.seg-hide[aria-pressed=true] { background: var(--neg-soft); color: #ffb3b3; }
.seg button.seg-only[aria-pressed=true] { background: var(--pos-soft); color: #8fe7b8; }
.filters-foot {
  display: flex; gap: 10px; justify-content: space-between; align-items: center;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
}
.filters-foot .primary { flex: 1; max-width: 220px; padding: 9px 12px; }

/* --- login and setup --- */
body.auth-page { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 16px; }
.auth-box { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 26px 26px 22px; }
.auth-box h1 { display: flex; align-items: center; gap: 10px; margin: 0 0 18px; font-size: 19px; }
.auth-box p { margin: 0 0 14px; }
.auth-box label, .stack label { display: block; color: var(--text-2); margin-bottom: 12px; }
.auth-box input, .stack input { display: block; width: 100%; margin-top: 5px; padding: 9px 11px; }
.auth-box button[type=submit] { width: 100%; padding: 10px 12px; margin-top: 6px; background: var(--accent); border-color: var(--accent); color: #1a0d05; font-weight: 600; }
.auth-box button[type=submit]:hover:not(:disabled) { background: #ff8b47; }

/* --- admin --- */
body.admin-page { min-height: 100vh; }
body.admin-page .status { min-width: 0; }
.admin { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); gap: 14px; padding: 16px; align-items: start; max-width: 1500px; margin: 0 auto; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; min-width: 0; }
.card.wide { grid-column: 1 / -1; }
.card h2 { margin: 0 0 12px; font-size: 15px; }
.stack { margin-top: 12px; max-width: 380px; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 6px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
details.manual { margin-top: 14px; border-top: 1px solid var(--line-soft); padding-top: 10px; }
details.manual summary { cursor: pointer; color: var(--text-2); }
details.manual summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
table.list { width: 100%; border-collapse: collapse; margin-top: 12px; }
table.list th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); }
table.list td { padding: 7px 8px 7px 0; border-bottom: 1px solid var(--line-soft); }
table.list tr.off td { color: var(--muted); }
td.actions { text-align: right; white-space: nowrap; }
td.actions button { margin-left: 4px; padding: 3px 9px; font-size: 12px; }
.password-box { margin-top: 12px; padding: 10px 12px; background: var(--pos-soft); border: 1px solid rgba(63, 214, 139, 0.35); border-radius: 8px; }
.password-box code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; color: var(--pos); user-select: all; }
#guest-form input { flex: 1; min-width: 180px; }
.settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 12px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0; padding: 10px 14px 12px; min-width: 0; }
legend { color: var(--text); font-weight: 600; padding: 0 6px; }
label.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 3px 0; }
label.setting span { color: var(--text-2); }
label.setting input { width: 96px; text-align: right; flex: none; }
.fx-line { font-weight: 600; margin: 0 0 12px; }
.collectors { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 18px; }
.collector h3 { margin: 0 0 8px; font-size: 14px; }
.collector h4 { margin: 12px 0 6px; font-size: 12px; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .filters { animation: none; }
}

/* --- phone: one card per item, the page scrolls as a whole, the toolbar sticks --- */
@media (max-width: 700px) {
  /* 16px stops iOS from zooming the page when a field gets focus. */
  input, select { font-size: 16px; }

  body.table-page { display: block; height: auto; overflow: visible; }
  .table-wrap { overflow: visible; }

  .top { gap: 8px 10px; padding: 8px 12px; }
  .brand { font-size: 14px; }
  .brand-mark { width: 22px; height: 22px; }
  .brand-mark::after { left: 6px; top: 7px; width: 7px; height: 7px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .tab { flex: 1; padding: 6px 8px; }
  .status { order: 4; flex-basis: 100%; min-width: 0; gap: 5px; font-size: 11.5px; }
  .st { padding: 2px 8px; }
  .user { gap: 10px; }
  .user-name { display: none; }

  .toolbar {
    position: sticky; top: 0; z-index: 10;
    padding: 10px 12px; gap: 8px;
    background: rgba(14, 17, 24, 0.94);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line-soft);
  }
  .count { font-size: 16px; order: 1; }
  .filters-btn { order: 2; }
  .search { order: 3; flex: 1 1 100%; }
  .sort-pick { display: block; order: 4; flex: 1 1 0; min-width: 0; }
  .sort-pick select { width: 100%; padding: 7px 8px; }
  .toggle { order: 5; font-size: 13px; }
  .quick { display: none; }
  .chips { flex-wrap: nowrap; overflow-x: auto; padding: 8px 12px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }

  .grid { padding: 4px 0 24px; }
  .ghead { display: none; }
  .r {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "item item item"
      "sih pbuy psell"
      "steam steam steam"
      "week week last";
    margin: 8px 10px 0;
    border: 1px solid var(--line);
    border-left: 3px solid var(--tier);
    border-radius: 10px;
    background: var(--surface);
    --row-bg: var(--surface);
    padding: 4px 0;
  }
  .r.t-ok, .r.t-none { border-left-color: var(--line); }
  .r:hover { --row-bg: var(--surface); }
  .r.open { --row-bg: var(--surface-2); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
  .c { padding: 6px 12px; align-items: flex-start; text-align: left; }
  .c[data-cap]::before { content: attr(data-cap); font-size: 10.5px; color: var(--muted); margin-bottom: 1px; }
  .c-sih, .c-steam, .c-pbuy, .c-psell, .c-week, .c-last, .c-age { align-items: flex-start; text-align: left; }
  .c-item { grid-area: item; box-shadow: none; padding: 9px 8px 5px 12px; gap: 10px; }
  .c-item .fav { order: 3; font-size: 20px; }
  .c-pbuy { grid-area: pbuy; background: none; }
  .c-psell { grid-area: psell; background: none; }
  .c-pbuy .big, .c-psell .big { font-size: 17px; }
  .c-sih { grid-area: sih; }
  .c-steam { grid-area: steam; flex-direction: row; flex-wrap: wrap; justify-content: flex-start; align-items: baseline; column-gap: 12px; }
  .c-steam::before { flex-basis: 100%; }
  .c-week { grid-area: week; flex-direction: row; flex-wrap: wrap; justify-content: flex-start; align-items: baseline; column-gap: 12px; padding-bottom: 9px; }
  .c-week::before { flex-basis: 100%; }
  .c-last { grid-area: last; }
  .c-age { display: none; }
  .c-age::before { flex-basis: 100%; }
  .c-age .pair { gap: 4px; }
  .c-sih, .c-pbuy, .c-psell { border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); padding-top: 8px; padding-bottom: 8px; }

  .detail { margin: 0 10px; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 10px 10px; }
  .detail-inner { padding: 12px; }
  .detail-grid { grid-template-columns: 1fr; gap: 18px; }
  .book { gap: 10px; }
  .empty { padding: 36px 16px; }

  .filters { left: 0; width: auto; border-left: 0; animation: none; }
  .filters-head { padding-top: calc(12px + env(safe-area-inset-top)); }
  .fl { flex-wrap: wrap; gap: 4px 10px; }
  .fl-pair input { width: 88px; }
  .fl-flag { flex-wrap: nowrap; }
  .seg button { padding: 6px 10px; font-size: 13px; }

  .admin { padding: 10px; gap: 10px; }
  .card { padding: 14px; }
  .stack { max-width: none; }
  dl.kv { grid-template-columns: 1fr; gap: 0; }
  dl.kv dt { margin-top: 6px; }
  table.list { display: block; overflow-x: auto; }
  td.actions { white-space: normal; }
  td.actions button { margin: 2px 0 2px 4px; }
  .auth-box { padding: 22px 18px 18px; }
}

/* Narrower windows drop "updated", then "last sale", then "7 days". The buy price, the Steam prices
   and both profits always stay; the rest is in the expanded row and the filters. */
@media (min-width: 701px) and (max-width: 1260px) {
  :root { --cols: minmax(260px, 1fr) 128px 152px 126px 126px 144px 132px; }
  .h-age, .c-age { display: none; }
}
@media (min-width: 701px) and (max-width: 1100px) {
  :root { --cols: minmax(240px, 1fr) 124px 148px 122px 122px 140px; }
  .h-last, .c-last { display: none; }
  .quick { order: 5; flex-basis: 100%; }
}
@media (min-width: 701px) and (max-width: 940px) {
  :root { --cols: minmax(190px, 1fr) 114px 140px 110px 110px; }
  .h-week, .c-week { display: none; }
  .c, .h { padding-left: 10px; padding-right: 10px; }
  .c-item { padding-left: 12px; gap: 10px; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .d-chart { grid-column: 1 / -1; }
}

/* --- markets and games --- */
.markets .tab.active { background: rgba(102, 192, 244, 0.14); color: var(--steam); }
.tab-all { border-left: 1px solid var(--line) !important; border-radius: 0 6px 6px 0; }
.mk { font-size: 10px; font-weight: 700; line-height: 15px; padding: 0 5px; border-radius: 4px; }
.mk-sih { color: #ffc4a3; background: var(--accent-soft); }
.mk-skinport { color: #9fd8ff; background: rgba(102, 192, 244, 0.14); }
.mk-mrkt { color: #b9f0c9; background: rgba(74, 222, 128, 0.13); }
.mk-mannco { color: #e6c8ff; background: rgba(176, 124, 255, 0.15); }
.sub.alt { color: var(--muted); font-size: 11px; }
.gtag { color: var(--text-2); font-weight: 600; }
.sp-line { margin: 0 0 4px; }
@media (max-width: 700px) {
  .markets { order: 4; width: 100%; }
  .markets .tab { flex: 1; }
  .status { order: 5; }
}

/* --- admin: proxy list --- */
.proxies { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 4px; }
.proxy { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--surface-2); }
.proxy.off { opacity: 0.65; }
.proxy-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.proxy .btn-row { margin-top: 8px; }
.proxy .btn-row button { padding: 4px 10px; font-size: 12px; }
.proxy-edit { margin-top: 10px; }
#proxy-form h3 { margin: 4px 0 10px; font-size: 13px; }
@media (max-width: 700px) {
  /* Games not collected yet only take room on a phone. */
  .tabs .tab:disabled { display: none; }
  .tabs .tab { white-space: nowrap; }
}
