/* Reproduction du thème Power BI CY24SU10 — clair par défaut, sombre en option */
:root {
  --accent: #118DFF;
  --accent-dark: #08467F;   /* ThemeDataColor 2, -50 % : bordures des segments */
  --accent-mid: #0D6ABF;    /* ThemeDataColor 2, -25 % : valeur de la carte */
  --bar-stroke: #0B5FAD;
  --fg: #252423;
  --fg2: #605E5C;
  --fg3: #B3B0AD;
  --bg: #FFFFFF;
  --bg-light: #F3F2F1;
  --neutral: #C8C6C4;
  --row-alt: #D6EBFF;
  --row-sel: #9FD0FF;
  --muted: #999999;
  --head-bg: #252423;
  --head-fg: #FFFFFF;
  --canvas: #EAEAEA;
  --coffee-bg: #FFDD00;
  --coffee-fg: #0D0C22;
  --overlay: rgba(255,255,255,.85);
  --shadow: rgba(0,0,0,.22);
  --font: "Segoe UI", "Segoe UI Web (West European)", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-title: "DIN", "DIN Alternate", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #118DFF; --accent-dark: #3D8FD9; --accent-mid: #5AB0FF; --bar-stroke: #5AB0FF;
    --fg: #F3F2F1; --fg2: #C8C6C4; --fg3: #797775; --bg: #252423; --bg-light: #323130; --neutral: #484644;
    --row-alt: #1C3552; --row-sel: #0D5596; --muted: #8A8886; --head-bg: #11100F; --head-fg: #F3F2F1;
    --canvas: #161514; --overlay: rgba(37,36,35,.85); --shadow: rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --accent: #118DFF; --accent-dark: #3D8FD9; --accent-mid: #5AB0FF; --bar-stroke: #5AB0FF;
  --fg: #F3F2F1; --fg2: #C8C6C4; --fg3: #797775; --bg: #252423; --bg-light: #323130; --neutral: #484644;
  --row-alt: #1C3552; --row-sel: #0D5596; --muted: #8A8886; --head-bg: #11100F; --head-fg: #F3F2F1;
  --canvas: #161514; --overlay: rgba(37,36,35,.85); --shadow: rgba(0,0,0,.6);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--canvas);
  color: var(--fg);
  font-family: var(--font);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Barre du haut ---------- */
#bar {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 16px; background: var(--bg); border-bottom: 1px solid var(--neutral);
}
#bar .copy { font-size: 12px; color: var(--fg2); white-space: nowrap; }
#bar .brand { font-family: var(--font-title); font-size: 15px; font-weight: 600; margin: 0; }
#hist { display: inline-flex; gap: 4px; }
#hist button {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 32px; height: 28px;
  font: inherit; font-size: 12px; color: var(--fg); background: var(--bg-light);
  border: 1px solid var(--neutral); border-radius: 14px; padding: 0 9px; cursor: pointer;
}
#hist button:hover:not(:disabled) { border-color: var(--fg2); }
#hist button:disabled { opacity: .4; cursor: default; }
#hist button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#coffee {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; text-decoration: none;
  color: var(--coffee-fg); background: var(--coffee-bg); border-radius: 14px; padding: 4px 12px; white-space: nowrap;
}
#coffee:hover { filter: brightness(.95); }
#coffee:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#themeBtn, #layoutBtn, #aboutBtn {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 12px; color: var(--fg);
  background: var(--bg-light); border: 1px solid var(--neutral); border-radius: 14px; padding: 4px 12px; cursor: pointer;
}
#themeBtn:hover, #layoutBtn:hover, #aboutBtn:hover { border-color: var(--fg2); }
#themeBtn:focus-visible, #layoutBtn:focus-visible, #aboutBtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Le rapport (page 1 + graphiques) mis à l'échelle ; taille réglée par fit() dans app.js ---------- */
#stage { flex: 1; min-height: 0; overflow: hidden; padding: 12px 16px; display: flex; align-items: center; justify-content: center; }
#frame { position: relative; flex: none; }
#scaler {
  position: absolute; left: 0; top: 0;
  width: 2080px; height: 720px;
  transform-origin: 0 0;
  background: var(--bg);
  box-shadow: 0 0 6px var(--shadow);
}
.page { position: absolute; top: 0; height: 720px; }
#page1 { left: 0; width: 1280px; }
#page2 { left: 1280px; width: 800px; border-left: 1px solid var(--neutral); }
#loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--overlay); font-size: 18px; color: var(--fg2); z-index: 1000;
}
#loading[hidden] { display: none; }
#noscript { position: absolute; inset: 0; z-index: 1001; display: flex; justify-content: center; padding-top: 300px; background: var(--bg); font-size: 18px; }
#bar .credit { flex: 1; min-width: 0; text-align: center; font-size: 12px; color: var(--fg2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#bar .credit a { color: var(--fg); }

