:root {
    --bg: #060b15;
    --bg-2: #0a1122;
    --panel: #0c1425;
    --panel-2: #101a2e;
    --line: rgba(148, 169, 220, 0.12);
    --line-strong: rgba(148, 169, 220, 0.22);
    --text: #e8eefc;
    --muted: #8b99bb;
    --accent: #7c6cff;
    --accent-2: #a08fff;
    --ok: #3ddc97;
    --warn: #f5b942;
    --danger: #ff6b7a;
    --radius: 14px;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    background: radial-gradient(1200px 600px at 15% -10%, #1a1f4d 0%, transparent 55%),
                radial-gradient(900px 500px at 95% 0%, #241a45 0%, transparent 50%),
                var(--bg);
    color: var(--text);
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: none; color: #c3b8ff; }

.glow {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(700px 350px at 50% -20%, rgba(124, 108, 255, 0.18), transparent 70%);
    z-index: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 26px;
    padding: 14px 28px;
    background: rgba(8, 13, 26, 0.82);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.01em;
}

.brand.big { font-size: 22px; margin-bottom: 6px; }

.brand-sub {
    color: var(--muted);
    font-weight: 500;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

.brand-mark {
    width: 22px;
    height: 22px;
    border-radius: 7px;
    background: linear-gradient(135deg, #8b7bff, #4d3df0);
    box-shadow: 0 0 18px rgba(124, 108, 255, 0.55);
}

.tabs { display: flex; gap: 6px; margin-left: 10px; }

.tabs a {
    padding: 8px 16px;
    border-radius: 10px;
    color: #aab6d6;
    font-weight: 500;
    font-size: 14px;
    border: 1px solid transparent;
}

.tabs a:hover { color: #fff; background: rgba(255, 255, 255, 0.04); }

.tabs a.active {
    color: #fff;
    background: linear-gradient(135deg, #7c6cff, #5b49e8);
    box-shadow: 0 6px 18px rgba(92, 73, 232, 0.35);
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.user { color: var(--muted); font-size: 13px; }

.wrap {
    position: relative;
    z-index: 1;
    max-width: 1500px;
    margin: 0 auto;
    padding: 30px 28px 70px;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.page-head h1 { margin: 0 0 4px; font-size: 30px; letter-spacing: -0.02em; font-weight: 650; }
.page-head .sub { margin: 0; color: var(--muted); font-size: 14px; }
.page-head .actions { display: flex; gap: 10px; align-items: center; }
.crumbs { margin: 0 0 8px; font-size: 13px; }

.card {
    background: linear-gradient(180deg, rgba(16, 26, 46, 0.75), rgba(10, 17, 33, 0.9));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 22px;
    overflow: hidden;
}

.card.pad { padding: 22px; }
.card h2 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
}

.card-head h2 { margin: 0; }

table.grid { width: 100%; border-collapse: collapse; }

table.grid th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 600;
    padding: 14px 22px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

table.grid td {
    padding: 15px 22px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    vertical-align: middle;
}

table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover td { background: rgba(255, 255, 255, 0.018); }

tr.base td { background: rgba(124, 108, 255, 0.04); }
tr.base td:first-child { font-weight: 600; }

.channel-name { white-space: nowrap; }
.tree { color: #4b5a7d; margin-right: 10px; }
tr.child td:first-child { padding-left: 44px; }

.num { text-align: right; font-variant-numeric: tabular-nums; color: #d7e0f6; }
.right { text-align: right; }
.strong { font-weight: 600; }
.strong-link { color: #fff; font-weight: 600; }
.strong-link:hover { color: var(--accent-2); }

.actions-cell { white-space: nowrap; }
.actions-cell form { display: inline; }
.actions-cell .link { margin-left: 14px; }

.link {
    background: none;
    border: 0;
    padding: 0;
    color: var(--accent-2);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}

.link:hover { color: #cfc5ff; }
.link.danger, .danger { color: var(--danger); }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: rgba(124, 108, 255, 0.10);
    color: #b7aaff;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
}

.badge.muted { color: var(--muted); background: rgba(139, 153, 187, 0.08); }
.badge.warn { color: var(--warn); background: rgba(245, 185, 66, 0.10); border-color: rgba(245, 185, 66, 0.3); }
.badge.accent { color: #c7bcff; }

.status-line { padding: 20px 22px; font-size: 15px; font-weight: 600; }
.status-line.ok { color: var(--ok); }
.status-line.warn { color: var(--warn); }

dl.kv {
    display: grid;
    grid-template-columns: 300px 1fr;
    margin: 0;
    padding: 6px 22px 16px;
}

dl.kv dt { padding: 14px 0; color: var(--muted); border-bottom: 1px solid var(--line); }
dl.kv dd { margin: 0; padding: 14px 0; text-align: right; border-bottom: 1px solid var(--line); }
dl.kv dt:last-of-type, dl.kv dd:last-of-type { border-bottom: 0; }

.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 10px;
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}

.btn:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }

.btn.primary {
    border-color: transparent;
    background: linear-gradient(135deg, #7c6cff, #5b49e8);
    color: #fff;
    box-shadow: 0 6px 18px rgba(92, 73, 232, 0.3);
}

.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: rgba(255, 107, 122, 0.35); }
.btn.block { width: 100%; text-align: center; }

input[type="text"], input[type="number"], input[type="password"], select, textarea {
    width: 100%;
    background: rgba(6, 11, 22, 0.75);
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    color: var(--text);
    padding: 10px 12px;
    font: inherit;
    font-size: 14px;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124, 108, 255, 0.18);
}

textarea { resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.55; }
textarea.code { background: #060b15; }

label { display: block; font-size: 13px; color: #b9c5e2; font-weight: 500; }
label small { display: block; margin-top: 6px; color: var(--muted); font-weight: 400; }
label.check { display: flex; align-items: center; gap: 8px; }
label.check input { width: auto; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 10px; padding-top: 4px; }

.stack { display: grid; gap: 14px; max-width: 900px; }

.flash {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 18px;
    font-size: 14px;
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.03);
}

.flash.ok { border-color: rgba(61, 220, 151, 0.35); background: rgba(61, 220, 151, 0.10); color: #9cf3cb; }
.flash.error { border-color: rgba(255, 107, 122, 0.35); background: rgba(255, 107, 122, 0.10); color: #ffb3bb; }
.flash.warn { border-color: rgba(245, 185, 66, 0.35); background: rgba(245, 185, 66, 0.10); color: #ffd88a; }

.empty { padding: 26px 22px; color: var(--muted); margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.url { color: #a7b4d6; font-family: var(--mono); font-size: 12.5px; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

code { font-family: var(--mono); font-size: 0.92em; background: rgba(255, 255, 255, 0.06); padding: 2px 6px; border-radius: 6px; }

.dot-bad, .dot-warn {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-left: 8px;
    vertical-align: middle;
}

.dot-bad { background: var(--danger); box-shadow: 0 0 8px rgba(255, 107, 122, 0.7); }
.dot-warn { background: var(--warn); }

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

.login-card {
    position: relative;
    width: 430px;
    padding: 32px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(16, 26, 46, 0.92), rgba(9, 15, 28, 0.96));
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}

.login-card .sub { color: var(--muted); margin: 0 0 20px; font-size: 13.5px; }

@media (max-width: 900px) {
    .topbar { flex-wrap: wrap; gap: 12px; }
    .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: span 1; }
    dl.kv { grid-template-columns: 1fr; }
    dl.kv dd { text-align: left; border-bottom: 0; padding-top: 0; }
    .page-head { flex-direction: column; }
}

.badge.ok { color: #9cf3cb; background: rgba(61, 220, 151, 0.12); border-color: rgba(61, 220, 151, 0.35); }
.badge.danger { color: #ffb3bb; background: rgba(255, 107, 122, 0.12); border-color: rgba(255, 107, 122, 0.35); }

pre.action-output {
    margin: 8px 0 0;
    padding: 10px 12px;
    max-height: 260px;
    overflow: auto;
    background: #060b15;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #a7b4d6;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
}

details summary { cursor: pointer; }

.small-tabs a { font-size: 13px; padding: 5px 10px; }
