:root {
  --accent: #3BA7FF;
  --bg: #070b14;
  --bg2: #0a1020;
  --panel: rgba(17, 24, 41, 0.72);
  --panel-solid: #111829;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);
  --text: #e8edf6;
  --muted: #8a97ad;
  --danger: #ff5c6c;
  --good: #46d39a;
  --warn: #ffc24b;
  --radius: 14px;
}

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

body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 80% -10%, rgba(59,167,255,0.10), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(59,167,255,0.08), transparent 55%),
    linear-gradient(180deg, var(--bg2), var(--bg));
  background-attachment: fixed;
  min-height: 100vh;
  font-size: 14px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

/* ---- Sign-in gate ---- */
.login {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(4, 7, 14, 0.85); backdrop-filter: blur(6px); z-index: 50;
}
.login-card {
  width: 360px; max-width: 90vw; background: var(--panel-solid);
  border: 1px solid var(--border-strong); border-radius: 18px; padding: 32px;
  text-align: center; box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}
.login-card .brand { justify-content: center; margin-bottom: 18px; }
.login-card .muted { margin-bottom: 4px; }
.login-card .btn { display: block; text-decoration: none; }
.login-card p + .btn { margin-top: 18px; }
.login-back { display: inline-block; margin-top: 18px; color: var(--muted); font-size: 13px; text-decoration: none; }
.login-back:hover { color: var(--text); }
.login-error { color: var(--danger); min-height: 18px; margin-top: 10px; font-size: 13px; }

/* ---- Brand ---- */
.brand { display: flex; align-items: center; gap: 11px; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: 0.2px; }
.brand-lg .brand-name { font-size: 22px; }
.logo {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  background: radial-gradient(circle at 30% 30%, var(--accent), #1a5fb4);
  box-shadow: 0 0 18px rgba(59,167,255,0.55); position: relative;
}
.logo::after {
  content: ""; position: absolute; inset: 6px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.85); border-right-color: transparent; transform: rotate(25deg);
}
.brand-lg .logo { width: 34px; height: 34px; }

/* ---- Top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 26px; border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, rgba(59,167,255,0.10), rgba(59,167,255,0.02));
  backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 16px; }
.stat-inline { color: var(--muted); font-size: 13px; }
.stat-inline b { color: var(--text); margin-left: 4px; }
.topbar-link { color: var(--muted); font-size: 13px; text-decoration: none; }
.topbar-link:hover { color: var(--text); }
.pill {
  display: inline-flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.6px; padding: 5px 11px; border-radius: 999px;
  background: rgba(70,211,154,0.12); color: var(--good); border: 1px solid rgba(70,211,154,0.25);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 8px var(--good); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.35} }

/* ---- Layout ---- */
.layout { display: flex; align-items: flex-start; gap: 22px; padding: 22px; max-width: 1500px; margin: 0 auto; }
.sidebar {
  width: 230px; flex: none; position: sticky; top: 80px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 14px; min-height: 70vh; display: flex; flex-direction: column;
}
.sidebar .brand { padding: 6px 8px 18px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 11px 13px; border: none; border-radius: 10px; cursor: pointer;
  background: transparent; color: var(--muted); font-size: 14px; font-weight: 500; transition: 0.15s;
}
.nav-item i { font-style: normal; width: 18px; text-align: center; opacity: 0.9; }
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item.active { background: rgba(59,167,255,0.14); color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; padding: 14px 8px 4px; font-size: 11px; }

