*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    min-height: 100vh;
    background-image: url("../img/imgfundo.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: #0f172a;
    margin: 0;
}

.container-login {
    width: 100%;
    max-width: 420px;
    min-height: 100vh;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.card-login {
    background: rgba(255, 255, 255, 0.95);
    padding: 2.2rem 2rem 1.8rem;
    border-radius: 18px;
    border: 1px solid rgba(34, 197, 94, 0.5);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
    width: 100%;
}

.container-page {
    width: 100%;
    max-width: 100%;
    padding: 1.5rem;
    min-height: 100vh;
    display: flex;
}

.card-page {
    background: rgba(255, 255, 255, 0.97);
    padding: 1.8rem 1.75rem 1.6rem;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.35);
    width: 100%;
    display: flex;
    flex-direction: column;
}

.card-page-painel {
    max-width: 1100px;
    margin: 0 auto;
    padding-top: 0.4rem;
}

/* Painel: menos espaço nas bordas externas para o logo ficar perto do topo da tela */
.container-page--painel {
    padding-top: 0.2rem;
    padding-left: 1rem;
    padding-right: 1rem;
    padding-bottom: 1.5rem;
}

/* Painel: Sair na primeira linha; logo na linha de baixo, centralizado */
.painel-cabecalho {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding-top: 0.08rem;
    margin-bottom: 0;
}

.painel-cabecalho-linha-sair {
    display: flex;
    justify-content: flex-end;
    width: 100%;
    margin-bottom: 0.4rem;
}

.painel-cabecalho--sem-logo .painel-cabecalho-linha-sair {
    margin-bottom: 0.85rem;
}

.painel-boasvindas {
    margin-top: 0;
}

/* Caixas de listagem com rolagem (tabelas) ocupando a altura até o fim da tela */
.card-page > div[style*="max-height:420px"] {
    flex: 1 1 auto;
    max-height: none !important;
    min-height: 0;
}

/* Tabela de custos: manter altura limitada e scroll horizontal para todas as colunas */
.card-page .tabela-custos-wrapper {
    max-height: 420px !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
    min-height: 120px;
}

.titulo-card {
    font-size: 1.7rem;
    font-weight: 700;
    color: #052e16;
    margin-bottom: 0.3rem;
    text-transform: uppercase;
}

.subtitulo-card {
    font-size: 0.9rem;
    color: #6b7280;
    text-transform: uppercase;
}

/* Cabeçalhos de tabela em maiúsculas em todo o projeto */
th {
    text-transform: uppercase;
}

/* Alinhamento padrão para números em tabelas */
td.td-num,
th.td-num,
.td-num {
    text-align: right !important;
    color: #000000 !important;
}

.mb-3 {
    margin-bottom: 1rem;
}

.mb-4 {
    margin-bottom: 1.3rem;
}

.text-center {
    text-align: center;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #064e3b;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.form-control {
    width: 100%;
    border-radius: 0.75rem;
    border: 1px solid #d1d5db;
    padding: 0.75rem 0.9rem;
    font-size: 0.9rem;
    background: #f9fafb;
    color: #111827;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.form-control::placeholder {
    color: #9ca3af;
}

.form-control:focus {
    border-color: #22c55e;
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.35);
    background: #ffffff;
}

/* Visual para campos não editáveis / calculados */
.campo-nao-editavel {
    background: #f3f4f6 !important;
    color: #6b7280 !important;
    border-color: #e5e7eb !important;
}
.celula-nao-editavel {
    background: #f9fafb;
    color: #6b7280;
}

/* Campo numérico mais estreito */
.form-control-num {
    max-width: 100px;
    width: 100%;
}

/* Formulários com campos lado a lado (2 colunas em desktop) */
.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.25rem;
}
/* 3 colunas em desktop */
.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem 1.25rem;
}
@media (max-width: 640px) {
    .form-grid-2,
    .form-grid-3 {
        grid-template-columns: 1fr;
    }
}

/* Formulário compacto: largura limitada + tamanho equilibrado */
.form-compact {
    max-width: 800px;
    margin: 0 auto;
}
.form-compact .form-grid-2 {
    gap: 0.75rem 1.1rem;
}
.form-compact .form-label {
    font-size: 0.8rem;
    margin-bottom: 0.28rem;
}
.form-compact .form-control {
    padding: 0.6rem 0.75rem;
    font-size: 0.9rem;
}
.form-compact .mb-3 {
    margin-bottom: 0.5rem;
}
.form-compact .mb-4 {
    margin-bottom: 0.75rem;
}
@media (max-width: 640px) {
    .form-compact {
        max-width: 100%;
    }
}

