/* ───── reset & base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: #0f172a;
  background: #f1f5f9;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: #6366f1; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 12px; color: #0b1220; font-weight: 700; }
h1 { font-size: clamp(22px, 3vw, 28px); }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0 0 12px; }
code { font-family: 'SF Mono', Menlo, monospace; font-size: 12px; }
pre { font-family: 'SF Mono', Menlo, monospace; margin: 0; }
.muted { color: #64748b; }
.small { font-size: 13px; }
.hide { display: none !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; } .mt-32 { margin-top: 32px; }
.w-100 { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2 .span-2 { grid-column: 1 / -1; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } .grid-2 .span-2 { grid-column: auto; } }

/* ───── buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; cursor: pointer; font-family: inherit;
  text-decoration: none; transition: transform .08s, box-shadow .15s, background .15s;
  background: #fff; color: #0f172a;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; box-shadow: 0 6px 24px -10px rgba(99,102,241,0.55); }
.btn-ghost { background: #fff; border-color: #e2e8f0; }
.btn-ghost:hover { background: #f8fafc; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-success { background: #10b981; color: #fff; }

/* ───── auth page ──────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(700px 380px at 100% 0%, rgba(220,38,38,0.18), transparent 60%),
    radial-gradient(600px 320px at 0% 100%, rgba(99,102,241,0.16), transparent 60%),
    #0b1220;
  color: #cbd5e1;
}
.auth-shell { width: 100%; max-width: 440px; padding: 24px; }
.auth-brand { text-align: center; font-size: 22px; font-weight: 800; color: #fff; margin-bottom: 18px; }
.auth-card { background: #0f1729; border: 1px solid #1f2940; border-radius: 18px; padding: 28px; box-shadow: 0 22px 60px -32px rgba(0,0,0,0.5); }
.auth-card h1 { color: #fff; }
.auth-card .muted { color: #94a3b8; }
.auth-card input {
  width: 100%; padding: 10px 12px; border: 1px solid #1f2940; border-radius: 10px;
  background: #0b1220; color: #fff; font: inherit;
}
.auth-card input:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.18); }
.auth-card label { display: block; font-size: 13px; font-weight: 600; color: #cbd5e1; margin-bottom: 12px; }
.admin-badge {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  background: rgba(239,68,68,0.16); color: #fca5a5; font-size: 11px;
  font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 14px;
}
.error { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.4); color: #fecaca; padding: 10px; border-radius: 10px; font-size: 14px; }
.success { background: rgba(16,185,129,0.12); border: 1px solid rgba(16,185,129,0.4); color: #6ee7b7; padding: 10px; border-radius: 10px; font-size: 14px; }
.app-page .error, .app-page .success { color: initial; background: initial; }
.app-page .error { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.app-page .success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }

/* ───── app shell ──────────────────────────────────────────────── */
.app-page { background: #f1f5f9; min-height: 100vh; }
.app-sidebar {
  position: fixed; inset: 0 auto 0 0; width: 240px;
  background: #0b1220; color: #cbd5e1; padding: 20px 14px;
  display: flex; flex-direction: column; gap: 6px; z-index: 30;
}
.app-sidebar .brand { color: #fff; font-weight: 800; font-size: 20px; margin-bottom: 18px; display: block; }
.app-sidebar .brand-name { background: linear-gradient(135deg, #c4b5fd, #f9a8d4); -webkit-background-clip: text; background-clip: text; color: transparent; }
.app-nav { display: flex; flex-direction: column; gap: 2px; }
.app-nav a {
  padding: 9px 12px; border-radius: 10px; color: #cbd5e1; font-weight: 500; font-size: 14px; cursor: pointer;
}
.app-nav a:hover { background: rgba(255,255,255,0.05); color: #fff; text-decoration: none; }
.app-nav a.active { background: linear-gradient(135deg, rgba(99,102,241,0.25), rgba(236,72,153,0.18)); color: #fff; }

.app-main { margin-left: 240px; padding: 22px 26px 56px; min-height: 100vh; }
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 20px; }
.app-header h1 { margin: 0; font-size: 22px; }
.mobile-toggle { display: none; background: none; border: 0; width: 36px; height: 36px; cursor: pointer; }
.mobile-toggle span { display: block; width: 22px; height: 2px; background: #0f172a; margin: 4px auto; }
.mobile-toggle.dark span { background: #fff; }
@media (max-width: 920px) {
  .app-sidebar { transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .app-sidebar { transform: none; }
  .app-main { margin-left: 0; padding: 16px; }
  .mobile-toggle { display: block; }
}

.view { display: none; }
.view.active { display: block; animation: fadeIn .15s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat-grid-6 { grid-template-columns: repeat(6, 1fr); }
.stat-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stat { background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.stat strong { font-size: 22px; color: #0b1220; }
@media (max-width: 920px) { .stat-grid, .stat-grid-3, .stat-grid-6 { grid-template-columns: 1fr 1fr; } }

.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 16px; padding: 20px; margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-controls input, .card-controls select { padding: 8px 10px; border: 1px solid #e2e8f0; border-radius: 9px; font: inherit; }
.card form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 10px; }
.card form input, .card form select, .card form textarea {
  padding: 10px 12px; border: 1px solid #e2e8f0; border-radius: 10px; font: inherit; background: #fff; color: #0f172a;
}
.card form input:focus, .card form select:focus, .card form textarea:focus {
  outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.16);
}
label.check { flex-direction: row !important; align-items: center; gap: 8px; font-weight: 500 !important; }
label.check input { margin: 0; }

.list-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.list-table th, .list-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.list-table th { background: #f8fafc; color: #475569; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; border: 1px solid #eef2f7; border-radius: 12px; }

.status { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.status.pending  { background: #fef3c7; color: #92400e; }
.status.paid, .status.completed, .status.active { background: #dcfce7; color: #166534; }
.status.overdue, .status.failed, .status.expired { background: #fee2e2; color: #b91c1c; }
.status.cancelled { background: #e5e7eb; color: #475569; }
.status.matched   { background: #dcfce7; color: #166534; }
.status.unmatched { background: #fef3c7; color: #92400e; }
.status.ignored   { background: #e5e7eb; color: #475569; }

.empty-row { text-align: center; padding: 36px; color: #94a3b8; }
.codeblock { background: #0b1220; color: #cbd5e1; padding: 14px; border-radius: 12px; overflow-x: auto; font-family: 'SF Mono', monospace; font-size: 13px; white-space: pre-wrap; word-break: break-all; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.topup-instructions { background: #f8fafc; padding: 14px; border-radius: 12px; font-size: 14px; }
