  :root { --primary: #007b5e; --bg: #f2f2f2; --border: #7DBA4E; --rad: 8px;}
  body { font-family: 'Arial', sans-serif; background: var(--bg); padding: 20px; margin:0; color: #333; }
  
  .container { max-width: 1200px; margin: 0 auto; background: #fff; padding: 25px; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); display: none; }
  #dashboardContainer { max-width: 1300px; margin: 0 auto; display: none; }
  
  .header-wrapper { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; background: white; padding: 15px 25px; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.1);}
  h1 { color: var(--primary); text-align: center; margin: 0; flex-grow: 1; font-size: 24px;}
  h2 { color: var(--primary); border-bottom: 2px solid var(--primary); padding-bottom: 5px; margin-top: 40px; word-break: break-word;}
  
  select, input[type="text"], input[type="number"], input[type="date"], input[type="password"], button, textarea { padding: 12px; font-size: 15px; border: 1px solid var(--border); border-radius: 5px; box-sizing: border-box; width: 100%; max-width: 100%;}
  input::placeholder, textarea::placeholder { color: #aaa; font-style: italic; }
  button { background: var(--primary); color: white; cursor: pointer; border: none; font-weight: bold; transition: 0.3s; width: auto;}
  button:hover { background: #529D42; transform: scale(1.02); }
  button:disabled { background: #aaa; cursor: not-allowed; }
  .btn-secondary { background: #6c757d; } .btn-secondary:hover { background: #5a6268; }
  .btn-danger { background: #d9534f; color:white; border:none; padding: 8px 15px; border-radius: 5px; cursor:pointer;} 
  .btn-danger:hover { background: #c9302c; }

  #loginScreen { position: fixed; inset: 0; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 10000; padding: 20px; box-sizing: border-box;}
  .login-box { background: white; padding: 40px; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); text-align: center; max-width: 350px; width: 100%; box-sizing: border-box;}
  #loader { display: none; position: fixed; top:0; left:0; width:100%; height:100%; background: rgba(255,255,255,0.85); z-index: 9999; flex-direction: column; justify-content: center; align-items: center; }
  .spinner { border: 8px solid #f3f3f3; border-top: 8px solid var(--primary); border-radius: 50%; width: 60px; height: 60px; animation: spin 1s linear infinite; }
  @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

  .dash-controls { display: flex; gap: 15px; margin-bottom: 20px; align-items: center; background: #fff; padding: 15px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.05);}
  .dash-controls input { flex-grow: 1; font-size: 16px;}
  .dash-table-wrapper { background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); overflow-x: auto;}
  
  .status-wrapper { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap;}
  .step-fraction { font-size: 12px; color: #555; font-weight: 800; background: #e9ecef; padding: 4px 8px; border-radius: 12px; letter-spacing: 0.5px; }
  .step-final { background: #5cb85c; color: white; box-shadow: 0 0 8px rgba(92,184,92,0.6); }
  .badge { padding: 6px 12px; border-radius: 6px; font-size: 13.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; white-space: normal; text-align: left; border: 1px solid transparent; }
  
  .bg-gray { background: #f8f9fa; color: #495057; border-color: #ddd; }
  .bg-red { background: #fff5f5; color: #dc3545; border-color: #f5c6c8; }
  .bg-blue-light { background: #f0f8ff; color: #0077c2; border-color: #b3e5fc; }
  .bg-blue { background: #e3f2fd; color: #0277bd; border-color: #90caf9; }
  .bg-green-light { background: #f1f8e9; color: #558b2f; border-color: #c5e1a5; }
  .bg-green { background: #e8f5e9; color: #2e7d32; border-color: #a5d6a7; border-left: 4px solid #4caf50; }

  .modal-overlay { position: fixed; top:0; left:0; width:100%; height:100%; background: rgba(0,0,0,0.6); z-index: 2000; display:none; align-items:center; justify-content:center; padding: 15px; box-sizing: border-box;}
  .modal-content { background: white; padding: 25px; border-radius: 8px; max-width: 500px; width: 100%; box-shadow: 0 5px 15px rgba(0,0,0,0.3); max-height: 90vh; overflow-y: auto;}
  .modal-content h3 { color: var(--primary); margin-top: 0; word-break: break-word;}
  .modal-content label { margin-top: 15px; }

  .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 15px; }
  .grid-3 { grid-template-columns: 1fr 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
  .full-width { grid-column: 1 / -1; }
  label { font-weight: bold; display: block; margin-bottom: 5px; font-size: 15px; color:#555;}
  
  .quill-container { background: #fff; margin-bottom: 10px; width: 100%; max-width: 100%; overflow-x: hidden;}
  .quill-editor-div { min-height: 150px; font-size: 15px; }
  .ql-toolbar { background-color: #f9f9f9; border-radius: 4px 4px 0 0; flex-wrap: wrap;}

  table { 
  width: 100%; 
  border-collapse: collapse; 
  margin-bottom: 10px; 
  font-size: 15px; 
  table-layout: fixed; /* Force le tableau à respecter la largeur de l'écran */
}
th, td { 
  border: 1px solid #ddd; 
  padding: 10px; 
  text-align: left; 
  vertical-align: middle;
  word-wrap: break-word; /* Coupe les mots trop longs */
  overflow-wrap: break-word; /* Pareil, sécurité pour les vieux navigateurs */
  word-break: break-word; /* Force la coupure si un mot (ou lien) est plus grand que la cellule */
}
  th { background: var(--primary); color: white; text-align: center; }
  tbody tr:nth-child(even) { background-color: #f9f9f9; }
  td input, td select, td textarea { width: 100%; padding: 8px; margin:0; border: 1px solid #ccc; resize: vertical; font-family: inherit;}
  #dashTable td { text-align: center; }
  
  .btn-action { padding: 6px 12px; margin: 2px; font-size: 14px; border-radius: 4px; border:none; width: auto;}
  .btn-move { background: #f0ad4e; color: #333; } .btn-move:hover { background: #ec971f; }
  .img-thumb { max-width: 100px; max-height: 80px; object-fit: contain; border-radius: 4px; border: 1px solid #ccc;}
  .deleted-row { opacity: 0.4; background: #ffeeba !important; }
  .deleted-row input, .deleted-row select, .deleted-row button.btn-move, .deleted-row textarea { pointer-events: none; }
  .new-img-row { background-color: #e8f5e9 !important; border-left: 4px solid #5cb85c; }

  .eval-container { display: flex; gap: 20px; align-items: flex-start; background: #fdfdfd; padding: 15px; border: 1px solid #eee; border-radius: 8px; }
  .eval-radios { flex-grow: 1; display: flex; flex-direction: column; gap: 20px; width: 100%; }
  .radio-group { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; } 
  .radio-label { position: relative; display: flex; align-items: center; justify-content: center; height: 44px; background: #fff; border: 1px solid var(--border); border-radius: var(--rad); cursor: pointer; transition: transform 0.2s; }
  .radio-label input { position: absolute; opacity: 0; width: 0; height: 0; }
  .radio-label span { font-size: 1.1em; color: #484848; pointer-events: none; }
  .radio-label:hover { transform: translateY(-2px); }
  .chart-box { width: 350px; flex-shrink: 0; position: sticky; top: 20px; }
  .criteria-box { background: #f9f9f9; padding: 10px; border-left: 4px solid var(--primary); font-size: 0.9em; margin-top: 5px; display: none; }
  
  .example-box { background: #fff3cd; border-left: 4px solid #ffc107; padding: 10px; margin-bottom: 10px; font-size: 14px; border-radius: 4px;}
  .upload-section { background: #e9ecef; padding: 15px; border-radius: 5px; margin-bottom: 15px; display: flex; gap:10px; align-items:flex-end; flex-wrap: wrap; }

  .cell-origine { vertical-align: middle !important; background: #fdfdfd; text-align: center !important; font-size: 13px; color: #555; }
 .btn-action-mini { padding: 4px; font-size: 12px; margin: 1px; cursor: pointer; border: none; border-radius: 3px; background: #e0e0e0; }
  .btn-action-mini:hover { background: #ccc; }
  .btn-action-danger-mini { background: #f2dede; color: #a94442; }
  .btn-action-danger-mini:hover { background: #e2b6b6; }
  .action-col { display: flex; flex-direction: column; gap: 2px; align-items: center; }
  
  .hist-icon { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; background: #e0f2f1; border-radius: 50%; margin-left: 8px; cursor: pointer; font-size: 13px; transition: 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
  .hist-icon:hover { background: var(--primary); color: white; transform: scale(1.1); }
  
  .timeline-box { background: #fff; border-left: 4px solid var(--primary); padding: 12px; margin-top: 15px; border-radius: 0 8px 8px 0; box-shadow: 0 2px 5px rgba(0,0,0,0.05); font-size: 13px;}
  .tl-item { margin-bottom: 8px; border-bottom: 1px dashed #eee; padding-bottom: 8px; word-break: break-word;}
  .tl-item:last-child { margin-bottom: 0; border-bottom: none; padding-bottom: 0; }
  
  .modal-lg { max-width: 800px; width: 100%; max-height: 90vh; display: flex; flex-direction: column; }
  .history-container { overflow-y: auto; max-height: 60vh; padding-right: 10px; margin-top: 15px; }
  .history-item { background: #fdfdfd; border-left: 4px solid var(--primary); padding: 12px; margin-bottom: 10px; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
  .history-item.type-statut { border-left-color: #f0ad4e; background: #fffbf5; }
  .history-item.type-equip { border-left-color: #5bc0de; background: #f4fbfc; }
  .hist-header { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: 12px; color: #666; flex-wrap: wrap;}
  .hist-action { font-weight: bold; font-size: 14.5px; color: #333; margin-bottom: 3px; word-break: break-word;}
  .hist-details { font-size: 13px; color: #555; background: #fff; padding: 6px; border: 1px dashed #ccc; border-radius: 4px; font-family: monospace; white-space: pre-wrap; word-break: break-word;}
  
  .progress-container { width: 100%; max-width: 100px; background: #e9ecef; border-radius: 10px; overflow: hidden; display: inline-flex; vertical-align: middle; margin-right: 8px; border: 1px solid #ccc;}
  .progress-bar { height: 10px; transition: width 0.4s ease; }
  .progress-text { font-size: 12px; font-weight: bold; color: #555; vertical-align: middle;}
  .btn-expand { background: none; border: none; font-size: 14px; cursor: pointer; color: var(--primary); transition: transform 0.3s; padding: 0 8px 0 0; outline: none; width: auto;}
  .btn-expand.open { transform: rotate(180deg); }
  
  .main-row { transition: background 0.2s; }
  .details-row { display: none; background: #fafafa; border-bottom: 2px solid var(--primary); box-shadow: inset 0 3px 6px rgba(0,0,0,0.05); }
  .details-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; padding: 15px 30px; font-size: 13px; }
  .detail-item { display: flex; align-items: center; gap: 6px; padding: 4px; background: #fff; border-radius: 4px; border: 1px solid #eee; word-break: break-word;}
  .detail-ok { border-left: 3px solid #5cb85c; }
  .detail-ko { border-left: 3px solid #d9534f; color: #888; }

  /* ==================================================
     📱 OPTIMISATIONS MOBILES (Max-width: 800px)
     ================================================== */
  @media (max-width: 800px) {
    body { padding: 5px; }
    .container { padding: 15px 10px; border-radius: 0; box-shadow: none; }
    
    .header-wrapper { flex-direction: column; gap: 15px; text-align: center; padding: 15px; }
    .header-wrapper button { width: 100%; }
    
    .dash-controls { flex-direction: column; align-items: stretch; gap: 10px; padding: 10px;}
    .dash-controls input, .dash-controls button { width: 100%; }
    .dash-table-wrapper { padding: 10px; }

    /* Forcer toutes les grilles à 1 seule colonne */
    .form-grid { grid-template-columns: 1fr !important; gap: 15px; }
    .form-grid > div { grid-column: 1 / -1 !important; width: 100%; box-sizing: border-box; }
    
    /* Graphe et Boutons Radios */
    .eval-container { flex-direction: column; align-items: stretch; padding: 10px;}
    .radio-group { grid-template-columns: repeat(3, 1fr); /* 3 colonnes au lieu de 6 sur mobile */ } 
    .chart-box { width: 100%; position: relative; top: 0; display: flex; justify-content: center; overflow: hidden;}
    .radio-label { height: 40px; }
    
    /* Boutons de la modale */
    .modal-content > div[style*="display: flex"] { flex-direction: column-reverse; }
    .modal-content > div[style*="display: flex"] button { width: 100%; margin-top: 10px;}

    /* Ligne de préparation Équipement */
    div[style*="align-items:flex-end"] { flex-direction: column; align-items: stretch !important; gap: 10px;}
    .hide-mobile { display: none; }

    /* Upload d'image */
    .upload-section { flex-direction: column; align-items: stretch; padding: 10px;}
    .upload-section > div { width: 100% !important; margin-bottom: 5px; }
    .upload-section button { width: 100%; height: auto; padding: 15px; }

    /* ==================================================
       TRANSFORMATION DES TABLEAUX EN "CARTES"
       ================================================== */
       
    /* 1. Tableau de bord */
    #dashTable thead { display: none; }
    #dashTable, #dashBody, #dashBody tr, #dashBody td { display: block; width: 100%; box-sizing: border-box; }
    
    #dashBody tr.main-row {
      margin-bottom: 15px;
      border: 1px solid #ccc; 
      border-radius: 8px; 
      background: #fff;
      padding: 10px;
      box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    }
    
    #dashBody td { 
      text-align: left !important; 
      padding: 5px 0; 
      border: none;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    
    /* Ajouter des faux labels pour le tableau de bord */
    #dashBody td:nth-child(2)::before { content: "Causse :"; font-weight: bold; color: var(--primary); }
    #dashBody td:nth-child(3)::before { content: "Complétude :"; font-weight: bold; color: var(--primary); }
    #dashBody td:nth-child(4)::before { content: "Statut :"; font-weight: bold; color: var(--primary); }
    #dashBody td:nth-child(5)::before { content: "Auteur :"; font-weight: bold; color: var(--primary); }
    #dashBody td:nth-child(6)::before { content: "Date :"; font-weight: bold; color: var(--primary); }
    
    #dashBody td:nth-child(1) { font-size: 18px; border-bottom: 1px solid #eee; padding-bottom: 10px; justify-content: flex-start; gap: 10px;}
    #dashBody td:nth-child(7) { justify-content: center; margin-top: 10px; }
    #dashBody td:nth-child(7) button { width: 100%; padding: 12px; }
    
    /* Détails du tableau de bord */
    #dashBody td[colspan="7"] { display: block; border: none !important; padding: 0 !important; }
/* Garder les détails cachés par défaut sur mobile */
    #dashBody tr.details-row { 
      display: none !important; 
    }
    
    /* Afficher uniquement quand on clique sur la flèche (.open) */
    #dashBody tr.details-row.open { 
      display: block !important; 
      margin-bottom: 15px; 
      margin-top: -10px; 
      border-radius: 0 0 8px 8px; 
      border: 1px solid #ccc; 
      border-top: none;
    }
    .details-grid { grid-template-columns: 1fr; padding: 10px; gap: 5px;}

    /* 2. Tableaux d'équipement et d'images */
    #equipTable thead, #imgTable thead { display: none; }
    #equipTable, #imgTable, #equipBody, #imgBody { display: block; width: 100%; }
    
    #equipBody tr, #imgBody tr { 
      display: block; 
      width: 100%; 
      margin-bottom: 20px; 
      border: 2px solid var(--border); 
      border-radius: 8px; 
      padding: 15px; 
      background: #fff;
      box-sizing: border-box;
    }
    
    #equipBody td, #imgBody td { 
      display: flex; 
      flex-direction: column; 
      align-items: flex-start; 
      gap: 5px; 
      padding: 10px 0; 
      border: none !important; 
      border-bottom: 1px solid #eee !important; 
      text-align: left !important;
      width: 100%;
    }
    #equipBody td:last-child, #imgBody td:last-child { border-bottom: none !important; }
    
    /* Générer les labels en mobile via CSS pour Equipement & Images */
    #equipBody td:nth-child(1)::before { content: "Actions"; font-weight: bold; color: var(--primary); }
    #equipBody td:nth-child(2)::before { content: "Obstacle"; font-weight: bold; color: var(--primary); }
    #equipBody td:nth-child(3)::before { content: "Corde"; font-weight: bold; color: var(--primary); }
    #equipBody td:nth-child(4)::before { content: "Amarrage"; font-weight: bold; color: var(--primary); }
    #equipBody td:nth-child(5)::before { content: "Observation"; font-weight: bold; color: var(--primary); }
    #equipBody td.cell-origine::before { content: "Origine"; font-weight: bold; color: var(--primary); }
    
    #equipBody td[data-label="Actions"], #imgBody td[data-label="Actions"] { 
      flex-direction: row; 
      flex-wrap: wrap; 
      justify-content: flex-start; 
      gap: 10px;
    }
    
    .img-thumb { max-width: 100%; height: auto; max-height: 250px; display: block; margin: 0 auto; }
    
    /* S'assurer que les textareas ne cassent pas le layout sur mobile */
    #equipBody td textarea { width: 100% !important; min-height: 60px; }
  }

table { 
    width: 100%; 
    border-collapse: collapse; 
    margin-bottom: 10px; 
    font-size: 15px; 
    table-layout: fixed; 
  }
  th, td { 
    border: 1px solid #ddd; 
    padding: 10px; 
    text-align: left; 
    vertical-align: middle;
    word-wrap: break-word; 
    overflow-wrap: break-word; 
    word-break: break-word; 
  }

  
/* ===== CalculetteUI (extrait de l'AdminUI GAS) ===== */
  /* VOS STYLES EXACTS */
  .calc-wrapper { font-family: sans-serif; background-color: #121212; color: #fff; padding: 10px; margin: 0; border-radius: 10px;}
  .calc-wrapper .app-container { max-width: 400px; margin: 0 auto; background: #1e1e1e; padding: 15px; border-radius: 10px; box-shadow: 0 4px 10px rgba(0,0,0,0.5); }
  
  .calc-wrapper .screen { background: #000; color: #00ff00; padding: 15px; border-radius: 5px; font-family: monospace; min-height: 50px; margin-bottom: 5px; font-size: 18px; word-wrap: break-word;}
  
  .calc-wrapper .warning { padding: 8px; font-size: 13px; margin-bottom: 10px; font-weight: bold; border-radius: 5px; display: none; text-align: center; color: white;}
  .calc-wrapper .alert-danger { background-color: #c62828; } 
  .calc-wrapper .alert-warning { background-color: #d35400; } 
  
  .calc-wrapper h4 { margin: 12px 0 5px 0; color: #aaa; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; border-bottom: 1px solid #333; padding-bottom: 3px;}
  
  .calc-wrapper .grid { display: grid; gap: 8px; margin-bottom: 10px; }
  .calc-wrapper .grid-4 { grid-template-columns: repeat(4, 1fr); }
  .calc-wrapper .grid-3 { grid-template-columns: repeat(3, 1fr); } 
  .calc-wrapper .grid-2 { grid-template-columns: repeat(2, 1fr); }
  
  .calc-wrapper button { padding: 12px 5px; font-size: 16px; font-weight: bold; border: none; border-radius: 6px; cursor: pointer; color: white; touch-action: manipulation; transition: all 0.2s ease;}
  .calc-wrapper button:active { transform: scale(0.95); }
  
  .calc-wrapper .btn-qty { background-color: #0277bd; font-size: 20px;}
  .calc-wrapper .btn-anchor-main { background-color: #2e7d32; font-size: 16px; padding: 15px 5px;}
  .calc-wrapper .btn-anchor-minor { background-color: #558b2f; font-size: 14px; padding: 10px 5px;}
  
  .calc-wrapper .btn-mod { background-color: #f57c00; font-size: 14px;}
  .calc-wrapper .btn-link-plus { background-color: #c2185b; font-size: 16px;}
  .calc-wrapper .btn-free-text { background-color: #546e7a; font-size: 14px;}
  
  .calc-wrapper .btn-link { background-color: #6a1b9a; font-size: 20px; padding: 15px 5px;}
  
  .calc-wrapper .btn-action { background-color: #c62828; width: 100%; margin-top: 15px; padding: 12px;}
  .calc-wrapper .btn-save { background-color: #37474f; width: 100%; margin-top: 8px; padding: 15px; font-size: 18px; border: 1px solid #546e7a;}
  .calc-wrapper .btn-export { background-color: #1565c0; width: 100%; margin-top: 8px; padding: 12px; font-size: 16px;}
  .calc-wrapper .btn-info { background-color: #00695c; width: 100%; margin-top: 8px; padding: 10px; font-size: 14px; border: 1px solid #004d40;}

  .calc-wrapper button:disabled { background-color: #333 !important; color: #666 !important; cursor: not-allowed; transform: none; }

  /* Modals */
  .calc-wrapper .modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85); display: none;
    align-items: center; justify-content: center; z-index: 2000; padding: 15px;
  }
  .calc-wrapper .modal-content {
    background: #1e1e1e; padding: 20px; border-radius: 10px;
    width: 100%; max-width: 380px; box-shadow: 0 4px 15px rgba(0,0,0,0.8);
    border: 1px solid #333; color: white;
  }
  .calc-wrapper .modal-content h3 { margin-top: 0; color: #fff; font-size: 18px; border-bottom: 1px solid #333; padding-bottom: 10px;}
  .calc-wrapper .modal-body { max-height: 60vh; overflow-y: auto; padding-right: 5px; font-size: 14px; line-height: 1.4; color: #ddd; }
  .calc-wrapper .modal-body h4 { color: #4fc3f7; margin-top: 15px; margin-bottom: 5px; border-bottom: none; font-size: 15px;}
  .calc-wrapper .modal-body ul { margin-top: 0; padding-left: 20px; margin-bottom: 15px;}
  .calc-wrapper .modal-body li { margin-bottom: 6px;}
  .calc-wrapper .modal-actions { display: flex; gap: 10px; margin-top: 15px; }
  .calc-wrapper .modal-actions button { flex: 1; margin: 0; }
  
  .calc-wrapper .modal-input {
    width: 100%; box-sizing: border-box; padding: 12px; margin-top: 10px;
    background: #000; color: #0f0; border: 1px solid #555;
    border-radius: 5px; font-family: monospace; font-size: 16px;
  }
  .calc-wrapper .modal-textarea {
    width: 100%; box-sizing: border-box; padding: 10px; margin-top: 10px;
    background: #000; color: #0f0; border: 1px solid #555;
    border-radius: 5px; font-family: monospace; font-size: 14px;
    height: 200px; resize: none;
  }
  
  .calc-wrapper .import-input { width: 100%; box-sizing: border-box; padding: 12px; background: #000; color: #fff; border: 1px solid #555; border-radius: 5px; font-family: monospace; font-size: 14px; }
  .calc-wrapper .grid-import { grid-template-columns: 1fr auto; display: grid; gap: 8px; margin-bottom: 10px; }