/* ---------- Conteneurs de visuels ---------- */
.visual { position: absolute; background: var(--bg); }
.visual.framed { border: 1px solid var(--neutral); }
.visual.rounded { border: 1px solid var(--accent-dark); border-radius: 8px; }
.visual.shadow { box-shadow: 0 3px 6px var(--shadow); }
.vtitle {
  font-family: var(--font-title); font-size: 16px; color: var(--fg);
  padding: 4px 8px 0; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.textbox { padding: 6px 8px; font-size: 10.7px; line-height: 1.35; background: transparent; }
.textbox p { margin: 0 0 2px; }
.textbox a { color: var(--fg); text-decoration: underline; }

.card { background: transparent; }
.card .callout {
  font-family: var(--font-title); font-weight: 700; font-size: 46px; line-height: 48px;
  color: var(--accent-mid); text-align: center; font-variant-numeric: tabular-nums;
}

/* ---------- Tables ---------- */
.tbl { position: absolute; inset: 0; display: flex; flex-direction: column; overflow: hidden; }
.tbl .thead, .tbl .trow, .tbl .ttotal { display: flex; }
.tbl .cell {
  flex: none; padding: 3px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  line-height: 16px;
}
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .thead .cell { white-space: normal; display: flex; align-items: flex-end; cursor: pointer; position: relative; }
.tbl .thead .cell.num { justify-content: flex-end; text-align: right; }
.tbl .thead .cell .sort { position: absolute; top: 1px; left: 50%; transform: translateX(-50%); font-size: 8px; }
.tbl .tbody { flex: 1; overflow-y: auto; overflow-x: hidden; position: relative; }
.tbl .tbody .spacer { position: relative; }
.tbl .trow { position: absolute; left: 0; right: 0; height: 22px; }
.tbl .trow .cell { line-height: 16px; }
.tbl .empty { padding: 12px; color: var(--fg2); }

/* Style "BoldHeaderFlashyRows" */
.flashy .thead { background: var(--head-bg); color: var(--head-fg); font-weight: 700; }
.flashy .trow { background: var(--bg); }
.flashy .trow.alt { background: var(--row-alt); }
.flashy .trow:hover { outline: 1px solid var(--accent-dark); outline-offset: -1px; cursor: pointer; }
.flashy .trow.sel { background: var(--row-sel); }
.flashy.has-sel .trow:not(.sel) { color: var(--muted); }
.flashy .ttotal { font-weight: 700; border-top: 2px solid var(--fg); background: var(--bg); }
.flashy a { color: inherit; text-decoration: underline; }
.flashy a:hover { color: var(--accent-mid); }

/* Style "Default" (tables secondaires) */
.plain .thead { font-size: 18.6px; border-bottom: 1px solid var(--neutral); color: var(--fg); }
.plain .thead .cell { cursor: default; line-height: 22px; }
.plain .trow { border-bottom: 1px solid var(--bg-light); }
.plain.clickable .trow { cursor: pointer; }
.plain.clickable .trow:hover { background: var(--bg-light); }
.plain .trow.sel, .plain.clickable .trow.sel:hover { background: var(--row-sel); }

/* ---------- Slicers ---------- */
.slicer { display: flex; flex-direction: column; }
.slicer .vtitle { flex: none; }
.slicer .eraser {
  position: absolute; right: 6px; top: 4px; width: 20px; height: 20px; display: none;
  border: 0; background: transparent; cursor: pointer; color: var(--fg2); padding: 0; z-index: 2;
}
.slicer:hover .eraser.on { display: block; }
.slicer .eraser:hover { color: var(--fg); }

.dd {
  margin: 6px 8px; border-bottom: 1px solid var(--fg3); height: 26px;
  display: flex; align-items: center; justify-content: space-between; cursor: pointer; padding: 0 2px;
  font-size: 13px;
}
.dd span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd svg { flex: none; }
.popup {
  position: absolute; background: var(--bg); color: var(--fg); border: 1px solid var(--neutral); box-shadow: 0 4px 12px var(--shadow);
  z-index: 500; max-height: 330px; overflow-y: auto; padding: 4px 0;
}
.popup[hidden] { display: none; }

.search {
  margin: 2px 8px 2px; display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--fg3);
  height: 24px; flex: none; color: var(--fg2);
}
.search input { border: 0; outline: 0; font: inherit; font-size: 12px; flex: 1; min-width: 0; background: transparent; color: var(--fg); }
.list { flex: 1; overflow-y: auto; position: relative; margin: 2px 0 6px; }
.item {
  height: 22px; display: flex; align-items: center; gap: 6px; padding: 0 8px; cursor: pointer;
  white-space: nowrap; font-size: 13px;
}
.list .item { position: absolute; left: 0; right: 0; }
.item:hover { background: var(--bg-light); }
.item .lbl { overflow: hidden; text-overflow: ellipsis; }
.item .chev { width: 12px; flex: none; color: var(--fg2); font-size: 9px; text-align: center; }
.cb {
  width: 13px; height: 13px; flex: none; border: 1px solid var(--fg); border-radius: 1px; background: var(--bg);
  position: relative;
}
.cb.on { background: var(--fg); }
.cb.on::after {
  content: ""; position: absolute; left: 3.5px; top: 0.5px; width: 3px; height: 7px;
  border: solid var(--bg); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg);
}
.cb.part::after { content: ""; position: absolute; left: 2px; top: 2px; right: 2px; bottom: 2px; background: var(--fg); }

