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

:root {
  --bg: #0a0a0f; --bg2: #111118; --bg3: #1a1a24; --bg4: #22222e;
  --border: rgba(255,255,255,0.08); --border2: rgba(255,255,255,0.15);
  --accent: #7c6dfa; --accent2: #a78bfa;
  --green: #22d37a; --red: #ff5c5c; --amber: #f59e0b;
  --text: #f0eeff; --muted: #8b8aaa;
  --mono: 'DM Mono', monospace; --sans: 'Syne', sans-serif;
  --radius: 16px; --radius-sm: 10px;
}

body {
  font-family: var(--sans);
  background: var(--bg); color: var(--text);
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 32px 16px;
}

body.modal-open { overflow: hidden; }

body::before {
  content: ''; position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(124,109,250,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124,109,250,0.03) 1px, transparent 1px);
  background-size: 40px 40px; pointer-events: none;
}

/* ── WRAPPER ── */
.wrapper {
  width: 100%; max-width: 460px;
  display: flex; flex-direction: column;
  align-items: center; gap: 14px;
  position: relative; z-index: 1;
}

/* ── MY TOKENS BUTTON ── */
.mytokens-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, rgba(124,109,250,0.15), rgba(167,139,250,0.08));
  border: 1px solid rgba(124,109,250,0.35);
  border-radius: var(--radius); padding: 14px 20px;
  cursor: pointer; transition: all 0.25s;
  position: relative; overflow: hidden;
}
.mytokens-btn::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(124,109,250,0.1), transparent);
  opacity: 0; transition: opacity 0.25s;
}
.mytokens-btn:hover { border-color: rgba(124,109,250,0.6); transform: translateY(-1px); box-shadow: 0 8px 24px rgba(124,109,250,0.15); }
.mytokens-btn:hover::before { opacity: 1; }
.mytokens-btn-left { display: flex; align-items: center; gap: 12px; }
.mytokens-btn-icon { width: 36px; height: 36px; border-radius: 10px; background: rgba(124,109,250,0.2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mytokens-btn-icon svg { width: 18px; height: 18px; stroke: var(--accent2); }
.mytokens-btn-title { font-size: 15px; font-weight: 700; color: var(--text); text-align: left; }
.mytokens-btn-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.mytokens-btn-arrow { color: var(--accent2); opacity: 0.7; }
.mytokens-btn-arrow svg { width: 18px; height: 18px; }

/* ── PAYMENT CARD ── */
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); width: 100%;
  overflow: hidden; position: relative;
}
.card::before {
  content: ''; position: absolute; top: -1px; left: 50%;
  transform: translateX(-50%);
  width: 200px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.card-header { padding: 22px 24px 0; display: flex; align-items: center; gap: 10px; }
.back-btn { background: none; border: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; display: flex; align-items: center; transition: all 0.2s; flex-shrink: 0; }
.back-btn:hover { color: var(--text); background: var(--bg3); }
.back-btn svg { width: 20px; height: 20px; }
.card-title { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
.card-body { padding: 18px 24px 24px; }

/* Steps */
.steps { display: flex; align-items: center; margin-bottom: 20px; }
.step-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border2); transition: all 0.3s; flex-shrink: 0; }
.step-dot.active { background: var(--accent); width: 24px; border-radius: 4px; }
.step-dot.done   { background: var(--green); }
.step-line { flex: 1; height: 1px; background: var(--border); }

/* Price badge */
.price-badge { display: flex; align-items: center; gap: 10px; background: rgba(124,109,250,0.08); border: 1px solid rgba(124,109,250,0.2); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 18px; width: 100%; }
.price-badge-icon { width: 36px; height: 36px; border-radius: 8px; background: rgba(124,109,250,0.15); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.price-badge-icon svg { width: 18px; height: 18px; color: var(--accent2); }
.price-badge-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.price-badge-value { font-size: 20px; font-weight: 700; color: var(--text); margin-top: 2px; }
.price-badge-value span { color: var(--accent2); }

/* Input */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 7px; letter-spacing: 0.5px; text-transform: uppercase; }
.field input { width: 100%; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-family: var(--sans); font-size: 15px; padding: 13px 16px; outline: none; transition: border-color 0.2s; }
.field input:focus { border-color: var(--accent); }
.field input::placeholder { color: var(--muted); }

