* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
body {
    background: #eef1f5;
    height: 100vh;
    overflow: hidden;
}
.app {
    display: flex;
    height: 100vh;
}
.sidebar {
    width: 320px;
    min-width: 320px;
    background: #ffffff;
    border-right: 1px solid #dce1e9;
    box-shadow: 2px 0 12px rgba(0,0,0,0.03);
    display: flex;
    flex-direction: column;
    padding: 16px;
    overflow-y: auto;
    transition: display 0.3s; /* для плавності, але display не анімується, можна замінити на transform */
}
.sidebar.hidden {
    display: none; /* повне приховування */
}
.sidebar header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.sidebar header h2 {
    font-size: 20px;
    color: #1e293b;
}
#refreshBtn {
    background: none;
    border: none;
    font-size: 18px;
    color: #475569;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 8px;
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}
#refreshBtn:hover {
    background: #e9edf2;
    color: #1a73e8;
    transform: scale(1.05);
}
#refreshBtn:active {
    transform: scale(0.9);
}
#refreshBtn:disabled {
    cursor: default;
    color: #1a73e8;
}
.stats {
    display: flex;
    gap: 20px;
    background: #f3f5f9;
    padding: 10px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.02);
    transition: box-shadow 0.2s ease;
}
.stats.refreshing {
    box-shadow: inset 0 0 0 1px rgba(26,115,232,0.25), inset 0 1px 3px rgba(0,0,0,0.02);
}
.stats .online { color: #2e7d32; }
.stats .offline { color: #c62828; }
.list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.list-item {
    background: #f8fafc;
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
    border-left: 4px solid #cbd5e1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation: itemIn 0.25s ease both;
}
@keyframes itemIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}
.list-item:hover {
    background: #f1f4f9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}
.list-item.active {
    background: #e8f0fe;
    border-left-color: #1a73e8;
    box-shadow: 0 2px 8px rgba(26,115,232,0.12);
}
.list-item.online {
    border-left-color: #34a853;
}
.list-item.offline {
    border-left-color: #ea4335;
    opacity: 0.6;
}
.list-item.active .item-name {
    color: #1a73e8;
}
.list-item .item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.list-item .item-name {
    font-weight: 600;
    font-size: 15px;
    color: #1a1a2e;
}
.list-item .item-ip {
    font-size: 12px;
    color: #666;
}
.item-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}
.item-actions button {
    background: white;
    border: 1px solid #dce1e9;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.item-actions button:hover:not(:disabled) {
    background: #e9edf2;
    border-color: #b0b8c4;
}
.item-actions button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.item-actions button.primary {
    background: #1a73e8;
    color: white;
    border-color: #1a73e8;
}
.item-actions button.primary:hover:not(:disabled) {
    background: #1557b0;
    border-color: #1557b0;
}
.loading {
    text-align: center;
    color: #666;
    padding: 30px 0;
    animation: itemIn 0.2s ease both;
}
.main {
    flex: 1;
    background: #1a1a2e;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
#videoContainer {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}
#remoteVideo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #0d0d1a;
}
.placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aaa;
    font-size: 24px;
    background: #1a1a2e;
    pointer-events: none;
}

/* ===== КНОПКА ПЕРЕМИКАННЯ САЙДБАРУ (завжди видима) ===== */
.menu-toggle {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 20;
    background: rgba(0,0,0,0.6);
    border: none;
    color: white;
    font-size: 24px;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}
.menu-toggle:hover {
    background: rgba(0,0,0,0.8);
}

/* ===== ВЕРХНЯ ІНФОРМАЦІЙНА ПАНЕЛЬ ===== */
#screenInfo {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding: 8px 10px 8px 10px;
    border-radius: 40px;
    display: none;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.28);
    border: 1px solid rgba(255,255,255,0.09);
    z-index: 10;
    pointer-events: auto;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    max-width: calc(100% - 32px);
}
#screenInfo.visible {
    display: flex;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
#screenInfo .screen-avatar {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a73e8, #1557b0);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0;
}
#screenInfo .screen-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}
#screenInfo .screen-name {
    color: #f8fafc;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}
#screenInfo .screen-ip {
    color: #94a3b8;
    font-size: 11px;
    white-space: nowrap;
}
#screenInfo .screen-status {
    color: #4ade80;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding-left: 10px;
    margin-left: 2px;
    border-left: 1px solid rgba(255,255,255,0.12);
    white-space: nowrap;
}
#screenInfo .screen-status .dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 rgba(74, 222, 128, 0.5);
    animation: pulse-dot 1.8s infinite;
}
#screenInfo.connecting .screen-status .dot {
    background: #fbbf24;
    animation: pulse-dot 0.9s infinite;
}
#screenInfo.connecting .screen-status {
    color: #fbbf24;
}
@keyframes pulse-dot {
    0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.45); }
    70% { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); }
    100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}
