/* PHPBaseTemplate - estilo base (PERSONALIZE as cores da paleta padrao abaixo) */

* { box-sizing: border-box; }

/* ============ PALETA PADRAO (azul) ============ */
:root {
    --topbar-bg: #ffffff;
    --topbar-text: #1e3a8a;
    --topbar-border: #e5e7eb;

    --sidebar-bg: #ffffff;
    --sidebar-text: #1f2937;
    --sidebar-hover-bg: #f3f4f6;
    --sidebar-active-bg: #eff6ff;
    --sidebar-active-text: #1e3a8a;
    --sidebar-active-border: #1e3a8a;

    --content-bg: #f4f6f8;
}

/* ============ PALETAS ALTERNATIVAS ============ */
body.tema-esmeralda {
    --topbar-bg: #065f46;
    --topbar-text: #ecfdf5;
    --topbar-border: #064e3b;

    --sidebar-hover-bg: #ecfdf5;
    --sidebar-active-bg: #d1fae5;
    --sidebar-active-text: #065f46;
    --sidebar-active-border: #065f46;

    --content-bg: #f0fdf4;
}

body.tema-vinho {
    --topbar-bg: #7f1d1d;
    --topbar-text: #fef2f2;
    --topbar-border: #991b1b;

    --sidebar-hover-bg: #fef2f2;
    --sidebar-active-bg: #fee2e2;
    --sidebar-active-text: #7f1d1d;
    --sidebar-active-border: #7f1d1d;

    --content-bg: #fdf6f6;
}

body.tema-roxo {
    --topbar-bg: #5b21b6;
    --topbar-text: #ede9fe;
    --topbar-border: #4c1d95;

    --sidebar-hover-bg: #f5f3ff;
    --sidebar-active-bg: #ede9fe;
    --sidebar-active-text: #5b21b6;
    --sidebar-active-border: #5b21b6;

    --content-bg: #faf5ff;
}

body.tema-cinza {
    --topbar-bg: #1f2937;
    --topbar-text: #f9fafb;
    --topbar-border: #111827;

    --sidebar-hover-bg: #f3f4f6;
    --sidebar-active-bg: #e5e7eb;
    --sidebar-active-text: #111827;
    --sidebar-active-border: #6b7280;

    --content-bg: #f9fafb;
}

/* ============ BASE ============ */
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--content-bg);
    color: #1f2937;
}

a { color: #1d4ed8; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ AUTH ============ */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(circle at 30% 20%, #6d28d9 0%, #4c1d95 55%, #3b0d6e 100%);
}
.auth-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 410px;
}
.auth-logo-top {
    width: 58%;
    max-width: 210px;
    height: auto;
    margin-bottom: 26px;
    filter: drop-shadow(0 6px 14px rgba(0,0,0,0.30));
}
.auth-card {
    background: #fff;
    padding: 36px 32px;
    border-radius: 16px;
    box-shadow: 0 18px 50px rgba(0,0,0,0.30);
    width: 100%;
    text-align: center;
}
.auth-card h1 {
    margin: 0 0 4px;
    color: #5b21b6;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.5px;
    line-height: 1.25;
}
.auth-sub {
    color: #6b7280;
    font-size: 14px;
    margin: 0 0 26px;
}
.auth-card p {
    color: #6b7280;
    margin-bottom: 24px;
    font-size: 14px;
}
.auth-logo {
    display: block;
    margin: 0 auto 16px;
    max-width: 180px;
    height: auto;
}
/* Botão "Entrar com Microsoft" */
.btn-microsoft {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 13px 16px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    color: #1f2937 !important;
    font-weight: 600;
    font-size: 15px;
    text-decoration: none !important;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn-microsoft:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    box-shadow: 0 3px 10px rgba(0,0,0,0.10);
}
.btn-microsoft svg { width: 19px; height: 19px; display: block; }
/* Separador "ou" entre o formulario local e o botao da Microsoft */
.auth-ou {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 0;
    color: #9ca3af;
    font-size: 13px;
}
.auth-ou::before,
.auth-ou::after {
    content: "";
    flex: 1;
    border-top: 1px solid #e5e7eb;
}
.auth-rodape {
    margin-top: 22px;
    color: rgba(255,255,255,0.75);
    font-size: 12px;
}

/* ============ BOTOES ============ */
/* Tamanho padrao para todos os botoes do sistema */
.btn-primary,
.btn-secondary,
.btn-danger {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    line-height: 1.4;
    cursor: pointer;
    text-align: center;
    vertical-align: middle;
    transition: background 0.15s, opacity 0.15s;
}

