/* ===== Analyse prélèvement ===== */

.modal-analyse-prelev-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 16px;
}
.modal-analyse-prelev-overlay.hidden { display: none; }

.modal-analyse-prelev-box {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 860px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
}

.modal-analyse-prelev-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  flex-shrink: 0;
}

.modal-analyse-prelev-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 4px;
}
.modal-analyse-prelev-close:hover { background: rgba(255,255,255,.06); color: var(--text); }

.modal-analyse-prelev-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.btn-importer-analyse {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-importer-analyse:hover { background: rgba(249,115,22,.85); }

.btn-export-analyse {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--green);
  color: #07101E;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-export-analyse:hover { opacity: .88; }
.btn-export-analyse.hidden { display: none; }

.modal-analyse-prelev-body {
  overflow-y: auto;
  flex: 1;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.analyse-prelev-dropzone {
  border: 2px dashed rgba(255,255,255,.15);
  border-radius: 10px;
  padding: 14px 24px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  user-select: none;
  cursor: default;
}
.analyse-prelev-dropzone.drag-over {
  border-color: var(--orange);
  background: rgba(249,115,22,.08);
  color: var(--orange);
}

.analyse-prelev-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  font-style: italic;
  padding: 20px 0;
}

.analyse-prelev-error {
  color: var(--red);
  background: rgba(248,113,113,.1);
  border: 1px solid rgba(248,113,113,.25);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.85rem;
}

/* Table analyse */
.ap-table-scroll {
  overflow-x: auto;
}

.ap-table {
  border-collapse: collapse;
  font-size: 0.82rem;
  min-width: 100%;
}

.ap-th-param {
  min-width: 220px;
  text-align: left;
  padding: 8px 12px;
  background: rgba(255,255,255,.04);
  font-weight: 700;
  color: var(--text-dim);
  border-bottom: 2px solid var(--border);
  position: sticky;
  left: 0;
  z-index: 2;
}

.ap-th-unite {
  min-width: 110px;
  text-align: left;
  padding: 8px 10px;
  background: rgba(255,255,255,.04);
  font-weight: 700;
  color: var(--text-dim);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.ap-th-val {
  min-width: 130px;
  text-align: center;
  padding: 8px 10px;
  background: rgba(255,255,255,.04);
  font-weight: 700;
  color: var(--text);
  border-bottom: 2px solid var(--border);
  border-left: 1px solid var(--border);
  white-space: nowrap;
}

.ap-th-ech-name {
  margin-bottom: 4px;
}

.ap-th-type-row {
  min-width: 90px;
  text-align: center;
  padding: 8px 10px;
  background: rgba(255,255,255,.04);
  font-weight: 700;
  color: var(--text-dim);
  border-bottom: 2px solid var(--border);
  border-left: 2px solid rgba(255,255,255,.12);
  white-space: nowrap;
  font-size: 0.78rem;
}

.ap-cell-type-row {
  text-align: center;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  border-left: 2px solid rgba(255,255,255,.12);
  white-space: nowrap;
}

.ap-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.03em;
}
.ap-badge-a     { background: rgba(74,222,128,.12); color: var(--green); }
.ap-badge-t     { background: rgba(56,189,248,.12); color: var(--blue-lt); }
.ap-badge-b     { background: rgba(249,115,22,.15); color: var(--orange); }
.ap-badge-e     { background: rgba(248,113,113,.12); color: var(--red); }
.ap-badge-over-e { background: rgba(248,113,113,.2); color: var(--red); font-style: italic; }

.ap-row-section td.ap-cell-section {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 12px 5px;
  background: rgba(255,255,255,.04);
  color: var(--muted);
  border-top: 2px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.ap-row-data:nth-child(even) .ap-cell-param,
.ap-row-data:nth-child(even) .ap-cell-unite,
.ap-row-data:nth-child(even) .ap-cell-val { background: rgba(255,255,255,.02); }

.ap-row-data:hover .ap-cell-param,
.ap-row-data:hover .ap-cell-unite,
.ap-row-data:hover .ap-cell-val { background: rgba(249,115,22,.06); }

.ap-cell-param {
  padding: 7px 12px;
  color: var(--text-dim);
  font-weight: 500;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  position: sticky;
  left: 0;
  z-index: 1;
  line-height: 1.3;
}

.ap-cell-unite {
  padding: 7px 10px;
  color: var(--muted);
  font-size: 0.78rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.ap-cell-val {
  padding: 7px 10px;
  text-align: center;
  color: var(--text-dim);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.ap-val-absent {
  color: var(--muted);
}

/* Coloration des cellules selon le type dépassé */
.ap-cell-t     { background: rgba(249,115,22,.08) !important; }
.ap-cell-b     { background: rgba(249,115,22,.12) !important; }
.ap-cell-e     { background: rgba(248,113,113,.08) !important; }
.ap-cell-over-e { background: rgba(248,113,113,.15) !important; color: var(--red) !important; font-weight: 600; }

@media (max-width: 767px) {
  .modal-analyse-prelev-box { max-width: 100%; border-radius: 10px; }
  .ap-th-param, .ap-cell-param { min-width: 140px; font-size: 0.75rem; }
  .ap-th-unite, .ap-cell-unite { min-width: 80px; font-size: 0.72rem; }
  .ap-th-val, .ap-cell-val { min-width: 90px; font-size: 0.78rem; }
}

/* ===== Modal synthèse prélèvement ===== */

.modal-synthese-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  padding: 16px;
}
.modal-synthese-overlay.hidden { display: none; }

.modal-synthese-box {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 920px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 48px rgba(0,0,0,.6);
}

.modal-synthese-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 16px;
  flex-wrap: wrap;
}

.modal-synthese-header-left { display: flex; align-items: center; gap: 14px; }

.modal-synthese-label {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}

.modal-synthese-type {
  font-size: 0.88rem;
  font-weight: 700;
  margin-top: 3px;
}

.modal-synthese-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.btn-synth-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.btn-synth-action:hover { opacity: .85; }

.btn-synth-excel { background: #1d6f42; color: #fff; }
.btn-synth-pdf   { background: var(--orange); color: #fff; }

.modal-synthese-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 6px;
  margin-left: 4px;
}
.modal-synthese-close:hover { background: rgba(255,255,255,.06); color: var(--text); }

.modal-synthese-body {
  overflow-y: auto;
  flex: 1;
  padding: 20px 24px;
}

/* ===== Bloc résumé synthèse (filières, OMoD, cimenterie) ===== */

.synth-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.synth-meta-item { display: flex; align-items: center; gap: 5px; }

.synth-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.synth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  min-width: 180px;
  flex: 1;
}
.synth-card-wide { flex-basis: 100%; }

.synth-card-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}

.synth-card-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

.synth-omod {
  font-family: monospace;
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  color: var(--text);
}


/* Lignes de bilan (bas du tableau) */
.ap-row-bilan .ap-cell-param { background: rgba(255,255,255,.04); border-top: 2px solid var(--border); }
.ap-row-bilan .ap-cell-unite { background: rgba(255,255,255,.04); border-top: 2px solid var(--border); }
.ap-row-bilan .ap-cell-val   { background: rgba(255,255,255,.04); border-top: 2px solid var(--border); }

.ap-cell-omod {
  font-family: monospace;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text);
  text-align: center;
}

/* Impression — affiche uniquement le contenu de la synthèse */
@media print {
  body > *:not(#modal-synthese-prelev) { display: none !important; }
  #modal-synthese-prelev {
    position: static !important;
    background: white !important;
    padding: 0 !important;
  }
  .modal-synthese-box {
    box-shadow: none !important;
    border: none !important;
    max-height: none !important;
  }
  .modal-synthese-header-right { display: none !important; }
  .ap-cell-param { background: white !important; }
  .ap-cell-unite, .ap-cell-val { background: white !important; }
  .ap-row-section .ap-cell-section { background: #eee !important; color: #333 !important; }
}
