:root {
  --bg: #f4f5f7; --fg: #1d2330; --muted: #6b7280; --panel: #ffffff;
  --accent: #0b6bcb; --ok: #15803d; --warn: #b45309; --bad: #b91c1c; --border: #d6d9de;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14161a; --fg: #e6e8eb; --muted: #9aa1ab; --panel: #1d2026; --border: #30343c; --accent: #4c9be8; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 14px/1.4 "Segoe UI", system-ui, sans-serif; }
body { display: flex; flex-direction: column; }
header { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.spacer { flex: 1; }
.status { color: var(--muted); }
.version { font-weight: normal; color: var(--muted); font-size: 12px; }
.status.ok { color: var(--ok); } .status.warn { color: var(--warn); } .status.bad { color: var(--bad); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
button, input, select { font: inherit; }
select { padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--fg); }
button { padding: 6px 12px; border: 1px solid var(--border); background: var(--panel); color: var(--fg); border-radius: 6px; cursor: pointer; }
button[type=submit] { background: var(--accent); color: #fff; border-color: var(--accent); }
/* Barra de progresso a percorrer um botão (enviar ao cliente, receber do cliente): --progress vai de 0% a 100%. */
button.progress { position: relative; overflow: hidden; }
button.progress::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: var(--progress, 0%); background: var(--accent); opacity: .35; transition: width .15s linear; pointer-events: none; }
button.progress:disabled { cursor: progress; }
.switch { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.hidden { display: none !important; }
.banner { display: flex; align-items: center; gap: 10px; padding: 6px 16px; background: var(--panel); border-bottom: 1px solid var(--warn); flex-wrap: wrap; }
.banner-close { padding: 0 8px; margin-left: auto; }
main { flex: 1; min-height: 0; display: flex; }
.lobby { margin: 32px auto; padding: 0 16px; width: 100%; max-width: 520px; }
.lobby form { display: flex; gap: 8px; align-items: end; }
.lobby form.login { flex-direction: column; align-items: stretch; max-width: 320px; }
.lobby form.login input { font-size: 16px; letter-spacing: normal; }
.lobby label { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.lobby input { padding: 8px; font-size: 20px; letter-spacing: 4px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--fg); }
.sessions { list-style: none; padding: 0; }
.sessions li { padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 6px; background: var(--panel); display: flex; justify-content: space-between; gap: 8px; }
.sessions li.clickable { cursor: pointer; }
.sessions li.clickable:hover { border-color: var(--accent); }
.muted { color: var(--muted); }
.viewer { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; background: #000; overflow: hidden; }
.viewer canvas { max-width: 100%; max-height: 100%; outline: none; cursor: default; }
.viewer.control canvas, .viewer.control .input-layer { cursor: crosshair; }
.input-layer { position: absolute; left: 0; top: 0; width: 0; height: 0; outline: none; caret-color: transparent; color: transparent; user-select: none; overflow: hidden; }
.viewer.ended canvas { filter: brightness(.25) grayscale(.6); cursor: default; }
.viewer.dragover { outline: 3px dashed var(--accent); outline-offset: -3px; }
.toast { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); color: #fff; background: rgba(20,20,20,.9); border: 1px solid var(--border); padding: 8px 14px; border-radius: 6px; max-width: 80%; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); margin-left: 4px; vertical-align: middle; }
.dot.active { background: var(--ok); } .dot.waiting { background: var(--warn); }
.modal-box.ended { border: 2px solid var(--bad); }
.modal-box.ended h2 { color: var(--bad); font-size: 24px; }
.overlay { position: absolute; color: #ddd; background: rgba(0,0,0,.6); padding: 8px 14px; border-radius: 6px; }
.cursor { position: absolute; left: 0; top: 0; width: 16px; height: 24px; pointer-events: none; filter: drop-shadow(0 1px 1px rgba(0,0,0,.5)); image-rendering: auto; }

/* Página do cliente pelo browser */
.code { font-size: 40px; font-weight: 700; letter-spacing: 6px; color: var(--accent); }
.preview { width: 100%; max-height: 260px; background: #000; border-radius: 6px; margin-top: 8px; }
.notice { padding: 10px 12px; border: 1px solid var(--warn); border-radius: 6px; margin-bottom: 12px; background: var(--panel); }
.lobby-links { margin-top: 24px; }
.download { margin-top: 10px; font-size: 13px; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 10; }
.modal-box { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 20px 24px; max-width: 440px; margin: 16px; }
.modal-box h2 { margin-top: 0; }
.modal-actions { display: flex; gap: 8px; margin-bottom: 0; }
.modal-actions button:first-child { background: var(--accent); color: #fff; border-color: var(--accent); }
.modal-box.wide { max-width: 640px; width: 100%; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field input, .inline-form input[type=text], .inline-form input[type=password], .inline-form input:not([type]) { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--fg); }
.table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.table th, .table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.table td:last-child, .table td:nth-child(2) { text-align: right; white-space: nowrap; }
.table .row-form { display: inline-flex; gap: 6px; align-items: center; }
.badge { font-size: 12px; color: var(--accent); border: 1px solid var(--accent); border-radius: 10px; padding: 0 6px; margin-left: 6px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
button.danger { color: var(--bad); border-color: var(--bad); }
a.button { display: inline-block; padding: 8px 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--fg); text-decoration: none; }
a.button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
a { color: var(--accent); }
/* Página de entrada: as três formas de entrar, uma por bloco, com o botão à cabeça e a explicação por baixo. */
.login-options { display: flex; flex-direction: column; gap: 10px; }
.login-option { padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.login-option .button { font-size: 15px; padding: 8px 16px; min-width: 200px; text-align: center; }
.login-option button.button.open { border-color: var(--accent); color: var(--accent); }
.login-option p { margin: 8px 0 0; font-size: 13px; }
.login-option form.login { margin-top: 10px; }
/* Sessão só de visualização (entrada por palavra-passe): aviso na página do técnico. */
.notice.view-only { margin-bottom: 16px; }
/* Autenticador: QR ao lado da chave para introdução manual. */
.auth-qr { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 10px; }
.auth-qr img { width: 180px; height: 180px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.auth-key { font: 16px/1.5 Consolas, "Courier New", monospace; letter-spacing: 1px; word-break: break-all; margin: 0 0 6px; }
#authStatus p { margin: 0 0 8px; }
#authStatus .modal-actions { margin: 10px 0 14px; }
