* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e0e6ed;
}

header h1 {
    color: #2c3e50;
    font-size: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-controls {
    display: flex;
    gap: 10px;
}

/* Botões */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-success {
    background-color: #27ae60;
    color: white;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* Filtros */
.filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.filters input, .filters select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    min-width: 160px;
    flex: 1 1 auto;
}

#searchInput {
    flex: 2 1 auto;
    min-width: 250px;
}

/* ESTILOS MULTISELECT PERSONALIZADO - COMPACTADO */
.multiselect-container {
    position: relative;
    min-width: 250px;
    max-width: 280px;
    width: 100%;
    flex: 0 0 auto;
}

.custom-multiselect {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background-color: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 42px;
    max-height: 42px;
    overflow: hidden;
    width: 100%;
    font-size: 14px;
}

.custom-multiselect:hover {
    border-color: #3498db;
}

#multiselect-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 20px;
    font-size: 14px;
    flex: 1;
    min-width: 0;
}

.multiselect-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-top: 5px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: none;
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    width: 100%;
    min-width: 250px;
}

.multiselect-dropdown.show {
    display: block;
}

.multiselect-option {
    padding: 12px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background-color 0.2s;
    font-size: 14px;
}

.multiselect-option:hover {
    background-color: #f8f9fa;
}

.multiselect-option input[type="checkbox"] {
    margin-right: 12px;
    cursor: pointer;
    transform: scale(1);
}

.multiselect-option label {
    cursor: pointer;
    flex: 1;
    margin: 0;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Estilo para quando há múltiplas seleções */
.multiselect-multiple .custom-multiselect {
    background-color: #ebf5fb;
    border-color: #3498db;
}

/* Badge para itens selecionados (quando quiser mostrar no label) */
.selected-count-badge {
    display: inline-block;
    background-color: #3498db;
    color: white;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 11px;
    margin-left: 5px;
    font-weight: bold;
}

/* Fechar dropdown ao clicar fora */
.multiselect-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
    display: none;
}

.multiselect-backdrop.show {
    display: block;
}

/* Tabela estilo planilha */
.spreadsheet-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: 20px;
}

.table-wrapper {
    overflow-x: auto;
}

#crmTable {
    width: 100%;
    border-collapse: collapse;
    min-width: 1600px;
}

#crmTable thead {
    background-color: #2c3e50;
    color: white;
}

#crmTable th {
    padding: 15px 10px;
    text-align: left;
    font-weight: 600;
    border-right: 1px solid #34495e;
    position: sticky;
    top: 0;
    z-index: 10;
}

#crmTable th:last-child {
    border-right: none;
}

#crmTable tbody tr {
    border-bottom: 1px solid #e0e6ed;
    transition: background-color 0.2s;
}

#crmTable tbody tr:hover {
    background-color: #f8f9fa;
}

#crmTable td {
    padding: 12px 10px;
    border-right: 1px solid #e0e6ed;
    vertical-align: top;
}

#crmTable td:last-child {
    border-right: none;
}

