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

:root {
    --cor-primaria: #1e5631;
    --cor-primaria-escura: #144421;
    --cor-secundaria: #3d8b5a;
    --cor-fundo: #f5f7fa;
    --cor-card: #ffffff;
    --cor-borda: #e1e5eb;
    --cor-texto: #2c3e50;
    --cor-texto-claro: #6c757d;
    --cor-sucesso: #28a745;
    --cor-erro: #dc3545;
    --cor-alerta: #ffc107;
    --sombra: 0 1px 3px rgba(0,0,0,0.08);
    --sombra-hover: 0 4px 12px rgba(0,0,0,0.12);
    --radius: 6px;
}

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: var(--cor-fundo);
    color: var(--cor-texto);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* TOPO / MENU */
.topo {
    background: var(--cor-primaria);
    color: white;
    box-shadow: var(--sombra);
}
.topo-conteudo {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 32px;
    height: 60px;
}
.logo {
    font-size: 22px;
    font-weight: 700;
    color: white;
    text-decoration: none;
    letter-spacing: 1px;
}
.menu {
    display: flex;
    gap: 4px;
    flex: 1;
}
.menu a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    transition: all 0.2s;
}
.menu a:hover { background: rgba(255,255,255,0.1); color: white; }
.menu a.ativo { background: var(--cor-primaria-escura); color: white; }

.usuario-info {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
}
.botao-sair {
    background: rgba(255,255,255,0.15);
    color: white;
    text-decoration: none;
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 13px;
}
.botao-sair:hover { background: rgba(255,255,255,0.25); }

/* CONTEÚDO */
.conteudo {
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 24px;
    width: 100%;
    flex: 1;
}

/* TÍTULOS */
h1 { font-size: 26px; margin-bottom: 24px; color: var(--cor-primaria); }
h2 { font-size: 20px; margin-bottom: 16px; color: var(--cor-texto); }

