/* Tech design tokens (Linear) */
:root {
  --primary: #5e6ad2;
  --primary-active: #828fff;
  --on-primary: #ffffff;
  --canvas: #010102;
  --card: #0f1011;
  --elev: #18191a;
  --hairline: #23252a;
  --text: #f7f8f8;
  --text-strong: #ffffff;
  --dim: #8a8f98;
  --muted: #62666d;
  --up: #0ecb81;
  --down: #f6465d;
  --info: #4d9fff;
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;
  --r-xl: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--canvas);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}
.num { font-variant-numeric: tabular-nums; }
.dim { color: var(--dim); }
.caption { font-size: 12px; font-weight: 500; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--dim); }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
#topbar {
  height: 52px; flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: var(--canvas);
  border-bottom: 1px solid var(--hairline);
}
.tb-left { display: flex; align-items: center; gap: 10px; }
.logo { color: var(--primary); font-size: 16px; }
.wordmark { color: var(--primary); font-weight: 700; font-size: 15px; letter-spacing: 0.5px; }
.tb-sep { width: 1px; height: 20px; background: var(--hairline); }
.badge {
  font-size: 12px; font-weight: 500; color: var(--text);
  background: var(--card); border: 1px solid var(--hairline);
  border-radius: var(--r-sm); padding: 2px 8px;
}
.tb-center { font-size: 15px; font-weight: 500; display: flex; gap: 12px; align-items: baseline; }
.view-seg { display: none; }
@media (min-width: 769px) { .view-seg { display: none !important; } }
.view-seg button { font-size: 13px; }
.view-seg .cnt { margin-left: 4px; font-size: 12px; }
.tb-right { display: flex; align-items: center; gap: 14px; }
.acc-box { position: relative; display: flex; align-items: center; }
.acc-btn { display: flex; align-items: center; gap: 5px; background: var(--card); border: 1px solid var(--hairline); color: var(--text); font-size: 12px; border-radius: 16px; padding: 4px 10px; cursor: pointer; transition: border-color .15s; max-width: 110px; overflow: hidden; white-space: nowrap; }
.acc-btn:hover { border-color: var(--dim); }
.acc-btn svg { flex-shrink: 0; opacity: .6; }
.acc-menu { position: absolute; top: calc(100% + 6px); right: 0; min-width: 110px; background: var(--card); border: 1px solid var(--hairline); border-radius: var(--r-sm); box-shadow: 0 8px 24px rgba(0,0,0,.45); z-index: 200; overflow: hidden; }
.acc-menu.hidden { display: none; }
.acc-item { padding: 8px 14px; font-size: 12px; color: var(--dim); cursor: pointer; transition: background .1s; }
.acc-item:hover { background: var(--elev); color: var(--text); }
.acc-item.on { color: var(--primary-active); font-weight: 500; }
@media (max-width: 768px) { .acc-btn { font-size: 11px; padding: 3px 8px; max-width: 96px; } .acc-menu { min-width: 96px; } .acc-item { padding: 7px 10px; } }
.conn { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dim); }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.conn.ok .dot { background: var(--up); }
.conn.err .dot { background: var(--down); }

.btn-primary {
  background: var(--primary); color: var(--on-primary);
  font-family: var(--font); font-size: 14px; font-weight: 600; line-height: 1;
  border: none; border-radius: var(--r-md);
  height: 32px; padding: 0 14px; cursor: pointer;
}
.btn-primary:hover { background: var(--primary-active); box-shadow: 0 0 18px rgba(94,106,210,0.45); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

/* ---------- error screen ---------- */
#errorScreen {
  flex: 1; display: flex; align-items: center; justify-content: center;
}
.card { background: var(--card); border: 1px solid var(--hairline); border-radius: var(--r-xl); }
.error-card {
  width: 560px; max-width: 90vw; padding: 32px;
  display: flex; flex-direction: column; gap: 12px; align-items: flex-start;
}
.error-card h2 { font-size: 20px; font-weight: 600; color: var(--text-strong); }
.err-msg { font-size: 14px; color: var(--text); word-break: break-all; }
.hint { font-size: 13px; color: var(--dim); line-height: 1.6; }

/* ---------- app layout ---------- */
#app { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#main {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr) 304px;
}
.pane { min-height: 0; background: var(--canvas); }
.pane-left { border-right: 1px solid var(--hairline); display: flex; flex-direction: column; }
.pane-right { border-left: 1px solid var(--hairline); display: flex; flex-direction: column; }
.scroll { overflow-y: auto; }
.scroll::-webkit-scrollbar { width: 8px; }
.scroll::-webkit-scrollbar-thumb { background: var(--elev); border-radius: 4px; }

