.trade-tabs {
  display: flex;
  gap: 6px;
  width: fit-content;
  margin-bottom: 24px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0c0f1c;
}

.spot-mode-switch {
  display: flex;
  gap: 8px;
  margin: 16px 0;
  padding: 5px;
  width: fit-content;
  max-width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.spot-mode-button {
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.18s ease;
}
.spot-mode-button:hover { color: #fff; }
.spot-mode-button.active, .spot-mode-button[aria-pressed="true"] {
  border-color: rgba(122,231,193,0.25);
  background: rgba(122,231,193,0.1);
  color: #7ae7c1;
}
.cross-chain-spot-panel {
  padding: 20px;
  margin: 16px 0 24px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255,255,255,0.025);
}
.cross-chain-panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.cross-chain-panel-heading h2 { margin: 6px 0; font-size: 20px; }
.cross-chain-panel-heading p, .cross-chain-disclaimer {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}
.cross-chain-btc-badge {
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 1px solid rgba(247,147,26,0.28);
  border-radius: 999px;
  background: rgba(247,147,26,0.08);
  color: #f7931a;
  font-size: 12px;
  font-weight: 700;
}
.cross-chain-widget-shell {
  width: min(100%, 760px);
  min-height: 660px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #11151b;
}
.cross-chain-widget-shell swapkit-widget {
  display: block;
  width: 100%;
  min-height: 660px;
}
.cross-chain-setup {
  display: flex;
  min-height: 520px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px;
  text-align: center;
}
.cross-chain-setup-icon { color: #f7931a; font-size: 44px; }
.cross-chain-setup h3 { margin: 0; font-size: 18px; }
.cross-chain-setup p, .cross-chain-setup small { max-width: 580px; color: var(--muted); font-size: 12px; line-height: 1.8; }
.cross-chain-setup a { color: #7ae7c1; font-size: 13px; }
.cross-chain-setup code { direction: ltr; color: #a5b4fc; }
.cross-chain-disclaimer { margin: 12px auto 0; text-align: center; }

.solana-spot-card {
  width: min(100%, 620px);
  margin: 0 auto;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(10, 14, 23, 0.72);
}
.solana-spot-card > label, .solana-spot-trade-row label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}
.solana-spot-wallet-row, .solana-spot-trade-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}
.solana-spot-wallet-row select, .solana-spot-trade-row select,
.solana-spot-trade-row input {
  width: 100%;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface, #11151b);
  color: var(--text, #f4f7fb);
  font: inherit;
}
.solana-spot-status, .solana-spot-quote {
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}
.solana-spot-quote {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,0.035);
}
.solana-spot-status.error, .solana-spot-quote.error { color: #ff9b9b; }

.trade-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}

.trade-tab span {
  color: inherit;
  font-size: 10px;
  font-weight: 400;
  opacity: 0.75;
}

.trade-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.trade-tab.active {
  color: #fff;
  background: linear-gradient(120deg, #7869ed, #998aff);
  box-shadow: 0 4px 15px rgba(120, 105, 237, 0.25);
}

#swap-section > .manage-header {
  align-items: flex-start;
  margin-bottom: 16px;
}

#swap-section .kp-dex-badge {
  white-space: normal;
  line-height: 1.7;
}

#swap-section .spot-mode-switch {
  margin: 0 0 18px;
}

#swap-section .swap-container {
  display: grid;
  grid-template-columns: minmax(340px, 0.78fr) minmax(0, 1.22fr);
  grid-template-areas:
    "vip vip"
    "market market"
    "card chart"
    "history history"
    "security security";
  align-items: start;
  gap: 16px;
  width: 100%;
  max-width: none;
  margin: 0;
}

#swap-section .king-vip-incentive-banner { grid-area: vip; }
#swap-section .swap-market-strip { grid-area: market; margin: 0; }
#swap-section .swap-card { grid-area: card; min-width: 0; }
#swap-section .native-chart-panel {
  grid-area: chart;
  width: 100%;
  min-width: 0;
  margin: 0;
}
#swap-section .swap-history-panel { grid-area: history; margin: 0; }
#swap-section .swap-security-panel { grid-area: security; }
#swap-section .swap-settings-panel {
  width: 100%;
  max-width: 760px;
  margin-inline: auto;
}

