:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --border: #e1e6ee;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --ok-bg: #d1fae5;
  --ok-fg: #047857;
  --warn-bg: #fef3c7;
  --warn-fg: #92400e;
  --err-bg: #fee2e2;
  --err-fg: #b91c1c;
  --pending-bg: #e5e7eb;
  --pending-fg: #374151;
  --code-bg: #f3f4f6;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px 8px;
}
.topbar h1 { margin: 0; font-size: 22px; }
.subtitle { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.auto-refresh { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }

button {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
button:hover:not(:disabled) { background: #f3f4f6; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.danger { color: var(--err-fg); border-color: #fecaca; }
button.danger:hover:not(:disabled) { background: var(--err-bg); }

input, select {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  padding: 16px 32px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
}
.card h2 { margin: 0 0 12px; font-size: 15px; color: var(--muted); font-weight: 600; }
.badge-row { display: flex; align-items: center; gap: 10px; }
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge.warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge.err { background: var(--err-bg); color: var(--err-fg); }
.badge.pending { background: var(--pending-bg); color: var(--pending-fg); }
.latency { color: var(--muted); font-size: 12px; }
.card-detail { margin: 12px 0 0; color: var(--muted); font-size: 13px; }

.panel-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 16px 32px;
  padding: 16px 20px;
}
.panel-section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.panel-section h2 { margin: 0; font-size: 16px; }
.section-sub { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: top;
}
th { background: #1f2937; color: #fff; font-weight: 600; font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }
tr:hover td { background: #f9fafb; }

.payload-cell {
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.payload-toggle {
  align-self: flex-start;
  font-size: 12px;
  padding: 2px 8px;
}
.payload-pre {
  background: var(--code-bg);
  border-radius: 6px;
  padding: 8px;
  font-size: 12px;
  max-height: 200px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.pagination {
  display: flex;
  gap: 4px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.pagination button { padding: 4px 10px; }
.pagination button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.bulk-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.login-overlay[hidden] {
  display: none;
}
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.login-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 32px;
  width: min(420px, 90vw);
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.3);
}
.login-card h1 { margin-top: 0; font-size: 20px; }
.login-card input { width: 100%; margin: 16px 0; }
.login-actions { display: flex; gap: 12px; align-items: center; }
.error-text { color: var(--err-fg); font-size: 13px; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1f2937;
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.3);
  z-index: 60;
  max-width: 360px;
  font-size: 13px;
}
.toast.err { background: var(--err-fg); }
.toast.ok { background: var(--ok-fg); }

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