/* ═══════════════════════════════════════
   Simulation page styles
═══════════════════════════════════════ */

.sim-page { display: flex; flex-direction: column; gap: 24px; }

/* ── Header barre ── */
.sim-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.sim-title { font-size: 20px; font-weight: 700; color: var(--primary); }
.sim-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.save-status { font-size: 12px; font-weight: 600; }
.save-ok  { color: #16A34A; }
.save-err { color: #DC2626; }

.sim-btn {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}
.sim-btn:hover { background: var(--primary-light); color: var(--primary); }

/* Modale fichiers */
.sim-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.sim-modal {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  min-width: 340px;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.sim-modal-title { font-size: 14px; font-weight: 700; color: var(--primary); }
.sim-file-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow-y: auto; }
.sim-file-item {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--border);
}
.sim-file-item:hover { background: var(--primary-light); color: var(--primary); }
.sim-file-input-row { display: flex; align-items: center; gap: 4px; }
.sim-file-input {
  flex: 1; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; color: var(--text);
}
.sim-file-input:focus { outline: none; border-color: var(--primary); }
.sim-file-ext { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.sim-file-select {
  width: 100%; border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; padding: 4px; color: var(--text); background: #fff;
}
.sim-file-select option { padding: 4px 8px; }
.sim-modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.sim-btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.sim-btn-primary:hover { background: #581c87; }
.sim-duration {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}
.sim-duration select {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: #fff;
  cursor: pointer;
}

/* ── Groupes de paramètres ── */
.sim-params {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.param-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.param-card-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
  border-bottom: 1px solid var(--primary-light);
  padding-bottom: 6px;
  margin-bottom: 2px;
}

/* ── Ligne de paramètre ── */
.param-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.param-label {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  color: var(--text);
  line-height: 1.2;
}
.param-label small {
  display: block;
  color: var(--text-muted);
  font-size: 9px;
}

/* Groupe input + unité collés à droite */
.param-input-group {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.param-input {
  width: 62px;
  padding: 2px 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  background: #fafafa;
  transition: border-color 0.15s;
  /* Supprime les flèches spinner et leur marge droite */
  -moz-appearance: textfield;
}
.param-input::-webkit-outer-spin-button,
.param-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.param-input:focus { outline: none; border-color: var(--primary); background: #fff; }

.param-unit {
  width: 22px;
  font-size: 9px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Cards à valeurs courtes (prix, %) */
.param-card-sm .param-input { width: 44px; font-size: 11px; }
.param-card-sm .param-unit  { width: auto; }

/* Plans sum indicator */
.plans-sum {
  font-size: 11px;
  text-align: right;
  padding-top: 4px;
  font-weight: 600;
}
.plans-sum.ok { color: #16A34A; }
.plans-sum.bad { color: #DC2626; }

/* ── Inputs dépenses dans le tableau ── */
.dep-input {
  width: 100%;
  padding: 3px 0;
  border: none;
  border-bottom: 1px dashed var(--border);
  border-radius: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  background: transparent;
  transition: border-color 0.15s;
}
.dep-input:focus { outline: none; border-bottom-color: var(--primary); background: transparent; }

/* cellule dépense : aligner comme les autres */
.row-sub td:has(.dep-input) { padding: 4px 12px; }

/* ── Séparateur ── */
.sim-divider {
  border: none;
  border-top: 2px solid var(--primary-light);
}

/* ── Compte d'exploitation ── */
.sim-results { display: flex; flex-direction: column; gap: 8px; }

.sim-results-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
}

.result-table-wrap {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: var(--surface);
}

.result-table th {
  background: var(--primary);
  color: #fff;
  padding: 8px 12px;
  text-align: right;
  font-weight: 600;
  white-space: nowrap;
}
.result-table th:first-child { text-align: left; }

.result-table td {
  padding: 6px 12px;
  text-align: right;
  border-bottom: 1px solid #f3f0ff;
  white-space: nowrap;
}
.result-table td:first-child {
  text-align: left;
  font-size: 11px;
  color: var(--text-muted);
}

/* sections */
.row-section td {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 12px;
  border-bottom: 1px solid #ddd6fe;
}

.row-sub td:first-child {
  padding-left: 22px;
  color: var(--text-muted);
}

.row-total td {
  font-weight: 700;
  background: #faf5ff;
  border-top: 2px solid var(--border);
  border-bottom: 2px solid var(--border);
}

.row-result td {
  font-weight: 800;
  font-size: 13px;
}
.row-result.positive td { color: #16A34A; }
.row-result.negative td { color: #DC2626; }

.row-cumul td {
  font-size: 11px;
  font-style: italic;
  color: var(--text-muted);
  background: #faf9ff;
}
.row-cumul td.cum-positive { color: #16A34A; font-style: normal; }
.row-cumul td.cum-negative { color: #DC2626; font-style: normal; }