.pane-head {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px 8px;
}
.pane-head-stick { border-top: 1px solid var(--hairline); margin-top: 4px; }
.pane-title { font-size: 12px; font-weight: 500; color: var(--dim); letter-spacing: 0.3px; }

/* positions */
.pos-list { flex: 1; min-height: 0; }
.pos-row {
  padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--hairline);
}
.pos-row:hover { background: var(--elev); }
.pos-row.active { background: var(--elev); box-shadow: inset 2px 0 0 var(--primary), 0 0 14px rgba(94,106,210,0.18); }
.pos-row .r1 { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; color: var(--text-strong); }
.pos-row .r2 { display: flex; justify-content: space-between; font-size: 12px; color: var(--dim); margin-top: 2px; }
.pos-row .r3, .pos-row .r4 { display: flex; justify-content: space-between; font-size: 12px; margin-top: 2px; }
.side-badge { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: var(--r-sm); margin-left: 6px; }
.side-badge.long { color: var(--up); background: rgba(14, 203, 129, 0.12); }
.side-badge.short { color: var(--down); background: rgba(246, 70, 93, 0.12); }
.empty-note { padding: 14px 12px; font-size: 12px; color: var(--muted); }

.fund-box { padding: 4px 12px 10px; display: flex; flex-direction: column; gap: 6px; }
.fund-line { display: flex; justify-content: space-between; font-size: 13px; }
.fund-line .k { color: var(--dim); }

/* ---------- center chart ---------- */
.pane-center { display: flex; flex-direction: column; min-width: 0; }
.chart-toolbar {
  flex: none; display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border-bottom: 1px solid var(--hairline);
}
.symbol-input {
  width: 130px; height: 32px;
  background: var(--card); color: var(--text-strong);
  border: 1px solid var(--hairline); border-radius: var(--r-lg);
  padding: 0 10px; font-size: 14px; font-weight: 600;
  font-variant-numeric: tabular-nums; letter-spacing: 0.5px;
  outline: none; text-transform: uppercase;
}
.symbol-input:focus { box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5); }
.seg { display: flex; background: var(--card); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: 2px; }
.seg button {
  height: 26px; padding: 0 12px; border: none; background: transparent;
  color: var(--dim); font-size: 12px; font-weight: 500; border-radius: 6px; cursor: pointer;
}
.seg button.on { background: var(--elev); color: var(--primary-active); font-weight: 600; box-shadow: inset 0 0 0 1px rgba(94,106,210,0.55), 0 0 14px rgba(94,106,210,0.28); }
.legend { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--dim); margin-left: auto; }
.legend .lg { display: inline-block; width: 8px; height: 8px; margin: 0 2px 0 8px; border-radius: 2px; }
.legend .lg-b { background: var(--up); }
.legend .lg-s { background: var(--down); }
.kline-wrap { flex: 1; min-height: 0; position: relative; }
.chart-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13px; pointer-events: none;
}

/* ---------- right panel ---------- */
.acct-box {
  flex: none; padding: 12px 14px; border-bottom: 1px solid var(--hairline);
  display: flex; flex-direction: column; gap: 8px;
}
.acct-main .k { font-size: 12px; color: var(--dim); margin-bottom: 2px; }
.acct-main .v { font-size: 24px; font-weight: 700; color: var(--text-strong); letter-spacing: -0.3px; line-height: 1.2; }
.hero-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hero-chip {
  font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: var(--r-sm);
  font-variant-numeric: tabular-nums;
}
.hero-chip.up { color: var(--up); background: rgba(14, 203, 129, 0.12); }
.hero-chip.down { color: var(--down); background: rgba(246, 70, 93, 0.12); }
.hero-chip.flat { color: var(--dim); background: var(--elev); }
.acct-main .v small { font-size: 13px; font-weight: 500; color: var(--dim); margin-left: 4px; }
.acct-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.acct-cell.wide { grid-column: 1 / -1; }
.acct-cell .k { font-size: 11px; color: var(--muted); }
.acct-cell .v { font-size: 14px; font-weight: 500; line-height: 1.3; font-variant-numeric: tabular-nums; }
.acct-chips { display: flex; gap: 8px; }
.chip {
  font-size: 11px; font-weight: 500; color: var(--dim);
  background: var(--elev); border-radius: var(--r-sm); padding: 2px 8px;
}
.chip b { color: var(--text); font-weight: 600; }
.equity-wrap { flex: 1; min-height: 120px; }

