:root {
  color-scheme: light;
  --bg: #f6f3ec;
  --surface: #fcfcfb;
  --line: #e7e3da;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #6f6e69;
  --series-1: #2a78d6;
  --track: #efece4;
  --brand: #f4c430;
  --brand-ink: #2c2110;
  --warn-bg: #fdf0d8;
  --warn-ink: #6d4a00;
  --err: #b3261e;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --line: #2d2d2b;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --ink-3: #a3a297;
    --series-1: #3987e5;
    --track: #262624;
    --warn-bg: #3a2e12;
    --warn-ink: #f0d596;
    --err: #f2b8b5;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
h2 { font-size: 22px; font-weight: 700; margin-bottom: 12px; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
.mark { background: var(--brand); color: var(--brand-ink); padding: 2px 8px; border-radius: 6px; }
.muted { color: var(--ink-2); }
.note { color: var(--ink-2); font-size: 13px; margin-top: 8px; }
button, select, input { font: inherit; color: inherit; }
button, select, input:not([type="checkbox"]) {
  min-height: 40px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
}
button { cursor: pointer; font-weight: 600; }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }

.top { position: sticky; top: 0; z-index: 10; background: var(--bg); border-bottom: 1px solid var(--line); }
.top-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  max-width: 1040px; margin: 0 auto; padding: 10px 16px 6px;
}
.top-actions { display: flex; align-items: center; gap: 6px; }
.top-actions form { margin: 0; }
.range { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.tabs { display: flex; gap: 2px; max-width: 1040px; margin: 0 auto; padding: 0 10px 6px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14px; }
.tabs a:hover { background: var(--track); }

main { max-width: 1040px; margin: 0 auto; padding: 8px 16px 48px; }
section { padding-top: 20px; scroll-margin-top: 108px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.card > h3 { margin-bottom: 10px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.tile b { display: block; font-size: 24px; font-weight: 700; line-height: 1.15; }
.tile span { color: var(--ink-2); font-size: 13px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: right; font-weight: 600; color: var(--ink-2); font-size: 12.5px; padding: 6px 8px; white-space: nowrap; border-bottom: 1px solid var(--line); }
td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
td small { color: var(--ink-3); font-size: 12px; }
.sticky th:first-child, .sticky td:first-child { position: sticky; left: 0; background: var(--surface); }

details { margin-top: 10px; }
summary { cursor: pointer; color: var(--ink-2); font-size: 13px; min-height: 28px; }

.badge { display: inline-block; background: var(--warn-bg); color: var(--warn-ink); font-size: 13px; font-weight: 650; padding: 3px 9px; border-radius: 999px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head h3 { margin: 0; }
.status { color: var(--ink-3); font-size: 12.5px; margin-top: 8px; }
.status.err { color: var(--err); }

.chart { position: relative; }
.chart-readout { font-size: 13px; color: var(--ink-2); min-height: 20px; margin-bottom: 4px; }
.chart-readout b { color: var(--ink); }
.chart-plot { position: relative; height: 120px; display: flex; align-items: flex-end; gap: 2px; border-bottom: 1px solid var(--line); }
.chart-max { position: absolute; top: 0; left: 0; right: 0; border-top: 1px solid var(--line); font-size: 11px; color: var(--ink-3); pointer-events: none; }
.chart-max span { position: absolute; top: 1px; left: 0; background: var(--surface); padding-right: 4px; }
.col { flex: 1 1 0; min-width: 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; background: none; border: 0; padding: 0; min-height: 0; border-radius: 0; cursor: default; }
.col i { display: block; width: 100%; max-width: 24px; background: var(--series-1); border-radius: 4px 4px 0 0; min-height: 0; }
.col:hover i, .col.on i { opacity: .72; }
.chart-axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }

.funnel { display: grid; gap: 5px; }
.fn-row { display: grid; grid-template-columns: 82px 1fr 92px; align-items: center; gap: 8px; font-size: 13.5px; }
.fn-bar { height: 16px; background: var(--track); border-radius: 0 4px 4px 0; overflow: hidden; }
.fn-bar i { display: block; height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.fn-val { text-align: right; white-space: nowrap; }
.fn-val small { color: var(--ink-3); font-size: 12px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; align-items: flex-end; }
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--ink-2); flex: 1 1 130px; min-width: 0; }
.filters select, .filters input:not([type="checkbox"]) { width: 100%; color: var(--ink); }
.filters .check { flex-direction: row; align-items: center; gap: 8px; min-height: 40px; color: var(--ink); }
.filters .check input { width: 20px; height: 20px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.pager span { color: var(--ink-2); font-size: 13px; }

@media (max-width: 640px) {
  .range-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .top-row { padding: 8px 16px 2px; flex-wrap: nowrap; }
  .top-actions button, .top-actions select { min-height: 36px; padding: 4px 8px; font-size: 14px; }
  h1 { font-size: 15px; gap: 5px; }
  .tabs a { padding: 8px 7px; }
  section { scroll-margin-top: 96px; }
  .summary td small { display: block; }
  .summary th, .summary td { padding-left: 4px; padding-right: 4px; }
  .players thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .players, .players tbody { display: block; width: 100%; }
  .players tr { display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line); }
  .players tr:last-child { border-bottom: 0; }
  .players td { border: 0; padding: 1px 0; display: flex; justify-content: space-between; gap: 6px; font-size: 13.5px; white-space: nowrap; text-align: right; min-width: 0; }
  .players td::before { content: attr(data-label); color: var(--ink-2); font-size: 12.5px; }
  .players td:first-child { grid-column: 1 / -1; font-weight: 700; padding: 0 0 3px; }
}

body.login { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.login-card h1 { margin-bottom: 8px; }
.login-card label { font-size: 13px; color: var(--ink-2); }
.login-card input { width: 100%; }
.login-card button { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.error { color: var(--err); font-size: 14px; }
