/* ============================================================
   EIVEX ADMIN — LAYOUT (Vuexy-like)
   ============================================================ */

.app-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}
.main-wrap {
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    box-shadow: 0 0 15px 0 rgba(34, 41, 47, 0.05);
    z-index: 100;
    transition: left 0.25s cubic-bezier(.4, 0, .2, 1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 22px 20px;
    border-bottom: 1px solid var(--border);
}
.brand-mark {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #7367F0, #A855F7);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 17px; color: #fff;
    box-shadow: 0 4px 12px rgba(115, 103, 240, 0.35);
    flex-shrink: 0;
}
.brand-text { min-width: 0; }
.brand-name {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.02em;
    color: var(--text);
}
.brand-sub {
    color: var(--text-3);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-group { margin-bottom: 22px; }
.nav-label {
    color: var(--text-3);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 0 12px;
    margin-bottom: 8px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text-2);
    text-decoration: none;
    border-radius: var(--r-sm);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 2px;
    position: relative;
    transition: var(--t);
}
.sidebar-nav a .nav-icon {
    font-size: 16px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
    transition: var(--t);
    color: var(--text-3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.sidebar-nav a .nav-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav a:hover {
    background: var(--surface-2);
    color: var(--text);
}
.sidebar-nav a:hover .nav-icon { color: var(--accent); transform: scale(1.08); }

.sidebar-nav a.active {
    background: linear-gradient(135deg, #7367F0, #9E95F5);
    color: #fff;
    box-shadow: 0 3px 10px rgba(115, 103, 240, 0.35);
}
.sidebar-nav a.active .nav-icon { color: #fff; }
.sidebar-nav a.active:hover {
    background: linear-gradient(135deg, #6E63E8, #948BF3);
}

.sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid var(--border);
}
.env-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 11px;
    color: var(--text-2);
    font-family: ui-monospace, monospace;
}
.env-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
    animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Backdrop — виден только на мобилке, когда sidebar открыт */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(34, 41, 47, 0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 28px;
    height: 72px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 3px rgba(34, 41, 47, 0.03);
}
.topbar-left {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.topbar-center { flex: 1; display: flex; justify-content: center; min-width: 0; }
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.page-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

/* shard pills */
.shard-pills { display: flex; gap: 6px; }
.shard-pills .pill {
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 11px;
    font-family: ui-monospace, monospace;
    background: var(--surface-3);
    color: var(--text-3);
    transition: var(--t);
}
.shard-pills .pill.connected {
    background: var(--success-bg);
    color: var(--success);
    box-shadow: 0 0 0 1px rgba(40, 199, 111, 0.2);
}
.shard-pills .pill.connecting {
    background: var(--warning-bg);
    color: var(--warning);
}
.shard-pills .pill.auth_failed,
.shard-pills .pill.disconnected {
    background: var(--danger-bg);
    color: var(--danger);
}

/* online summary */
.online-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12px;
    font-family: ui-monospace, monospace;
    white-space: nowrap;
}
.online-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    flex-shrink: 0;
}
.online-total { color: var(--success); font-weight: 700; }
.online-breakdown { display: flex; gap: 4px; color: var(--text-3); }
.online-breakdown .bd {
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--surface-3);
    font-size: 10px;
}
.online-breakdown .bd.online { color: var(--text); }
.online-breakdown .bd.offline { color: var(--text-3); opacity: 0.6; }

/* ws status */
.status { transition: var(--t); }
.ws-status {
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-weight: 500;
    white-space: nowrap;
}
.ws-status.ok  { color: var(--success); border-color: rgba(40, 199, 111, 0.3); background: var(--success-bg); }
.ws-status.warn { color: var(--warning); border-color: rgba(255, 159, 67, 0.3); background: var(--warning-bg); }
.ws-status.err { color: var(--danger); border-color: rgba(234, 84, 85, 0.3); background: var(--danger-bg); }

/* icon button */
.icon-btn {
    width: 38px; height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text-2);
    font-size: 15px;
    cursor: pointer;
    transition: var(--t);
    padding: 0;
    flex-shrink: 0;
}
.icon-btn:hover {
    background: var(--surface-3);
    border-color: var(--border-2);
    color: var(--accent);
    transform: translateY(-1px);
}
.icon-btn.danger:hover { color: var(--danger); border-color: rgba(234, 84, 85, 0.4); background: var(--danger-bg); }

/* Гамбургер нужен только на мобилке.
   Правило стоит ПОСЛЕ .icon-btn, чтобы не проиграть по каскаду. */
.sidebar-toggle { display: none; }

/* user chip */
.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 14px 4px 4px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    max-width: 240px;
}
.user-avatar {
    width: 30px; height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #7367F0, #A855F7);
    border-radius: 50%;
    font-size: 13px;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(115, 103, 240, 0.3);
}
.user-id {
    font-family: ui-monospace, monospace;
    font-size: 11px;
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
}

/* ============================================================
   CONTENT
   ============================================================ */
