:root {
  --bg: #050810;
  --bg-card: rgba(15, 22, 41, 0.72);
  --bg-elevated: #1a2442;
  --border: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(99, 102, 241, 0.35);
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.45);
  --accent: #22d3ee;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #f43f5e;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --font: "Plus Jakarta Sans", "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Animated ambient background */
.ambient {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  animation: floatOrb 18s var(--ease) infinite;
}

.ambient-orb:nth-child(1) {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, var(--primary-glow), transparent 70%);
  top: -120px;
  left: 10%;
  animation-delay: 0s;
}

.ambient-orb:nth-child(2) {
  width: 360px;
  height: 360px;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.35), transparent 70%);
  bottom: -80px;
  right: 5%;
  animation-delay: -6s;
}

.ambient-orb:nth-child(3) {
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.3), transparent 70%);
  top: 40%;
  right: 30%;
  animation-delay: -12s;
}

@keyframes floatOrb {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -20px) scale(1.05); }
  66% { transform: translate(-20px, 25px) scale(0.95); }
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  background: rgba(8, 12, 24, 0.75);
  backdrop-filter: blur(16px) saturate(1.2);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 20px var(--primary-glow);
}

.brand-icon svg { width: 22px; height: 22px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.live-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.live-status.offline {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.25);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
  animation: pulseLive 2s ease-out infinite;
}

.live-status.offline .live-dot {
  background: var(--warning);
  animation: none;
}

@keyframes pulseLive {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.container {
  position: relative;
  z-index: 1;
  max-width: 1140px;
  margin: 0 auto;
  padding: 1.5rem;
}

.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  transition: border-color 0.25s var(--ease), transform 0.25s var(--ease);
}

.card:hover { border-color: var(--border-strong); }

.card-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

.card-title svg, .card-title i { color: var(--accent); flex-shrink: 0; width: 20px; height: 20px; }

.muted { color: var(--text-muted); font-size: 0.875rem; }

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input-wrap {
  position: relative;
}

