#search-wrap {
    position: relative;
    display: flex;
    align-items: center;
  }

  #search-input {
    background: rgba(255,255,255,0.95);
    color: #222;
    border: 1px solid rgba(255,255,255,0.4);
    padding: 0 28px 0 28px;
    height: 28px;          /* aligner sur la hauteur des boutons */
    box-sizing: border-box;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1;
    width: 180px;
    outline: none;
    transition: width 0.2s, background 0.2s;
  }
  #search-icon {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    font-size: 12px;
    color: #555;
  }
  body.dark #search-icon { color: #b0bcc7; }

  /* Bouton ✕ d'effacement de la recherche — exception : il a sa propre dimension
     car il est positionné en absolu DANS la barre de recherche, pas à côté. */
  #search-clear {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    font-size: 16px;
    color: #666;
    cursor: pointer;
    width: 22px;
    height: 22px;        /* override .controls button { height: 28px; } */
    padding: 0;          /* override .controls button { padding: 0 12px; } */
    line-height: 1;
    border-radius: 50%;
    display: none;
  }
  #search-clear:hover { background: rgba(0,0,0,0.08); color: #000; }
  body.dark #search-clear:hover { background: rgba(255,255,255,0.1); color: #fff; }
  #search-wrap.has-text #search-clear { display: block; }

  #search-count {
    background: #ffb300;
    color: #3e2723;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 10px;
    margin-left: 6px;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    border: none;
  }
  #search-count:hover {
    background: #ffa000;
    transform: scale(1.05);
  }
  #search-count:empty { display: none; }
  #search-count[data-count="0"] { cursor: default; background: #bdbdbd; color: #555; }
  #search-count[data-count="0"]:hover { transform: none; background: #bdbdbd; }

  /* Panneau résultats de recherche (vue liste plein écran) */
  /* === PANNEAU COÛTS (colonne coulissante à droite) === */
  #search-results-panel {
    position: fixed;
    top: 50px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-page);
    z-index: 850;
    overflow-y: auto;
    padding: 20px 24px;
  }
  #search-results-panel.hidden { display: none; }

  #search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: var(--bg-panel);
    border: 1px solid var(--border-panel);
    border-radius: 8px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px var(--shadow-panel);
    position: sticky;
    top: 0;
    z-index: 5;
  }
  #search-results-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-accent);
    margin-right: 8px;
  }
  #search-results-query {
    font-size: 13px;
    color: var(--text-muted);
  }
  #search-results-close {
    background: var(--bg-header-btn);
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
  }
  #search-results-close:hover { background: var(--bg-header-btn-hover); }

  #search-results-list {
    display: block;
    max-width: 1400px;
    margin: 0 auto;
  }

  /* Carte résultat (réutilise visuellement les nœuds mais en list-mode) */
  .result-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-panel);
    border-left: 4px solid var(--node-default-border);
    border-radius: 6px;
    padding: 12px 14px;
    cursor: pointer;
    box-shadow: 0 1px 4px var(--shadow-panel);
    transition: transform 0.1s, box-shadow 0.1s, border-left-color 0.15s;
    position: relative;
  }
  .result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  }
  .result-card.verified { border-left-color: var(--node-verified-border); }
  .result-card.partial { border-left-color: var(--node-partial-border); }
  .result-card.approximate { border-left-color: var(--node-approximate-border); }
  .result-card.structural { border-left-color: var(--node-structural-border); }
  .result-card.minister { border-left-color: var(--node-minister-border); }
  .result-card.direction { border-left-color: var(--node-direction-border); }
  .result-card.installation { border-left-color: var(--node-installation-border); }

  .result-card .result-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-accent);
    line-height: 1.3;
    margin-bottom: 4px;
  }
  .result-card .result-name {
    font-size: 12px;
    color: var(--text-default);
    margin-bottom: 6px;
  }
  .result-card .result-path {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.4;
    border-top: 1px solid var(--border-modal-divider);
    padding-top: 6px;
    margin-top: 6px;
  }
  .result-card .result-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
  }
  .result-card .result-action-btn {
    background: var(--bg-header-btn);
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
  }
  .result-card .result-action-btn:hover { background: var(--bg-header-btn-hover); }
  .result-card .result-action-btn.secondary {
    background: transparent;
    color: var(--text-accent);
    border: 1px solid var(--border-panel);
  }
  .result-card .result-action-btn.secondary:hover {
    background: var(--bg-modal-source);
  }
  .result-card mark {
    background: rgba(255, 193, 7, 0.55);
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
  }
  #search-results-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
  }

  /* Toggle dark mode — hérite du style .controls button, on ajuste juste le padding
     pour que l'icône SVG (14×14) ne touche pas les bords */
  #btn-theme {
    padding: 0 10px;
  }
  #btn-theme svg { display: block; }

  /* Bouton Imprimer — icône seule, mêmes proportions que le bouton thème.
     Hérite du style .controls button, on ajuste juste le padding. */
  #btn-print {
    padding: 0 10px;
  }
  #btn-print svg {
    display: block;
    color: #e6edf7;
  }
  body.dark #btn-print svg {
    color: #e6edf7;
  }

  /* Bouton Coûts actif */
  #btn-costs.active {
    background: #f9a825;
    color: #3e2723;
    font-weight: 600;
  }
  #btn-costs.active:hover { background: #ffb300; }

  /* Bouton Incidents — surbrillance quand des résultats matchent la recherche */
  #btn-incidents.has-matches {
    background: #ffd54f;
    color: #3e2723;
    font-weight: 600;
    box-shadow: 0 0 0 2px rgba(255, 213, 79, 0.6);
    animation: incidents-pulse 1.6s ease-in-out infinite;
  }
  #btn-incidents.has-matches:hover { background: #ffb300; }
  @keyframes incidents-pulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(255, 213, 79, 0.6); }
    50% { box-shadow: 0 0 0 5px rgba(255, 213, 79, 0.0); }
  }

  /* Conteneur des panneaux flottants en bas-gauche (Qualité + Navigation) */
  .incident-item.search-match {
    background: rgba(255, 213, 79, 0.18);
    border-radius: 6px;
    padding-left: 12px;
    padding-right: 12px;
    margin-left: -12px;
    margin-right: -12px;
  }

  /* ============================================================
     RECHERCHE ÉTENDUE — résultats groupés par section
     ============================================================ */
  .search-section {
    margin-bottom: 22px;
  }
  .search-section-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px;
    border-bottom: 2px solid var(--accent, #1f6feb);
    margin-bottom: 10px;
    position: sticky;
    top: 0;
    background: var(--bg-panel, #ffffff);
    z-index: 2;
  }
  .search-section-title {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent, #1f6feb);
  }
  .search-section-count {
    font-size: 11px;
    font-weight: 700;
    background: var(--accent, #1f6feb);
    color: #fff;
    border-radius: 10px;
    padding: 1px 8px;
  }
  /* Bouton de tri : bleu franc + texte blanc dans les DEUX états
     (Trier par catégorie / Liste simple) et dans les 2 thèmes,
     pour rester lisible en mode nuit. */
  .search-sort-btn {
    margin-left: auto;
    font-size: 11.5px;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #1f6feb;
    background: #1f6feb;
    color: #fff;
    cursor: pointer;
    transition: filter 0.15s;
  }
  .search-sort-btn:hover {
    filter: brightness(1.12);
  }
  .search-sort-btn.active {
    background: #1f6feb;
    color: #fff;
    border-color: #1f6feb;
  }
  body.dark .search-sort-btn {
    background: #2f7ef0;
    border-color: #2f7ef0;
    color: #fff;
  }
  .search-section-body {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
  }
  .search-cat-group {
    margin-bottom: 12px;
  }
  .search-cat-head {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted, #888);
    padding: 4px 2px;
    margin-bottom: 4px;
    border-bottom: 1px dotted var(--bg-modal-source, #ddd);
  }
  .search-cat-count {
    font-size: 10.5px;
    color: var(--text-muted, #999);
  }
  .result-snippet {
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-muted, #777);
    margin-top: 3px;
  }
  .search-no-results {
    padding: 30px 10px;
    text-align: center;
    color: var(--text-muted, #888);
    font-size: 13px;
  }
  /* Liseré de couleur selon la nature du résultat */
  .search-kind-incident { border-left: 3px solid #d4761c; }
  .search-kind-resign   { border-left: 3px solid #c0392b; }
  .search-kind-cost     { border-left: 3px solid #1f8f4e; }
  .search-kind-reco     { border-left: 3px solid #7b4fc0; }
  .search-kind-defav    { border-left: 3px solid #d4a017; }

  /* ============================================================
     POP-UP de résultat de recherche
     - org   : 2 choix (Localiser / Voir les infos)
     - autre : détail complet de l'élément
     z-index 1200 : au-dessus du panneau de recherche (850),
     sous la modale de nœud (2000) qui peut s'ouvrir par-dessus.
     Couleurs alignées sur les variables de thème du kit
     (--bg-modal, --text-default…) pour rester lisible en mode nuit.
     ============================================================ */
  .sr-popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-modal-overlay, rgba(0, 0, 0, 0.55));
    padding: 20px;
  }
  .sr-popup {
    background: var(--bg-modal, #ffffff);
    color: var(--text-default, #333333);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    width: 100%;
    max-width: 440px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: srPopupIn 0.14s ease-out;
  }
  .sr-popup-detail {
    max-width: 720px;
    width: 92%;
    height: 59vh;
    max-height: 59vh;
  }
  @keyframes srPopupIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
  }
  .sr-popup-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px 8px;
  }
  .sr-popup-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
    flex: 1;
    color: var(--text-default, #333333);
  }
  .sr-popup-close {
    background: none;
    border: none;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted, #666666);
    padding: 2px 4px;
    border-radius: 5px;
    flex-shrink: 0;
  }
  .sr-popup-close:hover {
    background: var(--bg-modal-source, #f5f5f5);
    color: var(--text-default, #333333);
  }
  .sr-popup-sub {
    padding: 0 16px 10px;
    font-size: 12.5px;
    color: var(--text-muted, #666666);
  }
  /* -- choix org -- */
  .sr-popup-choices {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 16px 16px;
  }
  .sr-popup-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    padding: 11px 13px;
    font-size: 13.5px;
    border-radius: 8px;
    border: 1px solid #1f6feb;
    background: #1f6feb;
    color: #fff;
    cursor: pointer;
    transition: filter 0.13s;
  }
  .sr-popup-btn:hover { filter: brightness(1.12); }
  .sr-popup-btn-ico { font-size: 15px; }
  body.dark .sr-popup-btn { background: #2f7ef0; border-color: #2f7ef0; }
  /* -- détail -- */
  .sr-popup-body {
    padding: 4px 16px 18px;
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    color: var(--text-default, #333333);
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .sr-detail-meta {
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted, #666666);
    margin: 10px 0 5px;
  }
  .sr-detail-text {
    font-size: 13px;
    line-height: 1.6;
    margin: 6px 0;
    color: var(--text-default, #333333);
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .sr-detail-author {
    font-size: 13px;
    margin: 6px 0;
    color: var(--text-default, #333333);
  }
  .sr-detail-affil { font-size: 12px; color: var(--text-muted, #666666); }
  .sr-detail-year {
    display: inline-block;
    font-size: 11.5px;
    font-weight: 700;
    color: #7b4fc0;
    margin: 2px 0 4px;
  }
  body.dark .sr-detail-year { color: #b89be0; }
  .sr-detail-note {
    font-size: 11.5px;
    color: var(--text-muted, #666666);
    margin-top: 8px;
    font-style: italic;
  }
  .sr-detail-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 12.5px;
    margin: 6px 0 10px;
  }
  .sr-detail-table td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--bg-modal-source, #e6e6e6);
    color: var(--text-default, #333333);
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .sr-detail-table td:last-child {
    text-align: right;
    font-variant-numeric: tabular-nums;
    width: 38%;
  }
  .sr-detail-links { margin-top: 10px; font-size: 12.5px; }
  .sr-detail-links strong { color: var(--text-default, #333333); }
  .sr-detail-links ul { margin: 4px 0 0; padding-left: 18px; }
  .sr-detail-links li { margin: 3px 0; }
  .sr-detail-links a { color: #1f6feb; overflow-wrap: anywhere; word-break: break-word; }
  body.dark .sr-detail-links a { color: #6cb6ee; }
  /* liseré de couleur du pop-up détail selon la nature */
  .sr-popup.sr-kind-incident { border-top: 4px solid #d4761c; }
  .sr-popup.sr-kind-resign   { border-top: 4px solid #c0392b; }
  .sr-popup.sr-kind-cost     { border-top: 4px solid #1f8f4e; }
  .sr-popup.sr-kind-reco     { border-top: 4px solid #7b4fc0; }
  .sr-popup.sr-kind-defav    { border-top: 4px solid #d4a017; }
  .sr-popup.sr-kind-wait     { border-top: 4px solid #2f7ef0; }