/* ---------- bottom tabs ---------- */
#bottom { flex: none; height: 250px; display: flex; flex-direction: column; border-top: 1px solid var(--hairline); }
.tabs { flex: none; display: flex; gap: 4px; padding: 6px 12px 0; background: var(--canvas); }
.tab {
  background: transparent; border: none; color: var(--dim);
  font-size: 13px; font-weight: 500; padding: 6px 12px; cursor: pointer;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--primary-active); border-bottom-color: var(--primary); text-shadow: 0 0 12px rgba(130,143,255,0.45); }
.tab .cnt { color: var(--muted); font-size: 12px; margin-left: 4px; }
.tab-body { flex: 1; min-height: 0; padding: 8px 12px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; background: var(--canvas);
  color: var(--muted); font-size: 12px; font-weight: 500; text-align: right;
  padding: 6px 8px; border-bottom: 1px solid var(--hairline); white-space: nowrap;
}
thead th:first-child, tbody td:first-child { text-align: left; }
tbody td {
  text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--hairline);
  font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text);
}
tbody tr:hover td { background: rgba(43, 49, 57, 0.5); }

/* analysis tab */
.analysis-v2 { display: flex; flex-direction: column; gap: 10px; }
.stat-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--card); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: 8px 10px; }
.stat .k { font-size: 11px; color: var(--muted); }
.stat .v { font-size: 16px; font-weight: 600; margin-top: 2px; white-space: nowrap; }
.stat .sub { font-size: 10px; color: var(--muted); margin-top: 1px; white-space: nowrap; }
.ana-card { padding: 10px 12px; }
.ana-card h4 { font-size: 12px; color: var(--dim); font-weight: 500; margin-bottom: 8px; }
.daily-chart { height: 150px; }
.ana-cells { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; }
.ana-cells .cell .k { font-size: 11px; color: var(--muted); }
.ana-cells .cell .v { font-size: 15px; font-weight: 600; margin-top: 2px; white-space: nowrap; }
.ana-cells .cell .sub { font-size: 10px; color: var(--muted); white-space: nowrap; }
.top5-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.top5-h { font-size: 11px; font-weight: 600; margin-bottom: 6px; }
@media (max-width: 768px) {
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .ana-cells { grid-template-columns: 1fr 1fr; }
  .top5-cols { grid-template-columns: 1fr; gap: 10px; }
  .daily-chart { height: 130px; }
}

