/* ===== Données PNIN — feuille de style (charte PNIN : bleu, turquoise, vert) ===== */
:root {
  --pnin-blue: #1B75BC;
  --pnin-blue-dark: #145C95;
  --pnin-teal: #2BB5A8;
  --pnin-teal-dark: #1F8A80;
  --pnin-green: #8DC63F;
  --pnin-lime: #D7DF23;
  --ink: #23313f;
  --muted: #55636f;
  --bg: #f4f7f9;
  --card: #ffffff;
  --border: #dfe6ec;
  --good: #1F8A80;
  --bad: #C2410C;
  --warn: #B7791F;
  --info: #1B75BC;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 40, 60, .05), 0 4px 14px rgba(20, 40, 60, .05);
  --focus: 0 0 0 3px rgba(27, 117, 188, .45);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--pnin-blue-dark); }
h1, h2, h3, .h3 { line-height: 1.25; margin: 0; color: var(--ink); }
h1 { font-size: 1.65rem; letter-spacing: -.01em; }
h2 { font-size: 1.35rem; }
h3, .h3 { font-size: 1.05rem; display: flex; align-items: center; gap: .45rem; }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: .88rem; margin: .2rem 0 0; }
.wrap { width: 100%; max-width: 1280px; margin: 0 auto; padding-inline: 16px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.ico { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 8px; text-decoration: none; }
.skip-link:focus { top: 8px; }

/* ----- Barre supérieure ----- */
.topbar { background: #fff; border-bottom: 1px solid var(--border); position: relative; }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px;
  background: linear-gradient(90deg, var(--pnin-blue) 0 25%, var(--pnin-teal) 25% 50%, var(--pnin-green) 50% 75%, var(--pnin-lime) 75%); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: .6rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .8rem; text-decoration: none; color: var(--ink); }
.brand-logo { height: 52px; width: auto; display: block; }
.brand-text { display: flex; flex-direction: column; border-left: 1px solid var(--border); padding-left: .8rem; }
.brand-text strong { font-size: 1rem; }
.brand-text small { color: var(--muted); font-size: .78rem; }
.topbar-user { display: flex; align-items: center; gap: .5rem; font-size: .9rem; flex-wrap: wrap; }
.user-pill { display: inline-flex; align-items: center; gap: .4rem; background: #eef5fb; color: var(--pnin-blue-dark); border-radius: 999px; padding: .3rem .75rem; font-weight: 600; }
.adminnav { background: #16324a; }
.adminnav .wrap { display: flex; gap: .15rem; overflow-x: auto; }
.adminnav a { color: #c9d6e2; text-decoration: none; padding: .7rem .9rem; font-size: .9rem; white-space: nowrap; border-bottom: 3px solid transparent; }
.adminnav a:hover { color: #fff; background: rgba(255,255,255,.05); }
.adminnav a.active { color: #fff; border-bottom-color: var(--pnin-green); }

/* Dans l'iframe WordPress : la bannière du site suffit */
.is-embedded .area-public .topbar { display: none; }
.is-embedded .area-public #primary { padding-top: 8px; }

#primary { padding-block: 22px 36px; }
#primary:focus { outline: none; }

/* ----- Pied de page ----- */
.site-footer { border-top: 1px solid var(--border); background: #fff; font-size: .82rem; color: var(--muted); }
.footer-inner { display: flex; justify-content: space-between; gap: 1rem; padding-block: .9rem; flex-wrap: wrap; }

/* ----- Boutons & champs ----- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 40px; padding: .5rem 1rem; border-radius: 9px;
  border: 1px solid transparent; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease; }
.btn-primary { background: var(--pnin-blue); color: #fff; }
.btn-primary:hover { background: var(--pnin-blue-dark); }
.btn-secondary { background: var(--pnin-teal-dark); color: #fff; }
.btn-secondary:hover { background: #17736b; }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--border); }
.btn-ghost:hover { border-color: #b9c6d2; background: #f7fafc; }
.btn-danger { background: #fff; color: #b42318; border-color: #f3c3bd; }
.btn-danger:hover { background: #fef3f2; }
.btn-sm { min-height: 34px; padding: .3rem .7rem; font-size: .83rem; }
.linkbtn { background: none; border: 0; padding: .35rem .1rem; color: var(--pnin-blue-dark); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 1px solid var(--border); background: #fff;
  border-radius: 8px; cursor: pointer; color: var(--muted); transition: color .15s, border-color .15s; }
.iconbtn:hover { color: var(--pnin-blue-dark); border-color: #b9c6d2; }

input[type=text], input[type=search], input[type=password], input[type=email], input[type=number], input[type=file], select, textarea {
  font: inherit; font-size: .93rem; width: 100%; min-height: 40px; padding: .5rem .65rem; border: 1px solid #c8d3dc; border-radius: 9px; background: #fff; color: var(--ink);
  transition: border-color .15s ease;
}
input:hover, select:hover, textarea:hover { border-color: #a9b8c5; }
textarea { min-height: 80px; resize: vertical; }
select:disabled { background: #f3f6f8; color: var(--muted); }
:focus-visible { outline: none; box-shadow: var(--focus); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--pnin-blue); box-shadow: var(--focus); }
label, .label { display: block; font-size: .78rem; font-weight: 700; color: #3f4d59; margin-bottom: .35rem; text-transform: uppercase; letter-spacing: .03em; }
.inline-label { display: inline; margin: 0 .2rem 0 0; }
.input-icon { position: relative; }
.input-icon .ico { position: absolute; left: .65rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon input { padding-left: 2.2rem; }
.switch { display: inline-flex; align-items: center; gap: .4rem; min-height: 36px; font-size: .84rem; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--ink); margin: 0; cursor: pointer; }
.switch input { accent-color: var(--pnin-blue); width: 16px; height: 16px; }

/* ----- Cartes ----- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .8rem; margin-bottom: .9rem; flex-wrap: wrap; }
.card-tools { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.card-tools select { width: auto; min-height: 36px; padding: .3rem .55rem; font-size: .85rem; }

.alert { padding: .75rem 1rem; border-radius: 10px; margin-bottom: 14px; font-size: .92rem; border: 1px solid; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-error { background: #fef3f2; border-color: #fecdca; color: #912018; }
.alert-info { background: #eff6fc; border-color: #bcd8ef; color: #134a78; }
.alert-warning { background: #fffaeb; border-color: #fedf89; color: #7a4a0c; }

/* ----- En-tête de l'explorateur ----- */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 1.2rem; margin-bottom: 18px; flex-wrap: wrap; }
.hero .lead { color: var(--muted); margin: .4rem 0 0; max-width: 62ch; }
.eyebrow { margin: 0 0 .25rem; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--pnin-teal-dark); font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(4, auto); gap: .6rem; margin: 0; }
.stats div { background: #fff; border: 1px solid var(--border); border-top: 3px solid var(--pnin-blue); border-radius: 10px; padding: .5rem .9rem; min-width: 100px; }
.stats div:nth-child(2) { border-top-color: var(--pnin-teal); }
.stats div:nth-child(3) { border-top-color: var(--pnin-green); }
.stats div:nth-child(4) { border-top-color: var(--pnin-lime); }
.stats dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.stats dd { margin: 0; font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }

/* ----- Filtres ----- */
.filters { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(280px, 2.3fr) minmax(160px, 1fr) minmax(200px, 1fr); gap: 16px 18px; }
.field-full { grid-column: 1 / -1; }
.combo { display: flex; flex-direction: column; gap: 6px; }
.period { display: flex; align-items: center; gap: .4rem; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: .8rem; flex-wrap: wrap; }
.chip-actions { display: flex; gap: 1rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: .45rem; min-height: 38px; border: 1px solid var(--border); background: #fff; border-radius: 999px;
  padding: .3rem .85rem; font: inherit; font-size: .87rem; cursor: pointer; color: var(--muted); transition: border-color .15s, background-color .15s, color .15s; }
.chip:hover { border-color: #a9b8c5; }
.chip.on { border-color: var(--pnin-blue); color: var(--ink); background: #eef5fb; font-weight: 600; }
.chip.on::after { content: "✓"; font-size: .8rem; color: var(--pnin-blue-dark); }
.chip:not(.on) .dot { opacity: .35; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; margin-right: .4rem; vertical-align: middle; }
.chip .dot { margin-right: 0; }

/* ----- Panorama du secteur ----- */
.pano-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.pano-card { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: .25rem; text-align: left; font: inherit; color: var(--ink);
  background: #fbfcfd; border: 1px solid var(--border); border-radius: 10px; padding: .8rem .9rem .7rem; cursor: pointer; min-height: 150px;
  transition: border-color .15s, box-shadow .15s, transform .15s; }
.pano-card:hover { border-color: var(--pnin-blue); box-shadow: var(--shadow); }
.pano-card.is-current { border-color: var(--pnin-blue); background: #eef5fb; box-shadow: inset 3px 0 0 var(--pnin-blue); }
.pano-title { font-size: .84rem; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.2em; }
.pano-value { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.pano-value small { font-size: .8rem; font-weight: 600; color: var(--muted); margin-left: .15rem; }
.pano-meta { font-size: .78rem; color: var(--muted); display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.spark { width: 100%; height: 36px; margin-top: auto; }
.pano-more { text-align: center; margin-top: 12px; }
.delta { font-weight: 700; }
.delta-good { color: var(--good); }
.delta-bad { color: var(--bad); }
.delta-neutral { color: var(--info); }
.level-chip { display: inline-flex; align-items: center; gap: .35rem; font-size: .74rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px;
  color: #1d2733; background: color-mix(in srgb, var(--lvl) 16%, #fff); border: 1px solid color-mix(in srgb, var(--lvl) 45%, #fff); }
.level-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--lvl); }

/* ----- Chargement ----- */
.skeleton-wrap { margin-bottom: 18px; }
.skeleton { background: linear-gradient(90deg, #e8edf2 25%, #f3f6f9 37%, #e8edf2 63%); background-size: 400% 100%; border-radius: 10px; animation: shimmer 1.4s ease infinite; }
.sk-title { height: 28px; width: 55%; margin-bottom: 14px; }
.skeleton-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.sk-kpi { height: 86px; }
.sk-chart { height: 300px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.empty { background: #fff; border: 1px dashed #b9c6d2; border-radius: var(--radius); padding: 2rem; text-align: center; color: var(--muted); margin-bottom: 18px; }

/* ----- Indicateur ----- */
.ind-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin: 8px 0 16px; flex-wrap: wrap; scroll-margin-top: 12px; }
.ind-head h2 { max-width: 72ch; }
.ind-head h2:focus { outline: none; }
.ind-badges { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 0; }
.ind-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--border); border-left: 5px solid #9fb0bf; border-radius: var(--radius); padding: .75rem 1rem; display: flex; flex-direction: column; gap: .15rem; box-shadow: var(--shadow); }
.kpi-good { border-left-color: var(--good); }
.kpi-bad { border-left-color: var(--bad); }
.kpi-warn { border-left-color: #E6A700; }
.kpi-neutral { border-left-color: var(--pnin-blue); }
.kpi-label { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
.kpi-value { font-size: 1.45rem; font-variant-numeric: tabular-nums; }
.kpi-good .kpi-value { color: var(--good); }
.kpi-bad .kpi-value { color: var(--bad); }
.kpi-sub { font-size: .8rem; color: var(--muted); }

/* ----- Lecture des données ----- */
.insights { border-top: 4px solid var(--pnin-teal); }
.insights h3 .ico { color: var(--pnin-teal-dark); }
.insight-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.insight { position: relative; border: 1px solid var(--border); border-left: 4px solid var(--info); border-radius: 10px; padding: .7rem .9rem .75rem; background: #fbfcfd; }
.insight strong { display: block; font-size: .92rem; margin-bottom: .2rem; }
.insight p { margin: 0; font-size: .9rem; color: #2f3d49; }
.insight-tag { float: right; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: .1rem .45rem; border-radius: 6px; background: #eef5fb; color: var(--pnin-blue-dark); margin-left: .5rem; }
.insight-good { border-left-color: var(--good); }
.insight-good .insight-tag { background: #e6f5f3; color: #146b63; }
.insight-bad { border-left-color: var(--bad); }
.insight-bad .insight-tag { background: #fdeee6; color: #9a3412; }
.insight-warn { border-left-color: #E6A700; }
.insight-warn .insight-tag { background: #fff6dc; color: #7a4a0c; }
.disclaimer { display: flex; gap: .5rem; align-items: flex-start; margin: 12px 0 0; font-size: .8rem; color: var(--muted); }

/* ----- Graphiques ----- */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.grid-2 > .card { margin-bottom: 0; min-width: 0; }
.span-2 { grid-column: 1 / -1; }
.chart-box { position: relative; height: 310px; }
.chart-box.tall { height: 400px; }
.ref-legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin-top: 10px; font-size: .8rem; color: var(--muted); align-items: center; }
.ref-src { font-weight: 600; color: var(--ink); }
.ref-item { display: inline-flex; align-items: center; gap: .35rem; }
.ref-item i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; opacity: .75; }

/* ----- Tableaux ----- */
.table-scroll { overflow-x: auto; border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: .5rem .65rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
thead th { background: #f3f7fa; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; color: #3f4d59; white-space: nowrap; }
tbody tr:hover td, tbody tr:hover th { background-color: #f7fafc; }
.heat td { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.heat th[scope=row] { white-space: nowrap; background: #fff; position: sticky; left: 0; z-index: 1; }
.heat td.na { color: #b0bcc7; text-align: center; background: #fafbfc; }
td.var { font-weight: 700; }
.var-good { color: var(--good); }
.var-bad { color: var(--bad); }
.var-neutral { color: var(--ink); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .2rem 1.6rem; margin: 0; }
.meta div { padding: .55rem 0; border-bottom: 1px solid var(--border); }
.meta dt { font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; }
.meta dd { margin: .15rem 0 0; }

/* ----- Administration ----- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 18px; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px 16px; align-items: end; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: .5rem; margin-top: 16px; flex-wrap: wrap; align-items: center; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: #fff; border: 1px solid var(--border); border-top: 3px solid var(--pnin-blue); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.tile:nth-child(2) { border-top-color: var(--pnin-teal); }
.tile:nth-child(3) { border-top-color: var(--pnin-green); }
.tile:nth-child(4) { border-top-color: var(--pnin-lime); }
.tile span { display: block; font-size: .75rem; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; font-weight: 600; }
.tile strong { font-size: 1.55rem; font-variant-numeric: tabular-nums; }
.actions-cell { white-space: nowrap; text-align: right; }
.actions-cell form { display: inline; }
.pager { display: flex; gap: .4rem; align-items: center; margin-top: 12px; flex-wrap: wrap; font-size: .88rem; }
.saisie td input { max-width: 180px; text-align: right; }
.saisie tr.changed td { background: #fff8e1; }
.badge { display: inline-flex; align-items: center; font-size: .74rem; padding: .15rem .55rem; border-radius: 999px; background: #eef2f6; color: #3f4d59; font-weight: 600; }
.badge-ok { background: #dcf5e8; color: #135f3b; }
.badge-off { background: #fde7e4; color: #912018; }
.badge-warn { background: #fff4d6; color: #7a4a0c; }
.tabs { display: flex; gap: .3rem; margin-bottom: 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tabs a { padding: .6rem .95rem; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 600; font-size: .9rem; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--pnin-blue); }
code { background: #eef2f6; padding: .05rem .35rem; border-radius: 4px; font-size: .85em; }
.mode-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: #fff; }
.mode-switch a { padding: .5rem .9rem; text-decoration: none; color: var(--muted); font-size: .88rem; font-weight: 600; }
.mode-switch a.active { background: var(--pnin-blue); color: #fff; }

/* Connexion */
.login-page { min-height: calc(100vh - 160px); display: grid; place-items: center; }
.login-box { width: 100%; max-width: 420px; margin: 24px auto; padding: 28px 28px 22px; border-top: 4px solid var(--pnin-teal); }
.login-logo { display: block; width: 150px; height: auto; margin: 0 auto 10px; }
.login-box h1 { text-align: center; font-size: 1.3rem; }
.login-box .muted { text-align: center; }

@media (max-width: 960px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .field-wide { grid-column: 1 / -1; }
  .grid-2, .insight-list { grid-template-columns: minmax(0, 1fr); }
  .meta { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); width: 100%; }
}
@media (max-width: 560px) {
  .filters { grid-template-columns: 1fr; }
  h1 { font-size: 1.35rem; }
  .chart-box { height: 270px; }
  .chart-box.tall { height: 320px; }
  .skeleton-row { grid-template-columns: repeat(2, 1fr); }
  .brand-text { display: none; }
  .card { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
