/* Tableau de bord visuel — finances-atlas
   Mise en page : en-tête collant en verre, deux vues (Synthèse / Carte) ;
   la carte occupe la largeur, le panneau de détail se place à droite (en dessous sur iPhone). */
:root {
  --bg: #f2f2f7;
  --bg-blob-1: rgba(255, 59, 48, 0.10);
  --bg-blob-2: rgba(0, 122, 255, 0.10);
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --fg: #1d1d1f;
  --fg-2: #6e6e73;
  --fg-3: #8e8e93;
  --hair: rgba(60, 60, 67, 0.14);
  --accent: #ff3b30;
  --accent-deep: #a1140b;
  --map-low: #fde7e5;
  --map-empty: #e3e3e8;
  --map-stroke: #ffffff;
  --glass-tint: rgba(255, 255, 255, 0.55);
  --glass-edge: rgba(255, 255, 255, 0.85);
  --glass-shadow: 0 8px 28px rgba(0, 0, 0, 0.10), 0 1px 2px rgba(0, 0, 0, 0.06);
  --thumb: rgba(255, 255, 255, 0.92);
  --c1: #007aff; --c2: #ff9500; --c3: #34c759; --c4: #af52de; --c5: #ff3b30; --c6: #30b0c7;
  --c7: #ffcc00; --c8: #5856d6; --c9: #ff2d55; --c10: #a2845e; --c11: #00c7be; --c12: #8e8e93;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --radius: 22px;
  --radius-sm: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --bg-blob-1: rgba(255, 69, 58, 0.16);
    --bg-blob-2: rgba(10, 132, 255, 0.14);
    --surface: rgba(28, 28, 30, 0.72);
    --surface-solid: #1c1c1e;
    --fg: #f5f5f7;
    --fg-2: #a1a1a6;
    --fg-3: #8e8e93;
    --hair: rgba(84, 84, 88, 0.45);
    --accent: #ff453a;
    --accent-deep: #ff8a80;
    --map-low: #3a1c1a;
    --map-empty: #2c2c2e;
    --map-stroke: #000000;
    --glass-tint: rgba(44, 44, 46, 0.50);
    --glass-edge: rgba(255, 255, 255, 0.18);
    --glass-shadow: 0 8px 28px rgba(0, 0, 0, 0.55), 0 1px 2px rgba(0, 0, 0, 0.4);
    --thumb: rgba(99, 99, 102, 0.75);
    --c1: #0a84ff; --c2: #ff9f0a; --c3: #30d158; --c4: #bf5af2; --c5: #ff453a; --c6: #40c8e0;
    --c7: #ffd60a; --c8: #5e5ce6; --c9: #ff375f; --c10: #ac8e68; --c11: #63e6e2; --c12: #98989d;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000;
  --bg-blob-1: rgba(255, 69, 58, 0.16);
  --bg-blob-2: rgba(10, 132, 255, 0.14);
  --surface: rgba(28, 28, 30, 0.72);
  --surface-solid: #1c1c1e;
  --fg: #f5f5f7;
  --fg-2: #a1a1a6;
  --fg-3: #8e8e93;
  --hair: rgba(84, 84, 88, 0.45);
  --accent: #ff453a;
  --accent-deep: #ff8a80;
  --map-low: #3a1c1a;
  --map-empty: #2c2c2e;
  --map-stroke: #000000;
  --glass-tint: rgba(44, 44, 46, 0.50);
  --glass-edge: rgba(255, 255, 255, 0.18);
  --glass-shadow: 0 8px 28px rgba(0, 0, 0, 0.55), 0 1px 2px rgba(0, 0, 0, 0.4);
  --thumb: rgba(99, 99, 102, 0.75);
  --c1: #0a84ff; --c2: #ff9f0a; --c3: #30d158; --c4: #bf5af2; --c5: #ff453a; --c6: #40c8e0;
  --c7: #ffd60a; --c8: #5e5ce6; --c9: #ff375f; --c10: #ac8e68; --c11: #63e6e2; --c12: #98989d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40rem 30rem at 85% -5%, var(--bg-blob-1), transparent 70%),
    radial-gradient(36rem 28rem at -5% 30%, var(--bg-blob-2), transparent 70%),
    var(--bg);
}
.wrap { max-width: 1280px; margin-inline: auto; padding-inline: 16px; padding-block: 0 40px; }