.analysis { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 16px; height: 100%; min-height: 0; }
.tile-grid { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 1fr; gap: 8px; }
.tile {
  background: var(--card); border: 1px solid var(--hairline); border-radius: var(--r-lg);
  padding: 8px 12px; display: flex; flex-direction: column; justify-content: center; gap: 2px;
}
.tile .k { font-size: 11px; color: var(--muted); }
.tile .v { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile .sub { white-space: nowrap; }
.tile .sub { font-size: 11px; color: var(--dim); }
.analysis-right { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.analysis-right .card { flex: 1; min-height: 0; padding: 8px 10px; }
.analysis-right .card h4 { font-size: 12px; color: var(--dim); font-weight: 500; margin-bottom: 4px; }
.daily-chart { height: calc(100% - 22px); min-height: 90px; }
.mini-list { display: flex; flex-direction: column; gap: 4px; overflow: hidden; font-size: 12px; }
.mini-list .row { display: flex; justify-content: space-between; gap: 8px; }
.mini-list .row .sym { color: var(--text); font-weight: 600; }
.mini-list .row .t { color: var(--muted); }

/* footer */
.footer-strip {
  flex: none; height: 28px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; font-size: 11px; color: var(--muted);
  background: var(--surface-soft, #14171c); background: var(--card);
  border-top: 1px solid var(--hairline);
}

/* responsive: mobile single-column layout */
@media (max-width: 768px) {
  #topbar { height: 48px; padding: 0 10px; }
  #tbAssets { display: none; }
  .view-seg { display: flex; }
  body.view-pos .pane-center { display: none; }
  .pane-left { display: none; }
  body.view-pos .pane-left { display: flex; order: 0; }
  body.view-ana .pane-center { display: none; }
  .tab[data-tab="analysis"] { display: none; }
  #main > #tab-analysis { flex: 1 1 auto; min-height: 260px; overflow: auto; display: block; }
  .wordmark, .tb-sep, #lastUpdate { display: none; }
  .btn-primary { height: 28px; padding: 0 10px; font-size: 13px; }
  #main { display: flex; flex-direction: column; overflow-y: hidden; }
  body.view-pos #main { overflow-y: auto; }
  #main > .pane { flex: none; }
  #main > .pane-center { flex: 1 1 auto; min-height: 0; }
  .pane { border-right: none !important; border-left: none !important; }
  .pane-right { border-bottom: 1px solid var(--hairline); }
  .pane-right .pane-head, .equity-wrap { display: none; }
  .acct-box { padding: 8px 10px; gap: 4px; position: sticky; top: 0; z-index: 20; background: var(--canvas); flex: none; }
  .pane-right { order: -1; }
  #acctBox { order: -2; }
  .acct-main .k { font-size: 10px; margin-bottom: 1px; }
  .acct-main .v { font-size: 20px; }
  .hero-row { gap: 6px; }
  .hero-chip { font-size: 10px; padding: 2px 6px; }
  .acct-grid { gap: 4px 8px; grid-template-columns: 1fr 1fr 1fr; }
  .acct-cell .k { font-size: 10px; }
  .acct-cell .v { font-size: 12px; }
  .acct-cell.span2 { grid-column: span 2; }
  .acct-cell.wide { grid-column: 1 / -1; }
  .acct-chips { display: none; }
  .pane-center { order: 0; border-bottom: 1px solid var(--hairline); }
  .chart-toolbar { flex-wrap: wrap; gap: 8px; }
  .legend { display: none; }
  .kline-wrap { flex: 1 1 auto; min-height: 0; }
  #chartMeta { display: none; }
  .pane-left { order: 1; border-top: 1px solid var(--hairline); }
  .pos-list { flex: none; max-height: none; overflow: visible; }
  #bottom { height: 240px; }
  .tabs { overflow-x: auto; }
  .tab-body { overflow: auto; }
  .analysis { grid-template-columns: 1fr; height: auto; }
  .analysis-right .card { min-height: 140px; flex: none; }
  .tile-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-strip { display: none; }
}

/* responsive: shrink side rails on narrow screens */
@media (max-width: 1200px) {
  #main { grid-template-columns: 220px minmax(0, 1fr) 260px; }
  .analysis { grid-template-columns: 1fr 320px; }
}

/* ---------- trades: mobile cards + full-screen tab ---------- */
.trades-cards { display: none; }
.tab-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 768px) {
  #modeBadge, #refreshBtn { display: none; }
  .trades-table { display: none; }
  .trades-cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .tc { background: var(--card); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: 7px 10px; }
  .tc-top { display: flex; align-items: center; gap: 6px; font-size: 13px; }
  .tc-top b { color: var(--text-strong); font-weight: 600; flex: none; }
  .tc-time { margin-left: auto; font-size: 11px; flex: none; }
  .tc-dir { font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: var(--r-sm); flex: none; }
  .tc-dir.buy { color: var(--up); background: rgba(14, 203, 129, 0.12); }
  .tc-dir.sell { color: var(--down); background: rgba(246, 70, 93, 0.12); }
  .tc-src { font-style: normal; font-size: 10px; color: var(--muted); border: 1px solid var(--hairline); padding: 0 4px; border-radius: var(--r-sm); }
  .tc-bot { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 3px; font-size: 12px; }
  body.tab-full #main { display: none; }
  body.tab-full #bottom { flex: 1 1 auto; height: auto; }
}

/* ---------- top bar mobile nav redesign ---------- */
body { touch-action: manipulation; }
@media (max-width: 768px) {
  #topbar { height: auto; flex-wrap: wrap; row-gap: 8px; padding: 8px 10px; }
  .tb-left { order: 1; }
  .tb-right { order: 2; margin-left: auto; }
  .tb-center { order: 3; width: 100%; }
  .view-seg { width: 100%; }
  .view-seg button { flex: 1; padding: 8px 0; font-size: 13px; }
}

/* ---------- compare view ---------- */
.cmp-view { padding: 12px; }
.cmp-view.hidden { display: none; }
.cmp-chart-box { margin-bottom: 14px; position: relative; overflow: hidden; }
.cmp-chart-box::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(14,203,129,0.04) 0%, transparent 70%),
             radial-gradient(ellipse 80% 60% at 50% 100%, rgba(77,159,255,0.03) 0%, transparent 70%);
}
.cmp-chart { width: 100%; height: 240px; background: var(--card); border-radius: var(--r-sm); border: 1px solid var(--hairline); box-shadow: 0 0 20px rgba(0,0,0,0.2) inset; }
.cmp-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 10px; }
.cmp-rank table { width: 100%; font-size: 12px; }
.cmp-rank thead th { font-size: 11px; color: var(--dim); text-align: right; padding: 5px 6px; border-bottom: 1px solid var(--hairline); }
.cmp-rank thead th:first-child { text-align: left; }
.cmp-rank tbody td { text-align: right; padding: 8px 6px; border-bottom: 1px solid var(--hairline); color: var(--text); font-variant-numeric: tabular-nums; }
.cmp-rank tbody td.nm { text-align: left; font-weight: 500; }
.cmp-rank .up { color: var(--up); }
.cmp-rank .dn { color: var(--down); }
.rank-medal { font-size: 14px; }

