* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: #0a0a0a;
    color: #e0e0e0;
    font-family: 'Segoe UI', monospace;
    min-height: 100vh;
}

.back-btn {
    position: fixed;
    top: 20px;
    right: 24px;
    z-index: 999;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(17,17,17,0.9);
    color: #888;
    border: 1px solid #2e2e2e;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    text-decoration: none;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: color 0.2s, border-color 0.2s, background 0.2s;
    cursor: pointer;
}
.back-btn:hover {
    color: #e8e8e8;
    border-color: #444;
    background: rgba(30,30,30,0.95);
}
.back-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    flex-shrink: 0;
}

#loginScreen {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.login-card {
    background: #111;
    border: 1px solid #222;
    border-radius: 16px;
    padding: 48px;
    width: 360px;
    text-align: center;
}

.login-card h2 {
    font-size: 18px;
    color: #fff;
    margin-bottom: 8px;
}

.login-card p {
    font-size: 12px;
    color: #444;
    margin-bottom: 32px;
}

.login-card input {
    width: 100%;
    background: #0a0a0a;
    border: 1px solid #222;
    border-radius: 8px;
    padding: 12px 16px;
    color: #fff;
    font-size: 14px;
    outline: none;
    margin-bottom: 12px;
    transition: border 0.2s;
}

