*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2d3a;
  --text: #e2e8f0;
  --text-muted: #64748b;
  --primary: #6366f1;
  --primary-hover: #4f52d4;
  --code-bg: #0d1117;
  --danger: #f87171;
  --radius: 6px;
  --font-mono: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

/* ── Navbar ──────────────────────────────────────────── */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-left, .navbar-right { display: flex; align-items: center; gap: 16px; }

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.3px;
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 6px var(--primary);
}

/* ── Container ───────────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px;
}

/* ── Page header ─────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}

.page-header h1 {
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}

.btn:hover { background: #252836; border-color: #3a3d50; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-sm { padding: 4px 10px; font-size: 12px; }

.btn-danger { background: transparent; border-color: #7f1d1d; color: #f87171; }
.btn-danger:hover { background: #7f1d1d; color: #fecaca; border-color: #7f1d1d; }

.btn-copied { background: #166534 !important; border-color: #166534 !important; color: #bbf7d0 !important; }

/* ── Table ───────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.table th, .table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  background: var(--bg);
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: rgba(255,255,255,0.025); }
.row-clickable { cursor: pointer; }

@keyframes rowFlash {
  0%   { background: rgba(99,102,241,.18); }
  100% { background: transparent; }
}
.row-new td { animation: rowFlash 1.2s ease-out forwards; }

/* ── Code ────────────────────────────────────────────── */
code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* ── Table helpers ───────────────────────────────────── */
.col-center { text-align: center; }
.col-actions { text-align: right; white-space: nowrap; }
.col-actions .btn { margin-left: 6px; }
.text-muted { color: var(--text-muted); }
.mono { font-family: var(--font-mono); font-size: 12px; }

/* ── Badges ──────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: var(--border);
  color: var(--text-muted);
  min-width: 24px;
  text-align: center;
}
.badge-active { background: #1e3a5f; color: #60a5fa; }
.badge-count  { background: var(--border); color: var(--text-muted); font-size: 13px; }

/* ── Route list ──────────────────────────────────────── */
.route-slug { font-family: var(--font-mono); font-size: 12px; }
.route-name {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Route detail header ─────────────────────────────── */
.back-link {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  display: block;
  margin-bottom: 6px;
}
.back-link:hover { color: var(--text); }

.route-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.route-endpoint-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.endpoint-display { font-size: 13px; padding: 4px 10px; }

.header-actions { display: flex; gap: 6px; padding-top: 28px; }

/* ── Live dot ────────────────────────────────────────── */
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74,222,128,.5); }
  50%       { box-shadow: 0 0 0 5px rgba(74,222,128,0); }
}
@keyframes dotFlash {
  0%   { background: #fff; box-shadow: 0 0 10px #4ade80; }
  100% { background: #4ade80; }
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #4ade80;
  animation: pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}
.live-dot-flash { animation: dotFlash 0.4s ease-out, pulse 2s ease-in-out 0.4s infinite; }

/* ── Stats bar ───────────────────────────────────────── */
.stats-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  font-size: 13px;
}

.empty-events-cell {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 16px !important;
  font-size: 13px;
}

/* ── Pagination ──────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
}

/* ── Method badges ───────────────────────────────────── */
.method-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.method-POST   { background: #1e3a5f; color: #60a5fa; }
.method-GET    { background: #14532d; color: #4ade80; }
.method-PUT    { background: #3b2800; color: #fb923c; }
.method-PATCH  { background: #2e1065; color: #c084fc; }
.method-DELETE { background: #450a0a; color: #f87171; }

/* ── Event inspector ─────────────────────────────────── */
.inspector-meta {
  display: flex;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 18px;
  border-right: 1px solid var(--border);
  min-width: 120px;
}
.meta-item:last-child { border-right: none; }

.meta-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.inspector-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  background: var(--border);
  color: var(--text-muted);
}
.tag-json { background: #1e3a5f; color: #60a5fa; }
.tag-raw  { background: #3b2800; color: #fb923c; }

.inspector-body { padding: 0; }

.code-block {
  margin: 0;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text);
  background: var(--code-bg);
  max-height: 500px;
  overflow-y: auto;
}

.empty-inline {
  padding: 16px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Key-value table ─────────────────────────────────── */
.kv-table-wrap { overflow-x: auto; }

.kv-table { width: 100%; border-collapse: collapse; }
.kv-table tr { border-bottom: 1px solid var(--border); }
.kv-table tr:last-child { border-bottom: none; }

.kv-key {
  padding: 7px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #c084fc;
  white-space: nowrap;
  width: 240px;
  vertical-align: top;
}

.kv-value {
  padding: 7px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  word-break: break-all;
}

/* ── Empty / error states ────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 24px;
}
.empty-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 8px;
}
.empty-state .text-muted { font-size: 13px; }

.error-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
}
.error-state h1 { font-size: 48px; margin-bottom: 16px; color: var(--text); }
.error-state p  { margin-bottom: 8px; }
.error-state .btn { margin-top: 16px; }

/* ── Modal ───────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%; max-width: 420px;
  padding: 24px;
  display: flex; flex-direction: column; gap: 16px;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; }
.modal-title  { font-size: 15px; font-weight: 600; color: var(--text); }
.modal-close  { background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-label  { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.modal-input-row { display: flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg); }
.modal-prefix { padding: 7px 10px; font-size: 12px; color: var(--text-muted); white-space: nowrap; font-family: var(--font-mono); border-right: 1px solid var(--border); }
.modal-input  { flex: 1; background: transparent; border: none; outline: none; color: var(--text); padding: 7px 10px; font-size: 13px; font-family: var(--font-mono); }
.modal-hint   { font-size: 11px; color: var(--text-muted); }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; }

/* ── Filter bar ──────────────────────────────────────── */
.filter-bar {
  display: flex; align-items: flex-end; gap: 12px;
  padding: 12px 0 16px;
  flex-wrap: wrap;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-label { font-size: 11px; color: var(--text-muted); }
.filter-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 5px 9px;
  font-size: 13px;
  outline: none;
  color-scheme: dark;
}
.filter-input:focus { border-color: var(--primary); }

/* ── Auth / Login ─────────────────────────────────────────────────────────── */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 32px 32px;
  box-shadow: 0 4px 24px rgba(0,0,0,.07);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
}

.login-brand-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 20px;
}

.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.login-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.login-field input {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}

.login-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79,70,229,.12);
}

.login-remember {
  margin-top: -2px;
}

.remember-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.remember-label input[type=checkbox] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
}

.login-btn {
  width: 100%;
  padding: 10px;
  font-size: 14px;
  margin-top: 4px;
}