/* Estilo para células específicas */
.status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-prospecção { background-color: #f39c12; color: white; }
.status-negociação { background-color: #3498db; color: white; }
.status-fechado { background-color: #27ae60; color: white; }
.status-perdido { background-color: #e74c3c; color: white; }
.status-em andamento { background-color: #9b59b6; color: white; }
.status-contatar { background-color: #1abc9c; color: white; }

/* Links */
.link-pagamento {
    color: #3498db;
    text-decoration: none;
    word-break: break-all;
    font-size: 12px;
}

.link-pagamento:hover {
    text-decoration: underline;
}

/* Histórico resumido */
.historico-resumo {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    color: #3498db;
}

.historico-resumo:hover {
    text-decoration: underline;
}

/* Sumário */
.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.summary-item {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.summary-item span {
    display: block;
    color: #7f8c8d;
    font-size: 14px;
    margin-bottom: 5px;
}

.summary-item strong {
    font-size: 24px;
    color: #2c3e50;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow-y: auto;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 10px;
    width: 90%;
    max-width: 800px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-lg {
    max-width: 900px;
}

.modal-header {
    padding: 20px 30px;
    background-color: #2c3e50;
    color: white;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
}

.close, .close-history {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover, .close-history:hover {
    color: #ecf0f1;
}

.modal-body {
    padding: 30px;
}

/* Formulário */
.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.form-row .form-group {
    flex: 1;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

/* Conteúdo do histórico */
#historyContent {
    white-space: pre-wrap;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 6px;
    max-height: 500px;
    overflow-y: auto;
}

/* Responsividade */
@media (max-width: 1200px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .summary {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .header-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .filters input, .filters select {
        min-width: 100%;
    }
    
    .multiselect-container {
        min-width: 100% !important;
        max-width: 100% !important;
    }
    
    #searchInput {
        min-width: 100%;
    }
    
    .summary {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
}

/* Seções do formulário */
.form-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.form-section:last-child {
    border-bottom: none;
}

.form-section h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-section h3 i {
    color: #3498db;
}

/* Campos obrigatórios */
.form-group.required label::after {
    content: " *";
    color: #e74c3c;
}

/* Clique no nome do cliente */
.cliente-clickable {
    color: #3498db;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    padding: 5px;
    border-radius: 4px;
    display: inline-block;
}

.cliente-clickable:hover {
    background-color: #ebf5fb;
    text-decoration: underline;
}

.cliente-clickable i {
    margin-left: 5px;
    font-size: 12px;
    opacity: 0.7;
}

/* Modal de informações do cliente */
.modal-sm {
    max-width: 500px;
}

.client-info-card {
    text-align: center;
    padding: 20px;
}

.client-avatar {
    width: 80px;
    height: 80px;
    background-color: #3498db;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.client-avatar i {
    font-size: 36px;
    color: white;
}

.client-details {
    text-align: left;
}

.client-details h3 {
    text-align: center;
    margin-bottom: 20px;
    color: #2c3e50;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 6px;
}

.info-item i {
    color: #3498db;
    width: 20px;
    text-align: center;
}

.info-item span {
    flex: 1;
    word-break: break-word;
}

/* Responsividade adicional */
@media (max-width: 768px) {
    .cliente-clickable {
        font-size: 14px;
    }
    
    .info-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}

/* Estilo para o campo de documento */
#documentoCliente {
    text-transform: uppercase;
}

/* Indicador visual do tipo de documento */
.tipo-doc-indicator {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    margin-left: 5px;
    background-color: #3498db;
    color: white;
}

.tipo-doc-cpf { background-color: #3498db; }
.tipo-doc-cnpj { background-color: #9b59b6; }

/* Estilo para o X de fechar dos modais */
.close, .close-info, .close-history, .close-info-modal {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
    padding: 0 10px;
    display: inline-block;
}

.close:hover, .close-info:hover, .close-history:hover, .close-info-modal:hover {
    color: #ecf0f1;
    text-decoration: none;
}

/* Garantir que o header do modal tenha display flex para alinhar */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Ajustar o client-details para não herdar estilos incorretos */
.client-details {
    text-align: left;
    width: 100%;
}

.client-details h3 {
    text-align: center;
    margin-bottom: 20px;
    color: #2c3e50;
    font-size: 1.5em;
}

/* Estilo para os itens de informação */
.info-item {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 15px;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 6px;
    min-height: 40px;
}

.info-item i {
    color: #3498db;
    width: 20px;
    text-align: center;
    line-height: 1.5;
    margin-top: 2px;
}

.info-item span {
    flex: 1;
    word-break: break-word;
    line-height: 1.5;
}

/* NOVOS ESTILOS PARA DIFERENCIAR PARCEIRO/CLIENTE */

/* Badge para a coluna Tipo */
.tipo-registro-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    color: white;
    text-transform: uppercase;
    min-width: 70px;
    text-align: center;
}

.tipo-registro-badge.cliente {
    background-color: #3498db;
}

.tipo-registro-badge.parceiro {
    background-color: #9b59b6;
}

.tipo-registro-badge.fornecedor {
    background-color: #e74c3c;
}

/* Indicador de tipo de registro ao lado do nome */
.tipo-registro-indicator {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    margin-left: 5px;
    color: white;
    text-transform: uppercase;
}

.tipo-registro-indicator.cliente {
    background-color: #3498db;
}

.tipo-registro-indicator.parceiro {
    background-color: #9b59b6;
}

.tipo-registro-indicator.fornecedor {
    background-color: #e74c3c;
}

/* Ajuste na largura da tabela para nova coluna */
#crmTable {
    width: 100%;
    border-collapse: collapse;
    min-width: 1700px; /* Aumentado para acomodar nova coluna */
}

/* Estilo para o campo tipoRegistro no formulário */
.form-group select#tipoRegistro {
    background-color: #f8f9fa;
    border: 2px solid #e0e6ed;
    font-weight: bold;
}

.form-group select#tipoRegistro:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

/* Ajuste nos filtros para novo campo */
.filters select#tipoFilter {
    min-width: 150px;
}

/* Ajuste no sumário para novos itens */
.summary-item strong {
    font-size: 22px;
}

/* Responsividade para nova coluna */
@media (max-width: 768px) {
    .tipo-registro-badge {
        font-size: 9px;
        padding: 2px 4px;
        min-width: 50px;
    }
}

/* CORREÇÕES PARA OS FILTROS */

/* Estilo para o multiselect */
.multiselect-container {
    position: relative;
    min-width: 250px;
    max-width: 280px;
    width: 100%;
    flex: 0 0 auto;
    z-index: 1000;
}

.custom-multiselect {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background-color: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 42px;
    max-height: 42px;
    overflow: hidden;
    width: 100%;
    font-size: 14px;
    transition: border-color 0.3s;
}

.custom-multiselect:hover {
    border-color: #3498db;
}

#multiselect-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 20px;
    font-size: 14px;
    flex: 1;
    min-width: 0;
}

.multiselect-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-top: 5px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: none;
    z-index: 1001;
    max-height: 300px;
    overflow-y: auto;
    width: 100%;
    min-width: 250px;
}

.multiselect-dropdown.show {
    display: block;
}

.multiselect-option {
    padding: 12px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background-color 0.2s;
    font-size: 14px;
}

.multiselect-option:hover {
    background-color: #f8f9fa;
}

.multiselect-option input[type="checkbox"] {
    margin-right: 12px;
    cursor: pointer;
    transform: scale(1);
}

.multiselect-option label {
    cursor: pointer;
    flex: 1;
    margin: 0;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Estilo para quando há múltiplas seleções */
.multiselect-multiple .custom-multiselect {
    background-color: #ebf5fb;
    border-color: #3498db;
}

/* Fechar dropdown ao clicar fora */
.multiselect-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
    display: none;
    background-color: transparent;
}

.multiselect-backdrop.show {
    display: block;
}

/* Estilos para o filtro de tipo */
#tipoFilter {
    min-width: 150px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background-color: white;
    cursor: pointer;
}

#tipoFilter:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* Badge para a coluna Tipo */
.tipo-registro-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    color: white;
    text-transform: uppercase;
    min-width: 70px;
    text-align: center;
}

.tipo-registro-badge.cliente {
    background-color: #3498db;
}

.tipo-registro-badge.parceiro {
    background-color: #9b59b6;
}

.tipo-registro-badge.fornecedor {
    background-color: #e74c3c;
}

/* Status badges */
.status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-block;
    min-width: 80px;
    text-align: center;
}

.status-prospecção { 
    background-color: #f39c12; 
    color: white; 
}

.status-negociação { 
    background-color: #3498db; 
    color: white; 
}

.status-fechado { 
    background-color: #27ae60; 
    color: white; 
}

.status-perdido { 
    background-color: #e74c3c; 
    color: white; 
}

.status-em-andamento { 
    background-color: #9b59b6; 
    color: white; 
}

.status-contatar { 
    background-color: #1abc9c; 
    color: white; 
}

/* Ajuste na largura da tabela para nova coluna */
#crmTable {
    width: 100%;
    border-collapse: collapse;
    min-width: 1800px; /* Aumentado para acomodar nova coluna */
}

/* Ajuste nos filtros */
.filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.filters input, .filters select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    min-width: 160px;
    flex: 1 1 auto;
}

#searchInput {
    flex: 2 1 auto;
    min-width: 250px;
}

.filters button {
    padding: 10px 15px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

/* Responsividade */
@media (max-width: 992px) {
    .filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filters input, .filters select, .filters button, .multiselect-container {
        min-width: 100%;
        width: 100%;
    }
    
    #searchInput {
        min-width: 100%;
    }
    
    .multiselect-container {
        min-width: 100%;
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .tipo-registro-badge {
        font-size: 9px;
        padding: 2px 4px;
        min-width: 50px;
    }
    
    .status-badge {
        font-size: 10px;
        min-width: 60px;
        padding: 3px 6px;
    }
}