.login-card input:focus { border-color: #444; }

.login-card button {
    width: 100%;
    background: #fff;
    color: #000;
    border: none;
    border-radius: 8px;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.login-card button:hover { opacity: 0.85; }

.error-msg {
    font-size: 12px;
    color: #ef4444;
    margin-top: 10px;
    display: none;
}

#mainScreen { display: none; }

.topbar {
    background: #111;
    border-bottom: 1px solid #1a1a1a;
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar h1 {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
}

.badge {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 11px;
    color: #555;
}

.admin-mode-badge {
    background: #1a1500;
    border: 1px solid #3a3000;
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 11px;
    color: #aa8800;
    display: none;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-input {
    background: #0a0a0a;
    border: 1px solid #1e1e1e;
    border-radius: 8px;
    padding: 8px 14px;
    color: #ccc;
    font-size: 13px;
    outline: none;
    width: 220px;
    transition: border 0.2s;
}

.search-input:focus { border-color: #333; }

.btn {
    background: #1a1a1a;
    border: 1px solid #222;
    color: #888;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover { background: #222; color: #fff; }

.btn-logout {
    background: transparent;
    border: 1px solid #2a1a1a;
    color: #663333;
}

.btn-logout:hover { background: #1a0a0a; color: #ef4444; border-color: #ef4444; }

.table-wrap {
    padding: 24px 32px;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    text-align: left;
    padding: 10px 16px;
    color: #444;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid #1a1a1a;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

thead th:hover { color: #777; }
thead th.sorted { color: #aaa; }

.sort-arrow {
    display: inline-block;
    margin-left: 5px;
    font-size: 10px;
    opacity: 0.8;
}

tbody tr {
    border-bottom: 1px solid #111;
    transition: background 0.15s;
}

tbody tr:hover { background: #111; }

tbody td {
    padding: 12px 16px;
    color: #bbb;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

td.vkid { color: #666; font-size: 12px; }
td.vkid .vkid-link {
    color: #5a7a9a;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.15s;
}
td.vkid .vkid-link:hover { color: #7aaac9; text-decoration: underline; }

.admin-mode td.vkid .vkid-link {
    color: #9a8a3a;
}
.admin-mode td.vkid .vkid-link:hover { color: #ccb84a; }

td.text { color: #e0e0e0; white-space: normal; }
td.cmd { font-family: monospace; color: #7a9ec9; font-size: 12px; }
td.activity { color: #444; font-size: 12px; }
td.admintext { color: #7a6a2a; font-size: 12px; font-family: monospace; white-space: normal; word-break: break-word; max-width: 240px; }

.admin-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.admin-0 { background: #111; color: #333; }
.admin-1 { background: #1a2a1a; color: #4a8a4a; border: 1px solid #2a3a2a; }
.admin-2 { background: #1a1a2a; color: #4a4a9a; border: 1px solid #2a2a3a; }
.admin-3 { background: #2a1a1a; color: #9a4a4a; border: 1px solid #3a2a2a; }
.admin-4 { background: #2a2a0a; color: #aaaa33; border: 1px solid #3a3a1a; }

.state-msg {
    text-align: center;
    padding: 80px 0;
    color: #333;
    font-size: 13px;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #222;
    border-top-color: #555;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.stats {
    display: flex;
    gap: 16px;
    padding: 24px 32px 0;
}

.stat {
    background: #111;
    border: 1px solid #1a1a1a;
    border-radius: 10px;
    padding: 14px 20px;
    min-width: 120px;
}

.stat-val { font-size: 22px; font-weight: 700; color: #fff; }
.stat-label { font-size: 11px; color: #444; margin-top: 4px; }

.info-bar {
    padding: 12px 32px;
    font-size: 12px;
    color: #333;
    border-bottom: 1px solid #111;
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    z-index: 100;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(3px);
}

.modal-overlay.open { display: flex; }

.modal {
    background: #111;
    border: 1px solid #222;
    border-radius: 16px;
    width: 420px;
    max-width: calc(100vw - 32px);
    padding: 28px;
    position: relative;
    animation: modal-in 0.18s ease;
}

@keyframes modal-in {
    from { transform: scale(0.95); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 16px; right: 16px;
    background: none;
    border: none;
    color: #444;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s;
}

.modal-close:hover { color: #fff; }

.modal-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.modal-avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #444;
    flex-shrink: 0;
}

.modal-title {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
}

.modal-sub {
    font-size: 12px;
    color: #444;
    margin-top: 2px;
}

.modal-section {
    margin-bottom: 20px;
}

.modal-section-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #333;
    margin-bottom: 10px;
}

.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.modal-btn {
    background: #1a1a1a;
    border: 1px solid #222;
    border-radius: 8px;
    padding: 10px 12px;
    color: #888;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-btn:hover { background: #222; color: #fff; }

.modal-btn.danger { border-color: #2a1a1a; color: #664444; }
.modal-btn.danger:hover { background: #1a0808; color: #ef4444; border-color: #3a1a1a; }

.modal-btn.success { border-color: #1a2a1a; color: #446644; }
.modal-btn.success:hover { background: #0a180a; color: #4aaa4a; border-color: #1a3a1a; }

.modal-btn.warning { border-color: #2a2a0a; color: #666633; }
.modal-btn.warning:hover { background: #181800; color: #cccc44; border-color: #3a3a1a; }

.modal-btn.primary { border-color: #1a2a3a; color: #446688; }
.modal-btn.primary:hover { background: #0a1828; color: #5a9acf; border-color: #1a3a5a; }

.modal-btn .icon { font-size: 14px; }

.modal-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 20px;
}

.modal-info-item {
    background: #0e0e0e;
    border: 1px solid #1a1a1a;
    border-radius: 8px;
    padding: 10px 12px;
}

.modal-info-key { font-size: 10px; color: #333; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.modal-info-val { font-size: 13px; color: #bbb; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.modal-admintext {
    background: #0e0e00;
    border: 1px solid #2a2a00;
    border-radius: 8px;
    padding: 12px;
    font-family: monospace;
    font-size: 12px;
    color: #8a8a22;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 20px;
    max-height: 120px;
    overflow-y: auto;
}

.modal-input {
    width: 100%;
    background: #0a0a0a;
    border: 1px solid #222;
    border-radius: 8px;
    padding: 10px 14px;
    color: #fff;
    font-size: 13px;
    outline: none;
    margin-bottom: 8px;
    transition: border 0.2s;
    font-family: 'Segoe UI', monospace;
}

.modal-input:focus { border-color: #444; }

.modal-send-row {
    display: flex;
    gap: 8px;
}

.modal-send-row .modal-input { margin-bottom: 0; flex: 1; }

.modal-send-btn {
    background: #1a2a3a;
    border: 1px solid #2a3a4a;
    color: #5a9acf;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.modal-send-btn:hover { background: #1a3a5a; color: #7ab8ef; }

.modal-feedback {
    font-size: 11px;
    margin-top: 8px;
    min-height: 16px;
    color: #555;
}

.modal-feedback.ok { color: #4a8a4a; }
.modal-feedback.err { color: #8a4a4a; }

.admin-level-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.level-btn {
    background: #111;
    border: 1px solid #222;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 11px;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
}

.level-btn:hover { border-color: #444; color: #aaa; }
.level-btn.active { border-color: #555; color: #fff; background: #1a1a1a; }

.divider {
    border: none;
    border-top: 1px solid #1a1a1a;
    margin: 16px 0;
}

@media (max-width: 768px) {
    .login-card { width: calc(100vw - 40px); padding: 32px 24px; }

    .topbar { padding: 10px 12px; flex-direction: column; align-items: stretch; gap: 8px; }
    .topbar-left { justify-content: space-between; align-items: center; }
    .topbar-right { flex-wrap: wrap; gap: 6px; }
    .search-input { width: 100%; flex: 1 1 100%; order: -1; font-size: 14px; }
    .btn { flex: 1; text-align: center; padding: 9px 8px; font-size: 11px; min-width: 0; }
    .admin-mode-badge { font-size: 10px; padding: 2px 7px; }

    .stats { padding: 12px 12px 0; flex-wrap: wrap; gap: 8px; }
    .stat { min-width: calc(50% - 4px); flex: 1; padding: 10px 14px; }
    .stat-val { font-size: 18px; }

    .info-bar { padding: 8px 12px; font-size: 11px; }

    .table-wrap { padding: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { font-size: 12px; min-width: 320px; }
    thead th { padding: 8px 10px; font-size: 10px; letter-spacing: 0.3px; }
    tbody td { padding: 10px; max-width: 120px; }
    td.text { max-width: 140px; }
    td.cmd { max-width: 90px; }

    thead th:nth-child(2),
    thead th:nth-child(3),
    tbody td:nth-child(2),
    tbody td:nth-child(3) { display: none; }

    tbody td:nth-child(1) { min-width: 70px; white-space: nowrap; }

    tbody td:nth-child(4) { min-width: 90px; white-space: nowrap; font-size: 11px; }

    td.admintext {
        max-width: none;
        white-space: normal;
        word-break: break-word;
        font-size: 12px;
        line-height: 1.5;
        width: 100%;
    }

    .modal-overlay { align-items: flex-end; }
    .modal {
        width: 100%;
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        padding: 20px 16px 32px;
        max-height: 88vh;
        overflow-y: auto;
    }
    .modal-close { top: 14px; right: 14px; font-size: 20px; padding: 4px 8px; }
    .modal-header { margin-bottom: 16px; gap: 10px; }
    .modal-avatar { width: 36px; height: 36px; font-size: 15px; }
    .modal-title { font-size: 14px; }
    .modal-sub { font-size: 11px; }

    .modal-info-grid { grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 14px; }
    .modal-info-item { padding: 8px 10px; }
    .modal-info-val { font-size: 12px; }

    .modal-actions { grid-template-columns: 1fr 1fr; gap: 6px; }
    .modal-btn { padding: 11px 10px; font-size: 12px; }

    .level-btn { padding: 8px 10px; font-size: 11px; flex: 1; text-align: center; }
    .admin-level-row { gap: 4px; }

    .modal-send-row { flex-direction: column; gap: 6px; }
    .modal-send-btn { width: 100%; text-align: center; padding: 11px; }

    .divider { margin: 12px 0; }
    .modal-section { margin-bottom: 14px; }
    .modal-section-label { margin-bottom: 7px; }
}

.error-modal {
    width: 360px;
    max-width: 90vw;
    background: #111;
    border: 1px solid #3a1a1a;           /* красноватый акцент */
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.15);
}

.error-modal .modal-title {
    color: #ef4444;
}

.error-modal .modal-sub {
    color: #aa4444;
}

.error-modal .modal-avatar {
    background: #2a0f0f;
    color: #ef4444;
    border-color: #3a1a1a;
}

.error-modal .modal-info-val {
    color: #ef4444;
    font-weight: 500;
}

@media (max-width: 480px) {
    .error-modal {
        width: 92vw;
        padding: 20px 16px;
    }
}