:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-hover: #1c2230;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #f58e2c;
  --accent-soft: rgba(245, 142, 44, 0.18);
  --info: #7dd3fc;
  --info-soft: rgba(125, 211, 252, 0.15);
  --border: #30363d;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body {
  display: flex;
  flex-direction: column;
}

/* ─────────── Header ─────────── */
header {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.header-left h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.header-left h1 span {
  color: var(--muted);
  font-weight: 400;
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.help-btn {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(245, 142, 44, 0.4);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.help-btn:hover {
  background: rgba(245, 142, 44, 0.3);
}

/* ─────────── Layout ─────────── */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 380px 1fr;
  min-height: 0;
  position: relative;
}

#sidebar {
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 0 20px 18px;
  background: var(--panel);
  font-size: 13px;
  line-height: 1.55;
}

/* ─────────── Tabs ─────────── */
.tabs {
  display: flex;
  position: sticky;
  top: 0;
  height: 50px;
  align-items: stretch;
  background: var(--panel);
  z-index: 5;
  margin: 0 -20px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
}

.tab {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 0 8px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-count {
  font-weight: 400;
  font-size: 11px;
  color: var(--muted);
  margin-left: 4px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  padding-top: 18px;
}

#sidebar h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 24px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

#sidebar section:first-child h2 {
  margin-top: 0;
}

#map {
  height: 100%;
  width: 100%;
}

/* ─────────── Callout ─────────── */
.callout {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding: 12px 14px;
  border-radius: 4px;
  margin-bottom: 14px;
}

.callout h2 {
  margin-top: 0 !important;
  border-bottom: none !important;
  color: var(--accent) !important;
}

.callout p {
  margin: 6px 0;
  font-size: 13px;
  line-height: 1.55;
}

.muted-small {
  color: var(--muted);
  font-size: 11.5px;
  margin: 4px 0;
}

.footnote {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

/* ─────────── Step list ─────────── */
.howto-steps {
  list-style: none;
  padding: 0;
  margin: 0;
}

.howto-steps li {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 12.5px;
  align-items: flex-start;
}

.howto-steps li:last-child {
  border-bottom: none;
}

.step-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

/* ─────────── Signal list (familles) ─────────── */
.signal-list {
  list-style: none;
  padding: 0;
  margin: 8px 0;
}

.signal-list li {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
  align-items: flex-start;
}

.signal-list li:last-child {
  border-bottom: none;
}

.signal-list .emoji {
  font-size: 22px;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
  line-height: 1;
  padding-top: 2px;
}

.signal-list strong {
  font-size: 13px;
  color: var(--text);
}

.signal-list strong em {
  color: var(--accent);
  font-style: normal;
  font-weight: 500;
  font-size: 11px;
}

.signal-list p {
  margin: 4px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
}

.signal-list p em {
  color: var(--text);
  font-style: italic;
  opacity: 0.9;
}

/* ─────────── Info tip (ⓘ) ─────────── */
.info-tip {
  display: inline-block;
  font-size: 11px;
  color: var(--accent);
  cursor: pointer;
  margin-left: 2px;
  font-weight: 700;
  vertical-align: super;
  user-select: none;
  transition: color 0.15s, transform 0.15s;
}

.info-tip:hover {
  color: #fff;
  transform: scale(1.15);
}

/* ─────────── Custom popover (above clicked ⓘ) ─────────── */
.info-popover {
  position: fixed;
  background: #1c2230;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 12px;
  max-width: 320px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  z-index: 2000;
  color: var(--text);
  line-height: 1.55;
}

.info-popover.hidden {
  display: none;
}

.info-popover-text {
  white-space: pre-wrap;
}

/* Tail pointing DOWN from the bottom of popover (default state, popover above icon). */
.info-popover-tail {
  position: absolute;
  bottom: -8px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--border);
  transform: translateX(-8px);
}

.info-popover-tail::after {
  content: "";
  position: absolute;
  top: -9px;
  left: -7px;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 7px solid #1c2230;
}

/* Flipped : popover BELOW icon — tail points UP at the top. */
.info-popover.flip .info-popover-tail {
  bottom: auto;
  top: -8px;
  border-top: none;
  border-bottom: 8px solid var(--border);
}

.info-popover.flip .info-popover-tail::after {
  top: auto;
  bottom: -9px;
  border-top: none;
  border-bottom: 7px solid #1c2230;
}

/* ─────────── Layer toggles ─────────── */
.layer-toggle {
  margin: 12px 0 14px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border);
}

.layer-toggle:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
}

.layer-toggle label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  padding: 2px 0;
}

.layer-toggle label.inline {
  display: inline-flex;
  align-items: center;
  margin: 0 12px 0 4px;
  font-weight: 400;
  cursor: pointer;
}

