:root {
    --bg: #0f172a;
    --card: #1e293b;
    --border: #334155;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --erro: #f87171;
    --sucesso: #4ade80;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, "Segoe UI", Arial, sans-serif;
    min-height: 100vh;
}

#telaLogin {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 32px;
    width: 100%;
    max-width: 360px;
}

.card h1 {
    font-size: 20px;
    margin: 0 0 4px;
}

.card p.sub {
    color: var(--muted);
    font-size: 13px;
    margin: 0 0 24px;
}

label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
    color: var(--muted);
    margin-bottom: 6px;
    text-transform: uppercase;
}

input[type="text"], input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 16px;
    background: #0b1220;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
}

input:focus {
    outline: none;
    border-color: var(--accent);
}

button {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.6; cursor: default; }

#status {
    margin-top: 14px;
    font-size: 13px;
    min-height: 18px;
}

#status.erro { color: var(--erro); }
#status.ok { color: var(--sucesso); }

#telaSessao {
    display: none;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* celular: 100vh conta a barra de endereço do navegador e sobra scroll */
    position: relative;
    overscroll-behavior: none;
}

#barraSessao {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

#barraSessao .device { font-weight: 700; }
#barraSessao .badge {
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    background: #052e1c;
    color: var(--sucesso);
}
#barraSessao .spacer { flex: 1; }
#barraSessao button {
    width: auto;
    padding: 6px 14px;
    font-size: 12px;
    background: transparent;
    border: 1px solid var(--erro);
    color: var(--erro);
}
#barraSessao button:hover { background: rgba(248,113,113,0.12); }

#areaTela {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    overflow: hidden;
    position: relative;
}

#canvasTela {
    max-width: 100%;
    max-height: 100%;
    cursor: none;
    /* Sem isso o navegador do celular tenta rolar/dar zoom com o dedo em vez de deixar a gente
       tratar o toque como clique/arraste do mouse remoto -- mesmo problema que qualquer app de
       desenho ou controle remoto por toque precisa resolver. */
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Botão flutuante que só existe pra dar foco no campo de texto escondido e abrir o teclado
   do celular -- desktop não precisa dele (já tem teclado físico), mas não atrapalha deixar
   sempre visível, é pequeno e discreto. */
#btnTeclado {
    position: absolute;
    right: 16px;
    bottom: 16px;
    width: 52px;
    height: 52px;
    border-radius: 26px;
    padding: 0;
    font-size: 20px;
    background: var(--accent);
    box-shadow: 0 4px 14px rgba(0,0,0,0.4);
    z-index: 5;
}

#campoTecladoMovel {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
}

@media (max-width: 480px) {
    .card { padding: 24px 20px; }
    #barraSessao { padding: 8px 12px; font-size: 12px; }
    #barraSessao .device { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