/* Between slicers */
.between { padding: 4px 8px; display: flex; flex-direction: column; gap: 8px; }
.between .inputs { display: flex; gap: 4px; }
.between input[type=text] {
  width: 100%; min-width: 0; font: inherit; font-size: 12px; border: 1px solid var(--fg3); padding: 3px 4px; color: var(--fg);
  background: var(--bg); font-variant-numeric: tabular-nums;
}
.range { position: relative; height: 18px; }
.range .track { position: absolute; left: 7px; right: 7px; top: 8px; height: 2px; background: var(--neutral); }
.range .fill { position: absolute; top: 8px; height: 2px; background: var(--fg); }
.range input[type=range] {
  position: absolute; left: 0; right: 0; width: 100%; top: 0; margin: 0; height: 18px;
  background: none; pointer-events: none; -webkit-appearance: none; appearance: none;
}
.range input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; pointer-events: auto; width: 14px; height: 14px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--fg); cursor: pointer;
}
.range input[type=range]::-moz-range-thumb {
  pointer-events: auto; width: 10px; height: 10px; border-radius: 50%; background: var(--bg); border: 2px solid var(--fg); cursor: pointer;
}
.range input[type=range]::-moz-range-track { background: none; }

/* ---------- Tooltip (page d'info-bulle 320×320) ---------- */
#tooltip {
  position: absolute; z-index: 900; width: 320px; max-height: 320px; background: var(--bg); color: var(--fg);
  box-shadow: 0 2px 10px var(--shadow); border: 1px solid var(--neutral); pointer-events: none; overflow: hidden; font-size: 12px;
}
#tooltip[hidden] { display: none; }
#tooltip table { border-collapse: collapse; width: 100%; }
#tooltip th, #tooltip td { padding: 3px 6px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 142px; }
#tooltip th { font-weight: 600; border-bottom: 1px solid var(--neutral); }
#tooltip td.num, #tooltip th.num { text-align: right; font-variant-numeric: tabular-nums; }
#tooltip tr:nth-child(even) td { background: var(--bg-light); }
#tooltip .ttl { font-weight: 700; }
#tooltip.chart-tip { width: auto; max-height: none; padding: 6px 10px; font-size: 12px; }
#tooltip.chart-tip .k { color: var(--fg2); margin-right: 12px; }

/* ---------- Graphiques ---------- */
.chart svg { display: block; }
.chart text { font-family: var(--font); fill: var(--fg2); font-size: 12px; }
.chart .lbl { fill: var(--fg2); font-size: 12px; }
.chart .dl { fill: var(--fg2); font-size: 12px; }
.chart .axis-title { fill: var(--fg); font-size: 13px; }
.chart .bar { fill: var(--accent); stroke: var(--bar-stroke); stroke-width: 1; cursor: pointer; }
.chart .bar.dim { fill-opacity: .35; stroke-opacity: .35; }
.chart .grid { stroke: var(--neutral); stroke-dasharray: 1 3; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linejoin: round; }
.chart .pt { fill: var(--accent); stroke: var(--bg); stroke-width: 2; }
.chart .xhair { stroke: var(--fg2); stroke-width: 1; }
.chart .scroll { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; }

