/* ============================================
   ENERGITEL CRM STYLES - PRODUCCIÓN 2025
   ============================================ */

/* === RESET Y BASE === */
.crm-form-container {
    max-width: 100%;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: linear-gradient(135deg, rgb(15, 23, 42) 0%, rgb(30, 41, 59) 100%);
    
}

/* === UI OPTIMIZADA PARA IPAD === */

/* Header iPad-friendly - Extra Condensado */
.crm-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 12px 24px; /* Más condensado */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(15, 23, 42, 0.1);
}

.crm-header-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.crm-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.crm-title {
    color: rgb(15, 23, 42);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
}

.crm-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.crm-header-comercial-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.comercial-asignado {
    background: rgba(0, 124, 186, 0.1);
    color: #007cba;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.borrador-info {
    background: rgba(255, 193, 7, 0.1);
    color: #ffc107;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.crm-header-badges {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(15, 23, 42, 0.05);
}

.crm-header-badges .crm-badges-estado {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Responsive para móviles */
@media (max-width: 768px) {
    .crm-header {
        padding: 8px 16px;
    }
    
    .crm-header-main {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .crm-header-left {
        justify-content: center;
    }
    
    .crm-title {
        font-size: 16px;
        text-align: center;
    }
    
    .crm-header-right {
        justify-content: center;
    }
    
    .crm-header-comercial-info {
        justify-content: center;
    }
    
    .crm-header-badges {
        margin-top: 6px;
        padding-top: 6px;
    }
}

.crm-header h2 {
    margin: 0;
    color: rgb(15, 23, 42);
    font-size: 20px; /* Reducido de 28px */
    font-weight: 700;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px; /* Reducido de 12px */
    line-height: 1.2;
}

.crm-logo {
    width: 20px; /* Más pequeño */
    height: 20px; /* Más pequeño */
    border-radius: 4px;
    vertical-align: middle;
}

/* Container principal */
.crm-form-content {
    padding: 20px; /* Reducido de 32px */
    max-width: 1024px;
    margin: 0 auto;
}

/* Cards elegantes */
.form-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 24px; /* Reducido de 32px */
    margin-bottom: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.form-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.15);
}

.form-card h3 {
    color: rgb(15, 23, 42);
    font-size: 22px;
    font-weight: 600;
    margin: 0 0 24px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Grid responsive para iPad */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

/* === FORMULARIOS === */

/* Form Groups */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

/* Labels elegantes */
.form-group label {
    font-weight: 600;
    color: rgb(15, 23, 42);
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.form-group label::before {
    content: '';
    width: 4px;
    height: 16px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 2px;
}

/* Inputs profesionales */
.form-group input, .form-group select, .form-group textarea {
    padding: 16px 20px;
    border: 2px solid rgba(15, 23, 42, 0.1);
    border-radius: 16px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    width: 100%;
    box-sizing: border-box;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: #3b82f6;
    background: white;
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.15);
}

/* === VALIDACIONES === */

/* Email validación elegante */
.form-group input[type="email"] {
    transition: border-color 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease;
}

.form-group input[type="email"]:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.15);
    transform: scale(1.02);
}

.form-group input[type="email"].valid {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.05);
}

.form-group input[type="email"].invalid {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
}

input[type="email"]:valid:not(:placeholder-shown) {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%2310b981' d='m2.3 6.73.7-.4 1.85-2.77-1.42-1.42L2.3 6.73z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 20px;
    padding-right: 50px;
    border-color: #10b981;
    background-color: rgba(16, 185, 129, 0.05);
}

/* Teléfono y validaciones */
input[type="tel"] {
    transition: all 0.3s ease;
    border: 2px solid rgba(15, 23, 42, 0.1);
    border-radius: 16px;
    padding: 16px 20px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

input[type="tel"]:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.15);
    transform: scale(1.02);
}

input[type="tel"].valid {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.05);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='%2310b981' viewBox='0 0 16 16'%3e%3cpath d='M12.736 3.97a.733.733 0 0 1 1.047 0c.286.289.29.756.01 1.05L7.88 12.01a.733.733 0 0 1-1.065.02L3.217 8.384a.757.757 0 0 1 0-1.06.733.733 0 0 1 1.047 0l3.052 3.093 5.4-6.425a.247.247 0 0 1 .02-.022Z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 20px;
    padding-right: 50px;
}

input[type="tel"].invalid {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
}

.phone-help, .population-help {
    font-size: 14px;
    color: #64748b;
    margin-top: 8px;
    display: block;
    font-style: italic;
}

.email-error-message {
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Estilos para campos inválidos */
.invalid {
    border-color: red;
}

/* Estilos para mensajes de error */
.error-message {
    color: red;
    font-size: 0.9em;
    margin-top: 4px;
    display: block;
}

/* === SELECT Y AUTOCOMPLETADO === */

/* Select personalizado */
.form-select {
    appearance: none;
    background: rgba(255, 255, 255, 0.9) url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m6 8 4 4 4-4'/%3e%3c/svg%3e") no-repeat right 16px center;
    background-size: 20px;
    padding-right: 50px;
    cursor: pointer;
    border: 2px solid rgba(15, 23, 42, 0.1);
    border-radius: 16px;
    padding: 16px 20px;
    padding-right: 50px;
    font-size: 16px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.form-select:hover {
    border-color: #94a3b8;
    background-color: white;
}

.form-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.15);
    transform: scale(1.02);
}

/* Autocompletado profesional */
.autocomplete-container {
    position: relative;
}

.form-input-autocomplete {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid rgba(15, 23, 42, 0.1);
    border-radius: 16px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.9);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.form-input-autocomplete:focus {
    outline: none;
    border-color: #3b82f6;
    background: white;
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.15);
}

.autocomplete-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid rgba(59, 130, 246, 0.2);
    border-top: none;
    border-radius: 0 0 16px 16px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(20px);
    animation: slideInUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.autocomplete-suggestion {
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(15, 23, 42, 0.05);
    font-size: 16px;
}

.autocomplete-suggestion:hover {
    background: rgba(59, 130, 246, 0.05);
    color: #3b82f6;
}

.autocomplete-suggestion.selected {
    background: #3b82f6;
    color: white;
}

.autocomplete-suggestion:last-child {
    border-bottom: none;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Validación visual de campos provincia/población */
.form-select.valid, .form-input-autocomplete.valid {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.05);
}

.form-select.invalid, .form-input-autocomplete.invalid {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
}

.province-help, .population-help {
    display: block;
    margin-top: 8px;
    font-size: 13px;
    color: rgba(15, 23, 42, 0.6);
    line-height: 1.4;
}

.province-help.error, .population-help.error {
    color: #ef4444;
    font-weight: 500;
}

/* Indicador de carga para municipios */
.autocomplete-loading {
    padding: 16px 20px;
    text-align: center;
    color: rgba(15, 23, 42, 0.6);
    font-style: italic;
}

