
/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg:          #f4f5f9;
  --bg2:         #eceef5;
  --panel:       #ffffff;
  --sub:         #e8eaf2;
  --border:      rgba(0,0,0,0.08);
  --border-glow: rgba(99,102,241,0.28);
  --text:        #1e1b4b;
  --muted:       #64748b;
  --gold:        #d97706;
  --gold-dim:    rgba(217,119,6,0.1);
  --silver:      #64748b;
  --silver-dim:  rgba(100,116,139,0.1);
  --bronze:      #b45309;
  --bronze-dim:  rgba(180,83,9,0.1);
  --violet:      #6366f1;
  --violet-dim:  rgba(99,102,241,0.1);
  --green:       #059669;
  --green-dim:   rgba(5,150,105,0.1);
  --amber:       #d97706;
  --amber-dim:   rgba(217,119,6,0.1);
  --red:         #dc2626;
  --red-dim:     rgba(220,38,38,0.1);
  --sun:         #ea580c;
  --btn-grad:    linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  --btn-launch:  linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 10% 0%, rgba(99,102,241,0.06), transparent),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(245,158,11,0.05), transparent);
  color: var(--text);
  min-height: 100vh;
}

/* === HEADER === */
.header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 16px;
  padding: 14px 28px;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 var(--border);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(90deg, #6366f1, #d97706);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.3px;
}
.header-brand p { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.header-disclaimer {
  width: 100%;
  order: 10;
  margin: 0;
  padding: 6px 10px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  font-size: 11px;
  color: #92400e;
  line-height: 1.4;
}

/* === LAYOUT === */
.app-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 0;
  min-height: calc(100vh - 64px);
}

/* === PARAMS SIDEBAR === */
.params-sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
  max-height: calc(100vh - 64px);
  position: sticky;
  top: 64px;
}
/* === SIDEBAR STEPS === */
.step-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}
.step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--violet);
  color: white;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.step-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.step-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 12px;
  line-height: 1.5;
}
.sliders-group { display: flex; flex-direction: column; gap: 2px; }
.geo-checks { margin-top: 12px; }
.geo-checks-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 0 0 8px;
}
.label-opt { font-size: 11px; color: var(--muted); font-weight: 400; }

/* Advanced collapsible */
.advanced-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 12px;
  overflow: hidden;
}
.advanced-toggle {
  list-style: none;
  padding: 12px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
  transition: color 0.15s;
}
.advanced-toggle::-webkit-details-marker { display: none; }
.advanced-block[open] .advanced-toggle { color: var(--violet); }
.advanced-toggle:hover { color: var(--text); }
.advanced-body { padding: 4px 16px 16px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}
.field input, .field select {
  width: 100%;
  padding: 10px 13px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.2s;
  outline: none;
}
.field input:focus, .field select:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(167,139,250,0.12);
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--sub);
  border-radius: 4px;
  padding: 0;
  cursor: pointer;
  border: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: var(--violet);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(167,139,250,0.5);
}
.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.slider-row input { flex: 1; }
.slider-val {
  min-width: 36px;
  text-align: right;
  font-size: 14px;
  font-weight: 700;
  color: var(--violet);
}

.field-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-3col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.filter-group {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
}
.filter-group h3 {
  margin: 0 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 600;
}
.checks-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.15s;
}
.check-item:hover { background: rgba(255,255,255,0.04); }
.check-item input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--violet);
  cursor: pointer;
  flex-shrink: 0;
}

/* Mode tabs */
.mode-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}
.mode-tab {
  flex: 1;
  padding: 10px 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  line-height: 1.4;
}
.mode-tab small { font-size: 10px; font-weight: 400; display: block; margin-top: 1px; }
.mode-tab.active {
  background: var(--violet-dim);
  border-color: var(--violet);
  color: var(--violet);
}

/* Buttons */
.btn-launch {
  width: 100%;
  padding: 14px;
  background: var(--btn-launch);
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: opacity 0.2s, transform 0.1s;
  box-shadow: 0 4px 20px rgba(245,158,11,0.25);
}
.btn-launch:hover { opacity: 0.92; transform: translateY(-1px); }
.btn-launch:active { transform: translateY(0); }
.btn-launch:disabled { opacity: 0.6; cursor: wait; }

