* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

[hidden] {
    display: none !important;
}

:root {
    --azul: #123b91;
    --azul-claro: #e8eefb;
    --laranja: #ff7900;
    --laranja-escuro: #e66d00;
    --fundo: #f2f4f8;
    --cartao: #ffffff;
    --texto: #2b3445;
    --apagado: #6b7487;
    --borda: #d8dde7;
    --verde: #1f9d55;
    --vermelho: #c0392b;
    --topo-seguro: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
    --baixo-seguro: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
}

html, body {
    height: 100%;
}

body {
    font-family: system-ui, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--fundo);
    color: var(--texto);
    font-size: 15px;
    overscroll-behavior: none;
}

button, input, textarea, select {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    border: 0;
    background: none;
}

/* ---------- Tela inicial ---------- */

.tela {
    min-height: 100%;
}

.topo {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: calc(10px + var(--topo-seguro)) 16px 10px;
    background: var(--cartao);
    border-bottom: 3px solid var(--laranja);
}

.marca {
    font-size: 19px;
    font-weight: 700;
    color: var(--azul);
    display: flex;
    align-items: center;
    gap: 6px;
}

.logo {
    background: var(--azul);
    color: white;
    border-radius: 8px;
    padding: 2px 7px;
    font-size: 15px;
    letter-spacing: .5px;
}

.servidor {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--apagado);
    min-width: 0;
}

.servidor span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.servidor i {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #e0a020;
    flex: none;
}

.servidor.ok i {
    background: var(--verde);
}

.servidor.erro i {
    background: var(--vermelho);
}

.icone {
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: 50%;
    border: 1.5px solid var(--borda);
    color: var(--azul);
    font-weight: 700;
    font-size: 16px;
}

.conteudo {
    padding: 14px 16px calc(24px + var(--baixo-seguro));
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 640px;
    margin: 0 auto;
}

.cartao {
    background: var(--cartao);
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(20, 30, 60, .08);
}

.cartao h2 {
    font-size: 16px;
    color: var(--azul);
    margin-bottom: 10px;
}

.meu {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
}

.meu small {
    display: block;
    font-size: 11px;
    color: var(--apagado);
    font-weight: 600;
    letter-spacing: .3px;
}

.meu strong {
    font-size: 20px;
    letter-spacing: .5px;
    color: var(--azul);
}

.licenca {
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 99px;
    background: var(--azul-claro);
    color: var(--azul);
}

.licenca.lic-alerta {
    background: #fff2e6;
    color: #a24b00;
}

.licenca.lic-erro {
    background: #fdecea;
    color: var(--vermelho);
}

label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--apagado);
    letter-spacing: .3px;
    margin: 10px 0 4px;
}

label.opcao {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 0;
    color: var(--texto);
}

input:not([type=checkbox]) {
    width: 100%;
    height: 46px;
    padding: 0 12px;
    border: 1.5px solid var(--borda);
    border-radius: 10px;
    background: white;
    font-size: 16px;
}

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

#campoId, #contatoId {
    text-transform: uppercase;
    letter-spacing: .5px;
}

.principal, .secundario, .whatsapp {
    height: 46px;
    padding: 0 18px;
    border-radius: 10px;
    font-weight: 600;
}

.principal {
    background: var(--laranja);
    color: white;
}

.principal:active {
    background: var(--laranja-escuro);
}

.principal:disabled {
    opacity: .6;
}

#btnConectar {
    width: 100%;
    margin-top: 14px;
}

.secundario {
    background: var(--azul-claro);
    color: var(--azul);
}

.whatsapp {
    background: #25d366;
    color: white;
    width: 100%;
    margin-top: 8px;
}

.link {
    color: var(--azul);
    font-weight: 600;
    font-size: 14px;
    padding: 6px 0;
}

.erro {
    color: var(--vermelho);
    font-size: 13px;
    margin-top: 10px;
}

.dica {
    color: var(--apagado);
    font-size: 13px;
    line-height: 1.45;
    margin: 6px 0;
}

.titulo-lista {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.titulo-lista h2 {
    margin: 0;
}

.contatos {
    list-style: none;
    margin-top: 8px;
}

.contatos li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-top: 1px solid var(--borda);
}

.contatos li:first-child {
    border-top: 0;
}

.contato-abrir {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    padding: 4px 0;
}

.contato-abrir .ponto {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #c3c9d4;
    flex: none;
}

.contato-abrir .ponto.on {
    background: var(--verde);
}

.contato-abrir div {
    min-width: 0;
}

.contato-abrir strong, .contato-abrir small {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contato-abrir small {
    color: var(--apagado);
    font-size: 12px;
}

.contato-acao {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    color: var(--apagado);
    display: grid;
    place-items: center;
    flex: none;
}

.contato-acao svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.contato-acao:active {
    background: var(--fundo);
}

.vazio {
    color: var(--apagado);
    font-size: 13px;
    line-height: 1.45;
    margin-top: 8px;
}

.rodape {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--apagado);
    font-size: 12px;
    padding: 0 4px;
}

/* ---------- Diálogos ---------- */

dialog {
    margin: auto;
    width: min(440px, calc(100% - 32px));
    max-height: calc(100% - 32px);
    border: 0;
    border-radius: 16px;
    padding: 20px;
    color: var(--texto);
    background: var(--cartao);
}

dialog::backdrop {
    background: rgba(10, 20, 45, .55);
}

dialog h2 {
    font-size: 18px;
    color: var(--azul);
    margin-bottom: 6px;
}

dialog h3 {
    font-size: 14px;
    margin-bottom: 6px;
}

