/* Road to Max: minimal dark theme */
:root {
  color-scheme: dark;
  --bg: #0e1014; --side: #111419; --panel: #151920; --panel-2: #1a1f27; --hover: #1e242d;
  --border: #242a33; --border-2: #2e3540;
  --text: #e8eaed; --text-2: #a3aab4; --muted: #6d7581;
  --accent: #4c8dff; --accent-hover: #3d7cf0; --accent-soft: rgba(76, 141, 255, .14);
  --pos: #3ecf75; --neg: #f06262; --gold: #e3b04b; --gold-soft: rgba(227, 176, 75, .14);
  --grid: #20262e;
  --s1:#3987e5; --s2:#d95926; --s3:#199e70; --s4:#c98500; --s5:#d55181; --s6:#008300; --s7:#9085e9; --s8:#e66767; --other:#5c636d;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 8px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .sub { color: var(--text-2); }
.pos { color: var(--pos); } .neg { color: var(--neg); } .zero { color: var(--text-2); }
.gold { color: var(--gold); }
[hidden] { display: none !important; }

/* ---------- shell: sidebar + main ---------- */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); border-right: 1px solid var(--border); padding: 18px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 4px 8px 18px; letter-spacing: -0.01em; }
.brand svg { width: 28px; height: 28px; flex: none; }
.nav a, .nav button { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 7px; color: var(--text-2); font-weight: 500; font-size: 14.5px; width: 100%; background: none; border: 0; cursor: pointer; text-align: left; }
.nav a:hover, .nav button:hover { background: var(--hover); color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--text); }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav-sep { height: 1px; background: var(--border); margin: 12px 4px; }
.nav-label { font-size: 12.5px; color: var(--muted); padding: 4px 10px 2px; }
.side .grow { flex: 1; }
.side .foot { font-size: 12px; color: var(--muted); padding: 10px; line-height: 1.45; }
.main { min-width: 0; }
.topbar { height: 64px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: flex-end; padding: 0 28px; gap: 12px; position: sticky; top: 0; background: rgba(14, 16, 20, .92); backdrop-filter: blur(6px); z-index: 10; }
.topbar .mobile-brand { display: none; }
.search { position: relative; width: 260px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search input { width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px 8px 34px; font-size: 14px; }
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; border-color: var(--accent); }
.search input { padding-right: 58px; }
.kbd { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font: 600 11px var(--font); color: var(--muted); border: 1px solid var(--border-2); border-radius: 5px; padding: 1px 5px; pointer-events: none; }
.search-pop { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--panel); border: 1px solid var(--border-2); border-radius: 10px; box-shadow: 0 14px 34px rgba(0,0,0,.5); padding: 6px; z-index: 20; max-height: 380px; overflow-y: auto; }
.search-head { font-size: 12.5px; color: var(--text-2); padding: 6px 8px 8px; }
.sr { display: flex; align-items: center; gap: 11px; padding: 8px; border-radius: 7px; cursor: pointer; font-size: 14px; }
.sr.on { background: var(--hover); }
.sr b { font-weight: 700; }
.sr-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-av, .sr-ic { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border-2); background: var(--panel-2); display: grid; place-items: center; flex: none; font-weight: 800; font-size: 13px; color: var(--gold); }
.sr-ic { color: var(--text-2); }
.badge { width: 55%; height: 55%; object-fit: contain; image-rendering: pixelated; }
.sr-av .badge { width: 17px; height: 17px; }
/* Small account-type icon shown next to a player's name in lists */
.with-av { display: inline-flex; align-items: center; gap: 9px; min-width: 0; max-width: 100%; vertical-align: middle; }
.with-av > .nm-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-av { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--border-2); background: var(--panel-2); display: grid; place-items: center; font-size: 11px; font-weight: 800; color: var(--gold); flex: none; }
.mini-av .badge { width: 14px; height: 14px; object-fit: contain; }
.sr-ic svg { position: static; transform: none; width: 15px; height: 15px; }
.sr-lvl { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 900px) { .kbd { display: none; } .search input { padding-right: 12px; } }
.content { max-width: 1040px; margin: 0 auto; padding: 32px 28px 64px; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--border); gap: 2px; }
  .side .brand { padding: 4px 8px 4px 4px; }
  .side .nav { display: contents; }
  .side .nav a, .side .nav button { width: auto; padding: 7px 9px; font-size: 13.5px; }
  .side .nav-sep, .side .nav-label, .side .grow, .side .foot, .side .plans { display: none; }
  .nav svg { display: none; }
  .topbar { height: 56px; padding: 0 16px; position: static; }
  .search { width: 100%; }
  .content { padding: 22px 16px 48px; }
}

