:root {
    --azul: #0039A6;
    --laranja: #FF6B00;
    --cinza-claro: #f4f5f7;
    --cinza-borda: #dcdfe4;
    --texto: #2b2f36;
    --branco: #ffffff;
    --verde: #1e9e5a;
    --vermelho: #d33b3b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Verdana, sans-serif;
    background: var(--cinza-claro);
    color: var(--texto);
}

/* ===========================
   Topo / Header responsivo
   =========================== */
.topo {
    background: var(--azul);
    color: var(--branco);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
    z-index: 200;
}

.logo-topo {
    height: 46px;
    width: auto;
    flex-shrink: 0;
}

.topo-textos {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 0;
}

.topo h1 {
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.subtitulo {
    font-size: 12px;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Hambúrguer --- */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    flex-shrink: 0;
    margin-left: auto;
}

.nav-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--branco);
    border-radius: 2px;
    transition: transform 0.25s, opacity 0.25s;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}
.nav-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* --- Nav desktop --- */
.topo-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
}

.nav-usuario {
    display: none; /* só aparece no mobile */
}

.usuario-nome {
    font-weight: 600;
    font-size: 13px;
    color: var(--branco);
    margin-right: 6px;
}

/* Nome visível no topo em desktop */
.usuario-nome-topo {
    display: none;
}

/* Barra de usuário abaixo do header — sempre visível */
.barra-usuario-mobile {
    background: #002d80;
    color: rgba(255,255,255,0.85);
    font-size: 12px;
    padding: 6px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.barra-usuario-mobile strong {
    color: #fff;
}

@media (max-width: 700px) {
    .usuario-nome-topo {
        display: none;
    }
}

.nav-link {
    color: var(--branco);
    background: rgba(255,255,255,0.15);
    padding: 6px 12px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 13px;
    transition: background 0.2s;
    white-space: nowrap;
}

.nav-link:hover {
    background: rgba(255,255,255,0.28);
}

.nav-link-sair {
    background: var(--laranja);
}

.nav-link-sair:hover {
    background: #e65f00;
}

/* Mantém compatibilidade com .link-sair já usado em outros lugares */
.link-sair {
    color: var(--branco);
    background: rgba(255,255,255,0.15);
    padding: 6px 14px;
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.2s;
    font-size: 13px;
}

.link-sair:hover {
    background: var(--laranja);
}

/* --- Nav mobile --- */
@media (max-width: 700px) {
    .topo {
        padding: 10px 16px;
        flex-wrap: nowrap;
    }

    .logo-topo {
        height: 38px;
    }

    .topo h1 {
        font-size: 15px;
    }

    .subtitulo {
        display: none;
    }

    .nav-toggle {
        display: flex;
    }

    .topo-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--azul);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 8px 16px 16px;
        box-shadow: 0 6px 16px rgba(0,0,0,0.25);
        margin-left: 0;
        border-top: 1px solid rgba(255,255,255,0.15);
    }

    .topo-nav.aberto {
        display: flex;
    }

    .nav-usuario {
        display: block;
        padding: 10px 0 8px;
        border-bottom: 1px solid rgba(255,255,255,0.15);
        margin-bottom: 8px;
        font-size: 13px;
        opacity: 0.9;
    }

    .usuario-nome {
        display: block;
        margin-right: 0;
    }

    .nav-link {
        display: block;
        padding: 11px 14px;
        border-radius: 6px;
        margin-bottom: 4px;
        font-size: 14px;
        background: rgba(255,255,255,0.08);
        text-align: left;
    }

    .nav-link:hover,
    .nav-link:active {
        background: rgba(255,255,255,0.2);
    }

    .nav-link-sair {
        background: var(--laranja);
        margin-top: 4px;
    }
}