/* ---------- Verre liquide ---------- */
.glass {
  position: relative;
  background: var(--glass-tint);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-edge), inset 0 -1px 0 rgba(255, 255, 255, 0.06);
}
.glass::before {
  content: "";
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0.08) 38%, rgba(255, 255, 255, 0) 60%);
  mix-blend-mode: soft-light;
}
button { font: inherit; color: inherit; }
.btn {
  border-radius: 999px; border: 0; padding: 8px 14px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px;
  transition: transform .18s ease, box-shadow .18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(.97); }
.btn:focus-visible, .seg button:focus-visible, .list-row:focus-visible { outline: 2px solid var(--c1); outline-offset: 2px; }
.icon-btn { width: 38px; height: 38px; padding: 0; justify-content: center; }
.icon-btn svg { width: 18px; height: 18px; }
a.btn { color: var(--fg); text-decoration: none; }
.logout-btn:hover { color: var(--accent); }

.seg { display: inline-flex; position: relative; border-radius: 999px; padding: 4px; gap: 0; }
.seg button {
  position: relative; z-index: 1; border: 0; background: transparent; cursor: pointer;
  padding: 7px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; color: var(--fg-2);
  transition: color .2s ease;
}
.seg button[aria-pressed="true"] { color: var(--fg); }
.seg .thumb {
  position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 4px; border-radius: 999px;
  background: var(--thumb);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  transition: transform .35s cubic-bezier(.3, 1.3, .5, 1), width .35s cubic-bezier(.3, 1.3, .5, 1);
}
.seg.small button { padding: 5px 12px; font-size: 13px; }

/* ---------- En-tête ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  margin-inline: -16px; padding: 12px 16px;
}
.topbar-inner {
  max-width: 1280px; margin-inline: auto; border-radius: 999px; padding: 8px 8px 8px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.brand { display: flex; flex-direction: column; min-width: 0; }
.brand h1 { margin: 0; font: 700 17px/1.2 var(--font-display); letter-spacing: -0.01em; }
.brand span { color: var(--fg-2); font-size: 12px; }
.actions { display: flex; align-items: center; gap: 8px; }

.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 18px 4px 14px; }
.view-head h2 { margin: 0; font: 700 clamp(26px, 3.4vw, 34px)/1.1 var(--font-display); letter-spacing: -0.025em; text-wrap: balance; }
.view-head p { margin: 4px 0 0; color: var(--fg-2); max-width: 62ch; }

/* ---------- Cartes ---------- */
.card {
  background: var(--surface);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
  border-radius: var(--radius);
  border: 1px solid var(--hair);
  padding: 18px;
  min-width: 0;
}
.card h3 { margin: 0; font: 600 17px/1.25 var(--font-display); letter-spacing: -0.01em; }
.card .sub { margin: 2px 0 12px; color: var(--fg-2); font-size: 13px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.span-all { grid-column: 1 / -1; }

/* Anneaux */
.donut-wrap { display: grid; grid-template-columns: 170px 1fr; gap: 16px; align-items: center; }
@media (max-width: 420px) { .donut-wrap { grid-template-columns: 1fr; justify-items: center; } }
.donut { position: relative; width: 170px; height: 170px; }
.donut svg { width: 100%; height: 100%; overflow: visible; }
.donut path { cursor: pointer; transition: opacity .2s ease, transform .2s ease; }
.donut.has-focus path:not(.on) { opacity: .28; }
.donut .center {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; pointer-events: none; padding: 34px;
}
.donut .center b { font: 700 24px/1 var(--font-display); letter-spacing: -0.02em; }
.donut .center span { font-size: 11px; color: var(--fg-2); margin-top: 4px; line-height: 1.2; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; min-width: 0; width: 100%; }
.legend li {
  display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center;
  padding: 4px 8px; border-radius: 8px; cursor: default; font-size: 13px;
}
.legend li.on { background: var(--hair); }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.legend .nm { line-height: 1.25; overflow-wrap: anywhere; }
.legend .pc { color: var(--fg-2); font-weight: 600; }

/* Barres sociétés */
.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(7rem, 30%) 1fr 4.5rem; gap: 10px; align-items: center; font-size: 13px; padding: 3px 6px; border-radius: 8px; }
.bar-row:hover { background: var(--hair); }
.bar-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { height: 12px; border-radius: 6px; background: var(--hair); overflow: hidden; display: flex; }
.bar-row .track span { height: 100%; }
.bar-row .pc { text-align: right; font-weight: 600; }
.bar-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--fg-2); margin-bottom: 10px; }
.bar-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- Carte ---------- */
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start; }
@media (max-width: 960px) { .map-layout { grid-template-columns: 1fr; } }
.map-card { padding: 0; overflow: hidden; position: relative; }
.map-box { position: relative; width: 100%; aspect-ratio: 1.9 / 1; max-width: 100%; }
.map-box svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.map-box svg:active { cursor: grabbing; }
.country { stroke: var(--map-stroke); stroke-width: .5; vector-effect: non-scaling-stroke; transition: fill .25s ease; cursor: pointer; }
.country.empty { cursor: default; }
.country.hover { stroke: var(--fg); stroke-width: 1.2; }
.country.selected { stroke: var(--fg); stroke-width: 2; }
.dot { stroke: var(--map-stroke); stroke-width: 1; vector-effect: non-scaling-stroke; cursor: pointer; }
.dot.selected { stroke: var(--fg); stroke-width: 2; }
.map-tools { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 8px; z-index: 2; }
.map-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 18px 16px; border-top: 1px solid var(--hair); }
.scale { display: flex; align-items: flex-end; gap: 0; }
.scale div { display: flex; flex-direction: column; align-items: center; font-size: 10px; color: var(--fg-2); }
.scale i { display: block; width: 34px; height: 10px; }
.scale div:first-child i { border-radius: 5px 0 0 5px; }
.scale div:last-child i { border-radius: 0 5px 5px 0; }
.map-foot .note { font-size: 12px; color: var(--fg-2); }

