:root {
    --bg: #050505;
    --panel: rgba(255, 255, 255, 0.055);
    --panel-strong: rgba(255, 255, 255, 0.09);
    --panel-hover: rgba(255, 255, 255, 0.13);
    --line: rgba(255, 255, 255, 0.12);
    --line-soft: rgba(255, 255, 255, 0.07);
    --text: #ffffff;
    --text-soft: rgba(255, 255, 255, 0.74);
    --text-muted: rgba(255, 255, 255, 0.48);
    --accent: #5b7cfa;
    --accent-soft: rgba(91, 124, 250, 0.15);
    --danger: #ff5555;
    --danger-soft: rgba(255, 85, 85, 0.12);
    --success: #50fa7b;
    --success-soft: rgba(80, 250, 123, 0.12);
    --warn: #ffb86c;
    --warn-soft: rgba(255, 184, 108, 0.12);
    --radius: 8px;
    --radius-sm: 6px;
    --max-width: 1140px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    overscroll-behavior: none;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: geometricPrecision;
    display: flex;
    flex-direction: column;
}

.grid-bg {
    position: fixed;
    inset: 0;
    z-index: -2;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: 72px 72px;
}

.grid-overlay {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 260px),
        rgba(0, 0, 0, 0.48);
}

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 20px 24px;
    border-bottom: 1px solid var(--line-soft);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.brand-text {
    font-weight: 800;
    font-size: 18px;
    letter-spacing: 0.08em;
}

.brand-sub {
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.topbar-stats {
    display: flex;
    gap: 12px;
}

.stat-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-soft);
}

.stat-pill.muted {
    color: var(--text-muted);
    border-color: var(--line-soft);
}

.stat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.refresh-btn {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel);
    color: var(--text-soft);
    cursor: pointer;
    transition: all 200ms ease;
}

.refresh-btn:hover {
    background: var(--panel-hover);
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.2);
}

.refresh-btn.spinning svg {
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Main content */
.main-content {
    flex: 1;
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 48px 24px 80px;
}

.section-header {
    margin-bottom: 32px;
}

.section-header p {
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.section-header h2 {
    font-size: clamp(28px, 4vw, 42px);
    font-weight: 760;
    letter-spacing: -0.04em;
    line-height: 1;
}

/* Filter bar */
.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    height: 42px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: all 200ms ease;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input:focus {
    border-color: rgba(255, 255, 255, 0.3);
    background: var(--panel-strong);
}

.filter-tabs {
    display: flex;
    gap: 6px;
}

.filter-tab {
    padding: 8px 16px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 200ms ease;
}

.filter-tab:hover {
    color: var(--text-soft);
    border-color: var(--line);
}

.filter-tab.active {
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.3);
    background: var(--panel-strong);
}

/* Client cards */
.clients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.client-card {
    position: relative;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    transition: all 220ms ease;
    overflow: hidden;
}

.client-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: var(--panel-strong);
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
}

.client-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), transparent);
    opacity: 0.6;
}

.client-card.offline::before {
    background: linear-gradient(90deg, var(--text-muted), transparent);
    opacity: 0.3;
}

.client-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.client-avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--panel-strong);
    border: 1px solid var(--line-soft);
    object-fit: cover;
    flex-shrink: 0;
}

.client-info {
    flex: 1;
    min-width: 0;
}

.client-name {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.client-uuid {
    font-size: 11px;
    color: var(--text-muted);
    font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.client-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.client-status.online { color: var(--success); }
.client-status.offline { color: var(--text-muted); }

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 6px currentColor;
}

.client-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.detail-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
}

.detail-label {
    color: var(--text-muted);
    font-weight: 500;
}

.detail-value {
    color: var(--text-soft);
    font-weight: 600;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-badge {
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.detail-badge.singleplayer {
    background: var(--accent-soft);
    color: var(--accent);
}

.detail-badge.multiplayer {
    background: var(--success-soft);
    color: var(--success);
}

.detail-badge.plan-free {
    background: var(--panel-strong);
    color: var(--text-muted);
}

.detail-badge.plan-premium {
    background: var(--warn-soft);
    color: var(--warn);
}

.client-actions {
    display: flex;
    gap: 8px;
}

.btn {
    flex: 1;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel);
    color: var(--text-soft);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 180ms ease;
}

.btn:hover {
    background: var(--panel-hover);
    color: var(--text);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-danger {
    border-color: rgba(255, 85, 85, 0.3);
    color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger-soft);
    border-color: rgba(255, 85, 85, 0.5);
}

.btn-warn {
    border-color: rgba(255, 184, 108, 0.3);
    color: var(--warn);
}

.btn-warn:hover {
    background: var(--warn-soft);
    border-color: rgba(255, 184, 108, 0.5);
}

/* Empty state */
.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    color: var(--text-muted);
    text-align: center;
}

.empty-icon {
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-soft);
    margin-bottom: 4px;
}

.empty-state span {
    font-size: 13px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    animation: fadeIn 200ms ease;
}

.modal-overlay.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    width: min(440px, calc(100% - 48px));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #0a0a0a;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
    animation: slideUp 240ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

@keyframes slideUp {
    from { transform: translateY(16px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--line-soft);
}

.modal-header h3 {
    font-size: 17px;
    font-weight: 700;
}

.modal-close {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    transition: all 160ms ease;
}

.modal-close:hover {
    background: var(--panel);
    color: var(--text);
}

.modal-body {
    padding: 24px;
}

.modal-body p {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-soft);
}

.modal-actions {
    display: flex;
    gap: 10px;
    padding: 0 24px 24px;
}

.btn-confirm {
    border-color: rgba(255, 85, 85, 0.4);
    color: var(--danger);
}

.btn-confirm:hover {
    background: var(--danger-soft);
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #0a0a0a;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    animation: toastIn 240ms cubic-bezier(0.2, 0.7, 0.2, 1);
    max-width: 360px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warn { border-left: 3px solid var(--warn); }
.toast.info { border-left: 3px solid var(--accent); }

.toast.removing {
    animation: toastOut 200ms ease forwards;
}

@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toastOut {
    to { transform: translateX(100%); opacity: 0; }
}

/* Footer */
.footer {
    display: flex;
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    align-items: center;
    justify-content: space-between;
    padding: 28px 24px 48px;
    color: var(--text-muted);
    font-size: 12px;
    border-top: 1px solid var(--line-soft);
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 760;
    letter-spacing: 0.1em;
}

.footer-brand img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

/* Responsive */
@media (max-width: 760px) {
    .topbar {
        flex-wrap: wrap;
        gap: 12px;
        padding: 16px 18px;
    }

    .topbar-stats {
        order: 3;
        width: 100%;
    }

    .main-content {
        padding: 32px 18px 60px;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .clients-grid {
        grid-template-columns: 1fr;
    }

    .footer {
        flex-direction: column;
        gap: 14px;
        text-align: center;
        padding: 24px 18px 48px;
    }
}
