:root {
  color-scheme: dark;
  --bg: #09090b;
  --bg-elevated: #101014;
  --surface: #141418;
  --surface-2: #19191f;
  --surface-3: #202027;
  --line: #2a2a32;
  --line-strong: #3a3945;
  --ink: #f4f2f8;
  --muted: #91909c;
  --quiet: #62616c;
  --purple: #8b5cf6;
  --purple-dark: #6d3fe6;
  --purple-soft: rgba(139, 92, 246, .14);
  --green: #39d98a;
  --green-soft: rgba(57, 217, 138, .13);
  --red: #ff6b7a;
  --red-soft: rgba(255, 107, 122, .12);
  --amber: #e8b45a;
  --radius: 12px;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --ui: Aptos, "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg); overflow-x: hidden; }
body { margin: 0; min-width: 320px; min-height: 100vh; overflow-x: hidden; background: var(--bg); color: var(--ink); font-family: var(--ui); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
[hidden] { display: none !important; }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, #000 0, transparent 65%);
  opacity: .35;
}

.eyebrow { margin: 0 0 8px; color: var(--purple); font: 700 10px/1.2 var(--mono); letter-spacing: .15em; text-transform: uppercase; }
.brand-mark { display: flex; align-items: flex-end; gap: 4px; width: 40px; height: 30px; }
.brand-mark span { display: block; width: 8px; border: 1px solid var(--purple); background: var(--purple-soft); transform: skew(-10deg); }
.brand-mark span:nth-child(1) { height: 16px; }
.brand-mark span:nth-child(2) { height: 25px; }
.brand-mark span:nth-child(3) { height: 11px; }
.brand-mark.small { width: 29px; height: 24px; gap: 3px; }
.brand-mark.small span { width: 6px; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; }
.login-shell::after { content: ""; position: absolute; width: 340px; height: 340px; border: 1px solid rgba(139,92,246,.2); border-radius: 50%; top: 50%; left: 50%; transform: translate(-50%,-50%); box-shadow: 0 0 0 70px rgba(139,92,246,.025), 0 0 0 140px rgba(139,92,246,.015); }
.login-noise { position: absolute; inset: 0; background: radial-gradient(circle at 50% 45%, rgba(139,92,246,.12), transparent 32%); }
.login-card { position: relative; z-index: 2; width: min(100%, 430px); padding: 36px; border: 1px solid var(--line); background: rgba(16,16,20,.92); box-shadow: 0 28px 90px rgba(0,0,0,.48); border-radius: 16px; }
.login-card .brand-mark { margin-bottom: 32px; }
.login-card h1 { margin: 0; font: 650 clamp(38px, 8vw, 54px)/.95 var(--ui); letter-spacing: -.055em; }
.login-copy { color: var(--muted); margin: 14px 0 34px; }
.login-form label, .field > span { display: block; color: var(--muted); font: 600 11px/1.2 var(--mono); letter-spacing: .05em; text-transform: uppercase; margin-bottom: 8px; }
.password-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
input, select { width: 100%; min-height: 46px; border: 1px solid var(--line-strong); border-radius: 10px; background: #0d0d10; color: var(--ink); padding: 0 13px; outline: none; }
input:focus, select:focus { border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-soft); }
.form-error { min-height: 18px; color: var(--red); font-size: 12px; margin: 10px 0 0; }
.login-foot { display: flex; align-items: center; gap: 8px; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--quiet); font: 600 10px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(57,217,138,.1); }