/* ---------- Panneau du bas (cellulaire) et filtres repliables ---------- */
#mFilters { display: none; }
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 800; max-height: 55vh; overflow-y: auto;
  background: var(--bg); color: var(--fg); border-top: 1px solid var(--neutral); border-radius: 12px 12px 0 0;
  box-shadow: 0 -4px 16px var(--shadow); padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
}
#sheet .sh-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
#sheet h2 { font-family: var(--font-title); font-size: 17px; margin: 0; text-wrap: balance; }
#sheet p { margin: 2px 0 0; color: var(--fg2); font-size: 13px; }
#sheet .sh-close {
  flex: none; width: 32px; height: 32px; border-radius: 16px; border: 1px solid var(--neutral);
  background: var(--bg-light); color: var(--fg); font-size: 14px; cursor: pointer;
}
#sheet table { width: 100%; border-collapse: collapse; font-size: 13px; }
#sheet th, #sheet td { text-align: left; padding: 5px 4px; border-bottom: 1px solid var(--bg-light); }
#sheet th { color: var(--fg2); font-weight: 600; }
#sheet .num { text-align: right; font-variant-numeric: tabular-nums; }
#sheet .sh-link { margin-top: 10px; }
#sheet .sh-link a { color: var(--accent-mid); }

/* ---------- Version cellulaire : tout est empilé et la page défile ---------- */
body.mobile { display: block; height: auto; overflow: visible; }
.mobile #bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 700; flex-wrap: wrap; row-gap: 4px; padding: 8px 16px;
}
.mobile #bar { column-gap: 6px; }
.mobile #bar .brand { order: 1; flex: 1; font-size: 14px; }
.mobile #coffee { padding: 4px 9px; }
.mobile #coffee { order: 2; }
/* sur cellulaire : ligne 1 = titre, café, thème ; ligne 2 = historique, partage, About, vue */
.mobile #layoutBtn { order: 7; padding: 5px 9px; height: 34px; }
.mobile #aboutBtn { order: 6; padding: 5px 9px; height: 34px; }
@media (max-width: 440px) { .mobile #shareBtn span { display: none; } }
.mobile #themeBtn { order: 3; padding: 5px 9px; }
.mobile #themeBtn .lbl, .mobile #layoutBtn .lbl, .mobile #aboutBtn .lbl { display: none; }
#bar .brand { white-space: nowrap; }
#layoutBtn[hidden] { display: none; }
.mobile #hist { order: 5; flex: 1 1 auto; }
.mobile #hist button { height: 34px; min-width: 44px; }
.mobile #bar .credit { order: 8; flex-basis: 100%; text-align: left; white-space: normal; font-size: 11px; }
.mobile #bar .copy { order: 9; flex-basis: 100%; font-size: 11px; display: block; }
/* vue ordinateur forcée sur un écran étroit : la barre reste sur une ligne */
@media (max-width: 899px) {
  body:not(.mobile) #bar { padding: 6px 10px; gap: 8px; }
  body:not(.mobile) #bar .copy, body:not(.mobile) #bar .credit, body:not(.mobile) #themeBtn .lbl, body:not(.mobile) #layoutBtn .lbl, body:not(.mobile) #aboutBtn .lbl { display: none; }
  body:not(.mobile) #stage { align-items: flex-start; }
}
.mobile #stage { display: block; overflow: visible; padding: 12px 16px 24px; }
.mobile #frame { position: static; }
.mobile #scaler { position: relative; width: auto; height: auto; transform: none !important; background: transparent; box-shadow: none; }
.mobile #page1, .mobile #page2 { position: static; width: auto; height: auto; display: flex; flex-direction: column; gap: 12px; border: 0; min-width: 0; }
.mobile #page2 { margin-top: 12px; }
.mobile .visual { position: relative !important; left: auto !important; top: auto !important; width: auto !important; }
.mobile #loading { position: fixed; align-items: flex-start; padding-top: 40vh; }

.mobile #tbDesc { order: 1; height: auto !important; font-size: 13px; padding: 0; }
.mobile #card {
  order: 2; height: auto !important; display: flex; align-items: center; justify-content: space-between;
  background: var(--bg); border: 1px solid var(--neutral); border-radius: 8px; padding: 6px 12px;
}
.mobile #card .vtitle { padding: 0; }
.mobile #card .callout { font-size: 32px; line-height: 38px; }
.mobile #mFilters { display: block; order: 3; }
.mobile #mainTable { order: 4; height: max(380px, 62vh) !important; }
.mobile #altTable { order: 5; height: 180px !important; }
.mobile #tbCredit { order: 6; height: auto !important; font-size: 12px; padding: 0; }

