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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0e0e10;
  color: #efeff1;
  min-height: 100vh;
}

a { color: #9147ff; text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: 'Consolas', monospace; background: #18181b; padding: 2px 6px; border-radius: 4px; font-size: 0.85em; }

/* ── Topbar ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; height: 52px;
  background: #18181b; border-bottom: 1px solid #2a2a2d;
}
.topbar-logo { font-weight: 700; font-size: 1.05rem; color: #efeff1; letter-spacing: -0.3px; text-decoration: none; }
.topbar-logo:hover { text-decoration: none; opacity: 0.85; }
.topbar-logo span { color: #9147ff; }
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 0.88rem; color: #adadb8; }
.topbar-toggle {
  display: none;
  background: none; border: 1px solid #2a2a2d; color: #efeff1;
  font-size: 1.15rem; line-height: 1; padding: 5px 11px; border-radius: 7px; cursor: pointer;
}

@media (max-width: 640px) {
  .topbar { position: relative; padding: 0 16px; }
  .topbar-toggle { display: block; }
  .topbar-right {
    display: none;
    position: absolute; top: 52px; right: 12px;
    flex-direction: column; align-items: stretch; gap: 8px;
    background: #18181b; border: 1px solid #2a2a2d; border-radius: 10px;
    padding: 12px; min-width: 180px; z-index: 100;
    box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  }
  .topbar.nav-open .topbar-right { display: flex; }
  .topbar-user { padding: 2px 4px 6px; border-bottom: 1px solid #2a2a2d; }
  .topbar-right .btn, .topbar-right .badge { text-align: center; }
}

/* ── Page container ── */
.page { max-width: 1280px; margin: 0 auto; padding: 32px 24px; }

/* ── Dashboard two-column layout ── */
.dash-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}
.dash-side {
  position: sticky;
  top: 24px;
}
@media (max-width: 900px) {
  .dash-layout { grid-template-columns: 1fr; }
  .dash-side { position: static; }
}

