*{box-sizing:border-box}body{font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif;margin:0;background:#f6f7fb;color:#1b1f23}
header{background:#0d47a1;color:#fff;padding:12px 16px}
header h1{margin:0 0 8px 0;font-size:20px}
header .baseurl{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
header input{padding:6px;border-radius:8px;border:1px solid #d0d7de;min-width:320px}
header button{background:#1e88e5;color:#fff;border:0;border-radius:8px;padding:6px 10px;cursor:pointer}
main{max-width:1000px;margin:16px auto;padding:0 16px;display:grid;gap:16px}
section{background:#fff;border:1px solid #eaeef2;border-radius:12px;padding:16px}
section h2{margin-top:0;font-size:18px}
button{background:#1e88e5;color:#fff;border:0;border-radius:8px;padding:8px 12px;cursor:pointer}
button:disabled{opacity:.6;cursor:not-allowed}
input,textarea{width:100%;padding:8px;border:1px solid #d0d7de;border-radius:8px;margin:6px 0}
.output{background:#0b1020;color:#d1e7ff;padding:12px;border-radius:10px;min-height:42px;max-height:300px;overflow:auto}
.progress{height:8px;background:#eee;border-radius:999px;overflow:hidden;margin-top:8px}
#progressBar{height:100%;width:0;background:#43a047;transition:width .1s}
footer{padding:16px;color:#444}
code{background:#eef;padding:2px 6px;border-radius:6px}

/* Layouts form / table */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.form-field label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  line-height: 1.2;
}
.form-field input,
.form-field select {
  width: 100%;
}
.full-span { grid-column: 1 / -1; }
.search-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  align-items: end;
}
.table-wrap { overflow: auto; margin-top: 10px; position: relative; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; border-bottom: 1px solid #eaeef2; padding: 8px 6px; }
td.actions { white-space: nowrap; }
button.secondary { background: #eee; color: #111; }

/* Petits boutons dans la table */
.btn-sm { padding: 6px 8px; margin-right: 6px; border-radius: 6px; }
.muted { color:#666; padding: 8px; }
.row { display:flex; gap:8px; align-items:center; }
.action-select { max-width: 220px; padding: 6px 8px; }

/* Défilement doux pour l'ancre #editSection */
html { scroll-behavior: smooth; }

/* Cap la hauteur de la table des résultats et scrolle à l'intérieur */
.table-wrap {
  max-height: 55vh;      /* ajuste 40–65vh selon ta préférence */
  overflow: auto;
  margin-top: 10px;
  position: relative;
}

/* Garde l'entête visible quand on scrolle la table */
.table-wrap thead th {
  position: sticky;
  top: 0;
  background: #fff;
  /* Keep header above body cells/buttons during scroll */
  z-index: 10;
  box-shadow: 0 1px 0 #eaeef2;
}

/* Ensure body content stays under the sticky header (no overlap) */
.table-wrap tbody td,
.table-wrap tbody .btn-sm {
  position: relative;
  z-index: 0;
}

/* Required fields highlighting */
.required { outline: 2px solid #e67e22; background: #fff7ec; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #eef; color: #225; padding: 2px 8px; border-radius: 12px; font-size: 12px; }

/* Layout enhancements for equipements */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.stack { display: grid; gap: 12px; }
.card { background: #fff; border: 1px solid #eaeef2; border-radius: 12px; padding: 12px; }
.card h3 { margin: 0 0 8px 0; font-size: 16px; }
.badge { background: #fce4ec; color: #ad1457; padding: 4px 8px; border-radius: 12px; font-size: 12px; }
.primary { background: #1e88e5; color: #fff; }
.hidden { display: none !important; }

/* Hide legacy headings and required chips block on equipement form */
#equipForm h3 { display: none; }
#requiredFields { display: none !important; }

/* Blocking overlay for long-running actions (e.g., report generation) */
.overlay-block { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 9999; display: flex; align-items: center; justify-content: center; }
.overlay-card { background: #fff; color: #111; padding: 16px 20px; border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,0.25); display: flex; align-items: center; gap: 12px; min-width: 280px; }
.spinner { width: 20px; height: 20px; border: 3px solid #e0e0e0; border-top-color: #1e88e5; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Overlay pour l'édition d'équipement */
.equip-overlay { position: fixed; inset: 0; display: none; z-index: 2000; }
.equip-overlay.is-open { display: flex; align-items: center; justify-content: center; }
.equip-overlay-backdrop { position: absolute; inset: 0; background: rgba(7, 14, 24, 0.65); }
.equip-overlay-panel { position: relative; width: min(1100px, 96vw); max-height: calc(100vh - 60px); background: #fff; border-radius: 16px; box-shadow: 0 24px 60px rgba(0,0,0,0.35); display: flex; flex-direction: column; overflow: hidden; }
.equip-overlay-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid #eaeef2; }
.equip-overlay-body { padding: 16px; overflow: auto; flex: 1; background: #f6f7fb; }
.overlay-close { background: transparent; border: 0; color: #111; font-size: 28px; line-height: 1; cursor: pointer; }
body.no-scroll { overflow: hidden; }
.equip-overlay-body [data-overlay-hide="true"] { display: none !important; }
.specific-section { margin-top: 18px; padding-top: 10px; border-top: 1px solid #eaeef2; }
.specific-section:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
