:root {
  --bg: #0b0e14;
  --bg-soft: #131822;
  --bg-card: #171d29;
  --border: #232b3a;
  --text: #dde3f0;
  --text-dim: #8b95ab;
  --accent: #cd412b;
  --accent-soft: #e2694f;
  --ok: #3fb950;
  --warn: #d29922;
  --err: #f85149;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

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

.loading { padding: 4rem; text-align: center; color: var(--text-dim); }

/* ---------- layout ---------- */

header.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}

.brand { font-weight: 700; font-size: 1.1rem; letter-spacing: 0.02em; }
.brand span { color: var(--accent); }

nav.tabs { display: flex; gap: 0.35rem; flex-wrap: wrap; }

nav.tabs button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.92rem;
}

nav.tabs button.active,
nav.tabs button:hover {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text);
}

.spacer { flex: 1; }

.user-chip { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; }
.user-chip img { width: 28px; height: 28px; border-radius: 50%; }

main { padding: 1.25rem; max-width: 1180px; margin: 0 auto; }

/* ---------- components ---------- */

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

.card h2 { margin: 0 0 0.75rem; font-size: 1.05rem; }
.card h3 { margin: 1.25rem 0 0.5rem; font-size: 0.95rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

.row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.row.between { justify-content: space-between; }

button, .btn {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
}

button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--accent-soft); }
button.danger { border-color: var(--err); color: var(--err); }
button.small { padding: 0.2rem 0.55rem; font-size: 0.82rem; }

input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  width: 100%;
}

input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); }

label.field { display: block; margin-bottom: 0.7rem; }
label.field > span { display: block; font-size: 0.82rem; color: var(--text-dim); margin-bottom: 0.25rem; }

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.76rem;
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.badge.err { color: var(--err); border-color: var(--err); }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 500; font-size: 0.8rem; text-transform: uppercase; }
td.center, th.center { text-align: center; }

.muted { color: var(--text-dim); font-size: 0.87rem; }
.mono { font-family: Consolas, "SF Mono", monospace; font-size: 0.85rem; }

.toast-host { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 100; }

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  max-width: 340px;
  font-size: 0.88rem;
}

.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }

.login-hero { max-width: 460px; margin: 12vh auto; text-align: center; }
.login-hero h1 { font-size: 2rem; margin-bottom: 0.4rem; }
.login-hero p { color: var(--text-dim); }

.event-list { max-height: 340px; overflow-y: auto; }
.event-list li { list-style: none; padding: 0.35rem 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.event-list ul { padding: 0; margin: 0; }

.switch-cell { cursor: pointer; user-select: none; font-size: 1.05rem; }

.scroll-x { overflow-x: auto; }

@media (max-width: 640px) {
  main { padding: 0.85rem; }
  header.topbar { padding: 0.6rem 0.85rem; }
  .card { padding: 0.85rem; }
}