/* ── Cards ── */
.card {
  background: #18181b; border: 1px solid #2a2a2d; border-radius: 10px;
  padding: 20px 24px; margin-bottom: 16px;
}
.card:last-child { margin-bottom: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.card-title { font-size: 0.95rem; font-weight: 600; }
.card-sub { font-size: 0.82rem; color: #adadb8; margin-bottom: 16px; line-height: 1.5; }

/* ── Token section ── */
.token-card { border-color: #3a2d5a; }
.token-label { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: #9147ff; margin-bottom: 8px; }
.token-box {
  display: flex; align-items: center; gap: 10px;
  background: #0e0e10; border: 1px solid #2a2a2d; border-radius: 6px;
  padding: 11px 14px; font-family: monospace; font-size: 0.88rem; word-break: break-all;
}
.token-hint { font-size: 0.78rem; color: #6b6b7a; margin-top: 8px; }

/* ── Section divider inside a card ── */
.card-section { padding-top: 16px; margin-top: 16px; border-top: 1px solid #2a2a2d; }

/* ── Login page ── */
.login-wrap {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 100vh; gap: 12px; text-align: center;
}
.login-logo { font-size: 2rem; font-weight: 800; letter-spacing: -1px; }
.login-logo span { color: #9147ff; }
.login-sub { color: #adadb8; font-size: 0.95rem; margin-bottom: 12px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px; border-radius: 6px; font-size: 0.88rem;
  font-weight: 600; cursor: pointer; border: none; text-decoration: none;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; text-decoration: none; }
.btn-twitch { background: #9147ff; color: #fff; }
.btn-primary { background: #9147ff; color: #fff; }
.btn-ghost { background: transparent; color: #adadb8; border: 1px solid #3a3a3d; }
.btn-danger { background: #eb0400; color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }

/* ── Webhook table ── */
.wh-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.wh-table th { text-align: left; color: #6b6b7a; font-weight: 500; font-size: 0.75rem; letter-spacing: 0.05em; text-transform: uppercase; padding: 0 0 8px; border-bottom: 1px solid #2a2a2d; }
.wh-table td { padding: 9px 0; border-bottom: 1px solid #1e1e21; vertical-align: middle; }
.wh-table tr:last-child td { border-bottom: none; }
.wh-table td:first-child { width: 130px; font-weight: 500; color: #efeff1; white-space: nowrap; padding-right: 12px; }
.wh-url { color: #6b6b7a; word-break: break-all; font-family: monospace; font-size: 0.78rem; }
.copy-btn { margin-left: 6px; padding: 2px 8px; font-size: 0.72rem; border: 1px solid #3a3a3d; background: none; color: #adadb8; border-radius: 4px; cursor: pointer; white-space: nowrap; }
.copy-btn:hover { background: #2a2a2d; color: #efeff1; }

/* ── Badge ── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 0.72rem; font-weight: 600; }
.badge-green { background: #0d3321; color: #00c853; }
.badge-red { background: #3d0d0d; color: #eb0400; }
.badge-purple { background: #2d1a4a; color: #9147ff; }

/* ── Tabs ── */
.tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 1px solid #2a2a2d;
  margin-bottom: 20px;
}
.tab-btn {
  padding: 9px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: #6b6b7a;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.12s;
}
.tab-btn:hover { color: #efeff1; }
.tab-btn.active { color: #9147ff; border-bottom-color: #9147ff; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Form inputs (shared) ── */
.field-label { font-size: 0.78rem; color: #adadb8; display: block; margin-bottom: 4px; }
.field-input {
  width: 100%; padding: 7px 10px;
  background: #0e0e10; border: 1px solid #3a3a4a; border-radius: 6px;
  color: #fff; font-size: 0.85rem;
}
.field-input:focus { outline: none; border-color: #9147ff; }

/* ── Event log (right panel) ── */
.log-card { display: flex; flex-direction: column; }
.log-card .card-sub { margin-bottom: 10px; }
#event-log {
  font-family: 'Consolas', monospace;
  font-size: 0.75rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  max-height: calc(100vh - 180px);
  min-height: 300px;
}
.log-entry {
  padding: 6px 10px;
  background: #131316;
  border-radius: 4px;
  border-left: 2px solid var(--log-color, #3a3a4a);
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.45;
  color: #c0c0cc;
}
.log-entry-label { color: var(--log-color, #adadb8); font-weight: 600; display: block; margin-bottom: 2px; }

/* ── Admin table ── */
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.admin-table th { text-align: left; color: #6b6b7a; font-weight: 500; font-size: 0.75rem; letter-spacing: 0.05em; text-transform: uppercase; padding: 8px 10px; border-bottom: 1px solid #2a2a2d; }
.admin-table td { padding: 10px; border-bottom: 1px solid #1e1e21; vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }

/* ── Stat cards ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: #18181b; border: 1px solid #2a2a2d; border-radius: 10px; padding: 16px 20px; }
.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 0.72rem; color: #adadb8; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Alert / notice ── */
.notice { background: #1a1a2e; border: 1px solid #2a2a4d; border-radius: 8px; padding: 20px 24px; margin-bottom: 20px; }
.notice-title { font-weight: 600; margin-bottom: 6px; }
.notice-body { color: #adadb8; font-size: 0.9rem; line-height: 1.5; }

/* ── Inline form row ── */
.form-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.form-row .field-input { flex: 1; min-width: 160px; }

/* ── Admin: responsive user cards + EventSub panel ───────────────────────────── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.user-card-list { display: flex; flex-direction: column; gap: 10px; }
.user-card {
  border: 1px solid #2a2a2d;
  border-radius: 10px;
  padding: 14px 16px;
  background: #141417;
}
.user-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.user-card-info strong { font-size: 0.95rem; }
.uc-login { color: #adadb8; font-size: 0.8rem; display: block; }
.uc-email { color: #6b7280; font-size: 0.75rem; display: block; }
.uc-noemail { color: #4a4a5a; font-style: italic; }
.user-card-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.uc-until { color: #adadb8; font-size: 0.72rem; }

.user-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.user-card-actions form { display: inline; margin: 0; }

.eventsub-panel {
  margin-top: 12px;
  padding: 12px;
  background: #0e0e10;
  border: 1px solid #2a2a2d;
  border-radius: 8px;
}
.eventsub-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.es-count { font-size: 0.82rem; font-weight: 600; color: #adadb8; }
.eventsub-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 4px 12px;
  font-size: 0.76rem;
}
.es-item { display: inline-flex; align-items: center; gap: 7px; color: #c8c8d0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.es-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

@media (max-width: 640px) {
  .page { padding: 16px 12px; }
  .eventsub-list { grid-template-columns: 1fr 1fr; }
}
