:root {
  color-scheme: light dark;
  --bg: #f4f7fa;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --surface-strong: #edf2f5;
  --text: #172337;
  --muted: #5d6c83; /* 4,47 → 4,73:1 sur --surface-strong (sélecteur « Actifs ») — OPS-CDP-PAQUET-PROVIDERS-ETAT-1211-001 */
  --quiet: #616f84; /* 3,12 → 4,75:1 sur --bg (AA) — OPS-WEB-KO-CAMPAGNE-1211-001 */
  --border: #d9e1e8;
  --border-strong: #c4ced9;
  --primary: #177a70;
  --primary-strong: #0d625b;
  --primary-soft: #e4f3f0;
  --blue: #2f6fed;
  --blue-soft: #e9efff;
  --amber: #aa6811;
  --amber-soft: #fff4df;
  --danger: #b64052;
  --danger-soft: #fcebee;
  --shadow: 0 12px 30px rgba(24, 43, 66, .08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  --bg: #0d141b;
  --surface: #131d27;
  --surface-subtle: #182431;
  --surface-strong: #21303e;
  --text: #eef4f8;
  --muted: #a4b2c1;
  --quiet: #8190a0;
  --border: #2a3a49;
  --border-strong: #3b4d5d;
  --primary: #4cc1b1;
  --primary-strong: #73d7ca;
  --primary-soft: #163c39;
  --blue: #79a1ff;
  --blue-soft: #1e315a;
  --amber: #f1b95f;
  --amber-soft: #49361b;
  --danger: #ff8797;
  --danger-soft: #4c2430;
  --shadow: 0 12px 30px rgba(0, 0, 0, .24);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
button, select { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, select:focus-visible { outline: 3px solid color-mix(in srgb, var(--blue) 34%, transparent); outline-offset: 2px; }
.skip-link { position: fixed; top: -80px; left: 12px; z-index: 100; padding: 10px 14px; background: var(--text); color: var(--surface); border-radius: 6px; }
.skip-link:focus { top: 12px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.spacer { flex: 1; }

.app-header { min-height: 64px; padding: 0 24px; display: flex; align-items: center; gap: 14px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 30; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; min-width: 196px; }
.brand img { width: 34px; height: 34px; object-fit: contain; }
html[data-theme="dark"] .myth-logo { filter: brightness(0) invert(1); opacity: .94; }
.brand span, .profile-copy { display: grid; line-height: 1.15; }
.brand strong { font-size: 15px; letter-spacing: 0; }
.brand small, .profile-copy small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.header-context { display: inline-flex; align-items: center; gap: 8px; padding-left: 18px; border-left: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.icon-button { width: 38px; height: 38px; padding: 0; display: grid; place-items: center; background: transparent; color: var(--muted); border: 1px solid transparent; border-radius: 6px; cursor: pointer; }
.icon-button:hover { background: var(--surface-subtle); color: var(--text); border-color: var(--border); }
.icon-button svg, .secondary-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.profile-button { min-height: 42px; padding: 4px 7px; display: inline-flex; align-items: center; gap: 9px; background: transparent; color: var(--text); border: 0; border-radius: 6px; cursor: pointer; }
.profile-button:hover { background: var(--surface-subtle); }
.account-menu { position: relative; }
.account-popover { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; width: 210px; padding: 11px; display: grid; gap: 4px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); box-shadow: var(--shadow); }
.account-popover[hidden] { display: none; }
.account-popover > strong { font-size: 12px; }
.account-popover > span { padding-bottom: 9px; color: var(--muted); border-bottom: 1px solid var(--border); font-size: 10px; }
.account-popover a, .account-popover button { min-height: 34px; padding: 8px; text-align: left; border: 0; border-radius: 4px; background: transparent; color: var(--text); text-decoration: none; cursor: pointer; font-size: 12px; }
.account-popover a:hover, .account-popover button:hover { background: var(--surface-subtle); }
.avatar { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary-strong); font-weight: 750; font-size: 11px; }
.profile-copy { text-align: left; font-size: 12px; }

.app-shell { display: grid; grid-template-columns: 218px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.sidebar { position: sticky; top: 64px; height: calc(100vh - 64px); padding: 24px 14px 18px; display: flex; flex-direction: column; border-right: 1px solid var(--border); background: var(--surface); }
.sidebar nav { display: grid; gap: 4px; }
.nav-item { min-height: 42px; padding: 0 12px; display: grid; grid-template-columns: 26px 1fr; align-items: center; text-align: left; color: var(--muted); background: transparent; border: 0; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; }
.nav-item:hover { background: var(--surface-subtle); color: var(--text); }
.nav-item.is-active { background: var(--primary-soft); color: var(--primary-strong); }
.nav-icon { width: 24px; text-align: center; font-size: 17px; font-weight: 500; }
.sidebar-foot { margin-top: auto; padding: 14px 12px; border-top: 1px solid var(--border); display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; }
.sidebar-foot p { margin: 0; color: var(--muted); font-size: 11px; }
.sidebar-foot strong { grid-row: span 2; color: var(--primary-strong); font-size: 20px; font-variant-numeric: tabular-nums; }
.sidebar-foot span { color: var(--quiet); font-size: 12px; }

main { min-width: 0; width: 100%; padding: 28px clamp(20px, 3vw, 46px) 54px; }
.page-heading { display: flex; align-items: flex-end; gap: 24px; margin-bottom: 22px; }
.eyebrow { margin: 0 0 5px; color: var(--primary-strong); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
.page-heading h1 { margin: 0; font-size: clamp(24px, 2.4vw, 32px); line-height: 1.14; letter-spacing: 0; }
.page-heading p:not(.eyebrow) { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.heading-actions { margin-left: auto; }
.secondary-button { min-height: 38px; padding: 0 13px; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); color: var(--text); cursor: pointer; font-size: 13px; font-weight: 650; }
.secondary-button:hover { border-color: var(--primary); color: var(--primary-strong); }

.filter-bar { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)) auto; gap: 10px; padding: 12px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; margin-bottom: 14px; }
.filter-bar label { min-width: 0; display: grid; gap: 4px; }
.filter-bar label span { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.filter-bar select { width: 100%; height: 36px; padding: 0 32px 0 10px; color: var(--text); background: var(--surface-subtle); border: 1px solid var(--border); border-radius: 5px; cursor: pointer; }
.clear-button { align-self: end; height: 36px; padding: 0 12px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; }
.clear-button:hover { color: var(--primary-strong); text-decoration: underline; }
.notice { min-height: 40px; padding: 9px 12px; display: flex; align-items: center; gap: 10px; border-radius: 6px; font-size: 12px; margin-bottom: 10px; }
.notice[hidden] { display: none; }
.simulation-notice { border: 1px solid #efce8f; background: var(--amber-soft); color: var(--text); }
.notice-mark { padding: 2px 6px; border-radius: 3px; background: var(--amber); color: #fff; font-size: 9px; font-weight: 850; letter-spacing: .08em; }
.notice button { margin-left: auto; width: 28px; height: 28px; border: 0; background: transparent; color: currentColor; font-size: 20px; cursor: pointer; }
.simulation-notice button { width: auto; min-height: 30px; padding: 0 10px; border: 1px solid color-mix(in srgb, var(--amber) 55%, var(--border)); border-radius: 5px; background: var(--surface); color: var(--text); font-size: 11px; font-weight: 700; white-space: nowrap; }
.icon-button[aria-pressed="true"] { border-color: var(--amber); background: var(--amber-soft); color: var(--amber); }
.availability-notice { border: 1px solid color-mix(in srgb, var(--blue) 28%, var(--border)); background: var(--blue-soft); color: var(--text); }
.availability-notice > span:first-child { width: 20px; height: 20px; border: 1px solid currentColor; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800; }

.kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(145px, 1fr)); gap: 10px; margin: 20px 0 14px; }
.kpi-card { min-width: 0; min-height: 132px; padding: 15px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.kpi-top { min-height: 22px; display: flex; align-items: flex-start; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 650; }
.info-button { position: relative; margin-left: auto; flex: 0 0 auto; width: 20px; height: 20px; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: transparent; color: var(--muted); cursor: help; font-size: 10px; }
.info-button::after { content: attr(data-tooltip); position: absolute; right: -8px; top: 27px; z-index: 10; width: 220px; padding: 9px 10px; border-radius: 5px; background: #162335; color: #fff; box-shadow: var(--shadow); font-size: 11px; font-weight: 500; line-height: 1.4; text-align: left; opacity: 0; pointer-events: none; transform: translateY(-3px); transition: .15s ease; }
.info-button:hover::after, .info-button:focus-visible::after { opacity: 1; transform: translateY(0); }
.kpi-value { margin: 9px 0 6px; font-size: 26px; line-height: 1; font-weight: 760; font-variant-numeric: tabular-nums; }
.kpi-foot { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; }
.delta { padding: 2px 5px; border-radius: 4px; font-weight: 750; }
.delta.up { color: var(--primary-strong); background: var(--primary-soft); }
.delta.down { color: var(--danger); background: var(--danger-soft); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(270px, .8fr); gap: 14px; margin-top: 14px; }
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.panel.span-2 { grid-column: 1 / -1; }
.panel-header { min-height: 54px; padding: 12px 16px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); }
.panel-header h2 { margin: 0; font-size: 14px; letter-spacing: 0; }
.panel-header p { margin: 2px 0 0; color: var(--muted); font-size: 10px; }
.panel-body { padding: 16px; }
.segmented { margin-left: auto; padding: 2px; display: inline-flex; background: var(--surface-strong); border-radius: 5px; }
.segmented button { min-height: 28px; padding: 0 9px; border: 0; border-radius: 4px; color: var(--muted); background: transparent; cursor: pointer; font-size: 11px; }
.segmented button.is-active { color: var(--text); background: var(--surface); box-shadow: 0 1px 4px rgba(25, 42, 64, .1); }

.trend-chart { width: 100%; height: 236px; display: block; overflow: visible; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-area { fill: color-mix(in srgb, var(--primary) 12%, transparent); }
.chart-line { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-line.secondary { stroke: var(--blue); stroke-width: 2; }
.chart-point { fill: var(--surface); stroke: var(--primary); stroke-width: 2; }
.chart-label { fill: var(--muted); font: 10px Inter, sans-serif; }
.chart-legend { display: flex; gap: 18px; margin-top: 6px; color: var(--muted); font-size: 11px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.legend-dot.blue { background: var(--blue); }

.quality-list { display: grid; gap: 15px; }
.quality-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; }
.quality-row span { color: var(--muted); font-size: 11px; }
.quality-row strong { font-size: 12px; font-variant-numeric: tabular-nums; }
.quality-track { grid-column: 1 / -1; height: 5px; overflow: hidden; border-radius: 3px; background: var(--surface-strong); }
.quality-track i { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
.quality-meta { margin: 18px 0 0; padding-top: 13px; border-top: 1px solid var(--border); color: var(--quiet); font-size: 12px; }

.lifecycle-list { display: grid; gap: 12px; }
.lifecycle-row { display: grid; grid-template-columns: 100px 1fr 45px; gap: 10px; align-items: center; font-size: 11px; }
.lifecycle-row span:first-child { color: var(--muted); }
.lifecycle-bar { height: 8px; border-radius: 4px; background: var(--surface-strong); overflow: hidden; }
.lifecycle-bar i { display: block; height: 100%; border-radius: inherit; }
.lifecycle-row strong { text-align: right; font-variant-numeric: tabular-nums; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
td small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.empty-cell { padding: 24px; color: var(--muted); text-align: center; }
th, td { min-height: 46px; padding: 11px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; white-space: nowrap; }
th { color: var(--muted); background: var(--surface-subtle); font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
td { font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--primary-soft) 45%, transparent); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.subcell { display: grid; }
.subcell small { color: var(--muted); margin-top: 2px; }
.product-cell { display: flex; align-items: center; gap: 9px; }
.product-mark { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 6px; color: #fff; font-size: 9px; font-weight: 800; }
.progress-cell { min-width: 120px; }
.mini-progress { width: 86px; height: 5px; margin-top: 5px; border-radius: 3px; background: var(--surface-strong); overflow: hidden; }
.mini-progress i { display: block; height: 100%; background: var(--primary); }
.row-action { border: 0; background: transparent; color: var(--primary-strong); cursor: pointer; font-size: 11px; font-weight: 700; }
.row-action:hover { text-decoration: underline; }

.profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.profile-stat { padding: 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-subtle); }
.profile-stat span { color: var(--muted); font-size: 11px; }
.profile-stat strong { display: block; margin-top: 6px; font-size: 22px; font-variant-numeric: tabular-nums; }
.profile-stat small { color: var(--quiet); }

.geo-layout { display: grid; grid-template-columns: minmax(310px, .9fr) minmax(0, 1.2fr); gap: 14px; }
.geo-map { position: relative; min-height: 420px; overflow: hidden; background: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px), var(--surface-subtle); background-size: 52px 52px; }
.geo-map::before { content: "Aperçu cartographique · fond géographique à brancher"; position: absolute; left: 14px; bottom: 12px; color: var(--quiet); font-size: 9px; }
.map-spot { position: absolute; width: var(--size); height: var(--size); transform: translate(-50%, -50%); border: 2px solid var(--surface); border-radius: 50%; background: color-mix(in srgb, var(--primary) 76%, transparent); box-shadow: 0 2px 8px rgba(20, 69, 76, .25); cursor: pointer; }
.map-spot:hover, .map-spot:focus-visible { background: var(--blue); z-index: 2; }
.map-spot::after { content: attr(data-label); position: absolute; left: 50%; top: calc(100% + 5px); transform: translateX(-50%); padding: 3px 5px; border-radius: 3px; background: var(--surface); border: 1px solid var(--border); color: var(--text); white-space: nowrap; font-size: 9px; }

.retention-table td.heat { text-align: center; font-weight: 750; background: color-mix(in srgb, var(--primary) calc(var(--heat) * 1%), var(--surface)); }
.retention-table td.na { color: var(--quiet); text-align: center; background: var(--surface-subtle); }
.cohort-note { margin: 12px 0 0; color: var(--muted); font-size: 10px; }
.adoption-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.adoption-kpi { padding: 16px; border-left: 3px solid var(--primary); background: var(--surface-subtle); }
.adoption-kpi span { color: var(--muted); font-size: 11px; }
.adoption-kpi strong { display: block; margin-top: 7px; font-size: 24px; }
.journey { display: grid; grid-template-columns: 1fr 34px 1fr 74px; gap: 12px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.journey:last-child { border-bottom: 0; }
.journey-arrow { color: var(--primary); text-align: center; }
.journey strong { text-align: right; }

.empty-state, .error-state { min-height: 300px; padding: 42px 20px; display: grid; place-items: center; align-content: center; text-align: center; border: 1px dashed var(--border-strong); border-radius: 8px; background: var(--surface); }
.empty-state strong, .error-state strong { margin-top: 12px; font-size: 16px; }
.empty-state p, .error-state p { max-width: 480px; margin: 6px 0 16px; color: var(--muted); font-size: 12px; }
.empty-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-strong); color: var(--muted); font-size: 20px; }
.loading-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 20px; }
.loading-grid span { height: 132px; border-radius: 8px; background: linear-gradient(90deg, var(--surface) 20%, var(--surface-strong) 48%, var(--surface) 76%); background-size: 220% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -220% 0; } }

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .filter-bar { grid-template-columns: repeat(2, 1fr); }
  .clear-button { justify-self: start; }
  .adoption-kpis { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
  .app-header { padding: 0 14px; }
  .header-context, .profile-copy { display: none; }
  .brand { min-width: 0; }
  .app-shell { display: block; }
  .sidebar { position: sticky; top: 64px; z-index: 20; width: 100%; height: auto; padding: 7px 10px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar nav { display: flex; width: max-content; }
  .nav-item { grid-template-columns: 20px auto; min-height: 38px; padding: 0 10px; white-space: nowrap; }
  .sidebar-foot { display: none; }
  main { padding: 22px 14px 42px; }
  .dashboard-grid, .geo-layout { grid-template-columns: 1fr; }
  .panel.span-2 { grid-column: auto; }
  .geo-map { min-height: 340px; }
}

@media (max-width: 560px) {
  body { font-size: 14px; }
  .app-header { min-height: 58px; gap: 8px; }
  .app-shell { min-height: calc(100vh - 58px); }
  .sidebar { top: 58px; }
  .brand small, #refresh { display: none; }
  .page-heading { align-items: flex-start; }
  .page-heading h1 { font-size: 24px; }
  .heading-actions { margin-left: auto; }
  .icon-button, .profile-button, .secondary-button { min-width: 44px; min-height: 44px; }
  .secondary-button { width: 44px; padding: 0; justify-content: center; }
  .secondary-button span, .secondary-button:not(:has(svg)) { font-size: 0; }
  .nav-item { min-height: 44px; }
  .filter-bar { grid-template-columns: 1fr; }
  .filter-bar label:nth-of-type(3), .filter-bar label:nth-of-type(4) { grid-column: auto; }
  .filter-bar select, .clear-button { min-height: 44px; height: 44px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-card { min-height: 118px; padding: 12px; }
  .kpi-value { font-size: 23px; }
  .info-button::after { right: -16px; width: min(220px, calc(100vw - 42px)); }
  .profile-grid, .adoption-kpis { grid-template-columns: 1fr; }
  .notice { align-items: flex-start; }
  .simulation-notice { flex-wrap: wrap; }
  .simulation-notice button { min-height: 44px; margin-left: 0; }
  .lifecycle-row { grid-template-columns: 84px 1fr 38px; }
  .journey { grid-template-columns: 1fr 24px 1fr; }
  .journey strong { grid-column: 1 / -1; text-align: left; color: var(--muted); }
  .loading-grid { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* The environment gate must win over the icon button display rule. */
.icon-button[hidden] { display:none; }