.container {
    max-width: 1000px;
    margin: 24px auto;
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.card {
    background: var(--branco);
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.card-estreito {
    max-width: 420px;
    margin: 0 auto;
}

/* Dashboard do dia */
.card-dashboard {
    padding: 18px 24px;
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.dashboard-titulo {
    font-size: 13px;
    font-weight: 700;
    color: var(--azul);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.dashboard-data {
    font-size: 12px;
    color: #999;
}

.dashboard-corpo {
    display: flex;
    align-items: flex-start;
    gap: 24px;
}

.dashboard-total {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--azul);
    color: var(--branco);
    border-radius: 10px;
    padding: 14px 20px;
    min-width: 88px;
    flex-shrink: 0;
}

.total-num {
    font-size: 36px;
    font-weight: 700;
    line-height: 1;
}

.total-label {
    font-size: 11px;
    opacity: 0.85;
    margin-top: 4px;
    text-align: center;
}

.dashboard-setores {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dash-setor-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: var(--cinza-claro);
    border-radius: 6px;
    font-size: 13px;
}

.dash-setor-nome {
    color: var(--texto);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 75%;
}

.dash-setor-qtd {
    font-weight: 700;
    color: var(--azul);
    background: #dde6f7;
    border-radius: 10px;
    padding: 1px 9px;
    font-size: 12px;
    flex-shrink: 0;
}


.card h2 {
    font-size: 17px;
    color: var(--azul);
    margin-bottom: 18px;
    border-bottom: 2px solid var(--laranja);
    padding-bottom: 8px;
}

.campo {
    margin-bottom: 16px;
    position: relative;
}

.campo label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #555;
}

.campo input,
.campo select,
.campo textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--cinza-borda);
    border-radius: 6px;
    font-size: 14px;
    background: var(--branco);
}

.campo input:focus,
.campo select:focus,
.campo textarea:focus {
    outline: none;
    border-color: var(--azul);
}

.linha {
    display: flex;
    gap: 16px;
}

.linha .campo {
    flex: 1;
}

/* Busca dinâmica */
.resultado-busca {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--branco);
    border: 1px solid var(--cinza-borda);
    border-radius: 6px;
    max-height: 280px;
    overflow-y: auto;
    z-index: 50;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    display: none;
}

.resultado-busca.ativo {
    display: block;
}

.item-resultado {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

.item-resultado:hover {
    background: var(--cinza-claro);
}

.item-resultado img {
    width: 36px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    background: #ddd;
}

.item-resultado .info-item strong {
    display: block;
    font-size: 14px;
}

.item-resultado .info-item span {
    font-size: 12px;
    color: #777;
}

.item-resultado.novo {
    color: var(--laranja);
    font-weight: 600;
    justify-content: center;
}

/* Visitante selecionado */
.visitante-selecionado {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--cinza-claro);
    border: 1px solid var(--cinza-borda);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
}

.visitante-selecionado img {
    width: 60px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    background: #ddd;
}

