:root {
  --bg: #0e0e10;
  --panel: #18181b;
  --raised: #1f1f23;
  --hover: #26262c;
  --border: #2f2f35;
  --text: #efeff1;
  --muted: #adadb8;
  --faint: #6d6d79;
  --purple: #9146ff;
  --purple-hi: #a970ff;
  --purple-dk: #772ce8;
  --purple-glow: rgba(145, 70, 255, .35);
  --live: #eb0400;
  --green: #00c853;
  --amber: #ffb31a;
  --cyan: #1fd6ff;
  --pink: #ff5ec4;
  --radius: 8px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 Inter, "Segoe UI", system-ui, sans-serif; }
body { overflow: hidden; }
::selection { background: var(--purple); color: #fff; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #3a3a43; border-radius: 10px; border: 2px solid var(--panel); }
::-webkit-scrollbar-track { background: transparent; }
svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
code { background: var(--raised); border: 1px solid var(--border); padding: 1px 6px; border-radius: 4px; font-size: 12px; color: var(--purple-hi); }
h1, h2 { margin: 0; }
h2 { font-size: 16px; font-weight: 700; }
p { margin: 6px 0 12px; }
.muted { color: var(--muted); }
.small-text { font-size: 12px; }
[hidden] { display: none !important; }

.app { display: grid; grid-template-columns: 240px 1fr; height: 100vh; }

/* Sidebar */
.sidebar { background: var(--panel); border-right: 1px solid #000; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.brand { display: flex; gap: 10px; align-items: center; padding: 16px 16px 14px; border-bottom: 1px solid var(--border); }
.brand-icon { width: 34px; height: 34px; filter: drop-shadow(0 0 10px var(--purple-glow)); }
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: -.2px; }
.brand-sub { font-size: 11px; color: var(--faint); }
nav { padding: 8px 8px 10px; display: flex; flex-direction: column; gap: 1px; flex: none; }
.nav-group { padding: 12px 10px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--faint); }
nav button { display: flex; align-items: center; gap: 12px; padding: 8px 10px; flex: none; background: none; border: 0; color: var(--muted); font: inherit; font-weight: 600; border-radius: 6px; cursor: pointer; text-align: left; position: relative; }
nav button:hover { background: var(--hover); color: var(--text); }
nav button.active { background: var(--raised); color: var(--text); }
nav button.active::before { content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--purple); box-shadow: 0 0 12px var(--purple); }
nav button.active svg { color: var(--purple-hi); }
.nav-badge { margin-left: auto; background: var(--live); color: #fff; font-size: 11px; padding: 0 6px; border-radius: 10px; font-weight: 700; }
.side-section-title { padding: 12px 18px 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--faint); }
.side-fill { flex: 1 0 0; }
.side-ch { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.side-ch:hover { background: var(--hover); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; flex: none; position: relative; }
.avatar.lg { width: 46px; height: 46px; font-size: 18px; }
.avatar.on::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; background: var(--green); border: 2px solid var(--panel); }
.side-ch .name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-ch .sub { font-size: 11px; color: var(--faint); }
.sidebar-foot { position: sticky; bottom: 0; z-index: 2; background: var(--panel); border-top: 1px solid var(--border); padding: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bot-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; min-width: 0; }
.bot-chip .bot-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.warn { background: var(--amber); }
.dot.live { background: var(--live); box-shadow: 0 0 8px var(--live); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* Main */
main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: radial-gradient(1200px 500px at 80% -200px, rgba(145,70,255,.10), transparent 60%), var(--bg); }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; border-bottom: 1px solid var(--border); background: rgba(14,14,16,.7); backdrop-filter: blur(8px); }
.topbar h1 { font-size: 20px; font-weight: 800; letter-spacing: -.3px; }
.top-right { display: flex; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 99px; background: var(--raised); border: 1px solid var(--border); font-size: 12px; font-weight: 600; }
.pill.muted { color: var(--muted); }
.update-banner { margin: 12px 24px 0; padding: 10px 14px; border-radius: var(--radius); background: linear-gradient(90deg, var(--purple-dk), var(--purple)); font-weight: 600; }
.page { display: none; flex: 1; overflow-y: auto; padding: 20px 24px 28px; animation: fade .18s ease; }
.page.active { display: flex; flex-direction: column; gap: 16px; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.center { justify-content: center; }
.gap-top { margin-top: 14px; }

/* Inputs & buttons */
input, select, textarea { background: var(--bg); color: var(--text); border: 2px solid var(--border); border-radius: 6px; padding: 8px 10px; font: inherit; outline: none; transition: border-color .15s, box-shadow .15s; }
input:hover, select:hover, textarea:hover { border-color: #45454f; }
input:focus, select:focus, textarea:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(145,70,255,.2); }
input { flex: 1; min-width: 180px; }
input.tiny { width: 56px; min-width: 0; flex: none; text-align: center; margin-left: 6px; }
textarea { width: 100%; resize: vertical; min-height: 64px; }
.btn { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 6px; padding: 9px 16px; font: inherit; font-weight: 700; cursor: pointer; transition: background .15s, transform .05s, box-shadow .15s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--purple); color: #fff; }
.btn.primary:hover { background: var(--purple-dk); box-shadow: 0 0 18px var(--purple-glow); }
.btn.secondary { background: #2f2f35; color: var(--text); }
.btn.secondary:hover { background: #3a3a43; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.danger { background: transparent; color: #ff6b6b; }
.btn.danger:hover { background: rgba(235,4,0,.15); }
.btn.small { padding: 6px 10px; font-size: 12px; }
.link { background: none; border: 0; color: var(--purple-hi); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }
.link:hover { text-decoration: underline; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; position: relative; overflow: hidden; }
.stat::after { content: ""; position: absolute; inset: auto -20px -40px auto; width: 90px; height: 90px; border-radius: 50%; background: var(--c); opacity: .12; filter: blur(4px); }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat .label svg { width: 15px; height: 15px; color: var(--c); }
.stat .value { font-size: 28px; font-weight: 800; letter-spacing: -.5px; margin-top: 4px; }

/* Feed */
.feed { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; padding-right: 4px; }
.ev { display: flex; gap: 12px; align-items: center; padding: 10px 12px; background: var(--raised); border-radius: 6px; border-left: 3px solid var(--c); animation: pop .35s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.ev .ico { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--c); flex: none; }
.ev .txt { flex: 1; min-width: 0; }
.ev .txt b { color: var(--c); }
.ev .meta { font-size: 11px; color: var(--faint); }
.ev .test { font-size: 10px; text-transform: uppercase; font-weight: 800; color: var(--faint); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; margin-left: 6px; }
.empty { color: var(--faint); padding: 24px; text-align: center; border: 1px dashed var(--border); border-radius: 6px; }

/* Setup */
.setup-card { border-color: var(--purple); box-shadow: 0 0 0 1px var(--purple), 0 0 30px rgba(145,70,255,.15); }
.checklist { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 10px; }
.checklist li { display: flex; align-items: center; gap: 10px; }
.check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; flex: none; }
.checklist li.done .check { background: var(--purple); border-color: var(--purple); }
.checklist li.done .check::after { content: "✓"; font-size: 12px; font-weight: 800; }
.checklist li.done { color: var(--muted); }
.checklist li.done .link { display: none; }
.steps { padding-left: 20px; color: var(--muted); }
.steps li { margin-bottom: 6px; }
.steps b, .steps i { color: var(--text); }

/* Channels */
.channel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.ch-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: border-color .15s, transform .15s; }
.ch-card:hover { border-color: #45454f; transform: translateY(-2px); }
.ch-banner { height: 54px; background: linear-gradient(120deg, var(--a), var(--b)); position: relative; }
.ch-body { padding: 0 16px 16px; margin-top: -24px; position: relative; }
.ch-body .avatar { border: 3px solid var(--panel); }
.ch-name { font-weight: 800; font-size: 16px; margin-top: 6px; display: flex; align-items: center; gap: 8px; }
.ch-name a { color: inherit; text-decoration: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 4px; background: var(--raised); color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.chip.ok { color: #6cffa9; background: rgba(0,200,83,.12); }
.chip.purple { color: var(--purple-hi); background: rgba(145,70,255,.15); }
.chip.warn { color: var(--amber); background: rgba(255,179,26,.12); }
.mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0 12px; }
.mini-stats div { background: var(--raised); border-radius: 6px; padding: 6px; text-align: center; }
.mini-stats b { display: block; font-size: 15px; }
.mini-stats span { font-size: 10px; color: var(--faint); text-transform: uppercase; font-weight: 700; }

/* Chat */
.chat-card { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 0; overflow: hidden; }
#page-chat.active { min-height: 0; }
.tabs { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--border); overflow-x: auto; flex: none; }
.tab { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 700; padding: 8px 12px 10px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--purple-hi); border-bottom-color: var(--purple); }
.chat-list { flex: 1; overflow-y: auto; padding: 10px 6px; min-height: 0; }
.chat-list.compact { max-height: 420px; padding: 0; }
.msg { padding: 4px 12px; border-radius: 4px; line-height: 1.55; word-wrap: break-word; }
.msg:hover { background: var(--raised); }
.msg .time { color: var(--faint); font-size: 11px; margin-right: 6px; }
.msg .chan { font-size: 11px; color: var(--faint); background: var(--raised); border-radius: 3px; padding: 0 5px; margin-right: 6px; }
.msg .badge { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 3px; font-size: 11px; font-weight: 800; margin-right: 3px; vertical-align: -3px; color: #fff; }
.badge.b { background: #e91916; } .badge.m { background: #00ad03; } .badge.v { background: #e005b9; } .badge.s { background: var(--purple); } .badge.bot { background: #1f69ff; }
.msg .user { font-weight: 700; }
.msg.self { background: rgba(145,70,255,.07); }
.msg.cmd .body { color: var(--purple-hi); }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: var(--panel); flex: none; }
.chat-input select { width: 160px; }

/* Commands */
.cmd-table { display: flex; flex-direction: column; gap: 6px; }
.cmd-row { display: grid; grid-template-columns: 170px 1fr 100px 160px 40px; gap: 8px; align-items: center; }
.cmd-row select.c-perm { width: 100%; min-width: 0; padding: 8px 6px; }
.cmd-row.head { color: var(--faint); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; padding: 0 2px; }
.cmd-row input { min-width: 0; width: 100%; }
.cmd-row { align-items: start; }
.c-resps { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.c-reply { position: relative; }
.c-rm { display: none; position: absolute; right: 5px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; padding: 0; border: 0; border-radius: 4px; background: rgba(255,255,255,.06); color: var(--faint); cursor: pointer; font-size: 11px; }
.c-rm:hover { background: rgba(255,90,90,.18); color: #ff8a8a; }
.c-resps.multi .c-rm { display: block; }
.c-resps.multi .c-resp { padding-right: 32px; }
.c-addreply { align-self: flex-start; background: none; border: 1px dashed var(--border); color: var(--faint); border-radius: 5px; padding: 2px 9px; font: inherit; font-size: 11px; font-weight: 700; cursor: pointer; }
.c-addreply:hover { color: var(--text); border-color: var(--purple); }
.prefixed { position: relative; }
.prefixed span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--purple-hi); font-weight: 700; }
.prefixed input { padding-left: 24px; }
.icon-btn { background: none; border: 0; color: var(--faint); cursor: pointer; border-radius: 6px; padding: 6px; display: grid; place-items: center; }
.icon-btn:hover { color: #ff6b6b; background: rgba(235,4,0,.12); }

/* Toggle switch */
.switch { position: relative; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; background: #3a3a43; border-radius: 22px; transition: background .2s; cursor: pointer; }
.switch i::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; }
.switch input:checked + i { background: var(--purple); box-shadow: 0 0 12px var(--purple-glow); }
.switch input:checked + i::after { transform: translateX(18px); }
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; cursor: pointer; }

/* Alerts */
.alert-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.alert-card { background: var(--panel); border: 1px solid var(--border); border-top: 3px solid var(--c); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.alert-card.off { opacity: .6; }
.alert-top { display: flex; align-items: center; gap: 10px; }
.alert-top .ico { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--c); }
.alert-top h3 { margin: 0; font-size: 15px; flex: 1; }
.vars { font-size: 11px; color: var(--faint); }

/* Logs */
.logs { font: 12px/1.6 "Cascadia Code", Consolas, monospace; max-height: calc(100vh - 160px); overflow-y: auto; }
.log { display: flex; gap: 10px; padding: 2px 4px; border-radius: 3px; }
.log:hover { background: var(--raised); }
.log .t { color: var(--faint); }
.log .l { width: 44px; font-weight: 700; text-transform: uppercase; }
.log.ok .l { color: var(--green); } .log.info .l { color: var(--cyan); } .log.warn .l { color: var(--amber); } .log.error .l { color: #ff6b6b; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 50; animation: fade .15s; }
.modal-box { width: min(480px, 92vw); background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 26px; text-align: center; box-shadow: 0 0 0 1px rgba(145,70,255,.4), 0 30px 80px rgba(0,0,0,.6), 0 0 60px rgba(145,70,255,.2); display: flex; flex-direction: column; gap: 14px; }
.code { font: 800 38px/1 "Cascadia Code", Consolas, monospace; letter-spacing: 8px; padding: 18px; background: var(--bg); border: 2px dashed var(--purple); border-radius: 10px; color: var(--purple-hi); text-shadow: 0 0 20px var(--purple-glow); user-select: all; }
.waiting { display: flex; justify-content: center; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--purple); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toasts */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--raised); border: 1px solid var(--border); border-left: 4px solid var(--purple); padding: 10px 14px; border-radius: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.5); max-width: 360px; animation: pop .3s; font-weight: 500; }
.toast.error { border-left-color: var(--live); }
.toast.ok { border-left-color: var(--green); }

