:root {
    --bg: #0f1419;
    --surface: #1a2332;
    --border: #2d3a4f;
    --text: #e7ecf3;
    --muted: #8b9cb3;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #22c55e;
    --danger: #ef4444;
}

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

body {
    font-family: "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.container { max-width: 860px; margin: 0 auto; padding: 2rem 1.25rem; }

header { margin-bottom: 1.5rem; }
header h1 { font-size: 1.75rem; margin-bottom: 0.35rem; }
header p, .muted { color: var(--muted); font-size: 0.95rem; }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.panel h2 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-bottom: 1rem;
}

.form label,
.inline-label {
    display: block;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.inline-label select {
    display: block;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.form input {
    display: block;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.form small { color: var(--muted); font-size: 0.8rem; }

button, .btn-primary, .btn-secondary {
    font: inherit;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.actions { display: flex; gap: 0.75rem; margin-top: 1rem; }

.msg { margin-top: 1rem; font-size: 0.9rem; }
.msg.success { color: var(--success); }
.msg.error { color: var(--danger); }

.camera-list { display: flex; flex-direction: column; gap: 0.75rem; }

.camera-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.camera-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
}

.badge {
    font-size: 0.72rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: var(--bg);
    color: var(--muted);
}

.badge.live { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.badge.offline { background: rgba(139, 156, 179, 0.15); }

.urls { font-size: 0.82rem; margin-top: 0.5rem; word-break: break-all; }
a { color: var(--accent); }

.stream-wrap {
    background: #000;
    border-radius: 8px;
    aspect-ratio: 16/9;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.stream-wrap video,
#preview {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    background: #000;
    aspect-ratio: 16/9;
    object-fit: contain;
    display: none;
}

.stream-wrap video.active,
#preview {
    display: block;
}

#preview {
    object-fit: cover;
}

.placeholder { color: var(--muted); padding: 2rem; text-align: center; }
.status-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    font-size: 0.95rem;
}

.status-bar.monitoring { border-color: var(--border); }
.status-bar.recording { border-color: var(--danger); background: rgba(239, 68, 68, 0.1); }
.status-bar.saving { border-color: #f59e0b; background: rgba(245, 158, 11, 0.1); }
.status-bar.error { border-color: var(--danger); }

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--muted);
    flex-shrink: 0;
}

.status-dot.monitoring { background: var(--success); }
.status-dot.recording { background: var(--danger); box-shadow: 0 0 8px var(--danger); animation: pulse 1s infinite; }
.status-dot.saving { background: #f59e0b; animation: pulse 0.6s infinite; }
.status-dot.error { background: var(--danger); }

@keyframes pulse {
    50% { opacity: 0.4; }
}

.video-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.video-stage video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.video-stage canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.status-text.live { color: var(--success); }
.status-text.error { color: var(--danger); }
