:root {
  --bg: #0f0c18;
  --bg2: #17122a;
  --card: #1c1630;
  --card2: #241d3d;
  --line: #2f2650;
  --text: #ece8f7;
  --muted: #9a92b8;
  --accent: #c25cff;
  --accent2: #ff5cc8;
  --good: #3ddc97;
  --warn: #ffb547;
  --bad: #ff5c7a;
  --info: #5cb8ff;
  --radius: 14px;
  --nav-h: 62px;
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body { -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .6rem; line-height: 1.2; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; color: var(--muted); font-weight: 600; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.num { font-variant-numeric: tabular-nums; }
.good { color: var(--good); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex: 0 0 220px; background: var(--bg2); border-right: 1px solid var(--line);
  padding: 1rem .7rem; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: .2rem;
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.05rem; padding: .2rem .5rem 1rem; }
.brand img { width: 28px; height: 28px; border-radius: 8px; }
.nav a {
  display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border-radius: 10px; color: var(--muted);
  font-weight: 600; text-decoration: none;
}
.nav a:hover { background: var(--card); color: var(--text); }
.nav a.active { background: linear-gradient(90deg, #c25cff33, #ff5cc81a); color: var(--text); }
.nav .ico { width: 1.3rem; text-align: center; }
.sidebar .spacer { flex: 1; }
.sidebar .me { font-size: .82rem; color: var(--muted); padding: .5rem .7rem; border-top: 1px solid var(--line); }
main { flex: 1; min-width: 0; padding: 1.1rem 1.3rem 2rem; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: 1rem; flex-wrap: wrap; }
.topbar h1 { margin: 0; }
.mobile-nav { display: none; }

@media (max-width: 820px) {
  .sidebar { display: none; }
  main { padding: .8rem .75rem calc(var(--nav-h) + 1.2rem + env(safe-area-inset-bottom)); }
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--bg2);
    border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); overflow-x: auto;
  }
  .mobile-nav a {
    flex: 1 0 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    height: var(--nav-h); color: var(--muted); font-size: .68rem; font-weight: 600; text-decoration: none;
  }
  .mobile-nav a .ico { font-size: 1.15rem; }
  .mobile-nav a.active { color: var(--accent); }
  h1 { font-size: 1.2rem; }
}

/* ---------- status pill ---------- */
.pill { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .65rem; border-radius: 99px; background: var(--card); border: 1px solid var(--line); font-size: .8rem; font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.online { background: var(--good); box-shadow: 0 0 8px var(--good); }
.dot.offline, .dot.unauthorized, .dot.version_mismatch { background: var(--bad); }
.dot.connecting { background: var(--warn); }
.banner { padding: .7rem .9rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid; font-size: .9rem; }
.banner.warn { background: #ffb5471a; border-color: #ffb54755; }
.banner.bad { background: #ff5c7a1a; border-color: #ff5c7a55; }
.banner.info { background: #5cb8ff14; border-color: #5cb8ff44; }

/* ---------- cards / grid ---------- */
.grid { display: grid; gap: .8rem; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: .9rem; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; min-width: 0; }
.card + .card { margin-top: 0; }
.stack > * + * { margin-top: .8rem; }
.kpi .label { color: var(--muted); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi .value { font-size: 1.55rem; font-weight: 800; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: .78rem; margin-top: .1rem; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .6rem; }
.card-head h2 { margin: 0; }

/* ---------- controls ---------- */
button, .btn {
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--card2); color: var(--text);
  padding: .5rem .85rem; border-radius: 10px; cursor: pointer; display: inline-flex; align-items: center; gap: .35rem; line-height: 1.2;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: 0; color: #fff; }
button.danger { background: #ff5c7a22; border-color: #ff5c7a66; color: #ffb3c1; }
button.ghost { background: transparent; }
button.sm { padding: .3rem .55rem; font-size: .8rem; border-radius: 8px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg2); border: 1px solid var(--line); border-radius: 10px;
  padding: .55rem .7rem; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #c25cff66; border-color: var(--accent); }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
label { display: block; font-size: .82rem; color: var(--muted); font-weight: 600; margin-bottom: .25rem; }
.field { margin-bottom: .7rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 120px; }
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: .3rem .65rem; font-size: .82rem; color: var(--muted); border-radius: 8px; }
.seg button.on { background: var(--card2); color: var(--text); }
.check { display: flex; align-items: center; gap: .5rem; color: var(--text); font-size: .9rem; font-weight: 500; margin: .35rem 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -1rem; padding: 0 1rem; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
td.r, th.r { text-align: right; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #ffffff06; }

/* ---------- bars / funnel ---------- */
.bars { display: flex; flex-direction: column; gap: .35rem; }
.bar { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: .5rem; align-items: center; font-size: .85rem; }
.bar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.bar .track { display: block; height: 10px; background: var(--bg2); border-radius: 6px; overflow: hidden; }
.bar .fill { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 6px; }
.bar .fill.alt { background: linear-gradient(90deg, #5cb8ff, #3ddc97); }
.bar .val { font-variant-numeric: tabular-nums; white-space: nowrap; }
.funnel .bar { grid-template-columns: minmax(130px, 42%) 1fr 4.5rem; }
.funnel .bar .sub { grid-column: 1 / -1; font-size: .74rem; color: var(--muted); margin-top: -.25rem; }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; user-select: none; touch-action: pan-y; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .tip {
  position: absolute; pointer-events: none; background: #0b0814ee; border: 1px solid var(--line); border-radius: 8px;
  padding: .35rem .5rem; font-size: .75rem; white-space: nowrap; transform: translate(-50%, -110%); z-index: 2;
}
.chart .tip b { display: block; margin-bottom: .1rem; }
.legend { display: flex; gap: .8rem; flex-wrap: wrap; font-size: .76rem; color: var(--muted); margin-top: .3rem; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: .3rem; vertical-align: middle; }
.spark { display: block; width: 100%; height: 34px; }

/* ---------- live ---------- */
.live-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: .8rem; }
@media (max-width: 1100px) { .live-grid { grid-template-columns: 1fr; } }
.players-list { max-height: 520px; overflow-y: auto; }
.player-row { display: flex; align-items: center; gap: .6rem; padding: .45rem .2rem; border-bottom: 1px solid var(--line); }
.player-row:last-child { border-bottom: 0; }
.head { width: 28px; height: 28px; border-radius: 6px; background: var(--card2); flex: 0 0 28px; image-rendering: pixelated; }
.player-row .info { flex: 1; min-width: 0; }
.player-row .name { font-weight: 700; }
.player-row .meta { font-size: .75rem; color: var(--muted); }
.chat-box { height: 460px; overflow-y: auto; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: .4rem .6rem; font-size: .88rem; }
.chat-line { padding: .18rem 0; line-height: 1.35; word-wrap: break-word; }
.chat-line .t { color: var(--muted); font-size: .72rem; margin-right: .35rem; font-variant-numeric: tabular-nums; }
.chat-line .p { font-weight: 700; cursor: pointer; }
.chat-line.web .p { color: var(--info); }
.chat-line.blocked { background: #ff5c7a14; border-radius: 6px; padding-left: .3rem; }
.chat-line .tag { font-size: .65rem; font-weight: 700; border-radius: 4px; padding: 0 .3rem; margin-right: .3rem; vertical-align: 1px; }
.tag.web { background: #5cb8ff33; color: #a8d8ff; }
.tag.blocked { background: #ff5c7a33; color: #ffb3c1; }
.tag.sys { background: #ffffff14; color: var(--muted); }
.chat-line.sys { color: var(--muted); font-size: .8rem; }
.actions-list .item { padding: .4rem 0; border-bottom: 1px solid var(--line); font-size: .85rem; }
.actions-list .item:last-child { border-bottom: 0; }
.badge { display: inline-block; font-size: .7rem; font-weight: 700; padding: .1rem .4rem; border-radius: 5px; background: var(--card2); color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.badge.ban, .badge.temp_ban, .badge.tempban { background: #ff5c7a33; color: #ffb3c1; }
.badge.mute, .badge.temp_mute, .badge.tempmute { background: #ffb54733; color: #ffd699; }
.badge.kick, .badge.warning { background: #5cb8ff33; color: #a8d8ff; }
.badge.unban, .badge.unmute, .badge.revoke { background: #3ddc9733; color: #9ff0c9; }

/* ---------- modal / toast ---------- */
.modal-back { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 50; padding: 1rem; }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 1.1rem; width: min(480px, 100%); max-height: 90vh; overflow-y: auto; }
.modal .actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.templates { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .7rem; }
#toasts { position: fixed; top: .8rem; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .4rem; width: min(440px, 92vw); }
.toast { background: var(--card2); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: .6rem .8rem; border-radius: 10px; font-size: .88rem; box-shadow: 0 8px 30px #0008; animation: pop .15s ease-out; }
.toast.bad { border-left-color: var(--bad); }
.toast.good { border-left-color: var(--good); }
.toast ul { margin: .3rem 0 0; padding-left: 1.1rem; color: var(--muted); }
@keyframes pop { from { transform: translateY(-6px); opacity: 0; } }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(circle at 30% 20%, #c25cff22, transparent 50%), radial-gradient(circle at 80% 80%, #ff5cc815, transparent 50%); }
.login .card { width: min(380px, 100%); padding: 1.4rem; }
.login .brand { justify-content: center; font-size: 1.3rem; padding-bottom: 1.2rem; }
.login .brand img { width: 40px; height: 40px; }
.error { color: var(--bad); font-size: .88rem; min-height: 1.2em; margin: .3rem 0; }

/* ---------- misc ---------- */
.days { display: flex; flex-wrap: wrap; gap: 3px; }
.days span { width: 14px; height: 14px; border-radius: 3px; background: var(--bg2); border: 1px solid var(--line); }
.days span.on { background: var(--accent); border-color: var(--accent); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .3rem .9rem; font-size: .88rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); text-align: center; padding: 1.5rem .5rem; font-size: .9rem; }
.feature-card .stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .4rem .8rem; margin: .5rem 0; }
.feature-card .stats div { font-size: .78rem; color: var(--muted); }
.feature-card .stats b { display: block; font-size: 1.05rem; color: var(--text); font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .8rem; }
.search-results { margin-top: .4rem; }
code { background: var(--bg2); border: 1px solid var(--line); border-radius: 5px; padding: .05rem .3rem; font-size: .85em; }
.install { position: fixed; right: 1rem; bottom: 1rem; z-index: 30; }
@media (max-width: 820px) { .install { bottom: calc(var(--nav-h) + 1rem + env(safe-area-inset-bottom)); } }