.input-wrap .input-icon-btn {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.input-wrap .input-icon-btn:hover { color: var(--text); background: var(--bg-elevated); }

input, select, textarea {
  width: 100%;
  font: inherit;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(5, 8, 16, 0.6);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.input-wrap input { padding-right: 2.75rem; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
  background: rgba(5, 8, 16, 0.9);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font: inherit;
  font-weight: 600;
  padding: 0.7rem 1.15rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.2s, background 0.2s;
  position: relative;
  overflow: hidden;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn:not(:disabled):active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: white;
  box-shadow: 0 4px 18px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 28px var(--primary-glow);
  filter: brightness(1.08);
}

.btn-success { background: linear-gradient(135deg, var(--success), #059669); color: white; }
.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
}

.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); }

.btn-google {
  background: #fff;
  color: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.2);
  width: 100%;
  padding: 0.8rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.btn-google:hover { background: #f8fafc; transform: translateY(-1px); }

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.25rem 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-pending { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; }
.badge-awaiting_review { background: rgba(245, 158, 11, 0.18); color: #fbbf24; }
.badge-paid { background: rgba(16, 185, 129, 0.18); color: #34d399; }
.badge-expired, .badge-failed { background: rgba(244, 63, 94, 0.18); color: #fb7185; }

.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }

th {
  text-align: left;
  padding: 0.7rem 0.6rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.8rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr {
  transition: background 0.15s;
}

tbody tr:hover { background: rgba(99, 102, 241, 0.06); }

.hidden { display: none !important; }

/* Login */
.login-wrap {
  max-width: 440px;
  margin: 2rem auto 3rem;
  animation: fadeUp 0.5s var(--ease);
}

.login-hero {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-hero h1 {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.35rem;
  background: linear-gradient(135deg, #fff 30%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-card {
  border: 1px solid var(--border-strong);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.steps { list-style: none; counter-reset: step; }

.steps li {
  counter-increment: step;
  display: flex;
  gap: 0.85rem;
  margin-bottom: 0.9rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  align-items: flex-start;
}

.steps li::before {
  content: counter(step);
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--bg-elevated), rgba(99, 102, 241, 0.2));
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.8rem;
  color: var(--accent);
}

.alert {
  display: flex;
  gap: 0.7rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  align-items: flex-start;
}

.alert-warn {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fcd34d;
}

.alert-ok {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  border-radius: 16px;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.ref-code {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: #6ee7b7;
  font-family: var(--mono);
}

.amount { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.user-chip img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
}

#loginError { color: var(--danger); font-size: 0.875rem; margin-top: 0.65rem; min-height: 1.25rem; }

pre.keys-box {
  background: rgba(5, 8, 16, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  overflow: auto;
  font-size: 0.8rem;
  font-family: var(--mono);
}

.tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  padding: 0.3rem;
  background: rgba(15, 22, 41, 0.6);
  border-radius: 14px;
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1rem;
  border-radius: 11px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  position: relative;
}

.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }

.tab.active {
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: white;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.tab-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  font-weight: 800;
  display: none;
  align-items: center;
  justify-content: center;
}

.tab-badge.show { display: inline-flex; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  transition: transform 0.25s var(--ease), border-color 0.25s, box-shadow 0.25s;
  animation: fadeUp 0.45s var(--ease) backwards;
}

.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }
.stat-card:nth-child(5) { animation-delay: 0.25s; }
.stat-card:nth-child(6) { animation-delay: 0.3s; }

.stat-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg { width: 22px; height: 22px; }

.stat-icon.review { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.stat-icon.pending { background: rgba(148, 163, 184, 0.12); color: #94a3b8; }
.stat-icon.paid { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.stat-icon.revenue { background: rgba(99, 102, 241, 0.15); color: #a5b4fc; }
.stat-icon.projects { background: rgba(34, 211, 238, 0.12); color: #22d3ee; }
.stat-icon.webhook { background: rgba(244, 63, 94, 0.12); color: #fb7185; }

.stat-body .label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.stat-body .value {
  font-size: 1.55rem;
  font-weight: 800;
  margin-top: 0.2rem;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat-card.warn .value { color: #fbbf24; }
.stat-card.ok .value { color: #34d399; }

.code-block {
  position: relative;
  background: rgba(5, 8, 16, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 0.5rem;
}

.code-block pre {
  margin: 0;
  padding: 1rem;
  overflow: auto;
  font-size: 0.78rem;
  line-height: 1.5;
  max-height: 300px;
  font-family: var(--mono);
}

.code-block .copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.72rem;
}

.project-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.project-row:hover { background: rgba(99, 102, 241, 0.04); margin: 0 -0.5rem; padding-left: 0.5rem; padding-right: 0.5rem; border-radius: 8px; }
.project-row:last-child { border-bottom: none; }

.snippet-tabs { display: flex; gap: 0.35rem; flex-wrap: wrap; margin: 0.75rem 0; }

.snippet-tab {
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(5, 8, 16, 0.5);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.snippet-tab.active {
  border-color: var(--primary);
  color: var(--accent);
  background: rgba(99, 102, 241, 0.12);
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 0.85rem 1.2rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 200;
  box-shadow: var(--shadow);
  animation: toastIn 0.35s var(--ease);
}

.toast.success { border-color: rgba(16, 185, 129, 0.4); }
.toast.error { border-color: rgba(244, 63, 94, 0.4); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.panel {
  display: none;
  animation: fadeUp 0.35s var(--ease);
}

.panel.active { display: block; }

.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, rgba(99, 102, 241, 0.08) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  border-radius: 8px;
  height: 1.5rem;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Payment page */
.pay-progress {
  display: flex;
  justify-content: space-between;
  margin: 1.25rem 0 1.5rem;
  position: relative;
}

.pay-progress::before {
  content: "";
  position: absolute;
  top: 14px;
  left: 10%;
  right: 10%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}

.pay-step {
  flex: 1;
  text-align: center;
  position: relative;
  z-index: 1;
}

.pay-step-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  margin: 0 auto 0.4rem;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: all 0.3s var(--ease);
}

.pay-step.active .pay-step-dot {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
  box-shadow: 0 0 16px var(--primary-glow);
}

.pay-step.done .pay-step-dot {
  border-color: var(--success);
  background: var(--success);
  color: white;
}

.pay-step span { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; }

.copy-ref-btn { margin-top: 0.5rem; }

@media (max-width: 640px) {
  .container { padding: 1rem; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .header-actions .live-status span:last-child { display: none; }
}
