/* ================================================================
   Budget Perso – one-pager, DA Méthode LIBRE
   ================================================================ */

/* --- tooltip camembert --- */
#bp-chart-tip {
  position: fixed;
  z-index: 9999;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--font-d);
  font-size: 0.8rem;
  line-height: 1.5;
  padding: 7px 11px;
  border-radius: 8px;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .12s;
}
#bp-chart-tip.visible { opacity: 1; }
#bp-chart-tip strong { font-weight: 600; }

/* --- layout one-pager ---
   >= 1000px : bandeau = rail fixe, pas de hauteur.
   La variable --bp-hero-h synchronise hero et bp-app.
   < 1000px  : bandeau sticky 64px + hero auto.
   < 680px   : tout défile. */
body.bp-page { --bp-hero-h: clamp(195px, 26vw, 320px); }

/* Hero avec les onglets à l'intérieur */
.bp-hero {
  height: var(--bp-hero-h) !important;
  flex-direction: column !important;
  justify-content: flex-start !important;
  padding-bottom: 16px !important;
  gap: 0;
  align-items: center;
}
.bp-hero .wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
}
.bp-hero .bp-tabs-row {
  width: 100%;
  padding: 0 clamp(18px,3vw,40px);
  box-sizing: border-box;
  justify-content: center;
  flex-shrink: 0;
}
.bp-hero .bp-tab {
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.8);
  border-color: rgba(255,255,255,0.25);
}
.bp-hero .bp-tab:hover {
  background: rgba(255,255,255,0.28);
  color: #fff;
  border-color: rgba(255,255,255,0.4);
}
.bp-hero .bp-tab.actif {
  background: rgba(255,255,255,0.9);
  color: var(--brown);
  border-color: transparent;
}

.bp-app {
  display: flex;
  flex-direction: column;
  padding: 14px 20px 40px;
  gap: 10px;
  box-sizing: border-box;
}


@media (max-width: 999px) {
  body.bp-page { --bp-hero-h: calc(64px + clamp(195px, 26vw, 320px)); }
}
@media (max-width: 719px) {
  body.bp-page { --bp-hero-h: calc(64px + 220px); }
}

