/* ===== Reset & Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-font-smoothing: antialiased; }
body {
  background: #0a0a0a;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 24px;
}

/* ===== Link out to liquidity architecture doc ===== */
.liquidity-link {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
  background: #15191c;
  border: 1px solid #2c2f36;
  color: #3DF57A;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 15px;
  border-radius: 9px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.liquidity-link:hover {
  background: #1b2024;
  border-color: #3DF57A55;
}

/* ===== Extension popup frame ===== */
.popup-frame {
  width: 372px;
  height: 860px;
  background: #141618;
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  border: 1px solid #2c2f36;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
}

/* ===== MetaMask top bar ===== */
.mm-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #1c1f23;
  border-bottom: 1px solid #232730;
  font-size: 13px;
  color: #fff;
  font-weight: 600;
}
.mm-titlebar .mm-brand {
  display: flex; align-items: center; gap: 8px;
}
.mm-titlebar .mm-fox {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
}
.mm-titlebar .mm-fox svg { width: 22px; height: 22px; }
.mm-titlebar .mm-controls {
  display: flex; align-items: center; gap: 14px;
  color: #9fa6b2;
}
.mm-titlebar .mm-controls svg { width: 16px; height: 16px; cursor: pointer; }
.mm-titlebar .mm-controls svg:hover { color: #fff; }

/* ===== Screens ===== */
.screen { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.screen.active { display: flex; }
#screen-home.active {
  overflow-y: auto;
  overflow-x: hidden;
}
#screen-home::-webkit-scrollbar { width: 6px; }
#screen-home::-webkit-scrollbar-thumb { background: #2c2f36; border-radius: 3px; }

.screen-header {
  display: grid;
  grid-template-columns: 28px 1fr 28px;
  align-items: center;
  padding: 14px 14px 8px;
}
.screen-header .back-btn {
  width: 28px; height: 28px;
  background: none; border: 0; cursor: pointer;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.screen-header h2 {
  font-size: 16px; font-weight: 600;
  text-align: center;
  color: #fff;
}
.screen-header .settings-btn {
  width: 28px; height: 28px;
  background: none; border: 0; cursor: pointer;
  color: #9fa6b2;
  display: flex; align-items: center; justify-content: center;
}
.screen-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 14px 14px;
}
#screen-swap .screen-body {
  padding: 0 12px 12px;
}
.screen-body::-webkit-scrollbar { width: 6px; }
.screen-body::-webkit-scrollbar-thumb { background: #2c2f36; border-radius: 3px; }

/* ===== Home screen ===== */
.home-account-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 8px;
}
.account-dropdown {
  display: flex; align-items: center; gap: 6px;
  color: #fff; font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.account-dropdown svg { width: 14px; height: 14px; color: #9fa6b2; }
.account-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: #1c1f23;
  border: 1px solid #2c2f36;
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 12px;
  color: #9fa6b2;
  margin-left: 14px;
}
.account-pill-icons {
  display: inline-flex; align-items: center;
}
.account-pill-icons .chain-dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid #1c1f23;
  margin-left: -6px;
}
.account-pill-icons .chain-dot:first-child { margin-left: 0; }
.account-pill .copy-icon { width: 12px; height: 12px; color: #9fa6b2; cursor: pointer; }
.menu-btn {
  width: 32px; height: 32px;
  background: #1c1f23;
  border: 1px solid #2c2f36;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: #9fa6b2;
}

/* Fund-your-wallet hero */
.hero-fund {
  margin: 8px 14px 0;
  padding: 18px 16px;
  background: #1c1f23;
  border: 1px solid #232730;
  border-radius: 16px;
  text-align: center;
}
.hero-fund-icon {
  width: 64px; height: 64px;
  margin: 0 auto 8px;
  background: linear-gradient(135deg, #2a2f3c, #3a4259);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
}
.hero-fund-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.hero-fund-sub { color: #9fa6b2; font-size: 12px; margin-bottom: 14px; }
.hero-fund-btn {
  display: block;
  width: 100%;
  padding: 11px;
  background: #fff;
  color: #141618;
  border: 0;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

/* Action row */
.action-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 14px;
}
.action-tile {
  background: #1c1f23;
  border: 1px solid #232730;
  border-radius: 12px;
  padding: 12px 4px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  cursor: pointer;
  transition: background 0.12s;
}
.action-tile:hover { background: #232730; }
.action-tile svg { width: 18px; height: 18px; color: #fff; }
.action-tile span {
  font-size: 12px; color: #fff; font-weight: 500;
}

/* Promo card */
.promo-card {
  margin: 0 14px 12px;
  padding: 12px;
  background: #1c1f23;
  border: 1px solid #232730;
  border-radius: 12px;
  display: flex; align-items: center; gap: 10px;
}
.promo-card .promo-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, #3a2a5c, #5c3a8c);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.promo-card .promo-body { flex: 1; }
.promo-card .promo-title { font-size: 13px; font-weight: 600; color: #fff; }
.promo-card .promo-sub { font-size: 11px; color: #9fa6b2; line-height: 1.35; }
.promo-card .promo-close {
  width: 18px; height: 18px; color: #9fa6b2; cursor: pointer;
}

/* Tabs */
.section-tabs {
  display: flex; gap: 18px;
  padding: 4px 16px;
  border-bottom: 1px solid #232730;
  margin: 0 14px;
}
.section-tab {
  padding: 10px 0;
  font-size: 13px; font-weight: 500;
  color: #9fa6b2;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.section-tab.active { color: #fff; border-bottom-color: #fff; }

.tab-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 6px;
}
.network-filter {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; color: #fff; font-weight: 500;
  background: #1c1f23;
  border: 1px solid #2c2f36;
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
}
.network-filter svg { width: 10px; height: 10px; }
.tab-toolbar-actions { display: flex; gap: 10px; color: #9fa6b2; }
.tab-toolbar-actions svg { width: 16px; height: 16px; cursor: pointer; }

/* Assets section labels */
.assets-section-label {
  padding: 14px 20px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b7080;
  display: flex; align-items: center; gap: 10px;
}
.assets-section-label.vault-label { color: #8b95ff; }
.vault-pill {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: rgba(139, 149, 255, 0.12);
  border: 1px solid rgba(139, 149, 255, 0.35);
  color: #8b95ff;
  padding: 2px 6px;
  border-radius: 999px;
  text-transform: uppercase;
}

/* Harbor vault row variant */
.token-row.vault-row {
  background: rgba(139, 149, 255, 0.05);
  border: 1px solid rgba(139, 149, 255, 0.18);
  padding: 12px;
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  margin-bottom: 6px;
  cursor: default;
}
.token-row.vault-row:hover { background: rgba(139, 149, 255, 0.07); }
.vault-row .vault-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.vault-row .vault-head {
  display: flex; align-items: baseline; justify-content: space-between;
}
.vault-row .vault-name {
  font-size: 14px; font-weight: 600;
}
.vault-row .vault-total {
  font-family: 'SF Mono', monospace;
  font-size: 13px; font-weight: 700;
  color: #fff;
}
.vault-row .vault-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 11px;
}
.vault-row .vault-split .lbl { color: #9fa6b2; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; font-size: 10px; }
.vault-row .vault-split .val { color: #fff; font-family: 'SF Mono', monospace; font-weight: 600; }
.vault-row .vault-split .val.locked { color: #ffd74d; }
.vault-row .vault-actions {
  display: flex; gap: 6px; margin-top: 4px;
}
.vault-row .vault-btn {
  flex: 1;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid #2c2f36;
  border-radius: 8px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.vault-row .vault-btn:hover { background: #232730; }
.vault-row .vault-btn[disabled] { color: #4a4f56; border-color: #232730; cursor: not-allowed; }

/* Token list */
.token-list { padding: 0 14px 0; }
.token-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 6px;
  cursor: pointer;
  border-radius: 10px;
}
.token-row:hover { background: #1a1d22; }
.token-row.clob-row {
  cursor: default;
}
.token-row.clob-row:hover {
  background: transparent;
}
.token-row.clob-row .token-sub {
  max-width: none;
}
.token-row.clob-row .clob-sub {
  display: flex;
  flex-wrap: wrap;
  column-gap: 10px;
  row-gap: 2px;
  line-height: 1.25;
}
.token-icon {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #4459ff, #6677ff);
  position: relative;
  font-weight: 600;
}
.token-icon .chain-badge {
  position: absolute; bottom: -3px; right: -3px;
  width: 18px; height: 18px; border-radius: 6px;
  background: #4459ff;
  border: 2px solid #141618;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.token-icon .chain-badge.musd-icon { background: #c7e4fb; }
.token-icon .chain-badge.eth-icon { background: #627eea; }
.token-icon .chain-badge.btc-icon { background: #f7931a; }
.token-icon .chain-badge.harbor-badge {
  background: #141618;
  border-color: #141618;
  border-radius: 50%;
  padding: 2px;
}
.token-icon.has-chain-badge { overflow: visible; }
.token-icon.musd-icon,
.token-icon-sm.musd-icon {
  overflow: hidden;
  background: #c7e4fb;
}
.token-icon img,
.token-icon-sm img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}
.token-icon.has-chain-badge > img {
  border-radius: 50%;
}
.token-icon .chain-badge img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.token-icon.eth-icon,
.token-icon-sm.eth-icon {
  overflow: hidden;
  background: #627eea;
}
.token-icon.btc-icon,
.token-icon-sm.btc-icon {
  overflow: hidden;
  background: #f7931a;
}
.token-icon.musd-icon.has-chain-badge,
.token-icon.eth-icon.has-chain-badge,
.token-icon.btc-icon.has-chain-badge {
  overflow: visible;
}
.token-name { font-size: 14px; font-weight: 600; color: #fff; }
.token-sub { font-size: 12px; color: #9fa6b2; margin-top: 2px; }
.token-sub.accent { color: #8b95ff; }
.token-amounts { text-align: right; }
.token-balance { font-size: 14px; font-weight: 600; color: #fff; }
.token-units { font-size: 12px; color: #9fa6b2; margin-top: 2px; }
.token-pill-cta {
  background: #1c1f23;
  border: 1px solid #2c2f36;
  border-radius: 999px;
  padding: 6px 14px;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

/* ===== Swap screen ===== */
.swap-mode-toggle {
  display: flex; gap: 4px;
  background: #1c1f23;
  border: 1px solid #2c2f36;
  border-radius: 999px;
  padding: 3px;
  margin: 0 14px 12px;
}
.swap-mode-btn {
  flex: 1;
  padding: 7px 12px;
  border-radius: 999px;
  background: transparent;
  border: 0;
  color: #9fa6b2;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.swap-mode-btn.active {
  background: #2c3140;
  color: #fff;
}
.swap-mode-btn .mode-badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 9px;
  padding: 2px 5px;
  background: #4459ff;
  color: #fff;
  border-radius: 4px;
  font-weight: 700;
}

.swap-card {
  padding: 14px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}
.swap-side {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 12px 4px;
}
.swap-side input {
  background: transparent; border: 0; outline: none;
  color: #fff; font-size: 40px; font-weight: 500;
  width: 100%;
  font-family: inherit;
  padding: 0;
  letter-spacing: -0.02em;
}
.swap-side input::placeholder { color: #4a4f56; }
.swap-side-sub {
  display: flex; justify-content: space-between;
  margin-top: 4px;
  padding: 0 4px;
}
.swap-side-sub .fiat {
  color: #9fa6b2; font-size: 13px;
}
.swap-side-sub .fiat .zero { color: #ff5c5c; }
.swap-side-sub .right-link {
  color: #8b95ff; font-size: 13px; font-weight: 500;
  cursor: pointer;
}
.swap-side-sub button.right-link {
  background: none;
  border: 0;
  padding: 0;
  font-family: inherit;
}
.max-link-inline span { color: #fff; }
.swap-side-sub .right-link .underline { text-decoration: underline; }

.swap-token-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: #181b20;
  border: 1px solid #353a45;
  border-radius: 999px;
  padding: 6px 12px 6px 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  font-family: inherit;
}
.swap-token-pill .token-icon-sm {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  position: relative;
}
.swap-token-pill .chain-badge {
  position: absolute; bottom: -2px; right: -2px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #4459ff;
  border: 1.5px solid #1c1f23;
}

.swap-divider {
  display: flex; align-items: center; justify-content: center;
  margin: -6px 0;
  position: relative;
  z-index: 1;
}
.swap-flip {
  width: 32px; height: 32px;
  background: #2c3140;
  border: 4px solid #141618;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: #fff;
}
.swap-flip svg { width: 14px; height: 14px; }

.swap-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 4px;
  font-size: 13px;
  color: #9fa6b2;
}
.swap-row .label {
  display: inline-flex; align-items: center; gap: 4px;
}
.swap-row .label .info-i {
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 1px solid #4a4f56;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 8px;
  color: #9fa6b2;
}
.swap-row .value {
  display: inline-flex; align-items: center; gap: 4px;
  color: #fff; font-weight: 500;
}
.swap-row .value .edit-pencil { color: #9fa6b2; cursor: pointer; }
.swap-row .value .chev { color: #9fa6b2; }

.swap-section-divider {
  border: 0; border-top: 1px solid #232730; margin: 4px 0;
}

.bottom-cta {
  margin-top: auto;
  padding: 10px 14px 12px;
  background: #141618;
  border-top: 1px solid #1c1f23;
}
.bottom-cta button {
  width: 100%;
  padding: 12px;
  background: #2c3140;
  color: #6b7080;
  border: 0;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: not-allowed;
  transition: background 0.15s;
}
.bottom-cta button.is-active {
  background: #4459ff;
  color: #fff;
  cursor: pointer;
}
.bottom-cta button.is-active:hover { background: #3849e6; }

/* ===== Basic / Pro sub-toggle ===== */
.swap-subtoggle {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 6px 4px 10px;
  border-bottom: 1px solid #232730;
  margin: 0 0 12px;
}
.subtoggle-btn {
  background: none;
  border: 0;
  color: #6b7080;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  min-width: 62px;
  padding: 4px 0;
  position: relative;
}
.subtoggle-btn.active { color: #fff; }
.subtoggle-btn:focus { outline: none; }
.subtoggle-btn:focus-visible {
  border-radius: 6px;
  box-shadow: 0 0 0 2px #8b95ff;
}
.subtoggle-btn.active::after {
  content: '';
  position: absolute;
  bottom: -11px;
  left: 0; right: 0;
  height: 2px;
  background: #4459ff;
}

/* ===== Pro: order-type pills ===== */
.order-type-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0 0;
}
.ot-pill {
  background: #1c1f23;
  border: 1px solid #2c2f36;
  border-radius: 999px;
  padding: 8px 13px;
  color: #9fa6b2;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.ot-pill.active {
  background: rgba(68, 89, 255, 0.16);
  border-color: rgba(68, 89, 255, 0.5);
  color: #8b95ff;
}

/* ===== Pro flags row ===== */
.pro-flags {
  display: flex; gap: 14px; align-items: center;
  margin-top: 10px;
  font-size: 12px;
  color: #9fa6b2;
}
.pro-flag {
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer;
  user-select: none;
}
.pro-flag input[type="checkbox"] {
  appearance: none;
  width: 14px; height: 14px;
  border: 1px solid #4a4f56;
  border-radius: 3px;
  background: #1c1f23;
  cursor: pointer;
  position: relative;
}
.pro-flag input[type="checkbox"]:checked {
  background: #4459ff;
  border-color: #4459ff;
}
.pro-flag input[type="checkbox"]:checked::after {
  content: '✓';
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  position: absolute;
  top: -2px; left: 1px;
}
.tif-pill {
  background: #2c2f36;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 700;
  color: #9fa6b2;
  letter-spacing: 0.06em;
}

.muted-link { color: #6b7080; font-size: 11px; }

/* TWAP-specific fields */
.twap-row-label {
  font-size: 11px;
  color: #6b7080;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  margin: 10px 0 4px;
}
.twap-pill-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.twap-pill {
  padding: 8px 0;
  background: #1c1f23;
  border: 1px solid #2c2f36;
  border-radius: 8px;
  color: #9fa6b2;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.twap-pill:hover { background: #232730; color: #fff; }
.twap-pill.active {
  background: rgba(68, 89, 255, 0.16);
  border-color: rgba(68, 89, 255, 0.5);
  color: #8b95ff;
}

/* Subtle flash for orderbook rows when they change */
.orderbook-row.ask.flash-up::before,
.orderbook-row.ask.flash-down::before {
  background: #ff5c5c !important;
  opacity: 0.32 !important;
  transition: opacity 0.5s;
}
.orderbook-row.bid.flash-up::before,
.orderbook-row.bid.flash-down::before {
  background: #3df57a !important;
  opacity: 0.32 !important;
  transition: opacity 0.5s;
}

/* ===== Trade / Limit screen ===== */
.limit-rate-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 8px 6px;
  font-size: 12px;
  color: #9fa6b2;
}
.limit-rate-row > span {
  min-width: 0;
  line-height: 1.35;
  white-space: nowrap;
}
.limit-rate-row strong { color: #fff; font-weight: 600; }
.limit-rate-row .mid-pill {
  background: #1c1f23;
  border: 1px solid #2c2f36;
  border-radius: 6px;
  padding: 2px 8px;
  cursor: pointer;
  color: #8b95ff;
  font-weight: 600;
}

.limit-market-select {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  margin-top: 0;
  padding: 10px 12px;
  background: #181b20;
  border: 1px solid #353a45;
  border-radius: 12px;
  color: #fff;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.limit-market-select:hover,
.swap-token-pill:hover {
  background: #20242b;
  border-color: #454b58;
}
.limit-market-select .limit-market-label {
  display: block;
  color: #9fa6b2;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 2px;
}
.limit-market-select strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
}
.limit-market-select svg {
  width: 16px;
  height: 16px;
  color: #9fa6b2;
}
.market-token-pair {
  display: inline-flex;
  align-items: center;
  min-width: 42px;
}
.market-token-pair .token-icon-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #181b20;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.market-token-pair .token-icon-sm + .token-icon-sm {
  margin-left: -12px;
}

.orderbook-wrap {
  margin-top: 12px;
  background: #1c1f23;
  border: 1px solid #232730;
  border-radius: 12px;
  padding: 10px;
}
.orderbook-head {
  display: flex; justify-content: space-between;
  font-size: 10px;
  color: #6b7080;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 8px 8px;
  border-bottom: 1px solid #232730;
}
.orderbook-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(86px, auto);
  gap: 10px;
  align-items: center;
  padding: 5px 8px;
  min-height: 28px;
  font-size: 12.5px;
  line-height: 1.2;
  font-family: 'SF Mono', 'Menlo', monospace;
  cursor: pointer;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}
.orderbook-row::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0; right: 0;
  width: var(--depth, 0%);
  opacity: 0.18;
  pointer-events: none;
}
.orderbook-row.ask { color: #ff5c5c; }
.orderbook-row.ask::before { background: #ff5c5c; }
.orderbook-row.bid { color: #3df57a; }
.orderbook-row.bid::before { background: #3df57a; }
.orderbook-row:hover { background: #232730; }
.orderbook-row .px,
.orderbook-row .qty {
  position: relative;
  z-index: 1;
}
.orderbook-row .px { font-weight: 700; }
.orderbook-row .qty {
  text-align: right;
  color: #b5bbc7;
  font-weight: 500;
  white-space: nowrap;
}
.orderbook-mid {
  display: flex; justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: #232730;
  border-radius: 4px;
  margin: 5px 0;
  font-size: 12px;
  font-family: 'SF Mono', monospace;
  font-weight: 600;
}
.orderbook-mid .mid-label { color: #9fa6b2; font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; }
.orderbook-mid .mid-value { color: #fff; }

.side-toggle {
  display: flex; gap: 4px;
  background: #1c1f23;
  border: 1px solid #2c2f36;
  border-radius: 10px;
  padding: 5px;
  margin-top: 14px;
}
.side-toggle button {
  flex: 1;
  padding: 10px 0;
  border-radius: 8px;
  background: transparent;
  border: 0;
  font-size: 13px; font-weight: 600;
  color: #9fa6b2;
  cursor: pointer;
}
.side-toggle button.active.buy { background: rgba(61, 245, 122, 0.16); color: #3df57a; }
.side-toggle button.active.sell { background: rgba(255, 92, 92, 0.16); color: #ff5c5c; }

.limit-field {
  margin-top: 14px;
}
.limit-field-label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px; color: #9fa6b2;
  margin-bottom: 6px;
}
.limit-field-label .max-link {
  color: #8b95ff; font-weight: 600; cursor: pointer; font-size: 12px;
}
.limit-input-wrap {
  display: flex; align-items: center; gap: 8px;
  background: #1c1f23;
  border: 1px solid #2c2f36;
  border-radius: 12px;
  padding: 10px 14px;
}
.limit-input-wrap input {
  flex: 1;
  background: transparent; border: 0; outline: none;
  color: #fff; font-size: 18px;
  font-family: 'SF Mono', monospace;
}
.limit-input-wrap input::placeholder { color: #4a4f56; }
.limit-input-wrap .unit {
  color: #9fa6b2; font-size: 13px; font-weight: 600;
}

.limit-pct-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  margin-top: 6px;
}
.limit-pct-row button {
  padding: 6px 0;
  background: #1c1f23;
  border: 1px solid #2c2f36;
  border-radius: 8px;
  color: #9fa6b2;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.limit-pct-row button:hover { background: #232730; color: #fff; }

.limit-summary {
  margin-top: 12px;
  background: #1c1f23;
  border: 1px solid #232730;
  border-radius: 12px;
  padding: 7px 12px 10px;
}
.summary-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b7080;
  padding: 10px 0 2px;
}
.summary-section-label:first-child { padding-top: 4px; }
.limit-summary-row {
  display: flex; justify-content: space-between;
  padding: 3px 0;
  font-size: 12px;
}
.limit-summary-row .lbl { color: #9fa6b2; }
.limit-summary-row .val { color: #fff; font-weight: 500; font-family: 'SF Mono', monospace; }
.limit-summary-row.execution-fill .val { color: #3df57a; }
.limit-summary-row.execution-rest .val { color: #8b95ff; }
.limit-summary-row.empty { display: none; }
.limit-summary-row .val .sub { color: #6b7080; font-size: 10px; font-family: -apple-system, sans-serif; margin-left: 4px; }

/* ===== MetaMask sign modal ===== */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}
.modal-backdrop.active { display: flex; }
.modal-sheet {
  width: 100%;
  background: #1c1f23;
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  padding: 16px 16px 18px;
  max-height: 90%;
  overflow-y: auto;
}
.modal-handle {
  width: 40px; height: 4px;
  background: #2c2f36;
  border-radius: 2px;
  margin: 0 auto 12px;
}
.modal-title {
  font-size: 16px; font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
}
.modal-sub {
  text-align: center;
  font-size: 12px;
  color: #9fa6b2;
  margin-bottom: 14px;
}
.modal-account {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: #232730;
  border-radius: 10px;
  margin-bottom: 12px;
}
.modal-account .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #f6851b, #ff9742);
}
.modal-account .acct-info { flex: 1; }
.modal-account .acct-name { font-size: 13px; font-weight: 600; }
.modal-account .acct-addr { font-size: 11px; color: #9fa6b2; }
.modal-account .balance { font-size: 13px; font-family: 'SF Mono', monospace; color: #fff; }

.signing-payload {
  background: #141618;
  border: 1px solid #2c2f36;
  border-radius: 10px;
  padding: 10px 12px;
  font-family: 'SF Mono', monospace;
  font-size: 11px;
  color: #9fa6b2;
  line-height: 1.5;
  margin-bottom: 14px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 220px;
  overflow-y: auto;
}
.signing-payload .k { color: #8b95ff; }
.signing-payload .s { color: #3df57a; }
.signing-payload .n { color: #ff9742; }

.modal-meta-row {
  display: flex; justify-content: space-between;
  padding: 6px 0;
  font-size: 12px;
  color: #9fa6b2;
}
.modal-meta-row .v { color: #fff; font-weight: 500; }
.modal-divider { border: 0; border-top: 1px solid #232730; margin: 10px 0; }

.token-modal-backdrop {
  position: absolute;
  inset: 0;
  display: none;
  align-items: stretch;
  justify-content: center;
  z-index: 130;
  background: rgba(0, 0, 0, 0.42);
}
.token-modal-backdrop.active { display: flex; }
.token-modal-sheet {
  width: calc(100% - 28px);
  margin: 16px 14px;
  padding: 22px 18px;
  overflow-y: auto;
  border-radius: 18px;
  background: #141618;
  color: #fff;
  border: 1px solid #2c2f36;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
}
.token-modal-head {
  display: grid;
  grid-template-columns: 28px 1fr 28px;
  align-items: center;
  font-size: 20px;
  font-weight: 750;
  text-align: center;
  margin: 4px 0 24px;
}
.token-modal-head button {
  border: 0;
  background: none;
  color: #9fa6b2;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
}
.network-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  border: 1px solid #2c2f36;
  border-radius: 18px;
  background: #1c1f23;
  color: #fff;
  font: 500 19px inherit;
}
.token-search {
  height: 58px;
  margin: 24px 0 22px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1.5px solid #2c2f36;
  border-radius: 15px;
  background: #1c1f23;
}
.token-search svg {
  width: 22px;
  height: 22px;
  color: #9fa6b2;
}
.token-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #9fa6b2;
  font-size: 17px;
}
.token-select-list {
  display: flex;
  flex-direction: column;
  margin: 0 -18px;
}
.token-select-row {
  width: 100%;
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: 14px;
  min-height: 78px;
  padding: 10px 18px;
  border: 0;
  background: transparent;
  color: #fff;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.token-select-row.selected {
  background: rgba(68, 89, 255, 0.16);
  box-shadow: inset 4px 0 0 #5162ff;
}
.token-select-row:hover {
  background: #1c1f23;
}
.token-select-row.selected:hover {
  background: rgba(68, 89, 255, 0.16);
}
.token-select-row .token-icon {
  width: 38px;
  height: 38px;
}
.token-select-row.market-select-row {
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 12px;
  min-height: 66px;
  padding-top: 8px;
  padding-bottom: 8px;
}
.token-select-row.market-select-row .market-token-pair {
  min-width: 48px;
}
.token-select-row.market-select-row .token-icon-sm {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-color: #141618;
  border-radius: 50%;
  overflow: hidden;
  background: #1c1f23;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.04) inset;
}
.token-select-row.market-select-row .token-icon-sm img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.token-select-row.market-select-row:hover .token-icon-sm,
.token-select-row.market-select-row.selected .token-icon-sm {
  border-color: #1c1f23;
}
.token-select-row.market-select-row .token-select-symbol {
  font-size: 16px;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
}
.token-select-row.market-select-row .token-select-name {
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
}
.market-select-price {
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 4px;
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  font-family: 'SF Mono', monospace;
  white-space: nowrap;
}
.market-select-price span:last-child {
  color: #9fa6b2;
  font-size: 11px;
  font-family: inherit;
  font-weight: 600;
}
.token-select-main,
.token-select-balance {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.token-select-symbol {
  font-size: 18px;
  font-weight: 700;
}
.token-select-name,
.token-select-balance span:last-child {
  color: #9fa6b2;
  font-size: 15px;
}
.token-select-balance {
  align-items: flex-end;
  font-size: 17px;
  font-weight: 650;
}

.modal-buttons {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-top: 12px;
}
.modal-buttons button {
  padding: 12px;
  border-radius: 999px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  border: 0;
}
.modal-buttons .secondary {
  background: #2c3140;
  color: #fff;
}
.modal-buttons .primary {
  background: #4459ff;
  color: #fff;
}
.modal-buttons .primary:hover { background: #3849e6; }

/* ===== Toast ===== */
.toast {
  position: absolute;
  bottom: 88px;                        /* sits cleanly above the CTA */
  left: 14px;
  right: 14px;
  margin: 0 auto;
  width: max-content;
  max-width: calc(100% - 28px);
  background: #1c1f23;
  border: 1px solid #2c2f36;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.45;
  text-align: center;
  z-index: 200;
  display: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}
.toast.active {
  display: block;
  animation: toast-rise 0.18s ease-out;
}
@keyframes toast-rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.toast.success { border-color: rgba(61, 245, 122, 0.45); }
.toast.success::before {
  content: '✓';
  color: #3df57a;
  font-weight: 700;
  margin-right: 6px;
}

/* ===== Activity / Orders tab ===== */
.activity-card {
  background: #1c1f23;
  border: 1px solid #232730;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.activity-card-head {
  display: flex; justify-content: space-between;
  margin-bottom: 6px;
}
.activity-card-title { font-size: 13px; font-weight: 600; color: #fff; }
.activity-card-state {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 700;
}
.activity-card-state.open { background: rgba(139, 149, 255, 0.16); color: #8b95ff; }
.activity-card-state.pending { background: rgba(255, 215, 77, 0.16); color: #ffd74d; }
.activity-card-state.filled { background: rgba(61, 245, 122, 0.16); color: #3df57a; }
.activity-card-state.cancelled { background: rgba(255, 92, 92, 0.16); color: #ff5c5c; }
.activity-step-card {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 12px;
  align-items: start;
}
.activity-step-card .activity-card-head {
  margin-bottom: 2px;
}
.activity-step-icon .token-icon {
  width: 36px;
  height: 36px;
}
.activity-step-main {
  min-width: 0;
}
.activity-step-sub {
  color: #9fa6b2;
  font-size: 12px;
}
.activity-progress {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0 10px;
}
.activity-progress span {
  height: 5px;
  border-radius: 999px;
  background: #2c2f36;
}
.activity-progress span.active {
  background: #4459ff;
}
.activity-step-body {
  padding-top: 2px;
}
.activity-card-body {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px;
  font-size: 12px;
}
.activity-card-body .lbl { color: #9fa6b2; }
.activity-card-body .val { color: #fff; font-family: 'SF Mono', monospace; text-align: right; }
.activity-card-actions {
  display: flex; gap: 8px;
  margin-top: 10px;
}
.activity-card-actions button {
  flex: 1;
  padding: 7px 0;
  background: transparent;
  border: 1px solid #2c2f36;
  border-radius: 8px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.activity-card-actions button.danger {
  color: #ff5c5c; border-color: rgba(255, 92, 92, 0.3);
}

.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: #6b7080;
  font-size: 13px;
}
.empty-state .empty-icon {
  font-size: 32px;
  margin-bottom: 10px;
  opacity: 0.4;
}

/* Hidden helper */
.hidden { display: none !important; }
