:root {
    --bg: #05080f;
    --side: #070b15;
    --panel: #0b1222;
    --panel-2: #0e1729;
    --line: rgba(47, 140, 255, 0.16);
    --line-strong: rgba(47, 140, 255, 0.45);
    --blue: #1f7bff;
    --blue-light: #4da3ff;
    --text: #e8ecf3;
    --muted: #8d98ad;
    --dim: #5d6880;
    --red: #ef4444;
    --orange: #f59e0b;
    --green: #22c55e;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 'Inter', 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: 'Rajdhani', 'Segoe UI', sans-serif; font-weight: 700; line-height: 1.15; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
.mono { font-family: 'JetBrains Mono', Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.hidden { display: none !important; }

.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side {
    background: var(--side);
    border-right: 1px solid var(--line);
    padding: 16px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand img { width: 34px; height: 34px; border-radius: 50%; }
.brand b { font-family: 'Rajdhani', sans-serif; font-size: 19px; letter-spacing: 0.03em; line-height: 1; display: block; }
.brand small { color: var(--blue-light); font-family: 'Rajdhani', sans-serif; font-weight: 700; font-size: 10px; letter-spacing: 0.3em; }
.server-pick { margin: 0 4px 14px; }
.server-pick select { width: 100%; }
.nav-group { margin-bottom: 14px; }
.nav-title { color: var(--dim); font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; padding: 4px 10px; }
.nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 10px; border-radius: 6px; color: var(--muted); font-weight: 500;
}
.nav a:hover { color: var(--text); background: rgba(255, 255, 255, 0.03); }
.nav a.on { color: var(--text); background: rgba(31, 123, 255, 0.12); }
.nav a svg { width: 16px; height: 16px; fill: currentColor; flex: 0 0 16px; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 6px 0; display: flex; align-items: center; gap: 10px; }
.side-foot img { width: 30px; height: 30px; border-radius: 50%; background: var(--panel-2); }
.side-foot .who { flex: 1; min-width: 0; }
.side-foot .who b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot .who span { color: var(--dim); font-size: 12px; }

.main { padding: 24px 28px 48px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin-right: auto; }
.crumb { color: var(--dim); font-size: 13px; margin-bottom: 4px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.card-pad { padding: 18px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h3 { margin-right: auto; }
.grid { display: grid; gap: 16px; }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-2 { grid-template-columns: 1fr 1fr; }
.ov-grid { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }

.stat { padding: 16px 18px; }
.stat span { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.stat b { display: block; font-family: 'Rajdhani', sans-serif; font-size: 30px; margin-top: 2px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 34px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--line-strong);
    background: transparent; cursor: pointer; font-weight: 600; font-size: 13px; white-space: nowrap;
}
.btn:hover { border-color: var(--blue-light); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: #3a8cff; }
.btn-danger { border-color: rgba(239, 68, 68, 0.5); color: #fca5a5; }
.btn-danger:hover { border-color: var(--red); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn.on { background: rgba(31, 123, 255, 0.15); border-color: var(--blue); }

input[type=text], input[type=search], select, textarea {
    background: var(--bg); border: 1px solid var(--line-strong); border-radius: 6px;
    height: 34px; padding: 0 10px; outline: none; min-width: 0;
}
textarea { height: auto; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue-light); }
label.field { display: grid; gap: 6px; font-weight: 500; }
label.field small { color: var(--dim); font-weight: 400; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--line); color: var(--muted); }
.pill.online { color: var(--green); border-color: rgba(34, 197, 94, 0.35); }
.pill.online::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.pill.offline { color: var(--red); border-color: rgba(239, 68, 68, 0.35); }

.tag { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.tag.ban { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.tag.kick { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.tag.log { background: rgba(31, 123, 255, 0.15); color: #93c5fd; }
.tag.join { background: rgba(34, 197, 94, 0.12); color: #86efac; }
.tag.leave { background: rgba(255, 255, 255, 0.06); color: var(--muted); }
.tag.warn { background: rgba(31, 123, 255, 0.15); color: #93c5fd; }
.tag.unban { background: rgba(34, 197, 94, 0.12); color: #86efac; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--dim); font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid rgba(47, 140, 255, 0.08); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.015); }
.table-wrap { overflow-x: auto; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn + .btn { margin-left: 6px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { flex: 1; min-width: 220px; }

.empty { text-align: center; color: var(--muted); padding: 48px 20px; }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

.chart-box { height: 280px; padding: 8px 14px 14px; }
.range { display: flex; gap: 4px; }
.events { max-height: 420px; overflow-y: auto; }
.event { display: flex; gap: 12px; align-items: baseline; padding: 9px 18px; border-bottom: 1px solid rgba(47, 140, 255, 0.08); }
.event time { color: var(--dim); font-size: 12px; white-space: nowrap; width: 62px; flex: 0 0 62px; }
.event .tag { flex: 0 0 auto; }
.switch-row { display: flex; gap: 12px; align-items: flex-start; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.switch-row:last-child { border-bottom: 0; }
.switch-row div { flex: 1; }
.switch-row b { display: block; font-weight: 600; }
.switch-row small { color: var(--muted); font-size: 12px; }
.toggle { position: relative; width: 38px; height: 22px; flex: 0 0 38px; border-radius: 999px; background: #1c2538; border: 0; cursor: pointer; margin-top: 2px; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #8d98ad; transition: left 0.15s; }
.toggle.on { background: var(--blue); }
.toggle.on::after { left: 19px; background: #fff; }
.toggle:disabled { opacity: 0.5; cursor: default; }
.ent-counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 14px 18px 4px; text-align: center; }
.ent-counts b { display: block; font-family: 'Rajdhani', sans-serif; font-size: 24px; }
.ent-counts span { color: var(--muted); font-size: 12px; }
.ent-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px 18px 18px; }

.console-wrap { display: grid; grid-template-columns: 1fr 260px; gap: 16px; height: calc(100vh - 130px); min-height: 420px; }
.console { display: flex; flex-direction: column; min-height: 0; }
.console-out { flex: 1; overflow-y: auto; padding: 12px 16px; font: 12.5px/1.55 'JetBrains Mono', Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.console-out .cmd { color: var(--blue-light); }
.console-out .err { color: #fca5a5; }
.console-out .wrn { color: #fcd34d; }
.console-in { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.console-in input { flex: 1; font-family: 'JetBrains Mono', Consolas, monospace; }
.plist { overflow-y: auto; min-height: 0; }
.plist-item { display: flex; align-items: center; gap: 10px; padding: 7px 14px; border-bottom: 1px solid rgba(47, 140, 255, 0.08); cursor: default; }
.plist-item .id { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--blue-light); background: rgba(31, 123, 255, 0.12); padding: 1px 6px; border-radius: 4px; min-width: 34px; text-align: center; }
.plist-item.click { cursor: pointer; }
.plist-item.click:hover { background: rgba(255, 255, 255, 0.03); }
.plist-item.on { background: rgba(31, 123, 255, 0.1); }

.live-wrap { display: grid; grid-template-columns: 1fr 260px; gap: 16px; }
.tiles { display: grid; gap: 12px; align-content: start; }
.tile { position: relative; background: #000; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; aspect-ratio: 16 / 9; }
.tile img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile .bar { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: linear-gradient(rgba(0, 0, 0, 0.75), transparent); font-size: 12px; font-weight: 600; }
.tile .bar span { margin-right: auto; }
.tile .wait { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; text-align: center; padding: 20px; }

.clips { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.clip { cursor: pointer; overflow: hidden; }
.clip video { width: 100%; aspect-ratio: 16 / 9; background: #000; display: block; object-fit: cover; pointer-events: none; }
.clip .info { padding: 10px 12px; }
.clip .info b { display: block; font-size: 13px; }
.clip .info p { color: var(--muted); font-size: 12px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.clip:hover { border-color: var(--line-strong); }

.modal-bg { position: fixed; inset: 0; background: rgba(2, 4, 9, 0.75); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { width: 100%; max-width: 560px; max-height: calc(100vh - 40px); overflow-y: auto; }
.modal.wide { max-width: 760px; }
.modal-body { padding: 18px; display: grid; gap: 14px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--line); }
.modal-foot .left { margin-right: auto; }
.modal video { width: 100%; border-radius: 6px; background: #000; max-height: 420px; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kv div { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; }
.kv span { display: block; color: var(--dim); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.ids { display: grid; gap: 6px; }
.ids div { display: flex; gap: 10px; align-items: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
.ids div span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-label { color: var(--dim); font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: -6px; }

#toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: 6px; padding: 10px 14px; max-width: 360px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4); }
.toast.bad { border-color: rgba(239, 68, 68, 0.6); }

.center { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login { width: 100%; max-width: 380px; text-align: center; padding: 32px 28px; }
.login img { width: 84px; height: 84px; border-radius: 50%; margin: 0 auto 14px; display: block; }
.login h1 { margin-bottom: 4px; }
.login p { color: var(--muted); margin-bottom: 22px; }
.login .btn { width: 100%; margin-bottom: 10px; }
.login .error { color: #fca5a5; margin-bottom: 14px; }
.server-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.server-card { padding: 18px; display: grid; gap: 8px; }
.server-card:hover { border-color: var(--line-strong); }
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.perm-grid label { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.perm-grid input { accent-color: var(--blue); }
.code { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; font: 12.5px/1.6 'JetBrains Mono', Consolas, monospace; white-space: pre-wrap; word-break: break-all; }

@media (max-width: 1100px) {
    .cols-4 { grid-template-columns: repeat(2, 1fr); }
    .ov-grid, .console-wrap, .live-wrap { grid-template-columns: 1fr; }
    .console-wrap { height: auto; }
    .console-out { height: 60vh; }
}
@media (max-width: 760px) {
    .shell { grid-template-columns: 1fr; }
    .side { position: static; height: auto; }
    .main { padding: 18px 16px 40px; }
    .cols-2, .perm-grid, .kv { grid-template-columns: 1fr; }
}