.autocomplete-loading:before {
    content: "🔍 ";
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* === BOTONES ENERGITEL === */

.btn-group {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 32px;
    text-align: center;
}

.btn {
    padding: 16px 32px;
    border: none;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 160px;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 10px;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    box-shadow: 0 8px 16px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(59, 130, 246, 0.4);
    opacity: 0.9;
}

.btn-secondary {
    background: linear-gradient(135deg, #64748b, #94a3b8);
    color: white;
    box-shadow: 0 8px 16px rgba(100, 116, 139, 0.3);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(100, 116, 139, 0.4);
    opacity: 0.9;
}

button.crm-submit-btn.enviar-btn {
    background: #FF5722;
}

/* === ESTADOS Y BADGES === */

/* Estados elegantes */
.estado {
    padding: 8px 16px;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
    display: inline-block;
    line-height: 1.5;
    transition: background-color 0.3s, transform 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.5s ease-out;
}

.estado:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Colores por estado con gradientes profesionales */
.estado.borrador, 
.estado.badge-borrador,
strong.estado.borrador,
.widget .estado.borrador {
    background: linear-gradient(135deg, #6c757d, #495057);
}

.estado.enviado,
.estado.badge-enviado,
strong.estado.enviado,
.widget .estado.enviado {
    background: linear-gradient(135deg, #007bff, #0056b3);
}

.estado.presupuesto_aceptado,
.estado.badge-presupuesto_aceptado,
strong.estado.presupuesto_aceptado,
.widget .estado.presupuesto_aceptado {
    background: linear-gradient(135deg, #28a745, #1e7e34);
}

.estado.contratos_generados,
.estado.badge-contratos_generados,
strong.estado.contratos_generados,
.widget .estado.contratos_generados {
    background: linear-gradient(135deg, #007bff, #0056b3);
}

.estado.contratos_firmados,
.estado.badge-contratos_firmados,
strong.estado.contratos_firmados,
.widget .estado.contratos_firmados {
    background: linear-gradient(135deg, #7048E8, #5a34c7);
}

.estado.pendiente_revision,
.estado.badge-pendiente_revision,
strong.estado.pendiente_revision,
.widget .estado.pendiente_revision {
    background: linear-gradient(135deg, #fd7e14, #e55a00);
}

.estado.presupuesto_enviado,
.estado.badge-presupuesto_enviado,
strong.estado.presupuesto_enviado,
.widget .estado.presupuesto_enviado {
    background: linear-gradient(135deg, #000000, #333333);
}

.estado.presupuesto_generado,
.estado.badge-presupuesto_generado,
strong.estado.presupuesto_generado,
.widget .estado.presupuesto_generado {
    background: linear-gradient(135deg, #000000, #333333);
    color: #fff;
}

.estado.contratos_enviados,
.estado.badge-contratos_enviados,
strong.estado.contratos_enviados,
.widget .estado.contratos_enviados {
    background: linear-gradient(135deg, #17a2b8, #138496);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* CRM Badges con nueva paleta 2025 */
.crm-badge {
    color: #fff;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    display: inline-block;
    margin: 2px 6px 2px 0;
    font-weight: 600;
    line-height: 1.2em;
}

/* Estados */
.crm-badge.estado-borrador { background: #B0B7C3; }
.crm-badge.estado-enviado { background: #2AA8F2; }
.crm-badge.estado-presupuesto-generado { background: #F5A623; }
.crm-badge.estado-presupuesto_generado { background: #FF9500; } /* Versión con guión bajo */
.crm-badge.estado-presupuesto_aceptado { background: #25C685; }
.crm-badge.estado-contratos-firmados { background: #7048E8; }
.crm-badge.estado-contratos_generados { background: #007bff; }
.crm-badge.estado-contratos_firmados { background: #7048E8; }

/* Sectores */
.crm-badge.sector-energia { background: #FF6B6B; }
.crm-badge.sector-alarmas { background: #FFB400; }
.crm-badge.sector-telecomunicaciones { background: #00B8D9; }
.crm-badge.sector-seguros { background: #6DD400; }
.crm-badge.sector-renovables { background: #38B24A; }
.crm-badge.reenvio { background: #FF7E29; color: #fff; }

/* === SECCIONES CRM === */

.crm-section {
    background: #f5f5f5;
    padding: 25px;
    margin-bottom: 10px;
}

.crm-section h3 {
    font-size: 1.1em;
}

.crm-section.inicio {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
}

.crm-section.inicio .estado p {
    line-height: 1em;
    padding: 0px;
    margin: 0px;
}

.crm-section.inicio .estado p small {
    font-style: italic;
    font-size: 0.8em;
}

.crm-section.enviar {
    margin: 50px auto;
    text-align: center;
}

.crm-section.enviar button {
    width: 40%;
    margin: 0 auto;
}

/* === WIDGETS === */

.widget h3 {
    color: #000000;
    font-size: 16px !important;
    font-weight: bolder;
    text-transform: uppercase;
    border-bottom: 1px solid #ccc;
    text-align: center;
}

.widget canvas#clientesPorInteresChart {
    max-width: 400px;
    max-height: 400px;
    margin: 0 auto;
    display: block;
}

.widget .estado {
    font-size: 12px;
}

.recientes .info {
    line-height: 1em;
}

.infodos .estado-fecha {
    color: white;
}

li.recientes {
    display: flex;
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    margin: 4px 0px;
    border-bottom: 1px solid var(--ast-global-color-6);
}

.infodos {
    padding: 5px 0px;
}

.rendimiento-comercial a {
    color: var(--ast-global-color-2);
    font-weight: bold;
}

/* === CONTENEDORES Y GRIDS === */

/* Contenedor principal de datos */
.datos-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

/* Campos de ancho completo */
.full-width {
    grid-column: span 2;
}

/* Intereses */
.intereses-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.intereses-container label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: #f9f9f9;
    color: #333;
    font-size: 14px;
}

.intereses-container input[type="checkbox"] {
    display: none;
}

.intereses-container input[type="checkbox"]:checked+label {
    background-color: #0073aa;
    color: white;
    border-color: #005c85;
}

/* Intereses deshabilitados con archivos */
.interes-disabled-with-files.interes-alarmas { background-color: #FFB400!important; border: none; }
.interes-disabled-with-files.interes-energia { background-color: #FF6B6B!important; border: none; }
.interes-disabled-with-files.interes-telecomunicaciones { background-color: #00B8D9!important; border: none; }
.interes-disabled-with-files.interes-seguros { background-color: #6DD400!important; border: none; }
.interes-disabled-with-files.interes-renovables { background-color: #38B24A!important; border: none; }

.intereses-container label.interes-disabled-with-files.interes-energia {
    background-color: #FF6B6B;
    color: #fff;
    cursor: not-allowed;
}
.intereses-container label.interes-disabled-with-files.interes-alarmas {
    background-color: #FFB400;
    color: #fff;
    cursor: not-allowed;
}
.intereses-container label.interes-disabled-with-files.interes-telecomunicaciones {
    background-color: #00B8D9;
    color: #fff;
    cursor: not-allowed;
}
.intereses-container label.interes-disabled-with-files.interes-seguros {
    background-color: #6DD400;
    color: #fff;
    cursor: not-allowed;
}
.intereses-container label.interes-disabled-with-files.interes-renovables {
    background-color: #38B24A;
    color: #fff;
    cursor: not-allowed;
}

.intereses-container input[name="intereses[]"]:disabled + label {
    opacity: 0.8;
}

/* === TARJETAS DE SECTORES === */

.crm-cards-sectores {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px,1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.crm-cards-sectores .sector-card {
    display: none;
}

.crm-card {
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    background: #fff;
}

.crm-card .card-header {
    padding: .75rem 1rem;
    border-bottom: 1px solid #eee;
    background: #f7f7f7;
    position: relative;
}

.crm-card .card-header h4 {
    margin: 0; 
    font-size: 1rem;
}

.crm-card .card-body {
    padding: 1rem;
}

/* Bordes por sector */
.crm-card.sector-energia { border: 2px solid #FF6B6B; }
.crm-card.sector-alarmas { border: 2px solid #FFB400; }
.crm-card.sector-telecomunicaciones { border: 2px solid #00B8D9; }
.crm-card.sector-seguros { border: 2px solid #6DD400; }
.crm-card.sector-renovables { border: 2px solid #38B24A; }

/* Sectores con diseño profesional */
.sectores-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 24px;
    margin-top: 24px;
}

.sector-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 24px;
    border: 2px solid rgba(15, 23, 42, 0.1);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.sector-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #06d6a0);
}

.sector-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.1);
    border-color: #3b82f6;
}

/* === DOCUMENTACIÓN Y ARCHIVOS === */

/* Contenedor de facturas */
.facturas-container {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-around;
    gap: 20px;
}

/* Sector individual */
.factura-sector {
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 10px;
    background-color: #f9f9f9;
}

.factura-sector h4 {
    text-align: center;
    margin-bottom: 10px;
    font-size: 16px;
    color: #333;
}

/* Grupo de archivos */
.factura-file-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.factura-label {
    flex: 1;
    font-size: 14px;
    color: #555;
}

.factura-input {
    display: inline-block;
    width: auto;
    margin-left: 10px;
}

.remove-factura {
    padding: 5px 10px;
    background-color: #ff4d4d;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    margin-left: 10px;
    transition: background-color 0.3s ease;
}

.remove-factura:hover {
    background-color: #d93636;
}

/* Botón de añadir factura */
.add-factura {
    margin-top: 10px;
    padding: 8px 12px;
    background-color: #0073aa;
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 5px;
    text-align: center;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

.add-factura:hover {
    background-color: #005c85;
}

/* Upload sections */
.upload-section {
    margin-bottom: .75rem;
}

.upload-section strong {
    display: block;
    margin-bottom: .25rem;
}

.upload-input {
    display: block;
    margin-bottom: .25rem;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: clip;
    white-space: nowrap;
}

.upload-btn {
    padding: .3rem .6rem;
    font-size: .875rem;
    cursor: pointer;
}

.uploaded-file {
    display: flex;
    align-items: center;
    margin-bottom: .25rem;
}

.uploaded-file a {
    margin-right: .5rem;
    font-size: .875rem;
}

.remove-file-btn {
    background: transparent;
    border: none;
    color: #c00;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

button.remove-file {
    padding: 2px;
    font-size: 11px;
    width: 16px;
    height: 16px;
    line-height: 0em;
    border-radius: 50%;
    background: #F44336;
}

/* === ICONOS Y COLORES POR SECTOR === */

.factura-energia { color: #FF6B6B; }
.factura-alarmas { color: #FFB400; }
.factura-telecomunicaciones { color: #00B8D9; }
.factura-seguros { color: #6DD400; }
.factura-renovables { color: #38B24A; }

.presupuesto-energia { color: #FF6B6B; }
.presupuesto-alarmas { color: #FFB400; }
.presupuesto-telecomunicaciones { color: #00B8D9; }
.presupuesto-seguros { color: #6DD400; }
.presupuesto-renovables { color: #38B24A; }

.factura-icon {
    font-size: 18px;
    margin-right: 4px;
}

.contrato-firmado-icon {
    font-size: 16px;
    margin-right: 5px;
}

.contrato-icon { 
    color: #007bff; 
    opacity: .85; 
    transition: opacity .15s;
}

.contrato-icon:hover { 
    opacity: 1; 
}

/* === TABLAS MATERIAL DESIGN PARA IPAD === */

.crm-table-container {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 32px;
    margin: 24px auto;
    max-width: 1400px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.3);
    overflow: hidden;
    position: relative;
}

.crm-table-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #06b6d4);
    border-radius: 24px 24px 0 0;
}

.crm-table-header {
    margin-bottom: 16px; /* Reducido de 28px */
    text-align: center;
    border-bottom: 2px solid rgba(15, 23, 42, 0.08);
    padding-bottom: 12px; /* Reducido de 24px */
}

.crm-table-header h3 {
    margin: 0 0 6px 0; /* Reducido de 12px */
    color: rgb(15, 23, 42);
    font-size: 20px; /* Reducido de 26px */
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px; /* Reducido de 12px */
    line-height: 1.2;
}

.crm-logo-small {
    width: 22px; /* Reducido de 28px */
    height: 22px; /* Reducido de 28px */
    border-radius: 6px;
    vertical-align: middle;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.table-subtitle {
    color: rgb(100, 116, 139);
    font-size: 14px; /* Reducido de 16px */
    margin: 0;
    font-weight: 400;
}

.table-responsive {
    overflow-x: auto;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    background: white;
}

.crm-table-material {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    border-radius: 16px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.05);
}

.crm-table-material thead {
    background: linear-gradient(135deg, rgb(15, 23, 42) 0%, rgb(30, 41, 59) 50%, rgb(15, 23, 42) 100%);
    position: relative;
}

.crm-table-material thead::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
}

.crm-table-material th {
    padding: 18px 20px;
    text-align: left;
    font-weight: 600;
    color: white;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border: none;
    position: relative;
    white-space: nowrap;
}

.crm-table-material th:first-child {
    border-top-left-radius: 16px;
}

.crm-table-material th:last-child {
    border-top-right-radius: 16px;
}

.crm-table-material td {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.03);
    color: rgb(15, 23, 42);
    font-size: 14px;
    vertical-align: middle;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    line-height: 1.5;
}

.crm-table-material tbody tr {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.crm-table-material tbody tr:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.03), rgba(139, 92, 246, 0.02));
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.08);
}

.crm-table-material tbody tr:last-child td:first-child {
    border-bottom-left-radius: 16px;
}

.crm-table-material tbody tr:last-child td:last-child {
    border-bottom-right-radius: 16px;
}

.crm-table-material tbody tr:last-child td {
    border-bottom: none;
}

/* Columnas específicas optimizadas */
.th-id { width: 70px; text-align: center; }
.th-fecha { width: 110px; }
.th-cliente { width: 200px; }
.th-empresa { width: 180px; }
.th-contacto { width: 160px; }
.th-intereses { width: 140px; }
.th-estado { width: 180px; }
.th-updated { width: 120px; }
.th-acciones { width: 140px; text-align: center; }

/* Badges de estado con glassmorphism */
.estado-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 25px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: white;
    white-space: nowrap;
    margin: 2px 4px 2px 0;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.estado-badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.6s;
}

.estado-badge:hover::before {
    left: 100%;
}

.estado-badge.borrador {
    background: linear-gradient(135deg, #6c757d, #495057);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

.estado-badge.enviado {
    background: linear-gradient(135deg, #007bff, #0056b3);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.estado-badge.presupuesto_aceptado {
    background: linear-gradient(135deg, #28a745, #1e7e34);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.estado-badge.contratos_generados {
    background: linear-gradient(135deg, #ffc107, #e0a800);
    color: #000;
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.3);
}

.estado-badge.contratos_firmados {
    background: linear-gradient(135deg, #dc3545, #c82333);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

/* Botones de acción con efectos premium */
.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 12px;
    border-radius: 10px;
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 2px;
    min-width: 40px;
    height: 40px;
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.action-btn:hover::before {
    left: 100%;
}

.action-btn.edit {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.action-btn.edit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4);
}

.action-btn.delete {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.action-btn.delete:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.4);
}

/* Responsive para iPad */
@media (max-width: 1024px) {
    .crm-table-container {
        padding: 20px;
        margin: 16px;
        border-radius: 20px;
    }
    
    .table-responsive {
        border-radius: 12px;
    }
    
    .crm-table-material {
        border-radius: 12px;
    }
    
    .crm-table-material th,
    .crm-table-material td {
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .th-cliente, .th-empresa { 
        width: 140px; 
    }
    
    .th-contacto, .th-intereses { 
        width: 110px; 
    }
}

@media (max-width: 768px) {
    .crm-table-container {
        margin: 8px;
        padding: 16px;
        border-radius: 16px;
    }
    
    .crm-table-material th,
    .crm-table-material td {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .crm-table-header h3 {
        font-size: 20px;
    }
    
    .table-subtitle {
        font-size: 14px;
    }
}

/* DataTables personalizado para Material Design */
.dataTables_wrapper {
    margin-top: 20px;
}

.dataTables_info, 
.dataTables_paginate a {
    color: rgb(15, 23, 42) !important;
    font-weight: 500;
}

.dataTables_paginate a {
    padding: 8px 12px !important;
    border-radius: 8px !important;
    margin: 0 4px !important;
    background: rgba(59, 130, 246, 0.1) !important;
    border: none !important;
    transition: all 0.2s ease !important;
}

.dataTables_paginate a:hover {
    background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
    color: white !important;
    transform: translateY(-1px);
}

.dataTables_paginate .current {
    background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
    color: white !important;
}

/* Enlaces de email en la tabla */
.email-link {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.email-link:hover {
    color: #2563eb;
    text-decoration: underline;
}

/* Botones de acción agrupados */
.action-buttons {
    display: flex;
    gap: 4px;
    justify-content: center;
    align-items: center;
}

/* Texto en cursiva para campos vacíos */
em {
    color: rgb(100, 116, 139);
    font-style: italic;
    font-size: 13px;
}

/* Mejoras para badges de estado */
.estado-badge {
    margin-bottom: 4px;
    display: inline-block;
}

/* Centrado de contenido */
.text-center {
    text-align: center !important;
}

/* Estados heredados de la tabla antigua */
.crm-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    margin-top: 20px;
}

.crm-table th,
.crm-table td {
    border: 1px solid #ddd;
    padding: 4px 6px;
    text-align: left;
    font-size: 12px;
    word-wrap: break-word;
}

.crm-table th {
    background-color: #f4f4f4;
    font-weight: bold;
    color: #333;
}

.crm-table tr:hover {
    background-color: #f1f1f1;
}

/* Columnas específicas */
#crm-todas-las-altas.crm-table td:nth-child(5) {
    min-width: 200px;
}

.crm-table td:last-child {
    white-space: nowrap;
    display: table-cell;
}

/* === E-MAIL COMPACTO === */

.td-email { 
    max-width: 110px; 
    min-width: 110px; 
    padding-right: 4px; 
    width: 130px; 
    text-align: center; 
}

.email-preview {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    text-overflow: ellipsis;
    cursor: pointer;
    font-size: 12px;
}

.email-preview::-webkit-scrollbar { 
    height: 3px; 
}

.show-email-btn {
    font-size: 12px;
    line-height: 12px;
    padding: 0 4px;
    background: #25C685;
    color: #fff;
    border: none;
    border-radius: 2px;
    cursor: pointer;
    margin-left: 2px;
}

@media (hover:hover) {
    .show-email-btn:hover { 
        background: #1cab6f; 
    }
}

.td-email span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === BADGES Y CHIPS === */

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    color: white;
    border-radius: 9px;
    padding: 2px 4px;
    margin: 1px 0;
    width: fit-content;
}

.badge-energia { background-color: #4caf50; color: white; }
.badge-alarmas { background-color: #f44336; color: white; }
.badge-telecomunicaciones { background-color: #2196f3; color: white; }
.badge-seguros { background-color: #ff9800; color: white; }
.badge-renovables { background-color: #ef8edd; }
.badge-default { background-color: #9e9e9e; color: white; }

.badge-contrato-generado {
    background-color: #0073aa;
    color: #fff;
    padding: 3px 5px;
    border-radius: 3px;
    font-size: 12px;
    margin-right: 5px;
}

/* Toggle chips */
.toggle-chip {
    display: inline-block;
    margin: 4px 6px;
    cursor: pointer;
    border: 1px solid #ccc;
    border-radius: 16px;
    padding: 6px 14px;
    font-size: 14px;
    user-select: none;
    transition: all .2s;
}

.toggle-chip:hover {
    box-shadow: 0 0 0 2px rgba(0,0,0,.06);
}

.toggle-chip.checked {
    background: #007bff;
    color: #fff;
    border-color: #007bff;
}

.toggle-chip.sector-energia.checked { background: #FF6B6B; border-color: #FF6B6B; }
.toggle-chip.sector-alarmas.checked { background: #FFB400; border-color: #FFB400; }
.toggle-chip.sector-telecomunicaciones.checked { background: #00B8D9; border-color: #00B8D9; }
.toggle-chip.sector-seguros.checked { background: #6DD400; border-color: #6DD400; }
.toggle-chip.sector-renovables.checked { background: #38B24A; border-color: #38B24A; }

.toggle-chip input { 
    cursor: pointer; 
}

.toggle-chip input:focus + span,
.toggle-chip:focus-within { 
    outline: 2px solid #000; 
    outline-offset: 2px;
}

/* Doc chips */
.doc-chip {
    color: #fff; 
    padding: 2px 6px; 
    border-radius: 9px;
    font-size: 11px; 
    line-height: 1;
    display: inline-block; 
    cursor: pointer;
}

.doc-chip sup { 
    font-size: 9px; 
    top: -0.3em; 
}

.doc-chip:hover { 
    opacity: .85; 
}

.docs-mini { 
    border-collapse: collapse; 
    width: 100%; 
}

.docs-mini th,
.docs-mini td {
    text-align: center; 
    font-size: 11px; 
    padding: 2px;
    border: 1px solid #eee;
}

.docs-mini thead th { 
    background: #fafafa; 
    font-weight: 600; 
}

/* === NOTIFICACIONES === */

.crm-notification.success {
    background-color: #d4edda;
    color: #155724;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
}

.crm-notification.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 10px;
    margin-top: 15px;
    border-radius: 5px;
    display: block;
}

/* Toast notifications mejorados */
.crm-toast {
    animation: slideInRight 0.3s ease-out, fadeOut 0.5s ease-in 2.5s forwards;
    transform: translateX(0);
    opacity: 1;
    transition: all 0.3s ease;
}

.crm-toast:hover {
    transform: translateX(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.3) !important;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.crm-toast.success {
    background: linear-gradient(135deg, #28a745, #20c997) !important;
}

.crm-toast.error {
    background: linear-gradient(135deg, #dc3545, #e74c3c) !important;
}

.crm-toast.info {
    background: linear-gradient(135deg, #17a2b8, #3498db) !important;
}

/* === BOTONES ADICIONALES === */

a.atras {
    text-decoration: none !important;
    color: gray;
    font-size: 13px;
}

.agregar-documento-btn {
    font-size: 12px;
    padding: 9px 14px;
    background: #FF5722;
}

button.btn.btn-delete {
    background: none;
    float: right;
}

.btn-edit {
    color: #A5D6A7;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 4px;
}

.btn-edit:hover {
    background-color: #1e88e5;
}

.crm-global-actions {
    text-align: right;
    margin-top: 1.5rem;
}

.crm-btn {
    padding: .6rem 1.2rem;
    margin-left: .5rem;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

button.aceptar-presupuesto {
    background: #25C685;
    color: #fff;
    font-size: 12px;
    margin: 4px 0;
}

.enviar-sector-btn.disabled {
    opacity: .45;
    pointer-events: none;
}

/* === SPINNER Y LOADING === */

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: #09f;
    animation: spin 1s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading {
    opacity: 0.7;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 2px solid #3b82f6;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

/* === UTILIDADES === */

.no-data {
    color: #ccc;
}

.accion {
    display: flex;
    flex-direction: row;
    align-content: center;
    align-items: center;
    flex-wrap: nowrap;
    justify-content: space-between;
}

.estado-fecha {
    font-size: 0.85em;
    color: #666;
}

.info-sector {
    background: #f5f5f5;
    border-left: 4px solid #25C685;
    padding: 6px 8px;
    font-size: 12px;
    margin: 6px 0;
}

/* === RESPONSIVE DESIGN === */

/* Responsive para iPad específicamente */
@media (min-width: 768px) and (max-width: 1024px) {
    .crm-form-content {
        padding: 40px;
    }
    
    .form-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .btn-group {
        position: fixed;
        bottom: 32px;
        left: 32px;
        right: 32px;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        padding: 20px;
        border-radius: 20px;
        box-shadow: 0 16px 32px rgba(0, 0, 0, 0.15);
        margin-top: 100px;
    }
}

/* Responsive para pantallas pequeñas */
@media (max-width: 768px) {
    .datos-container {
        grid-template-columns: 1fr;
    }
    
    .form-select, .form-input-autocomplete, input[type="tel"] {
        font-size: 16px; /* Evita zoom en iOS */
    }

    .crm-table td,
    .crm-table th {
        font-size: 12px;
        padding: 5px;
    }
}

/* === DATATABLES === */

.dataTables_info, .dataTables_paginate a {
    font-size: 12px;
}

.crm-section h3 {
    font-size: 1.1em;
}

.crm-section.inicio {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
}

.crm-section.inicio .estado p {
    line-height: 1em;
    padding: 0px;
    margin: 0px;
}

.crm-section.inicio .estado p small {
    font-style: italic;
    font-size: 0.8em;
}

.widget h3 {
    color: #000000;
    font-size: 16px !important;
    font-weight: bolder;
    text-transform: uppercase;
    border-bottom: 1px solid #ccc;
    /* background: var(--ast-global-color-6); */
    text-align: center;
}

.widget canvas#clientesPorInteresChart {
    max-width: 400px;
    /* Ancho máximo */
    max-height: 400px;
    /* Alto máximo */
    margin: 0 auto;
    /* Centrar */
    display: block;
    /* Evitar comportamiento inline */
}

/* Contenedor principal de datos */
.datos-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

/* Campos de ancho completo */
.full-width {
    grid-column: span 2;
}

/* Ajuste de los campos individuales */
.form-group {
    display: flex;
    flex-direction: column;
}

.form-group input,
.form-group select {
    padding: 10px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 5px;
    outline: none;
    transition: border-color 0.3s;
    width: 100%;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #0073aa;
}

/* Espaciado entre elementos */
.form-group:not(:last-child) {
    margin-bottom: 10px;
}

/* Responsividad para pantallas pequeñas */
@media (max-width: 768px) {
    .datos-container {
        grid-template-columns: 1fr;
        /* Una columna en pantallas pequeñas */
    }
}
.crm-cards-sectores .sector-card {
  display: none;
}


/* Intereses */
.intereses-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.intereses-container label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: #f9f9f9;
    color: #333;
    font-size: 14px;
}

.intereses-container input[type="checkbox"] {
    display: none;
    /* Oculta el checkbox visualmente */
}

.intereses-container input[type="checkbox"]:checked+label {
    background-color: #0073aa;
    /* Fondo azul */
    color: white;
    /* Texto blanco */
    border-color: #005c85;
    /* Borde más oscuro */
}


/* Documentación */
/* Contenedor de facturas */
.facturas-container {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-around;
    gap: 20px;
}

/* Sector individual */
.factura-sector {
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 10px;
    background-color: #f9f9f9;
}

.factura-sector h4 {
    text-align: center;
    margin-bottom: 10px;
    font-size: 16px;
    color: #333;
}

/* Grupo de archivos */
.factura-file-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.factura-label {
    flex: 1;
    font-size: 14px;
    color: #555;
}

.factura-input {
    display: inline-block;
    width: auto;
    margin-left: 10px;
}

.remove-factura {
    padding: 5px 10px;
    background-color: #ff4d4d;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    margin-left: 10px;
    transition: background-color 0.3s ease;
}

.remove-factura:hover {
    background-color: #d93636;
}

/* Botón de añadir factura */
.add-factura {
    margin-top: 10px;
    padding: 8px 12px;
    background-color: #0073aa;
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 5px;
    text-align: center;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

.add-factura:hover {
    background-color: #005c85;
}


.crm-section.enviar {
    margin: 50px auto;
    text-align: center;
}

.crm-section.enviar button {
    width: 40%;
    margin: 0 auto;
}

.crm-notification.success {
    background-color: #d4edda;
    color: #155724;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
}

.crm-notification.error {
    background-color: #f8d7da;
    color: #721c24;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
}

/* Ejemplo de estilos para el spinner */
.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: #09f;
    animation: spin 1s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Estilos para campos inválidos */
.invalid {
    border-color: red;
}

/* Estilos para mensajes de error */
.error-message {
    color: red;
    font-size: 0.9em;
    margin-top: 4px;
    display: block;
}


.crm-notification.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 10px;
    margin-top: 15px;
    border-radius: 5px;
    display: block;
}

.crm-table {
    width: 100%;
    border-collapse: collapse;
}

.crm-table th,
.crm-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.crm-table th {
    background-color: #f4f4f4;
    font-weight: bold;
}

button.crm-submit-btn.enviar-btn {
    background: #FF5722;
}
.crm-badge { font-weight:600; letter-spacing:0.2px; display:inline-block; }
/* Estados */
.estado {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 5px;

    font-weight: bold;
    text-align: center;
}

.estado {
    display: inline-block;
    font-size: 12px;
    font-weight: bold;
    line-height: 1.5;
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    transition: background-color 0.3s, transform 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.estado:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Colores según el estado */

/* Colores según el estado */

.estado.badge-borrador,
strong.estado.borrador,
.widget .estado.borrador,
.estado.borrador {
    background-color: #6c757d;
    /* Gris */
}

.estado.badge-enviado,
strong.estado.enviado,
.widget .estado.enviado,
.estado.enviado {
    background-color: #007bff;
    /* Azul */
}

.estado.badge-pendiente_revision,
strong.estado.pendiente_revision,
.widget .estado.pendiente_revision,
.estado.pendiente_revision {
    background-color: #fd7e14;
    /* Naranja */
}

.estado.badge-presupuesto_aceptado,
strong.estado.presupuesto_aceptado,
.widget .estado.presupuesto_aceptado,
.estado.presupuesto_aceptado {
    background-color: #28a745;
    /* Verde */
}

.estado.badge-presupuesto_enviado,
strong.estado.presupuesto_enviado,
.widget .estado.presupuesto_enviado,
.estado.presupuesto_enviado {
    background-color: #000000;
    /* Negro */
}

.estado.badge-contratos_enviados,
strong.estado.contratos_enviados,
.widget .estado.contratos_enviados,
.estado.contratos_enviados {
    background-color: #17a2b8;
    /* Cian */
}

.estado.badge-contratos_firmados,
strong.estado.contratos_firmados,
.widget .estado.contratos_firmados,
.estado.contratos_firmados {
    background-color: #7048E8;
    /* Morado violeta */
}

.estado.badge-contratos_generados,
strong.estado.contratos_generados,
.widget .estado.contratos_generados,
.estado.contratos_generados {
    background-color: #007bff;
    /* Azul */
}

.estado.badge-presupuesto_generado,
strong.estado.presupuesto_generado,
.widget .estado.presupuesto_generado,
.estado.presupuesto_generado {
    background-color: #000000; /* Negro */
    color: #fff;
}

/* Añadimos estilos adicionales para accesibilidad */
.estado.badge-borrador:focus,
.estado.badge-enviado:focus,
.estado.badge-pendiente_revision:focus,
.estado.badge-aceptado:focus,
.estado.badge-presupuesto_enviado:focus,
.estado.badge-presupuesto_generado:focus,
.estado.badge-contratos_generados:focus,
.estado.badge-contratos_enviados:focus,
.estado.badge-contratos_firmados:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Animación para un toque moderno */
.estado {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.rendimiento-comercial a{color: var(--ast-global-color-2);
    font-weight: bold;}
/* Tabla */
.crm-dashboard {
    padding: 16px;
    font-family: 'Roboto', sans-serif;
    color: #333;
}

.crm-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.crm-table th,
.crm-table td {
    text-align: left;
    padding: 12px 8px;
    border-bottom: 1px solid #ddd;
}

.crm-table th {
    background-color: #f4f4f4;
    color: #333;
}

.crm-table tr:hover {
    background-color: #f1f1f1;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    color: white;
}

.badge-energia {
    background-color: #4caf50;
}

.badge-alarmas {
    background-color: #f44336;
}

.badge-telecomunicaciones {
    background-color: #2196f3;
}

.badge-seguros {
    background-color: #ff9800;
}
.badge-renovables {
    background-color: #ef8edd;
}

.badge-default {
    background-color: #9e9e9e;
}

.badge-contrato-generado {
    background-color: #0073aa;
    color: #fff;
    padding: 3px 5px;
    border-radius: 3px;
    font-size: 12px;
    margin-right: 5px;
}

.contrato-firmado-icon {
    font-size: 16px;
    margin-right: 5px;
}

.factura-icon {
    font-size: 18px;
    margin-right: 4px;
}

.factura-energia {
    color: #4caf50;
}

.factura-alarmas {
    color: #f44336;
}

.factura-telecomunicaciones {
    color: #2196f3;
}

.factura-seguros {
    color: #ff9800;
}

.no-data {
    color: #ccc;
}

.btn-edit {
    color: #A5D6A7;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 4px;
}

.btn-edit:hover {
    background-color: #1e88e5;
}
.dataTables_info, .dataTables_paginate a{font-size:12px}

@media (max-width: 768px) {

    .crm-table td,
    .crm-table th {
        font-size: 12px;
        padding: 5px;
    }
}

/* Botones */
a.atras {
    text-decoration: none !important;
    color: gray;
    font-size: 13px;
}

.agregar-documento-btn {
    font-size: 12px;
    padding: 9px 14px;
    background: #FF5722;
}

button.remove-file {
    padding: 2px;
    font-size: 11px;
    width: 16px;
    height: 16px;
    line-height: 0em;
    border-radius: 50%;
    background: #F44336;
}

button.btn.btn-delete {
    background: none;
}

.accion {
    display: flex;
    flex-direction: row;
    align-content: center;
    align-items: center;
    flex-wrap: nowrap;
    justify-content: space-between;
}

.badge {
    border-radius: 9px;
    padding: 2px 4px;
    font-size: 12px;
    margin: 1px 0;
    display: flex;
    width: fit-content;
    align-content: space-around;
    justify-content: space-between;
    flex-direction: column;
    column-gap: 5px;
}

.badge-energia {
    background-color: #4caf50;
    /* Verde */
    color: white;
}

.badge-alarmas {
    background-color: #f44336;
    /* Rojo */
    color: white;
}

.badge-telecomunicaciones {
    background-color: #2196f3;
    /* Azul */
    color: white;
}

.badge-seguros {
    background-color: #ff9800;
    /* Naranja */
    color: white;
}

.badge-default {
    background-color: #9e9e9e;
    /* Gris */
    color: white;
}

.estado-fecha {
    font-size: 0.85em;
    color: #666;
}

/*widgets*/
.recientes .info {
    line-height: 1em;
}

.infodos .estado-fecha {
    color: white;
}

li.recientes {
    display: flex;
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    margin: 4px 0px;
    border-bottom: 1px solid var(--ast-global-color-6);

}

.infodos {
    padding: 5px 0px;
}

.widget .estado {
    font-size: 12px;
}
.enviar-sector-btn.disabled{
    opacity: .45;
    pointer-events:none;
}


/* ----------  NUEVA PALETA 2025  ---------- */

/* --- ESTADOS --- */
.crm-badge.estado-borrador            { background:#B0B7C3; }
.crm-badge.estado-enviado             { background:#2AA8F2; }
.crm-badge.estado-presupuesto-generado{ background:#F5A623; }
.crm-badge.estado-presupuesto_aceptado{ background:#25C685; }
.crm-badge.estado-contratos-firmados  { background:#7048E8; }

/* --- SECTORES (intereses) --- */
.crm-badge.sector-energia             { background:#FF6B6B; }
.crm-badge.sector-alarmas             { background:#FFB400; }
.crm-badge.sector-telecomunicaciones  { background:#00B8D9; }
.crm-badge.sector-seguros             { background:#6DD400; }
.crm-badge.sector-renovables          { background:#38B24A; }
.crm-badge.reenvio { background:#FF7E29; color:#fff; }
/* Badge base (si no lo tenías ya) */
.crm-badge{
    color:#fff;
    padding:2px 10px;
    border-radius:12px;
    font-size:11px;
    display:inline-block;
    margin:2px 6px 2px 0;
    font-weight:600;
    line-height: 1.2em;;

}
/* — Bordes de los cards por sector — */
.crm-card.sector-energia            { border: 2px solid #FF6B6B; }
.crm-card.sector-alarmas            { border: 2px solid #FFB400; }
.crm-card.sector-telecomunicaciones { border: 2px solid #00B8D9; }
.crm-card.sector-seguros            { border: 2px solid #6DD400; }
.crm-card.sector-renovables         { border: 2px solid #38B24A; }
.interes-disabled-with-files.interes-alarmas {background-color: #FFB400!important;border: none;}
.interes-disabled-with-files.interes-energia {background-color: #FF6B6B!important;border: none;}
.interes-disabled-with-files.interes-telecomunicaciones {background-color: #00B8D9!important;border: none;}
.interes-disabled-with-files.interes-seguros {background-color: #6DD400!important;border: none;}
.interes-disabled-with-files.interes-renovables {background-color: #38B24A!important;border: none;}
/* — Checkbox labels deshabilitados con archivos — */
.intereses-container label.interes-disabled-with-files.interes-energia {
  background-color: #FF6B6B;
  color: #fff;
  cursor: not-allowed;
}
.intereses-container label.interes-disabled-with-files.interes-alarmas {
  background-color: #FFB400;
  color: #fff;
  cursor: not-allowed;
}
.intereses-container label.interes-disabled-with-files.interes-telecomunicaciones {
  background-color: #00B8D9;
  color: #fff;
  cursor: not-allowed;
}
.intereses-container label.interes-disabled-with-files.interes-seguros {
  background-color: #6DD400;
  color: #fff;
  cursor: not-allowed;
}
.intereses-container label.interes-disabled-with-files.interes-renovables {
  background-color: #38B24A;
  color: #fff;
  cursor: not-allowed;
}

/* Opcional: bajamos la opacidad del input disabled (si quieres ocultarlo visualmente) */
.intereses-container input[name="intereses[]"]:disabled + label {
  opacity: 0.8;
}


.factura-energia             { color:#FF6B6B; }
.factura-alarmas            { color:#FFB400; }
.factura-telecomunicaciones { color:#00B8D9; }
.factura-seguros            { color:#6DD400; }
.factura-renovables         { color:#38B24A; }
/* ejemplo */
.presupuesto-energia       { color:#FF6B6B; }
.presupuesto-alarmas       { color:#FFB400; }
.presupuesto-telecomunicaciones { color:#00B8D9; }
.presupuesto-seguros       { color:#6DD400; }
.presupuesto-renovables    { color:#38B24A; }


.crm-table{
    table-layout: fixed;     /* cada columna hereda el ancho de la cabecera */
    width: 100%;
}

.crm-table th,
.crm-table td{
    padding: 4px 6px;        /* más estrecho */
    font-size: 12px;
    word-wrap: break-word;   /* que corte palabras largas */
}

/* Columnas específicas */
#crm-todas-las-altas.crm-table td:nth-child(5) {
    min-width: 200px;
}

/* la celda de acciones con los iconos */
.crm-table td:last-child {
    white-space: nowrap;
    display: table-cell; /* para que no se expanda */
}

.btn.btn-delete{float: right;}
/* ----- E-mail plegado ----- */
.td-email{ width:130px; text-align:center; }

.show-email-btn{
    font-size:12px;
    line-height:12px;
    padding:0 4px;
    background:#25C685;   /* verde suave */
    color:#fff;
    border:none;
    border-radius:2px;
    cursor:pointer;
}

@media (hover:hover){
  .show-email-btn:hover{ background:#1cab6f; }
}

/* Cuando el + ya se ha expandido: el span hereda estilos de la celda */
.td-email span{
    display:block;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}
/* --- e-mails compactos --- */
.td-email          { max-width:110px; min-width:110px; padding-right:4px; }
.email-preview     {
  display:block;
  overflow-x:auto;               /* permite swipe horizontal */
  white-space:nowrap;
  text-overflow:ellipsis;
  cursor:pointer;
  font-size:12px;                /* más compacto */
}
.email-preview::-webkit-scrollbar { height:3px; }      /* scrollbar fino */
.show-email-btn {
  border:none;background:none;color:#0073aa;
  font-size:12px; line-height:1; margin-left:2px; cursor:pointer;
}
.estado-contratos_generados,
.crm-badge.estado-contratos_generados{
   background:#007bff;
}
button.aceptar-presupuesto{background:#25C685;color:#fff;font-size:12px;margin:4px 0;}
.info-sector{background:#f5f5f5;border-left:4px solid #25C685;padding:6px 8px;font-size:12px;margin:6px 0;}

.toggle-chip{
  display:inline-block;margin:4px 6px;cursor:pointer;
  border:1px solid #ccc;border-radius:16px;padding:6px 14px;
  font-size:14px;user-select:none;transition:all .2s;
}
.toggle-chip:hover{box-shadow:0 0 0 2px rgba(0,0,0,.06);}
.toggle-chip.checked{
  background:#007bff;color:#fff;border-color:#007bff;
}

/* ----------  Chips por sector ---------- */
.toggle-chip.sector-energia.checked             { background:#FF6B6B; border-color:#FF6B6B; }
.toggle-chip.sector-alarmas.checked             { background:#FFB400; border-color:#FFB400; }
.toggle-chip.sector-telecomunicaciones.checked  { background:#00B8D9; border-color:#00B8D9; }
.toggle-chip.sector-seguros.checked             { background:#6DD400; border-color:#6DD400; }
.toggle-chip.sector-renovables.checked          { background:#38B24A; border-color:#38B24A; }


.crm-badge.estado-contratos_firmados{ background:#7048E8; }          /* unifica violeta */
.contrato-icon{ color:#007bff; opacity:.85; transition:opacity .15s;}
.contrato-icon:hover{ opacity:1; }
.toggle-chip input{ cursor:pointer; }
.toggle-chip input:focus + span,
.toggle-chip:focus-within{ outline:2px solid #000; outline-offset:2px;}

.docs-mini{ border-collapse:collapse; width:100%; }
.docs-mini th,
.docs-mini td{
  text-align:center; font-size:11px; padding:2px;
  border:1px solid #eee;
}
.docs-mini thead th{ background:#fafafa; font-weight:600; }

.doc-chip{
  color:#fff; padding:2px 6px; border-radius:9px;
  font-size:11px; line-height:1;
  display:inline-block; cursor:pointer;
}
.doc-chip sup{ font-size:9px; top:-0.3em; }
.doc-chip:hover{ opacity:.85; }



.crm-cards-sectores {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px,1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.crm-card {
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  background: #fff;
}

.crm-card .card-header {
  padding: .75rem 1rem;
  border-bottom: 1px solid #eee;
  background: #f7f7f7;
  position: relative;
}

.crm-card .card-header h4 {
  margin: 0; font-size: 1rem;
}

.crm-card .card-body {
  padding: 1rem;
}

.upload-section {
  margin-bottom: .75rem;
}

.upload-section strong {
  display: block;
  margin-bottom: .25rem;
}

.upload-input {
    display: block;
    margin-bottom: .25rem;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: clip;
    white-space: nowrap;
}

.upload-btn {
  padding: .3rem .6rem;
  font-size: .875rem;
  cursor: pointer;
}

.uploaded-file {
  display: flex;
  align-items: center;
  margin-bottom: .25rem;
}

.uploaded-file a {
  margin-right: .5rem;
  font-size: .875rem;
}

.remove-file-btn {
  background: transparent;
  border: none;
  color: #c00;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.crm-global-actions {
  text-align: right;
  margin-top: 1.5rem;
}

.crm-btn {
  padding: .6rem 1.2rem;
  margin-left: .5rem;
  background: #0073aa;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

/* === DASHBOARD COMPACTO ESTILO SEMRUSH === */
.crm-dashboard-compact {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    margin: 16px 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.dashboard-header-compact {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f3f4f6;
}

.dashboard-title-compact {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
    line-height: 1.4;
}

.stats-row-compact {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.stat-compact {
    background: #fafbfc;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 12px;
    text-align: center;
    transition: all 0.2s ease;
}

.stat-compact:hover {
    border-color: #d1d5db;
    background: #f9fafb;
}

.stat-label-compact {
    font-size: 11px;
    font-weight: 500;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-value-compact {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
    line-height: 1;
    margin-bottom: 2px;
}

.stat-percent-compact {
    font-size: 11px;
    font-weight: 500;
    color: #6b7280;
}

/* Estados específicos - colores sutiles */
.estado-borrador {
    border-left: 3px solid #f59e0b;
}

.estado-presupuesto_aceptado {
    border-left: 3px solid #10b981;
}

.estado-contratos_generados {
    border-left: 3px solid #3b82f6;
}

.estado-contratos_firmados {
    border-left: 3px solid #8b5cf6;
}

.dashboard-actions-compact {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding-top: 12px;
    border-top: 1px solid #f3f4f6;
}

.action-link-compact {
    color: #3b82f6;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.action-link-compact:hover {
    background: #eff6ff;
    color: #2563eb;
    text-decoration: none;
}

/* === TABLA MODERNA UNIFICADA === */
.crm-table-container {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin: 16px 0;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.crm-table-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f3f4f6;
    background: #fafbfc;
}

.crm-table-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.crm-logo-small {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.table-subtitle {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
}

.table-responsive {
    overflow-x: auto;
}

.crm-table-material {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.crm-table-material thead {
    background: #f9fafb;
}

.crm-table-material thead th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e5e7eb;
}

.crm-table-material tbody tr {
    border-bottom: 1px solid #f3f4f6;
    transition: background-color 0.15s ease;
}

.crm-table-material tbody tr:hover {
    background: #fafbfc;
}

.crm-table-material tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    color: #374151;
}

/* Columnas específicas */
.th-id, .td-id {
    width: 60px;
    text-align: center;
}

.th-fecha, .td-fecha {
    width: 100px;
}

.th-estado, .td-estado {
    width: 140px;
}

.th-docs, .td-docs {
    width: 120px;
    text-align: center;
}

.th-acciones, .td-acciones {
    width: 100px;
    text-align: center;
}

/* Responsive para móviles */
@media (max-width: 768px) {
    .stats-row-compact {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .dashboard-actions-compact {
        flex-direction: column;
    }
    
    .action-link-compact {
        text-align: center;
    }
    
    .crm-table-header {
        padding: 12px 16px;
    }
    
    .crm-table-material thead th,
    .crm-table-material tbody td {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* === DOCUMENTOS MINIMALISTAS ELEGANTES === */
.doc-badge {
    display: inline-block;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    margin: 1px;
    transition: all 0.2s ease;
    cursor: help;
    border: 1px solid;
}

.doc-badge.presup {
    background: #eff6ff;
    color: #2563eb;
    border-color: #dbeafe;
}

.doc-badge.contratos-gen {
    background: #fef3c7;
    color: #d97706;
    border-color: #fde68a;
}

.doc-badge.firmados {
    background: #d1fae5;
    color: #047857;
    border-color: #a7f3d0;
}

.doc-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.no-docs {
    color: #9ca3af;
    font-size: 12px;
    opacity: 0.7;
}

/* ============================================
   COMPACT WIDGETS - SEMRUSH STYLE
   ============================================ */

/* Widget Compact Container */
.crm-widget-compact {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.crm-widget-compact:hover {
    border-color: #d1d5db;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Widget Header */
.widget-header-compact {
    padding: 16px 20px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.widget-title-compact {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

.widget-stats-compact {
    display: flex;
    align-items: center;
    gap: 12px;
}

.total-count {
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
}

/* Widget Content */
.widget-content-compact {
    padding: 16px 20px;
}

/* Stats Row for Performance Widget */
.stats-row-compact {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.stat-item-compact {
    text-align: center;
    padding: 12px;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Chart Container */
.chart-container-compact {
    height: 200px;
    margin-bottom: 16px;
}

/* Chart Legend */
.chart-legend-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-label {
    color: #374151;
    font-weight: 500;
}

.legend-value {
    color: #6b7280;
    font-weight: 600;
}

/* Table Compact */
.table-responsive-compact {
    overflow-x: auto;
}

.crm-table-compact {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.crm-table-compact th {
    background: #f9fafb;
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.crm-table-compact td {
    padding: 8px 12px;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
}

.crm-table-compact tbody tr:hover {
    background: #f9fafb;
}

.client-name-cell {
    font-weight: 600;
    color: #1f2937;
}

.company-cell {
    color: #6b7280;
}

.date-cell {
    color: #9ca3af;
    font-size: 12px;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-borrador {
    background: #f3f4f6;
    color: #6b7280;
}

.status-presupuesto_aceptado {
    background: #dbeafe;
    color: #1e40af;
}

.status-contratos_generados {
    background: #fef3c7;
    color: #92400e;
}

.status-contratos_firmados {
    background: #d1fae5;
    color: #065f46;
}

/* Chart Summary */
.chart-summary-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #f9fafb;
    border-radius: 16px;
    font-size: 12px;
}

.summary-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.summary-label {
    color: #374151;
    font-weight: 500;
}

.summary-value {
    color: #1f2937;
    font-weight: 700;
}

/* Admin Panel Compact */
.admin-panel-compact .admin-quick-settings {
    margin: 16px 0;
}

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

.setting-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
}

.setting-toggle input[type="checkbox"] {
    margin: 0;
    accent-color: #3b82f6;
}

.toggle-label {
    color: #374151;
    font-weight: 500;
}

.admin-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-compact {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-compact:not(.btn-primary):not(.btn-danger) {
    background: #f3f4f6;
    color: #374151;
}

.btn-compact:not(.btn-primary):not(.btn-danger):hover {
    background: #e5e7eb;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.admin-tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 16px;
}

.tool-link {
    padding: 8px 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s ease;
}

.tool-link:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #1f2937;
}

/* Responsive */
@media (max-width: 768px) {
    .stats-row-compact {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .settings-row-compact {
        grid-template-columns: 1fr;
    }
    
    .admin-tools-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* === WIDGET RENDIMIENTO COMERCIAL COMPACT === */
.stats-grid-compact {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.stat-item-compact {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    transition: all 0.2s ease;
}

.stat-item-compact:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.stat-item-compact .stat-label {
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-item-compact .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 2px;
}

.stat-item-compact .stat-percent {
    font-size: 11px;
    font-weight: 500;
    color: #9ca3af;
}

/* Estados específicos */
.stat-item-compact.estado-borrador {
    border-left: 4px solid #f59e0b;
}

.stat-item-compact.estado-presupuesto_aceptado {
    border-left: 4px solid #3b82f6;
}

.stat-item-compact.estado-contratos_generados {
    border-left: 4px solid #8b5cf6;
}

.stat-item-compact.estado-contratos_firmados {
    border-left: 4px solid #10b981;
}

.widget-actions-compact {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

.action-link-compact {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    transition: all 0.2s ease;
}

.action-link-compact:hover {
    background: #e5e7eb;
    color: #1f2937;
    text-decoration: none;
}

/* Responsive para rendimiento */
@media (max-width: 768px) {
    .stats-grid-compact {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .widget-actions-compact {
        flex-direction: column;
    }
    
    .stat-item-compact .stat-value {
        font-size: 20px;
    }
}

/* === COMERCIALES ESTADISTICAS WIDGET === */
.comercial-name-cell {
    min-width: 150px;
}

.comercial-link {
    color: #374151;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.comercial-link:hover {
    color: #1f2937;
    text-decoration: underline;
}

.estado-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    min-width: 24px;
    text-align: center;
}

.estado-badge.estado-borrador {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #f59e0b;
}

.estado-badge.estado-presupuesto {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #3b82f6;
}

.estado-badge.estado-contratos-gen {
    background-color: #e0e7ff;
    color: #5b21b6;
    border: 1px solid #8b5cf6;
}

.estado-badge.estado-contratos-firm {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.total-cell {
    background-color: #f9fafb;
    font-size: 14px;
}

.text-center {
    text-align: center;
}

/* DataTable customización para estadísticas comerciales */
#crm-comerciales-estadisticas_wrapper {
    margin-top: 0;
}

#crm-comerciales-estadisticas_wrapper .dataTables_length,
#crm-comerciales-estadisticas_wrapper .dataTables_filter {
    margin-bottom: 16px;
}

#crm-comerciales-estadisticas_wrapper .dataTables_length label,
#crm-comerciales-estadisticas_wrapper .dataTables_filter label {
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
}

#crm-comerciales-estadisticas_wrapper .dataTables_filter input {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
}

#crm-comerciales-estadisticas_wrapper .dataTables_info,
#crm-comerciales-estadisticas_wrapper .dataTables_paginate {
    font-size: 13px;
    color: #6b7280;
}

/* Responsive para tabla de comerciales */
@media (max-width: 768px) {
    .estado-badge {
        padding: 2px 6px;
        font-size: 11px;
        min-width: 20px;
    }
    
    .comercial-name-cell {
        min-width: 120px;
    }
    
    .crm-table-compact th,
    .crm-table-compact td {
        padding: 8px 4px;
        font-size: 12px;
    }
}

/* === ESTILOS PARA COLUMNA FECHA CON USUARIO === */
.fecha-usuario {
    text-align: center;
    line-height: 1.3;
}

.fecha-usuario .fecha {
    font-weight: 600;
    color: #374151;
    font-size: 12px;
    margin-bottom: 2px;
}

.fecha-usuario .usuario {
    font-size: 10px;
    color: #6b7280;
    font-style: italic;
}

.fecha-usuario .usuario strong {
    color: #059669;
    font-weight: 600;
}

/* Responsive para la columna fecha */
@media (max-width: 768px) {
    .fecha-usuario .fecha {
        font-size: 11px;
    }
    
    .fecha-usuario .usuario {
        font-size: 9px;
    }
}

/* === COLUMNA ACCIONES MODERNA === */
.acciones-cell {
    text-align: center;
    padding: 8px 4px !important;
    width: 80px;
    min-width: 80px;
    max-width: 80px;
}

.acciones-group {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 14px;
    position: relative;
    overflow: hidden;
}

.action-btn:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 6px;
    transition: all 0.2s ease;
    z-index: 0;
}

.action-btn .icon-edit,
.action-btn .icon-delete {
    position: relative;
    z-index: 1;
    line-height: 1;
}

/* Botón Editar */
.edit-btn {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.edit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.4);
    background: linear-gradient(135deg, #2563eb, #1e40af);
}

.edit-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(59, 130, 246, 0.4);
}

/* Botón Eliminar */
.delete-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.delete-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.4);
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.delete-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(239, 68, 68, 0.4);
}

/* Responsive para móviles */
@media (max-width: 768px) {
    .acciones-cell {
        width: 70px;
        min-width: 70px;
        max-width: 70px;
        padding: 6px 2px !important;
    }
    
    .action-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    
    .acciones-group {
        gap: 2px;
    }
}

/* Estado de carga para botones */
.action-btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.action-btn.loading:after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   CHECKBOX PRESUPUESTO ACEPTADO
   ============================================ */

.presupuesto-aceptado-section {
    margin-top: 12px !important;
    padding: 12px !important;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%) !important;
    border: 1px solid #0284c7 !important;
    border-radius: 8px !important;
    transition: all 0.3s ease !important;
}

.presupuesto-aceptado-section:hover {
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.15);
}

.presupuesto-aceptado-section label {
    display: flex !important;
    align-items: center !important;
    font-weight: 600 !important;
    color: #0c4a6e !important;
    margin: 0 !important;
    cursor: pointer !important;
}

.presupuesto-aceptado-checkbox {
    width: 18px !important;
    height: 18px !important;
    margin-right: 10px !important;
    margin-left: 0 !important;
    accent-color: #0284c7 !important;
    cursor: pointer !important;
    transform: scale(1.1);
}

.presupuesto-aceptado-section small {
    color: #475569 !important;
    margin-left: 28px !important;
    margin-top: 4px !important;
    display: block !important;
    font-size: 13px !important;
    line-height: 1.4 !important;
}

/* Animación cuando está marcado */
.presupuesto-aceptado-checkbox:checked + span {
    color: #0c4a6e !important;
    font-weight: 700 !important;
}

/* Estado hover para el checkbox */
.presupuesto-aceptado-checkbox:hover {
    transform: scale(1.2);
    filter: brightness(1.1);
}

/* Estilo para el botón enviar cuando aparece */
.send-sector-wrapper[style*="block"] {
    animation: slideInFromTop 0.4s ease-out;
    margin-top: 15px !important;
}

@keyframes slideInFromTop {
    0% {
        opacity: 0;
        transform: translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Estado presupuesto_generado */
.estado.presupuesto_generado,
.estado-badge.presupuesto_generado {
    background: linear-gradient(135deg, #FF9500 0%, #e67e00 100%) !important;
    color: white !important;
    border-color: #FF9500 !important;
}

/* === ADMIN CONTROLS STYLING === */
.admin-controls {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 16px;
    margin-top: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.admin-controls label {
    display: flex;
    align-items: center;
    font-weight: 500;
    color: #334155;
    margin-bottom: 0;
    cursor: pointer;
    transition: color 0.2s ease;
}

.admin-controls label:hover {
    color: #1e293b;
}

.admin-controls input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 10px;
    accent-color: #0ea5e9;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.admin-controls input[type="checkbox"]:checked {
    transform: scale(1.05);
}

.admin-presupuesto-control {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 10px 12px;
    transition: all 0.2s ease;
}

.admin-presupuesto-control:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: #cbd5e1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.admin-presupuesto-control input[type="checkbox"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.admin-presupuesto-control small {
    font-size: 11px;
    font-style: italic;
    opacity: 0.8;
}

/* Admin controls en sectores específicos */
.sector-card .admin-controls {
    background: linear-gradient(135deg, rgba(248, 250, 252, 0.9) 0%, rgba(226, 232, 240, 0.9) 100%);
    border: 1px solid rgba(203, 213, 225, 0.8);
    backdrop-filter: blur(4px);
}

/* Colores específicos por sector para admin controls */
.sector-card.solar .admin-controls {
    border-left: 4px solid #f59e0b;
}

.sector-card.autoconsumo .admin-controls {
    border-left: 4px solid #10b981;
}

.sector-card.aerotermia .admin-controls {
    border-left: 4px solid #3b82f6;
}

.sector-card.cargadores .admin-controls {
    border-left: 4px solid #8b5cf6;
}

.sector-card.eficiencia .admin-controls {
    border-left: 4px solid #f97316;
}

.sector-card.gas .admin-controls {
    border-left: 4px solid #06b6d4;
}

.sector-card.seguros .admin-controls {
    border-left: 4px solid #ef4444;
}

.sector-card.placas .admin-controls {
    border-left: 4px solid #84cc16;
}

.sector-card.fibra .admin-controls {
    border-left: 4px solid #ec4899;
}

.sector-card.alarmas .admin-controls {
    border-left: 4px solid #6366f1;
}

/* Estilo para texto de ayuda en botones de envío */
.sector-send-help {
    display: block;
    margin: 4px 0 8px 0;
    padding: 0;
    color: #6b7280;
    font-size: 11px;
    line-height: 1.3;
    font-style: italic;
}

/* Botón de envío de sector mejorado */
.send-sector-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    border: none;
    border-radius: 6px;
    color: white;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(5, 150, 105, 0.2);
}

.send-sector-btn:hover {
    background: linear-gradient(135deg, #047857 0%, #065f46 100%);
    box-shadow: 0 4px 8px rgba(5, 150, 105, 0.3);
    transform: translateY(-1px);
}

.send-sector-btn svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.send-sector-btn:hover svg {
    transform: translateX(2px);
}

/* Estado ya enviado */
.send-sector-btn.already-sent {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    box-shadow: 0 2px 4px rgba(107, 114, 128, 0.2);
    opacity: 0.8;
}

.send-sector-btn.already-sent:hover {
    background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
    box-shadow: 0 4px 8px rgba(107, 114, 128, 0.3);
}

/* Indicador de sector enviado al admin en badges */
.estado-badge.sent-to-admin {
    position: relative;
}

.estado-badge.sent-to-admin::after {
    content: '';
    position: absolute;
    top: -4px;
    right: -4px;
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border: 2px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    z-index: 10;
}

.estado-badge.sent-to-admin::before {
    content: '✉';
    position: absolute;
    top: -5px;
    right: -5px;
    width: 14px;
    height: 14px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border: 2px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 7px;
    color: white;
    line-height: 1;
    z-index: 11;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

/* Variante con icono SVG más profesional */
.crm-badge.sent-indicator {
    position: relative;
}

.crm-badge.sent-indicator::after {
    content: '';
    position: absolute;
    top: -6px;
    right: -6px;
    width: 16px;
    height: 16px;
    background: #3b82f6;
    border: 2px solid white;
    border-radius: 50%;
    z-index: 10;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M3 20L21 12L3 4V10L16 12L3 14V20Z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 10px;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.4);
}
