/* ==================== GESTION DES IMPAYÉS ==================== */
/* Palette inspirée du document de suivi recouvrement (navy / orange) */
.page_gestion_impayes {
  --imp-navy: #1B2A4A;
  --imp-navy-soft: #2C4270;
  --imp-orange: #F07D00;
  --imp-brown: #8A5A34;
  --imp-purple: #6B3FA0;
  --imp-bg: #F5F6F8;
  --imp-card: #FFF;
  --imp-line: #DDE1E7;
  --imp-txt: #22272E;
  --imp-muted: #6B7280;
  --imp-red: #C0392B;
  --imp-green: #2E7D52;

  padding: 18px 22px 30px;
  background: var(--imp-bg);
  color: var(--imp-txt);
  min-height: calc(100vh - 60px);
}

/* ---- Header (charte des autres pages : h1 16pt couleur principale) ---- */
.imp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}
.imp-header h1 {
  margin: 0;
  font-size: 16pt;
  color: var(--main-bg-color);
}
.imp-header h1 .fa { margin-right: 6px; }
.imp-sub { color: #888; font-size: 8.5pt; margin-top: 2px; }
.imp-header-actions { display: flex; gap: 8px; }

/* ---- Boutons (charte .prosp-btn) ---- */
.imp-btn {
  padding: 5px 14px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #f5f5f5;
  color: #333;
  cursor: pointer;
  font-size: 9pt;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.imp-btn:hover { background: #ececec; }
.imp-btn:disabled { opacity: .6; cursor: not-allowed; }
.imp-btn-primary { background: var(--main-bg-color); border-color: var(--main-bg-color); color: #fff; }
.imp-btn-primary:hover { filter: brightness(1.1); }
.imp-btn-success { background: var(--imp-green); border-color: var(--imp-green); color: #fff; }
.imp-btn-success:hover { background: #256742; }

/* ---- KPI (charte : carte blanche arrondie + icône colorée 42px) ---- */
.imp-kpi-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.imp-kpi-card {
  flex: 1;
  min-width: 150px;
  background: #fff;
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  display: flex;
  align-items: center;
  gap: 12px;
  transition: box-shadow 0.2s;
}
.imp-kpi-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
.imp-kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
}
.imp-kpi-content { display: flex; flex-direction: column; min-width: 0; }
.imp-kpi-value { font-size: 18pt; font-weight: 700; color: #222; line-height: 1.1; white-space: nowrap; }
.imp-kpi-label { font-size: 8.5pt; color: #888; font-weight: 500; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.imp-kpi-due .imp-kpi-icon { background: #e53935; }
.imp-ki-count { background: #5c6bc0; }
.imp-ki-late { background: #ff9800; }
.imp-ki-old { background: #8d6e63; }
.imp-ki-inc { background: #ab47bc; }
.imp-kpi-qr .imp-kpi-icon { background: #43a047; }
.imp-kpi-clickable { cursor: pointer; border: 2px solid transparent; transition: border-color 0.2s, box-shadow 0.2s; }
.imp-kpi-active { border-color: var(--main-bg-color); }

/* ---- Panneaux de répartition ---- */
.imp-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.imp-panel {
  background: var(--imp-card);
  border: 1px solid var(--imp-line);
  border-radius: 6px;
  padding: 13px 15px;
}
.imp-panel h2 {
  margin: 0 0 9px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--imp-muted);
  text-align: left;
}
.imp-bar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px dashed var(--imp-line);
  font-size: 12.5px;
  text-align: left;
}
.imp-bar:last-child { border-bottom: none; }
.imp-bar b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.imp-nb { color: var(--imp-muted); font-size: 11px; }

/* ---- Toolbar ---- */
.imp-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 11px;
  align-items: center;
}
.imp-chip {
  border: 1px solid var(--imp-line);
  background: var(--imp-card);
  border-radius: 20px;
  padding: 6px 13px;
  font-size: 12px;
  cursor: pointer;
  color: var(--imp-navy);
  user-select: none;
}
.imp-chip.on { background: var(--imp-navy); color: #fff; border-color: var(--imp-navy); }
.imp-chip-nb { opacity: .65; font-size: 10.5px; }
.imp-chip-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 3px;
  vertical-align: baseline;
}
.imp-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--imp-navy);
  cursor: pointer;
  user-select: none;
  padding: 6px 4px;
}
.imp-rech {
  margin-left: auto;
  padding: 7px 12px;
  border: 1px solid var(--imp-line);
  border-radius: 20px;
  font-size: 12px;
  min-width: 240px;
}

/* ---- Tableau (charte .prosp-table : conteneur blanc arrondi, thead gris clair) ---- */
.imp-wrap {
  overflow-x: auto;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
.imp-table { width: 100%; border-collapse: collapse; font-size: 9pt; }
/* main.css impose thead th / thead th a { background: var(--main-bg-color) } et table { text-align: center } → surcharges */
.imp-table thead th,
.imp-table thead th a {
  background: #f8f9fa;
  color: #555;
}
.imp-table thead th {
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 8.5pt;
  border-bottom: 2px solid #e0e0e0;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 2;
}
.imp-table thead th:hover { background: #eef; }
.imp-arrow { font-size: 8pt; margin-left: 2px; color: var(--main-bg-color); }
.imp-table td {
  padding: 7px 10px;
  vertical-align: top;
  text-align: left;
}
.imp-table tbody tr { border-bottom: 1px solid #f0f0f0; }
.imp-table tbody tr:hover { background: rgba(92, 107, 192, 0.06); }
.imp-num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.imp-table thead th.imp-num { text-align: right; }
.imp-fa a { font-weight: 700; color: var(--main-bg-color); white-space: nowrap; text-decoration: none; }
.imp-fa a:hover { text-decoration: underline; }
.imp-client { color: var(--imp-txt); text-decoration: none; font-weight: 600; }
.imp-client:hover { text-decoration: underline; color: var(--main-bg-color); }
.imp-tel { white-space: nowrap; font-variant-numeric: tabular-nums; }
.imp-mail { color: var(--imp-navy-soft); font-size: 11.5px; word-break: break-all; }
.imp-com { color: var(--imp-muted); font-size: 11.5px; min-width: 150px; }
.imp-empty { text-align: center !important; color: var(--imp-muted); padding: 24px !important; }

/* Badges entité — la couleur de fond vient du tag Dolibarr (llx_categorie.color,
   appliquée en :style par imp_tagStyle, texte blanc/foncé selon la luminance) */
.imp-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

/* Retard (ancienneté) */
.imp-anc { font-weight: 700; }
.imp-a1 { color: var(--imp-muted); }
.imp-a2 { color: #B8860B; }
.imp-a3 { color: var(--imp-orange); }
.imp-a4 { color: var(--imp-red); }

/* Divers cellules */
.imp-part {
  display: inline-block;
  background: #EAF4EE;
  color: var(--imp-green);
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
}
.imp-qr-tag {
  display: inline-block;
  background: #EAF4EE;
  color: var(--imp-green);
  border: 1px solid #8FC4A8;
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
}
.imp-acomp {
  display: inline-block;
  background: #FFF1F0;
  color: var(--imp-red);
  border: 1px solid #E9B4AE;
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 10.5px;
  font-weight: 700;
}
.imp-todo { color: #B0B6BE; font-style: italic; font-size: 11.5px; }

/* Cellule procédure éditable */
.imp-proc { cursor: pointer; position: relative; min-width: 170px; }
.imp-proc .imp-pen {
  opacity: 0;
  color: var(--imp-navy-soft);
  font-size: 10px;
  position: absolute;
  top: 8px;
  right: 6px;
  transition: opacity .15s ease;
}
.imp-proc:hover .imp-pen { opacity: .8; }
td.imp-com { cursor: pointer; }

/* ---- Footer ---- */
.imp-footer {
  margin-top: 14px;
  font-size: 11px;
  color: var(--imp-muted);
  line-height: 1.7;
}

/* ---- Modale suivi de relance ---- */
.imp-edit-mask {
  display: flex !important;
  align-items: center;
  justify-content: center;
}
.imp-edit-modal {
  background: #fff;
  border-radius: 10px;
  width: min(560px, calc(100vw - 30px));
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.imp-edit-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--imp-line);
}
.imp-edit-title { font-size: 15px; font-weight: 700; color: var(--imp-navy); }
.imp-edit-title .fa { margin-right: 6px; color: var(--imp-orange); }
.imp-edit-sub { font-size: 12px; color: var(--imp-muted); margin-top: 3px; }
.imp-edit-close {
  border: none;
  background: none;
  font-size: 16px;
  color: var(--imp-muted);
  cursor: pointer;
  padding: 4px 6px;
}
.imp-edit-close:hover { color: var(--imp-red); }
.imp-edit-body { padding: 14px 18px; text-align: left; }
.imp-edit-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--imp-muted);
  font-weight: 600;
  margin: 12px 0 6px;
}
.imp-edit-label:first-child { margin-top: 0; }
.imp-stade-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.imp-stade-pill { cursor: pointer; border: 2px solid transparent; user-select: none; }
.imp-stade-pill:hover { filter: brightness(0.95); }
.imp-stade-on { border-color: var(--imp-navy); box-shadow: 0 0 0 1px #fff inset; }
.imp-edit-body textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--imp-line);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12.5px;
  font-family: inherit;
  resize: vertical;
}
.imp-edit-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--imp-line);
}

/* ---- Modale tuto / aide (pattern gp-tuto de Gestion Projet) ---- */
.imp-tuto-modal {
  background: #fff;
  border-radius: 10px;
  width: min(760px, calc(100vw - 30px));
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.imp-tuto-nav {
  display: flex;
  gap: 4px;
  padding: 0 18px;
  border-bottom: 2px solid #eee;
  flex-shrink: 0;
}
.imp-tuto-nav-btn {
  background: none;
  border: none;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  color: #888;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
}
.imp-tuto-nav-btn.active {
  color: var(--main-bg-color);
  border-bottom-color: var(--main-bg-color);
}
.imp-tuto-content {
  padding: 14px 18px 18px;
  overflow-y: auto;
  min-height: 300px;
  text-align: left;
}
.imp-tuto-content h4 {
  font-size: 15px;
  font-weight: 700;
  color: #333;
  margin: 14px 0 8px;
}
.imp-tuto-content h4:first-child { margin-top: 0; }
.imp-tuto-content p {
  font-size: 13px;
  line-height: 1.6;
  color: #555;
  margin: 0 0 8px;
}
.imp-tuto-flow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin: 10px 0 14px;
}
.imp-tuto-flow-step {
  flex: 1;
  text-align: center;
  padding: 12px 10px;
  background: #f8f9fb;
  border-radius: 8px;
  min-width: 120px;
}
.imp-tuto-flow-step .fa {
  display: block;
  font-size: 20px;
  color: var(--main-bg-color);
  margin-bottom: 6px;
}
.imp-tuto-flow-step strong { font-size: 12px; display: block; }
.imp-tuto-flow-step p { font-size: 11px; margin: 4px 0 0; color: #888; }
.imp-tuto-flow-arrow { color: #ccc; margin: 0 4px; }
.imp-tuto-list {
  list-style: none;
  padding: 0;
  margin: 8px 0;
}
.imp-tuto-list li {
  padding: 6px 0;
  font-size: 13px;
  line-height: 1.55;
  color: #555;
}
.imp-tuto-list li strong { color: #333; }
.imp-tuto-tip {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: #EAF4EE;
  border: 1px solid #8FC4A8;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.6;
  color: #333;
}
.imp-tuto-tip > .fa {
  font-size: 18px;
  color: var(--imp-green);
  margin-top: 2px;
}
.imp-tuto-stades {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 8px 16px;
  margin-top: 10px;
}
.imp-tuto-stade { padding: 4px 0; }
.imp-tuto-stade p { font-size: 12px; color: #666; margin: 4px 0 0; }

/* ---- Responsive tablette (tailles KPI de référence du projet) ---- */
@media (max-width: 992px) {
  .page_gestion_impayes { padding: 12px; }
  .imp-kpi-row { gap: 8px; }
  .imp-kpi-card { padding: 8px 10px; gap: 8px; min-width: 120px; }
  .imp-kpi-icon { width: 32px; height: 32px; border-radius: 8px; font-size: 14px; }
  .imp-kpi-value { font-size: 14pt; }
  .imp-kpi-label { font-size: 7.5pt; }
  .imp-rech { min-width: 160px; }
}

/* ---- Responsive mobile (KPI grille 3 colonnes) ---- */
@media (max-width: 768px) {
  .imp-kpi-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
  .imp-kpi-card { padding: 4px 6px; gap: 4px; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); min-width: 0; }
  .imp-kpi-icon { width: 22px; height: 22px; border-radius: 5px; font-size: 10px; }
  .imp-kpi-value { font-size: 10pt; }
  .imp-kpi-label { font-size: 6.5pt; }
  .imp-hide-mobile { display: none; }
  .imp-split { grid-template-columns: 1fr; }
  .imp-rech { margin-left: 0; width: 100%; }
  .imp-tuto-nav { flex-wrap: wrap; }
}

/* ---- Impression ---- */
@media print {
  .page_gestion_impayes { padding: 0; background: #fff; min-height: 0; }
  .imp-toolbar, .imp-header-actions, .imp-pen, .imp-edit-mask { display: none !important; }
  .imp-wrap { border: none; overflow: visible; }
  .imp-table thead th { position: static; }
}