.layer-toggle label input {
  margin-right: 8px;
}

.layer-desc {
  margin: 6px 0 4px;
  padding-left: 22px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.55;
}

.layer-desc code {
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 5px;
  border-radius: 2px;
  font-size: 10.5px;
  color: var(--text);
}

.legend-list {
  list-style: none;
  padding-left: 22px;
  margin: 4px 0;
  font-size: 11.5px;
  color: var(--muted);
}

.legend-list li {
  padding: 3px 0;
  line-height: 1.5;
}

.dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 5px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.dot-orange { background: #f58e2c; }
.dot-gray { background: #8b949e; }
.dot-blue { background: #7dd3fc; }
.dot-red { background: #f87171; }
.dot-yellow { background: #fbbf24; }
.dot-green { background: #34d399; }

/* ─────────── Score scale ─────────── */
.score-scale {
  margin: 10px 0 4px 22px;
}

.scale-bar {
  height: 8px;
  border-radius: 2px;
  background: linear-gradient(90deg, #000004 0%, #3b0f70 25%, #8c2981 50%, #de4968 75%, #fe9f6d 90%, #fcfdbf 100%);
}

.scale-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
}

/* ─────────── Stats grid ─────────── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0;
}

.stat-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  text-align: center;
}

.stat-card.highlight {
  background: var(--accent-soft);
  border-color: rgba(245, 142, 44, 0.4);
}

.stat-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}

.stat-card.highlight .stat-num {
  color: var(--accent);
}

.stat-label {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.3;
}

.stats-details {
  margin-top: 8px;
  padding: 8px 0;
  font-size: 11.5px;
}

.stats-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stats-details .row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px dashed var(--border);
}

.stats-details .row span:last-child {
  color: var(--accent);
  font-weight: 600;
}

/* ─────────── Sites tab : liste complète + filtres ─────────── */
.sites-header {
  position: sticky;
  top: 50px; /* aligne pile avec le bas de la barre d'onglets sticky (height 50) */
  background: var(--panel);
  z-index: 4;
  margin: 0 -20px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}

#tab-sites.active {
  /* Annule le padding-top par défaut puisque .sites-header gère son propre padding et ne doit pas avoir de gap au-dessus */
  padding-top: 0;
}

.sites-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.filter-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 5px 10px;
  font-size: 11.5px;
  font-family: inherit;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.filter-btn:hover {
  color: var(--text);
  border-color: rgba(245, 142, 44, 0.4);
}

.filter-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(245, 142, 44, 0.5);
  font-weight: 600;
}

.sites-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.site-item {
  padding: 9px 10px;
  margin: 0 -10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px dashed var(--border);
}

.site-item:last-child {
  border-bottom: none;
}

.site-item:hover,
.site-item:focus {
  background: rgba(245, 142, 44, 0.08);
  outline: none;
}

.site-item:focus {
  box-shadow: inset 0 0 0 1px rgba(245, 142, 44, 0.5);
}

.site-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.site-rank {
  color: var(--accent);
  font-weight: 700;
  min-width: 36px;
}

.site-area {
  color: var(--text);
  font-weight: 500;
}

.site-score {
  color: var(--muted);
  font-size: 11px;
  margin-left: auto;
}

.site-arrow {
  color: var(--muted);
  font-size: 16px;
  margin-left: 6px;
  transition: color 0.12s, transform 0.12s;
}

.site-item:hover .site-arrow {
  color: var(--accent);
  transform: translateX(2px);
}

.site-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.site-coord {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 10px;
  color: var(--muted);
  margin-left: auto;
}

.site-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.site-badge-discovery {
  background: var(--accent-soft);
  color: var(--accent);
}

.site-badge-known {
  background: rgba(139, 148, 158, 0.18);
  color: var(--muted);
}

.site-badge-confirm {
  background: rgba(76, 175, 80, 0.15);
  color: #8cd596;
}

.site-badge-dismissed {
  background: rgba(125, 211, 252, 0.12);
  color: var(--info);
}

/* ─────────── Watchlist (legacy, retiré du HTML) ─────────── */
#watchlist ol {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
}

.wl-item {
  padding: 9px 10px;
  margin: 0 -10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px dashed var(--border);
}

.wl-item:last-child {
  border-bottom: none;
}

.wl-item:hover,
.wl-item:focus {
  background: rgba(245, 142, 44, 0.08);
  outline: none;
}

.wl-item:focus {
  box-shadow: inset 0 0 0 1px rgba(245, 142, 44, 0.5);
}

.wl-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.wl-rank {
  color: var(--accent);
  font-weight: 700;
  min-width: 32px;
}

.wl-area {
  color: var(--text);
  font-weight: 500;
}

.wl-score {
  color: var(--muted);
  font-size: 11px;
  margin-left: auto;
}

.wl-arrow {
  color: var(--muted);
  font-size: 16px;
  margin-left: 6px;
  transition: color 0.12s, transform 0.12s;
}

.wl-item:hover .wl-arrow {
  color: var(--accent);
  transform: translateX(2px);
}

.wl-coord {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

/* ─────────── Isolate button (bottom-left of map) ─────────── */
.map-btn {
  position: absolute;
  z-index: 10;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 7px 12px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.map-btn:hover {
  background: var(--panel-hover);
  border-color: rgba(245, 142, 44, 0.5);
}

.map-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(245, 142, 44, 0.5);
  font-weight: 700;
}

.isolate-btn {
  bottom: 30px;
  left: 12px;
}

.isolate-icon {
  font-size: 14px;
  line-height: 1;
}

/* ─────────── Basemap control (top-left of map) ─────────── */
.basemap-control {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  display: flex;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  font-size: 12px;
}

.basemap-control button {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  transition: background 0.12s, color 0.12s;
}

.basemap-control button:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.basemap-control button.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.basemap-control button + button {
  border-left: 1px solid var(--border);
}

.basemap-control button[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ─────────── Timelapse slider ─────────── */
.timelapse-control {
  position: absolute;
  top: 52px;
  left: 12px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  font-size: 12px;
  color: var(--text);
  min-width: 260px;
}

.timelapse-control.hidden {
  display: none;
}

.timelapse-control label {
  color: var(--muted);
  font-weight: 500;
}

.timelapse-control input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.timelapse-control #timelapse-month {
  font-weight: 700;
  color: var(--accent);
  min-width: 60px;
  text-align: right;
}

/* ─────────── Limits list ─────────── */
.limits-list {
  list-style: none;
  padding: 0;
  margin: 4px 0;
}

.limits-list li {
  padding: 6px 0 6px 16px;
  position: relative;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  border-bottom: 1px dashed var(--border);
}

.limits-list li:last-child {
  border-bottom: none;
}

.limits-list li::before {
  content: "▸";
  color: var(--accent);
  position: absolute;
  left: 0;
}

.limits-list strong {
  color: var(--text);
}

/* ─────────── Glossary ─────────── */
.glossary {
  margin: 0;
  font-size: 12px;
}

.glossary dt {
  font-weight: 600;
  color: var(--accent);
  margin-top: 12px;
}

.glossary dd {
  margin: 4px 0 0;
  padding: 0;
  color: var(--muted);
  line-height: 1.55;
}

.glossary dd em {
  color: var(--text);
  font-style: italic;
}

/* ─────────── Sidebar footer ─────────── */
#sidebar footer {
  margin-top: 32px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

#sidebar a {
  color: var(--accent);
}

/* ─────────── Popup ─────────── */
.maplibregl-popup-content {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 12px;
  padding: 14px 16px;
  max-width: 400px;
}

.maplibregl-popup-tip {
  border-top-color: var(--panel) !important;
  border-bottom-color: var(--panel) !important;
}

.maplibregl-popup-close-button {
  color: var(--text);
  font-size: 20px;
  padding: 4px 9px;
}

.popup h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--accent);
}

.popup h4 {
  margin: 12px 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}

.badge {
  display: block;
  padding: 7px 10px;
  border-radius: 4px;
  font-size: 11.5px;
  margin-bottom: 10px;
  line-height: 1.5;
}

.badge-help {
  font-size: 9px;
  margin-left: 3px;
  opacity: 0.7;
  cursor: help;
}

.badge.discovery {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(245, 142, 44, 0.4);
}

.badge.known {
  background: rgba(139, 148, 158, 0.18);
  color: var(--muted);
  border: 1px solid rgba(139, 148, 158, 0.3);
}

.popup-meta {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  gap: 5px 10px;
  font-size: 12px;
  margin-bottom: 4px;
}

.popup-meta span {
  color: var(--muted);
  cursor: help;
}

.popup-meta strong {
  color: var(--accent);
  font-weight: 600;
}

.popup-howto {
  margin: 10px 0 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  font-style: italic;
}

.up-color { color: var(--accent); font-weight: 600; }
.down-color { color: var(--info); font-weight: 600; }

/* ─────────── Contributions block ─────────── */
.contrib-block {
  margin-bottom: 6px;
}

.contrib-family {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}

.contrib-family:first-child {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.family-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}

.contrib-line {
  padding: 4px 0;
  cursor: help;
}

.contrib-text {
  font-size: 11.5px;
  color: var(--text);
  margin-bottom: 3px;
}

.contrib-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 3px;
}

