diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index 911d15562254ed820f1ce75c2830febd6a3d7612..2f2da5bd8769ac9c283ba7e092ee5c200e35deb0 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -62,13 +62,12 @@ $origin=GETPOST('origin','alpha');
 $originid=GETPOST('originid','int');
 
 $datecontrat='';
+$usehm=(! empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:0);
 
 // Security check
 if ($user->societe_id) $socid=$user->societe_id;
 $result=restrictedArea($user,'contrat',$id);
 
-$usehm=(! empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:0);
-
 // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
 $hookmanager->initHooks(array('contractcard','globalcard'));
 
@@ -1700,7 +1699,7 @@ else
             if ($object->statut > 0)
             {
                 print '<tr '.$bcnd[$var].'>';
-                print '<td colspan="'.($conf->margin->enabled?7:6).'"><hr class="opacitymedium"></td>';
+                print '<td class="tdhrthin" colspan="'.($conf->margin->enabled?7:6).'"><hr class="opacitymedium tdhrthin"></td>';
                 print "</tr>\n";
             }
 
@@ -1862,7 +1861,7 @@ else
                 print $form->select_date($dateactend,"end",$usehm,$usehm,'',"active",1,0,1);
                 print '</td>';
 
-                print '<td align="center nohover" rowspan="2" valign="middle" class="nohover">';
+                print '<td class="center nohover" rowspan="2" valign="middle" class="nohover">';
                 print '<input type="submit" class="button" name="activate" value="'.$langs->trans("Activate").'"><br>';
                 print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
                 print '</td>';
@@ -1917,7 +1916,7 @@ else
                 }
                 print '</td>';
 
-                print '<td align="right" rowspan="2" class="nohover">';
+                print '<td rowspan="2" class="center nohover">';
                 print '<input type="submit" class="button" name="close" value="'.$langs->trans("Unactivate").'"><br>';
                 print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
                 print '</td></tr>';
diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php
index 1e442aec41a6025428f828ebd1469723b34851db..12265d551662d43beebbe3e7ae0b43f0bf71af71 100644
--- a/htdocs/contrat/class/contrat.class.php
+++ b/htdocs/contrat/class/contrat.class.php
@@ -608,7 +608,8 @@ class Contrat extends CommonObject
 		$extralabelsline=$extrafieldsline->fetch_name_optionals_label($line->table_element,true);
 
 		$this->lines=array();
-
+        $pos = 0;
+		
 		// Selectionne les lignes contrats liees a un produit
 		$sql = "SELECT p.label as product_label, p.description as product_desc, p.ref as product_ref,";
 		$sql.= " d.rowid, d.fk_contrat, d.statut, d.description, d.price_ht, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.remise_percent, d.subprice, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht,";
@@ -693,8 +694,8 @@ class Contrat extends CommonObject
 				// fetch optionals attributes and labels
 				$line->fetch_optionals($line->id,$extralabelsline);
 
-				$this->lines[$i]			= $line;
-				$this->lines_id_index_mapper[$line->id] = $i;
+				$this->lines[$pos]			= $line;
+				$this->lines_id_index_mapper[$line->id] = $pos;
 
 				//dol_syslog("1 ".$line->desc);
 				//dol_syslog("2 ".$line->product_desc);
@@ -709,6 +710,7 @@ class Contrat extends CommonObject
                 $total_ht+=$objp->total_ht;
 
 				$i++;
+				$pos++;
 			}
 			$this->db->free($result);
 		}
@@ -798,14 +800,15 @@ class Contrat extends CommonObject
 				$line->fetch_optionals($line->id,$extralabelsline);
 
 
-				$this->lines[]        = $line;
-				$this->lines_id_index_mapper[$line->id] = key($this->lines);
+				$this->lines[$pos]			= $line;
+				$this->lines_id_index_mapper[$line->id] = $pos;
 
 				$total_ttc+=$objp->total_ttc;
                 $total_vat+=$objp->total_tva;
                 $total_ht+=$objp->total_ht;
 
                 $i++;
+                $pos++;
 			}
 
 			$this->db->free($result);
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index 558d793cc506dee3352477418d0c38a7fd727b56..0a802475f01ac508c24aa8c9ce1bbced231e5899 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -1047,7 +1047,6 @@ div.photoref {
 	vertical-align:middle;
 	text-align:center;
 }
-
 img.photorefnoborder {
     padding: 2px;
 	height: 48px;
@@ -1060,7 +1059,10 @@ img.photorefnoborder {
 .underbanner {
 	border-bottom: <?php echo $borderwith ?>px solid rgb(<?php echo $colortopbordertitle1 ?>);
 }
-
+.tdhrthin {
+	margin: 0;
+	padding-bottom: 0 !important;
+}
 
 /* ============================================================================== */
 /* Menu top et 1ere ligne tableau                                                 */
diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php
index d855baeb966cbfdc151448a237255738cfb2f71b..df3e374b565fee6b419a93a1a7b74f2ef74961d2 100644
--- a/htdocs/theme/md/style.css.php
+++ b/htdocs/theme/md/style.css.php
@@ -1069,7 +1069,6 @@ div.photoref {
 	vertical-align:middle;
 	text-align:center;
 }
-
 img.photorefnoborder {
     padding: 2px;
 	height: 48px;
@@ -1077,12 +1076,15 @@ img.photorefnoborder {
     object-fit: contain;
     border: 1px solid #CCC;
 }
-
 .underrefbanner {
 }
 .underbanner {
 	border-bottom: <?php echo $borderwith; ?>px solid rgb(<?php echo $colortopbordertitle1 ?>);
 }
+.tdhrthin {
+	margin: 0;
+	padding-bottom: 0 !important;
+}
 
 
 /* ============================================================================== */