:root {
  --cb-blue: #0052ff;
  --cb-blue-dark: #0045d8;
  --cb-blue-soft: #eef3ff;
  --cb-bg: #f6f8fb;
  --cb-card: #ffffff;
  --cb-border: #e2e8f0;
  --cb-text: #0b1c33;
  --cb-muted: #667085;
  --cb-green: #12b76a;
  --cb-red: #f04438;
  --cb-radius: 12px;
  --cb-shadow: 0 2px 4px rgba(11, 28, 51, 0.06), 0 12px 32px rgba(11, 28, 51, 0.08);
  --font: "Montserrat", "Noto Sans Arabic", "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cb-bg);
  color: var(--cb-text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- topbar ---------- */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--cb-border);
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 0 20px;
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: 14px 0;
}
.topbar-logo { display: flex; align-items: center; gap: 4px; text-decoration: none; color: inherit; }
.logo-img { width: 30px; height: 30px; border-radius: 6px; object-fit: cover; }
.logo-wordmark { height: 30px; width: auto; display: block; margin-left: -5px; }
.logo-text { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
.logo-text-strong { color: var(--cb-blue); }

/* language switcher */
.lang-switch { position: relative; }
.lang-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #fff;
  border: 1.5px solid var(--cb-border);
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font);
  color: var(--cb-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.lang-trigger:hover { border-color: #b9c7e8; }
.lang-switch.open .lang-trigger { border-color: var(--cb-blue); box-shadow: 0 0 0 3px rgba(0, 82, 255, 0.12); }
.lang-globe { width: 16px; height: 16px; color: var(--cb-muted); flex-shrink: 0; }
.lang-code { font-size: 13px; font-weight: 600; }
.lang-switch .drop-chevron { width: 15px; height: 15px; }
.lang-switch.open .drop-chevron { transform: rotate(180deg); color: var(--cb-blue); }
.lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  z-index: 30;
  background: #fff;
  border: 1px solid var(--cb-border);
  border-radius: var(--cb-radius);
  box-shadow: 0 8px 24px rgba(11, 28, 51, 0.14);
  padding: 6px;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}
.lang-switch.open .lang-menu { opacity: 1; transform: translateY(0); pointer-events: auto; }
.lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--cb-text);
  text-align: left;
  transition: background 0.12s;
}
.lang-option:hover { background: var(--cb-blue-soft); }
.lang-option.selected { background: var(--cb-blue-soft); color: var(--cb-blue); font-weight: 700; }
.lang-option .lang-check { margin-left: auto; font-size: 12px; font-weight: 800; color: transparent; }
.lang-option.selected .lang-check { color: var(--cb-blue); }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font);
  font-weight: 600;
  font-size: 15px;
  padding: 11px 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  line-height: 1.2;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--cb-blue); color: #fff; }
