:root {
    --bg: #090910;
    --bg-elevated: #11111a;
    --bg-soft: #171725;
    --bg-panel: rgba(20, 20, 31, 0.92);
    --stroke: #25253a;
    --stroke-strong: #34344e;
    --text: #f5f7ff;
    --muted: #9297b2;
    --muted-strong: #c1c5db;
    --accent: #ff4d57;
    --accent-strong: #ff6a72;
    --success: #19f29d;
    --warning: #f4b740;
    --danger: #ff5d67;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
    --radius-lg: 24px;
    --radius-md: 18px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px 1fr;
    background:
        radial-gradient(circle at top left, rgba(255, 77, 87, 0.14), transparent 28%),
        radial-gradient(circle at bottom right, rgba(73, 148, 255, 0.08), transparent 25%),
        var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

a,
button,
select {
    font: inherit;
}

.sidebar {
    padding: 24px 20px;
    background: rgba(10, 10, 16, 0.92);
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(18px);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 8px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.brand-mark {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(145deg, rgba(255, 77, 87, 0.24), rgba(255, 77, 87, 0.05));
    border: 1px solid rgba(255, 77, 87, 0.35);
    color: var(--accent-strong);
    font-weight: 700;
    letter-spacing: 0.08em;
}

.brand-kicker,
.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.68rem;
    color: var(--muted);
}

.brand h1 {
    font-size: 1.35rem;
    color: var(--text);
    margin-top: 2px;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 16px;
    border-radius: 16px;
    text-decoration: none;
    color: var(--muted);
    border: 1px solid transparent;
    transition: 0.2s ease;
}

.nav-item:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(255, 77, 87, 0.16), rgba(255, 77, 87, 0.04));
    border-color: rgba(255, 77, 87, 0.25);
    box-shadow: inset 0 0 0 1px rgba(255, 77, 87, 0.12);
}

.nav-label {
    font-weight: 600;
    color: inherit;
}

.nav-hint {
    font-size: 0.8rem;
    color: var(--muted);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent-strong);
    font-weight: 700;
}

.user-name {
    font-weight: 600;
}

.user-role {
    font-size: 0.85rem;
    color: var(--muted);
    text-transform: capitalize;
}

.logout-btn,
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-success {
    border-radius: 12px;
    padding: 0.8rem 1rem;
    cursor: pointer;
    transition: 0.2s ease;
}

.logout-btn {
    width: 100%;
    border: 1px solid var(--stroke);
    background: transparent;
    color: var(--muted-strong);
}

.logout-btn:hover {
    border-color: rgba(255, 77, 87, 0.35);
    color: var(--text);
}

.main {
    padding: 28px;
    overflow-y: auto;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.hero,
.section-header,
.panel,
.metric-card,
.control-card {
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: var(--bg-panel);
    box-shadow: var(--shadow);
}

.hero,
.section-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.hero {
    padding: 26px 28px;
    border-radius: var(--radius-lg);
    align-items: end;
}

.hero h2,
.section-header h2 {
    font-size: clamp(2rem, 3vw, 2.6rem);
    line-height: 1.05;
    margin-top: 6px;
}

.hero-copy {
    max-width: 700px;
    color: var(--muted-strong);
    margin-top: 12px;
    line-height: 1.55;
}

.hero-meta,
.meta-pill {
    display: flex;
    align-items: center;
}

.meta-pill {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 14px 18px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
}

.meta-label {
    font-size: 0.75rem;
    color: var(--muted);
}

.meta-value {
    font-size: 1.1rem;
    font-weight: 600;
}

.status-ribbon {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 0.85rem 1rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--muted-strong);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
}

.status-dot.green {
    background: var(--success);
    box-shadow: 0 0 14px rgba(25, 242, 157, 0.5);
}

.status-dot.yellow {
    background: var(--warning);
    box-shadow: 0 0 14px rgba(244, 183, 64, 0.45);
}

