:root {
  --bg: #0a0e16;
  --bg2: #0e1420;
  --panel: #111827;
  --panel2: #151d2e;
  --line: #1f2a3d;
  --line2: #2a3850;
  --text: #e6ebf5;
  --muted: #8b97ad;
  --dim: #5d6b85;
  --good: #2dd4a8;
  --good-bg: rgba(45, 212, 168, 0.12);
  --bad: #f87171;
  --bad-bg: rgba(248, 113, 113, 0.12);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.12);
  --brand: #8b7bff;
  --brand-bg: rgba(139, 123, 255, 0.14);
  --info: #60a5fa;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 500px at 20% -10%, #141b2e 0%, var(--bg) 60%);
  color: var(--text);
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 13.5px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
b, strong { font-weight: 650; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-weight: 400; }
.dim { color: var(--dim); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }

#app { max-width: 1760px; margin: 0 auto; padding: 14px 18px 18px; display: flex; flex-direction: column; gap: 12px; min-height: 100%; }

/* ------------------------------------------------ top bar */
.topbar { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 11px; min-width: 250px; }
.logo { width: 38px; height: 38px; flex: none; filter: drop-shadow(0 4px 12px rgba(124, 92, 255, 0.35)); }
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: 0.2px; }
.brand-sub { color: var(--muted); font-size: 12px; }
.brand-sub b { color: var(--warn); font-weight: 600; }

.status { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 12.5px; max-width: 420px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.dot.live { background: var(--good); box-shadow: 0 0 0 0 rgba(45, 212, 168, 0.6); animation: pulse 1.8s infinite; }
.dot.demo { background: var(--warn); animation: pulse-w 1.8s infinite; }
.dot.warn { background: var(--warn); }
.dot.off { background: var(--bad); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(45, 212, 168, 0.55); } 70% { box-shadow: 0 0 0 8px rgba(45, 212, 168, 0); } 100% { box-shadow: 0 0 0 0 rgba(45, 212, 168, 0); } }
@keyframes pulse-w { 0% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.5); } 70% { box-shadow: 0 0 0 8px rgba(251, 191, 36, 0); } 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); } }
.status span.txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pricebox { display: flex; align-items: baseline; gap: 10px; margin-left: auto; }
.pricebox .px { font-size: 26px; font-weight: 700; letter-spacing: 0.3px; }
.pricebox .chg { font-size: 13px; font-weight: 600; }
.pricebox .meta { color: var(--muted); font-size: 11.5px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { background: var(--panel2); border: 1px solid var(--line2); padding: 8px 13px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 12.8px; transition: background 0.15s, border-color 0.15s, transform 0.05s; white-space: nowrap; }
.btn:hover:not(:disabled) { background: #1b2740; border-color: #3a4d6e; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, #7c5cff, #5b7bff); border-color: transparent; color: #fff; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.1); background: linear-gradient(135deg, #7c5cff, #5b7bff); }
.btn.go { background: var(--good-bg); border-color: rgba(45, 212, 168, 0.4); color: var(--good); }
.btn.stop { background: var(--warn-bg); border-color: rgba(251, 191, 36, 0.4); color: var(--warn); }
.btn.danger { background: var(--bad-bg); border-color: rgba(248, 113, 113, 0.4); color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:focus-visible, .tab:focus-visible, .chip:focus-visible, tr.row:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ------------------------------------------------ banners */
#banners { display: flex; flex-direction: column; gap: 8px; }
.banner { display: flex; align-items: center; gap: 12px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line2); background: var(--panel); font-size: 13px; }
.banner.info { background: var(--brand-bg); border-color: rgba(139, 123, 255, 0.4); }
.banner.warn { background: var(--warn-bg); border-color: rgba(251, 191, 36, 0.4); }
.banner.bad { background: var(--bad-bg); border-color: rgba(248, 113, 113, 0.4); }
.banner .grow { flex: 1; }
.banner .x { cursor: pointer; opacity: 0.6; border: 0; background: none; font-size: 16px; line-height: 1; padding: 2px 6px; }
.banner .x:hover { opacity: 1; }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, #7c5cff, #2dd4a8); transition: width 0.2s; }

/* ------------------------------------------------ KPI cards */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--line2); }
.kpi.k-good::before { background: var(--good); }
.kpi.k-bad::before { background: var(--bad); }
.kpi.k-brand::before { background: var(--brand); }
.kpi.k-warn::before { background: var(--warn); }
.kpi .lbl { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.7px; font-weight: 600; }
.kpi .val { font-size: 27px; font-weight: 700; margin-top: 3px; letter-spacing: 0.2px; white-space: nowrap; }
.kpi .val small { font-size: 14px; font-weight: 600; color: var(--muted); }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.hero .val { font-size: 32px; }

