:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #222d3f;
  --border: #2d3a4d;
  --border-strong: #3d4f68;
  --text: #e7ecf3;
  --muted: #8b9bb4;
  --faint: #6b7a94;
  --accent: #3d8bfd;
  --accent-muted: rgba(61, 139, 253, 0.2);
  --error: #f07178;
  --warn: #e6c07b;
  --ok: #7fd962;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --shadow-toast: 0 8px 24px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav .brand {
  font-weight: 700;
  color: var(--text);
  margin-right: auto;
}

.nav form.inline {
  display: inline;
  margin: 0;
}

main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

h1 {
  font-size: 1.4rem;
  margin: 0 0 1rem;
  font-weight: 600;
}

h2 {
  font-size: 1.05rem;
  margin: 1.5rem 0 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.flash-error {
  background: rgba(240, 113, 120, 0.15);
  border: 1px solid var(--error);
  color: var(--error);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"] {
  width: 100%;
  max-width: 28rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  margin-bottom: 0.75rem;
}

button,
.btn {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}

button.secondary,
.btn.secondary {
  background: transparent;
  color: var(--text);
}

button.ghost,
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--accent);
  padding-left: 0.35rem;
  padding-right: 0.35rem;
}

.btn-sm,
button.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.85rem;
}

button:hover,
.btn:hover {
  filter: brightness(1.08);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  text-align: left;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--border);
}

tbody tr:hover {
  background: var(--surface-2);
}

th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--border);
  color: var(--text);
}

.badge.error,
.badge.fatal {
  background: rgba(240, 113, 120, 0.25);
  color: var(--error);
}

.badge.warning {
  background: rgba(230, 192, 123, 0.25);
  color: var(--warn);
}

.badge.info {
  background: rgba(61, 139, 253, 0.25);
  color: var(--accent);
}

.badge.resolved {
  background: rgba(127, 217, 98, 0.2);
  color: var(--ok);
}

.badge.ignored {
  background: var(--border);
  color: var(--muted);
}

.badge.unresolved {
  background: var(--accent-muted);
  color: var(--accent);
}

.tags {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
}

.tags li {
  font-family: var(--mono);
  font-size: 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
}

.tag-key {
  color: var(--muted);
}

.tag-val {
  color: var(--text);
}

.breadcrumbs {
  list-style: none;
  padding: 0;
  margin: 0;
}

.breadcrumbs li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.breadcrumbs li:last-child {
  border-bottom: none;
}

.nav-breadcrumb {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.nav-breadcrumb a {
  color: var(--muted);
}

.nav-breadcrumb a:hover {
  color: var(--accent);
}

.nav-breadcrumb .sep {
  margin: 0 0.35rem;
  color: var(--faint);
}

.dsn {
  font-family: var(--mono);
  font-size: 0.85rem;
  word-break: break-all;
  background: var(--bg);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: block;
}

.dsn-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem;
}

.dsn-wrap .dsn {
  flex: 1 1 16rem;
  margin: 0;
}

.onboarding-hint {
  margin: 0.75rem 0 0;
  padding-left: 1.15rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.onboarding-hint li {
  margin-bottom: 0.25rem;
}

.meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem 1.25rem;
  margin: 0.75rem 0;
  font-size: 0.9rem;
}

.meta-grid dt {
  color: var(--faint);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 0;
}

.meta-grid dd {
  margin: 0.1rem 0 0;
  color: var(--text);
  word-break: break-word;
}

@media (max-width: 640px) {
  .meta-grid {
    grid-template-columns: 1fr;
  }
}

.stack {
  font-family: var(--mono);
  font-size: 0.85rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.stack li {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.stack li.in-app {
  background: rgba(61, 139, 253, 0.08);
  border-left: 3px solid var(--accent);
}

.stack li.lib {
  color: var(--muted);
}

.stack.stack-collapse-lib li.lib {
  display: none;
}

.stack .fn {
  color: var(--accent);
}

.stack li.lib .fn {
  color: var(--muted);
}

.stack .file {
  color: var(--muted);
  word-break: break-all;
  margin-left: 0.35rem;
}

.stack-toolbar {
  margin-bottom: 0.5rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.form-row input {
  margin-bottom: 0;
  flex: 1;
  min-width: 12rem;
}

.login-box {
  max-width: 22rem;
  margin: 3rem auto;
  padding: 1.5rem 1.35rem;
}

.login-box button {
  width: 100%;
  margin-top: 0.25rem;
}

.empty {
  color: var(--muted);
  font-style: italic;
}

.empty-state {
  text-align: left;
  padding: 0.5rem 0;
}

.empty-state .empty-title {
  font-style: normal;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.35rem;
}

.empty-state .empty-body {
  font-style: normal;
  color: var(--muted);
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0;
}

.filters input,
.filters select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.55rem;
  min-width: 8rem;
  margin-bottom: 0;
  font: inherit;
}

details summary {
  cursor: pointer;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.culprit-cell {
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.event-count {
  font-variant-numeric: tabular-nums;
}

.event-count.hot {
  font-weight: 700;
  color: var(--warn);
}

#toast-region {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(22rem, calc(100vw - 2rem));
  pointer-events: none;
}

.toast {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-toast);
  font-size: 0.9rem;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.toast.toast-out {
  opacity: 0;
}

.exception-title {
  font-size: 1.05rem;
  margin: 0.25rem 0;
}

pre.dsn {
  white-space: pre-wrap;
  overflow-x: auto;
}