#closeScreenBtn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #e2e8f0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
#closeScreenBtn:hover {
    background: rgba(255,255,255,0.22);
    color: white;
    transform: rotate(90deg);
}

/* ===== СТАРУ ПАНЕЛЬ КЕРУВАННЯ ПОВНІСТЮ ХОВАЄМО ===== */
#controls {
    display: none !important;
}

/* ===== МОБІЛЬНА АДАПТАЦІЯ ===== */
@media (max-width: 768px) {
    .app {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        min-width: unset;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid #dce1e9;
        transition: max-height 0.3s ease;
        overflow-y: auto;
        padding: 12px;
        /* на мобільних display не змінюємо, використовуємо max-height для анімації */
    }
    .sidebar.hidden {
        display: flex; /* повертаємо flex, щоб застосувався max-height */
        max-height: 0;
        padding: 0 12px;
        overflow: hidden;
        border-bottom: none;
    }
    .main {
        flex: 1;
        height: 60vh;
    }
    .menu-toggle {
        top: 12px;
        left: 12px;
        font-size: 20px;
        padding: 6px 10px;
    }
    #screenInfo {
        top: 12px;
        padding: 6px 8px;
        gap: 8px;
        font-size: 13px;
    }
    #screenInfo .screen-avatar {
        width: 26px;
        height: 26px;
        font-size: 12px;
    }
    #screenInfo .screen-name {
        font-size: 12.5px;
        max-width: 100px;
    }
    #screenInfo .screen-ip {
        font-size: 10px;
    }
    #screenInfo .screen-status {
        font-size: 10px;
        padding-left: 8px;
    }
    #closeScreenBtn {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
    .stats {
        font-size: 13px;
        gap: 12px;
        flex-wrap: wrap;
    }
    .list-item .item-name {
        font-size: 14px;
    }
    .modal-content {
        padding: 24px;
        max-width: 90%;
    }
}

/* ===== ПОКРАЩЕНИЙ ДИЗАЙН МОДАЛЬНОГО ВІКНА ПАРОЛЯ ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}
.modal-content {
    background: linear-gradient(145deg, #ffffff, #f0f4ff);
    padding: 40px 32px;
    border-radius: 24px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: transform 0.2s;
    position: relative;
    overflow: hidden;
}
.modal-content::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 20%, rgba(25, 118, 210, 0.05), transparent 60%);
    pointer-events: none;
}
.modal-content h2 {
    font-size: 28px;
    color: #0d1b3e;
    margin-bottom: 8px;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.modal-content h2 i {
    color: #1976d2;
    margin-right: 10px;
}
.modal-content p {
    color: #5a6a8a;
    font-size: 15px;
    margin-bottom: 28px;
    line-height: 1.5;
}
.modal-content input {
    width: 100%;
    padding: 14px 18px;
    font-size: 16px;
    border: 2px solid #dce3ef;
    border-radius: 12px;
    background: #ffffff;
    transition: border-color 0.3s, box-shadow 0.3s;
    margin-bottom: 20px;
    outline: none;
    color: #1a1a2e;
}
.modal-content input:focus {
    border-color: #1976d2;
    box-shadow: 0 0 0 4px rgba(25, 118, 210, 0.15);
}
.modal-content button {
    background: linear-gradient(135deg, #1976d2, #1565c0);
    color: white;
    border: none;
    padding: 14px 32px;
    font-size: 18px;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.25s;
    width: 100%;
    letter-spacing: 0.3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.modal-content button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(25, 118, 210, 0.35);
    background: linear-gradient(135deg, #1e88e5, #0d47a1);
}
.modal-content button:active {
    transform: translateY(0);
}
#loginError {
    margin-top: 16px;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 12px;
    background: #ffebee;
    border-radius: 8px;
    color: #c62828;
    display: none;
}
#loginError i {
    margin-right: 6px;
}
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}
@media (max-width: 480px) {
    .modal-content {
        padding: 28px 20px;
    }
    .modal-content h2 {
        font-size: 24px;
    }
    .modal-content input {
        padding: 12px 14px;
        font-size: 15px;
    }
    .modal-content button {
        font-size: 16px;
        padding: 12px 20px;
    }
}