:root {
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --text: #1a1d23;
  --muted: #6b7280;
  --border: #e2e5ea;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --card-bg: #1d2026;
    --text: #e8eaed;
    --muted: #9aa0ab;
    --border: #2c303a;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.topbar h1 { font-size: 18px; margin: 0; }

.mode-switch { display: flex; gap: 8px; }

.mode-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}

.mode-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.live-banner {
  background: #fee2e2;
  color: #991b1b;
  text-align: center;
  padding: 10px;
  font-weight: 600;
}

@media (prefers-color-scheme: dark) {
  .live-banner { background: #4c1414; color: #fca5a5; }
}

.hidden { display: none !important; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.card.wide { grid-column: 1 / -1; }

.card h2 { margin-top: 0; font-size: 15px; }

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 12px 0 4px;
}

input, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.row { display: flex; gap: 8px; align-items: center; }
.row input { flex: 1; }

button {
  cursor: pointer;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  font-size: 14px;
}

.primary {
  background: var(--primary);
  color: white;
  padding: 12px 16px;
  width: 100%;
  margin-top: 16px;
}
.primary:hover { background: var(--primary-hover); }

.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
}

.secondary.small { padding: 4px 10px; font-size: 12px; }

.hint { font-size: 12px; color: var(--muted); line-height: 1.5; }

code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.result {
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  background: var(--bg);
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: auto;
}

.status-box {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.badge.pending { background: #fef3c7; color: #92400e; }
.badge.success { background: #dcfce7; color: #166534; }
.badge.failed { background: #fee2e2; color: #991b1b; }

.inline-checkbox { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }

.webhook-log {
  margin-top: 14px;
  max-height: 320px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.webhook-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.webhook-item .meta {
  display: flex;
  justify-content: space-between;
  font-family: -apple-system, sans-serif;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}

.footer {
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-size: 12px;
}

.topbar-right { display: flex; align-items: center; gap: 16px; }

.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.wallet-pill {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
}

#authScreen a { color: var(--primary); }