.perps-intro {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.perps-status-badge,
.perps-disabled-label,
.perps-market-placeholder {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(238, 193, 110, 0.24);
  border-radius: 999px;
  background: rgba(238, 193, 110, 0.08);
  color: #efc778;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.perps-status-badge {
  padding: 8px 13px;
}

.perps-notice {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin: 22px 0;
  padding: 17px 19px;
  border: 1px solid rgba(238, 193, 110, 0.22);
  border-radius: 14px;
  background: linear-gradient(110deg, rgba(238, 193, 110, 0.08), rgba(120, 105, 237, 0.06));
}

.perps-notice-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border-radius: 11px;
  background: rgba(238, 193, 110, 0.12);
  color: #efc778;
  font-size: 18px;
}

.perps-notice strong,
.perps-notice p {
  display: block;
  margin: 0;
}

.perps-notice strong {
  font-size: 12px;
}

.perps-notice p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.8;
}

.perps-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.8fr);
  gap: 16px;
}

.perps-market-panel,
.perps-order-panel {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(12, 16, 32, 0.72);
}

.perps-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line);
}

.perps-panel-heading .eyebrow {
  display: block;
  margin-bottom: 5px;
}

.perps-panel-heading h3 {
  margin: 0;
  font-size: 15px;
}

.perps-market-placeholder {
  padding: 6px 9px;
  font-size: 9px;
}

.perps-empty-state {
  display: grid;
  min-height: 210px;
  place-content: center;
  justify-items: center;
  padding: 24px;
  text-align: center;
}

.perps-empty-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  margin-bottom: 13px;
  border: 1px solid rgba(146, 132, 255, 0.2);
  border-radius: 15px;
  background: rgba(146, 132, 255, 0.08);
  color: #a69bff;
  font-size: 27px;
}

.perps-empty-state strong {
  font-size: 12px;
}

.perps-empty-state p {
  max-width: 360px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.8;
}

.perps-market-footer {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 9px;
  text-align: center;
}

.perps-market-footer b {
  color: #a4abc0;
  font: 12px 'DM Mono', monospace;
}

.perps-disabled-label {
  padding: 5px 8px;
  border-color: var(--line);
  background: #171c2c;
  color: #929ab1;
}

.perps-order-preview {
  display: grid;
  gap: 14px;
  padding-top: 15px;
  opacity: 0.62;
}

.perps-order-type {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #090d19;
}

.perps-order-type span {
  padding: 9px 6px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.perps-order-type .selected {
  background: #20253a;
  color: #d5d8e6;
}

.perps-order-preview label {
  color: #aab1c4;
  font-size: 10px;
}

.perps-order-preview input,
.perps-order-preview select {
  margin-top: 6px;
  padding: 10px;
  color: #929ab1;
  font-size: 11px;
}

.perps-submit {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #242a40;
  color: #aab1c4;
  font-size: 11px;
  font-weight: 700;
  cursor: not-allowed;
}

.perps-risk-note {
  margin: 14px 0 0;
  color: #929ab1;
  font-size: 9px;
  line-height: 1.8;
}

.perps-bottom-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.perps-bottom-note a {
  color: #b6adff;
  font-weight: 700;
  text-decoration: none;
}

.perps-bottom-note a:hover {
  color: #fff;
}

@media (max-width: 900px) {
  #swap-section .swap-container {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "vip"
      "market"
      "card"
      "chart"
      "history"
      "security";
  }
}

@media (max-width: 768px) {
  #swap-section .swap-container {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "vip"
      "market"
      "card"
      "chart"
      "history"
      "security";
    gap: 12px;
  }

  #swap-section > .manage-header {
    align-items: stretch;
  }

  #swap-section #spot-local-header-tools {
    width: 100%;
  }

  #swap-section #spot-local-header-tools .btn {
    min-height: 42px;
  }

  .perps-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  #swap-section {
    padding: 14px;
  }

  #swap-section .trade-tabs {
    width: 100%;
    margin-bottom: 16px;
  }

  #swap-section .trade-tab {
    flex: 1;
    justify-content: center;
  }

  #swap-section .spot-mode-switch {
    width: 100%;
  }

  #swap-section .spot-mode-button {
    flex: 1;
    padding-inline: 8px;
    line-height: 1.5;
  }

  #swap-section .swap-card {
    padding: 14px;
    border-radius: 18px;
  }

  #swap-section .swap-box {
    padding: 13px 12px;
    border-radius: 14px;
  }

  #swap-section .swap-box-header {
    align-items: flex-start;
    gap: 8px;
  }

  #swap-section .swap-balance-info {
    flex-wrap: wrap;
    justify-content: flex-end;
    font-size: 10px;
  }

  #swap-section .swap-box-body {
    gap: 8px;
  }

  #swap-section .swap-amount-input {
    min-width: 0;
    font-size: 22px !important;
  }

  #swap-section .token-select-pill {
    gap: 5px;
    padding: 6px 9px;
    font-size: 12px;
  }

  #swap-section .swap-details-drawer {
    padding: 12px;
  }

  #swap-section .swap-detail-row {
    align-items: flex-start;
    gap: 12px;
  }

  #swap-section .detail-value {
    text-align: left;
    overflow-wrap: anywhere;
  }

  #swap-section .btn-swap-execute {
    min-height: 48px;
    font-size: 13px;
  }

  .trade-tabs {
    width: 100%;
  }
  .spot-mode-switch { width: 100%; }
  .spot-mode-button { flex: 1; padding: 10px 8px; }
  .cross-chain-spot-panel { padding: 14px; }
  .cross-chain-panel-heading { flex-direction: column; }
  .cross-chain-btc-badge { align-self: flex-start; }
  .cross-chain-widget-shell, .cross-chain-widget-shell swapkit-widget { min-height: 640px; }

  .trade-tab {
    flex: 1;
    justify-content: center;
    padding: 9px 8px;
  }

  #perps-section {
    padding: 18px;
  }

  #perps-section .manage-header {
    flex-direction: row;
    align-items: center;
  }

  .perps-market-panel,
  .perps-order-panel {
    padding: 15px;
  }

  .perps-notice {
    padding: 14px;
  }

  .perps-market-placeholder {
    font-size: 8px;
  }
}