/* --- onglets --- */
.bp-tabs-row {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.bp-tab {
  font-family: var(--font-d);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 7px 18px;
  border-radius: 100px;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .18s, color .18s, border-color .18s;
}
.bp-tab:hover { background: var(--cream); color: var(--ink); }
.bp-tab.actif {
  background: var(--brown);
  color: var(--cream);
  border-color: var(--brown);
}

/* --- dashboard --- */
#bpDashboard {
  display: none;
  padding-bottom: 14px;
}
.dash-titre {
  font-family: var(--font-d);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.dash-kpi-row {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.dash-blocs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.dash-bloc {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--rcard);
  box-shadow: var(--sh-card);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  max-height: 260px;
}
.dash-sous-titre {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 10px 0 6px;
}
.dash-sous-titre:first-child { margin-top: 0; }
.dash-ligne {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}
.dash-ligne:last-child { border-bottom: none; }
.dash-label { flex: 1; color: var(--ink); }
.dash-mt { font-weight: 500; font-variant-numeric: tabular-nums; color: var(--ink); }

/* --- top : mois + KPI --- */
.bp-top { flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; }

/* --- navigation mois --- */
.bp-mois-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.bp-annee-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.bp-annee-nav span {
  font-family: var(--font-s);
  font-weight: 500;
  font-size: 1.05rem;
  color: var(--ink);
  min-width: 52px;
  text-align: center;
  letter-spacing: -0.02em;
}

.bp-annee-btn {
  background: none;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: background .18s, color .18s;
  padding: 0;
}
.bp-annee-btn:hover { background: var(--cream); color: var(--ink); }

.bp-bulles {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  flex: 1;
}

.bp-bulle {
  font-family: var(--font-d);
  font-size: 13px;
  font-weight: 400;
  padding: 5px 13px;
  border-radius: 100px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .18s, color .18s, border-color .18s;
  white-space: nowrap;
}
.bp-bulle:hover { background: var(--cream); color: var(--ink); }
.bp-bulle.actif {
  background: var(--cream-2);
  color: var(--brown);
  border-color: rgba(243,189,63,.55);
  font-weight: 600;
}

/* --- KPI --- */
.bp-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.bp-kpi {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--rcard);
  box-shadow: var(--sh-card);
  padding: 16px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bp-kpi.bp-kpi-chart {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.bp-kpi-info { display: flex; flex-direction: column; gap: 4px; }
.bp-kpi-info .eyebrow { margin: 0; }
.bp-kpi-donut {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.bp-kpi-tete {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bp-kpi-tete .eyebrow { margin: 0; }

.bp-add {
  border: none;
  background: transparent;
  color: var(--brown);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: color .18s, transform .18s;
}
.bp-add:hover {
  color: var(--gold);
  transform: scale(1.18);
}

.bp-gros {
  font-family: var(--font-s);
  font-weight: 500;
  font-size: clamp(22px, 2.6vw, 36px);
  letter-spacing: -0.03em;
  color: var(--ink);
  margin: 0;
  line-height: 1.1;
}
.bp-gros.pos { color: var(--ok); }
.bp-gros.neg { color: var(--stop); }

/* --- tag sur les lignes --- */
.bp-tag {
  font-family: var(--font-d);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 100px;
  border: 1px solid var(--line-2);
  background: var(--white);
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background .16s, color .16s, border-color .16s;
  min-width: 76px;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.bp-tag:hover { background: var(--cream); color: var(--brown); border-color: var(--line); }
.bp-tag.bp-tag-actif { font-size: 11px; }

/* --- tag readonly (mois précédent) --- */
.bp-tag-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.bp-tag-dot-vide { background: var(--line-2); }

/* --- emoji ressenti (rentrées) --- */
.bp-feeling {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px;
  flex-shrink: 0;
  opacity: 0.3;
  transition: opacity .18s, transform .18s;
}
.bp-feeling:hover { opacity: 0.7; transform: scale(1.2); }
.bp-feeling.bp-feeling-set { opacity: 1; }

/* --- camemberts --- */
.bp-charts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}
.bp-chart-bloc {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--rcard);
  box-shadow: var(--sh-card);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 0;
}
.bp-chart-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.bp-chart-svg-wrap { position: relative; }
.bp-chart-total {
  flex: 1;
  text-align: right;
  font-family: var(--font-s);
  font-weight: 500;
  font-size: clamp(26px, 3vw, 44px);
  letter-spacing: -0.03em;
  color: var(--ink);
  margin: 0;
  line-height: 1;
}
.bp-chart-legend-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 200px;
}
.bp-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  color: var(--ink);
  white-space: nowrap;
}
.bp-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.bp-legend-pct {
  margin-left: auto;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.bp-legend-vide {
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
  margin: 0;
}

/* --- zone budget : top (KPI+charts) + colonnes côte à côte --- */
#bpBudgetZone {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bp-colonnes {
  display: grid;
  grid-template-columns: 2fr 3fr;
  gap: 14px;
  padding-bottom: 14px;
}

.bp-colonne {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--rcard);
  box-shadow: var(--sh-card);
  padding: 14px 18px 12px;
  display: flex;
  flex-direction: column;
}

.bp-colonne-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.bp-colonne-titre {
  font-family: var(--font-s);
  font-weight: 500;
  font-size: clamp(18px, 1.6vw, 22px);
  letter-spacing: -0.025em;
  color: var(--ink);
  margin: 0;
}

.bp-scroll {
  overflow: visible;
}

