/* =============================================================================
   Données & cartes – espace public du portail MEFPT (16/10/2026)
   Charte du portail : crème, bleu institutionnel, titres Fraunces, texte Instrument Sans
   ============================================================================= */
:root {
  --bg-cream: #f7f2e4; --bg-paper: #faf6ea; --bg-white: #fff;
  --ink: #0b1b2e; --ink-soft: #3d4a5c; --ink-softer: #55657a; --muted: #7a8593;
  --border: #e5dfc9; --border-strong: #d4cbac;
  --blue: #0b5cad; --blue-dark: #084a8c; --blue-deep: #062f5c; --blue-soft: rgba(11,92,173,.08); --blue-light: #3d8ee6;
  --gold: #b8925a; --gold-dark: #8a6c3f; --gold-soft: rgba(184,146,90,.12);
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Instrument Sans', 'Inter', system-ui, sans-serif;
  --r-lg: 16px; --r-xl: 22px;
  --shadow-md: 0 4px 16px rgba(11,27,46,.06), 0 1px 2px rgba(11,27,46,.04);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--sans); color: var(--ink); background: var(--bg-cream); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--blue-dark); }
.container { width: min(1240px, 100% - 48px); margin: 0 auto; }
.skip-link { position: absolute; left: -9999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }

/* En-tête */
.pub-header { position: sticky; top: 0; z-index: 50; background: rgba(247,242,228,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.pub-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 12px 0; }
.pub-brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; min-width: 0; }
.pub-brand-logo { width: 54px; height: 54px; border-radius: 14px; background: #fff; border: 1px solid var(--border); display: grid; place-items: center; flex: none; overflow: hidden; }
.pub-brand-logo img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.pub-brand-name { font-family: var(--serif); font-weight: 600; font-size: 15.5px; color: var(--blue-deep); line-height: 1.2; }
.pub-brand-sub { font-size: 12px; color: var(--ink-softer); margin-top: 2px; }
.pub-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.pub-nav a { text-decoration: none; color: var(--ink-soft); font-weight: 600; font-size: 14px; padding: 8px 12px; border-radius: 999px; transition: background .2s, color .2s; }
.pub-nav a:hover, .pub-nav a.is-active { background: var(--blue-soft); color: var(--blue-dark); }
.pub-nav .pub-nav-cta { background: var(--ink); color: #fff; margin-left: 6px; }
.pub-nav .pub-nav-cta:hover { background: var(--blue-dark); color: #fff; }
.pub-flag { display: flex; height: 3px; }
.pub-flag i { flex: 1; } .pub-flag i:nth-child(1) { background: #00853f; } .pub-flag i:nth-child(2) { background: #fcd116; } .pub-flag i:nth-child(3) { background: #e31b23; }

/* Bandeau */
.pub-hero { padding: 56px 0 34px; background: linear-gradient(180deg, #fbf7ec 0%, var(--bg-cream) 100%); border-bottom: 1px solid var(--border); }
.pub-eyebrow { font-size: 11.5px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: var(--blue-dark); margin-bottom: 14px; display: inline-flex; align-items: center; gap: 10px; }
.pub-eyebrow::before { content: ''; width: 22px; height: 1px; background: var(--blue); }
.pub-hero h1 { font-family: var(--serif); font-size: clamp(30px, 4vw, 46px); line-height: 1.1; letter-spacing: -.02em; font-weight: 600; margin: 0 0 16px; max-width: 900px; }
.pub-hero h1 em { font-style: italic; font-weight: 500; color: var(--blue-dark); }
.pub-lead { font-size: 16.5px; color: var(--ink-soft); max-width: 820px; margin: 0; }
.pub-crumb { font-size: 13px; color: var(--ink-softer); margin-bottom: 10px; }
.pub-crumb a { font-weight: 600; text-decoration: none; }
.pub-kpis { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.pub-kpi { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 12px 18px; min-width: 150px; box-shadow: var(--shadow-md); }
.pub-kpi b { display: block; font-family: var(--serif); font-size: 26px; font-weight: 600; color: var(--blue-deep); line-height: 1.1; font-variant-numeric: tabular-nums; }
.pub-kpi span { font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-softer); }

/* En-tête officiel (mefpt-entete.css) placé en haut des pages */
.pub-top { padding-top: 22px; }
.pub-top .me-ban { margin-bottom: 0; }
.pub-topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-top: 14px; }
.pub-topbar .pub-campagne { margin-top: 0; }
.pub-topbar .pub-crumb { margin: 0; }
.me-btn { cursor: pointer; font-family: var(--sans); }

/* Sélecteur de campagne */
.pub-campagne { display: inline-flex; align-items: center; gap: 10px; margin-top: 20px; padding: 8px 10px 8px 16px; background: #fff; border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow-md); }
.pub-campagne label { font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-softer); }
.pub-campagne select { height: 36px; border: 1px solid #d5dde6; border-radius: 999px; padding: 0 34px 0 12px; font: 600 13.5px var(--sans); color: var(--blue-deep); background: #fff; cursor: pointer; max-width: 420px; }
.pub-campagne select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(11,92,173,.15); }
@media (max-width: 760px) { .pub-campagne { display: flex; } .pub-campagne select { flex: 1; max-width: none; } }

/* Sections et panneaux */
.pub-section { padding: 34px 0 70px; }
.pub-section-title { font-family: var(--serif); font-size: 22px; font-weight: 600; margin: 34px 0 14px; color: var(--ink); }
.pub-section-title:first-child { margin-top: 0; }
.pub-panel { background: #fff; border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px 20px; min-width: 0; }
.pub-panel-title { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.pub-note { margin: 14px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.pub-notice { background: #fff; border: 1px dashed var(--border-strong); border-radius: var(--r-lg); padding: 22px 26px; font-size: 15px; color: var(--ink-soft); }
.pub-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: #fff; color: var(--ink); font: 600 13px var(--sans); text-decoration: none; cursor: pointer; transition: all .2s; }
.pub-btn:hover { border-color: var(--blue); color: var(--blue-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.pub-table-wrap { overflow-x: auto; }
.pub-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.pub-table th { background: var(--blue-deep); color: #fff; text-align: left; font-weight: 600; font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; padding: 10px 12px; }
.pub-table th:not(:first-child), .pub-table td:not(:first-child) { text-align: right; }
.pub-table td { padding: 9px 12px; border-bottom: 1px solid #efe9d8; font-variant-numeric: tabular-nums; }
.pub-table tbody tr:nth-child(even) td { background: #fcfaf3; }
.pub-table tfoot td { font-weight: 700; background: #f3f6fa; }

/* Statistiques en cartes */
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.stat-card { display: flex; flex-direction: column; gap: 8px; background: #fff; border: 1px solid var(--border); border-radius: var(--r-xl); padding: 22px 22px 18px; text-decoration: none; color: inherit; position: relative; overflow: hidden; transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease; animation: pub-rise .6s cubic-bezier(.16,1,.3,1) both; animation-delay: calc(min(var(--i, 0), 8) * 50ms); }
.stat-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--acc, var(--blue)); }
.stat-card:hover { transform: translateY(-4px); border-color: var(--acc, var(--blue)); box-shadow: 0 20px 40px -24px rgba(6,33,63,.35); }
.stat-card.acc-blue { --acc: #0b5cad; } .stat-card.acc-gold { --acc: #b8925a; } .stat-card.acc-green { --acc: #0a6b3a; } .stat-card.acc-plum { --acc: #6b3d6e; } .stat-card.acc-red { --acc: #b4343a; }
.stat-card-top { display: flex; justify-content: space-between; align-items: center; }
.stat-tag { font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--acc, var(--blue)); background: var(--bg-paper); border: 1px solid var(--border); border-radius: 999px; padding: 4px 9px; }
.stat-card h3 { margin: 4px 0 0; font-family: var(--serif); font-size: 18.5px; font-weight: 600; line-height: 1.25; letter-spacing: -.01em; }
.stat-card p { margin: 0; font-size: 13.5px; color: var(--ink-soft); line-height: 1.5; flex: 1; }
.stat-card-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.stat-headline { font-family: var(--serif); font-size: 20px; font-weight: 600; color: var(--blue-deep); font-variant-numeric: tabular-nums; }
.stat-go { font-size: 13px; font-weight: 600; color: var(--blue-dark); }
.stat-detail { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; align-items: start; }
.stat-chart { position: relative; height: 380px; }
.stat-nav { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
@keyframes pub-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Pied de page */
.pub-footer { background: var(--blue-deep); color: rgba(255,255,255,.8); padding: 30px 0; margin-top: 20px; }
.pub-footer-inner { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; font-size: 13px; }
.pub-footer strong { display: block; color: #fff; margin-bottom: 4px; }
.pub-footer-right { white-space: nowrap; }

@media (max-width: 1100px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } .stat-detail { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .container { width: min(1240px, 100% - 32px); }
  .pub-header-inner { flex-direction: column; align-items: flex-start; gap: 10px; }
  .pub-nav { justify-content: flex-start; }
  .pub-brand-name { font-size: 13.5px; }
  .stat-grid { grid-template-columns: 1fr; }
  .pub-hero { padding: 36px 0 26px; }
}

/* =============================================================================
   Carte thématique (mêmes classes que le module FORPRO)
   ============================================================================= */
.carte-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1100px) { .carte-grid { grid-template-columns: 1fr; } }
.carte-main { display: grid; gap: 18px; min-width: 0; }
.carte-param { position: sticky; top: 92px; }
@media (max-width: 1100px) { .carte-param { position: static; } }

.carte-label { display: block; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); margin: 0 0 6px; }
.carte-select { width: 100%; height: 42px; border: 1px solid #d5dde6; border-radius: 9px; padding: 0 10px; font-size: 13.5px; font-weight: 500; color: var(--ink); background: #fff; }
.carte-select:focus { outline: none; border-color: #0078d4; box-shadow: 0 0 0 3px rgba(0, 120, 212, .15); }
.carte-desc { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }

.carte-ensemble { margin: 14px 0 0; padding: 12px 14px; border-radius: 12px; background: #eaf3fc; border: 1px solid #cfe4f8; display: grid; gap: 2px; }
.carte-ens-lbl { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #084a8c; }
.carte-ensemble b { font-size: 24px; line-height: 1.1; color: #062f5c; font-variant-numeric: tabular-nums; }
.carte-ensemble small { font-size: 12px; color: var(--ink-soft); }

.carte-check { display: flex; align-items: flex-start; gap: 9px; margin: 14px 0 0; font-size: 13px; color: var(--ink); cursor: pointer; }
.carte-check input { margin-top: 3px; accent-color: #0078d4; }
.carte-hint { margin: 8px 0 0; font-size: 12px; color: var(--muted); line-height: 1.4; }
.carte-hint i { color: #0078d4; margin-right: 3px; }
.carte-sep { height: 1px; background: var(--border); margin: 16px 0 14px; }

/* Légende */
.carte-legende { display: grid; gap: 5px; }
.carte-leg-bar { height: 10px; border-radius: 5px; margin: 2px 0 2px; }
.carte-leg-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink); }
.carte-leg-row i { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .15); flex: none; }
.carte-leg-row b { font-variant-numeric: tabular-nums; min-width: 86px; }
.carte-leg-row span { color: var(--muted); }
.carte-leg-pt { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink); margin-top: 6px; }
.carte-leg-pt i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); flex: none; }

/* Classement */
.carte-rang { display: grid; gap: 3px; max-height: 330px; overflow-y: auto; }
.carte-rang-row { display: flex; align-items: center; gap: 8px; padding: 5px 7px; border-radius: 8px; font-size: 12.5px; cursor: pointer; transition: background-color .15s; }
.carte-rang-row:hover { background: rgba(0, 120, 212, .07); }
.carte-rang-row .n { width: 20px; height: 20px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 10.5px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex: none; }
.carte-rang-row .nom { flex: 1; font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.carte-rang-row .bar { width: 46px; height: 6px; background: #e9eef3; border-radius: 3px; overflow: hidden; flex: none; }
.carte-rang-row .bar b { display: block; height: 100%; border-radius: 3px; }
.carte-rang-row .val { min-width: 52px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Carte */
.carte-panel { padding: 16px 18px 12px; }
.carte-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.carte-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.carte-tools { display: flex; gap: 6px; }
.carte-tools .btn { height: 36px; width: 38px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.carte-map { height: 620px; border-radius: 14px; overflow: hidden; background: #dfe9f3; z-index: 1; border: 1px solid var(--border); }
@media (max-width: 760px) { .carte-map { height: 440px; } }
.carte-panel:fullscreen { background: #fff; padding: 16px; }
.carte-panel:fullscreen .carte-map { height: calc(100vh - 110px); }
.carte-credit { margin: 8px 0 0; font-size: 11px; color: var(--muted); }

.leaflet-container { font-family: inherit; font-size: 13px; }
.leaflet-tooltip.carte-tip { background: rgba(9, 22, 32, .88); color: #fff; border: 0; border-radius: 8px; padding: 6px 9px; font-size: 12px; box-shadow: 0 6px 18px -8px rgba(0, 0, 0, .6); }
.leaflet-tooltip.carte-tip::before { display: none; }
.carte-info { background: rgba(255, 255, 255, .97); padding: 12px 14px; border-radius: 12px; border-left: 4px solid #003f7f; box-shadow: 0 8px 24px -10px rgba(0, 38, 77, .45); min-width: 200px; max-width: 260px; font-size: 12.5px; }
.carte-info h6 { margin: 0 0 6px; font-size: 14px; font-weight: 800; color: #003f7f; padding-bottom: 4px; border-bottom: 3px solid #003f7f; }
.carte-info .row { display: flex; justify-content: space-between; gap: 10px; margin: 3px 0; }
.carte-info .row b { font-variant-numeric: tabular-nums; }
.carte-info .det { color: var(--muted); font-size: 11.5px; margin-top: 4px; }
.carte-info .muted { color: var(--muted); margin: 0; }
.carte-info .meter { margin-top: 8px; height: 7px; background: #e9eef3; border-radius: 4px; overflow: hidden; }
.carte-info .meter b { display: block; height: 100%; }
.carte-popup .leaflet-popup-content { margin: 12px 14px; font-size: 12.5px; line-height: 1.4; min-width: 190px; }
.carte-popup h6 { margin: 0 0 6px; font-size: 13.5px; font-weight: 800; color: #003f7f; }
.carte-popup .tag { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; background: #eaf3fc; color: #004e8f; margin: 2px 4px 4px 0; }
.carte-popup .tag.prive { background: #fbf3e2; color: #8a6c3f; }
.carte-popup .tag.ok { background: #e4f4ea; color: #1b6b3a; }
.carte-popup .tag.warn { background: #fdecec; color: #a12727; }
.carte-popup .lien { display: inline-block; margin-top: 6px; font-weight: 600; color: #0078d4; }

/* Tableau */
.carte-table td.cls { text-align: center; }
.carte-cls { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; color: #fff; white-space: nowrap; }
.carte-table .meter { display: inline-block; width: 90px; height: 10px; background: #e9eef3; border-radius: 5px; overflow: hidden; vertical-align: middle; margin-right: 8px; }
.carte-table .meter b { display: block; height: 100%; }
.carte-table tfoot td { font-weight: 700; background: #f3f6fa; }
.carte-table td.det { text-align: left; color: var(--muted); font-size: 12px; }


/* Impression : carte seule, en paysage */
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  .pub-header, .pub-footer, .pub-topbar, .carte-param, .carte-tools, .carte-credit, .pub-note, .carte-main > .pub-panel:not(.carte-panel) { display: none !important; }
  .pub-top { padding-top: 0; }
  .me-ban { margin-bottom: 10px; }
  .carte-grid { display: block; }
  .carte-panel { border: 0; padding: 0; box-shadow: none; }
  .carte-map { height: 165mm; border: 1px solid #999; border-radius: 0; }
  .carte-print-leg { display: block !important; }
  .leaflet-control-zoom, .leaflet-control-attribution, .carte-info { display: none !important; }
}
.carte-print-leg { display: none; }

/* Impression de la fiche statistique : en-tête officiel, tableau et graphique */
@media print {
  body { background: #fff; }
  .stat-nav, .stat-grid, .pub-section-title { display: none !important; }
  .stat-detail { grid-template-columns: 1fr; gap: 10px; }
  .pub-panel { break-inside: avoid; border-color: #bbb; }
  .stat-chart { height: 300px; }
  .pub-section { padding: 10px 0 0; }
  .container { width: 100%; }
}

/* Impression : en-tête officiel compact (une bande d'environ 3 cm) et contenu qui suit sans saut de page */
@media print {
  .me-ban { padding: 7px 12px 9px !important; border-radius: 6px !important; margin: 0 0 8px !important; }
  .me-ban::after { height: 3px !important; }
  .me-top { gap: 10px !important; padding-bottom: 5px !important; margin-bottom: 5px !important; border-bottom-width: 1px !important; }
  .me-logo { width: 38px !important; height: 38px !important; border-radius: 8px !important; }
  .me-logo img { width: 32px !important; height: 32px !important; }
  .me-rep { font-size: 7.5px !important; letter-spacing: .08em !important; }
  .me-min { font-size: 11px !important; }
  .me-dir { font-size: 8.5px !important; }
  .me-ref { font-size: 8.5px !important; }
  .me-head { gap: 10px !important; align-items: center !important; }
  .me-label { font-size: 7.5px !important; margin-bottom: 1px !important; }
  .me-title { font-size: 14px !important; line-height: 1.15 !important; margin: 0 !important; }
  .me-sub { font-size: 9px !important; line-height: 1.3 !important; margin: 2px 0 0 !important; max-width: none !important; }
  .me-per { font-size: 7.5px !important; padding: 2px 7px !important; margin-top: 3px !important; }
  .me-kpis { gap: 6px !important; }
  .me-kpi { padding: 4px 8px !important; min-width: 64px !important; border-radius: 7px !important; }
  .me-kpi b { font-size: 12px !important; }
  .me-kpi span { font-size: 7px !important; letter-spacing: .04em !important; }
  .pub-top { padding-top: 0 !important; }
  .pub-section { padding: 0 !important; }
  .pub-panel { padding: 8px 10px !important; border-radius: 8px !important; }
  .pub-panel-title { font-size: 10px !important; margin-bottom: 6px !important; }
  /* Le tableau peut s'étaler sur plusieurs pages ; le graphique reste entier */
  .stat-detail .pub-panel:first-child { break-inside: auto !important; }
  .stat-detail .pub-panel:last-child { break-inside: avoid; }
  .pub-table { font-size: 10.5px !important; }
  .pub-table th { padding: 5px 8px !important; font-size: 9px !important; }
  .pub-table td { padding: 4px 8px !important; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
  .stat-chart { height: 260px !important; }
  .carte-head { margin-bottom: 6px !important; }
  .carte-sub { font-size: 9px !important; }
  .carte-map { width: 277mm !important; height: 118mm !important; }
  .carte-print-leg { margin-top: 4px; }
  .carte-print-leg .carte-legende { display: flex; flex-wrap: wrap; gap: 3px 16px; }
  .carte-print-leg .carte-leg-bar { display: none; }
  .carte-print-leg .carte-leg-row, .carte-print-leg .carte-leg-pt { font-size: 9px; }
  .carte-print-leg .carte-leg-row b { min-width: 0; }
}

/* Mode impression appliqué à l'écran le temps du rendu (voir carte.js) : mêmes dimensions que la feuille A4 paysage */
body.impression .carte-grid { display: block; }
body.impression .carte-param, body.impression .carte-tools, body.impression .pub-header, body.impression .pub-footer { display: none; }
body.impression .container { width: 277mm; max-width: none; }
body.impression .carte-map { width: 277mm; height: 118mm; }
