:root {
  --bg: #07090f;
  --bg-2: #0c1018;
  --panel: rgba(16, 20, 32, 0.78);
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #eef2fa;
  --muted: #8b94a8;
  --faint: #5a6278;
  --accent: #34d399;
  --accent-2: #22d3ee;
  --bingx: #818cf8;
  --bingx-glow: rgba(129, 140, 248, 0.35);
  --tangem: #34d399;
  --tangem-glow: rgba(52, 211, 153, 0.35);
  --red: #fb7185;
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.75);
  --radius: 20px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: linear-gradient(180deg, var(--bg), var(--bg-2));
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
  overflow-x: hidden;
}

#bgCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: 38px 24px 80px;
}

/* Header */
header.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; flex-wrap: wrap; margin-bottom: 28px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 48px; height: 48px; border-radius: 14px;
  background: linear-gradient(135deg, var(--tangem), var(--accent-2));
  display: grid; place-items: center; font-size: 22px;
  box-shadow: 0 12px 36px -10px var(--tangem-glow);
  animation: logoPulse 4s ease-in-out infinite;
}
@keyframes logoPulse {
  0%, 100% { box-shadow: 0 12px 36px -10px var(--tangem-glow); }
  50% { box-shadow: 0 12px 48px -6px rgba(52, 211, 153, 0.55); }
}
.brand h1 { font-size: 23px; font-weight: 800; letter-spacing: -0.03em; }
.brand p { font-size: 13px; color: var(--muted); margin-top: 2px; }
.head-actions { display: flex; align-items: center; gap: 10px; }