.botoes {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.bloco {
    border-top: 1px solid var(--borda);
    padding: 14px 0 4px;
    margin-top: 10px;
    font-size: 14px;
}

.linha {
    display: flex;
    gap: 8px;
    align-items: center;
}

.linha output {
    flex: 1;
    font-weight: 700;
    font-size: 16px;
}

.planos {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 8px 0;
}

.plano {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1.5px solid var(--borda);
    border-radius: 10px;
    padding: 10px 12px;
}

.plano div {
    flex: 1;
}

.plano strong {
    display: block;
}

.plano small {
    color: var(--apagado);
}

.plano button {
    height: 38px;
    font-size: 13px;
    padding: 0 12px;
}

.gestos {
    padding-left: 18px;
    line-height: 1.5;
    font-size: 13px;
    color: var(--apagado);
}

.gestos li + li {
    margin-top: 6px;
}

.monitores {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.monitores button {
    height: 46px;
    border-radius: 10px;
    border: 1.5px solid var(--borda);
    text-align: left;
    padding: 0 14px;
}

.monitores button.atual {
    border-color: var(--azul);
    color: var(--azul);
    font-weight: 600;
}

/* ---------- Sessão ---------- */

.sessao {
    position: fixed;
    inset: 0;
    background: #0b0f17;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.palco {
    position: relative;
    flex: 1;
    overflow: hidden;
    touch-action: none;
}

#video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform-origin: 0 0;
    pointer-events: none;
    background: #0b0f17;
}


.cursor {
    position: absolute;
    left: 0;
    top: 0;
    width: 22px;
    height: 22px;
    pointer-events: none;
    z-index: 1;
    background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 2l16 11-7 1.4-3.6 6.6z' fill='%23fff' stroke='%23000' stroke-width='1.6' stroke-linejoin='round'/%3E%3C/svg%3E");
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .5));
}

.aviso {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 24px;
    text-align: center;
    color: #dfe5f2;
    background: #0b0f17;
}

.aviso p {
    max-width: 420px;
    line-height: 1.5;
}

.aviso.erro p {
    color: #ffb4a8;
}

.giro {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, .15);
    border-top-color: var(--laranja);
    animation: girar 1s linear infinite;
}

@keyframes girar {
    to { transform: rotate(360deg); }
}

.toast {
    position: absolute;
    left: 50%;
    top: calc(14px + var(--topo-seguro));
    transform: translateX(-50%);
    z-index: 4;
    max-width: calc(100% - 32px);
    background: rgba(20, 28, 45, .92);
    color: white;
    font-size: 13px;
    padding: 9px 14px;
    border-radius: 99px;
    text-align: center;
}

.teclas {
    background: #161c28;
    border-top: 1px solid #262f42;
    padding: 6px 0;
}

.faixa {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 4px 8px;
    scrollbar-width: none;
}

.faixa::-webkit-scrollbar {
    display: none;
}

.faixa button {
    flex: none;
    min-width: 44px;
    height: 38px;
    padding: 0 10px;
    border-radius: 8px;
    background: #273047;
    color: #e8ecf5;
    font-size: 13px;
    font-weight: 600;
}

.faixa button:active {
    background: #34405e;
}

.faixa button.ligada {
    background: var(--laranja);
    color: white;
}

.barra {
    display: flex;
    justify-content: space-around;
    background: #111724;
    border-top: 1px solid #262f42;
    padding: 4px 4px calc(4px + var(--baixo-seguro));
}

.barra button {
    flex: 1;
    max-width: 96px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 2px;
    color: #c9d1e2;
    font-size: 11px;
    border-radius: 10px;
}

.barra button svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.barra button.ligado {
    color: var(--laranja);
}

.barra button.perigo {
    color: #ff8a7a;
}

.barra button:active {
    background: #1e2638;
}

/* Deitado: barra na lateral para sobrar altura para a tela */
@media (orientation: landscape) and (max-height: 520px) {
    .sessao {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .palco {
        order: 1;
        flex: 1 1 0;
        height: 100%;
    }

    .barra {
        order: 2;
        flex-direction: column;
        justify-content: flex-start;
        width: 64px;
        height: 100%;
        border-top: 0;
        border-left: 1px solid #262f42;
        padding: calc(4px + var(--topo-seguro)) calc(4px + env(safe-area-inset-right, 0px)) 4px 4px;
        overflow-y: auto;
    }

    .barra button {
        flex: none;
        padding: 5px 2px;
        font-size: 10px;
    }

    .teclas {
        position: absolute;
        left: 0;
        right: 64px;
        bottom: 0;
        z-index: 2;
        background: rgba(22, 28, 40, .94);
    }
}

#entradaTexto {
    /* 16px: o iPhone não dá zoom na página ao abrir o teclado */
    font-size: 16px;
    position: fixed;
    left: 0;
    bottom: 0;
    width: 1px;
    height: 1px;
    opacity: 0;
    border: 0;
    resize: none;
    pointer-events: none;
}

.detalhe {
    flex-basis: 100%;
    margin-top: 2px;
    word-break: break-word;
}

/* Dica de instalação no iPhone (aberto pelo Safari) */
.instalar {
    background: #e8eefb;
    color: var(--azul);
    font-size: 14px;
    line-height: 1.5;
}

.instalar p {
    margin-top: 4px;
    color: var(--texto);
}

.instalar svg {
    width: 18px;
    height: 18px;
    vertical-align: -3px;
    fill: none;
    stroke: var(--azul);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* iPhone: sem menu de "copiar/salvar imagem" ao segurar o dedo na tela do computador */
.sessao, .palco, #video {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}
