:root {
  --bg: #07080a;
  --bg-elevated: #0b0d11;
  --bg-hover: #13161e;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f3f5f8;
  --muted: #7b8393;
  --crimson: #ff244c;
  --crimson-soft: rgba(255, 36, 76, 0.14);
  --amber: #ff8a00;
  --green: #22e58a;
  --green-soft: rgba(34, 229, 138, 0.12);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

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

html,
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

.accent-crimson {
  color: var(--crimson);
}

.accent-green {
  color: var(--green);
}

/* Seamless 1px Top Bar */
.topbar {
  height: 52px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text);
}

.brand-logo {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  object-fit: cover;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.nav-link {
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  padding: 15px 2px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.nav-link:hover {
  color: var(--text);
}

.nav-link.active {
  color: var(--text);
  border-bottom-color: var(--crimson);
}

.topbar-center {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.72rem;
  color: var(--muted);
}

.unlock-bar {
  width: 110px;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
}

.unlock-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--amber), var(--crimson));
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-icon-link,
.top-ca-btn,
.top-demo-btn,
.top-connect-btn {
  height: 32px;
  padding: 0 11px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.top-ca-btn:hover,
.top-demo-btn:hover,
.top-icon-link:hover {
  border-color: var(--line-strong);
  background: var(--bg-hover);
}

.ca-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--crimson);
}

.demo-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}

.top-demo-btn.active {
  border-color: rgba(34, 229, 138, 0.45);
  background: var(--green-soft);
  color: var(--green);
}

.top-demo-btn.active .demo-dot {
  background: var(--green);
}

.top-connect-btn {
  background: var(--crimson);
  border-color: var(--crimson);
  color: #fff;
}

.top-connect-btn:hover {
  background: #e61c42;
}

/* Seamless Full-Width Exchange Grid */
.exchange-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 338px;
  min-height: calc(100vh - 52px);
}

.exchange-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--line);
}

/* Market Strip */
.market-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.market-strip-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.dropdown-wrap {
  position: relative;
}

.pair-dropdown-btn {
  height: 32px;
  padding: 0 11px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: border-color 0.15s, background 0.15s;
}

.pair-dropdown-btn:hover,
.pair-dropdown-btn.open,
.pair-dropdown-btn.active-cat {
  border-color: rgba(255, 36, 76, 0.5);
  background: var(--bg-hover);
}

.pair-dropdown-btn.open .chev {
  transform: rotate(180deg);
}

.tier-pill {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--crimson);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 60;
  width: 330px;
  background: rgba(11, 13, 17, 0.98);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.72);
  overflow: hidden;
  animation: ddFade 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes ddFade {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-head {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 0.66rem;
  color: var(--muted);
}

.dropdown-search-wrap {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.dropdown-search {
  width: 100%;
  height: 30px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 9px;
  color: var(--text);
  font-size: 0.74rem;
  outline: none;
}

.dropdown-search:focus {
  border-color: var(--crimson);
}

.dropdown-list {
  max-height: 290px;
  overflow-y: auto;
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-width: thin;
}

.dropdown-item {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--bg-hover);
}

.dropdown-item.selected {
  background: var(--crimson-soft);
  border-color: rgba(255, 36, 76, 0.35);
}

.dd-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dd-sym-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dd-sym {
  font-weight: 600;
  font-size: 0.84rem;
}

.dd-lev {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
}

.dd-sub {
  font-size: 0.69rem;
  color: var(--muted);
}

.dd-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.dd-price {
  font-size: 0.8rem;
  font-weight: 600;
}

.dd-chg {
  font-size: 0.68rem;
}

.active-pair-inline {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-left: 6px;
  flex-wrap: wrap;
}

.pair-name {
  font-size: 0.98rem;
  font-weight: 700;
}

.pair-price {
  font-size: 1.02rem;
  font-weight: 700;
  transition: color 0.15s;
}

.pair-chg,
.pair-meta,
.pair-tier-inline {
  font-size: 0.76rem;
}

.pair-meta {
  color: var(--muted);
}

.pair-tier-inline {
  color: var(--crimson);
  font-weight: 600;
}

.tick-up { color: var(--green) !important; }
.tick-down { color: var(--crimson) !important; }

.ca-inline-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ca-inline-input {
  width: 220px;
  height: 30px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 9px;
  color: var(--text);
  font-size: 0.72rem;
  outline: none;
}

.ca-inline-input:focus {
  border-color: var(--crimson);
}

.ca-inline-btn {
  height: 30px;
  padding: 0 11px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--bg-hover);
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
}

