:root {
  --bg: #0b0b0c;
  --panel: #111113;
  --raise: #17171a;
  --line: #222226;
  --line-strong: #2e2e33;
  --text: #ececee;
  --muted: #8b8b93;
  --faint: #5c5c63;
  --accent: #8b9cff;
  --danger: #f2716b;
  --ok: #5fd39a;
  --radius: 8px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }

/* sign-in */
.card {
  width: 100%; max-width: 340px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 28px;
}
.card h1 { font-size: 15px; font-weight: 600; margin: 0 0 20px; }
.card p { margin: 0 0 20px; color: var(--muted); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { color: var(--muted); font-size: 12px; }
input, select {
  width: 100%; height: 34px; padding: 0 10px;
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: 6px;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
select { appearance: none; padding-right: 26px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 13px) 50%, calc(100% - 9px) 50%;
  background-size: 4px 4px; background-repeat: no-repeat; }
.error { color: var(--danger); font-size: 12px; min-height: 18px; margin: 0 0 10px; }

.btn {
  height: 32px; padding: 0 12px; border-radius: 6px;
  border: 1px solid var(--line-strong); background: var(--raise);
  cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #3c3c43; background: #1c1c20; }
.btn.primary { background: var(--text); color: #0b0b0c; border-color: var(--text); font-weight: 500; }
.btn.primary:hover { background: #fff; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--raise); }
.btn.sm { height: 26px; padding: 0 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; }

/* shell */
.shell { display: grid; grid-template-columns: 200px 1fr; min-height: 100vh; }
.side {
  border-right: 1px solid var(--line); padding: 16px 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.brand { font-weight: 600; padding: 4px 10px 18px; display: flex; gap: 8px; align-items: center; }
.brand .dot { width: 14px; height: 14px; border-radius: 4px; background: linear-gradient(135deg, var(--accent), #c79bff); }
.nav a {
  display: block; padding: 6px 10px; border-radius: 6px; text-decoration: none; color: var(--muted);
}
.nav a:hover { color: var(--text); background: var(--raise); }
.nav a.on { color: var(--text); background: var(--raise); }
.side .me { margin-top: auto; padding: 10px; border-top: 1px solid var(--line); display: grid; gap: 6px; justify-items: start; }
.side .me .btn { margin-left: -8px; }
.side .me .email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }

main { padding: 28px 32px; min-width: 0; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.head h2 { font-size: 15px; font-weight: 600; margin: 0; }
.head .tools { display: flex; gap: 8px; align-items: center; }
.head input { width: 240px; }
.crumb { color: var(--muted); text-decoration: none; }
.crumb:hover { color: var(--text); }

/* overview */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 26px; font-weight: 500; margin-top: 6px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* table */
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--faint); font-weight: 500; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #141417; }
tr.click { cursor: pointer; }
td.name { font-weight: 500; }
td .sub { color: var(--muted); font-weight: 400; }
td.actions { text-align: right; }
td select { height: 28px; width: auto; min-width: 110px; font-size: 12px; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; border: 1px solid var(--line-strong); color: var(--muted); }
.tag.ban { color: var(--danger); border-color: #5a2a28; }
.tag.you { color: var(--accent); border-color: #343c6b; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; color: var(--muted); }
.pager .btns { display: flex; gap: 6px; }

/* menu */
.menu-anchor { position: relative; display: inline-block; }
.menu {
  position: absolute; right: 0; top: 30px; z-index: 10; min-width: 160px;
  background: var(--raise); border: 1px solid var(--line-strong); border-radius: 8px; padding: 4px;
  box-shadow: 0 12px 30px rgba(0,0,0,.45); text-align: left;
}
.menu button { display: block; width: 100%; text-align: left; padding: 6px 10px; border: 0; background: none; border-radius: 5px; cursor: pointer; }
.menu button:hover { background: #222227; }
.menu button.danger { color: var(--danger); }

/* dialog */
dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--line-strong); border-radius: 12px;
  padding: 0; width: min(520px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0,0,0,.6); }
.dlg-head { padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.dlg-body { padding: 18px 20px; }
.dlg-body p { margin: 0 0 12px; color: var(--muted); }
.dlg-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.sessions { display: grid; gap: 8px; }
.session { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.session .meta { min-width: 0; }
.session .ua { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.session .sub { color: var(--muted); font-size: 12px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--raise); border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4); z-index: 50;
}
.toast.err { color: var(--danger); }

@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 16px; overflow-x: auto; }
  .brand { padding: 0 10px 0 0; }
  .nav { display: flex; gap: 2px; }
  .side .me { margin: 0 0 0 auto; border: 0; padding: 0; display: flex; align-items: center; }
  .side .me .email { display: none; }
  main { padding: 20px 16px; }
  .head input { width: 100%; }
  .head .tools { width: 100%; }
}

/* ---------- hardening additions ---------- */
.small { font-size: 12px; }
code { font: 12px/1.4 ui-monospace, "SF Mono", Menlo, monospace; color: var(--text); }
.link { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
.link:hover { color: var(--text); }
.link:disabled { opacity: .5; cursor: default; }
.alt { display: grid; gap: 12px; justify-items: center; margin-top: 14px; }
.card .alt .btn.block { width: 100%; }
.check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; margin: -2px 0 12px; cursor: pointer; }
.check input { width: 14px; height: 14px; accent-color: var(--accent); }
.captcha:empty { display: none; }
.captcha { margin-bottom: 10px; }
.card .error .link { color: var(--text); }
.card a { color: var(--text); }

.note { border: 1px solid #343c6b; background: #12152a; color: #c7cdfa; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; max-width: 720px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.panel .title { font-weight: 500; margin-bottom: 2px; }
.pk-list { display: grid; gap: 8px; margin-top: 14px; }
.pk-list:has(.session) { margin-top: 14px; }

.enrol p { color: var(--text); margin: 0 0 10px; }
.enrol .faint { color: var(--faint); }
.qr { width: 168px; height: 168px; background: #fff; border-radius: 8px; padding: 6px; display: grid; place-items: center; margin-bottom: 10px; }
.qr svg { width: 100%; height: 100%; display: block; }
.secret { user-select: all; }
.codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; margin-bottom: 10px; }
.codes code { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 5px 8px; user-select: all; }

.facts { display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); max-width: 720px; margin-bottom: 24px; }
.facts > div { display: flex; align-items: center; gap: 16px; padding: 9px 14px; border-bottom: 1px solid var(--line); min-height: 44px; }
.facts > div:last-child { border-bottom: 0; }
.facts .k { width: 90px; color: var(--faint); font-size: 12px; flex: none; }
.facts select { height: 28px; width: auto; min-width: 120px; font-size: 12px; }
h3.section { font-size: 13px; font-weight: 500; color: var(--muted); margin: 0 0 10px; }
.filters { margin-bottom: 12px; }
.filters input { max-width: 300px; }
td.trunc { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
td a { text-decoration: none; }
td a:hover { text-decoration: underline; }
.tag.on { color: var(--ok); border-color: #22533b; }