.main { flex: 1; min-width: 0; }
.page { display: none; }
.page.active { display: block; animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- Cards & grids ---- */
.grid { display: grid; gap: 18px; margin-bottom: 18px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.stats { grid-template-columns: repeat(4, 1fr); }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 18px;
}
.card h2 { font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h2 { margin: 0; }

.stat { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; }
.stat-value { font-size: 30px; font-weight: 800; }

.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---- Inputs ---- */
input, textarea, select {
  width: 100%; background: rgba(0,0,0,0.25); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 12px 14px; color: var(--text); font-size: 14px;
  font-family: inherit; outline: none; transition: 0.15s; margin-bottom: 12px;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,167,255,0.18); }
textarea { min-height: 90px; resize: vertical; }
.row { display: flex; gap: 10px; align-items: stretch; }
.row input { margin-bottom: 0; }
.row .btn { white-space: nowrap; }

/* ---- Buttons ---- */
.btn {
  border: 1px solid var(--border-strong); background: rgba(255,255,255,0.03); color: var(--text);
  padding: 12px 16px; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600;
  font-family: inherit; transition: 0.15s; width: 100%;
}
.btn:hover { border-color: var(--accent); background: rgba(59,167,255,0.08); }
.btn-accent { background: #fff; color: #0a1020; border-color: #fff; }
.btn-accent:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-ghost { background: rgba(255,255,255,0.03); }
.btn-danger { background: rgba(255,92,108,0.12); border-color: rgba(255,92,108,0.4); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { width: auto; padding: 8px 13px; font-size: 13px; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.5px; padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.table td { padding: 12px; border-bottom: 1px solid var(--border); }
.table tr:hover td { background: rgba(255,255,255,0.02); }
.table .pname { font-weight: 600; }

.tag { display: inline-block; padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 700;
  background: rgba(59,167,255,0.14); color: var(--accent); margin: 2px 3px 2px 0; }
.vl-pill { font-weight: 800; }
.vl-low { color: var(--good); } .vl-mid { color: var(--warn); } .vl-high { color: var(--danger); }

/* ---- Feed ---- */
.feed { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.feed-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: rgba(0,0,0,0.22); border: 1px solid var(--border); border-radius: 10px; font-size: 13px;
}
.feed-item .fi-check { font-weight: 700; color: var(--warn); }
.feed-item .fi-player { font-weight: 600; }
.feed-item .fi-time { margin-left: auto; color: var(--muted); font-size: 12px; }
.feed-empty { color: var(--muted); padding: 14px; text-align: center; }

/* ---- Checks grid ---- */
.checks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.check-card {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px; background: rgba(0,0,0,0.22); border: 1px solid var(--border); border-radius: 12px;
}
.check-meta { display: flex; flex-direction: column; gap: 3px; }
.check-meta .cn { font-weight: 700; }
.check-meta .cc { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ---- Toggle switch ---- */
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; margin: 0; }
.slider { position: absolute; inset: 0; background: rgba(255,255,255,0.14); border-radius: 999px; cursor: pointer; transition: 0.2s; }
.slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.2s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ---- Code editor ---- */
.code {
  font-family: "JetBrains Mono", "Consolas", monospace; font-size: 12.5px; line-height: 1.55;
  min-height: 420px; white-space: pre; tab-size: 2;
}

/* ---- Bar ---- */
.bar { height: 14px; background: rgba(0,0,0,0.3); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #1a5fb4); transition: width 0.4s; }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel-solid); border: 1px solid var(--border-strong); color: var(--text);
  padding: 12px 20px; border-radius: 12px; opacity: 0; pointer-events: none; transition: 0.25s; z-index: 60;
  box-shadow: 0 18px 50px rgba(0,0,0,0.5); font-size: 14px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(255,92,108,0.5); }

/* ---- Connection pill (offline state) ---- */
.pill.offline { background: rgba(255,92,108,0.12); color: var(--danger); border-color: rgba(255,92,108,0.3); }
.pill.offline .dot { background: var(--danger); box-shadow: 0 0 8px var(--danger); }

/* ---- Toolbars / search ---- */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.search {
  width: 220px; max-width: 46vw; margin-bottom: 0;
  padding: 8px 12px; font-size: 13px; border-radius: 9px;
}

/* ---- Sortable table headers ---- */
.th-sort { cursor: pointer; user-select: none; white-space: nowrap; }
.th-sort:hover { color: var(--text); }
.th-sort .caret { font-size: 9px; opacity: 0.45; margin-left: 2px; }
.th-sort.active { color: var(--text); }
.th-sort.active .caret { opacity: 1; color: var(--accent); }

/* ---- Filter chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  padding: 6px 13px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: rgba(255,255,255,0.03); color: var(--muted); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: 0.15s; width: auto;
}
.chip:hover { color: var(--text); border-color: var(--accent); }
.chip.active { background: rgba(59,167,255,0.14); color: #fff; border-color: var(--accent); }

/* ---- VL bars (top violators + player modal) ---- */
.vlbars { display: flex; flex-direction: column; gap: 9px; }
.vlbar-row { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.vlbar-name { width: 120px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vlbar-name.clickable { cursor: pointer; }
.vlbar-row[data-player]:hover .vlbar-name.clickable { color: var(--accent); }
.vlbar-track { flex: 1; height: 8px; background: rgba(0,0,0,0.3); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.vlbar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #1a5fb4); border-radius: 999px; }
.vlbar-val { width: 38px; text-align: right; flex: none; font-weight: 800; }

/* ---- Checks: per-category groups ---- */
.check-group { margin-bottom: 20px; }
.check-group:last-child { margin-bottom: 0; }
.group-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.group-name { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; }
.group-name .muted { text-transform: none; letter-spacing: 0; margin-left: 4px; }
.group-actions { display: flex; gap: 8px; }

/* ---- Player detail modal ---- */
.modal {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(4, 7, 14, 0.7); backdrop-filter: blur(4px); z-index: 55; padding: 20px;
}
.modal-card {
  width: 480px; max-width: 94vw; background: var(--panel-solid);
  border: 1px solid var(--border-strong); border-radius: 18px; padding: 26px;
  position: relative; box-shadow: 0 30px 80px rgba(0,0,0,0.55);
}
.modal-close {
  position: absolute; top: 12px; right: 14px; width: auto; padding: 4px 8px;
  background: none; border: none; color: var(--muted); font-size: 16px; cursor: pointer;
}
.modal-close:hover { color: var(--text); background: none; border: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-meta { color: var(--muted); font-size: 13px; display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 20px; }
.modal-meta b { color: var(--text); font-weight: 600; }
.modal-sub { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); margin-bottom: 12px; }
.modal-actions { display: flex; gap: 10px; margin-top: 22px; }

@media (max-width: 900px) {
  .grid.two, .grid.stats { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .layout { padding: 14px; }
  .topbar { padding: 12px 16px; }
  .topbar-right { gap: 10px; }
}
