:root {
  --bg: #0d1220;
  --panel: #141b2d;
  --raise: #1b2540;
  --line: #27324e;
  --line-soft: #1f2942;
  --text: #e8edf8;
  --muted: #8c98b5;
  --gold: #f4b942;
  --gold-dim: #3a3120;
  --sky: #6ccbff;
  --up: #46d39a;
  --down: #ff6f61;
  --warn: #f0a04b;
  --radius: 10px;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: "Sora", "Manrope", system-ui, sans-serif;
  --side-w: 232px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--sky); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; border-radius: 4px; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; }
.muted { color: var(--muted); }
.gold { color: var(--gold); }
.up { color: var(--up); }
.down { color: var(--down); }
.hide { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 22px 14px; display: flex; flex-direction: column; gap: 26px; border-right: 1px solid var(--line-soft); background: #0b1020; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; }
.brand-name { font-family: var(--font-head); font-weight: 700; font-size: 20px; letter-spacing: -0.02em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; }
.nav a svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav a:hover { color: var(--text); background: var(--panel); text-decoration: none; }
.nav a.active { color: var(--gold); background: var(--gold-dim); }
.side-foot { margin-top: auto; padding: 0 8px; font-size: 12.5px; color: var(--muted); }
.live { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.live.on .dot { background: var(--up); box-shadow: 0 0 0 0 rgba(70, 211, 154, .6); animation: pulse 2.4s infinite; }
.live.off .dot { background: var(--down); }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(70, 211, 154, 0); } 100% { box-shadow: 0 0 0 0 rgba(70, 211, 154, 0); } }
.age { margin-top: 4px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 16px; padding: 16px 32px; border-bottom: 1px solid var(--line-soft); position: sticky; top: 0; z-index: 20; background: rgba(13, 18, 32, .92); backdrop-filter: blur(8px); }
.search { position: relative; flex: 1; max-width: 520px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
.search input { width: 100%; padding: 10px 14px 10px 38px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.search input::placeholder { color: var(--muted); }
.user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { width: 30px; height: 30px; border-radius: 6px; background: var(--raise); object-fit: cover; image-rendering: pixelated; }
#view { padding: 28px 32px 40px; flex: 1; max-width: 1400px; width: 100%; outline: none; }
.foot { padding: 20px 32px 28px; color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--line-soft); }

/* ---------- type & layout ---------- */
h1, h2, h3 { font-family: var(--font-head); letter-spacing: -0.015em; margin: 0; }
h1 { font-size: 28px; font-weight: 600; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 68ch; }
.section { margin-top: 30px; }
.head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px 16px; }
.stat .k { color: var(--muted); font-size: 13px; }
.stat .v { font-family: var(--font-head); font-size: 22px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .s { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.panel { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 18px; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--raise); font-weight: 600; cursor: pointer; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #1a1405; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.tabs { display: inline-flex; padding: 3px; gap: 2px; background: var(--panel); border: 1px solid var(--line-soft); border-radius: 9px; }
.tabs button { padding: 7px 14px; border: 0; background: transparent; color: var(--muted); font-weight: 600; border-radius: 7px; cursor: pointer; }
.tabs button:hover { color: var(--text); }
.tabs button.active { background: var(--raise); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.field input, .field select, .toolbar input[type=text], .toolbar input[type=search], .toolbar select, .form input { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; min-width: 120px; color: var(--text); }
.field input::placeholder, .form input::placeholder { color: #5d6988; }
.check { display: inline-flex; gap: 7px; align-items: center; color: var(--muted); cursor: pointer; font-size: 14px; }
.check input { accent-color: var(--gold); }
.form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form input { min-width: 240px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line-soft); }
th { font-size: 12.5px; font-weight: 600; color: var(--muted); background: #121a2c; position: sticky; top: 0; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th .arrow { margin-left: 4px; color: var(--gold); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover td { background: var(--raise); }
td.name { font-weight: 600; max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; color: var(--muted); font-size: 13.5px; }
.pager .btns { display: flex; gap: 6px; }

/* tier colouring, softened so it reads on the dark panel */
.tier { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.tier::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--c, #aab); }
.t-COMMON { --c: #c7ccd8; } .t-UNCOMMON { --c: #62d97a; } .t-RARE { --c: #5f86ff; } .t-EPIC { --c: #b866e8; }
.t-LEGENDARY { --c: #f4b942; } .t-MYTHIC { --c: #ff7ad9; } .t-DIVINE { --c: #6ee8e8; } .t-SPECIAL, .t-VERY_SPECIAL { --c: #ff6f61; } .t-ULTIMATE { --c: #d34a4a; }
.flag { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: rgba(240, 160, 75, .14); color: var(--warn); margin-right: 4px; }
.conf { font-weight: 700; font-size: 12.5px; }
.conf.high { color: var(--up); } .conf.medium { color: var(--gold); } .conf.low { color: var(--warn); }

/* ---------- flip ladder (dashboard) ---------- */
.ladder { display: flex; flex-direction: column; }
.rung { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 120px; gap: 14px; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--line-soft); color: inherit; }
.rung:last-child { border-bottom: 0; }
.rung:hover { text-decoration: none; background: rgba(27, 37, 64, .5); }
.rung .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rung .sub { color: var(--muted); font-size: 12.5px; }
.rung .bar { height: 6px; border-radius: 3px; background: var(--line-soft); overflow: hidden; }
.rung .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), #ffd987); border-radius: 3px; }
.rung .gain { font-family: var(--font-head); font-weight: 600; font-size: 17px; color: var(--gold); text-align: right; font-variant-numeric: tabular-nums; min-width: 84px; }

/* ---------- chart ---------- */
.chart-wrap { position: relative; width: 100%; }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.chart-tip { position: absolute; pointer-events: none; background: #0b1020; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; min-width: 150px; z-index: 5; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }
.chart-tip .t { color: var(--muted); margin-bottom: 4px; }
.chart-tip .r { display: flex; justify-content: space-between; gap: 14px; }
.chart-tip .r i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }

/* ---------- order book ---------- */
.book { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.book .row { position: relative; display: flex; justify-content: space-between; padding: 6px 8px; font-size: 13.5px; font-variant-numeric: tabular-nums; border-radius: 4px; overflow: hidden; }
.book .row i { position: absolute; inset: 0 auto 0 0; opacity: .16; }
.book .row span { position: relative; }
.book .buy i { background: var(--up); } .book .sell i { background: var(--down); }

/* ---------- account ---------- */
.suggest { display: flex; flex-direction: column; gap: 10px; }
.suggest .item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); }
.suggest .item .gain { color: var(--gold); font-family: var(--font-head); font-weight: 600; text-align: right; }
.suggest .item p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }
.suggest .kind { font-size: 12px; font-weight: 700; color: var(--sky); margin-bottom: 2px; }
.who { display: flex; align-items: center; gap: 14px; }
.who img { width: 52px; height: 52px; border-radius: 8px; image-rendering: pixelated; }
.splitbar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--line-soft); margin-top: 6px; }
.splitbar i { display: block; height: 100%; }
.cont { display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; font-size: 14px; }
.banner { padding: 12px 16px; border-radius: var(--radius); border: 1px solid rgba(240, 160, 75, .4); background: rgba(240, 160, 75, .08); color: #ffd9a8; margin-bottom: 16px; }
.banner.info { border-color: rgba(108, 203, 255, .35); background: rgba(108, 203, 255, .07); color: #cfeeff; }
.steps { margin: 10px 0 0; padding-left: 20px; color: var(--muted); }
.steps li { margin: 4px 0; }

/* ---------- misc ---------- */
.skel { background: linear-gradient(90deg, var(--panel), var(--raise), var(--panel)); background-size: 200% 100%; animation: sk 1.4s linear infinite; border-radius: 8px; min-height: 18px; }
@keyframes sk { to { background-position: -200% 0; } }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--raise); border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 50; }
#toast.show { opacity: 1; transform: translateX(-50%); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.range { display: inline-flex; gap: 4px; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: auto 0 0 0; height: auto; z-index: 30; flex-direction: row; padding: 6px 8px; border-right: 0; border-top: 1px solid var(--line); gap: 0; }
  .brand, .side-foot { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 2px; padding: 6px 8px; font-size: 11.5px; }
  .top { padding: 12px 16px; }
  #view { padding: 20px 16px 96px; }
  .foot { padding: 16px 16px 90px; }
  .grid-2, .book { grid-template-columns: 1fr; }
  h1 { font-size: 23px; }
  .rung { grid-template-columns: minmax(0, 1fr) auto; }
  .rung .bar { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .live.on .dot, .skel { animation: none; }
  #toast { transition: none; }
}