/* ------------------------------------------------ layout */
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 12px; align-items: start; flex: 1; }
.col-main, .col-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 11px 14px 4px; }
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 650; }
.chart { height: 250px; }
#race { padding: 4px 8px 10px; }
.feed-panel { display: flex; flex-direction: column; }
.feed { max-height: 430px; overflow-y: auto; padding: 4px 6px 8px; }

.foot { color: var(--dim); font-size: 11.5px; text-align: center; padding: 4px 0 0; }

/* ------------------------------------------------ tabs & table */
.tabs { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.tab { background: none; border: 0; padding: 9px 14px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 13.5px; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--brand); }
.tab .cnt { background: var(--panel2); border: 1px solid var(--line2); border-radius: 99px; padding: 0 7px; margin-left: 6px; font-size: 11.5px; color: var(--muted); }
.tab.on .cnt { color: var(--text); background: var(--brand-bg); border-color: rgba(139, 123, 255, 0.4); }
.tabs .spacer { flex: 1; }

.filters { display: flex; gap: 6px; padding: 10px 14px 6px; align-items: center; flex-wrap: wrap; }
.chip { border: 1px solid var(--line2); background: var(--panel2); border-radius: 99px; padding: 4px 11px; cursor: pointer; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.chip:hover { color: var(--text); }
.chip.on { background: var(--brand-bg); border-color: rgba(139, 123, 255, 0.5); color: var(--text); }
.filters .hint { margin-left: auto; color: var(--dim); font-size: 12px; }

.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--dim); font-weight: 600; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th.r, .tbl td.r { text-align: right; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid rgba(31, 42, 61, 0.6); vertical-align: middle; }
tr.row { cursor: pointer; transition: background 0.12s; }
tr.row:hover { background: rgba(139, 123, 255, 0.07); }
tr.row.sel { background: rgba(139, 123, 255, 0.12); }
tr.row.dead { opacity: 0.55; }
tr.row.winner td:first-child { box-shadow: inset 3px 0 0 var(--good); }
.rank { color: var(--dim); font-weight: 600; width: 34px; }
.aname { font-weight: 650; font-size: 14px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.strat { color: var(--text); font-weight: 600; font-size: 12.8px; }
.strat-sub { color: var(--muted); font-size: 11.8px; max-width: 250px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.money { font-weight: 700; font-size: 15px; }
.money small { display: block; font-weight: 600; font-size: 12px; opacity: 0.9; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 99px; font-size: 10.8px; font-weight: 650; border: 1px solid var(--line2); color: var(--muted); background: var(--panel2); letter-spacing: 0.2px; white-space: nowrap; }
.badge.gen { color: var(--brand); border-color: rgba(139, 123, 255, 0.4); background: var(--brand-bg); }
.badge.hof { color: var(--warn); border-color: rgba(251, 191, 36, 0.45); background: var(--warn-bg); }
.badge.live { color: var(--good); border-color: rgba(45, 212, 168, 0.4); background: var(--good-bg); }
.badge.hist { color: var(--info); border-color: rgba(96, 165, 250, 0.4); background: rgba(96, 165, 250, 0.1); }
.badge.unv { color: var(--muted); }
.badge.dead { color: var(--bad); border-color: rgba(248, 113, 113, 0.4); background: var(--bad-bg); }
.pos { font-size: 12px; white-space: nowrap; }
.pos .side { font-weight: 700; }
.pos .side.long { color: var(--good); }
.pos .side.short { color: var(--bad); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 15px; color: var(--text); font-weight: 600; margin-bottom: 4px; }
svg.spark { display: block; }

/* ------------------------------------------------ feed */
.ev { display: flex; gap: 8px; padding: 6px 8px; border-radius: 8px; font-size: 12.5px; line-height: 1.35; }
.ev:hover { background: rgba(255, 255, 255, 0.03); }
.ev .ic { flex: none; width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; font-size: 11px; font-weight: 700; margin-top: 1px; background: var(--panel2); color: var(--muted); }
.ev.good .ic { background: var(--good-bg); color: var(--good); }
.ev.bad .ic { background: var(--bad-bg); color: var(--bad); }
.ev.t-clone .ic, .ev.t-mutation .ic { background: var(--brand-bg); color: var(--brand); }
.ev.t-news .ic { background: var(--warn-bg); color: var(--warn); }
.ev .tm { color: var(--dim); font-size: 11px; display: block; }
@keyframes slidein { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------ news */
.badge.riskoff { color: var(--warn); border-color: rgba(251, 191, 36, 0.45); background: var(--warn-bg); }
.newslist { padding: 4px 8px 8px; max-height: 260px; overflow-y: auto; }
.nw { display: flex; gap: 8px; padding: 6px 4px; font-size: 12.5px; line-height: 1.35; border-radius: 8px; }
.nw .badge { flex: none; align-self: flex-start; margin-top: 1px; }
.nw.high { background: var(--warn-bg); }
.nw a { color: var(--text); text-decoration: none; }
.nw a:hover { text-decoration: underline; }
.nw .tm { color: var(--dim); font-size: 11px; display: block; }

/* ------------------------------------------------ drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 520px; max-width: 94vw; background: var(--bg2); border-left: 1px solid var(--line2); box-shadow: var(--shadow); transform: translateX(105%); transition: transform 0.22s ease; z-index: 20; overflow-y: auto; }
.drawer.open { transform: none; }
.drawer .dh { position: sticky; top: 0; background: rgba(14, 20, 32, 0.96); backdrop-filter: blur(6px); padding: 14px 18px 12px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; z-index: 2; }
.drawer .dh h3 { margin: 0; font-size: 20px; }
.drawer .dh .x { margin-left: auto; }
.drawer section { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer h4 { margin: 0 0 8px; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); }
.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.stat .l { color: var(--muted); font-size: 11px; }
.stat .v { font-weight: 700; font-size: 16px; }
.rules { margin: 0; padding-left: 18px; color: var(--text); }
.rules li { margin: 4px 0; color: #cdd6e6; }
.dna { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 18px; font-size: 12.3px; }
.dna div { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 2px 0; }
.dna span:first-child { color: var(--muted); }
.mini { width: 100%; }
.trade { display: grid; grid-template-columns: 52px 1fr auto; gap: 8px; padding: 5px 0; border-bottom: 1px solid rgba(31, 42, 61, 0.5); font-size: 12.3px; align-items: center; }
.mod { padding: 7px 0; border-bottom: 1px solid rgba(31, 42, 61, 0.5); font-size: 12.3px; }
.mod .why { color: var(--muted); }
.note { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; color: #cdd6e6; font-size: 12.5px; }
.shade { position: fixed; inset: 0; background: rgba(4, 7, 12, 0.5); z-index: 15; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.shade.on { opacity: 1; pointer-events: auto; }

/* ------------------------------------------------ modal */
.modal-wrap { position: fixed; inset: 0; display: none; place-items: center; background: rgba(4, 7, 12, 0.66); z-index: 40; padding: 20px; }
.modal-wrap.open { display: grid; }
.modal { width: 720px; max-width: 100%; max-height: 90vh; overflow-y: auto; background: var(--bg2); border: 1px solid var(--line2); border-radius: 16px; box-shadow: var(--shadow); }
.modal .mh { display: flex; align-items: center; padding: 16px 20px 10px; position: sticky; top: 0; background: var(--bg2); z-index: 1; border-bottom: 1px solid var(--line); }
.modal .mh h3 { margin: 0; font-size: 18px; flex: 1; }
.modal .mb { padding: 6px 20px 8px; }
.modal .mf { padding: 12px 20px 16px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--bg2); }
.sect { padding: 12px 0 10px; border-bottom: 1px solid var(--line); }
.sect:last-child { border-bottom: 0; }
.sect h5 { margin: 0 0 8px; font-size: 13px; font-weight: 650; }
.sect p.help { margin: 0 0 8px; color: var(--muted); font-size: 12.3px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.field input[type="number"], .field input[type="text"], .field input[type="password"], .field select { width: 100%; background: var(--panel); border: 1px solid var(--line2); color: var(--text); padding: 7px 9px; border-radius: 8px; font: inherit; }
.field input:focus, .field select:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
.field .hint { font-size: 11.5px; color: var(--dim); margin-top: 2px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; margin: 4px 0; }
.check input { margin-top: 3px; accent-color: #7c5cff; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 9px; overflow: hidden; }
.seg button { background: var(--panel); border: 0; padding: 7px 14px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--brand-bg); color: var(--text); }
.callout { background: var(--warn-bg); border: 1px solid rgba(251, 191, 36, 0.35); border-radius: 10px; padding: 9px 12px; font-size: 12.5px; color: #f3dca0; }
.callout.info { background: var(--brand-bg); border-color: rgba(139, 123, 255, 0.35); color: #cfc8ff; }
.row2 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.explain h3 { margin: 16px 0 6px; font-size: 15px; }
.explain p, .explain li { color: #cdd6e6; max-width: 900px; }
.explain { padding: 8px 18px 18px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 10px; padding: 12px 14px 14px; }
.card { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px; cursor: pointer; }
.card:hover { border-color: var(--line2); background: #19233a; }
.card .ct { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.card .cs { color: var(--muted); font-size: 12px; margin: 3px 0 8px; }
.card .cm { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; font-size: 12px; }
.card .cm .l { color: var(--dim); font-size: 10.8px; text-transform: uppercase; letter-spacing: 0.5px; }
.card .cm .v { font-weight: 650; }
.hof-bar { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.hof-bar .grow { flex: 1; min-width: 260px; color: var(--muted); font-size: 12.5px; }

/* ------------------------------------------------ history tab */
.hkpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; padding: 12px 14px 4px; }
.hkpis .kpi .val { font-size: 22px; }
.hpad { padding: 8px 14px; font-size: 12.5px; }
.hhead { border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.sel { background: var(--panel); border: 1px solid var(--line2); color: var(--text); padding: 5px 9px; border-radius: 8px; font: inherit; font-size: 12.5px; }
.sel:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--text); }
.pager { display: flex; gap: 12px; align-items: center; justify-content: flex-end; padding: 10px 14px; font-size: 12.5px; }
.hdetail { margin: 8px 14px 12px; padding: 12px 14px; background: var(--panel2); border: 1px solid var(--line2); border-radius: 12px; }
.hsub { margin: 14px 0 6px; font-size: 13px; }
.hevents { padding: 4px 10px 10px; max-height: 420px; overflow-y: auto; }
@media (max-width: 1100px) { .hkpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .col-side { flex-direction: row; }
  .col-side > .panel { flex: 1; }
}

/* leaderboard: drop the least important columns before the table needs to scroll */
.tbl td, .tbl th { padding-left: 8px; padding-right: 8px; }
@media (max-width: 1560px) { .tbl .c-spark { display: none; } }
@media (max-width: 1360px) { .tbl .c-pos { display: none; } }

/* ------------------------------------------------ login page */
.login-body { display: grid; place-items: center; min-height: 100%; padding: 20px; }
.login-card { width: 400px; max-width: 100%; background: var(--bg2); border: 1px solid var(--line2); border-radius: 16px; box-shadow: var(--shadow); padding: 24px 24px 20px; display: flex; flex-direction: column; gap: 16px; }
.login-brand { display: flex; align-items: center; gap: 11px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form[hidden] { display: none; }
.login-form h1 { margin: 0; font-size: 18px; }
.login-form p.help { margin: 0; color: var(--muted); font-size: 12.3px; }
.login-form .btn { align-self: stretch; padding: 10px 13px; }
.login-msg { min-height: 18px; font-size: 12.8px; }

/* ------------------------------------------------ users */
.who { color: var(--muted); font-size: 12.5px; padding: 0 4px; white-space: nowrap; }
.who b { color: var(--text); }
.users-tbl td, .users-tbl th { padding: 7px 8px; }
.users-tbl .acts { text-align: right; white-space: nowrap; }
.users-tbl .confirm-row td { background: var(--panel); }
.users-tbl .confirm-row .field { max-width: 320px; }
.add-user { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.add-user .field { flex: 1; min-width: 200px; }
.temp-pw { margin-top: 10px; padding: 10px 12px; background: var(--brand-bg); border: 1px solid rgba(139, 123, 255, 0.35); border-radius: 10px; }
.temp-pw .row2 { display: flex; gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.temp-pw input { flex: 1; min-width: 220px; background: var(--panel); border: 1px solid var(--line2); color: var(--text); padding: 7px 9px; border-radius: 8px; font-family: ui-monospace, Menlo, Consolas, monospace; }