.status-dot.red {
    background: var(--danger);
    box-shadow: 0 0 14px rgba(255, 93, 103, 0.45);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.metric-card {
    padding: 20px;
    border-radius: var(--radius-md);
}

.metric-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.metric-label {
    color: var(--muted);
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.metric-card h3 {
    font-size: clamp(1.7rem, 2vw, 2.4rem);
}

.metric-sub {
    margin-top: 10px;
    margin-bottom: 12px;
    color: var(--muted);
}

.uptime-value {
    font-size: 1.1rem;
    line-height: 1.45;
}

.metric-badge {
    border-radius: 999px;
    padding: 0.35rem 0.65rem;
    font-size: 0.76rem;
    font-weight: 700;
}

.metric-badge.normal {
    background: rgba(25, 242, 157, 0.15);
    color: var(--success);
}

.metric-badge.warning {
    background: rgba(244, 183, 64, 0.18);
    color: var(--warning);
}

.metric-badge.danger {
    background: rgba(255, 93, 103, 0.18);
    color: var(--danger);
}

.progress-bar {
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.progress {
    height: 100%;
    width: 0;
    background: var(--success);
    border-radius: inherit;
    transition: width 0.3s ease;
}

.progress.warning {
    background: var(--warning);
}

.progress.danger {
    background: var(--danger);
}

.dashboard-grid,
.admin-layout,
.games-layout {
    display: grid;
    gap: 18px;
}

.dashboard-grid {
    grid-template-columns: 1.4fr 0.9fr;
}

.panel {
    padding: 22px;
    border-radius: var(--radius-lg);
}

.panel-large {
    min-height: 260px;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.panel-head h3 {
    font-size: 1.25rem;
    margin-top: 6px;
}

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

.mini-card,
.overview-card,
.detail-card,
.activity-item,
.user-row,
.game-card {
    background: var(--bg-soft);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.mini-card {
    border-radius: 18px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mini-card strong {
    font-size: 1.4rem;
}

.mini-label,
.mini-sub {
    color: var(--muted);
}

.server-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}

.overview-card {
    border-radius: 18px;
    padding: 16px;
}

.overview-head,
.game-card-header,
.detail-row,
.user-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.overview-head h4,
.game-card h3 {
    font-size: 1.05rem;
}

.overview-head p,
.game-card-header p,
.activity-item p,
.detail-note p {
    color: var(--muted);
}

.overview-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 12px;
    color: var(--muted-strong);
    font-size: 0.9rem;
}

.state-pill,
.role-badge {
    border-radius: 999px;
    padding: 0.4rem 0.7rem;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

.state-online {
    background: rgba(25, 242, 157, 0.15);
    color: var(--success);
}

.state-offline {
    background: rgba(255, 93, 103, 0.15);
    color: var(--danger);
}

.role-badge {
    background: rgba(255, 255, 255, 0.06);
    color: var(--muted-strong);
}

.activity-list,
.log-preview,
.logs-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 420px;
    overflow: auto;
}

.activity-item {
    border-radius: 16px;
    padding: 14px 16px;
}

.activity-item div {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
}

.activity-item span,
.activity-item small {
    color: var(--muted);
}

.log-line {
    padding: 0.75rem 0.9rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    color: var(--muted-strong);
    font-family: Consolas, "Courier New", monospace;
    line-height: 1.45;
    word-break: break-word;
}

.log-line.error {
    color: #ff8a92;
}

.log-line.warning {
    color: #ffd68a;
}

.log-line.info {
    color: #7af2c3;
}

.games-layout {
    grid-template-columns: 1.15fr 0.85fr;
    align-items: start;
}

.games-list {
    display: grid;
    gap: 14px;
}

.game-card {
    width: 100%;
    text-align: left;
    border-radius: 20px;
    padding: 18px;
    cursor: pointer;
}

.game-card.selected {
    border-color: rgba(255, 77, 87, 0.28);
    box-shadow: inset 0 0 0 1px rgba(255, 77, 87, 0.14);
}

.game-card-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-top: 18px;
}

.game-card-metrics span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    margin-bottom: 6px;
}

.detail-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.detail-card {
    border-radius: 18px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.detail-row span {
    color: var(--muted);
}

.detail-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.detail-note {
    padding: 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.terminal-shell,
.logs-panel,
.action-result-panel {
    min-height: 420px;
}

.terminal-placeholder,
.action-result {
    min-height: 320px;
    border-radius: 18px;
    padding: 18px;
    background: #050507;
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #d6daf1;
    line-height: 1.6;
}

.action-result {
    white-space: pre-wrap;
    font-family: Consolas, "Courier New", monospace;
}

#log-selector {
    border: 1px solid var(--stroke);
    background: var(--bg-elevated);
    color: var(--text);
    padding: 0.8rem 1rem;
    border-radius: 12px;
}

.logs-content {
    min-height: 540px;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 18px;
    margin-bottom: 18px;
}

.control-card {
    padding: 22px;
    border-radius: var(--radius-lg);
}

.control-card h3 {
    margin: 8px 0 10px;
    font-size: 1.35rem;
}

.control-card p {
    color: var(--muted);
    line-height: 1.5;
    margin-bottom: 16px;
}

.control-card.danger {
    border-color: rgba(255, 93, 103, 0.2);
}

.admin-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.users-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-row {
    padding: 16px;
    border-radius: 18px;
    align-items: center;
}

.user-row-role {
    color: var(--muted);
    font-size: 0.88rem;
    margin-top: 4px;
}

.user-row-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-primary,
.btn-danger,
.btn-success {
    border: none;
    color: var(--text);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.btn-primary:hover {
    filter: brightness(1.06);
}

.btn-secondary {
    border: 1px solid var(--stroke-strong);
    color: var(--text);
    background: transparent;
}

.btn-secondary:hover {
    border-color: rgba(255, 255, 255, 0.18);
}

.btn-danger {
    background: linear-gradient(135deg, #d63d48, var(--danger));
}

.btn-success {
    background: linear-gradient(135deg, #119f69, var(--success));
    color: #08110d;
}

.loading {
    color: var(--muted);
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    place-items: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 24px;
}

.modal.show {
    display: grid;
}

.modal-box {
    width: min(420px, 100%);
    padding: 24px;
    border-radius: 20px;
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-box p {
    color: var(--muted-strong);
    margin: 12px 0 18px;
    line-height: 1.55;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 999px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

@media (max-width: 1240px) {
    .metrics-grid,
    .dashboard-grid,
    .admin-layout,
    .games-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    body {
        grid-template-columns: 1fr;
    }

    .sidebar {
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .nav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .hero,
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .insight-grid,
    .game-card-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .main {
        padding: 16px;
    }

    .sidebar {
        padding: 16px;
    }

    .nav {
        grid-template-columns: 1fr;
    }

    .insight-grid,
    .game-card-metrics {
        grid-template-columns: 1fr;
    }
}