.perps-header-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.perps-status-badge.healthy {
  border-color: rgba(103, 226, 183, 0.25);
  background: rgba(103, 226, 183, 0.08);
  color: #67e2b7;
}

.perps-status-badge.unavailable {
  border-color: rgba(255, 115, 138, 0.25);
  background: rgba(255, 115, 138, 0.08);
  color: #ff8598;
}

.perps-network-bar {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 16px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #0c1020;
  color: var(--muted);
  font-size: 10px;
}

.perps-network-bar > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #dfe2ee;
}

.perps-network-bar > span:nth-child(2) {
  margin-right: auto;
}

.perps-network-bar label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  white-space: nowrap;
}

.perps-network-bar select {
  max-width: 150px;
  padding: 8px 10px;
  font-size: 10px;
}

.perps-network-bar select:disabled {
  opacity: 0.65;
}

.perps-network-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #efc778;
  box-shadow: 0 0 10px rgba(239, 199, 120, 0.3);
}

.perps-network-dot.connected {
  background: #67e2b7;
  box-shadow: 0 0 10px rgba(103, 226, 183, 0.4);
}

.perps-message {
  margin-bottom: 15px;
  padding: 11px 14px;
  border: 1px solid #1a415e;
  border-radius: 10px;
  background: #0d1e2e;
  color: #62ddea;
  font-size: 11px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.perps-message.error {
  border-color: #571e28;
  background: #2b1117;
  color: #ff8598;
}

.perps-message.success {
  border-color: #1c5242;
  background: #11352b;
  color: #67e2b7;
}

.perps-market-strip {
  display: grid;
  grid-template-columns: minmax(240px, 1.7fr) repeat(3, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(12, 16, 32, 0.82);
}

.perps-market-strip label,
.perps-market-stat {
  min-width: 0;
  color: var(--muted);
  font-size: 10px;
}

.perps-market-strip select {
  margin-top: 6px;
  padding: 10px;
  font-size: 11px;
}

.perps-market-stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 9px;
  padding: 4px 10px;
  border-right: 1px solid var(--line);
}

.perps-market-stat b {
  color: #f4f5fb;
  font: 12px 'DM Mono', monospace;
  white-space: nowrap;
}

.perps-market-stat #perps-price-change {
  color: #67e2b7;
}

.perps-trade-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.4fr);
  gap: 16px;
}

.perps-order-panel,
.perps-market-panel,
.perps-positions-panel {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(12, 16, 32, 0.72);
}

.perps-collateral-label {
  color: #a69bff;
  font-size: 10px;
}

.perps-direction-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin: 16px 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #090d19;
}

.perps-direction-toggle button {
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.perps-direction-toggle button.active:first-child {
  border-color: rgba(103, 226, 183, 0.2);
  background: rgba(103, 226, 183, 0.12);
  color: #67e2b7;
}

.perps-direction-toggle button.active:last-child {
  border-color: rgba(255, 115, 138, 0.2);
  background: rgba(255, 115, 138, 0.12);
  color: #ff8598;
}

.perps-input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.perps-input-grid label {
  color: #c4cada;
  font-size: 10px;
}

.perps-input-with-unit {
  position: relative;
}

.perps-input-with-unit input {
  padding-left: 62px;
  font: 13px 'DM Mono', monospace;
}

.perps-input-with-unit > span {
  position: absolute;
  top: 20px;
  left: 12px;
  color: #a69bff;
  font: 10px 'DM Mono', monospace;
}

.perps-input-grid small {
  display: block;
  margin-top: 6px;
  line-height: 1.7;
}

.perps-size-estimate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 17px 0 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #090d19;
  color: var(--muted);
  font-size: 10px;
}