.contrib-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.2s;
}

.contrib-bar-fill.up { background: var(--accent); }
.contrib-bar-fill.down { background: var(--info); }

.contrib-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 10.5px;
}

.stars {
  font-size: 12px;
  letter-spacing: 1px;
}

.stars.up { color: var(--accent); }
.stars.down { color: var(--info); }

.intensity-label {
  color: var(--text);
  font-style: italic;
  flex: 1;
}

.z-mini {
  font-family: ui-monospace, "SF Mono", monospace;
  color: var(--muted);
  opacity: 0.6;
  font-size: 9.5px;
}

.popup-foot {
  margin: 12px 0 0;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 11px;
  color: var(--muted);
}

.popup-foot a {
  color: var(--accent);
  text-decoration: none;
}

.popup-foot a:hover {
  text-decoration: underline;
}

.popup-foot .coord {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 10px;
  opacity: 0.7;
}

/* ─────────── Detail panel (right side, on candidate click) ─────────── */
.detail-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -6px 0 20px rgba(0, 0, 0, 0.45);
  overflow-y: auto;
  padding: 22px 22px 50px;
  z-index: 500;
  transform: translateX(0);
  transition: transform 0.25s ease-out;
  font-size: 13px;
  line-height: 1.55;
}

.detail-panel.hidden {
  transform: translateX(110%);
  pointer-events: none;
}