/* Buttons */
.btn { width: 100%; padding: 14px; border-radius: var(--radius-sm); border: none; font-family: var(--sans); font-size: 15px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-ghost { background: var(--bg3); border: 1px solid var(--border2); color: var(--text); }
.btn-ghost:hover { background: var(--bg4); }
.btn-success-open { width: 100%; padding: 16px; border-radius: var(--radius-sm); border: none; font-family: var(--sans); font-size: 16px; font-weight: 700; cursor: pointer; transition: all 0.2s; margin-top: 8px; background: linear-gradient(135deg, var(--green), #16a057); color: #fff; letter-spacing: 0.3px; box-shadow: 0 4px 20px rgba(34,211,122,0.25); }
.btn-success-open:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(34,211,122,0.35); }

/* Currency grid */
.currency-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; margin-bottom: 18px; }
.currency-item { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; cursor: pointer; display: flex; align-items: center; gap: 10px; transition: all 0.2s; }
.currency-item:hover  { border-color: var(--accent); background: rgba(124,109,250,0.08); }
.currency-item.selected { border-color: var(--accent); background: rgba(124,109,250,0.12); }
.currency-icon { width: 32px; height: 32px; border-radius: 50%; overflow: hidden; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.currency-icon img { width: 100%; height: 100%; object-fit: contain; }
.currency-icon-fallback { width: 32px; height: 32px; border-radius: 50%; background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 10px; font-family: var(--mono); color: var(--accent2); font-weight: 500; flex-shrink: 0; }
.currency-name { font-size: 13px; font-weight: 600; }
.currency-network { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* QR */
.qr-wrapper { display: flex; justify-content: center; margin-bottom: 18px; }
.qr-box { background: #fff; padding: 12px; border-radius: 12px; display: inline-flex; }

/* Info rows */
.info-row { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.info-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.info-value { font-family: var(--mono); font-size: 12px; word-break: break-all; line-height: 1.4; }
.copy-btn { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--muted); cursor: pointer; padding: 7px 10px; font-size: 12px; font-family: var(--sans); font-weight: 600; white-space: nowrap; transition: all 0.2s; flex-shrink: 0; }
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.copy-btn.copied { border-color: var(--green); color: var(--green); }

/* Waiting */
.waiting { display: flex; flex-direction: column; align-items: center; padding: 16px 0 4px; gap: 10px; }
.waiting-ring { width: 44px; height: 44px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.waiting-text { font-size: 13px; color: var(--muted); text-align: center; }
.waiting-dots::after { content: ''; animation: dots 1.5s steps(3,end) infinite; }
@keyframes dots { 0%{content:''} 33%{content:'.'} 66%{content:'..'} 100%{content:'...'} }

/* Result screens */
.result-wrap { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 16px 0 8px; gap: 14px; }
.result-icon { width: 72px; height: 72px; border-radius: 50%; display: flex; align-items: center; justify-content: center; animation: popIn 0.4s cubic-bezier(0.34,1.56,0.64,1); }
.result-icon.success { background: rgba(34,211,122,0.12); }
.result-icon.rejected { background: rgba(255,92,92,0.12); }
.result-icon svg { width: 36px; height: 36px; }
@keyframes popIn { from{transform:scale(0);opacity:0} to{transform:scale(1);opacity:1} }
.result-title { font-size: 22px; font-weight: 700; }
.result-title.red { color: var(--red); }
.result-sub { font-size: 14px; color: var(--muted); line-height: 1.5; }

/* Error */
.error-msg { background: rgba(255,92,92,0.1); border: 1px solid rgba(255,92,92,0.25); border-radius: var(--radius-sm); color: var(--red); font-size: 13px; padding: 12px 14px; margin-top: 12px; display: none; }
.error-msg.show { display: block; }

/* Screens */
.screen { display: none; animation: fadeIn 0.22s ease; }
.screen.active { display: block; }
@keyframes fadeIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:none} }

.divider { height: 1px; background: var(--border); margin: 16px 0; }
.note { font-size: 12px; color: var(--muted); text-align: center; line-height: 1.5; margin-top: 12px; }

/* ── MY TOKENS MODAL ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.75); backdrop-filter: blur(8px); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius); width: 100%; max-width: 480px; max-height: 88vh; display: flex; flex-direction: column; position: relative; transform: translateY(16px); transition: transform 0.25s; }
.modal-overlay.open .modal { transform: translateY(0); }
.modal::before { content: ''; position: absolute; top: -1px; left: 50%; transform: translateX(-50%); width: 200px; height: 1px; background: linear-gradient(90deg, transparent, var(--accent), transparent); }
.modal-header { padding: 18px 20px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; color: var(--muted); cursor: pointer; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.modal-close:hover { color: var(--text); }
.modal-close svg { width: 15px; height: 15px; }
.modal-body { padding: 16px 20px 20px; overflow-y: auto; flex: 1; }

/* Order cards in modal */
.order-card { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 10px; }
.order-card:last-child { margin-bottom: 0; }
.order-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 6px; gap: 8px; }
.order-date { font-size: 13px; font-weight: 600; color: var(--text); }
.order-amount { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.status-badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; white-space: nowrap; flex-shrink: 0; }
.status-pending  { background: rgba(245,158,11,0.12); color: var(--amber); }
.status-approved { background: rgba(34,211,122,0.12); color: var(--green); }
.status-rejected { background: rgba(255,92,92,0.12);  color: var(--red); }
.token-block { background: var(--bg4); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.token-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.token-value { font-family: var(--mono); font-size: 11px; color: var(--accent2); word-break: break-all; line-height: 1.5; margin-bottom: 10px; }
.token-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.copy-token-btn { background: var(--bg); border: 1px solid var(--border2); border-radius: 7px; color: var(--muted); font-family: var(--sans); font-size: 12px; font-weight: 600; padding: 6px 12px; cursor: pointer; transition: all 0.2s; }
.copy-token-btn:hover { color: var(--accent); border-color: var(--accent); }
.copy-token-btn.copied { color: var(--green); border-color: var(--green); }
.token-timer { font-size: 11px; color: var(--amber); font-family: var(--mono); font-weight: 500; }
.token-expired-msg { font-size: 12px; color: var(--muted); font-style: italic; margin-top: 6px; }
.token-pending-msg { font-size: 12px; color: var(--amber); margin-top: 6px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state svg { width: 44px; height: 44px; margin-bottom: 12px; opacity: 0.25; }
.empty-state p { font-size: 14px; line-height: 1.6; }
.spinner-wrap { text-align: center; padding: 40px 20px; }
.spinner { width: 30px; height: 30px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 10px; }

/* ── MOBILE ── */
@media (max-width: 500px) {
  body { padding: 16px 12px; align-items: flex-start; padding-top: 20px; }
  .wrapper { max-width: 100%; gap: 12px; }
  .card-header { padding: 18px 18px 0; }
  .card-body { padding: 16px 18px 20px; }
  .currency-grid { gap: 8px; }
  .currency-item { padding: 10px; gap: 8px; }
  .currency-name { font-size: 12px; }
  .info-value { font-size: 11px; }
  .modal { max-height: 92vh; border-radius: 16px 16px 0 0; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .price-badge-value { font-size: 18px; }
  .mytokens-btn { padding: 12px 16px; }
  .qr-box canvas, .qr-box img { width: 140px !important; height: 140px !important; }
}