.btn {
  border: 1px solid var(--border-strong); background: var(--panel);
  color: var(--text); padding: 10px 16px; border-radius: 12px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; font-family: inherit; display: inline-flex;
  align-items: center; gap: 8px; transition: all .2s ease; backdrop-filter: blur(10px);
}
.btn:hover { border-color: var(--tangem); color: #fff; transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary {
  background: linear-gradient(135deg, var(--tangem), var(--accent-2));
  border: none; color: #042018;
  box-shadow: 0 12px 32px -10px var(--tangem-glow);
}
.btn .spin { display: none; }
.btn.loading .spin { display: inline-block; animation: spin .8s linear infinite; }
.btn.loading .lbl { opacity: .7; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Cards */
.cards {
  display: grid; grid-template-columns: 1.4fr 1fr 1fr;
  gap: 14px; margin-bottom: 14px;
}
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  backdrop-filter: blur(14px); box-shadow: var(--shadow);
  position: relative; overflow: hidden;
  animation: cardIn .5s ease backwards;
}
.card:nth-child(1) { animation-delay: .05s; }
.card:nth-child(2) { animation-delay: .1s; }
.card:nth-child(3) { animation-delay: .15s; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.card .label {
  font-size: 11px; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em;
}
.card .value {
  font-size: 26px; font-weight: 800; margin-top: 10px;
  letter-spacing: -0.03em; font-family: 'JetBrains Mono', monospace;
}
.card .sub { font-size: 12px; color: var(--faint); margin-top: 6px; }
.card.hero {
  background: linear-gradient(135deg, rgba(52,211,153,.12), rgba(34,211,238,.07));
}
.card.hero .value {
  font-size: 34px;
  background: linear-gradient(135deg, #fff, #b9f6e2);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.card-tangem { border-color: rgba(52,211,153,.2); }
.card-tangem .value { color: var(--tangem); }
.card-bingx { border-color: rgba(129,140,248,.2); }
.card-bingx .value { color: var(--bingx); }
/* Dropzone */
.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  padding: 44px 24px; text-align: center; cursor: pointer;
  transition: all .25s ease; background: var(--panel); margin-bottom: 24px;
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--tangem);
  background: rgba(52,211,153,.05);
  box-shadow: 0 0 40px -10px var(--tangem-glow);
}
.dropzone .dz-icon { font-size: 36px; margin-bottom: 10px; }
.dropzone h3 { font-size: 17px; font-weight: 700; }
.dropzone p { font-size: 13px; color: var(--muted); margin-top: 6px; }
.dropzone .hl { color: var(--tangem); font-weight: 600; }

/* Flow section */
#flowSection {
  margin-bottom: 28px;
  animation: cardIn .6s ease backwards;
}
.flow-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.flow-head h2 { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.flow-head p { font-size: 13px; color: var(--muted); margin-top: 4px; }
.flow-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.flow-legend span { display: flex; align-items: center; gap: 6px; }
.flow-legend .dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}
.flow-legend .dot.bingx { background: var(--bingx); box-shadow: 0 0 8px var(--bingx-glow); }
.flow-legend .dot.tangem { background: var(--tangem); box-shadow: 0 0 8px var(--tangem-glow); }
.flow-legend .dot.flow { background: var(--accent-2); animation: flowBlink 1.5s ease infinite; }
@keyframes flowBlink { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

.flow-stage {
  position: relative;
  display: grid;
  grid-template-columns: 1fr minmax(120px, 200px) 1fr;
  gap: 0;
  align-items: stretch;
  min-height: 340px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
#flowCanvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 2;
}

.flow-node {
  position: relative; z-index: 3;
  display: flex; flex-direction: column; align-items: center;
  padding: 16px 12px; border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(10, 14, 24, 0.6);
  backdrop-filter: blur(8px);
  transition: border-color .3s, box-shadow .3s;
}
.flow-node.bingx { border-color: rgba(129,140,248,.25); }
.flow-node.tangem { border-color: rgba(52,211,153,.25); }
.flow-node.bingx:hover { box-shadow: 0 0 30px -8px var(--bingx-glow); }
.flow-node.tangem:hover { box-shadow: 0 0 30px -8px var(--tangem-glow); }

.node-glow {
  position: absolute; inset: -1px; border-radius: inherit; opacity: .5;
  pointer-events: none; z-index: -1;
}
.flow-node.bingx .node-glow {
  background: radial-gradient(ellipse at 50% 0%, var(--bingx-glow), transparent 70%);
  animation: nodeGlow 3s ease-in-out infinite;
}
.flow-node.tangem .node-glow {
  background: radial-gradient(ellipse at 50% 0%, var(--tangem-glow), transparent 70%);
  animation: nodeGlow 3s ease-in-out infinite .5s;
}
@keyframes nodeGlow {
  0%, 100% { opacity: .4; }
  50% { opacity: .8; }
}

.node-icon {
  width: 52px; height: 52px; border-radius: 14px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 15px; letter-spacing: .04em;
  margin-bottom: 12px;
}
.flow-node.bingx .node-icon {
  background: linear-gradient(135deg, #6366f1, #818cf8);
  color: #fff; box-shadow: 0 8px 24px -6px var(--bingx-glow);
}
.flow-node.tangem .node-icon {
  background: linear-gradient(135deg, #10b981, #34d399);
  color: #042018; box-shadow: 0 8px 24px -6px var(--tangem-glow);
}

.node-info { text-align: center; margin-bottom: 14px; }
.node-info h3 { font-size: 16px; font-weight: 800; }
.node-val {
  display: block; font-family: 'JetBrains Mono', monospace;
  font-size: 18px; font-weight: 700; margin-top: 6px;
}
.flow-node.bingx .node-val { color: var(--bingx); }
.flow-node.tangem .node-val { color: var(--tangem); }
.node-count { font-size: 11px; color: var(--faint); }

.node-coins {
  width: 100%; display: flex; flex-wrap: wrap; gap: 6px;
  justify-content: center; max-height: 180px; overflow-y: auto;
  padding: 2px;
}
.node-coins::-webkit-scrollbar { width: 4px; }
.node-coins::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

.coin-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 9px; border-radius: 9px;
  font-size: 11px; font-weight: 600;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  cursor: default;
  animation: chipIn .4s ease backwards;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.coin-chip:hover {
  transform: translateY(-2px) scale(1.03);
  border-color: rgba(255,255,255,.2);
  box-shadow: 0 6px 20px -8px rgba(0,0,0,.5);
}
.coin-chip .chip-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.coin-chip .chip-sym { font-family: 'JetBrains Mono', monospace; }
.coin-chip .chip-val { color: var(--muted); font-size: 10px; }

@keyframes chipIn {
  from { opacity: 0; transform: scale(.85); }
  to { opacity: 1; transform: none; }
}

/* Bridge */
.flow-bridge {
  position: relative; z-index: 3;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 0 8px;
}
.bridge-svg {
  width: 100%; height: 50px; overflow: visible;
}
.bridge-path {
  fill: none; stroke: rgba(34,211,238,.25); stroke-width: 2;
  stroke-dasharray: 6 4;
  animation: dashMove 2s linear infinite;
}
.bridge-path.glow {
  stroke: rgba(34,211,238,.08); stroke-width: 8; filter: blur(4px);
  animation: none;
}
@keyframes dashMove { to { stroke-dashoffset: -20; } }

.bridge-arrows {
  position: absolute; top: 50%; left: 10%; right: 10%;
  height: 2px; transform: translateY(-50%);
}
.arrow-bit {
  position: absolute; top: -3px; width: 8px; height: 8px;
  background: var(--accent-2); border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-2);
  animation: arrowFly 2.2s ease-in-out infinite;
  animation-delay: var(--d);
  opacity: 0;
}
@keyframes arrowFly {
  0% { left: 0%; opacity: 0; transform: scale(.5); }
  10% { opacity: 1; transform: scale(1); }
  90% { opacity: 1; }
  100% { left: 100%; opacity: 0; transform: scale(.5); }
}

.bridge-label {
  font-size: 10px; font-weight: 600; color: var(--accent-2);
  text-transform: uppercase; letter-spacing: .08em;
  margin-top: 8px; white-space: nowrap;
  animation: flowBlink 2s ease infinite;
}

/* Split bar */
.flow-split { margin-top: 14px; }
.split-labels {
  display: flex; justify-content: space-between;
  font-size: 12px; font-weight: 600; margin-bottom: 8px;
}
.split-labels span:first-child { color: var(--bingx); }
.split-labels span:last-child { color: var(--tangem); }
.split-track {
  display: flex; height: 10px; border-radius: 6px;
  overflow: hidden; background: rgba(255,255,255,.06);
}
.split-bingx, .split-tangem {
  height: 100%; transition: width .8s cubic-bezier(.4,0,.2,1);
  position: relative;
}
.split-bingx {
  background: linear-gradient(90deg, #6366f1, var(--bingx));
  border-radius: 6px 0 0 6px;
}
.split-tangem {
  background: linear-gradient(90deg, var(--tangem), #2dd4bf);
  border-radius: 0 6px 6px 0;
}
.split-bingx::after, .split-tangem::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.15), transparent);
  animation: shimmer 2.5s ease infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Toolbar */
.toolbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.search {
  flex: 1; min-width: 200px; display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 11px 15px;
}
.search input {
  background: none; border: none; outline: none;
  color: var(--text); font-size: 14px; width: 100%; font-family: inherit;
}
.toggle {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted); cursor: pointer;
}

/* Table */
.table-wrap {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: right; font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; white-space: nowrap; user-select: none;
}
thead th:first-child, thead th:nth-child(2) { text-align: left; }
thead th .arrow { opacity: 0; font-size: 10px; margin-left: 4px; }
thead th.sorted .arrow { opacity: 1; color: var(--tangem); }
tbody td {
  padding: 14px 16px; text-align: right; font-size: 13.5px;
  border-bottom: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
}
tbody td:first-child, tbody td:nth-child(2) { text-align: left; font-family: 'Inter', sans-serif; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: rgba(255,255,255,.025); }
tbody tr.highlight { background: rgba(52,211,153,.08); }
tbody tr:last-child td { border-bottom: none; }

.asset { display: flex; align-items: center; gap: 11px; }
.sym-wrap { position: relative; flex-shrink: 0; width: 34px; height: 34px; }
.asset .sym-icon {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
  color: #051a14; flex-shrink: 0; font-family: 'JetBrains Mono', monospace;
}
.asset .sym-icon.sym-img {
  display: block; object-fit: cover;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
}
.sym-fallback--hidden { display: none !important; }

.loc-cell { display: flex; align-items: center; gap: 8px; }
.loc-track {
  flex: 1; max-width: 100px; height: 5px; border-radius: 3px;
  background: rgba(255,255,255,.08); overflow: hidden; display: flex;
}
.loc-bingx { background: var(--bingx); height: 100%; transition: width .5s; }
.loc-tangem { background: var(--tangem); height: 100%; transition: width .5s; }

.badge {
  font-size: 10px; font-weight: 700; padding: 3px 8px;
  border-radius: 7px; letter-spacing: .03em; white-space: nowrap;
}
.badge.bingx { background: rgba(129,140,248,.18); color: #b3bbff; }
.badge.tangem { background: rgba(52,211,153,.18); color: #7df0c4; }
.badge.split { background: rgba(34,211,238,.12); color: #7de8f7; }

.num { font-variant-numeric: tabular-nums; }
.val { font-weight: 600; color: #fff; }
.na { color: var(--faint); font-size: 12px; }

.share-cell { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.bar { width: 56px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.08); overflow: hidden; }
.bar > i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--tangem), var(--accent-2));
  border-radius: 3px; transition: width .5s;
}
.share-pct { width: 42px; text-align: right; color: var(--muted); font-size: 12px; }

.fee-cell { vertical-align: middle; }
.fee-cell-inner {
  display: inline-flex; flex-direction: column; align-items: flex-end; gap: 5px;
}
.fee-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: .02em; text-transform: none;
}
.fee-badge-1 { background: rgba(52,211,153,.14); color: #7df0c4; border: 1px solid rgba(52,211,153,.22); }
.fee-badge-2 { background: rgba(251,191,36,.16); color: #fcd34d; border: 1px solid rgba(251,191,36,.28); }
.fee-badge-3 { background: rgba(251,146,60,.18); color: #fdba74; border: 1px solid rgba(251,146,60,.3); }
.fee-badge-4 { background: rgba(251,113,133,.2); color: #fda4af; border: 1px solid rgba(251,113,133,.35); }
.fee-usd { color: var(--muted); font-size: 11px; font-weight: 500; }

.dca-cell { vertical-align: middle; }
.dca-cell-inner {
  display: inline-flex; flex-direction: column; align-items: flex-end; gap: 4px;
}
.dca-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: .02em; text-transform: none;
}
.dca-badge-1 { background: rgba(129,140,248,.14); color: #b3bbff; border: 1px solid rgba(129,140,248,.22); }
.dca-badge-2 { background: rgba(34,211,238,.12); color: #7de8f7; border: 1px solid rgba(34,211,238,.22); }
.dca-badge-3 { background: rgba(52,211,153,.14); color: #7df0c4; border: 1px solid rgba(52,211,153,.22); }
.dca-badge-4 { background: rgba(167,139,250,.16); color: #d8c4ff; border: 1px solid rgba(167,139,250,.28); }
.dca-avg { color: var(--muted); font-size: 11px; font-weight: 500; }
.dca-pnl { font-size: 11px; font-weight: 600; }
.dca-pnl.up { color: var(--tangem); }
.dca-pnl.down { color: var(--red); }

.demo-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  flex-wrap: wrap; padding: 10px 20px;
  background: linear-gradient(90deg, rgba(129,140,248,.2), rgba(52,211,153,.2));
  border-bottom: 1px solid rgba(255,255,255,.1);
  backdrop-filter: blur(12px);
  font-size: 13px; font-weight: 600;
}
.demo-banner .pill {
  padding: 3px 10px; border-radius: 20px; font-size: 11px;
  background: rgba(251,191,36,.2); color: #fcd34d;
  letter-spacing: .05em; text-transform: uppercase;
}
.demo-banner a {
  color: var(--accent-2); text-decoration: none; font-weight: 600;
}
.demo-banner a:hover { text-decoration: underline; }
body.has-demo { padding-top: 44px; }

.hidden { display: none !important; }
.empty-note { text-align: center; padding: 36px; color: var(--faint); }
footer.foot { text-align: center; margin-top: 24px; color: var(--faint); font-size: 12px; }
footer.foot .dot { color: var(--tangem); }
.err { color: var(--red); font-size: 13px; margin-top: 10px; text-align: center; }

@media (max-width: 960px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .flow-stage { grid-template-columns: 1fr; min-height: auto; gap: 16px; }
  .flow-bridge { order: 2; padding: 8px 0; }
  .flow-node.bingx { order: 1; }
  .flow-node.tangem { order: 3; }
  .bridge-svg { transform: rotate(90deg); height: 80px; }
  .bridge-arrows { top: auto; left: 50%; right: auto; width: 2px; height: 60px; transform: translateX(-50%); }
  .arrow-bit { animation-name: arrowFlyVert; left: -3px !important; }
  @keyframes arrowFlyVert {
    0% { top: 0%; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { top: 100%; opacity: 0; }
  }
  .col-hide { display: none; }
}
@media (max-width: 540px) {
  .wrap { padding: 22px 14px 60px; }
  .cards { grid-template-columns: 1fr; }
}