.detail-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 26px;
  cursor: pointer;
  width: 30px;
  height: 30px;
  line-height: 1;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
}

.detail-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

/* The HTML injected into the detail panel uses .popup styling — adjust for sidebar layout */
.detail-panel .popup h3 {
  margin: 0 0 12px;
  padding-right: 32px;
  font-size: 17px;
}

.detail-panel .popup h4 {
  margin: 16px 0 8px;
  font-size: 11px;
}

.detail-panel .popup-meta {
  font-size: 13px;
  margin: 4px 0 6px;
}

.detail-panel .popup-howto {
  font-size: 12.5px;
}

.detail-panel .contrib-line {
  padding: 6px 0;
}

.detail-panel .contrib-text {
  font-size: 12px;
}

/* ─────────── Labels (évaluation candidat) ─────────── */
.labels-section {
  margin-top: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.labels-section h4 {
  margin: 0 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
}

.label-row {
  margin-bottom: 8px;
}

.label-prefix {
  font-size: 11.5px;
  color: var(--muted);
  margin: 8px 0 6px;
}

.label-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.label-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  font-size: 11.5px;
  font-family: inherit;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.label-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(245, 142, 44, 0.4);
}

.label-confirm {
  background: rgba(76, 175, 80, 0.12);
  border-color: rgba(76, 175, 80, 0.4);
  color: #8cd596;
  font-weight: 600;
  width: 100%;
  text-align: center;
}

.label-confirm:hover {
  background: rgba(76, 175, 80, 0.2);
  border-color: rgba(76, 175, 80, 0.6);
}

.label-state {
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 12px;
  margin-bottom: 8px;
}

.label-state.confirmed {
  background: rgba(76, 175, 80, 0.12);
  border: 1px solid rgba(76, 175, 80, 0.4);
  color: #8cd596;
}

.label-state.dismissed {
  background: rgba(139, 148, 158, 0.15);
  border: 1px solid rgba(139, 148, 158, 0.3);
  color: var(--muted);
}

.label-reset {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 5px 10px;
  font-size: 11px;
  font-family: inherit;
  border-radius: 4px;
  cursor: pointer;
}

.label-reset:hover {
  background: var(--accent-soft);
}

.labels-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 8px 0 4px;
  padding: 7px 10px;
  background: rgba(245, 142, 44, 0.08);
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--text);
}

.labels-reset-all {
  background: transparent;
  border: 1px solid rgba(245, 142, 44, 0.4);
  color: var(--accent);
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
}

.labels-reset-all:hover {
  background: var(--accent-soft);
}

.stat-num-sub {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  margin-left: 2px;
}

/* ─────────── Modal d'aide ─────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px 32px;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-content h2 {
  margin-top: 0;
  font-size: 18px;
  color: var(--accent);
}

.modal-content ol {
  padding-left: 22px;
  margin: 16px 0;
}

.modal-content li {
  padding: 8px 0;
  font-size: 13.5px;
  line-height: 1.6;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  color: var(--muted);
  border: none;
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  line-height: 1;
}

.modal-close:hover { color: var(--text); }

/* ─────────── Responsive ─────────── */
@media (max-width: 800px) {
  main {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  #sidebar {
    max-height: 45vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .detail-panel {
    width: 100%;
    max-width: 100%;
  }
}