.panel { border-radius: var(--radius); padding: 18px; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 84px); max-height: calc(100vh - 110px); display: flex; flex-direction: column; min-width: 0; }
@media (max-width: 960px) { .panel { position: static; max-height: none; } .panel .list { max-height: 62vh; } }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.panel-head h3 { margin: 0; font: 700 22px/1.15 var(--font-display); letter-spacing: -0.02em; }
.panel-head .meta { color: var(--fg-2); font-size: 13px; margin-top: 2px; }
.big { font: 700 40px/1 var(--font-display); letter-spacing: -0.03em; margin: 14px 0 2px; color: var(--accent); }
.big small { font-size: 18px; color: var(--fg-2); font-weight: 600; margin-left: 4px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 14px; }
.chip { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--hair); color: var(--fg-2); }
.list { overflow: auto; margin-inline: -6px; padding-inline: 6px; min-height: 0; }
.list-row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 8px; border-radius: 10px; font-size: 13px;
  border: 0; background: transparent; width: 100%; text-align: left;
}
button.list-row { cursor: pointer; }
button.list-row:hover { background: var(--hair); }
.list-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.list-row .pc { font-weight: 600; }
.list-row .sm { grid-column: 1 / -1; color: var(--fg-3); font-size: 11px; }
.list-row .tr { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: var(--hair); overflow: hidden; }
.list-row .tr span { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.rank { color: var(--fg-3); font-weight: 500; margin-right: 6px; }
.panel .seg { align-self: flex-start; margin-bottom: 10px; }

/* ---------- Info-bulle ---------- */
.tip {
  position: fixed; z-index: 50; pointer-events: none; min-width: 180px; max-width: 280px;
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 12.5px; opacity: 0; transform: translateY(4px);
  transition: opacity .15s ease, transform .15s ease;
}
.tip.on { opacity: 1; transform: translateY(0); }
.tip h4 { margin: 0 0 2px; font: 600 14px/1.25 var(--font-display); }
.tip .v { font: 700 20px/1.1 var(--font-display); color: var(--accent); margin-bottom: 6px; }
.tip ul { list-style: none; margin: 0; padding: 6px 0 0; border-top: 1px solid var(--hair); display: grid; gap: 2px; }
.tip li { display: flex; justify-content: space-between; gap: 12px; color: var(--fg-2); }
.tip li b { color: var(--fg); font-weight: 600; }

footer.meta { margin-top: 22px; color: var(--fg-3); font-size: 12px; display: grid; gap: 4px; padding-inline: 4px; }

.empty-state { color: var(--fg-2); padding: 40px 0; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before { transition: none !important; animation: none !important; }
}
.tip .sub { color: var(--fg-2); font-size: 11.5px; margin-bottom: 4px; }