.info-visitante {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-visitante strong {
    font-size: 15px;
}

.info-visitante span {
    font-size: 13px;
    color: #777;
}

.info-visitante a {
    font-size: 12px;
    color: var(--azul);
    margin-top: 4px;
    text-decoration: none;
}

.info-visitante a:hover {
    text-decoration: underline;
}

/* Botões */
.btn-primario {
    background: var(--azul);
    color: var(--branco);
    border: none;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primario:hover {
    background: #002d80;
}

.btn-primario:disabled {
    background: #b0bdd6;
    cursor: not-allowed;
}

.btn-secundario {
    background: var(--laranja);
    color: var(--branco);
    border: none;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secundario:hover {
    background: #e65f00;
}

/* Botões de formulário (lado a lado) */
.botoes-form {
    display: flex;
    gap: 10px;
}

.botoes-form .btn-primario,
.botoes-form .btn-secundario {
    flex: none;
}

/* Texto de ajuda abaixo dos campos */
.ajuda {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #888;
}

/* Badges de status */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-ativo {
    background: #e6f7ee;
    color: var(--verde);
}

.badge-inativo {
    background: #fdecec;
    color: var(--vermelho);
}

/* Ações em forma de link na tabela */
.acoes-tabela {
    display: flex;
    gap: 12px;
    white-space: nowrap;
}

.btn-link {
    background: none;
    border: none;
    padding: 0;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--azul);
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-excluir-link {
    color: var(--vermelho);
}

/* Mensagens */
.mensagem {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    display: none;
}

.mensagem.sucesso {
    display: block;
    background: #e6f7ee;
    color: var(--verde);
    border: 1px solid #b7e8cd;
}

.mensagem.erro {
    display: block;
    background: #fdecec;
    color: var(--vermelho);
    border: 1px solid #f6c2c2;
}

/* Tabela */
.tabela-wrapper {
    overflow-x: auto;
}

.tabela {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.tabela th {
    background: var(--cinza-claro);
    color: var(--azul);
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid var(--cinza-borda);
    white-space: nowrap;
}

.tabela td {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.tabela img.foto-mini {
    width: 36px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    background: #ddd;
    cursor: pointer;
    transition: transform 0.15s;
}

.tabela img.foto-mini:hover {
    transform: scale(1.08);
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-conteudo {
    background: var(--branco);
    border-radius: 10px;
    width: 100%;
    max-width: 560px;
    max-height: 92vh;
    overflow-y: auto;
}

.modal-cabecalho {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid var(--cinza-borda);
    background: var(--azul);
    color: var(--branco);
    border-radius: 10px 10px 0 0;
}

.modal-cabecalho h2 {
    font-size: 16px;
}

.fechar {
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
}

.modal-corpo {
    padding: 24px;
}

/* Webcam / Captura vertical */
.area-foto {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.webcam-wrapper {
    position: relative;
    width: 270px;
    height: 360px;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.webcam-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* webcam é horizontal: aplica zoom/recorte para simular enquadramento vertical */
    transform: scaleX(-1);
}

.overlay-marcacao {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.linha-corte {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(255, 107, 0, 0.85);
    left: 0;
}

.linha-corte.direita {
    left: auto;
    right: 0;
}

.overlay-marcacao::before,
.overlay-marcacao::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(255,255,255,0.5);
}

.overlay-marcacao::before {
    top: 33%;
}

.overlay-marcacao::after {
    top: 66%;
}

.preview-wrapper {
    width: 270px;
    height: 360px;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
}

.preview-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.botoes-foto {
    margin-top: 12px;
    display: flex;
    gap: 10px;
}

/* Modal de Detalhes do Acesso */
.modal-detalhes {
    max-width: 640px;
}

.detalhes-corpo {
    display: flex;
    gap: 24px;
}

.detalhes-foto {
    flex-shrink: 0;
    width: 220px;
}

.detalhes-foto img {
    width: 100%;
    border-radius: 8px;
    object-fit: cover;
    background: #ddd;
    display: block;
}

.detalhes-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.detalhe-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-bottom: 1px solid var(--cinza-borda);
    padding-bottom: 8px;
}

.detalhe-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--azul);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detalhe-valor {
    font-size: 15px;
    color: var(--texto);
}

.detalhes-acoes {
    margin-top: 6px;
}

.btn-excluir {
    background: var(--vermelho);
    color: var(--branco);
    border: none;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
}

.btn-excluir:hover {
    background: #b32d2d;
}

.btn-excluir:disabled {
    background: #e8a3a3;
    cursor: not-allowed;
}

/* Responsivo */
@media (max-width: 600px) {
    .linha {
        flex-direction: column;
    }

    .webcam-wrapper,
    .preview-wrapper {
        width: 100%;
        max-width: 270px;
    }

    .detalhes-corpo {
        flex-direction: column;
    }

    .detalhes-foto {
        width: 160px;
        margin: 0 auto;
    }
}

/* Tela de Login */
.pagina-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--azul) 0%, #002463 100%);
}

.login-container {
    width: 100%;
    max-width: 380px;
    padding: 16px;
}

.login-card {
    background: var(--branco);
    border-radius: 12px;
    padding: 36px 32px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.login-logo {
    height: 70px;
    width: auto;
    margin-bottom: 16px;
}

.login-card h1 {
    font-size: 19px;
    color: var(--azul);
    font-weight: 600;
}

.login-subtitulo {
    font-size: 12px;
    color: #888;
    margin-bottom: 24px;
}

.login-form {
    width: 100%;
}

.btn-login {
    width: 100%;
    margin-top: 8px;
}

/* Rodapé */
.rodape {
    text-align: center;
    padding: 20px 16px;
    font-size: 12px;
    color: #aaa;
    margin-top: 16px;
    border-top: 1px solid var(--cinza-borda);
}

.rodape strong {
    color: var(--azul);
    font-weight: 600;
}

/* Campo com erro de validação */
.campo input.campo-erro {
    border-color: var(--vermelho);
    background: #fff8f8;
}

.aviso-cpf {
    font-size: 12px;
    margin-top: 4px;
    display: none;
}

.aviso-cpf.erro {
    display: block;
    color: var(--vermelho);
}

.aviso-cpf.ok {
    display: block;
    color: var(--verde);
}

/* Modal de edição de visitante */
.modal-editar-visitante {
    max-width: 620px;
}

.modal-editar-visitante .modal-corpo {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.modal-editar-visitante .area-foto {
    flex-shrink: 0;
    width: 190px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 0;
}

/* Container de tamanho fixo que mantém o layout estável */
.foto-slot {
    width: 180px;
    height: 240px;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    flex-shrink: 0;
}

.foto-slot img,
.foto-slot video,
.foto-slot .preview-wrapper,
.foto-slot .webcam-wrapper {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0;
}

.foto-slot .preview-wrapper img {
    position: static;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.foto-slot .webcam-wrapper {
    border-radius: 0;
}

.foto-slot .overlay-marcacao {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.foto-atual-grande {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.btn-sm {
    padding: 7px 14px;
    font-size: 12px;
}

.modal-editar-visitante form {
    flex: 1;
}

@media (max-width: 600px) {
    .modal-editar-visitante .modal-corpo {
        flex-direction: column;
    }

    .modal-editar-visitante .area-foto {
        width: 100%;
    }

    .foto-slot {
        width: 150px;
        height: 200px;
        margin: 0 auto;
    }
}

/* Página de Relatórios */
.container-relatorio {
    max-width: 1100px;
}

.campo-btn-filtro {
    flex: none;
    min-width: 100px;
}

.relatorio-cabecalho {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
    border-bottom: 2px solid var(--laranja);
    padding-bottom: 8px;
}

.relatorio-cabecalho h2 {
    border: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    color: var(--azul);
}

.botoes-exportar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Gráfico de barras horizontal */
.grafico-barras {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 0;
    max-height: 420px;
    overflow-y: auto;
}

.barra-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 26px;
}

.barra-label {
    font-size: 12px;
    color: #555;
    width: 44px;
    flex-shrink: 0;
    text-align: right;
}

.barra-track {
    flex: 1;
    background: var(--cinza-claro);
    border-radius: 4px;
    overflow: hidden;
    height: 22px;
}

.barra-fill {
    background: var(--azul);
    height: 100%;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    min-width: 30px;
    transition: width 0.4s ease;
}

.barra-fill:hover {
    background: var(--laranja);
}

.barra-valor {
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
}

/* Logo no topo da página de relatórios */
.relatorio-logo-topo {
    text-align: center;
    padding: 16px 0 8px;
}

.relatorio-logo-topo img {
    max-height: 90px;
    width: auto;
}

/* Barras de setores (label maior) */
.barra-label-setor {
    width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
}

.barra-fill-laranja {
    background: var(--laranja);
}

.barra-fill-laranja:hover {
    background: #e65f00;
}

/* Filtro de visitante no relatório */
.filtro-visitante-wrapper {
    position: relative;
}

.filtro-visitante-wrapper input[type="text"] {
    padding-right: 36px;
}

.btn-limpar-visitante {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #999;
    padding: 4px;
    line-height: 1;
}

.btn-limpar-visitante:hover {
    color: var(--vermelho);
}

/* Barra verde para top visitantes */
.barra-fill-verde {
    background: var(--verde);
}

.barra-fill-verde:hover {
    background: #178a4d;
}