.btn-refresh {
  padding: 9px 16px;
  background: transparent;
  border: 1px solid var(--border-glow);
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-refresh:hover {
  border-color: var(--violet);
  color: var(--violet);
  background: var(--violet-dim);
}

/* Alert boxes */
.alert {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  display: none;
}
.alert-error {
  background: var(--red-dim);
  border: 1px solid rgba(248,113,113,0.25);
  color: #fca5a5;
}
.alert-info {
  background: var(--violet-dim);
  border: 1px solid rgba(167,139,250,0.25);
  color: #c4b5fd;
}

/* Divider */
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* === RESULTS AREA === */
.results-area { padding: 24px; overflow-y: auto; }

/* KPI bar */
.kpis-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
}
.kpi-card.kpi-count::before { background: var(--violet); }
.kpi-card.kpi-score::before { background: var(--gold); }
.kpi-card.kpi-dept::before  { background: var(--green); }

.kpi-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 600; }
.kpi-value {
  font-size: 28px;
  font-weight: 800;
  margin-top: 6px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-card.kpi-count .kpi-value { color: var(--violet); }
.kpi-card.kpi-score .kpi-value { color: var(--gold); }
.kpi-card.kpi-dept  .kpi-value { font-size: 18px; color: var(--green); }

/* === RESULT CARDS === */
.results-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }

/* Carte résultat de base */
.res-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 16px;
  align-items: center;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
}
.res-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.25);
}

/* Rank 1 — OR */
.res-card.rank-1 {
  background: linear-gradient(135deg, #fffbeb 0%, var(--panel) 60%);
  border-color: rgba(217,119,6,0.3);
  box-shadow: 0 0 0 1px rgba(217,119,6,0.08), 0 4px 24px rgba(217,119,6,0.08);
  padding: 22px 24px;
}
.res-card.rank-1::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, #f59e0b, #fde68a, #f59e0b);
}

/* Rank 2 — ARGENT */
.res-card.rank-2 {
  border-color: rgba(176,184,200,0.30);
  box-shadow: 0 0 0 1px rgba(176,184,200,0.08);
}
.res-card.rank-2::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, #94a3b8, #cbd5e1, #94a3b8);
}

/* Rank 3 — BRONZE */
.res-card.rank-3 {
  border-color: rgba(212,135,74,0.28);
  box-shadow: 0 0 0 1px rgba(212,135,74,0.08);
}
.res-card.rank-3::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, #d4874a, #fbbf7c, #d4874a);
}

/* Badge de rang */
.rank-badge {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 900;
  flex-shrink: 0;
}
.rank-1 .rank-badge {
  width: 56px; height: 56px;
  font-size: 24px;
  background: linear-gradient(135deg, #f59e0b, #fde68a);
  color: #78350f;
  box-shadow: 0 4px 12px rgba(245,158,11,0.35);
}
.rank-2 .rank-badge {
  background: linear-gradient(135deg, #94a3b8, #e2e8f0);
  color: #1e293b;
  box-shadow: 0 4px 10px rgba(148,163,184,0.25);
}
.rank-3 .rank-badge {
  background: linear-gradient(135deg, #d4874a, #f5c89a);
  color: #431407;
  box-shadow: 0 4px 10px rgba(212,135,74,0.25);
}
.rank-other .rank-badge {
  background: var(--sub);
  color: var(--muted);
  font-size: 18px;
  border: 1px solid var(--border);
}

/* Contenu carte */
.res-body { min-width: 0; }
.res-code { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0.5px; margin-bottom: 2px; }
.res-name {
  font-size: 20px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  color: var(--text);
}
.rank-1 .res-name { font-size: 24px; color: #92400e; }
.res-location {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}
/* Meta chips (score mini, postes, pression, distance) */
.res-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}
.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  background: var(--sub);
  border: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}
.meta-chip strong { color: var(--violet); font-weight: 800; }
.meta-chip-good { background: var(--green-dim); border-color: rgba(52,211,153,0.25); color: var(--green); }
.meta-chip-good strong { color: var(--green); }
.meta-chip-mid  { background: var(--amber-dim); border-color: rgba(251,191,36,0.25); color: var(--amber); }
.meta-chip-mid strong { color: var(--amber); }
.meta-chip-bad  { background: var(--red-dim); border-color: rgba(248,113,113,0.25); color: var(--red); }
.meta-chip-bad strong { color: var(--red); }

/* Tooltip global */
.has-tooltip { cursor: help; }
#chip-tooltip-global {
  display: none;
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--border-glow);
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text);
  white-space: normal;
  width: 230px;
  line-height: 1.55;
  box-shadow: 0 8px 28px rgba(0,0,0,0.55);
  z-index: 9999;
  pointer-events: none;
}