@media (max-width: 860px) {
  .app { grid-template-columns: 72px 1fr; }
  .brand div, nav button { font-size: 0; } nav button { justify-content: center; }
  .side-section-title, .side-ch .name, .side-ch .sub, .bot-chip .bot-name, .nav-group { display: none; }
  .subtabs-row { flex-direction: column; align-items: stretch; }
  .cmd-row { grid-template-columns: 1fr 1fr; }
}

/* Accounts */
#accounts { display: flex; flex-direction: column; gap: 8px; }
.acct { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--raised); border: 1px solid var(--border); border-radius: 8px; }
.acct.is-bot { border-color: var(--purple); box-shadow: 0 0 16px rgba(145,70,255,.15); }
.acct-info { flex: 1; min-width: 0; }
.acct-info b { margin-right: 8px; }

.toggle-mini { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.toggle-mini .switch { width: 34px; height: 19px; }
.toggle-mini .switch i::after { width: 13px; height: 13px; }
.toggle-mini .switch input:checked + i::after { transform: translateX(15px); }

.invite-link { font: 600 13px/1.4 "Cascadia Code", Consolas, monospace; padding: 14px; background: var(--bg); border: 2px dashed var(--purple); border-radius: 10px; color: var(--purple-hi); word-break: break-all; user-select: all; }

/* Per-channel commands */
.cmd-card { padding: 0; overflow: hidden; }
.cmd-body { padding: 18px; }
.tab-count { margin-left: 6px; font-size: 11px; background: var(--raised); color: var(--muted); padding: 0 6px; border-radius: 10px; }
.tab.active .tab-count { background: rgba(145,70,255,.2); color: var(--purple-hi); }
.sub-head { font-size: 14px; margin: 22px 0 2px; }
#global-toggles { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.gt-row { display: grid; grid-template-columns: 150px 1fr auto; gap: 12px; align-items: center; padding: 8px 12px; background: var(--raised); border-radius: 6px; }
.gt-row .gt-resp { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gt-row.overridden { opacity: .7; }

/* Real profile pictures */
.avatar { overflow: visible; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar.on::after { z-index: 1; }
.ch-followers { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-top: 2px; }
.ch-followers svg { width: 14px; height: 14px; color: #ff5ec4; }
.ch-followers b { color: var(--text); }

/* ---------- Analytics ---------- */
.an-filters { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; }
.an-filters select { min-width: 190px; }
.seg { display: inline-flex; background: var(--bg); border: 2px solid var(--border); border-radius: 8px; padding: 2px; }
.seg button { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 700; padding: 6px 14px; border-radius: 5px; cursor: pointer; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--purple); color: #fff; }
.an-nav { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; }
.an-nav span { min-width: 210px; text-align: center; }
.nav-arrow { font-size: 22px; line-height: 1; width: 32px; height: 32px; color: var(--muted); }
.nav-arrow:hover { color: var(--text); background: var(--hover); }
.nav-arrow:disabled { opacity: .3; cursor: default; background: none; }
.an-note { padding: 0 4px; }
.kpi-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(225px, 1fr)); gap: 14px; }
.kpi-group { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi-group h3 { margin: 0 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--faint); }
.kpi { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border); cursor: pointer; border-radius: 4px; }
.kpi:first-of-type { border-top: 0; }
.kpi:hover .kpi-label { color: var(--text); }
.kpi.selected .kpi-label { color: var(--purple-hi); }
.kpi-label { color: var(--muted); font-weight: 600; font-size: 13px; }
.kpi-right { text-align: right; }
.kpi-value { font-size: 20px; font-weight: 800; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.kpi-delta { display: block; font-size: 11px; font-weight: 700; color: var(--faint); }
.kpi-delta.up { color: #6cffa9; } .kpi-delta.down { color: #ff8a8a; }
.chart-wrap { position: relative; height: 300px; }
.chart-wrap svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart-wrap .grid { stroke: var(--border); stroke-width: 1; }
.chart-wrap .axis-label { fill: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-wrap .bar { fill: #a970ff; pointer-events: none; }
.chart-wrap .bar.dim { opacity: .35; }
.chart-wrap .hit { fill: transparent; cursor: crosshair; }
.chart-wrap .hit:hover + .bar, .chart-wrap .bar.hover { fill: #bf94ff; }
.chart-tip { position: absolute; pointer-events: none; background: var(--raised); border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; font-size: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.5); white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); z-index: 5; }
.chart-tip b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
.chart-empty { height: 100%; display: grid; place-items: center; color: var(--faint); border: 1px dashed var(--border); border-radius: 6px; text-align: center; padding: 20px; }
.an-table-wrap { overflow-x: auto; }
.an-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.an-table th { text-align: right; color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.an-table td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.an-table th:first-child, .an-table td:first-child { text-align: left; }
.an-table tr:hover td { background: var(--raised); }
.an-table .chan-cell { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.an-table .chan-cell .avatar { width: 24px; height: 24px; font-size: 11px; }
.live-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--live); color: #fff; font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 4px; text-transform: uppercase; }
.ch-live { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--muted); margin: 4px 0 2px; }

.problem-banner { margin: 12px 24px 0; padding: 10px 14px; border-radius: var(--radius); background: rgba(255,179,26,.12); border: 1px solid rgba(255,179,26,.45); color: #ffd27a; font-weight: 600; }
.problem-banner .link { color: #fff; text-decoration: underline; margin-left: 6px; }
.problem-text { color: #ffd27a; }
.secret-box { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.secret-box summary { cursor: pointer; font-weight: 700; }
.secret-box[open] summary { margin-bottom: 4px; }

/* Streamer portal settings */
#portal-body.off { opacity: .55; }
.radio-row { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.radio { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; background: var(--raised); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.radio:has(input:checked) { border-color: var(--purple); box-shadow: 0 0 14px rgba(145,70,255,.15); }
.radio input { margin-top: 3px; accent-color: var(--purple); width: auto; min-width: 0; flex: none; }
.radio span { display: flex; flex-direction: column; gap: 2px; }
.radio small { color: var(--muted); font-size: 12px; line-height: 1.45; }
.portal-status { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; flex-wrap: wrap; word-break: break-all; }
.editor-box { margin-top: 20px; display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 14px; border: 1px solid rgba(145,70,255,.45); background: rgba(145,70,255,.07); border-radius: 8px; }
.editor-box p { margin: 2px 0 0; }

/* System card */
.sys-backups { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
#sys-backup-list { display: flex; flex-direction: column; gap: 4px; max-height: 190px; overflow-y: auto; }
.bk-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px; background: var(--raised); font-size: 13px; }

/* Spam-bot shield card */
.shield-card { display: flex; flex-direction: column; gap: 12px; border-top: 3px solid var(--purple); }
.shield-card.off > :not(.mod-head) { opacity: .45; }
.sh-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.sh-item { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; padding: 7px 10px; background: var(--raised); border-radius: 6px; font-size: 13px; }
.sh-item .tag { font-size: 10px; font-weight: 800; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; background: rgba(235,4,0,.2); color: #ff8a8a; }
.sh-item .tag.t { background: rgba(255,179,26,.15); color: var(--amber); }
.sh-item .tag.u { background: var(--hover); color: var(--muted); }
.sh-item .msg { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.sh-item .msg b { color: var(--text); margin-right: 6px; }

/* Extras page */
#ex-timers { display: flex; flex-direction: column; gap: 8px; }
.ex-timer { display: grid; grid-template-columns: 1fr auto auto auto auto; gap: 10px; align-items: center; padding: 10px 12px; background: var(--raised); border-radius: 8px; }
.ex-timer input.t-msg { min-width: 0; }
.ex-timer label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.ex-timer input[type=number] { width: 62px; min-width: 0; flex: none; padding: 5px 8px; }
#ex-so-msg { width: 100%; }
@media (max-width: 1100px) { .ex-timer { grid-template-columns: 1fr 1fr; } .ex-timer input.t-msg { grid-column: 1 / -1; } }

/* Moderation page */
.mod-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1000px) { .mod-grid { grid-template-columns: 1fr; } }
.mod-rule { display: flex; flex-direction: column; gap: 10px; border-top: 3px solid var(--border); }
.mod-rule.on { border-top-color: var(--purple); }
.mod-rule:not(.on) > :not(.mod-head) { opacity: .45; pointer-events: none; }
.mod-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.mod-head h3 { margin: 0 0 2px; font-size: 15px; }
.m-field { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--muted); font-weight: 600; }
.m-field input[type=number] { width: 68px; min-width: 0; flex: none; padding: 5px 8px; }
.m-field select { width: auto; }

/* Donation link setting */
.dono-set { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; }

/* Portal settings extras, approvals, per-channel alerts */
.portal-extra { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.portal-extra select { width: auto; min-width: 200px; }
.pending-card { border-color: var(--amber); box-shadow: 0 0 0 1px rgba(255,179,26,.25); }
#pending-list { display: flex; flex-direction: column; gap: 8px; }
.pending-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--raised); border-radius: 8px; flex-wrap: wrap; }
.pending-info { flex: 1; min-width: 160px; display: flex; flex-direction: column; }
.alerts-chan-opts { margin-top: 12px; padding-top: 6px; border-top: 1px solid var(--border); }
.badge-custom { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; color: var(--purple-hi); background: rgba(145,70,255,.16); padding: 2px 6px; border-radius: 4px; vertical-align: 2px; }

/* ---------- leaderboards (analytics) ---------- */
.lead-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.lead { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.lead h3 { margin: 0 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--faint); }
.lead ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lead li { display: flex; align-items: center; gap: 12px; padding: 7px 10px; background: var(--raised); border-radius: 6px; }
.lead .medal { font-size: 18px; width: 24px; text-align: center; }
.lead .nm { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead .v { font-weight: 800; font-variant-numeric: tabular-nums; }
.lead .v small { color: var(--faint); font-weight: 600; margin-left: 4px; }
.lead .none { color: var(--faint); font-size: 13px; padding: 6px 0; }
.lead .note { margin-top: 10px; font-size: 12px; color: var(--faint); }

/* ---------- usage ---------- */
.us-adopt { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 8px 28px; }
.us-bar { display: grid; grid-template-columns: 170px 1fr 82px; gap: 12px; align-items: center; font-size: 13px; }
.us-l { font-weight: 600; color: var(--muted); }
.us-track { height: 8px; background: var(--raised); border-radius: 8px; overflow: hidden; }
.us-track i { display: block; height: 100%; background: linear-gradient(90deg, var(--purple), #ff5ec4); border-radius: 8px; }
.us-v { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.us-v small { color: var(--faint); font-weight: 600; }
.us-table th.us-th { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; font-size: 10.5px; padding: 8px 4px; height: 175px; text-align: left; }
.us-table td { text-align: center; }
.us-table td:first-child { text-align: left; }
.us-ok { color: #6cffa9; font-weight: 800; }
.us-no { color: var(--faint); }

/* ---------- feedback ---------- */
.fbk-list { display: flex; flex-direction: column; gap: 8px; }
.fbk { display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: start; padding: 12px 14px; background: var(--raised); border-radius: 8px; border-left: 3px solid transparent; }
.fbk.unread { border-left-color: var(--purple); background: linear-gradient(90deg, rgba(145,70,255,.1), var(--raised) 40%); }
.fbk-ico { font-size: 20px; text-align: center; }
.fbk-meta { font-size: 12px; margin-bottom: 4px; }
.fbk-text { white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.fbk-acts { display: flex; gap: 4px; align-items: center; }

/* ---------- command gallery ---------- */
.gal-box { width: min(980px, 94vw); max-height: 88vh; text-align: left; gap: 14px; }
.gal-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.gal-x { font-size: 16px; color: var(--muted); }
.gal-x:hover { color: var(--text); background: var(--hover); }
.gal-tools { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.gal-tools input { flex: 1; min-width: 160px; }
.gal-grid { overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; padding: 2px; }
.gal-item { background: var(--raised); border: 1px solid var(--border); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.gal-item.have { opacity: .6; }
.gal-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gal-top code { font-size: 14px; font-weight: 800; border: 0; }
.gal-sample { font-size: 12px; color: var(--faint); background: var(--bg); border-radius: 6px; padding: 8px 10px; flex: 1; }
.gal-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* ---------- viewer lookup (panel) ---------- */
#page-viewers .row input { flex: 1; }
.vw-cols { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.vw-results { display: flex; flex-direction: column; gap: 2px; max-height: 520px; overflow-y: auto; }
.vw-r { all: unset; box-sizing: border-box; display: flex; flex-direction: column; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.vw-r:hover { background: var(--raised); }
.vw-r small { font-size: 11px; }
#vw-card { display: flex; flex-direction: column; gap: 12px; }
.vw-top { display: flex; gap: 14px; align-items: center; }
.vw-age { padding: 12px 14px; border-radius: 8px; background: rgba(0,200,83,.08); border: 1px solid rgba(0,200,83,.3); display: flex; flex-direction: column; }
.vw-age b { font-size: 16px; }
.vw-age span { color: var(--muted); font-size: 13px; }
.vw-age.fresh { background: rgba(255,179,26,.1); border-color: rgba(255,179,26,.5); }
.vw-age.fresh b { color: #ffd27a; }
.vw-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.vw-stats div { background: var(--raised); border-radius: 6px; padding: 8px 10px; }
.vw-stats b { display: block; }
.vw-stats span { font-size: 11px; color: var(--faint); text-transform: uppercase; font-weight: 700; }
.vw-last { background: var(--raised); border-radius: 6px; padding: 8px 10px; display: flex; flex-direction: column; }

/* Sub-tabs inside a page */
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; padding: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; align-self: flex-start; max-width: 100%; }
.subtabs button { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--muted); font: inherit; font-weight: 700; font-size: 13.5px; padding: 7px 14px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.subtabs button:hover { color: var(--text); background: var(--hover); }
.subtabs button.active { background: var(--raised); color: var(--text); box-shadow: inset 0 -2px 0 var(--purple); }
.subtabs .nav-badge { margin-left: 2px; }
.subtabs-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.subtabs-row .subtabs { align-self: auto; }
.subtabs-pick { display: flex; align-items: center; gap: 8px; }
.subpane { display: flex; flex-direction: column; gap: 16px; animation: fade .15s ease; }
.subpane.narrow { max-width: 920px; }
.sub-note { margin: 0; }

/* Top emotes (panel) */
.em-wrap { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.em-r { display: grid; grid-template-columns: 30px 32px minmax(90px, 200px) minmax(0, 1fr) 70px 96px; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 6px; }
.em-r:nth-child(odd) { background: var(--raised); }
.em-r img { width: 28px; height: 28px; object-fit: contain; }
.em-r b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-k { text-align: center; font-weight: 800; color: var(--faint); }
.em-b { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .06); overflow: hidden; }
.em-b i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--purple), #ff5ec4); }
.em-c { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.em-r small { color: var(--faint); font-size: 11px; font-weight: 600; }
.em-r .em-ph { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 6px; background: rgba(145, 70, 255, .15); font-size: 14px; }

/* Built for hundreds of channels: pickers instead of tab rows, search + paging on Channels */
.pick-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--border); flex: none; }
.pick-bar label { display: flex; align-items: center; gap: 8px; }
.pick-bar select { min-width: 240px; max-width: 100%; }
.ch-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; }
.ch-tools input { flex: 1 1 240px; min-width: 0; }
.ch-more { display: flex; justify-content: center; }
.us-search { width: 100%; max-width: 360px; margin-bottom: 10px; }

.chat-route { margin-top: 12px; display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--raised); font-size: 13px; }
.chat-route span { color: var(--muted); }
.chat-route.on { border-color: rgba(0, 224, 164, .35); background: rgba(0, 224, 164, .06); }