.btn-primary:hover { background: var(--cb-blue-dark); }
.btn-primary:disabled { background: #a9c1f5; cursor: not-allowed; }
.btn-ghost { background: #fff; color: var(--cb-text); border-color: var(--cb-border); }
.btn-ghost:hover { border-color: #c3cdd9; background: #fafbfc; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------- layout ---------- */
.main { flex: 1; display: flex; justify-content: center; padding: 40px 20px; }
.invoice {
  width: 100%;
  max-width: 620px;
  background: var(--cb-card);
  border: 1px solid var(--cb-border);
  border-radius: 16px;
  box-shadow: var(--cb-shadow);
  padding: 28px 32px 32px;
}

/* ---------- invoice head ---------- */
.invoice-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 26px;
}
.head-brand { display: flex; align-items: center; gap: 12px; }
.head-logo {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--cb-blue);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800;
}
.head-merchant { font-size: 14px; color: var(--cb-muted); font-weight: 500; }
.head-amount { font-size: 22px; font-weight: 800; letter-spacing: -0.4px; margin-top: 2px; }
.head-currency { font-size: 14px; color: var(--cb-muted); font-weight: 600; margin-left: 4px; }
.head-invoice-id { font-size: 13px; color: var(--cb-muted); font-weight: 500; }

/* ---------- stepper ---------- */
.stepper {
  list-style: none;
  display: flex;
  gap: 0;
  margin: 0 0 30px;
  padding: 0;
  counter-reset: step;
}
.step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  padding-bottom: 14px;
}
.step:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 20px;
  right: 12px;
  top: 13px;
  height: 2px;
  background: var(--cb-border);
}
.step.active:not(:last-child)::after { background: var(--cb-blue); }
.step-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #e8edf5;
  color: var(--cb-muted);
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  z-index: 1;
}
.step.active .step-dot { background: var(--cb-blue); color: #fff; }
.step.done .step-dot { background: var(--cb-green); color: #fff; }
.step-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.step-label { font-size: 13px; font-weight: 700; line-height: 1.2; }
.step-sub { font-size: 12px; color: var(--cb-muted); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step.active .step-label { color: var(--cb-blue); }
.step.done .step-label { color: var(--cb-green); }

/* ---------- panels ---------- */
.panels { position: relative; }
.panel { display: none; animation: fadein 0.18s ease; }
.panel.active { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.panel-title { font-size: 19px; font-weight: 800; margin: 0 0 6px; letter-spacing: -0.3px; }
.panel-sub { font-size: 14px; color: var(--cb-muted); margin: 0 0 22px; }

/* ---------- fields ---------- */
.field { margin-bottom: 20px; }
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--cb-text);
  margin-bottom: 10px;
}

/* step counter */
.step-head { margin-bottom: 10px; }
.step-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--cb-blue);
  background: var(--cb-blue-soft);
  padding: 4px 10px;
  border-radius: 999px;
  display: inline-block;
  letter-spacing: 0.2px;
}

/* ---------- dropdowns (currency / network) ---------- */
.dropdown { position: relative; }
.dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  background: #fff;
  border: 1.5px solid var(--cb-border);
  border-radius: var(--cb-radius);
  cursor: pointer;
  font-family: var(--font);
  transition: border-color 0.15s, box-shadow 0.15s;
  text-align: left;
}
.dropdown-trigger:hover { border-color: #b9c7e8; }
.dropdown.open .dropdown-trigger { border-color: var(--cb-blue); box-shadow: 0 0 0 3px rgba(0, 82, 255, 0.12); }
.drop-icon { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; }
.drop-body { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.drop-name { font-size: 14px; font-weight: 700; }
.drop-sub { font-size: 12px; color: var(--cb-muted); font-weight: 500; }
.drop-chevron { width: 18px; height: 18px; color: var(--cb-muted); flex-shrink: 0; transition: transform 0.15s; }
.dropdown.open .drop-chevron { transform: rotate(180deg); color: var(--cb-blue); }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 30;
  background: #fff;
  border: 1px solid var(--cb-border);
  border-radius: var(--cb-radius);
  box-shadow: 0 8px 24px rgba(11, 28, 51, 0.14);
  padding: 6px;
  max-height: 280px;
  overflow-y: auto;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}
.dropdown.open .dropdown-menu { opacity: 1; transform: translateY(0); pointer-events: auto; }
.drop-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font);
  text-align: left;
  transition: background 0.12s;
}
.drop-option:hover { background: var(--cb-blue-soft); }
.drop-option.selected { background: var(--cb-blue-soft); }
.drop-option.selected .drop-name { color: var(--cb-blue); }
.drop-option .drop-check {
  width: 18px; height: 18px;
  margin-left: auto;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800;
  color: transparent;
  flex-shrink: 0;
}
.drop-option.selected .drop-check { background: var(--cb-blue); color: #fff; }

/* fees note */
.fees-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #f0fdf6;
  border: 1px solid #d6f5e5;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  color: #157a4b;
  margin-bottom: 20px;
  line-height: 1.5;
}
.fees-note strong { font-weight: 700; color: #0e6b40; }
.fees-check {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--cb-green);
  color: #fff;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

/* amount to receive box */
.amount-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--cb-blue-soft);
  border: 1px solid #d4e0ff;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 20px;
}
.amount-label { font-size: 12px; font-weight: 700; color: var(--cb-blue); text-transform: uppercase; letter-spacing: 0.4px; }
.amount-crypto { font-size: 24px; font-weight: 800; letter-spacing: -0.4px; }
.amount-usd { font-size: 14px; color: var(--cb-muted); font-weight: 600; }
.amount-coin { display: flex; align-items: center; gap: 10px; }
.amount-icon { width: 28px; height: 28px; border-radius: 50%; }