.content {
    padding: 28px 32px 60px;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}
.section { display: none; }
.section.active {
    display: block;
    animation: fade-up 0.25s cubic-bezier(.4, 0, .2, 1);
}
@keyframes fade-up {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.page-header h2 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
    color: var(--text);
}
.page-header .subtitle {
    color: var(--text-2);
    font-size: 13px;
}

/* tabs — включая внешние под-табы «Игрок» (.ptab-outer) */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.ptab, .atab, .etab, .stab, .ptab-outer, .btab {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 12px 18px;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    transition: var(--t);
    margin-bottom: -1px;
    border-bottom: 2px solid transparent;
    box-shadow: none;
    font-family: inherit;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.ptab:hover, .atab:hover, .etab:hover, .stab:hover, .ptab-outer:hover, .btab:hover {
    color: var(--text);
    background: transparent;
    transform: none;
}

.ptab.active, .atab.active, .etab.active, .stab.active, .ptab-outer.active, .btab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.ptab-body, .atab-body, .stab-body, .ptab-outer-body, .btab-body { padding: 6px 0; }
.stab-body.hidden, .ptab-outer-body.hidden, .btab-body.hidden { display: none !important; }

/* ============================================================
   CHART: meta-строка — квадратные плашки как .srm-row
   (Heap used / Heap limit из «Нагрузка шардов»)
   ============================================================ */
.chart-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
    padding: 0 2px;
}
.chart-meta:empty { display: none; }

.chart-meta-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 6px 10px;
    background: var(--surface-2);
    border: none;
    border-radius: 6px !important;
    font-family: ui-monospace, monospace;
    font-size: 12px;
    line-height: 1.2;
    min-width: 150px;
    white-space: nowrap;
}
.chart-meta-item .chart-meta-k {
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 10px;
    font-weight: 700;
}
.chart-meta-item .chart-meta-v,
.chart-meta-item b {
    color: var(--text);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-size: 13px;
    font-family: ui-monospace, monospace;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 260px;
        z-index: 100;
    }
    .sidebar.open { left: 0; box-shadow: var(--shadow-lg); }

    .sidebar-backdrop.open {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }

    body.sidebar-open { overflow: hidden; }

    .topbar {
        padding: 0 12px;
        gap: 8px;
        height: 60px;
    }
    .topbar-left {
        gap: 8px;
        flex-shrink: 1;
        min-width: 0;
        flex: 1;
    }
    .topbar-center { display: none; }

    .sidebar-toggle { display: inline-flex; }

    .page-title {
        font-size: 15px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0;
    }

    .topbar-right {
        gap: 6px;
        flex-shrink: 0;
    }

    .ws-status { display: none; }
    .online-breakdown { display: none; }
    #reconnectAllBtn { display: none; }
    .user-id { display: none; }

    .online-pill {
        padding: 5px 10px;
        gap: 6px;
        font-size: 11px;
    }

    .user-chip {
        padding: 4px;
        max-width: none;
    }

    .icon-btn {
        width: 34px;
        height: 34px;
        font-size: 14px;
    }

    .content { padding: 18px 16px 60px; }

    .page-header h2 { font-size: 19px; }
    .page-header { margin-bottom: 18px; }

    .player-stats-grid { grid-template-columns: repeat(2, 1fr); }

    .modal { padding: 20px; }
    .modal-backdrop { padding: 12px; }

    .action-row { padding: 12px; }
    .action-row input[type="number"],
    .action-row input[type="text"] { width: 100%; }
    .action-label { min-width: 100%; }

    .filter-bar { padding: 14px; }
    .filter-group { flex-direction: column; }
    .filter-group label,
    .search-inline { min-width: 100%; width: 100%; }

    .tabs { margin: 0 -16px 16px; padding: 0 16px; }
}

@media (max-width: 700px) {
    .bans-grid { grid-template-columns: 1fr; }
    .suspicious-grid { grid-template-columns: 1fr; }
    .shard-grid { grid-template-columns: 1fr; }

    .bonus-row { grid-template-columns: 1fr 80px; }
    .bonus-row > *:nth-child(n+3) { display: none; }

    .catalog-layout { grid-template-columns: 1fr; }
    .catalog-list-wrap { position: static; max-height: 320px; }

    .history-header, .history-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    .history-header { display: none; }
    .history-row {
        padding: 14px;
        border-left: 3px solid transparent;
    }
    .history-row > div { padding: 2px 0; }

    .analytics-hero { grid-template-columns: 1fr; }
    .hero-card .hc-value { font-size: 28px; }

    .page-header {
        flex-direction: column;
        align-items: stretch;
    }
    .page-header .btn-row { justify-content: flex-start; }

    .user-chip { display: none; }
    .online-pill { padding: 4px 8px; }
}

@media (max-width: 420px) {
    .page-title { font-size: 14px; max-width: 100px; }
    .online-pill { font-size: 10px; padding: 4px 8px; }
}