.btn-primary {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 0.35rem;
    border-radius: 999px;
    padding: 0.8rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border: 1px solid #16a34a;
    background: #f9fafb;
    color: #166534;
    cursor: pointer;
    text-decoration: none;
    box-shadow: none;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

/* Largura padrão para botões (sem ocupar a tela toda) */
.btn-largura-padrao {
    min-width: 180px;
}

/* Botões menores usados no painel (menu principal) */
.btn-menu {
    min-width: 150px;
    font-size: 0.72rem;
    padding: 0.5rem 0.75rem;
    text-align: center;
    white-space: normal;
}

/* Barra padrão de ações (topo das telas) */
.toolbar-top {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* Responsividade painel: no mobile, um botão por linha */
@media (max-width: 640px) {
    .painel-grid {
        grid-template-columns: 1fr !important;
        justify-content: stretch !important;
    }
}

/* Painel: logo e grupos de navegação */
.painel-conteudo {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.painel-logo-wrap {
    text-align: center;
    margin: 0 auto;
    width: 100%;
}

/* Espaço entre logo e bloco «Painel / Bem-vindo» */
.painel-logo-wrap--painel {
    margin-bottom: 1.45rem;
}

.painel-logo-img {
    max-width: min(100%, 260px);
    width: auto;
    height: auto;
    display: inline-block;
    vertical-align: middle;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.55);
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
    background: #fff;
}

.painel-grupos {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.painel-grupo {
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 14px;
    padding: 0.95rem 1rem 1.05rem;
    background: rgba(248, 250, 252, 0.72);
}

.painel-grupo-titulo {
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: #166534;
    margin: 0 0 0.65rem;
    padding-bottom: 0.45rem;
    border-bottom: 1px solid rgba(34, 197, 94, 0.28);
}

.painel-grupo-btns {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
    gap: 0.65rem;
}

@media (min-width: 720px) {
    .painel-grupo-btns {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 960px) {
    .painel-grupo-btns {
        grid-template-columns: repeat(3, 1fr);
    }
}

.btn-primary:hover {
    background: #ecfdf3;
    border-color: #15803d;
    color: #14532d;
}

.btn-primary:active {
    background: #dcfce7;
    border-color: #15803d;
}

.w-100 {
    width: 100%;
}

.btn-secondary {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border-radius: 999px;
    padding: 0.6rem 1rem;
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid #16a34a;
    background: transparent;
    color: #166534;
    cursor: pointer;
    text-decoration: none;
}

.btn-secondary:hover {
    background: rgba(22, 163, 74, 0.06);
}

.texto-link {
    text-align: center;
    margin-top: 1rem;
}

.link-secundario {
    font-size: 0.8rem;
    color: #16a34a;
    text-decoration: none;
}

.link-secundario:hover {
    text-decoration: underline;
}

.texto-ajuda {
    margin-top: 1.3rem;
    text-align: center;
    font-size: 0.78rem;
    color: #6b7280;
}

.login-footer-text {
    margin-top: 1.4rem;
    font-size: 0.75rem;
    color: #9ca3af;
    text-align: center;
}

.alert {
    padding: 0.55rem 0.75rem;
    border-radius: 0.6rem;
    font-size: 0.8rem;
    text-align: center;
    margin-bottom: 0.9rem;
}

.alert-erro {
    background: rgba(248, 113, 113, 0.16);
    color: #991b1b;
}

.alert-sucesso {
    background: rgba(74, 222, 128, 0.16);
    color: #166534;
}

/* Badges para listas (usuarios, etc.) */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.badge-perfil-admin {
    background: rgba(22, 163, 74, 0.1);
    color: #166534;
    border: 1px solid rgba(22, 163, 74, 0.5);
}

.badge-perfil-usuario {
    background: rgba(148, 163, 184, 0.15);
    color: #4b5563;
    border: 1px solid rgba(148, 163, 184, 0.5);
}

.badge-status-ativo {
    background: rgba(22, 163, 74, 0.12);
    color: #166534;
    border: 1px solid rgba(22, 163, 74, 0.5);
}

.badge-status-inativo {
    background: rgba(248, 113, 113, 0.12);
    color: #b91c1c;
    border: 1px solid rgba(248, 113, 113, 0.5);
}

/* Badge como link/botão de ação (mesmo estilo do status) */
a.badge,
button.badge {
    text-decoration: none;
    cursor: pointer;
    border: none;
    font-family: inherit;
}
a.badge:hover,
button.badge:hover {
    opacity: 0.9;
}

/* Links de ação em tabelas (verde = editar/permissões, vermelho = excluir) */
.link-acao {
    font-size: 0.8rem;
    color: #166534;
    text-decoration: none;
}
.link-acao:hover {
    text-decoration: underline;
}
.link-acao--danger {
    color: #b91c1c;
}
.link-acao--danger:hover {
    color: #991b1b;
}

/* Ações em listas (botões em forma de pílula) */
.acoes-linha {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* Botões simples de ação (estilo link) */
.btn-acao {
    display: inline;
    padding: 0;
    margin: 0;
    border: none;
    background: none;
    font-size: 0.8rem;
    color: #166534;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}
.btn-acao:hover {
    text-decoration: underline;
}
.btn-acao--danger {
    color: #b91c1c;
}
.btn-acao--danger:hover {
    color: #991b1b;
}

.action-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    color: #374151;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.action-pill:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.action-pill--ghost {
    background: transparent;
    border-color: #d1d5db;
}

.action-pill--danger {
    border-color: #b91c1c;
    background: rgba(248, 113, 113, 0.12);
    color: #b91c1c;
}

.action-pill--danger:hover {
    background: rgba(248, 113, 113, 0.22);
}

@media (max-width: 480px) {
    .card-login {
        padding: 1.9rem 1.5rem 1.7rem;
        border-radius: 16px;
    }

    .titulo-card {
        font-size: 1.5rem;
    }
}

/* ========== Modais (confirmação e mensagens) ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1rem;
    animation: modalFadeIn 0.2s ease;
}

.modal-overlay.modal-escondido {
    display: none;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-box {
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    max-width: 420px;
    width: 100%;
    overflow: hidden;
    animation: modalSlideIn 0.25s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-box .modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-box.modal-sucesso .modal-header {
    background: rgba(34, 197, 94, 0.08);
    color: #166534;
}

.modal-box.modal-erro .modal-header {
    background: rgba(248, 113, 113, 0.1);
    color: #991b1b;
}

.modal-box.modal-confirm .modal-header {
    background: rgba(245, 158, 11, 0.1);
    color: #92400e;
}

.modal-box .modal-header .modal-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.modal-box .modal-body {
    padding: 1.25rem 1.25rem;
    font-size: 0.95rem;
    color: #374151;
    line-height: 1.5;
}

.modal-box .modal-footer {
    padding: 0.75rem 1.25rem 1rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.modal-box .modal-footer .btn-primary,
.modal-box .modal-footer .btn-secondary {
    min-width: 100px;
}

.modal-box .modal-footer .btn-danger {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border-radius: 999px;
    padding: 0.6rem 1rem;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid #b91c1c;
    background: rgba(248, 113, 113, 0.15);
    color: #b91c1c;
    cursor: pointer;
    text-decoration: none;
}

.modal-box .modal-footer .btn-danger:hover {
    background: rgba(248, 113, 113, 0.25);
}

/* Confirmações de recálculo: cancelar vermelho, confirmar verde */
.modal-box .modal-footer .btn-cancelar-vermelho {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border-radius: 999px;
    padding: 0.6rem 1rem;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid #b91c1c;
    background: rgba(248, 113, 113, 0.15);
    color: #b91c1c;
    cursor: pointer;
    text-decoration: none;
    min-width: 100px;
}
.modal-box .modal-footer .btn-cancelar-vermelho:hover {
    background: rgba(248, 113, 113, 0.25);
}

.modal-box .modal-footer .btn-confirmar-verde {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border-radius: 999px;
    padding: 0.6rem 1rem;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid #15803d;
    background: #16a34a;
    color: #ffffff;
    cursor: pointer;
    text-decoration: none;
    min-width: 100px;
}
.modal-box .modal-footer .btn-confirmar-verde:hover {
    background: #15803d;
    border-color: #166534;
}