/* Chart Subbar & Seamless Canvas */
.chart-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 18px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.chart-tf-group,
.chart-tools-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tf-btn,
.mode-btn,
.tool-icon-btn {
  height: 24px;
  padding: 0 7px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.71rem;
  font-weight: 600;
  cursor: pointer;
}

.tf-btn:hover,
.mode-btn:hover,
.tool-icon-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.tf-btn.active,
.mode-btn.active {
  color: var(--text);
  background: var(--bg-hover);
}

.tool-sep {
  width: 1px;
  height: 14px;
  background: var(--line);
  margin: 0 4px;
}

.chart-ohlc {
  font-size: 0.7rem;
  color: var(--muted);
}

.chart-canvas-wrap {
  position: relative;
  height: 455px;
  width: 100%;
}

#priceChart {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

/* Bottom Seamless Ledger */
.ledger-section {
  flex: 1;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.ledger-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.ledger-tabs {
  display: flex;
  gap: 18px;
}

.ledger-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 11px 2px;
  cursor: pointer;
}

.ledger-tab.active {
  color: var(--text);
  border-bottom-color: var(--crimson);
}

.ledger-right {
  font-size: 0.74rem;
  color: var(--muted);
}

.ledger-right strong {
  color: var(--text);
}

.ledger-body {
  padding: 14px 18px;
  flex: 1;
}

.empty-state {
  padding: 26px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.pos-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.pos-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.pos-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}

.pos-table td {
  padding: 9px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.close-pos-btn,
.receipt-mini-btn {
  padding: 4px 10px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  background: var(--bg-hover);
  color: var(--text);
  font-size: 0.72rem;
  cursor: pointer;
}

/* Stake Panel */
.stake-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.stake-title {
  font-size: 0.9rem;
  font-weight: 600;
}

.stake-sub {
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 3px;
}

.stake-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stake-input {
  width: 130px;
  height: 34px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text);
  font-size: 0.8rem;
  outline: none;
}

.stake-btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 6px;
  border: none;
  background: var(--crimson);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.unstake-btn {
  height: 34px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--bg-hover);
  color: var(--text);
  font-size: 0.78rem;
  cursor: pointer;
}

/* Right Order Column (Seamless getbust.trade layout) */
.order-column {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg);
}

.side-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--bg-elevated);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.side-btn {
  height: 36px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.86rem;
  cursor: pointer;
}

.side-btn.long.active {
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid rgba(34, 229, 138, 0.35);
}

.side-btn.short.active {
  background: var(--crimson-soft);
  color: var(--crimson);
  border: 1px solid rgba(255, 36, 76, 0.4);
}

.order-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--muted);
}

.field-top strong {
  color: var(--text);
}

.margin-input-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  height: 40px;
}

.margin-input-row:focus-within {
  border-color: var(--crimson);
}

.margin-input-row input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  outline: none;
}

.margin-input-row .unit {
  font-size: 0.74rem;
  color: var(--muted);
}

.preset-row {
  display: flex;
  gap: 6px;
}

.preset-btn {
  padding: 4px 10px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--muted);
  font-size: 0.71rem;
  cursor: pointer;
}

.preset-btn:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

/* Seamless Fuse Risk Stage (No inner box!) */
.fuse-risk-stage {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 0;
}

.fuse-emblem-stage {
  position: relative;
  width: 74px;
  height: 74px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fuse-glow-aura {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 36, 76, 0.3) 0%, transparent 70%);
  opacity: 0.4;
  transition: opacity 0.2s, transform 0.2s;
}

.fuse-emblem {
  width: 68px;
  height: 68px;
  border-radius: 16px;
  object-fit: cover;
  position: relative;
  z-index: 2;
}

.fuse-risk-stage.heat-mid .fuse-glow-aura {
  opacity: 0.7;
}

.fuse-risk-stage.heat-high .fuse-emblem {
  animation: fuseJitterSoft 0.24s infinite linear;
  filter: drop-shadow(0 0 12px rgba(255, 36, 76, 0.75));
}