.btn-primary {
    background: #1e3a8a;
    color: #fff !important;
    font-weight: 600;
}
.btn-primary:hover { background: #1e40af; text-decoration: none; }

.btn-secondary {
    background: #e5e7eb;
    color: #1f2937 !important;
}
.btn-secondary:hover { background: #d1d5db; text-decoration: none; }

.btn-danger {
    background: #dc2626;
    color: #fff !important;
    font-weight: 600;
}
.btn-danger:hover { background: #b91c1c; text-decoration: none; }

/* Variante maior para CTAs principais (ex.: tela de login) */
.btn-lg {
    padding: 12px 24px;
    font-size: 15px;
}

/* Botoes que mostram apenas icone (acoes em tabelas) */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    width: 34px;
    height: 34px;
    line-height: 1;
}
.btn-icon svg {
    width: 18px;
    height: 18px;
    display: block;
}

/* Botoes com icone + texto (ex.: "Nova retenção" com +) */
.btn-with-icon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-with-icon svg { width: 16px; height: 16px; display: block; }

/* Espacamento entre acoes inline em tabelas */
td .btn-icon + .btn-icon,
td .btn-icon + form,
td form + .btn-icon,
td form + form,
td a + a,
td a + form,
td form + a { margin-left: 4px; }

td form { display: inline-block; vertical-align: middle; margin: 0; }
td .btn-icon { vertical-align: middle; }

/* Forca a ultima coluna (acoes) a manter botoes em uma linha so */
table tr > td:last-child {
    white-space: nowrap;
}

.btn-link {
    color: var(--topbar-text) !important;
    margin-left: 12px;
}

/* ============ LAYOUT ============ */
.topbar {
    background: var(--topbar-bg);
    color: var(--topbar-text);
    border-bottom: 1px solid var(--topbar-border);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.topbar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--topbar-text) !important;
    font-size: 18px;
    text-decoration: none;
}
.topbar .brand:hover { text-decoration: none; opacity: 0.85; }
.topbar .brand img { height: 32px; width: auto; display: block; }
.topbar .user {
    color: var(--topbar-text);
    font-size: 14px;
    opacity: 0.92;
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.35);
}
.user-avatar-fallback {
    background: rgba(255, 255, 255, 0.25);
    color: var(--topbar-text);
    font-weight: 600;
    font-size: 14px;
}

.layout {
    display: flex;
    min-height: calc(100vh - 57px);
}

.sidebar {
    width: 220px;
    flex-shrink: 0; /* nao deixa o menu ser espremido por conteudo largo */
    background: var(--sidebar-bg);
    border-right: 1px solid #e5e7eb;
    padding: 16px 0;
}
.sidebar a.menu-item {
    display: block;
    padding: 10px 20px;
    color: var(--sidebar-text) !important;
    border-left: 3px solid transparent;
}
.sidebar a.menu-item:hover { background: var(--sidebar-hover-bg); text-decoration: none; }
.sidebar a.menu-item.active {
    background: var(--sidebar-active-bg);
    border-left-color: var(--sidebar-active-border);
    color: var(--sidebar-active-text) !important;
    font-weight: 600;
}

/* ============ GRUPOS DE MENU ============ */
.sidebar .menu-group {
    margin: 0;
}
.sidebar .menu-group > summary {
    list-style: none;
    cursor: pointer;
    padding: 10px 20px;
    color: var(--sidebar-text);
    font-weight: 600;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-left: 3px solid transparent;
}
.sidebar .menu-group > summary::-webkit-details-marker { display: none; }
.sidebar .menu-group > summary::marker { display: none; content: ''; }
.sidebar .menu-group > summary:hover { background: var(--sidebar-hover-bg); }
.sidebar .menu-group > summary::after {
    content: '▸';
    font-size: 12px;
    color: #9ca3af;
    transition: transform 0.15s;
    margin-left: 8px;
}
.sidebar .menu-group[open] > summary::after {
    transform: rotate(90deg);
}
.sidebar .menu-sub a.menu-item {
    padding-left: 36px;
    font-size: 14px;
}

/* ============ TOGGLE DO MENU LATERAL ============ */
.btn-toggle-sidebar {
    background: transparent;
    border: none;
    color: var(--topbar-text);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    padding: 4px 10px;
    margin-right: 10px;
    border-radius: 6px;
    transition: opacity 0.15s;
}
.btn-toggle-sidebar:hover { opacity: 0.75; }
.topbar-left {
    display: flex;
    align-items: center;
}

.sidebar-collapsed .sidebar { display: none; }

