:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --raised: #ffffff;
  --line: #e2e1dc;
  --grid: #ecebe6;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #75746f;
  --accent: #2a78d6;
  --series-1: #2a78d6;  /* market */
  --series-2: #eb6834;  /* lowest */
  --gold: #a07800; --silver: #6f7378; --copper: #a4532b;
  --good: #0b7a0b; --bad: #c03030;
  --q0: #6b6b6b; --q1: #1b1b1b; --q2: #138a00; --q3: #0062c4; --q4: #8a2bd6; --q5: #d36b00;
  --row-hover: #f1f0ec;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --raised: #222221; --line: #343432; --grid: #2a2a28;
    --ink: #f0efec; --ink-2: #c3c2b7; --ink-3: #9a998f; --accent: #3987e5;
    --series-1: #3987e5; --series-2: #d95926;
    --gold: #f2c94c; --silver: #c9ccd1; --copper: #e08a5a;
    --good: #3ec43e; --bad: #f07070;
    --q0: #9d9d9d; --q1: #ffffff; --q2: #1eff00; --q3: #3d9bff; --q4: #b863ff; --q5: #ff8000;
    --row-hover: #262624;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --raised: #222221; --line: #343432; --grid: #2a2a28;
  --ink: #f0efec; --ink-2: #c3c2b7; --ink-3: #9a998f; --accent: #3987e5;
  --series-1: #3987e5; --series-2: #d95926;
  --gold: #f2c94c; --silver: #c9ccd1; --copper: #e08a5a;
  --good: #3ec43e; --bad: #f07070;
  --q0: #9d9d9d; --q1: #ffffff; --q2: #1eff00; --q3: #3d9bff; --q4: #b863ff; --q5: #ff8000;
  --row-hover: #262624;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.muted { color: var(--ink-2); }
button, input, select { font: inherit; color: inherit; }

.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface);
  position: sticky; top: 0; z-index: 5;
}
.top h1 { font-size: 18px; margin: 0; }
main { max-width: 1200px; margin: 0 auto; padding: 16px; }

select, input[type=search], input[type=number] {
  background: var(--raised); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-height: 34px;
}
input[type=search] { flex: 1 1 220px; min-width: 0; }
input[type=number] { width: 64px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lvl, .check { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
#count { margin: 10px 0 6px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--grid); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
th { font-weight: 600; color: var(--ink-2); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--ink); }
th.sorted::after { content: " ▾"; }
th.sorted.asc::after { content: " ▴"; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
#list tbody tr { cursor: pointer; }
#list tbody tr:hover, #list tbody tr:focus-visible { background: var(--row-hover); outline: none; }
td.name { white-space: normal; min-width: 180px; }
td.name a, #i-name a { text-decoration: none; font-weight: 500; }
.rq0 { color: var(--q0) !important; } .rq1 { color: var(--q1) !important; } .rq2 { color: var(--q2) !important; }
.rq3 { color: var(--q3) !important; } .rq4 { color: var(--q4) !important; } .rq5 { color: var(--q5) !important; }
.sub { display: block; font-size: 12px; color: var(--ink-3); font-weight: 400; }

.money { white-space: nowrap; font-variant-numeric: tabular-nums; }
.money .g { color: var(--gold); } .money .s { color: var(--silver); } .money .c { color: var(--copper); }
.money i { font-style: normal; font-size: .85em; margin-left: 1px; margin-right: 3px; }
.up { color: var(--bad); } .down { color: var(--good); }

.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 12px 0 24px; }
.pager button, button.link {
  background: var(--raised); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer;
}
.pager button:disabled { opacity: .4; cursor: default; }
button.link { margin-bottom: 8px; }

#item h2 { margin: 8px 0 2px; font-size: 22px; }
#item h3 { margin: 24px 0 8px; font-size: 15px; }
.stats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; min-width: 130px; }
.stat b { display: block; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.stat span { font-size: 17px; }

.chart { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px; position: relative; }
.chart svg { display: block; width: 100%; height: 260px; overflow: visible; }
.chart .legend { display: flex; gap: 16px; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.chart .legend span::before { content: ""; display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 6px; background: var(--c); }
.tip {
  position: absolute; pointer-events: none; background: var(--raised); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 9px; font-size: 13px; box-shadow: 0 4px 14px rgb(0 0 0 / .18); white-space: nowrap; z-index: 2;
}
.tip .k { color: var(--ink-2); }
.tip .sw { display: inline-block; width: 10px; height: 2px; margin-right: 6px; vertical-align: middle; }
details { margin-top: 8px; color: var(--ink-2); }
details .table-wrap { margin-top: 8px; color: var(--ink); }

@media (max-width: 640px) {
  .hide-s { display: none; }
  th, td { padding: 7px 8px; }
  td.name { min-width: 0; }
}