.fuse-risk-stage.heat-max .fuse-glow-aura {
  opacity: 1;
  transform: scale(1.2);
}

.fuse-risk-stage.heat-max .fuse-emblem {
  animation: fuseJitterHard 0.11s infinite linear;
  filter: drop-shadow(0 0 18px rgba(255, 36, 76, 1)) saturate(1.3);
}

@keyframes fuseJitterSoft {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-1px, 1px); }
  50% { transform: translate(1px, -1px); }
  75% { transform: translate(-1px, -1px); }
}

@keyframes fuseJitterHard {
  0%, 100% { transform: translate(0, 0) scale(1.04); }
  20% { transform: translate(-2px, 1.5px) rotate(-1.5deg) scale(1.05); }
  40% { transform: translate(2px, -1.5px) rotate(1.5deg) scale(1.05); }
  60% { transform: translate(-1.5px, -2px) rotate(-1deg) scale(1.04); }
  80% { transform: translate(1.5px, 2px) rotate(1deg) scale(1.05); }
}

.fuse-risk-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.risk-kicker {
  font-size: 0.72rem;
  color: var(--muted);
}

.fuse-lev-big {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.05;
}

.fuse-risk-status {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--amber);
}

.fuse-risk-stage.heat-max .fuse-risk-status {
  color: var(--crimson);
}

.lev-chips {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.lev-chip {
  flex: 1;
  min-width: 42px;
  height: 28px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  cursor: pointer;
}

.lev-chip.active {
  border-color: var(--line-strong);
  color: var(--text);
  background: var(--bg-hover);
}

.lev-slider {
  width: 100%;
  accent-color: var(--crimson);
  cursor: pointer;
}

.fuse-heat-bar {
  height: 3px;
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 99px;
  overflow: hidden;
}

.fuse-heat-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--amber), var(--crimson));
  transition: width 0.2s;
}

.risk-line {
  font-size: 0.72rem;
  color: var(--amber);
}

.order-specs {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  font-size: 0.75rem;
}

.spec-row {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
}

.spec-row strong {
  color: var(--text);
}

.submit-order-btn {
  height: 44px;
  border: none;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.submit-order-btn.long {
  background: var(--green);
  color: #04130b;
}

.submit-order-btn.short {
  background: var(--crimson);
  color: #fff;
}

.ticket-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.71rem;
  color: var(--muted);
}

.ticket-footer strong {
  color: var(--text);
}

.copy-mini-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 4px;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  cursor: pointer;
}

/* Toasts & Modals */
.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-item {
  background: #12151d;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--crimson);
  color: var(--text);
  padding: 9px 13px;
  border-radius: 7px;
  font-size: 0.78rem;
}

.toast-item.ok {
  border-left-color: var(--green);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 660px;
  background: var(--bg-elevated);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wallet-modal-card {
  max-width: 360px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.35rem;
  cursor: pointer;
}

.receipt-canvas {
  width: 100%;
  height: auto;
  border-radius: 8px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.receipt-dl-btn,
.receipt-x-btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.receipt-dl-btn {
  background: var(--bg-hover);
  border: 1px solid var(--line-strong);
  color: var(--text);
}

.receipt-x-btn {
  background: var(--crimson);
  border: none;
  color: #fff;
}

.wallet-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wallet-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.wallet-option:hover {
  border-color: var(--crimson);
}

@media (max-width: 1040px) {
  .topbar-center {
    display: none;
  }

  .exchange-grid {
    grid-template-columns: 1fr;
  }

  .exchange-main {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .chart-canvas-wrap {
    height: 330px;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 0 10px;
    gap: 8px;
  }

  .top-nav {
    display: none;
  }

  .top-ca-btn,
  .top-demo-btn,
  .top-connect-btn {
    padding: 0 8px;
    font-size: 0.7rem;
  }

  .market-strip {
    padding: 10px 12px;
  }

  .ca-inline-form {
    width: 100%;
  }

  .ca-inline-input {
    flex: 1;
    width: auto;
  }

  .dropdown-menu {
    width: min(320px, calc(100vw - 24px));
  }

  .chart-canvas-wrap {
    height: 270px;
  }
}
