:root {
    --bg: #0f172a;
    --card: #1e293b;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --primary: #6366f1;
    --online: #22c55e;
    --offline: #64748b;
    --danger: #ef4444;
    --radius: 12px;
    --touch: 44px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom);
}

.page-auth {
    display: grid;
    place-items: center;
    padding: 1rem;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.25rem;
    width: min(100%, 420px);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .75rem 1rem;
    background: var(--card);
    position: sticky;
    top: 0;
    z-index: 10;
}

.toolbar {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    padding: .75rem 1rem;
}

input, select, button, .btn {
    min-height: var(--touch);
    font-size: 1rem;
    border-radius: 8px;
}

input, select {
    width: 100%;
    border: 1px solid #334155;
    background: #0f172a;
    color: var(--text);
    padding: .5rem .75rem;
}

label { display: block; margin-bottom: 1rem; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .5rem 1rem;
    text-decoration: none;
    border: none;
    cursor: pointer;
    color: var(--text);
    background: #334155;
}

.btn.primary { background: var(--primary); color: #fff; }
.btn.small { min-height: 36px; font-size: .875rem; }
.btn.full { width: 100%; }

.client-list {
    list-style: none;
    margin: 0;
    padding: 0 1rem 2rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.client-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: .75rem;
    align-items: center;
    background: var(--card);
    border-radius: var(--radius);
    padding: .75rem;
}

.client-info { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.client-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.online { background: var(--online); box-shadow: 0 0 8px var(--online); }
.status-dot.offline { background: var(--offline); }

.muted { color: var(--muted); font-size: .875rem; }
.mono { font-family: ui-monospace, monospace; font-size: .8rem; color: var(--muted); }
.device-specs { font-size: .75rem; color: #a5b4fc; line-height: 1.3; }
.flash { margin: .75rem 1rem; padding: .75rem; border-radius: 8px; font-size: .9rem; }
.flash.ok { background: #14532d; color: #bbf7d0; }
.flash.err { background: #451a1a; color: #fecaca; }
.section-block { padding: 0 1rem 1rem; }
.section-title { font-size: 1rem; margin: 0 0 .25rem; }
.section-desc { margin: 0 0 .75rem; font-size: .875rem; }
.unassigned-item { grid-template-columns: auto 1fr; align-items: start; }
.add-agent-form { display: flex; flex-direction: column; gap: .5rem; width: 100%; }
.inline-label { margin: 0; }
.inline-label input { margin-top: .25rem; }
.download-card h1 { margin-top: 0; font-size: 1.25rem; }
.install-steps { margin: 1.25rem 0 0; padding-left: 1.25rem; color: var(--muted); font-size: .9rem; }
.install-steps a { color: #a5b4fc; }
.alert { background: #451a1a; color: #fecaca; padding: .75rem; border-radius: 8px; margin-bottom: 1rem; }
.footer-note { text-align: center; padding: 1rem; }
.note { background: #0f172a; padding: .75rem; border-radius: 8px; margin: 1rem 0; font-size: .9rem; }
.actions { display: flex; flex-direction: column; gap: .75rem; margin-top: 1rem; }

.page-control .card { width: min(100%, 960px); margin: 0 auto 1rem; padding: 1rem; }
.control-tabs { display: flex; gap: .5rem; margin: 1rem 0; }
.control-tabs .tab.active { background: var(--primary); color: #fff; }
.control-tab-panel.hidden { display: none; }
.web-viewer-wrap {
    position: relative;
    width: 100%;
    height: min(70dvh, 640px);
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}
.web-viewer-wrap iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

@media (min-width: 768px) {
    .toolbar { flex-direction: row; }
    .toolbar input { flex: 1; }
}