/* ---------- building blocks ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border-2); background: var(--panel-2); color: var(--text); border-radius: var(--radius); padding: 8px 14px; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .6; cursor: progress; }
.field, select.field { background: var(--panel); border: 1px solid var(--border-2); border-radius: var(--radius); padding: 8px 12px; min-width: 0; }
.field:focus { outline: none; border-color: var(--accent); }
select.field { padding-right: 30px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a3aab4' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; cursor: pointer; }

.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
@media (max-width: 760px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 16px; min-width: 0; }
.card .k { font-size: 12.5px; color: var(--text-2); }
.card .v { font-size: 15px; font-weight: 700; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card.big .v { font-size: 22px; letter-spacing: -0.01em; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.panel-head h2 { font-size: 17px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.panel-head .desc { font-size: 13.5px; color: var(--text-2); margin-top: 2px; }
.panel-head .desc b { color: var(--text); font-weight: 600; }
.panel-head .right { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.panel-body { padding: 16px 20px; }
.panel.chart-panel .panel-body { padding: 14px 18px 10px; }

.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 12.5px; color: var(--text-2); font-weight: 500; padding: 11px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; }
.tbl th.sort { cursor: pointer; } .tbl th.sort:hover { color: var(--text); }
.tbl th .ar { display: inline-block; margin-left: 4px; opacity: .55; font-size: 10px; }
.tbl th.sorted .ar { opacity: 1; color: var(--text); }
.tbl td { padding: 11px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.name { font-weight: 600; }
.icw { display: inline-flex; width: 20px; height: 20px; margin-right: 10px; vertical-align: -5px; align-items: center; justify-content: center; flex: none; }
.ic { max-width: 20px; max-height: 20px; object-fit: contain; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: var(--hover); }
.tbl tbody tr.sel td { background: var(--accent-soft); }
.tbl tbody tr.sel td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
.tbl tr.pinned td { background: var(--panel-2); }
.tbl .r { text-align: right; }
.bar { display: inline-block; width: 90px; height: 6px; border-radius: 3px; background: var(--panel-2); vertical-align: middle; overflow: hidden; margin-right: 8px; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.full > span { background: var(--gold); }
.tbl input { width: 100px; background: var(--panel-2); border: 1px solid transparent; border-radius: 6px; padding: 4px 8px; text-align: right; font-variant-numeric: tabular-nums; }
.tbl input.txt { width: 120px; text-align: left; }
.tbl input:hover { border-color: var(--border-2); }
.tbl input:focus { outline: none; border-color: var(--accent); }

.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 2px; }
.seg button { border: 0; background: transparent; color: var(--text-2); padding: 5px 11px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; }
.seg button.on { background: var(--hover); color: var(--text); }

.tabs { display: flex; gap: 26px; border-bottom: 1px solid var(--border); margin: 0 0 22px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 12px 0; color: var(--text-2); font-weight: 500; font-size: 14.5px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); font-weight: 600; }

.empty { color: var(--muted); padding: 34px 16px; text-align: center; }
.msg-err { color: var(--neg); font-size: 13.5px; min-height: 20px; margin-top: 8px; }

/* charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11.5px; font-family: var(--font); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--text-2); margin: 0 0 8px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }
.tip { position: absolute; pointer-events: none; z-index: 5; background: var(--panel-2); border: 1px solid var(--border-2); box-shadow: 0 10px 28px rgba(0,0,0,.45); border-radius: 8px; padding: 8px 11px; font-size: 12.5px; min-width: 150px; display: none; white-space: nowrap; }
.tip b { display: block; margin-bottom: 3px; }
.tip .r { display: flex; gap: 12px; justify-content: space-between; color: var(--text-2); }
.tip .r span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }
.tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

dialog { border: 1px solid var(--border-2); border-radius: 12px; background: var(--panel); color: var(--text); padding: 0; width: min(460px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog form { padding: 22px; }
dialog h2 { font-size: 18px; margin: 0 0 4px; }
dialog p { color: var(--text-2); margin: 0 0 8px; font-size: 13.5px; }
dialog label { display: block; margin-top: 12px; font-size: 13px; color: var(--text-2); }
dialog input { width: 100%; margin-top: 5px; }
dialog .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
dialog .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
dialog .foot { display: flex; gap: 8px; margin-top: 22px; } dialog .foot .grow { flex: 1; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-size: 13.5px; font-weight: 500; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 30; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