/* ---------- input ---------- */
.input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1.5px solid var(--cb-border);
  border-radius: 10px;
  padding: 0 14px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-wrap:focus-within { border-color: var(--cb-blue); box-shadow: 0 0 0 3px rgba(0, 82, 255, 0.12); }
.input-coin {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 12px;
  flex-shrink: 0;
}
.input {
  flex: 1;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 14px;
  padding: 13px 0;
  color: var(--cb-text);
  background: transparent;
}
.input::placeholder { color: #9aa4b2; }
.field-error { font-size: 12.5px; color: var(--cb-red); margin: 8px 0 0; font-weight: 500; }

/* ---------- checkbox ---------- */
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; margin: 4px 0 22px; }
.check input { display: none; }
.check-box {
  width: 20px; height: 20px;
  border: 1.5px solid var(--cb-border);
  border-radius: 6px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  margin-top: 1px;
}
.check input:checked + .check-box { background: var(--cb-blue); border-color: var(--cb-blue); }
.check input:checked + .check-box::after {
  content: "✓";
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}
.check-text { font-size: 13px; color: var(--cb-muted); line-height: 1.45; }

/* ---------- button rows ---------- */
.btn-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ---------- details ---------- */
.qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px;
  margin-bottom: 22px;
  background: #fff;
  border: 1px solid var(--cb-border);
  border-radius: 14px;
}
.qr-img {
  width: 220px;
  height: 220px;
  border-radius: 10px;
  image-rendering: pixelated;
  background: #fff;
}
.qr-hint { font-size: 13px; color: var(--cb-muted); font-weight: 500; text-align: center; }
.qr-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  margin-top: 12px;
}
.qr-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 13px;
  color: var(--cb-muted);
  font-weight: 500;
  min-height: 24px;
}
.qr-status.success { color: #12b76a; }
.qr-status.error { color: #f04438; }
.qr-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #e4e7ec;
  border-top-color: #0052ff;
  border-radius: 50%;
  animation: qrspin 0.9s linear infinite;
}
@keyframes qrspin { to { transform: rotate(360deg); } }
.refresh-btn {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--cb-border);
  border-radius: 100px;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--cb-muted);
  cursor: pointer;
  transition: all .2s ease;
}
.qr-bar.ready { justify-content: center; }
.refresh-btn:hover:not(:disabled) { border-color: #98a2b3; color: #344054; }
.refresh-btn:active:not(:disabled) { background: #f5f7fa; }
.refresh-btn:disabled { opacity: .45; cursor: default; }
.refresh-btn svg { width: 14px; height: 14px; }
.invoice-subtitle { font-size: 15px; font-weight: 800; margin: 0 0 10px; letter-spacing: -0.2px; }
.status-waiting { color: #b54708; background: #fffaeb; border: 1px solid #fedf89; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }

.details {
  border: 1px solid var(--cb-border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 22px;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  font-size: 14px;
}
.detail-row + .detail-row { border-top: 1px solid var(--cb-border); }
.detail-label { color: var(--cb-muted); font-weight: 500; }
.detail-value { font-weight: 700; text-align: right; word-break: break-all; }
.detail-value.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 12.5px; font-weight: 600; }

/* ---------- footer ---------- */
.footer {
  text-align: center;
  padding: 24px;
  font-size: 13px;
  color: var(--cb-muted);
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: #101828;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 560px) {
  .invoice { padding: 22px 18px 24px; }
  .invoice-head { flex-direction: column; }
  .step-sub { display: none; }
}

/* ---------- RTL (Arabic) ---------- */
html[dir="rtl"] .lang-menu { right: auto; left: 0; }
html[dir="rtl"] .drop-chevron { transform: scaleX(-1); }
html[dir="rtl"] .dropdown.open .drop-chevron { transform: scaleX(-1) rotate(180deg); }
html[dir="rtl"] .lang-switch .drop-chevron { transform: scaleX(-1); }
html[dir="rtl"] .lang-switch.open .drop-chevron { transform: scaleX(-1) rotate(180deg); }
html[dir="rtl"] .qr-hint { direction: rtl; }