/* ============ AUTOCOMPLETE ============ */
.autocomplete-wrap { position: relative; }
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 360px;
    max-width: 600px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
    max-height: 280px;
    overflow-y: auto;
    z-index: 100;
    margin-top: 4px;
}
.autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid #f3f4f6;
    line-height: 1.4;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.highlighted { background: #eff6ff; }
.autocomplete-item .ac-codigo { color: #1e3a8a; font-weight: 600; margin-right: 8px; }
.autocomplete-item .ac-desc { color: #4b5563; }
.autocomplete-empty {
    padding: 10px 12px;
    color: #6b7280;
    font-size: 13px;
    text-align: center;
}

.content {
    flex: 1;
    /* Sem isto o item flex nao encolhe abaixo do conteudo: uma tabela larga
       estica o .content, estica o .layout e a PAGINA INTEIRA passa a rolar
       na horizontal (cortando o topo). Com min-width:0 quem rola e a
       .table-scroll, como deveria. */
    min-width: 0;
    padding: 24px;
}

/* ============ COMPONENTES ============ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.page-header h1 {
    margin: 0;
    font-size: 22px;
    color: #1f2937;
}

.card {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 16px;
}

table {
    width: 100%;
    background: #fff;
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
th, td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 14px;
}
th { background: #f9fafb; font-weight: 600; color: #4b5563; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9fafb; }

.row {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.field { flex: 1; min-width: 180px; }
.row label,
.field label {
    display: block;
    font-size: 13px;
    color: #4b5563;
    margin-bottom: 4px;
    font-weight: 500;
}
.row input, .row select, .row textarea,
.field input, .field select, .field textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}
.row input:focus, .row select:focus, .row textarea:focus,
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: #1e3a8a;
    box-shadow: 0 0 0 3px rgba(30,58,138,0.1);
}
.row textarea, .field textarea { min-height: 80px; resize: vertical; }

/* Lista aberta na tela (select com size) + campo de filtro logo acima */
.field .filtro-select { margin-bottom: 6px; }
.field select.lista-selecao { height: auto; padding: 4px; }
.lista-selecao option { padding: 6px 8px; border-radius: 4px; cursor: pointer; }
.lista-selecao option:checked { background: #1e3a8a; color: #fff; }
/* Funcao x Treinamento agrupado por funcao (<details> com +/-) */
.matriz-barra { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.matriz-barra label.opcao { display: flex; align-items: center; gap: 6px; font-size: 14px; white-space: nowrap; cursor: pointer; }
.matriz-lista { margin-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.matriz-funcao { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.matriz-funcao[hidden] { display: none; }
.matriz-funcao > summary {
    list-style: none; cursor: pointer;
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; font-size: 14px;
}
.matriz-funcao > summary::-webkit-details-marker { display: none; }
.matriz-funcao > summary:hover { background: #f9fafb; border-radius: 8px; }
.matriz-sinal {
    flex: 0 0 22px; height: 22px; border-radius: 5px;
    display: inline-flex; align-items: center; justify-content: center;
    background: #e0e7ff; color: #1e3a8a; font-weight: 700; font-size: 15px;
}
.matriz-sinal::before { content: '+'; }
.matriz-funcao[open] .matriz-sinal::before { content: '−'; }
.matriz-funcao[open] .matriz-sinal { background: #1e3a8a; color: #fff; }
.matriz-nome { font-weight: 600; color: #1f2937; }
.matriz-acoes { margin-left: auto; font-size: 13px; color: #9ca3af; white-space: nowrap; }
.matriz-funcao > table, .matriz-vazio { margin: 0 16px 14px 48px; width: calc(100% - 64px); }
.matriz-itens { box-shadow: none; border: 1px solid #e5e7eb; }
.matriz-itens td { padding: 8px 14px; }
.turma-data { font-weight: 600; color: #1e3a8a; font-variant-numeric: tabular-nums; min-width: 84px; }

/* Ordenacao clicando no titulo da coluna (app.js) */
th.ordenavel { cursor: pointer; user-select: none; white-space: nowrap; }
th.ordenavel:hover { color: #1f2937; background: #f3f4f6; }
th.ordenavel::after { content: '↕'; margin-left: 6px; font-size: 11px; color: #d1d5db; }
th.ordenavel[data-ordem="asc"]::after  { content: '▲'; color: #1e3a8a; }
th.ordenavel[data-ordem="desc"]::after { content: '▼'; color: #1e3a8a; }

/* Enviar turma por e-mail: formulario + previa lado a lado */
.envio-grade { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.3fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .envio-grade { grid-template-columns: 1fr; } }
.previa-email { width: 100%; height: 560px; border: 1px solid #e5e7eb; border-radius: 6px; background: #f3f4f6; }
.recentes { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.chip {
    border: 1px solid #c7d2fe; background: #eef2ff; color: #3730a3;
    border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; font-family: inherit;
}
.chip:hover { background: #e0e7ff; }
.chip:disabled { opacity: .45; cursor: default; }

/* Indicador de etapas (ex.: agendar -> participantes) */
.passos { display: flex; align-items: center; gap: 10px; margin: -4px 0 16px; flex-wrap: wrap; }
.passo {
    padding: 4px 12px; border-radius: 999px; font-size: 13px;
    background: #e5e7eb; color: #4b5563;
}
.passo-atual { background: #1e3a8a; color: #fff; font-weight: 600; }
.passo-seta { color: #9ca3af; }

/* Lista pesquisavel (select.select-busca, montada pelo app.js) */
.sb { position: relative; }
.sb .sb-input {
    padding-right: 32px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%234b5563' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 12px center;
    cursor: pointer;
}
.sb .sb-input:focus { cursor: text; }
.sb .sb-nativo {          /* fica no form so para enviar/validar */
    position: absolute; left: 0; bottom: 0;
    width: 100%; height: 1px; opacity: 0; pointer-events: none;
}
.sb-lista {
    position: absolute; left: 0; right: 0; top: calc(100% + 4px);
    z-index: 50;
    max-height: 320px; overflow-y: auto;
    background: #fff;
    border: 1px solid #d1d5db; border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    padding: 4px;
}
.sb-lista[hidden], .sb-item[hidden], .sb-nada[hidden] { display: none; }
.sb-item { padding: 8px 10px; border-radius: 4px; cursor: pointer; font-size: 14px; }
.sb-item:hover { background: #f3f4f6; }
.sb-item.sb-ativo { background: #1e3a8a; color: #fff; }
/* Opcao "nenhum" (Todos, Nao...) no topo da lista, separada das demais */
.sb-item-vazio { font-style: italic; color: #6b7280; border-bottom: 1px solid #e5e7eb; border-radius: 4px 4px 0 0; }
.sb-nada { padding: 8px 10px; color: #6b7280; font-size: 13px; }
.sb.sb-erro .sb-input { border-color: #dc2626; box-shadow: 0 0 0 3px rgba(220,38,38,0.12); }

/* Funcao x Treinamento: vinculo desmarcado, sera removido ao salvar */
tr.linha-remover td { background: #fef2f2; color: #991b1b; text-decoration: line-through; }
tr.linha-remover td:first-child { text-decoration: none; }
.form-actions { margin-top: 16px; display: flex; gap: 8px; }

/* Tabela com inputs/selects/textareas dentro das celulas (ex.: tolerancias por pais) */
.tabela-form td select,
.tabela-form td input,
.tabela-form td textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}
.tabela-form td textarea {
    min-height: 60px;
    resize: vertical;
}
.tabela-form td select:focus,
.tabela-form td input:focus,
.tabela-form td textarea:focus {
    outline: none;
    border-color: #1e3a8a;
    box-shadow: 0 0 0 3px rgba(30,58,138,0.1);
}
.tabela-form td { vertical-align: top; }

/* Validação visual do campo Resultado (entre m e M) */
.input-conforme {
    background: #d1fae5 !important;
    border-color: #10b981 !important;
    color: #065f46 !important;
    font-weight: 600;
}
.input-nao-conforme {
    background: #fee2e2 !important;
    border-color: #ef4444 !important;
    color: #991b1b !important;
    font-weight: 600;
}

/* Grid de 6 colunas iguais (para alinhar campos em multiplas linhas) */
.grid-6 {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
    margin-bottom: 12px;
}
@media (max-width: 1024px) {
    .grid-6 { grid-template-columns: repeat(3, 1fr); }
    .grid-6 .field[style*="grid-column"] { grid-column: span 3 !important; }
}
@media (max-width: 600px) {
    .grid-6 { grid-template-columns: repeat(2, 1fr); }
    .grid-6 .field[style*="grid-column"] { grid-column: span 2 !important; }
}

/* ============ LOADING ============ */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 9999;
    animation: fadeIn 0.15s ease-out;
}
.loading-overlay .spinner {
    width: 56px;
    height: 56px;
    border: 5px solid #e5e7eb;
    border-top-color: #1e3a8a;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}
.loading-overlay .msg {
    font-size: 15px;
    color: #1e3a8a;
    font-weight: 600;
}
.loading-overlay .submsg {
    font-size: 13px;
    color: #6b7280;
    margin-top: 4px;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.flash {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
}
.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash-info    { background: #dbeafe; color: #1e3a8a; border: 1px solid #93c5fd; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}
.badge-success   { background: #d1fae5; color: #065f46; }
.badge-danger    { background: #fee2e2; color: #991b1b; }
.badge-warning   { background: #fef3c7; color: #92400e; }
.badge-info      { background: #dbeafe; color: #1e40af; }
.badge-primary   { background: #c7d2fe; color: #3730a3; }
.badge-purple    { background: #ede9fe; color: #5b21b6; }
.badge-pink      { background: #fce7f3; color: #9d174d; }
.badge-orange    { background: #ffedd5; color: #9a3412; }
.badge-secondary { background: #e5e7eb; color: #4b5563; }

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

/* Grids genericos do dashboard quebram em telas pequenas */
@media (max-width: 900px) {
    div[style*="grid-template-columns: 2fr 1fr"],
    div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}
.stat-card {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.stat-card .label { color: #6b7280; font-size: 13px; margin-bottom: 6px; }
.stat-card .value { font-size: 28px; font-weight: 700; color: #1e3a8a; }

.empty {
    text-align: center;
    padding: 40px;
    color: #6b7280;
}

.filters-bar {
    background: #fff;
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 16px;
}

/* ============ SELETOR DE TEMA ============ */
.tema-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 8px;
}
.tema-card {
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s;
    position: relative;
}
.tema-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.tema-card.selected {
    border-color: #1e3a8a;
    box-shadow: 0 0 0 3px rgba(30,58,138,0.1);
}
.tema-card .preview {
    display: flex;
    height: 90px;
}
.tema-card .preview .pv-topbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 24px;
}
.tema-card .preview .pv-sidebar {
    width: 38%;
    margin-top: 24px;
    border-right: 1px solid #e5e7eb;
}
.tema-card .preview .pv-content {
    flex: 1;
    margin-top: 24px;
}
.tema-card .info {
    padding: 12px 14px;
    border-top: 1px solid #f3f4f6;
}
.tema-card .info .nome {
    font-weight: 600;
    color: #1f2937;
    font-size: 15px;
}
.tema-card .info .selecionado {
    display: none;
    font-size: 12px;
    color: #065f46;
    background: #d1fae5;
    padding: 2px 8px;
    border-radius: 12px;
    margin-top: 4px;
}
.tema-card.selected .info .selecionado { display: inline-block; }
.tema-card input[type=radio] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}


/* ============ INDICADORES (bolinhas de status) ============ */
.dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-left: 6px;
    vertical-align: middle;
}
.dot-ok     { background: #16a34a; }
.dot-alerta { background: #f59e0b; }
.dot-ruim   { background: #dc2626; }

/* Dica curta ao lado do rotulo (ex.: "auto", "da fórmula") */
.label-hint {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 10px;
    background: #eef2ff;
    color: #4f46e5;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    vertical-align: middle;
    cursor: help;
}


/* ============ PAINEL DE FILTROS RECOLHIVEL ============ */
.filtros-box {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 14px;
    overflow: hidden;
}
.filtros-resumo {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #4b5563;
    user-select: none;
}
.filtros-resumo::-webkit-details-marker { display: none; }
.filtros-resumo::before {
    content: '';
    width: 0; height: 0;
    border-left: 5px solid #9ca3af;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    transition: transform .15s;
}
.filtros-box[open] .filtros-resumo::before { transform: rotate(90deg); }
.filtros-resumo:hover { background: #f9fafb; }
.filtros-badge {
    background: #eef2ff;
    color: #4f46e5;
    border-radius: 999px;
    padding: 2px 9px;
    font-size: 11px;
    font-weight: 700;
}
.filtros-box form { padding: 0 16px 14px; }
.filtros-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px 14px;
    align-items: end;
}
.filtros-grid .field { min-width: 0; }
/* Formula tem o texto mais longo (codigo + descricao) — ocupa 3 colunas.
   Com isso os 8 filtros somam 10 unidades e preenchem a linha inteira,
   sem sobrar coluna vazia antes da borda direita. */
.filtros-grid .filtro-largo { grid-column: span 3; }
.filtros-acoes {
    display: flex;
    gap: 8px;
    align-items: end;
    grid-column: 1 / -1;
    margin-top: 2px;
}

/* ============ RESUMO DA LISTAGEM ============ */
.lista-resumo {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-bottom: 10px;
    font-size: 13px;
    color: #4b5563;
}
.resumo-total strong { font-size: 15px; color: #111827; }
.resumo-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.resumo-chip .dot { margin-left: 0; }
.resumo-ok     { background: #f0fdf4; color: #166534; }
.resumo-alerta { background: #fffbeb; color: #92400e; }
.resumo-ruim   { background: #fef2f2; color: #991b1b; }
.resumo-legenda {
    margin-left: auto;
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: #9ca3af;
}
.resumo-legenda .dot { margin-left: 0; margin-right: 3px; width: 8px; height: 8px; }

/* ============ PAGINACAO ============ */
.paginacao {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 14px 0 4px;
}
.pag-btn {
    display: inline-block;
    min-width: 34px;
    padding: 6px 11px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    color: #4b5563 !important;
    font-size: 13px;
    text-align: center;
    text-decoration: none;
}
.pag-btn:hover { background: #f9fafb; border-color: #d1d5db; text-decoration: none; }
.pag-atual {
    background: var(--sidebar-active-bg, #ede9fe);
    border-color: var(--sidebar-active-border, #7c3aed);
    color: #5b21b6 !important;
    font-weight: 700;
}
.pag-off {
    opacity: .45;
    pointer-events: none;
}
.pag-sep { color: #9ca3af; padding: 0 2px; }

/* ============ ESTADO VAZIO ============ */
.empty-state {
    text-align: center;
    padding: 44px 24px;
}
.empty-titulo {
    font-size: 16px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}
.empty-texto {
    font-size: 13px;
    color: #6b7280;
    max-width: 440px;
    margin: 0 auto 18px;
    line-height: 1.5;
}


/* ============ TABELA COM ROLAGEM HORIZONTAL ============ */
.table-scroll {
    overflow-x: auto;
    max-width: 100%;
    border-radius: 8px;
}

/* ============ CAMPO DE ARQUIVO ============ */
.field input[type=file] {
    cursor: pointer;
    background: #fff;
    padding: 0;                 /* o botao interno cuida do respiro */
    overflow: hidden;
    line-height: 38px;
}
.field input[type=file]::file-selector-button {
    margin-right: 12px;
    padding: 0 16px;
    height: 38px;
    border: none;
    border-right: 1px solid #d1d5db;
    background: #f3f4f6;
    color: #1e3a8a;
    font-weight: 600;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease;
}
.field input[type=file]::file-selector-button:hover { background: #e5e7eb; }

/* ============ TEXTOS E CAIXAS AUXILIARES ============ */
.muted { color: #6b7280; font-size: 13px; }

.info-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e3a8a;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    line-height: 1.55;
}
.info-box code { background: #dbeafe; padding: 1px 6px; border-radius: 4px; }

.warn-box {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    color: #92400e;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    line-height: 1.55;
}

/* Acao sem volta (ex.: excluir colaboradores na importacao) */
.danger-box {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    line-height: 1.55;
}
.danger-box[hidden] { display: none; }

/* Checkbox com rotulo ao lado (ex.: "Ativar restricao por IP") */
.field-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    cursor: pointer;
}
.field-check input { width: 18px; height: 18px; cursor: pointer; }

/* ============ LOGIN LOCAL (AUTH_DRIVER=local) ============ */
.auth-form { text-align: left; }
.auth-form .field { margin-bottom: 14px; }
.auth-form label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}
.auth-form input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
}
.auth-form input:focus {
    outline: none;
    border-color: #5b21b6;
    box-shadow: 0 0 0 3px rgba(91,33,182,0.12);
}
.auth-form .btn-primary { width: 100%; justify-content: center; margin-top: 6px; }
.auth-erro {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #991b1b;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 16px;
    font-size: 13px;
    text-align: left;
}

/* ============ AUDITORIA (diff antes/depois) ============ */
.diff-de   { color: #991b1b; text-decoration: line-through; }
.diff-para { color: #166534; font-weight: 600; }
.json-box {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    font-size: 12px;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 340px;
    overflow: auto;
}

/* ============ FILTRO DE TABELA ============ */
/* Busca rapida das listagens (substitui o campo de busca do DataTables) */
.filtro-tabela,
.filtro-participantes {
    width: 100%;
    max-width: 340px;
    padding: 8px 12px;
    border: 1px solid var(--topbar-border, #e5e7eb);
    border-radius: 6px;
    font-size: 14px;
}
.filtro-participantes { max-width: none; flex: 1; min-width: 260px; }
.filtro-tabela:focus,
.filtro-participantes:focus {
    outline: none;
    border-color: var(--sidebar-active-border);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

/* ============ ACOES DO CABECALHO ============ */
/* Mais de um botao a direita do titulo da tela */
.page-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* ============ SECOES DE FORMULARIO (ex.: lancamento) ============ */
.secao-titulo { font-size: 16px; margin: 0 0 14px; color: #1f2937; }
.secao-cabecalho { display: flex; align-items: center; gap: 10px; }
.secao-cabecalho .secao-titulo { margin-bottom: 6px; }

.participantes-barra {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.participantes-barra label.opcao {
    display: flex; align-items: center; gap: 6px;
    font-size: 14px; color: #374151; white-space: nowrap; cursor: pointer;
}
.participantes-barra button:disabled { opacity: .5; cursor: not-allowed; }

/* Tabela longa dentro de caixa com rolagem; o cabecalho fica parado */
.tabela-rolagem {
    max-height: 460px;
    overflow: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}
.tabela-rolagem table { border-radius: 0; overflow: visible; box-shadow: none; } /* overflow:hidden quebra o sticky */
.tabela-rolagem thead th { position: sticky; top: 0; z-index: 1; }
#tabela-participantes tbody tr { cursor: pointer; }
#tabela-participantes td { padding: 7px 14px; }
#tabela-participantes tr.linha-marcada td { background: #eff6ff; }
#tabela-participantes .tag-fora { margin-left: 6px; cursor: help; }
#tabela-participantes .tag-fora[hidden] { display: none; } /* .badge tem display proprio */
#tabela-participantes input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }

/* O numero do cartao segue a cor do tema, nao o azul fixo da paleta padrao */
.stat-card .value { color: var(--sidebar-active-text); }

/* ============ LOGO NA TOPBAR ============ */
/* O logo da Frooty e amarelo: nas topbars escuras (roxo, vinho, esmeralda,
   cinza) ele salta sozinho, mas o tema Azul tem topbar BRANCA e o amarelo
   praticamente some. A sombra abaixo devolve o contorno so nesse caso. */
.tema-azul .topbar .brand img {
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.45));
}

/* ============ CAMPOS EM CAIXA ALTA ============ */
/* Cadastros basicos e RH sao gravados em maiuscula; o campo ja mostra assim
   enquanto a pessoa digita, para o que ela ve ser o que sera gravado. */
input.maiusculas { text-transform: uppercase; }

/* ============ CAIXAS DE MARCACAO ============ */
/* Checkbox e radio nao sao campos de texto, mas caem na mesma regra dos
   inputs dentro de .field/.row — herdavam width:100%, padding e borda, o que
   os deixava esticados e desalinhados do proprio rotulo. */
.row input[type="checkbox"], .row input[type="radio"],
.field input[type="checkbox"], .field input[type="radio"] {
    width: auto;
    padding: 0;
    border: 0;
    margin: 0;
    box-shadow: none;
    flex: none;
}

/* Rotulo de uma opcao marcavel: quadradinho e texto na mesma linha */
.row label.opcao,
.field label.opcao {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
    font-size: 14px;
    color: #1f2937;
    cursor: pointer;
}

/* ============ LANCAMENTO: conteudo programatico do treinamento escolhido ============ */
.conteudo-programatico {
    margin: 4px 0 16px;
    padding: 12px 16px;
    border-left: 4px solid var(--sidebar-active-text);
    background: var(--sidebar-active-bg);
    border-radius: 6px;
}
.conteudo-programatico[hidden] { display: none; }
.conteudo-programatico-titulo { font-weight: 600; font-size: 14px; color: #1f2937; margin-bottom: 6px; }
.conteudo-programatico ul {
    margin: 0; padding-left: 20px;
    columns: 2 320px; column-gap: 32px;
    font-size: 14px; color: #374151;
}
.conteudo-programatico li { margin: 2px 0; break-inside: avoid; }
.conteudo-programatico p { margin: 0; }

/* ============ PAINEL (graficos em CSS/SVG puro, sem biblioteca) ============ */
.cor-ok   { background: #10b981; }
.cor-pend { background: #f59e0b; }
.cor-venc { background: #ef4444; }
.cor-info { background: #3b82f6; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}
.kpi {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    background: #fff;
    padding: 18px 20px;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border-top: 4px solid var(--kpi-cor, #3b82f6);
}
.kpi-tema { --kpi-cor: var(--sidebar-active-text); }
.kpi-ok   { --kpi-cor: #10b981; }
.kpi-pend { --kpi-cor: #f59e0b; }
.kpi-venc { --kpi-cor: #ef4444; }
.kpi-info { --kpi-cor: #3b82f6; }
.kpi-icone {
    flex: none;
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--kpi-cor) 14%, #fff);
    color: var(--kpi-cor);
}
.kpi-icone svg {
    width: 24px; height: 24px;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
}
.kpi-rotulo { color: #6b7280; font-size: 13px; }
.kpi-valor  { font-size: 30px; font-weight: 700; color: #111827; line-height: 1.2; margin: 2px 0; }
.kpi-valor small { font-size: 14px; font-weight: 500; color: #6b7280; }
.kpi-sub    { color: #6b7280; font-size: 12px; }

.barra-progresso {
    height: 8px; border-radius: 4px; background: #e5e7eb;
    overflow: hidden; margin: 6px 0;
}
.barra-progresso span { display: block; height: 100%; border-radius: 4px; }

.painel-grade { display: grid; gap: 16px; margin-top: 16px; }
.painel-grade-1-1 { grid-template-columns: 1fr 1fr; }
.painel-grade-1-2 { grid-template-columns: minmax(300px, 1fr) 2fr; }
@media (max-width: 1000px) {
    .painel-grade-1-1, .painel-grade-1-2 { grid-template-columns: 1fr; }
}
.painel-card { margin-bottom: 0; display: flex; flex-direction: column; min-width: 0; }
.painel-card h2 { margin: 0 0 12px; font-size: 16px; color: #1f2937; }
.painel-card-topo {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.painel-card-topo h2 { margin: 0; }
.painel-nota { margin: -6px 0 14px; font-size: 13px; }
.painel-link { margin-top: auto; padding-top: 12px; font-size: 13px; }

/* Rosca */
.rosca-area { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; justify-content: center; flex: 1; }
.rosca { width: 170px; height: 170px; }
.rosca-fundo { fill: none; stroke: #e5e7eb; stroke-width: 5; }
.rosca-fatia { fill: none; stroke-width: 5; transition: stroke-width .15s; }
.rosca-fatia:hover { stroke-width: 6.5; }
.traco-ok   { stroke: #10b981; }
.traco-pend { stroke: #f59e0b; }
.traco-venc { stroke: #ef4444; }
.rosca-num { font-size: 8px; font-weight: 700; text-anchor: middle; fill: #111827; }
.rosca-txt { font-size: 3.6px; text-anchor: middle; fill: #6b7280; }

.legenda { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.legenda li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.legenda li strong { margin-left: auto; padding-left: 12px; }
.legenda i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; }
.legenda-linha { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; font-size: 12px; color: #4b5563; }
.legenda-linha li strong { margin-left: 0; }

/* Colunas mensais */
.seletor { display: inline-flex; border: 1px solid #d1d5db; border-radius: 6px; overflow: hidden; }
.seletor button {
    border: 0; background: #fff; padding: 5px 12px; font-size: 13px;
    cursor: pointer; color: #4b5563;
}
.seletor button + button { border-left: 1px solid #d1d5db; }
.seletor button.ativo { background: var(--sidebar-active-text); color: #fff; }
/* Mesmo seletor feito de radios (formularios GET) */
.seletor-opcao {
    display: inline-flex; align-items: center;
    padding: 8px 14px; font-size: 14px; font-weight: 400;
    cursor: pointer; color: #4b5563; background: #fff; margin: 0;
}
.seletor-opcao + .seletor-opcao { border-left: 1px solid #d1d5db; }
.seletor-opcao input { position: absolute; opacity: 0; pointer-events: none; }
.seletor-opcao.ativo { background: var(--sidebar-active-text); color: #fff; }
.colunas {
    display: flex; align-items: stretch; gap: 6px;
    /* flex-basis fixa: com flex:1 a altura sumia quando o card fica sozinho na linha (celular) */
    flex: 1 0 230px; min-height: 230px; padding-top: 4px;
}
@media (max-width: 600px) {
    .colunas { gap: 2px; }
    .coluna-rotulo { font-size: 9px; }
    .coluna-valor { font-size: 10px; }
}
.coluna {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
}
.coluna-area {
    flex: 1; width: 100%; min-height: 0;
    display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
}
.coluna-valor { font-size: 12px; font-weight: 600; color: #374151; min-height: 16px; }
.coluna-barra {
    width: 70%; max-width: 44px; min-height: 0;
    background: linear-gradient(180deg, color-mix(in srgb, var(--sidebar-active-text) 75%, #fff), var(--sidebar-active-text));
    border-radius: 5px 5px 0 0;
    transition: height .35s ease;
}
.coluna:hover .coluna-barra { filter: brightness(1.15); }
.coluna-rotulo {
    font-size: 11px; color: #6b7280; padding-top: 6px; white-space: nowrap;
    border-top: 1px solid #e5e7eb; width: 100%; text-align: center;
}

/* Barras horizontais */
.barras-h { display: flex; flex-direction: column; gap: 10px; }
.barra-h { display: grid; grid-template-columns: minmax(90px, 34%) 1fr 48px; align-items: center; gap: 10px; font-size: 13px; }
.barra-h-rotulo { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #374151; }
.barra-h-trilho {
    display: flex; height: 14px; border-radius: 7px;
    background: #f3f4f6; overflow: hidden;
}
.barra-h-trilho span { height: 100%; transition: width .35s ease; }
.barra-h-valor { text-align: right; font-weight: 600; color: #111827; }

/* Agenda */
.painel-rolagem { max-height: 320px; }
.painel-rolagem td { padding: 7px 14px; }
.agenda { list-style: none; margin: 0; padding: 0; }
.agenda li {
    display: flex; align-items: center; gap: 14px;
    padding: 10px 0; border-bottom: 1px solid #f3f4f6;
}
.agenda li:last-child { border-bottom: 0; }
.agenda-data {
    flex: none; width: 48px; text-align: center; border-radius: 8px;
    background: color-mix(in srgb, var(--sidebar-active-text) 10%, #fff);
    color: var(--sidebar-active-text); padding: 4px 0; line-height: 1.1;
}
.agenda-data strong { display: block; font-size: 18px; }
.agenda-data span { font-size: 11px; text-transform: uppercase; }
.agenda-info { flex: 1; min-width: 0; }