#mFilterBtn {
  width: 100%; min-height: 44px; font: inherit; font-size: 15px; font-weight: 600; color: var(--fg);
  background: var(--bg); border: 1px solid var(--accent-dark); border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
#mFilterBtn::after { content: "▾"; font-size: 12px; }
#mFilterBtn[aria-expanded="true"]::after { content: "▴"; }
#mFilterBody { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
#mFilterBody[hidden] { display: none; }
.mobile #mFilterBody .slicer { height: auto !important; }
/* listes longues : hauteur fixe avec défilement interne ; la page défile en touchant hors de la liste */
.mobile #mFilterBody #slDev, .mobile #mFilterBody #slPub, .mobile #mFilterBody #slName { height: 230px !important; }
.mobile #mFilterBody .list { min-height: 0; }
.mobile #slName::before {
  content: "Game title"; font-family: var(--font-title); font-size: 16px; color: var(--fg);
  padding: 4px 8px 0; line-height: 20px; flex: none;
}
.mobile #slMoy, .mobile #slMed { border: 1px solid var(--neutral); border-radius: 8px; }
.mobile .slicer .eraser.on { display: block; }
.mobile .item { height: 22px; font-size: 14px; }
.mobile .dd { height: 36px; }
.mobile .between input[type=text] { font-size: 14px; padding: 6px; }

/* Tableau principal en lignes à deux niveaux */
.mobile .flashy .thead { padding: 6px 10px !important; align-items: center; font-weight: 600; }
.msort { display: flex; align-items: center; gap: 8px; width: 100%; font-size: 13px; }
.msort select {
  flex: 1; min-width: 0; font: inherit; font-size: 14px; padding: 4px 6px; border-radius: 4px;
  border: 1px solid var(--fg3); background: var(--bg); color: var(--fg);
}
.mobile .flashy .trow.mrow { height: 48px; display: block; padding: 5px 10px; }
.mrow .m1 { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 20px; }
.mrow .m2 {
  display: flex; gap: 10px; font-size: 12px; line-height: 18px; color: var(--fg2);
  white-space: nowrap; overflow: hidden; font-variant-numeric: tabular-nums;
}
.mrow .m2 b { color: var(--fg); }
.mobile .flashy.has-sel .trow:not(.sel) .m2 b { color: inherit; }
.mtotal { padding: 6px 10px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mobile .plain .thead { font-size: 15px; font-weight: 600; }

/* Graphiques empilés, avec un titre */
.mobile .chart { height: auto !important; border: 1px solid var(--neutral); border-radius: 8px; padding: 8px 0 4px; overflow: hidden; }
.mobile .chart::before { content: attr(data-title); display: block; font-family: var(--font-title); font-size: 15px; font-weight: 600; padding: 0 12px 6px; color: var(--fg); }
.mobile #barChart .scroll { position: static; max-height: 420px; }
.mobile #tooltip { display: none; }

/* ---------- Fenêtre « About » ---------- */
#about {
  width: min(640px, calc(100% - 32px)); max-height: 85vh; overflow-y: auto; padding: 20px 24px;
  background: var(--bg); color: var(--fg); border: 1px solid var(--neutral); border-radius: 12px;
  box-shadow: 0 8px 32px var(--shadow); font-size: 14px; line-height: 1.5;
}
#about::backdrop { background: rgba(0,0,0,.45); }
#about h2 { font-family: var(--font-title); font-size: 20px; margin: 0 40px 8px 0; }
#about h3 { font-family: var(--font-title); font-size: 15px; margin: 16px 0 4px; }
#about p { margin: 0 0 8px; }
#about ul { margin: 0 0 8px; padding-left: 20px; }
#about li { margin-bottom: 4px; }
#about a { color: var(--accent-mid); }
#about .ab-ver { color: var(--fg2); font-size: 12px; }
#about .ab-close {
  position: sticky; top: 0; float: right; width: 32px; height: 32px; border-radius: 16px; border: 1px solid var(--neutral);
  background: var(--bg-light); color: var(--fg); font-size: 14px; cursor: pointer;
}
#about .ab-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