.res-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}
.tag-verdict-ok    { background: var(--green-dim); border-color: rgba(52,211,153,0.3); color: var(--green); }
.tag-verdict-mid   { background: var(--amber-dim); border-color: rgba(251,191,36,0.3); color: var(--amber); }
.tag-verdict-bad   { background: var(--red-dim);   border-color: rgba(248,113,113,0.3); color: var(--red); }
.tag-verdict-unk   { background: var(--sub);       border-color: var(--border);         color: var(--muted); }
.tag-sun           { background: rgba(251,146,60,0.12); border-color: rgba(251,146,60,0.3); color: #fb923c; }
.tag-geo           { background: var(--violet-dim); border-color: rgba(167,139,250,0.2); color: #c4b5fd; }

/* Côté droit: score */
.res-score { text-align: center; flex-shrink: 0; }
.score-ring {
  width: 64px; height: 64px;
  position: relative;
}
.rank-1 .score-ring { width: 76px; height: 76px; }
.score-arc {
  width: 100%; height: 100%;
}
.score-arc circle {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
}
.score-arc .track   { stroke: var(--sub); }
.score-arc .fill    { stroke: var(--green); stroke-dasharray: 157; transition: stroke-dashoffset 0.6s ease; }
.rank-1 .score-arc .fill { stroke: var(--gold); }
.rank-2 .score-arc .fill { stroke: var(--silver); }
.rank-3 .score-arc .fill { stroke: var(--bronze); }
.score-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.score-pct {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.rank-1 .score-pct { font-size: 15px; color: var(--gold); font-weight: 900; }
.score-sub { font-size: 9px; color: var(--muted); margin-top: 1px; letter-spacing: 0.3px; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty-icon { font-size: 48px; display: block; margin-bottom: 12px; }
.empty-state p { margin: 0; font-size: 15px; }

/* Loading state */
.loading-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--violet);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === CARTE === */
.map-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
}
.map-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.map-header h2 { margin: 0; font-size: 14px; font-weight: 700; }
.map-note { font-size: 12px; color: var(--muted); }
.map-canvas-wrap {
  position: relative;
  height: 360px;
  background:
    radial-gradient(ellipse 70% 60% at 40% 45%, rgba(99,102,241,0.06), transparent),
    radial-gradient(ellipse 50% 40% at 70% 70%, rgba(245,158,11,0.04), transparent),
    var(--bg2);
}
.map-dot {
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
  transition: transform 0.2s;
}
.map-dot:hover { transform: translate(-50%, -50%) scale(1.4); }
.map-dot.rank-1 {
  width: 18px; height: 18px;
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(251,191,36,0.2), 0 0 16px rgba(251,191,36,0.4);
  z-index: 10;
}
.map-dot.rank-2 {
  width: 14px; height: 14px;
  background: var(--silver);
  box-shadow: 0 0 0 3px rgba(176,184,200,0.2);
  z-index: 9;
}
.map-dot.rank-3 {
  width: 13px; height: 13px;
  background: var(--bronze);
  box-shadow: 0 0 0 3px rgba(212,135,74,0.2);
  z-index: 8;
}
.map-dot.rank-other {
  width: 10px; height: 10px;
  background: var(--violet);
  box-shadow: 0 0 0 2px rgba(167,139,250,0.15);
}
.map-tooltip {
  position: absolute;
  transform: translate(-50%, calc(-100% - 10px));
  background: var(--panel);
  border: 1px solid var(--border-glow);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  z-index: 20;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

/* === SECTION TITLE === */
.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 700;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* === LAYOUT RÉSULTATS + CARTE CÔTE À CÔTE === */
.results-map-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

/* === CARTE LEAFLET === */
.map-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  position: sticky;
  top: calc(64px + 24px);
}
#leaflet-map {
  height: 520px;
  width: 100%;
  background: #e8edf2;
}

/* Leaflet thème clair */
.leaflet-container { background: var(--bg2); font-family: 'Inter', sans-serif; }
.leaflet-control-zoom a {
  background: var(--panel) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12) !important;
}
.leaflet-control-zoom a:hover { background: var(--sub) !important; }
.leaflet-control-attribution {
  background: rgba(255,255,255,0.85) !important;
  color: var(--muted) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--violet) !important; }