.button { min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; font-weight: 650; transition: transform .16s ease, background .16s ease, border-color .16s ease; }
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button-primary { background: var(--purple); color: white; }
.button-primary:hover { background: #9a71f8; }
.button-ghost { background: var(--surface); border-color: var(--line); }
.button-ghost:hover { border-color: var(--line-strong); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button.full { width: 100%; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: 232px; padding: 24px 18px; background: #0c0c0f; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.brand { color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 12px; padding: 4px 8px 30px; }
.brand strong, .brand em { display: block; font: 800 16px/.82 var(--ui); letter-spacing: .08em; font-style: normal; }
.brand em { color: var(--purple); }
.nav-stack { display: grid; gap: 5px; }
.nav-item, .nav-action { min-height: 45px; display: flex; align-items: center; gap: 12px; padding: 0 11px; border: 1px solid transparent; border-radius: 8px; color: var(--muted); background: transparent; text-decoration: none; font-weight: 600; font-size: 13px; cursor: pointer; }
.nav-item span { color: var(--quiet); font: 600 9px var(--mono); }
.nav-item:hover, .nav-item.active { color: var(--ink); background: var(--surface); border-color: var(--line); }
.nav-item.active span { color: var(--purple); }
.sidebar-bottom { margin-top: auto; display: grid; gap: 14px; }
.nav-action { justify-content: space-between; width: 100%; border-color: var(--line); color: var(--ink); }
.nav-action:hover { background: var(--surface); }
.network-state { display: flex; align-items: center; gap: 12px; padding: 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.network-state b, .network-state small { display: block; }
.network-state b { font: 700 10px var(--mono); letter-spacing: .1em; }
.network-state small { color: var(--quiet); font: 10px var(--mono); margin-top: 3px; }
.logout { border: 0; background: transparent; color: var(--quiet); text-align: left; padding: 6px 12px; cursor: pointer; font-size: 12px; }
.logout:hover { color: var(--red); }

.main-content { margin-left: 232px; padding: 30px clamp(20px, 3vw, 44px) 26px; max-width: 1720px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.topbar h1 { margin: 0; font-size: clamp(31px, 4vw, 48px); letter-spacing: -.05em; line-height: .95; }
.top-actions { display: flex; gap: 8px; }
.refresh-button span { font-size: 18px; margin-right: 6px; }

.command-bar { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; }
.preset-group { display: flex; gap: 3px; background: #0c0c0f; padding: 3px; border-radius: 8px; }
.preset-group button { min-width: 45px; height: 36px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; cursor: pointer; font: 700 11px var(--mono); }
.preset-group button.active { background: var(--purple); color: white; }
.field.compact { display: grid; grid-template-columns: auto minmax(76px,100px); align-items: center; gap: 8px; }
.field.compact > span { margin: 0; white-space: nowrap; }
.field.compact input, .field.compact select { min-height: 36px; height: 36px; padding: 0 9px; font: 600 11px var(--mono); }
.toggle { display: flex; align-items: center; gap: 8px; color: var(--muted); font: 600 11px var(--mono); cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle span { position: relative; width: 34px; height: 19px; border-radius: 20px; background: #08080a; border: 1px solid var(--line-strong); }
.toggle span::after { content: ""; position: absolute; width: 13px; height: 13px; top: 2px; left: 2px; border-radius: 50%; background: var(--muted); transition: .18s ease; }
.toggle input:checked + span { border-color: var(--purple); background: var(--purple-soft); }
.toggle input:checked + span::after { left: 17px; background: var(--purple); }
.window-copy { margin-left: auto; text-align: right; }
.window-copy small, .window-copy b { display: block; }
.window-copy small { color: var(--quiet); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.window-copy b { margin-top: 3px; font: 600 11px var(--mono); }

.metric-strip { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); margin-bottom: 12px; }
.metric-strip article { padding: 17px 19px; min-height: 94px; border-right: 1px solid var(--line); }
.metric-strip article:last-child { border-right: 0; }
.metric-strip span, .metric-strip small { display: block; }
.metric-strip span { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.metric-strip strong { display: block; margin: 8px 0 3px; font: 650 26px/1 var(--mono); letter-spacing: -.04em; }
.metric-strip small { color: var(--quiet); font-size: 10px; }

.error-banner { padding: 12px 16px; margin-bottom: 12px; border: 1px solid rgba(255,107,122,.35); background: var(--red-soft); color: #ff9aa5; border-radius: 10px; font-size: 13px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0,1.75fr) minmax(310px,.75fr); gap: 12px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-head { min-height: 75px; padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 3px 0 0; font-size: 17px; letter-spacing: -.02em; }
.panel-index { margin: 0; color: var(--purple); font: 700 9px var(--mono); letter-spacing: .12em; }
.panel-note { margin: 0; color: var(--quiet); font-size: 11px; }
.legend { color: var(--quiet); font: 600 10px var(--mono); }
.legend-in { color: var(--green); margin-right: 2px; }
.legend-out { color: var(--red); margin: 0 2px 0 9px; }
.rule-chip { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font: 600 9px var(--mono); text-transform: uppercase; }

.tape-head, .tape-row { display: grid; grid-template-columns: 76px minmax(132px, .72fr) 74px minmax(260px, 1.65fr); align-items: center; gap: 10px; }
.tape-head { min-height: 35px; padding: 0 15px; color: var(--quiet); background: #101013; border-bottom: 1px solid var(--line); font: 700 9px var(--mono); text-transform: uppercase; letter-spacing: .08em; }
.tape-body { max-height: 640px; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.tape-row { min-height: 53px; padding: 8px 15px; border-bottom: 1px solid rgba(42,42,50,.72); transition: background .15s ease; }
.tape-row:hover { background: rgba(255,255,255,.018); }
.tape-time { font: 600 11px var(--mono); color: var(--muted); }
.tape-time small { display: block; color: var(--quiet); margin-top: 3px; }
.account { font: 600 11px var(--mono); white-space: nowrap; }
.account.own { color: var(--purple); }
.account.own::before { content: "WIR"; display: inline-block; margin-right: 7px; padding: 3px 5px; border-radius: 4px; background: var(--purple-soft); font-size: 8px; }
.venue { width: max-content; padding: 5px 7px; border-radius: 5px; background: rgba(255,255,255,.045); color: #c5c3cd; font: 700 9px var(--mono); letter-spacing: .04em; }
.venue.lambda { color: #cdbafa; background: var(--purple-soft); }
.venue.xfer { color: var(--amber); background: rgba(232,180,90,.1); }
.moves { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.move { display: inline-flex; gap: 6px; align-items: baseline; font: 600 11px var(--mono); }
.move b { color: var(--muted); font-size: 9px; }
.move.positive { color: var(--green); }
.move.negative { color: var(--red); }

.duel-list { max-height: 675px; overflow: auto; }
.duel-row { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.duel-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.token-badge { font: 700 10px var(--mono); color: var(--ink); }
.duel-delta { font: 700 15px var(--mono); }
.duel-delta.win { color: var(--green); }
.duel-delta.loss { color: var(--red); }
.duel-track { position: relative; height: 2px; background: var(--line); margin: 18px 0 14px; }
.duel-track::before, .duel-track::after { content: ""; position: absolute; top: -4px; width: 10px; height: 10px; border-radius: 50%; }
.duel-track::before { left: 7%; background: var(--purple); }
.duel-track::after { right: 7%; background: var(--red); }
.duel-row.win .duel-track::after { background: var(--green); }
.duel-times { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.duel-times div:last-child { text-align: right; }
.duel-times span, .duel-times b { display: block; }
.duel-times span { color: var(--quiet); font: 700 8px var(--mono); text-transform: uppercase; letter-spacing: .08em; }
.duel-times b { margin-top: 4px; font: 600 10px var(--mono); color: var(--muted); }

.empty-state { min-height: 230px; display: grid; place-items: center; align-content: center; color: var(--quiet); }
.empty-state span { font: 300 34px var(--mono); }
.empty-state p { margin: 8px 0 0; font-size: 12px; }
.empty-state.small { min-height: 170px; }
.wallets-panel { margin-top: 12px; }
.wallet-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); }
.wallet-card { min-height: 170px; padding: 18px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.wallet-card:nth-child(3n) { border-right: 0; }
.wallet-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.wallet-card-head b { font: 650 12px var(--mono); }
.wallet-card-head small { color: var(--quiet); display: block; margin-top: 5px; }
.own-chip { color: var(--purple); background: var(--purple-soft); border-radius: 5px; padding: 5px 6px; font: 700 8px var(--mono); }
.net-section { margin-top: 18px; }
.net-label { display: flex; justify-content: space-between; color: var(--quiet); font: 700 9px var(--mono); text-transform: uppercase; }
.net-moves { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 7px; }
.net-pill { padding: 6px 8px; background: #0e0e11; border: 1px solid var(--line); border-radius: 6px; font: 600 10px var(--mono); }
.net-pill.positive { color: var(--green); }
.net-pill.negative { color: var(--red); }
.net-empty { color: var(--quiet); font: 10px var(--mono); }

.footer { display: flex; justify-content: space-between; gap: 16px; padding: 22px 2px 0; color: var(--quiet); font: 600 9px var(--mono); letter-spacing: .08em; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.62); backdrop-filter: blur(2px); }
.drawer { position: fixed; z-index: 60; inset: 0 0 0 auto; width: min(440px, 100%); padding: 24px; background: #101014; border-left: 1px solid var(--line-strong); box-shadow: -30px 0 80px rgba(0,0,0,.5); transform: translateX(100%); visibility: hidden; pointer-events: none; transition: transform .24s cubic-bezier(.2,.8,.2,1), visibility 0s linear .24s; overflow-y: auto; }
.drawer.open { transform: translateX(0); visibility: visible; pointer-events: auto; transition-delay: 0s; }
.drawer header { display: flex; justify-content: space-between; align-items: flex-start; }
.drawer h2 { margin: 0; font-size: 29px; letter-spacing: -.04em; }
.icon-button { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; font-size: 24px; }
.drawer-copy { color: var(--muted); line-height: 1.5; margin: 22px 0; font-size: 13px; }
.rival-form { padding: 17px; border: 1px solid var(--line); border-radius: 11px; background: #0c0c0f; }
.rival-form .field + .field { margin-top: 14px; }
.field em { color: var(--quiet); font-style: normal; text-transform: none; }
.rival-form .button { margin-top: 16px; }
.watchlist-head { display: flex; justify-content: space-between; margin: 25px 0 10px; color: var(--muted); font: 700 10px var(--mono); text-transform: uppercase; letter-spacing: .08em; }
.watchlist-head b { color: var(--ink); }
.rival-list { display: grid; gap: 7px; }
.rival-item { min-height: 61px; display: flex; align-items: center; gap: 12px; padding: 10px 11px 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; }
.rival-avatar { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 7px; color: var(--purple); background: var(--purple-soft); font: 700 10px var(--mono); }
.rival-meta { min-width: 0; flex: 1; }
.rival-meta b, .rival-meta small { display: block; }
.rival-meta b { font: 600 11px var(--mono); }
.rival-meta small { margin-top: 4px; color: var(--quiet); font-size: 10px; }
.remove-rival { width: 38px; height: 38px; border: 0; border-radius: 8px; color: var(--quiet); background: transparent; cursor: pointer; font-size: 18px; }
.remove-rival:hover { color: var(--red); background: var(--red-soft); }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 11px 15px; border: 1px solid var(--line-strong); border-radius: 8px; background: #1b1b21; box-shadow: 0 15px 50px rgba(0,0,0,.45); font-size: 12px; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
.loading .refresh-button span { display: inline-block; animation: spin .7s linear infinite; }
.skeleton { min-height: 53px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, transparent, rgba(255,255,255,.025), transparent); background-size: 200% 100%; animation: shimmer 1.2s infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }

@media (max-width: 1120px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .duel-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); max-height: none; }
  .duel-row { border-right: 1px solid var(--line); }
  .command-bar { flex-wrap: wrap; }
  .window-copy { margin-left: 0; }
  .wallet-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .wallet-card:nth-child(3n) { border-right: 1px solid var(--line); }
  .wallet-card:nth-child(2n) { border-right: 0; }
}

@media (max-width: 760px) {
  .sidebar { position: sticky; top: 0; width: 100%; height: 63px; flex-direction: row; align-items: center; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0; }
  .brand-mark.small, .nav-stack, .sidebar-bottom { display: none; }
  .brand strong, .brand em { display: inline; font-size: 14px; }
  .main-content { margin-left: 0; padding: 22px 14px 24px; }
  .topbar { align-items: center; margin-bottom: 18px; }
  .topbar .eyebrow { display: none; }
  .topbar h1 { font-size: 30px; }
  .top-actions .button { min-height: 40px; padding: 0 12px; }
  .command-bar { align-items: stretch; gap: 9px; }
  .preset-group { width: 100%; }
  .preset-group button { flex: 1; }
  .field.compact { flex: 1; grid-template-columns: 1fr; gap: 4px; min-width: 120px; }
  .toggle { min-height: 44px; }
  .window-copy { width: 100%; text-align: left; border-top: 1px solid var(--line); padding-top: 10px; }
  .metric-strip { grid-template-columns: repeat(2,1fr); }
  .metric-strip article:nth-child(2) { border-right: 0; }
  .metric-strip article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .metric-strip strong { font-size: 23px; }
  .tape-head { display: none; }
  .tape-row { grid-template-columns: 68px 1fr auto; gap: 8px; align-items: start; padding: 12px; }
  .tape-row .moves { grid-column: 1 / -1; padding-top: 5px; }
  .tape-body { max-height: 680px; }
  .account { font-size: 10px; padding-top: 3px; }
  .venue { justify-self: end; }
  .duel-list { grid-template-columns: 1fr; }
  .wallet-grid { grid-template-columns: 1fr; }
  .wallet-card, .wallet-card:nth-child(3n) { border-right: 0; }
  .panel-head { align-items: flex-start; }
  .panel-note { max-width: 140px; text-align: right; }
  .footer { flex-direction: column; }
  .login-card { padding: 28px 22px; }
  .password-row { grid-template-columns: 1fr; }
}
