:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #fbfbfe;
  --border: #e6e8f0;
  --text: #1a1d29;
  --text-muted: #6b7280;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --neutral-soft: #f1f2f6;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 20, 43, 0.04), 0 8px 24px -12px rgba(20, 20, 43, 0.12);
  --shadow-sm: 0 1px 2px rgba(20, 20, 43, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #171a24;
    --surface-2: #1d2029;
    --border: #2a2e3a;
    --text: #eef0f6;
    --text-muted: #9aa0b2;
    --accent: #818cf8;
    --accent-hover: #a5b0ff;
    --accent-soft: #23253a;
    --danger: #f87171;
    --danger-soft: #2a1a1c;
    --success: #4ade80;
    --success-soft: #16241c;
    --warning: #fbbf24;
    --warning-soft: #2a2216;
    --neutral-soft: #1d2029;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0 0 4px; font-weight: 700; }
p { margin: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: #0d0d10;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.login-card .brand-mark { width: 40px; height: 40px; border-radius: 11px; }
.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-link {
  padding: 8px 14px; border-radius: 10px; color: var(--text-muted); font-weight: 600; font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--neutral-soft); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav-right { display: flex; align-items: center; gap: 10px; }
.user-chip { font-size: 13px; color: var(--text-muted); }

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}
.container-wide { max-width: 1180px; }

.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 22px; }
.page-head .sub { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}
.card + .card { margin-top: 16px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.field .hint { font-size: 12px; color: var(--text-muted); }
input, select, textarea {
  font-family: inherit;
  font-size: 14.5px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[disabled] { opacity: .65; cursor: not-allowed; }
textarea { resize: vertical; min-height: 70px; }

.amount-field { position: relative; }
.amount-field input { padding-left: 62px; }
.amount-field .currency-fixed {
  position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 12.5px;
  padding: 6px 10px; border-radius: 8px;
}

.phone-field { position: relative; }
.phone-field input { padding-left: 66px; direction: ltr; text-align: left; }
.phone-field .country-fixed {
  position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 12.5px;
  padding: 6px 10px; border-radius: 8px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-weight: 700; font-size: 14.5px;
  padding: 11px 20px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  transition: transform .05s ease, filter .15s, background .15s;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 22px; font-size: 16px; }
.btn-secondary { background: var(--neutral-soft); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { filter: brightness(0.97); }
.btn-outline { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-outline:hover { background: var(--accent-soft); }
.btn-danger-outline { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.alert { padding: 13px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; font-weight: 600; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 800; }
.badge-pending { background: var(--warning-soft); color: var(--warning); }
.badge-paid { background: var(--success-soft); color: var(--success); }
.badge-failed { background: var(--danger-soft); color: var(--danger); }
.badge-expired { background: var(--neutral-soft); color: var(--text-muted); }
.badge-cancelled { background: var(--neutral-soft); color: var(--text-muted); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.success-card { text-align: center; padding: 36px 24px; }
.success-icon {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 14px;
  background: var(--success-soft); color: var(--success);
  display: flex; align-items: center; justify-content: center; font-size: 28px;
}
.summary-list { text-align: right; margin: 22px 0; display: grid; gap: 10px; }
.summary-row { display: flex; justify-content: space-between; gap: 14px; padding: 10px 14px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 14px; }
.summary-row .k { color: var(--text-muted); font-weight: 600; }
.summary-row .v { font-weight: 700; }

.link-box {
  display: flex; align-items: center; gap: 8px; background: var(--surface-2);
  border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin: 18px 0;
}
.link-box input { border: none; background: transparent; padding: 4px; direction: ltr; text-align: left; font-size: 13px; color: var(--text-muted); }

.actions-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 18px; }
.toolbar .field { margin-bottom: 0; min-width: 160px; }
.toolbar .field.grow { flex: 1; min-width: 220px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 12px 14px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-muted); font-weight: 700; font-size: 12.5px; text-transform: uppercase; letter-spacing: .02em; }
tbody tr:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.table-wrap table { border: none; }
.table-wrap tr:last-child td { border-bottom: none; }
.mono { direction: ltr; text-align: left; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.icon-btn { display: inline-flex; padding: 6px 9px; border-radius: 8px; font-size: 12px; border: 1px solid var(--border); background: var(--surface-2); font-weight: 700; }
.icon-btn:hover { background: var(--neutral-soft); }
.empty-state { padding: 60px 20px; text-align: center; color: var(--text-muted); }

.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 18px; }
.pagination a, .pagination span { padding: 7px 13px; border-radius: 8px; font-size: 13px; font-weight: 700; border: 1px solid var(--border); }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

.section-title { font-size: 13px; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin: 26px 0 10px; }
.section-title:first-child { margin-top: 0; }

.masked-field { display: flex; align-items: center; gap: 10px; }
.masked-field .value { font-family: ui-monospace, monospace; direction: ltr; background: var(--surface-2); padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border); flex: 1; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { justify-content: center; margin-bottom: 20px; font-size: 19px; }

.helper-text { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
.copy-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 20px; border-radius: 999px;
  font-size: 13.5px; font-weight: 700; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
  z-index: 100;
}
.copy-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .topbar { padding: 12px 16px; }
  .nav-links { width: 100%; order: 3; justify-content: center; }
  .nav-link { padding: 7px 10px; font-size: 13px; }
  .container { padding: 20px 14px 50px; }
  .summary-row { flex-direction: column; gap: 4px; }
  th, td { padding: 10px; }
}