/* Popups Leaflet thème clair */
.leaflet-popup-content-wrapper {
  background: var(--panel) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 14px !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12) !important;
  padding: 0 !important;
}
.leaflet-popup-content { margin: 0 !important; padding: 14px 16px !important; }
.leaflet-popup-tip { background: var(--panel) !important; }
.leaflet-popup-close-button { color: var(--muted) !important; font-size: 18px !important; top: 8px !important; right: 10px !important; }

.popup-rank    { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 4px; }
.popup-dept    { font-size: 16px; font-weight: 800; color: var(--text); }
.popup-loc     { font-size: 13px; color: var(--muted); margin-top: 3px; }
.popup-score   { font-size: 13px; font-weight: 700; margin-top: 8px; }
.popup-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 6px 12px;
  background: var(--violet-dim);
  border: 1px solid rgba(167,139,250,0.3);
  border-radius: 8px;
  color: var(--violet);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.popup-btn:hover { background: rgba(167,139,250,0.2); }

/* Marqueurs personnalisés */
.marker-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.7);
  font-weight: 900;
  font-size: 11px;
  color: #1e1b4b;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  cursor: pointer;
  transition: transform 0.15s;
}
.marker-pin:hover { transform: scale(1.15); }
.marker-gold   { background: radial-gradient(circle at 35% 35%, #fde68a, #f59e0b); width: 36px; height: 36px; font-size: 16px; box-shadow: 0 0 0 4px rgba(217,119,6,0.2), 0 4px 14px rgba(217,119,6,0.3); }
.marker-silver { background: radial-gradient(circle at 35% 35%, #e2e8f0, #94a3b8); width: 30px; height: 30px; box-shadow: 0 2px 8px rgba(0,0,0,0.18); }
.marker-bronze { background: radial-gradient(circle at 35% 35%, #fcd9a0, #d97706); width: 28px; height: 28px; box-shadow: 0 2px 8px rgba(0,0,0,0.18); }
.marker-other  { background: radial-gradient(circle at 35% 35%, #a5b4fc, #6366f1); width: 22px; height: 22px; color: #fff; font-size: 9px; box-shadow: 0 2px 6px rgba(0,0,0,0.15); }

/* === BOUTON VILLES (dans les cartes résultats) === */
.btn-cities {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border-glow);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 10px;
  width: auto;
}
.btn-cities:hover {
  background: var(--violet-dim);
  border-color: var(--violet);
  color: var(--violet);
}

/* === LIEN FICHE DÉPARTEMENT (dans les cartes résultats) === */
/* === CARTE DÉPARTEMENT CIBLE === */
.rank-target {
  border: 2px solid var(--violet) !important;
  box-shadow: 0 0 0 4px rgba(99,102,241,.1), 0 4px 16px rgba(99,102,241,.15) !important;
}
.target-banner {
  background: linear-gradient(90deg, var(--violet), #818cf8);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 5px 16px;
  border-radius: 10px 10px 0 0;
  margin: -16px -16px 14px;
}

.btn-fiche {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--violet-dim);
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: 8px;
  color: var(--violet);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
  text-decoration: none;
  width: fit-content;
}
.btn-fiche:hover {
  background: var(--violet);
  color: #fff;
  border-color: var(--violet);
  box-shadow: 0 2px 8px rgba(99,102,241,0.25);
}

.btn-compare {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #fff;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: box-shadow 0.2s, transform 0.15s;
  box-shadow: 0 2px 12px rgba(99,102,241,0.3);
  width: 100%;
  justify-content: center;
}
.btn-compare:hover {
  box-shadow: 0 4px 20px rgba(99,102,241,0.45);
  transform: translateY(-1px);
}

/* === MODAL VILLES === */
.city-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 27, 75, 0.4);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.city-modal-overlay.open { display: flex; }

.city-modal-panel {
  background: var(--panel);
  border: 1px solid var(--border-glow);
  border-radius: 22px;
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.city-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.city-modal-dept   { font-size: 12px; color: var(--violet); font-weight: 700; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 4px; }
.city-modal-title  { margin: 0; font-size: 20px; font-weight: 800; }
.city-modal-close {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--sub);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}
.city-modal-close:hover { background: var(--red-dim); color: var(--red); border-color: rgba(248,113,113,0.3); }

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

/* Grille 2 colonnes pour les villes */
.city-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.city-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  transition: background 0.15s;
}
.city-row:hover { background: var(--sub); }
.city-rank {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.city-rank-top { background: var(--gold-dim); color: var(--gold); }
.city-rank-mid { background: var(--violet-dim); color: var(--violet); }
.city-rank-low { background: var(--sub); color: var(--muted); }
.city-name { font-size: 13px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.city-pop  { font-size: 11px; color: var(--muted); white-space: nowrap; }
.city-error { padding: 32px; text-align: center; color: var(--muted); }

/* === BOUTON INLINE CALCUL BARÈME === */
.field label { display: flex; align-items: center; justify-content: space-between; }
.btn-calc-inline {
  padding: 2px 8px;
  background: var(--violet-dim);
  border: 1px solid rgba(167,139,250,0.35);
  border-radius: 6px;
  color: var(--violet);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-calc-inline:hover { background: rgba(167,139,250,0.2); }

/* === MODAL CALCUL BARÈME === */
.bareme-modal-panel { max-width: 480px; }
.bareme-modal-body  { padding: 16px 24px 24px; }

.bareme-disclaimer {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 18px;
}
.bareme-form { display: flex; flex-direction: column; gap: 2px; }
.bareme-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--violet);
  font-weight: 700;
  margin-bottom: 8px;
}
.calc-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.calc-input {
  width: 80px !important;
  text-align: center;
}
.calc-unit { font-size: 12px; color: var(--muted); }
.calc-check {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  margin-bottom: 6px;
  justify-content: flex-start;
  gap: 8px;
}
.calc-bonus {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--green);
  background: var(--green-dim);
  border-radius: 5px;
  padding: 2px 7px;
}

.bareme-result {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 20px;
  margin: 20px 0 16px;
  text-align: center;
}
.bareme-result-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
}
.bareme-result-value {
  font-size: 36px;
  font-weight: 900;
  color: var(--gold);
  line-height: 1.1;
}
.bareme-result-detail {
  margin-top: 10px;
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}
.calc-line { padding: 1px 0; }

.bareme-actions {
  display: flex;
  gap: 10px;
}
.btn-apply-bareme {
  flex: 1;
  padding: 14px;
  background: var(--green-dim);
  border: 1px solid rgba(52,211,153,0.35);
  border-radius: 12px;
  color: var(--green);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-apply-bareme:hover { background: rgba(52,211,153,0.2); }

/* === RESPONSIVE === */
@media (max-width: 1400px) {
  .results-map-grid { grid-template-columns: 1fr; }
  .map-section { position: static; }
}
@media (max-width: 1200px) {
  .app-layout { grid-template-columns: 1fr; }
  .params-sidebar { max-height: none; position: static; }
  .kpis-bar { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .res-card { grid-template-columns: 44px 1fr auto; gap: 12px; }
  .rank-1 .res-name { font-size: 18px; }
  .city-grid { grid-template-columns: 1fr; }
}
