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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #0f1115;
    color: #e4e6eb;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    padding: 12px 20px;
    background: #161922;
    border-bottom: 1px solid #232733;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
header h1 { font-size: 18px; font-weight: 600; }
#status { font-size: 13px; color: #8a8f9c; }
#status.ok { color: #4ade80; }
#status.bad { color: #f87171; }

main {
    flex: 1;
    display: flex;
    min-height: 0;
}

#sidebar {
    width: 280px;
    background: #131620;
    border-right: 1px solid #232733;
    padding: 16px;
    overflow-y: auto;
}
#sidebar h2 {
    font-size: 14px;
    margin-bottom: 12px;
    color: #8a8f9c;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
#deviceCount { color: #4a4f5c; }

#deviceList { list-style: none; }
.deviceItem {
    padding: 10px 12px;
    background: #1c1f2b;
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: border-color 0.15s;
}
.deviceItem:hover { border-color: #2d3344; }
.deviceItem.active {
    border-color: #4f8cff;
    background: #1a2238;
}
.deviceItem.offline { opacity: 0.5; }
.deviceModel { font-size: 14px; font-weight: 500; }
.deviceMeta {
    font-size: 11px;
    color: #6b7080;
    margin-top: 4px;
    display: flex;
    gap: 8px;
}
.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}
.dot.on { background: #4ade80; }
.dot.off { background: #6b7080; }
.dot.viewing { background: #facc15; }

#viewer {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    min-width: 0;
}
#viewerEmpty { color: #6b7080; font-size: 14px; }

.stateBadge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}
.stateBadge.online {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.3);
}
.stateBadge.offline {
    background: rgba(248, 113, 113, 0.15);
    color: #f87171;
    border: 1px solid rgba(248, 113, 113, 0.3);
}

.canvasWrap {
    position: relative;
    flex: 1;
    background: #000;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}
.offlineOverlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}
.offlineMsg {
    color: #f87171;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
}


#viewerActive {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}
.viewerHeader {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
    font-size: 13px;
}
#viewerTitle { font-weight: 600; flex: 1; }
#viewerFps { color: #8a8f9c; font-variant-numeric: tabular-nums; }
#btnClose {
    padding: 6px 12px;
    background: #2a2f3d;
    border: 1px solid #3a3f4d;
    color: #e4e6eb;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}
#btnClose:hover { background: #353b4d; }
#screen {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: crosshair;
    image-rendering: -webkit-optimize-contrast;
}
.hint {
    text-align: center;
    color: #6b7080;
    font-size: 12px;
    margin-top: 8px;
}
