:root {
  /* ALFATREX brand palette */
  --bg: #070b1f;
  --bg-mid: #0c1230;
  --bg-card: #12183a;
  --bg-input: #1a2150;
  --border: #2a3366;
  --border-glow: rgba(233, 30, 140, 0.35);
  --text: #f0f2ff;
  --text-muted: #8b95c7;
  --primary: #e91e8c;
  --primary-hover: #ff3da5;
  --primary-soft: rgba(233, 30, 140, 0.15);
  --magenta: #ff2d92;
  --purple: #9b5cf6;
  --purple-soft: rgba(155, 92, 246, 0.2);
  --cyan: #22d3ee;
  --cyan-soft: rgba(34, 211, 238, 0.15);
  --green: #0ecb81;
  --red: #f6465d;
  --blue: #4f6ef7;
  --gradient-btn: linear-gradient(135deg, #4f6ef7 0%, #e91e8c 100%);
  --gradient-btn-hover: linear-gradient(135deg, #6b85ff 0%, #ff3da5 100%);
  --gradient-logo: linear-gradient(135deg, #22d3ee, #9b5cf6, #e91e8c, #f0b90b);
  --radius: 16px;
  --shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
  --glow-magenta: 0 0 24px rgba(233, 30, 140, 0.25);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 20% 10%, rgba(79, 110, 247, 0.18) 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 85% 20%, rgba(233, 30, 140, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse 50% 60% at 50% 100%, rgba(155, 92, 246, 0.1) 0%, transparent 55%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a {
  color: var(--magenta);
  text-decoration: none;
}

a:hover {
  color: var(--primary-hover);
}

/* Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: rgba(12, 18, 48, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: var(--gradient-logo);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  font-size: 0.75rem;
  box-shadow: 0 0 16px rgba(155, 92, 246, 0.4);
  letter-spacing: -0.5px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.network-badge {
  background: var(--cyan-soft);
  color: var(--cyan);
  border: 1px solid rgba(34, 211, 238, 0.35);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--gradient-btn);
  color: #fff;
  box-shadow: var(--glow-magenta);
}

.btn-primary:hover:not(:disabled) {
  background: var(--gradient-btn-hover);
  box-shadow: 0 0 28px rgba(233, 30, 140, 0.4);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--magenta);
  background: var(--primary-soft);
}

.btn-connect {
  background: var(--gradient-btn);
  color: #fff;
  font-weight: 700;
  box-shadow: var(--glow-magenta);
}

.btn-connect:hover {
  background: var(--gradient-btn-hover);
}

.btn-full {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
}

/* Main layout */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

.page-title {
  text-align: center;
  margin-bottom: 24px;
}

.page-title h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 6px;
  background: linear-gradient(90deg, #fff 0%, #e91e8c 50%, #9b5cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-title p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Swap Card */
.swap-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow), var(--glow-magenta);
  position: relative;
  overflow: hidden;
}

.swap-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--magenta), var(--purple), var(--cyan), transparent);
  opacity: 0.8;
}

.swap-tabs {
  display: flex;
  background: var(--bg-input);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.tab-btn.buy.active {
  color: var(--green);
  border: 1px solid rgba(14, 203, 129, 0.3);
}

.tab-btn.sell.active {
  color: var(--red);
  border: 1px solid rgba(246, 70, 93, 0.3);
}

/* Token input box */
.token-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.token-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.token-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.token-box-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.token-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 600;
  width: 100%;
  min-width: 0;
}

.token-input::placeholder {
  color: #3d4a7a;
}

.token-select {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
}

.token-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 800;
}

.token-icon.aft {
  background: var(--gradient-logo);
  color: #fff;
}

.token-icon.usdt {
  background: #26a17b;
  color: #fff;
}

.max-btn {
  background: var(--primary-soft);
  color: var(--magenta);
  border: 1px solid rgba(233, 30, 140, 0.35);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.max-btn:hover {
  background: rgba(233, 30, 140, 0.3);
}

.swap-arrow {
  display: flex;
  justify-content: center;
  margin: -4px 0;
  position: relative;
  z-index: 2;
}

.swap-arrow-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 3px solid var(--bg);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.2s;
}

.swap-arrow-btn:hover {
  color: var(--magenta);
  border-color: var(--primary);
  box-shadow: var(--glow-magenta);
}

/* Info row */
.swap-info {
  margin-top: 16px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.85rem;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  color: var(--text-muted);
}

.info-row span:last-child {
  color: var(--text);
  font-weight: 500;
}

.info-row .highlight {
  color: var(--magenta);
  font-weight: 600;
}

/* Status & alerts */
.status-bar {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  display: none;
}

.status-bar.show {
  display: block;
}

.status-bar.info {
  background: rgba(79, 110, 247, 0.15);
  border: 1px solid rgba(79, 110, 247, 0.35);
  color: #a5b4fc;
}

.status-bar.success {
  background: rgba(14, 203, 129, 0.15);
  border: 1px solid rgba(14, 203, 129, 0.35);
  color: var(--green);
}

.status-bar.error {
  background: rgba(246, 70, 93, 0.15);
  border: 1px solid rgba(246, 70, 93, 0.35);
  color: var(--red);
}

.status-bar.warning {
  background: var(--primary-soft);
  border: 1px solid rgba(233, 30, 140, 0.35);
  color: var(--magenta);
}

/* Limits card */
.limits-card {
  margin-top: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.limits-card h3 {
  font-size: 0.95rem;
  margin-bottom: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.limit-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 0.9rem;
}

.limit-bar {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  margin-top: 6px;
  overflow: hidden;
}

.limit-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

.limit-bar-fill.buy {
  background: linear-gradient(90deg, var(--green), var(--cyan));
}

.limit-bar-fill.sell {
  background: linear-gradient(90deg, var(--red), var(--magenta));
}

/* Wallet info */
.wallet-info {
  display: none;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 6px 12px 6px 6px;
  border-radius: 24px;
  font-size: 0.85rem;
}

.wallet-info.show {
  display: flex;
}

.wallet-dot {
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  margin-left: 6px;
  box-shadow: 0 0 8px var(--green);
}

/* Footer */
.footer {
  text-align: center;
  margin-top: 40px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.footer a {
  color: var(--text-muted);
}

.footer a:hover {
  color: var(--magenta);
}

/* Loading spinner */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 520px) {
  .navbar {
    padding: 12px 16px;
  }
  .container {
    padding: 24px 12px 48px;
  }
  .token-input {
    font-size: 1.25rem;
  }
  .page-title h1 {
    font-size: 1.45rem;
  }
}