.perps-size-estimate b {
  color: #f4f5fb;
  font-size: 12px;
}

.perps-approve-button,
.perps-review-cancel {
  width: 100%;
  margin-top: 8px;
}

.perps-approve-button.approved {
  border-color: rgba(103, 226, 183, 0.25);
  background: rgba(103, 226, 183, 0.08);
  color: #67e2b7;
  cursor: default;
}

.perps-approval-note {
  display: block;
  margin-top: 7px;
  line-height: 1.7;
}

.perps-submit {
  width: 100%;
  margin-top: 12px;
}

.perps-submit:not(:disabled) {
  background: linear-gradient(135deg, #7869ed, #a496ff);
  color: #fff;
  cursor: pointer;
}

.perps-submit:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.perps-risk-note,
.perps-market-disclaimer {
  margin: 12px 0 0;
  color: #929ab1;
  font-size: 9px;
  line-height: 1.8;
}

.perps-market-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 18px 0;
}

.perps-market-details > div {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  border: 1px solid #252c45;
  border-radius: 10px;
  background: #090d19;
}

.perps-market-details span {
  color: var(--muted);
  font-size: 9px;
}

.perps-market-details b {
  color: #e8eaf3;
  font-size: 11px;
  white-space: nowrap;
}

.perps-positions-panel {
  margin-top: 16px;
}

.perps-positions-list {
  display: grid;
  gap: 9px;
  padding-top: 12px;
}

.perps-position-row {
  display: grid;
  grid-template-columns: minmax(130px, 1.3fr) repeat(3, minmax(115px, 1fr)) auto;
  align-items: center;
  gap: 13px;
  padding: 13px;
  border: 1px solid #252c45;
  border-radius: 11px;
  background: #090d19;
}

.perps-position-identity {
  display: grid;
  gap: 7px;
}

.perps-position-identity strong {
  font: 11px 'DM Mono', monospace;
  overflow-wrap: anywhere;
}

.perps-side {
  font-size: 9px;
}

.perps-side.long,
.positive {
  color: #67e2b7;
}

.perps-side.short,
.negative {
  color: #ff8598;
}

.perps-position-stat {
  display: grid;
  gap: 7px;
}

.perps-position-stat span {
  color: var(--muted);
  font-size: 9px;
}

.perps-position-stat b {
  font-size: 10px;
}

.perps-close-button {
  padding: 9px 12px;
  color: #ff9baa;
  white-space: nowrap;
}

.perps-review-content {
  width: min(520px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
}

.perps-review-content .modal-header h3 {
  margin: 0;
  font-size: 16px;
}

.perps-review-summary {
  display: grid;
  gap: 10px;
  margin-top: 17px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0c1020;
}

.perps-review-summary > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #212940;
  padding-bottom: 8px;
  font-size: 10px;
}

.perps-review-summary > div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.perps-review-summary span {
  color: var(--muted);
}

.perps-review-summary b {
  color: #f4f5fb;
  text-align: left;
  overflow-wrap: anywhere;
}

.perps-review-warning {
  margin: 12px 0;
  color: #efc778;
  font-size: 10px;
  line-height: 1.8;
}

.perps-review-cancel {
  margin-top: 8px;
}

@media (max-width: 900px) {
  .perps-market-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .perps-market-strip label {
    grid-column: 1 / -1;
  }

  .perps-trade-grid {
    grid-template-columns: 1fr;
  }

  .perps-position-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .perps-position-identity {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  .perps-header-actions {
    width: 100%;
    justify-content: space-between;
  }

  #perps-section .manage-header {
    align-items: flex-start;
  }

  .perps-network-bar {
    flex-wrap: wrap;
  }

  .perps-network-bar > span:nth-child(2) {
    width: 100%;
    margin-right: 14px;
    order: 3;
  }

  .perps-network-bar .btn {
    margin-right: auto;
    padding: 8px 10px;
    font-size: 9px;
  }

  .perps-market-strip {
    grid-template-columns: 1fr 1fr;
  }

  .perps-market-strip label {
    grid-column: 1 / -1;
  }

  .perps-market-stat {
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 10px;
  }

  .perps-input-grid {
    grid-template-columns: 1fr;
  }

  .perps-position-row {
    gap: 10px;
  }

  .perps-position-stat b {
    font-size: 9px;
  }
}