/* ---------- admin panel ---------- */
.admin-btn { background: transparent; border: 1px solid var(--hairline); color: var(--dim); width: 28px; height: 28px; border-radius: 50%; font-size: 14px; display: flex; align-items: center; justify-content: center; cursor: pointer; line-height: 1; }
.admin-btn:hover { border-color: var(--dim); color: var(--text); }
.admin-panel { position: fixed; top: 0; right: 0; bottom: 0; width: 300px; max-width: 100vw; background: var(--canvas); border-left: 1px solid var(--hairline); z-index: 999; display: flex; flex-direction: column; box-shadow: -4px 0 20px rgba(0,0,0,.4); }
.admin-panel.hidden { display: none; }
.admin-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--hairline); }
.admin-head h3 { font-size: 14px; font-weight: 600; color: var(--text); margin: 0; }
.admin-close { background: none; border: none; color: var(--dim); font-size: 22px; cursor: pointer; padding: 4px; line-height: 1; }
.admin-close:hover { color: var(--text); }
.admin-body { flex: 1; overflow-y: auto; padding: 14px 16px; }
.adm-auth { margin-bottom: 16px; }
.adm-auth.hidden { display: none; }
.admin-list.hidden { display: none; }
.admin-list { margin-bottom: 18px; }
.adm-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--hairline); }
.adm-nm { flex: 1; font-size: 13px; color: var(--text); }
.adm-del, .adm-ren { background: none; border: 1px solid var(--hairline); color: var(--dim); font-size: 11px; padding: 3px 8px; border-radius: 4px; cursor: pointer; }
.adm-init { width: 80px; background: var(--card); border: 1px solid var(--hairline); color: var(--text); font-size: 11px; padding: 3px 6px; border-radius: 4px; text-align: right; }
.adm-init:focus { outline: none; border-color: var(--primary); }
.adm-del:hover { color: var(--down); border-color: var(--down); }
.adm-ren:hover { color: var(--primary); border-color: var(--primary); }
.admin-form h4 { font-size: 12px; color: var(--dim); margin: 0 0 8px; font-weight: 500; }
.adm-input { display: block; width: 100%; background: var(--card); border: 1px solid var(--hairline); color: var(--text); font-size: 12px; padding: 7px 10px; border-radius: var(--r-sm); margin-bottom: 8px; box-sizing: border-box; }
.adm-input:focus { outline: none; border-color: var(--primary); }
.adm-btn { display: block; width: 100%; background: var(--primary); color: #16191e; font-size: 12px; font-weight: 600; border: none; padding: 8px; border-radius: var(--r-sm); cursor: pointer; }
.adm-btn:hover { opacity: .9; }

/* view-cmp: hide main + bottom */
body.view-cmp #main, body.view-cmp #bottom { display: none; }
@media (max-width: 768px) {
  .admin-panel { width: 100%; }
  .cmp-chart { height: 200px; }
}


/* ===== Welcome Screen ===== */
.welcome-screen {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: #010102;
  animation: fadeIn 0.4s ease;
  background-image:
    radial-gradient(ellipse 90% 50% at 50% -10%, rgba(94,106,210,0.28), transparent 70%),
    linear-gradient(rgba(35,37,42,0.3) 1px, transparent 1px),
    linear-gradient(90deg, rgba(35,37,42,0.3) 1px, transparent 1px);
  background-size: 100% 100%, 44px 44px, 44px 44px;
}
.welcome-screen.hidden { display: none; }
.welcome-bg {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 90% 50% at 50% -10%, rgba(94,106,210,0.28), transparent 70%);
}
.welcome-content {
  position: relative; width: 100%; max-width: 400px; padding: 40px 24px;
  text-align: center;
}
.welcome-logo {
  display: inline-block; margin-bottom: 16px;
  animation: slideDown 0.5s ease 0.1s both;
}
.welcome-title {
  font-size: 26px; font-weight: 800; color: #eaecef; letter-spacing: -0.5px;
  margin: 0 0 6px; animation: slideDown 0.5s ease 0.2s both;
}
.welcome-sub {
  font-size: 14px; color: #707a8a; margin: 0 0 32px;
  animation: slideDown 0.5s ease 0.3s both;
}
.welcome-cards {
  display: flex; flex-direction: column; gap: 12px;
}
.wcard {
  position: relative; display: flex; align-items: center; gap: 14px;
  padding: 18px 20px; border-radius: 16px;
  background: rgba(15, 16, 17, 0.85);
  border: 1px solid #23252a;
  backdrop-filter: blur(10px);
  cursor: pointer; transition: all 0.25s ease;
  animation: slideUp 0.5s ease both;
  overflow: hidden;
}
.wcard:nth-child(1) { animation-delay: 0.4s; }
.wcard:nth-child(2) { animation-delay: 0.55s; }
.wcard:nth-child(3) { animation-delay: 0.7s; }
.wcard::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(94,106,210,0.12) 0%, transparent 55%);
  opacity: 0; transition: opacity 0.3s;
}
.wcard:active, .wcard:hover {
  transform: scale(0.97);
  border-color: rgba(94,106,210,0.55);
  box-shadow: 0 0 28px rgba(94,106,210,0.22), 0 8px 32px rgba(0,0,0,0.35);
}
.wcard:active::before, .wcard:hover::before { opacity: 1; }
.wcard-avatar {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; flex-shrink: 0;
}
.wcard-info { flex: 1; text-align: left; min-width: 0; }
.wcard-name { font-size: 15px; font-weight: 700; color: #eaecef; margin-bottom: 3px; }
.wcard-meta { font-size: 12px; color: #707a8a; display: flex; gap: 12px; }
.wcard-eq { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.wcard-eq.up { color: #0ecb81; }
.wcard-eq.dn { color: #f6465d; }
.wcard-arrow { font-size: 18px; color: #3e4550; transition: transform 0.2s; }
.wcard:active .wcard-arrow { transform: translateX(3px); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* Compare period toggle */
.cmp-periods { display: flex; gap: 6px; margin-bottom: 10px; }
.cmp-period { padding: 4px 12px; border-radius: 4px; font-size: 12px; color: var(--dim); cursor: pointer; border: 1px solid var(--hairline); background: transparent; }
.cmp-period.on { color: var(--up); border-color: var(--up); background: rgba(14,203,129,0.08); font-weight: 600; }

/* ===== Tech FX ===== */
#topbar { position: relative; z-index: 60; background: rgba(1,1,2,0.85); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
#topbar::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(130,143,255,0.55), rgba(77,159,255,0.35), transparent);
  background-size: 220% 100%; animation: fx-beam 7s linear infinite;
}
@keyframes fx-beam { to { background-position: -220% 0; } }
.wordmark { text-shadow: 0 0 12px rgba(130,143,255,0.5); }
.conn .dot { box-shadow: 0 0 6px rgba(138,143,152,0.7); }
.conn.ok .dot { background: var(--up); box-shadow: 0 0 8px rgba(14,203,129,0.9); animation: fx-pulse 2.4s ease-in-out infinite; }
.conn.err .dot { background: var(--down); box-shadow: 0 0 8px rgba(246,70,93,0.9); animation: fx-pulse 0.9s ease-in-out infinite; }
@keyframes fx-pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(0.72); opacity: 0.65; } }
.tabs { background: rgba(1,1,2,0.88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.tab { position: relative; }
.tab.on::after {
  content: ''; position: absolute; left: 18%; right: 18%; bottom: -1px; height: 2px; border-radius: 2px;
  background: var(--primary-active); box-shadow: 0 0 10px 1px rgba(130,143,255,0.65);
}
.kline-wrap::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 5;
  border: 1px solid rgba(94,106,210,0.14); border-radius: 6px;
  box-shadow: inset 0 0 24px rgba(94,106,210,0.05);
}
.acct-main .v.tick { animation: fx-tick 0.7s ease; }
@keyframes fx-tick { 0% { text-shadow: 0 0 16px rgba(130,143,255,0.9); } 100% { text-shadow: 0 0 0 rgba(130,143,255,0); } }
.view-anim { animation: fx-view 0.28s ease; }
@keyframes fx-view { from { opacity: 0; transform: translateY(8px); } }
.tc.st-in { animation: fx-view 0.3s ease backwards; }
.cmp-chart { animation: fx-view 0.35s ease; }

/* ---------- Market (Polymarket finance) ---------- */
#mktList { display: flex; flex-direction: column; gap: 10px; max-width: 760px; margin: 0 auto; }
.mkt-load, .mkt-empty { text-align: center; color: var(--dim); padding: 44px 0; font-size: 13px; }
.mkt-card {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: 12px;
}
.mkt-card.st-in { animation: fx-view 0.32s ease backwards; }
.mkt-head { margin-bottom: 4px; }
.mkt-title { font-size: 16.5px; font-weight: 700; line-height: 1.4; color: var(--text-strong); letter-spacing: 0; }
.mkt-meta { display: flex; gap: 10px; margin-top: 6px; font-size: 11px; color: var(--dim); }
.mkt-meta .vol { color: var(--primary-active); font-weight: 600; font-variant-numeric: tabular-nums; }
.mkt-m { padding: 9px 0 2px; border-top: 1px solid var(--hairline); margin-top: 9px; }
.mkt-q { font-size: 12.5px; color: #b6bcc4; margin-bottom: 7px; line-height: 1.4; }
.vs-bar { position: relative; display: flex; height: 22px; border-radius: 5px; overflow: hidden; background: var(--hairline); box-shadow: 0 0 0 1px rgba(255,255,255,0.04) inset; }
.vs-yes { height: 100%; background: linear-gradient(90deg, rgba(14,203,129,.28), rgba(14,203,129,.78)); box-shadow: 0 0 12px rgba(14,203,129,.25); transition: width .6s ease; }
.vs-no { height: 100%; background: linear-gradient(270deg, rgba(246,70,93,.28), rgba(246,70,93,.78)); box-shadow: 0 0 12px rgba(246,70,93,.2); transition: width .6s ease; }
.vs-logo {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); transition: left .6s ease;
  z-index: 2; font-size: 9px; font-weight: 800; letter-spacing: 0.04em; color: #fff;
  background: #0f1011; border: 1px solid #3a3d45; border-radius: 999px;
  padding: 2.5px 7px; line-height: 1.2;
  box-shadow: 0 0 8px rgba(0,0,0,.65), 0 0 10px rgba(130,143,255,.22);
}
.mkt-p { display: flex; justify-content: space-between; font-size: 11px; margin-top: 5px; color: var(--dim); font-variant-numeric: tabular-nums; }
.mkt-p .yes { color: var(--up); font-weight: 600; }
.mkt-p .no { color: var(--down); font-weight: 600; }

/* Market view (top nav) */
.mkt-view { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 12px 24px; }
.mkt-view.hidden { display: none; }
body.view-mkt #main, body.view-mkt #bottom { display: none; }

/* ---------- welcome: champion & loser fx ---------- */
.fw-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.wbadge { position: absolute; top: -10px; right: 14px; z-index: 6; font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; line-height: 1.4; }
.wbadge-champ { background: linear-gradient(135deg, #33290e, #191507); color: #ffd54a; border: 1px solid rgba(255, 213, 74, 0.6); box-shadow: 0 0 14px rgba(255, 213, 74, 0.35); animation: badge-float 2.2s ease-in-out infinite; }
.wbadge-loser { background: linear-gradient(135deg, #11301c, #0a180f); color: #7ee787; border: 1px solid rgba(126, 231, 135, 0.55); box-shadow: 0 0 14px rgba(126, 231, 135, 0.25); }
@keyframes badge-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.wcard-champ { overflow: visible; z-index: 0; border-color: transparent; animation: slideUp 0.5s ease both, champ-glow 2.6s ease-in-out infinite; }
.wcard-champ::before {
  content: ''; position: absolute; z-index: -1; left: 50%; top: 50%;
  width: 320%; aspect-ratio: 1 / 1;
  background: conic-gradient(from 0deg, transparent 0deg, rgba(255, 213, 74, 0.85) 26deg, rgba(130, 143, 255, 0.6) 48deg, transparent 80deg, transparent 170deg, rgba(126, 231, 135, 0.4) 200deg, transparent 245deg);
  animation: champ-rot 3.4s linear infinite;
  filter: blur(0.6px);
}
@keyframes champ-rot { from { transform: translate(-50%, -50%) rotate(0deg); } to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes champ-glow { 0%, 100% { box-shadow: 0 0 16px rgba(255, 213, 74, 0.16), 0 8px 30px rgba(0, 0, 0, 0.3); } 50% { box-shadow: 0 0 30px rgba(255, 213, 74, 0.34), 0 0 54px rgba(130, 143, 255, 0.2), 0 8px 30px rgba(0, 0, 0, 0.3); } }
.wcard-champ > .wcard-avatar, .wcard-champ > .wcard-info, .wcard-champ > .wcard-arrow { position: relative; z-index: 1; }
.wcard-champ:active, .wcard-champ:hover { border-color: transparent; box-shadow: 0 0 30px rgba(255, 213, 74, 0.4), 0 8px 32px rgba(0, 0, 0, 0.35); }
.wcard-loser { overflow: visible; border-color: rgba(126, 231, 135, 0.3); animation: slideUp 0.5s ease both, loser-sag 3.8s ease-in-out infinite; box-shadow: 0 0 18px rgba(126, 231, 135, 0.12); }
.wcard-loser:active, .wcard-loser:hover { border-color: rgba(126, 231, 135, 0.5); box-shadow: 0 0 22px rgba(126, 231, 135, 0.2); }
@keyframes loser-sag { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(-0.7deg) translateY(1.5px); } }
.poop-scene { position: absolute; top: -30px; right: 18px; width: 52px; height: 60px; z-index: 5; pointer-events: none; }
.poop-main { position: absolute; bottom: 2px; left: 50%; margin-left: -15px; font-size: 30px; line-height: 1; animation: poop-drop 2.4s ease-in-out infinite; filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.55)); }
@keyframes poop-drop {
  0% { transform: translateY(-16px) rotate(-10deg) scale(1.02, 0.98); }
  38% { transform: translateY(0) rotate(0deg) scale(0.96, 1.04); }
  52% { transform: translateY(2px) rotate(4deg) scale(1.14, 0.78); }
  66% { transform: translateY(0) rotate(0deg) scale(0.98, 1.02); }
  100% { transform: translateY(-16px) rotate(-10deg) scale(1.02, 0.98); }
}
.poop-ring { position: absolute; bottom: -3px; left: 50%; width: 36px; height: 11px; margin-left: -18px; border-radius: 50%; background: radial-gradient(ellipse, rgba(126, 231, 135, 0.45), rgba(126, 231, 135, 0) 70%); opacity: 0; animation: ring-squash 2.4s ease-in-out infinite; }
@keyframes ring-squash { 0%, 40% { transform: scale(0.4); opacity: 0; } 55% { transform: scale(1.25); opacity: 0.9; } 80%, 100% { transform: scale(1.6); opacity: 0; } }
.poop-stink { position: absolute; bottom: 26px; width: 3px; height: 15px; border-radius: 2px; background: linear-gradient(to top, rgba(126, 231, 135, 0), rgba(126, 231, 135, 0.6)); filter: blur(0.5px); opacity: 0; animation: stink-rise 1.9s ease-in infinite; }
.poop-stink.s1 { left: 8px; }
.poop-stink.s2 { left: 20px; height: 20px; animation-delay: 0.55s; }
.poop-stink.s3 { left: 33px; animation-delay: 1.1s; }
@keyframes stink-rise { 0% { transform: translateY(8px) scaleY(0.35); opacity: 0; } 30% { opacity: 0.9; } 100% { transform: translateY(-20px) scaleY(1.2) translateX(3px); opacity: 0; } }
.poop-puff { position: absolute; bottom: 20px; width: 12px; height: 12px; border-radius: 50%; background: radial-gradient(circle, rgba(126, 231, 135, 0.4), rgba(126, 231, 135, 0) 70%); filter: blur(2px); opacity: 0; animation: puff-float 3.2s ease-out infinite; }
.poop-puff.p1 { left: -4px; animation-delay: 0.4s; }
.poop-puff.p2 { left: 34px; animation-delay: 2s; }
@keyframes puff-float { 0% { transform: translate(0, 0) scale(0.4); opacity: 0; } 25% { opacity: 0.8; } 100% { transform: translate(-16px, -38px) scale(1.6); opacity: 0; } }

/* welcome: live odometer clock */
.welcome-clock { display:flex; align-items:center; justify-content:center; gap:5px; margin:14px 0 16px; }
.wcl-digit { position:relative; width:24px; height:38px; overflow:hidden; border-radius:8px; background:rgba(15,16,17,.92); border:1px solid #23252a; box-shadow: 0 0 14px rgba(130,143,255,.14), inset 0 0 10px rgba(130,143,255,.05); }
.wcl-strip { display:flex; flex-direction:column; transition: transform .5s cubic-bezier(.22,1,.36,1); will-change: transform; }
.wcl-strip i { height:38px; line-height:38px; font-style:normal; text-align:center; font-size:20px; font-weight:800; font-variant-numeric:tabular-nums; background:linear-gradient(180deg,#fff 30%,#828fff 90%); -webkit-background-clip:text; background-clip:text; color:transparent; filter:drop-shadow(0 0 6px rgba(130,143,255,.35)); }
.wcl-colon { font-size:20px; font-weight:800; color:#828fff; animation: wcl-blink 1s steps(1) infinite; }
@keyframes wcl-blink { 0%,49% { opacity:1 } 50%,100% { opacity:.25 } }
@media (min-width: 700px) {
  .wcl-digit { width:34px; height:52px; }
  .wcl-strip i { height:52px; line-height:52px; font-size:28px; }
  .wcl-colon { font-size:28px; }
}
