:root {
    color-scheme: dark;
    --bg: #0b0d12;
    --panel: #11131a;
    --panel-2: #161922;
    --panel-3: #1f2330;
    --line: #2b3141;
    --text: #f4f7fb;
    --muted: #a3adbd;
    --soft: #6f7b8f;
    --accent: #5865f2;
    --accent-2: #3ba55d;
    --danger: #ed4245;
    --warning: #faa61a;
    --radius: 8px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background: var(--bg);
}

button,
input {
    font: inherit;
}

input,
select {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 12px;
    color: var(--text);
    background: #0c0f15;
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--accent);
}

button,
.logout-link {
    border: 0;
    border-radius: var(--radius);
    padding: 10px 14px;
    color: #fff;
    background: var(--accent);
    text-decoration: none;
    cursor: pointer;
    transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

button:hover,
.logout-link:hover {
    transform: translateY(-1px);
    background: #4752c4;
}

button:disabled {
    color: var(--soft);
    background: #242936;
    cursor: not-allowed;
    transform: none;
}

.auth-body {
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 20% 20%, rgba(88, 101, 242, 0.22), transparent 30%),
        linear-gradient(135deg, #0b0d12, #151821 52%, #0d1117);
}

.auth-shell {
    width: min(100%, 440px);
}

.auth-panel {
    padding: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(17, 19, 26, 0.92);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

.brand-mark {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 8px;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), #9b59ff);
    font-weight: 800;
    letter-spacing: 0;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--soft);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.auth-panel h1,
.topbar h1,
.section-heading h2,
.detail-panel h2 {
    margin: 0;
}

.auth-copy {
    color: var(--muted);
    line-height: 1.6;
}

.login-form {
    display: grid;
    gap: 12px;
    margin-top: 24px;
}

.login-form label {
    color: var(--muted);
    font-weight: 700;
}

.login-form input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 13px 14px;
    color: var(--text);
    background: #0c0f15;
    outline: none;
}

.login-form input:focus {
    border-color: var(--accent);
}

.alert {
    border-radius: var(--radius);
    padding: 12px;
    font-weight: 700;
}

.alert-error {
    color: #ffd7d7;
    background: rgba(237, 66, 69, 0.16);
}

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 20px;
    border-right: 1px solid var(--line);
    background: #0f1118;
}

.sidebar-brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 28px;
}

.sidebar-brand span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.nav-list {
    display: grid;
    gap: 8px;
}

.nav-list a {
    border-radius: var(--radius);
    padding: 12px;
    color: var(--muted);
    text-decoration: none;
}

.nav-list a:hover,
.nav-list a.active {
    color: #fff;
    background: var(--panel-3);
}

.sidebar-note {
    position: absolute;
    right: 20px;
    bottom: 20px;
    left: 20px;
    display: flex;
    gap: 8px;
    align-items: center;
    color: var(--muted);
    font-size: 13px;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: var(--accent-2);
}

.main-panel {
    min-width: 0;
    padding: 28px;
}

.topbar,
.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar {
    margin-bottom: 24px;
}

.topbar-actions,
.row-actions,
.section-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.section-tools {
    justify-content: flex-end;
}

.section-tools input {
    min-width: 260px;
}

.ghost-action,
.row-actions button {
    border: 1px solid var(--line);
    background: transparent;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card,
.table-panel,
.group-card,
.detail-panel,
.zone-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
}

.stat-card {
    padding: 18px;
}

.stat-card span,
.stat-card small,
.muted {
    color: var(--muted);
}

.stat-card strong {
    display: block;
    margin: 8px 0;
    font-size: 32px;
}

.content-section {
    margin-top: 28px;
}

.diagnostic-panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    background: var(--panel);
}

.diagnostic-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.diagnostic-grid article {
    display: grid;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    background: #0c0f15;
}

.diagnostic-config {
    display: grid;
    gap: 8px;
    margin-top: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    background: #0c0f15;
}

.diagnostic-config div {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 12px;
}

.diagnostic-config span {
    overflow-wrap: anywhere;
    color: var(--muted);
}

.ok-text {
    color: var(--accent-2);
    font-weight: 800;
}

.error-text {
    color: var(--danger);
    font-weight: 800;
}

.diagnostic-errors,
.diagnostic-raw {
    margin-top: 14px;
}

.diagnostic-errors pre,
.diagnostic-raw pre {
    overflow-x: auto;
    margin: 8px 0 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    color: #ffd7d7;
    background: rgba(237, 66, 69, 0.12);
    white-space: pre-wrap;
}

.diagnostic-raw pre {
    color: var(--muted);
    background: #0c0f15;
}

.table-panel {
    margin-top: 14px;
    overflow-x: auto;
}

.live-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.live-player,
.moderation-panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
}

.live-player {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 12px;
}

.live-player small,
.table-subline {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.row-actions {
    min-width: 300px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}

th,
td {
    padding: 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
}

th {
    color: var(--soft);
    font-size: 12px;
    text-transform: uppercase;
}

tr:last-child td {
    border-bottom: 0;
}

.player-cell,
.group-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar,
.group-card-head span {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 8px;
    background: var(--panel-3);
    font-weight: 800;
}

.group-card-head span {
    background: var(--group-color);
}

.presence {
    display: block;
    margin-top: 2px;
    color: var(--muted);
}

.presence.online {
    color: var(--accent-2);
}

.presence.away {
    color: var(--warning);
}

.level-pill,
.group-pill,
.zone-id {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 800;
}

.level-pill {
    color: #dce2ff;
    background: rgba(88, 101, 242, 0.16);
}

.group-pill {
    color: #fff;
    background: color-mix(in srgb, var(--group-color) 65%, #11131a);
}

.two-column {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
    align-items: start;
}

.group-grid,
.zone-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 14px;
}

.group-card,
.detail-panel,
.zone-card {
    padding: 16px;
}

.group-card p,
.zone-card p {
    color: var(--muted);
}

.permission-list {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.permission-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
}

.permission-toggle input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.permission-item {
    display: grid;
    gap: 4px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.permission-item:last-child {
    border-bottom: 0;
}

.permission-item span {
    color: var(--muted);
    line-height: 1.5;
}

.zone-card {
    display: grid;
    gap: 14px;
}

.moderation-panel {
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(320px, 1fr);
    gap: 18px;
    align-items: end;
    padding: 16px;
}

.moderation-panel h2 {
    margin: 0;
}

.moderation-panel p {
    color: var(--muted);
    line-height: 1.5;
}

.moderation-form {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 12px;
}

.moderation-form label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-weight: 700;
}

.zone-card h3 {
    margin: 8px 0 0;
}

.zone-id {
    color: #a7f3d0;
    background: rgba(59, 165, 93, 0.16);
}

dl {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 0;
}

dt {
    color: var(--soft);
    font-size: 12px;
    font-weight: 800;
}

dd {
    margin: 4px 0 0;
    font-weight: 800;
}

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    max-width: 360px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--text);
    background: var(--panel-3);
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 980px) {
    .app-shell,
    .two-column {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
    }

    .sidebar-note {
        position: static;
        margin-top: 20px;
    }

    .stats-grid,
    .group-grid,
    .zone-grid,
    .live-strip,
    .moderation-panel,
    .moderation-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .main-panel,
    .sidebar,
    .auth-panel {
        padding: 18px;
    }

    .topbar,
    .section-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar-actions,
    .section-tools,
    .section-tools input,
    .section-heading button,
    .logout-link {
        width: 100%;
    }
}