/* --- lignes d'entrées --- */
.bp-ligne {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.bp-ligne:last-of-type { border-bottom: none; }

.bp-label-input {
  flex: 1;
  font-family: var(--font-d);
  font-size: 0.92rem;
  font-weight: 300;
  color: var(--ink);
  border: none;
  background: transparent;
  outline: none;
  min-width: 0;
  padding: 3px 5px;
  border-radius: 5px;
}
.bp-label-input:focus { background: var(--cream); outline: 1px solid var(--line-2); }
.bp-label-input::placeholder { color: var(--on-dark-7); }

/* --- date --- */
input.bp-date-input {
  flex: 0 0 150px;
  width: 150px;
  max-width: 150px;
  font-family: var(--font-d);
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--muted);
  padding: 6px 8px;
  cursor: pointer;
}
input.bp-date-input:focus { color: var(--ink); }
input.bp-date-input::-webkit-calendar-picker-indicator { opacity: 0.4; cursor: pointer; }
.bp-date-ro {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  flex-shrink: 0;
  min-width: 20px;
  text-align: right;
}

.bp-montant-wrap { display: flex; align-items: center; gap: 3px; flex-shrink: 0; }

input.bp-montant-input {
  width: 75px;
  text-align: right;
  font-family: var(--font-d);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink);
  padding: 6px 8px;
  font-variant-numeric: tabular-nums;
}
input.bp-montant-input::-webkit-inner-spin-button,
input.bp-montant-input::-webkit-outer-spin-button { -webkit-appearance: none; }

.bp-devise {
  font-size: 0.82rem;
  color: var(--muted);
  flex-shrink: 0;
}

.bp-suppr {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .18s, color .18s;
  padding: 0;
}
.bp-suppr:hover { background: var(--stop-soft); color: var(--stop); }

/* --- empty state --- */
.bp-vide {
  color: var(--muted);
  font-size: 0.88rem;
  font-style: italic;
  padding: 10px 0;
  margin: 0;
}

/* --- mois précédent --- */
.bp-prev {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line-2);
}

.bp-prev-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.bp-prev-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.bp-dup-all {
  font-size: 0.75rem;
  font-family: var(--font-d);
  color: var(--brown);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.bp-dup-all:hover { color: var(--gold); }
.bp-dup-all-header { font-size: 0.7rem; opacity: 0.7; display: block; margin: -6px 0 10px; text-align: left; }

.bp-ligne-prev {
  opacity: 0.5;
  transition: opacity .18s;
}
.bp-ligne-prev:hover { opacity: 0.75; }

.bp-label-ro {
  flex: 1;
  font-family: var(--font-d);
  font-size: 0.92rem;
  color: var(--muted);
  padding: 3px 5px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bp-montant-ro {
  font-family: var(--font-d);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-width: 72px;
  text-align: right;
  padding: 3px 5px;
}

.bp-dup {
  font-family: var(--font-d);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 100px;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--brown);
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background .18s, border-color .18s;
}
.bp-dup:hover { background: var(--cream-2); border-color: var(--gold); }

/* --- budget cible --- */
#bpCible {
  display: none;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 14px;
}

.cible-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.cible-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.cible-revenu-moyen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.cible-revenu-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.cible-revenu-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.cible-revenu-input {
  width: 120px;
  text-align: right;
  font-family: var(--font-s);
  font-size: clamp(24px, 2.5vw, 36px);
  font-weight: 500;
  letter-spacing: -0.03em;
  color: var(--ink);
  border: none;
  border-bottom: 2px solid var(--line-2);
  background: transparent;
  outline: none;
  padding: 4px 6px;
}
.cible-revenu-input:focus { border-bottom-color: var(--gold); }
.cible-revenu-input::-webkit-inner-spin-button,
.cible-revenu-input::-webkit-outer-spin-button { -webkit-appearance: none; }

.cible-body { flex: 1; min-height: 0; }

.cible-methodes-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
  margin-bottom: 4px;
}

.cible-methode-btn {
  font-family: var(--font-d);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 7px 18px;
  border-radius: 100px;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .18s, color .18s, border-color .18s;
}
.cible-methode-btn:hover { background: var(--cream); color: var(--ink); }
.cible-methode-btn.actif {
  background: var(--brown);
  color: var(--cream);
  border-color: var(--brown);
}

