/* V15 — Analyses › Comparer & Prévoir : tableaux de comparaison, donut, barres empilées, heatmap, projection, trajectoire. */

/* Six tabs: the switcher scrolls on narrow screens instead of widening the page. */
.analyses > .seg { overflow-x: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 10px, #000 calc(100% - 10px), transparent 100%); mask-image: linear-gradient(90deg, transparent 0, #000 10px, #000 calc(100% - 10px), transparent 100%); }
.analyses > .seg::-webkit-scrollbar { display: none; }
.analyses > .seg button { flex: 1 0 auto; padding-left: 12px; padding-right: 12px; }
.analyses .period-note .tip { vertical-align: 0; }

/* ---------- Comparer : family × (this month / reference / delta) ---------- */
.cmp { display: flex; flex-direction: column; font-size: 13px; }
.cmp-row { display: grid; grid-template-columns: minmax(84px, 1.15fr) 1fr 1fr minmax(58px, .7fr); gap: 6px; align-items: center; width: 100%; padding: 8px 2px; text-align: right; }
.cmp-row > span:first-child { text-align: left; }
.cmp-row .num { font-variant-numeric: tabular-nums; min-width: 0; }
.cmp-row strong { font-weight: 600; }
.cmp-row small.block { font-size: 11px; line-height: 1.2; white-space: nowrap; }
.cmp-head { font-size: 11px; color: var(--ink-3); font-weight: 600; border-bottom: 1px solid var(--border); padding-bottom: 6px; align-items: end; }
.cmp-head small { font-weight: 500; }
.cmp-fam { border-bottom: 1px solid var(--border); }
.cmp-main, .cmp-cat { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; border-radius: 10px; }
.cmp-main:hover, .cmp-cat:hover { background: var(--surface-2); }
.cmp-main .cmp-name { font-weight: 600; }
.cmp-name { display: flex; align-items: center; gap: 6px; min-width: 0; text-align: left; }
.cmp-name .sw { flex: none; margin: 0; }
.cmp-name .cat-ico { flex: none; }
.cmp-chev { color: var(--ink-3); font-size: 11px; margin-left: 2px; }
.cmp-explain { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 12px; padding: 0 2px 8px 24px; }
.cmp-explain .calc { margin: 0; }
.cmp-explain .calc-lines { width: 100%; }
.cmp-cats { padding: 2px 0 6px 10px; border-left: 2px solid var(--border); margin: 0 0 8px 6px; }
.cmp-cat { padding: 6px 2px; font-size: 12.5px; }
.cmp-cat .cmp-name { color: var(--ink-2); }
.cmp-total { font-weight: 600; padding-top: 10px; }
.cmp-foot { margin-top: 6px; }
.cmp .delta { font-size: 12px; }
@media (max-width: 400px) {
  .cmp-row { grid-template-columns: minmax(76px, 1fr) 1fr 1fr 60px; gap: 4px; }
  .cmp { font-size: 12.5px; }
}

/* ---------- Budget placé vs réel ---------- */
.pvr-card .table { font-size: 13px; margin-top: 8px; }
.pvr-card .table tr.static { cursor: default; }
.pvr-card .table tr.static:hover { background: transparent; }
.chart .tick.on { fill: var(--ink-1); font-weight: 700; }

/* ---------- Répartition (donut) ---------- */
.donut-wrap { display: grid; grid-template-columns: 140px 1fr; gap: 12px 16px; align-items: center; }
.donut { width: 140px; height: 140px; }
.donut-slice { cursor: pointer; transition: opacity .2s; }
.donut-big { font-size: 15px; font-weight: 700; fill: var(--ink-1); font-family: var(--font-display); letter-spacing: -.02em; }
.donut-small { font-size: 9.5px; fill: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.donut-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.donut-legend li.on .donut-leg { background: var(--surface-2); }
.donut-leg { display: flex; align-items: center; gap: 6px; width: 100%; background: none; border: 0; color: inherit; font: inherit; padding: 4px 6px; border-radius: 8px; text-align: left; cursor: pointer; }
.donut-leg .sw { flex: none; margin: 0; }
.donut-leg strong { flex: 1; font-weight: 600; }
.donut-legend small.block { padding-left: 22px; font-size: 11px; line-height: 1.3; }
.donut-cats { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.donut-cats li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 4px; border-bottom: 1px solid var(--border); }
.donut-cats li span:first-child { display: flex; align-items: center; gap: 6px; min-width: 0; }
@media (max-width: 360px) { .donut-wrap { grid-template-columns: 1fr; justify-items: center; } }

/* ---------- 12 mois par famille ---------- */
.income-line { fill: none; stroke: var(--c-income); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.income-dot { fill: var(--c-income); stroke: var(--surface); stroke-width: 1.5; }

/* ---------- Quand tu dépenses (heatmap) ---------- */
.heat { display: grid; gap: 4px; align-items: stretch; margin-bottom: 10px; }
.heat-h { font-size: 11px; color: var(--ink-3); font-weight: 600; text-align: center; line-height: 1.15; align-self: end; padding-bottom: 2px; }
.heat-h small { font-size: 9.5px; font-weight: 500; }
.heat-d { font-size: 11px; color: var(--ink-3); font-weight: 600; display: flex; align-items: center; }
.heat-c { --k: 0; min-height: 36px; border-radius: 8px; border: 1px solid var(--border); background: color-mix(in srgb, var(--accent) calc(var(--k) * 78% + 6%), var(--surface-2)); color: var(--ink-1); font: inherit; font-size: 10.5px; font-weight: 600; font-variant-numeric: tabular-nums; padding: 2px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.heat-c.empty { background: var(--surface-2); cursor: default; opacity: .55; }
.heat-c.best { box-shadow: inset 0 0 0 2px var(--accent); }
.heat-c:not(.empty):hover { filter: brightness(1.1); }
:root[data-theme="light"] .heat-c { color: var(--ink-1); }
.heat-card .calc { margin-top: 6px; }

/* ---------- Prévoir : projection ---------- */
.proj-kpis { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 480px) { .proj-kpis { grid-template-columns: 1fr 1fr; } .proj-kpis > :first-child { grid-column: 1 / -1; } }
.proj-kpis .kpi strong { font-size: 20px; }
.proj-kpis .kpi.is-open { box-shadow: inset 0 0 0 1px var(--accent-line); }
.proj-kpis .kpi > span:first-child { display: flex; align-items: center; gap: 2px; }
.proj-card .chart { margin-top: 10px; }
.proj-prev { fill: none; stroke: var(--ink-3); stroke-width: 1.5; opacity: .45; }
.proj-dotted { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 3 5; stroke-linecap: round; }
.proj-band { fill: var(--accent); opacity: .14; }
.proj-end { fill: var(--accent-text); font-weight: 700; }

/* ---------- Prévoir : dérive ---------- */
.drift-list, .drift-compact, .gf-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.drift { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border-left: 3px solid var(--st-serious); display: flex; flex-direction: column; gap: 6px; }
.drift.is-over { border-left-color: var(--st-critical); }
.drift-head, .gf-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.drift-name { display: flex; align-items: center; gap: 6px; font-weight: 600; min-width: 0; }
.drift-name .emoji { font-size: 15px; }
.drift p { font-size: 13.5px; color: var(--ink-2); margin: 0; }
.drift .calc { margin: 0; }
.drift-ok { margin-top: 10px; }
.drift-ok summary { cursor: pointer; color: var(--ink-2); font-weight: 600; font-size: 13px; margin-bottom: 8px; }
.drift-compact { gap: 2px; }
.drift-compact li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding: 6px 4px; border-bottom: 1px solid var(--border); font-size: 13px; }
.drift-compact li .calc { grid-column: 1 / -1; margin: 0; }
.drift-compact li .calc-btn { font-size: 11px; }
.drift-compact .drift-name { font-weight: 500; }

/* ---------- Prévoir : trajectoire ---------- */
.traj-card .table { font-size: 12.5px; margin-top: 8px; }
.traj-card .table th, .traj-card .table td { padding: 6px 4px; }
.traj-card .table tr.static { cursor: default; }
.traj-card .table tr.static:hover { background: transparent; }
.traj-card .table tr.is-neg td { background: color-mix(in srgb, var(--st-critical) 10%, transparent); }
.traj-neg { fill: var(--st-critical); stroke: var(--surface); stroke-width: 2; }
.traj-card .legend .sw { margin-right: 4px; }

/* ---------- Prévoir : objectifs ---------- */
.gf { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border-left: 3px solid var(--g-epargne); display: flex; flex-direction: column; gap: 6px; }
.gf.is-late { border-left-color: var(--st-serious); }
.gf-name { font-weight: 600; display: flex; align-items: center; gap: 6px; min-width: 0; }
.gf-body { display: flex; gap: 12px; align-items: flex-start; }
.gf-body .spark { flex: none; margin-top: 2px; }
.gf-body p { margin: 0; color: var(--ink-2); min-width: 0; }
.gf .calc { margin: 0; }

/* ---------- V25 — Aperçus par catégorie : « Avant de dépenser » (Accueil), « Puis-je ? », pills, carte Aperçus ---------- */
.quickcheck .card-head h2 { display: flex; align-items: center; gap: 4px; }
.qc-chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 4px; margin: 0 -2px; -webkit-overflow-scrolling: touch; }
.qc-chips::-webkit-scrollbar { display: none; }
.qc-chip { --qc: var(--st-good); flex: none; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 112px; max-width: 150px; padding: 9px 11px 8px; border-radius: 14px; border: 1px solid color-mix(in srgb, var(--qc) 35%, var(--border)); background: color-mix(in srgb, var(--qc) 9%, var(--surface-2)); color: var(--ink-1); font: inherit; text-align: left; cursor: pointer; transition: transform .15s var(--ease), background .2s; }
.qc-chip:active { transform: scale(.97); }
.qc-chip.qc-attention { --qc: var(--st-warning); }
.qc-chip.qc-stop { --qc: var(--st-critical); }
.qc-chip-name { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--ink-2); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qc-chip-name .cat-ico { flex: none; }
.qc-chip-val { font-size: 19px; font-weight: 700; letter-spacing: -0.03em; color: var(--qc); font-variant-numeric: tabular-nums; }
.qc-chip.qc-attention .qc-chip-val { color: var(--warn-ink); }
.qc-chip-word { font-size: 11px; font-weight: 600; color: var(--ink-3); white-space: nowrap; }
.qc-more { min-width: 44px; max-width: 44px; align-items: center; justify-content: center; font-size: 22px; font-weight: 500; color: var(--ink-2); --qc: var(--ink-3); background: var(--surface-2); border-color: var(--border); }

/* « Puis-je ? » */
.qc-status { --qc: var(--st-good); display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--qc) 12%, var(--surface-2)); border-left: 4px solid var(--qc); margin-bottom: 12px; }
.qc-status.qc-attention { --qc: var(--st-warning); }
.qc-status.qc-stop { --qc: var(--st-critical); }
.qc-status-word { font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -0.03em; color: var(--qc); line-height: 1.1; }
.qc-status.qc-attention .qc-status-word { color: var(--warn-ink); }
.qc-msg { margin: 0; font-size: 14px; color: var(--ink-1); line-height: 1.4; }
.qc-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.qc-tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.qc-tile > span:first-child { font-size: 11.5px; color: var(--ink-3); font-weight: 600; display: flex; align-items: center; gap: 2px; }
.qc-tile strong { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qc-tile strong .muted { font-size: 14px; font-weight: 500; }
.qc-tile small { font-size: 11px; line-height: 1.3; }
.qc-anomaly { margin: 10px 0 0; padding: 8px 12px; border-radius: 10px; font-size: 13px; background: color-mix(in srgb, var(--st-serious) 12%, transparent); color: var(--ink-1); }
.qc-anomaly.down { background: color-mix(in srgb, var(--st-good) 12%, transparent); }
.qc-drift { margin: 10px 0 0; padding: 8px 12px; border-radius: 10px; font-size: 13px; background: color-mix(in srgb, var(--st-warning) 14%, transparent); color: var(--ink-1); overflow-wrap: anywhere; }
.qc-cap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px dashed var(--border); }
.qc-cap > div { display: flex; flex-direction: column; min-width: 0; }
.qc-cap > div > span:first-child { display: flex; align-items: center; gap: 2px; }
.qc-cap strong { font-size: 18px; font-weight: 700; }
.qc-cap .calc { width: 100%; margin: 0; text-align: left; }
.sheet .qc-status + .qc-tiles + .calc, .sheet .qc-cap + .calc { margin-top: 10px; }

