:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #2563eb;
  --primary-h: #1d4ed8;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--err); }
.ok-text { color: var(--ok); }

.btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: #475569; background: #314158; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); }
.btn.primary:hover:not(:disabled) { background: var(--primary-h); }
.btn.danger { color: #fca5a5; }
.btn.danger:hover:not(:disabled) { background: #7f1d1d; border-color: #991b1b; color: #fff; }
.btn.small { padding: 4px 10px; font-size: 13px; }
input, select {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 14px;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.pill { font-size: 12px; padding: 3px 10px; border-radius: 99px; background: var(--panel-2); color: var(--muted); }
.pill.ok { background: #14532d; color: #bbf7d0; }
.pill.warn { background: #78350f; color: #fde68a; }
.pill.err { background: #7f1d1d; color: #fecaca; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; padding: 32px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin: 0 0 6px; text-align: center; font-size: 22px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.login-card .btn { justify-content: center; padding: 10px; margin-top: 6px; }
.logo { width: 56px; height: 56px; align-self: center; }
.logo-sm { width: 26px; height: 26px; }

/* dashboard */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 18px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.container { max-width: 1280px; margin: 0 auto; padding: 24px; }
.summary { color: var(--muted); margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.agent { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.agent.offline { opacity: .6; }
.agent-head { display: flex; align-items: center; gap: 10px; }
.agent-name { margin: 0; font-size: 17px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.off { background: #64748b; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: #312e81; color: #c7d2fe; }
.agent-info { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 13px; }
.agent-info dt { color: var(--muted); }
.agent-info dd { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }

/* visualizador */
.viewer-page { display: flex; flex-direction: column; overflow: hidden; }
.toolbar {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.tb-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tb-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.tb-label select { padding: 4px 8px; font-size: 13px; }
.toolbar > .tb-group > select { padding: 6px 8px; font-size: 13px; }
.viewer-body { flex: 1; display: flex; min-height: 0; }
.stage { flex: 1; position: relative; background: #000; outline: none; min-width: 0; }
.stage:focus-visible { box-shadow: inset 0 0 0 2px var(--primary); }
#screen { width: 100%; height: 100%; object-fit: contain; display: block; cursor: default; }
.overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(15, 23, 42, .85); font-size: 18px; color: var(--muted); text-align: center; padding: 20px;
}
.drop-hint {
  position: absolute; inset: 16px; display: grid; place-items: center; border: 3px dashed var(--primary);
  border-radius: 16px; background: rgba(37, 99, 235, .15); font-size: 20px; pointer-events: none;
}

/* painel de arquivos */
.files {
  width: 380px; flex: none; background: var(--panel); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
.files-head { display: flex; justify-content: space-between; align-items: center; padding: 12px; border-bottom: 1px solid var(--border); }
.files-path { display: flex; gap: 6px; padding: 10px 12px 0; }
.files-path input { flex: 1; min-width: 0; padding: 4px 8px; font-size: 13px; }
.files-actions { display: flex; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.files-list { list-style: none; margin: 0; padding: 4px 0; overflow: auto; flex: 1; min-height: 120px; }
.files-list li { display: flex; align-items: center; gap: 8px; padding: 5px 12px; font-size: 13px; }
.files-list li:hover { background: var(--panel-2); }
.files-list li.muted, .files-list li.error { justify-content: center; padding: 16px; }
.f-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files-list li.dir .f-name { cursor: pointer; }
.files-list li.dir .f-name:hover { color: #93c5fd; }
.f-size { color: var(--muted); font-size: 12px; }
.transfers-head { padding: 8px 12px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--border); }
.transfers { list-style: none; margin: 0; padding: 0 12px 12px; max-height: 30%; overflow: auto; }
.transfers li { padding: 6px 0; font-size: 12px; border-bottom: 1px solid var(--border); }
.transfers progress { width: 100%; height: 6px; }
.t-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 800px) {
  .files { position: absolute; right: 0; top: 0; bottom: 0; width: 100%; z-index: 5; }
  .viewer-body { position: relative; }
}