.cible-contenu {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.cible-cats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.cible-cat-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--rcard);
  box-shadow: var(--sh-card);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cible-cat-label {
  font-family: var(--font-s);
  font-weight: 500;
  font-size: 1rem;
  color: var(--ink);
  margin: 0;
}

.cible-cat-pct-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cible-pct-input {
  width: 60px;
  text-align: right;
  font-family: var(--font-d);
  font-size: 1rem;
  font-weight: 600;
  color: var(--brown);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--cream);
  padding: 4px 6px;
  outline: none;
}
.cible-pct-input:focus { border-color: var(--gold); background: var(--cream-2); }

.cible-pct-sym { color: var(--muted); font-weight: 500; }

.cible-montant-cible {
  font-family: var(--font-d);
  font-size: 0.88rem;
  color: var(--muted);
  margin-left: auto;
}

/* cat cards (50/30/20, jars, 80/20) */
.cible-cats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.cible-cat {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--rcard);
  box-shadow: var(--sh-card);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cible-cat-r1 {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.cible-cat-nom {
  font-family: var(--font-s);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--ink);
  flex: 1;
}
.cible-pct-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.88rem;
  color: var(--muted);
  flex-shrink: 0;
}
.cible-pct {
  width: 52px;
  text-align: right;
  font-family: var(--font-d);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--brown);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--cream);
  padding: 3px 5px;
  outline: none;
}
.cible-pct:focus { border-color: var(--gold); background: var(--cream-2); }
.cible-cat-mt { font-weight: 500; font-size: 0.9rem; color: var(--ink); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.cible-bar-track { height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; }
.cible-bar { height: 100%; border-radius: 3px; background: var(--brown); transition: width .3s; }
.cible-bar.over { background: var(--stop); }
.cible-cat-r2 { display: flex; gap: 8px; align-items: center; font-size: 0.82rem; }
.cible-reel-lbl { color: var(--muted); }
.cible-reel-mt { font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }
.cible-ecart { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted); }
.cible-ecart.ok { color: var(--ok); }
.cible-ecart.over { color: var(--stop); }
.cible-warn { font-size: 0.82rem; color: var(--stop); margin: 6px 0 0; }

/* base 0 */
.cz-kpi-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.cz-kpi-row .bp-kpi { flex: 0 1 160px; }
.cible-bravo { font-size: 0.88rem; color: var(--ok); font-weight: 500; margin: 0 4px; }

/* --- tabs dynamiques --- */
.bp-tab-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.bp-tab-del {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: var(--ink);
  color: var(--cream);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 2;
  transition: background .16s;
}
.bp-tab-wrap:hover .bp-tab-del { display: flex; }
.bp-tab-del:hover { background: var(--stop); }
.bp-hero .bp-tab-del { background: rgba(255,255,255,.9); color: var(--brown); }
.bp-hero .bp-tab-del:hover { background: var(--cream-2); color: var(--stop); }

.bp-tab-home {
  padding: 7px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bp-tab-add {
  font-size: 16px;
  font-weight: 300;
  line-height: 1;
  padding: 6px 13px;
  border-radius: 100px;
  border: 1px dashed var(--line-2);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .18s, color .18s, border-color .18s;
}
.bp-tab-add:hover { background: var(--cream); color: var(--brown); border-style: solid; border-color: rgba(200,140,60,.4); }
.bp-hero .bp-tab-add { border-color: rgba(255,255,255,.3); color: rgba(255,255,255,.6); }
.bp-hero .bp-tab-add:hover { background: rgba(255,255,255,.2); color: #fff; border-color: rgba(255,255,255,.5); }

.bp-tab-wrap.bp-dragging { opacity: 0.35; }
.bp-tab-wrap.bp-drag-over .bp-tab {
  box-shadow: -3px 0 0 0 var(--gold);
}

/* --- responsive mobile --- */
@media (max-width: 680px) {
  .bp-kpi-row { grid-template-columns: 1fr 1fr; }
  .bp-kpi-row .bp-kpi:last-child { grid-column: 1 / -1; }
  .bp-colonnes { grid-template-columns: 1fr; }
}
