:root {
  --bg: #0b0f14; --bg2: #0f151d; --surface: #131b25; --surface2: #182230; --border: #22303f; --border2: #2d3d50;
  --text: #e6edf3; --muted: #8b9bb0; --faint: #5b6b80;
  --accent: #53fc18; --accent2: #3fd10f; --accent-ink: #062b00;
  --ban: #ff5d5d; --timeout: #ff9f43; --delete: #f3d34a; --warn: #f3d34a; --info: #4cc9ff; --good: #37d67a; --lock: #b48cff;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 14px; --sidebar: 236px; --topbar: 60px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
code, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .error { color: var(--ban); min-height: 1em; }
small { color: var(--muted); font-size: 12px; }
h1 { font-size: 20px; margin: 0 0 14px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 14px; margin: 0 0 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
::-webkit-scrollbar { width: 10px; height: 10px; } ::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 8px; border: 2px solid var(--bg); }

/* ---------- login ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(1200px 600px at 20% -10%, rgba(83,252,24,.12), transparent 60%), var(--bg); }
.login-card { width: min(420px, 92vw); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.login-logo { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; }
.login-logo img { width: 36px; height: 36px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; grid-template-rows: var(--topbar) 1fr; height: 100vh; height: 100dvh; }
.sidebar { grid-row: 1 / span 2; background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 14px 12px; gap: 10px; }
.brand { display: flex; gap: 10px; align-items: center; padding: 6px 8px 14px; }
.brand img { width: 34px; height: 34px; } .brand b { display: block; font-size: 15px; } .brand small { display: block; }
nav { display: grid; gap: 2px; }
nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--muted); font-weight: 500; }
nav a i { font-style: normal; width: 22px; text-align: center; opacity: .8; font-size: 13px; }
nav a:hover { background: var(--surface); color: var(--text); }
nav a.active { background: linear-gradient(90deg, rgba(83,252,24,.16), rgba(83,252,24,.05)); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; padding: 8px; }
.conn { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.conn span { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); box-shadow: 0 0 0 3px rgba(255,255,255,.04); }
.conn.on span { background: var(--accent); box-shadow: 0 0 10px var(--accent); } .conn.off span { background: var(--ban); }
.conn em { font-style: normal; }

.topbar { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--border); background: rgba(11,15,20,.8); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 5; }
.menu { display: none; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 12px; white-space: nowrap; cursor: default; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.pill.on .dot { background: #ff3b3b; box-shadow: 0 0 10px #ff3b3b; animation: pulse 1.6s infinite; }
.pill.on b { color: #ff6b6b; } .pill small { color: var(--muted); }
.pill.lock { cursor: pointer; } .pill.lock.on { border-color: var(--lock); background: rgba(180,140,255,.12); } .pill.lock.on b { color: var(--lock); }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .4 } }
.say { flex: 1; display: flex; gap: 8px; max-width: 640px; }
.say input { flex: 1; }
.clock { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }

.main { overflow: auto; padding: 22px 24px 40px; }
.view { display: grid; gap: 18px; max-width: 1400px; }

/* ---------- controls ---------- */
input, select, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--border2); border-radius: 10px; padding: 8px 11px; font: inherit; outline: none; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(83,252,24,.15); }
input[type=number] { width: 92px; } input[type=checkbox] { width: auto; }
textarea { resize: vertical; min-height: 64px; }
.btn { background: var(--surface2); color: var(--text); border: 1px solid var(--border2); border-radius: 10px; padding: 8px 14px; font: inherit; font-weight: 500; cursor: pointer; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: var(--accent2); transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.btn.primary:hover { background: #7bff4d; }
.btn.danger { border-color: rgba(255,93,93,.5); color: var(--ban); } .btn.danger:hover { background: rgba(255,93,93,.12); }
.btn.warn { border-color: rgba(255,159,67,.5); color: var(--timeout); } .btn.warn:hover { background: rgba(255,159,67,.12); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); } .btn.ghost:hover { background: var(--surface); color: var(--text); }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.tiny { padding: 2px 8px; font-size: 11.5px; border-radius: 7px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.toggle { position: relative; width: 40px; height: 22px; border-radius: 999px; background: var(--border2); cursor: pointer; transition: .2s; flex: none; border: none; padding: 0; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; }
.toggle.on { background: var(--accent); } .toggle.on::after { left: 21px; background: var(--accent-ink); }
.field { display: grid; gap: 4px; } .field label { font-size: 12px; color: var(--muted); }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 14px; }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: 0 1px 0 rgba(255,255,255,.02) inset; }
.card.wide { grid-column: 1 / -1; }
.stat { display: grid; gap: 4px; }
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .value.small { font-size: 18px; }
.stat .sub { font-size: 12px; color: var(--muted); }
.stat.accent .value { color: var(--accent); }
.two { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.chart { position: relative; height: 150px; }
.chart canvas { width: 100%; height: 100%; display: block; }
.chart .tip { position: absolute; pointer-events: none; background: var(--bg); border: 1px solid var(--border2); border-radius: 8px; padding: 4px 8px; font-size: 12px; transform: translate(-50%, -120%); white-space: nowrap; display: none; }
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 110px 1fr 40px; align-items: center; gap: 10px; font-size: 12.5px; }
.bar .track { height: 10px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent2); border-radius: 6px; min-width: 2px; }
.bar b { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- tables & lists ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; padding: 8px 10px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:hover td { background: rgba(255,255,255,.02); }
.table-wrap { overflow: auto; max-height: 70vh; border-radius: 10px; border: 1px solid var(--border); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; border: 1px solid var(--border2); background: var(--bg); white-space: nowrap; }
.chip.ban { color: var(--ban); border-color: rgba(255,93,93,.4); } .chip.timeout { color: var(--timeout); border-color: rgba(255,159,67,.4); }
.chip.delete { color: var(--delete); border-color: rgba(243,211,74,.4); } .chip.none { color: var(--muted); }
.chip.unban, .chip.good { color: var(--good); } .chip.lock { color: var(--lock); }
.chip.role-moderator { color: var(--info); } .chip.role-broadcaster { color: var(--ban); } .chip.role-subscriber, .chip.role-vip { color: var(--accent); }
.user-link { color: var(--text); font-weight: 600; cursor: pointer; } .user-link:hover { color: var(--accent); text-decoration: underline; }

.feed { display: flex; flex-direction: column-reverse; gap: 2px; max-height: calc(100vh - var(--topbar) - 150px); overflow: auto; padding: 4px; }
.msg { display: grid; grid-template-columns: 58px 1fr auto; gap: 10px; padding: 7px 10px; border-radius: 10px; align-items: start; animation: fade .25s; }
.msg:hover { background: var(--surface2); }
.msg.flagged { background: rgba(255,159,67,.06); box-shadow: inset 3px 0 0 var(--timeout); }
.msg.flagged.ban { background: rgba(255,93,93,.08); box-shadow: inset 3px 0 0 var(--ban); }
.msg.flagged.delete { box-shadow: inset 3px 0 0 var(--delete); background: rgba(243,211,74,.05); }
.msg.command { opacity: .75; } .msg.first .name::after { content: "NEW"; font-size: 9px; margin-left: 6px; color: var(--accent); border: 1px solid var(--accent); border-radius: 4px; padding: 0 3px; vertical-align: middle; }
.msg time { color: var(--faint); font-size: 11.5px; font-variant-numeric: tabular-nums; padding-top: 2px; }
.msg .body { min-width: 0; } .msg .name { font-weight: 600; margin-right: 6px; cursor: pointer; } .msg .name:hover { color: var(--accent); }
.msg .text { word-break: break-word; white-space: pre-wrap; }
.msg .verdict { font-size: 11.5px; margin-top: 3px; }
.msg .quick { display: none; gap: 4px; } .msg:hover .quick { display: flex; }
.msg .side { display: grid; gap: 4px; justify-items: end; }
@keyframes fade { from { opacity: 0; transform: translateY(4px) } to { opacity: 1; transform: none } }

/* ---------- filters ---------- */
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.filter-card .head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.filter-card .head b { font-size: 15px; } .filter-card.off { opacity: .6; }
.filter-card .desc, .card .desc { font-size: 12px; color: var(--muted); margin: -6px 0 12px; }
.ladder { display: grid; gap: 6px; } .ladder .step { display: grid; grid-template-columns: 130px 110px 80px auto; gap: 8px; align-items: center; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border2); font-size: 12px; }
.tag button { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0; } .tag button:hover { color: var(--ban); }
.tag.off { opacity: .45; text-decoration: line-through; }
.tag.dyn { border-color: rgba(83,252,24,.4); }
.tier-hate { box-shadow: inset 3px 0 0 var(--ban); } .tier-harassment { box-shadow: inset 3px 0 0 var(--timeout); } .tier-profanity { box-shadow: inset 3px 0 0 var(--delete); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tabs button { background: none; border: none; color: var(--muted); padding: 8px 12px; cursor: pointer; font: inherit; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
pre.result { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px; overflow: auto; font-size: 12px; margin: 0; white-space: pre-wrap; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; font-size: 13px; } .kv div:nth-child(odd) { color: var(--muted); }

/* ---------- drawer, toasts ---------- */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); background: var(--bg2); border-left: 1px solid var(--border); box-shadow: var(--shadow); z-index: 20; padding: 20px; overflow: auto; display: grid; gap: 14px; align-content: start; animation: slide .2s; }
@keyframes slide { from { transform: translateX(30px); opacity: 0 } to { transform: none; opacity: 1 } }
.drawer h1 { display: flex; justify-content: space-between; align-items: center; }
.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 30; }
.toast { background: var(--surface); border: 1px solid var(--border2); border-left: 4px solid var(--info); border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow); min-width: 260px; max-width: 380px; font-size: 13px; animation: fade .2s; }
.toast.ban { border-left-color: var(--ban); } .toast.timeout { border-left-color: var(--timeout); } .toast.delete { border-left-color: var(--delete); }
.toast.good { border-left-color: var(--good); } .toast.error { border-left-color: var(--ban); } .toast.lock { border-left-color: var(--lock); }
.toast b { display: block; }
.empty { color: var(--muted); padding: 24px; text-align: center; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 25; transform: translateX(-100%); transition: .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .menu { display: inline-block; }
  .say { display: none; }
  .main { padding: 14px 16px 30px; }
  .two { grid-template-columns: 1fr; }
  .msg { grid-template-columns: 1fr; gap: 2px; } .msg time { display: none; } .msg .quick { display: flex; }
  .ladder .step { grid-template-columns: 1fr 1fr; }
  .kv { grid-template-columns: 1fr; }
}