/* Budgets par catégorie : pills « À surveiller » */
.env-watch { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 2px 0 8px; }
.env-watch > span:first-child { display: inline-flex; align-items: center; gap: 2px; margin-right: 2px; }
.env-watch-pill { border: 1px solid color-mix(in srgb, var(--st-warning) 40%, var(--border)); background: color-mix(in srgb, var(--st-warning) 10%, var(--surface-2)); color: var(--ink-1); border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.env-watch-pill .muted { font-weight: 500; font-variant-numeric: tabular-nums; }

/* Analyses › Catégories › Aperçus */
.insights-card .seg { margin-bottom: 8px; overflow-x: auto; scrollbar-width: none; }
.insights-card .seg::-webkit-scrollbar { display: none; }
.insights-card .seg button { flex: 1 0 auto; white-space: nowrap; }
.ins-explain { margin: 0 0 6px; line-height: 1.4; }
.ins-explain .tip { vertical-align: 0; }
.ins-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ins-row { border-bottom: 1px solid var(--border); padding: 2px 0 4px; }
.ins-row:last-child { border-bottom: 0; }
.ins-row .calc { margin: 0 0 4px 2px; }
.ins-row .calc-btn { font-size: 11.5px; }
.ins-main { display: grid; grid-template-columns: minmax(96px, 1fr) minmax(0, auto); gap: 2px 10px; align-items: center; width: 100%; padding: 8px 4px; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: 10px; }
.ins-main:hover { background: var(--surface-2); }
.ins-name { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ins-name .cat-ico { flex: none; }
.ins-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ins-vals { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; min-width: 0; max-width: 100%; text-align: right; justify-self: end; }
.ins-vals strong { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ins-vals strong .muted { font-size: 12px; font-weight: 500; }
.ins-sub { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px 8px; font-size: 11.5px; color: var(--ink-3); line-height: 1.25; }
.ins-trend.neg { color: var(--st-critical); } .ins-trend.pos { color: var(--st-good); }
.ins-bar { display: block; width: 110px; height: 5px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.ins-bar span { display: block; height: 100%; border-radius: 4px; background: var(--st-good); }
.ins-none { margin: 6px 0 2px; }

/* Budgets vs revenus du mois */
.env-income { padding: 12px 14px; display: grid; gap: 8px; }
.env-income.over { border-color: color-mix(in srgb, var(--neg) 45%, var(--border)); }
.env-income.room, .env-income.exact { border-color: color-mix(in srgb, var(--st-good) 40%, var(--border)); }
.env-income.spend-over { border-color: color-mix(in srgb, var(--st-warning) 50%, var(--border)); }
.env-income .warn { color: var(--warn-ink); }
.env-gauge { position: relative; }
.env-gauge-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink-1); border-radius: 1px; }
.env-mark-legend { color: var(--ink-1); font-weight: 700; }
.env-income .btn-row { gap: 14px; flex-wrap: wrap; }
.env-income .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; margin: 0 3px 0 2px; background: var(--st-good); }
.env-income .dot.save { background: var(--accent); } .env-income .dot.free { background: var(--surface-3); border: 1px solid var(--border-strong); }
.env-income-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.env-income-head > strong { white-space: nowrap; font-variant-numeric: tabular-nums; }
.env-gauge { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; display: flex; }
.env-gauge i { display: block; height: 100%; background: var(--st-good); transition: width .3s; }
.env-gauge i.save { background: var(--accent); }
.env-gauge i.neg { background: var(--neg); }
.env-income p { margin: 0; }
.env-cuts { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.env-cuts li { display: flex; align-items: center; gap: 8px; }
.env-cuts li > span:first-of-type { flex: 1; font-weight: 600; }
.env-cuts .num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Accueil · rythme de dépenses (speedometer) */
.spend-gauge { display: grid; gap: 6px; padding: 14px 16px 12px; border-color: color-mix(in srgb, var(--gz) 35%, var(--border)); background: linear-gradient(180deg, color-mix(in srgb, var(--gz) 9%, var(--surface)), var(--surface)); }
.sg-head { display: flex; justify-content: space-between; align-items: center; }
.sg-ratio { font-weight: 700; font-size: 15px; color: var(--gz); font-variant-numeric: tabular-nums; }
.sg-dial { width: min(100%, 300px); margin: -4px auto -10px; display: block; overflow: visible; }
.sg-tick { font-size: 9px; fill: var(--ink-3); font-family: var(--mono, ui-monospace, monospace); letter-spacing: .04em; }
.sg-needle { stroke-width: 3.5; stroke-linecap: round; transform-origin: 100px 100px; transition: all .8s cubic-bezier(.2, .9, .3, 1.2); filter: drop-shadow(0 0 4px color-mix(in srgb, var(--gz) 60%, transparent)); }
.sg-zone { display: flex; align-items: center; gap: 12px; }
.sg-zone strong { font-size: 17px; }
.sg-zone p { margin: 2px 0 0; }
.sg-emoji { font-size: 34px; line-height: 1; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .25)); animation: sg-pop .5s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes sg-pop { from { transform: scale(.4) rotate(-20deg); opacity: 0; } to { transform: none; opacity: 1; } }
.sg-sub { margin: 0; }
@media (prefers-reduced-motion: reduce) { .sg-needle, .sg-emoji { transition: none; animation: none; } }
.basis-switch { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.msd-split .msd-aside { color: var(--ink-3); border-top: 1px dashed var(--border); padding-top: 6px; margin-top: 4px; }

/* « Payé ✓ » on a planned fixed payment */
.pay-check { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 1.5px dashed var(--border-strong); background: transparent; color: var(--ink-3); display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; transition: all .15s; }
.pay-check:hover, .pay-check:focus-visible { border-style: solid; border-color: var(--st-good); color: var(--st-good); background: color-mix(in srgb, var(--st-good) 12%, transparent); }
.pay-check:active { transform: scale(.9); }
.upcoming li { grid-template-columns: 40px 1fr auto 34px; }
.pay-slot { width: 34px; height: 34px; }
.fixes-month li:has(.pay-check) { display: flex; align-items: center; gap: 8px; }
.fixes-month li:has(.pay-check) > .row { flex: 1; min-width: 0; }

/* ---------- Filtre global d'Analyses (sous les onglets, identique partout) ---------- */
.an-filter { margin: 8px 0 12px; }
.an-filter .fbar-chips { gap: 6px; }
.an-filter .fbar-result { margin-left: 0; }
.analyses .not-filtered { margin: 6px 0 0; font-style: italic; }
.calc-row .see-tx { margin-top: 6px; display: inline-block; }
.donut-cats li { display: block; padding: 0; }
.donut-cat { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; padding: 6px 4px; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: 8px; }
.donut-cat:hover { background: var(--surface-2); }
.donut-cat > span:first-child { display: flex; align-items: center; gap: 6px; min-width: 0; }
.an-filter .fbar-row { flex-wrap: nowrap; }
.an-filter .fbar-row > .an-sub { order: -1; margin: 0; min-width: 0; }
.an-filter .fbar-btn { margin-left: auto; flex: none; }