/* CARDS / DASHBOARD */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.card {
    background: var(--cor-card);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--sombra);
    border-left: 4px solid var(--cor-primaria);
}
.card-titulo {
    font-size: 13px;
    color: var(--cor-texto-claro);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.card-valor {
    font-size: 28px;
    font-weight: 700;
    color: var(--cor-primaria);
}
.card-subtitulo { font-size: 12px; color: var(--cor-texto-claro); margin-top: 4px; }

/* TABELAS */
.tabela-wrap {
    background: var(--cor-card);
    border-radius: var(--radius);
    box-shadow: var(--sombra);
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
thead {
    background: #f8f9fa;
    border-bottom: 2px solid var(--cor-borda);
}
th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--cor-texto);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
td {
    padding: 12px;
    border-bottom: 1px solid var(--cor-borda);
}
tbody tr:hover { background: #fafbfc; }

/* STATUS BADGES */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
.badge-emitida { background: #d4edda; color: #155724; }
.badge-pendente { background: #fff3cd; color: #856404; }
.badge-cancelada { background: #f8d7da; color: #721c24; }

/* FORMULÁRIOS */
.form-card {
    background: var(--cor-card);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--sombra);
    max-width: 800px;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}
.campo {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.campo label {
    font-size: 13px;
    font-weight: 600;
    color: var(--cor-texto);
}
.campo input, .campo select, .campo textarea {
    padding: 10px 12px;
    border: 1px solid var(--cor-borda);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: white;
    transition: border-color 0.2s;
}
.campo input:focus, .campo select:focus, .campo textarea:focus {
    outline: none;
    border-color: var(--cor-primaria);
}
.campo textarea { resize: vertical; min-height: 80px; }
.campo-largo { grid-column: 1 / -1; }

/* BOTÕES */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    font-family: inherit;
}
.btn-primario { background: var(--cor-primaria); color: white; }
.btn-primario:hover { background: var(--cor-primaria-escura); }
.btn-secundario { background: #6c757d; color: white; }
.btn-secundario:hover { background: #545b62; }
.btn-perigo { background: var(--cor-erro); color: white; }
.btn-perigo:hover { background: #c82333; }
.btn-pequeno { padding: 6px 12px; font-size: 12px; }

.acoes-form {
    margin-top: 24px;
    display: flex;
    gap: 12px;
}

/* FILTROS */
.filtros {
    background: var(--cor-card);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--sombra);
    margin-bottom: 16px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: end;
}
.filtros .campo { min-width: 150px; flex: 1; }

/* ALERTAS */
.alerta {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
}
.alerta-sucesso { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alerta-erro { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* LOGIN */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--cor-primaria) 0%, var(--cor-secundaria) 100%);
}
.login-card {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 400px;
}
.login-card h1 {
    text-align: center;
    margin-bottom: 32px;
    color: var(--cor-primaria);
}
.login-card .btn { width: 100%; margin-top: 8px; }

/* CABEÇALHO PÁGINA */
.pagina-cabecalho {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

/* RODAPÉ */
.rodape {
    background: #ffffff;
    border-top: 1px solid var(--cor-borda);
    padding: 16px;
    text-align: center;
    color: var(--cor-texto-claro);
    font-size: 13px;
}

/* RESPONSIVO */
@media (max-width: 768px) {
    .topo-conteudo { flex-wrap: wrap; height: auto; padding: 12px; gap: 12px; }
    .menu { width: 100%; overflow-x: auto; }
    .conteudo { padding: 16px; }
}

/* ============================================================
   COMPONENTES v2: METAS, TAREFAS, RANKING
   ============================================================ */

/* Grid de 2 colunas (dashboard) */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 24px;
}
@media (max-width: 900px) {
    .grid-2col { grid-template-columns: 1fr; }
}

/* Barra mini (ranking inline) */
.barra-mini {
    background: #e9ecef;
    height: 6px;
    border-radius: 3px;
    margin-top: 4px;
    overflow: hidden;
}
.barra-mini-fill {
    background: var(--cor-primaria);
    height: 100%;
    transition: width 0.5s ease;
}

/* === METAS === */
.metas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 16px;
}
.meta-card {
    background: var(--cor-card);
    border-radius: var(--radius);
    box-shadow: var(--sombra);
    padding: 20px;
    border-left: 4px solid var(--cor-primaria);
    transition: transform 0.2s;
}
.meta-card:hover { transform: translateY(-2px); box-shadow: var(--sombra-hover); }

.meta-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.meta-card-header h3 { color: var(--cor-primaria); font-size: 18px; }
.meta-card-acoes { display: flex; gap: 4px; }

.meta-item { margin-bottom: 16px; }
.meta-label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 6px;
    color: var(--cor-texto);
}
.meta-pct { color: var(--cor-texto-claro); margin-left: 8px; }

.barra-progresso {
    background: #e9ecef;
    height: 22px;
    border-radius: 11px;
    overflow: hidden;
    position: relative;
}
.barra-progresso-fill {
    height: 100%;
    transition: width 0.8s ease;
    border-radius: 11px;
}
.progresso-vermelho { background: linear-gradient(90deg, #dc3545, #ff6b6b); }
.progresso-amarelo  { background: linear-gradient(90deg, #ffc107, #ffd54f); }
.progresso-verde    { background: linear-gradient(90deg, #28a745, #5cb85c); }
.progresso-ouro     {
    background: linear-gradient(90deg, #ffd700, #ffeb3b, #ffd700);
    background-size: 200% 100%;
    animation: brilho 2s linear infinite;
}
@keyframes brilho {
    0% { background-position: 0% 0%; }
    100% { background-position: 200% 0%; }
}

/* Marcador de ritmo esperado */
.barra-ritmo {
    position: absolute;
    top: -3px;
    bottom: -3px;
    width: 2px;
    background: #333;
    z-index: 2;
}
.barra-ritmo::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #333;
}

.meta-obs {
    margin-top: 12px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 13px;
    color: var(--cor-texto-claro);
    border-left: 3px solid var(--cor-borda);
}
.meta-estrela {
    margin-top: 12px;
    text-align: center;
    padding: 8px;
    background: linear-gradient(90deg, #fff8dc, #fffacd, #fff8dc);
    border-radius: 6px;
    font-weight: bold;
    color: #b8860b;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

/* === TAREFAS === */
.badge-aberta     { background: #e2e3e5; color: #383d41; }
.badge-andamento  { background: #fff3cd; color: #856404; }
.badge-tratativa  { background: #ffd8b1; color: #8b4500; }
.badge-finalizada { background: #d4edda; color: #155724; }

.linha-atrasada {
    background: #fff5f5 !important;
}
.linha-atrasada td {
    border-left: 3px solid var(--cor-erro);
}

/* ============================================================
   COMPONENTES v3
   ============================================================ */

/* Card clicável */
.card-link {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: transform 0.15s, box-shadow 0.15s;
}
.card-link:hover {
    transform: translateY(-2px);
    box-shadow: var(--sombra-hover);
}

/* Multi-select de seguradoras */
.multi-select { position: relative; }
.multi-select-btn {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--cor-borda);
    border-radius: var(--radius);
    background: white;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
}
.multi-select-btn:hover { border-color: var(--cor-primaria); }
.multi-select-opcoes {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--cor-borda);
    border-radius: var(--radius);
    box-shadow: var(--sombra-hover);
    max-height: 280px;
    overflow-y: auto;
    z-index: 10;
    margin-top: 4px;
}
.multi-opcao {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
}
.multi-opcao:hover { background: #f8f9fa; }
.multi-opcao input { cursor: pointer; }

/* Cabeçalho dos blocos com toggle */
.bloco-cabecalho {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}
.toggle-vista {
    display: flex;
    gap: 4px;
    background: #e9ecef;
    border-radius: 6px;
    padding: 3px;
}
.btn-vista {
    background: transparent;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--cor-texto-claro);
    transition: all 0.2s;
}
.btn-vista:hover { color: var(--cor-texto); }
.btn-vista.ativo {
    background: white;
    color: var(--cor-primaria);
    box-shadow: var(--sombra);
}

/* Header da tabela ordenável */
.th-link {
    color: inherit;
    text-decoration: none;
    display: block;
    cursor: pointer;
}
.th-link:hover { color: var(--cor-primaria); }

/* Card do gráfico */
.grafico-card {
    background: var(--cor-card);
    border-radius: var(--radius);
    box-shadow: var(--sombra);
    padding: 16px;
    height: 380px;
    position: relative;
}
.grafico-card canvas { max-height: 100%; }

/* Cores de barra mini */
.bg-vermelho { background: linear-gradient(90deg, #dc3545, #ff6b6b) !important; }
.bg-amarelo { background: linear-gradient(90deg, #ffc107, #ffd54f) !important; }
.bg-verde { background: linear-gradient(90deg, #28a745, #5cb85c) !important; }
.bg-ouro { background: linear-gradient(90deg, #ffd700, #ffeb3b, #ffd700) !important; }

/* Meta mini (na tabela do dashboard) */
.meta-mini { font-size: 13px; }

/* Alerta de tarefas no topo */
.alerta-tarefas {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
    flex-wrap: wrap;
    gap: 8px;
}
.alerta-tarefas a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
    white-space: nowrap;
}
.alerta-tarefa-pendente {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}
.alerta-tarefa-atrasada {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    animation: pulse-alerta 2s infinite;
}
@keyframes pulse-alerta {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220,53,69,0.3); }
    50% { box-shadow: 0 0 0 8px rgba(220,53,69,0); }
}

.alerta-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
}

/* Abas (tipo) - nas Metas */
.abas-tipo {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--cor-borda);
    margin-bottom: 16px;
}
.aba {
    padding: 10px 20px;
    text-decoration: none;
    color: var(--cor-texto-claro);
    font-weight: 600;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}
.aba:hover { color: var(--cor-primaria); }
.aba.ativa {
    color: var(--cor-primaria);
    border-bottom-color: var(--cor-primaria);
}

/* Mensagens em tarefas (chat) */
.mensagens-lista {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 16px 0;
}
.msg-item {
    background: var(--cor-card);
    padding: 12px 16px;
    border-radius: var(--radius);
    box-shadow: var(--sombra);
    max-width: 80%;
}
.msg-item.msg-eu {
    align-self: flex-end;
    background: #d4edda;
    border-left: 3px solid var(--cor-primaria);
}
.msg-item.msg-outro {
    align-self: flex-start;
    border-left: 3px solid var(--cor-borda);
}
.msg-cabecalho {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    gap: 16px;
    font-size: 13px;
}
.msg-cabecalho small { color: var(--cor-texto-claro); }
.msg-corpo {
    line-height: 1.5;
    word-wrap: break-word;
}


/* ============================================================
   GRUPOS DE SEGURADORAS - v4
   ============================================================ */

/* Form: grid de checkboxes de seguradoras */
.seg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
    padding: 12px;
    background: #f8f9fa;
    border: 1px solid var(--cor-borda);
    border-radius: var(--radius);
    max-height: 320px;
    overflow-y: auto;
}
.seg-check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid transparent;
    font-size: 14px;
    transition: all 0.15s;
}
.seg-check:hover:not(.seg-indisponivel) {
    border-color: var(--cor-primaria);
    background: #f0f7f1;
}
.seg-check input { cursor: pointer; }
.seg-check.seg-indisponivel {
    opacity: 0.5;
    cursor: not-allowed;
    background: #fff3cd;
}
.seg-check.seg-indisponivel small {
    display: block;
    font-size: 11px;
    color: var(--cor-texto-claro);
    width: 100%;
    margin-top: 2px;
}

/* Card de grupo na listagem (full width) */
.meta-card-grupo {
    border-left: 4px solid #6f42c1;
}
.meta-card-grupo h3 {
    color: #6f42c1;
}
.grupo-membros {
    margin: 8px 0 12px 0;
    font-size: 13px;
    line-height: 1.8;
}
.tag-membro {
    display: inline-block;
    background: #e9ecef;
    color: var(--cor-texto);
    padding: 3px 8px;
    border-radius: 12px;
    margin: 0 4px 4px 0;
    font-size: 12px;
    font-weight: 600;
}

/* Tabela de contribuição (dentro do card de grupo) */
.grupo-contribuicao {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--cor-borda);
    font-size: 13px;
}
.grupo-contribuicao > strong {
    display: block;
    margin-bottom: 8px;
}
.tabela-contribuicao {
    width: 100%;
    border-collapse: collapse;
}
.tabela-contribuicao td {
    padding: 4px 8px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}
.tabela-contribuicao tr:last-child td {
    border-bottom: none;
}

/* Grid de grupos no dashboard */
.grupos-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
    margin-top: 12px;
}
.grupo-dashboard-card {
    background: var(--cor-card);
    border-left: 4px solid #6f42c1;
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--sombra);
}
.grupo-dashboard-card h4 {
    margin: 0 0 8px 0;
    font-size: 15px;
    color: #6f42c1;
}
.grupo-segs {
    margin-bottom: 10px;
    line-height: 1.8;
}
.grupo-segs .tag-membro {
    font-size: 11px;
    padding: 2px 6px;
}
.grupo-numeros {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin: 8px 0;
    font-size: 14px;
}
.grupo-pct {
    font-weight: bold;
    color: var(--cor-primaria);
    font-size: 16px;
}

