/* BUD G : coque de navigation (quatre rubriques, onglets de rubrique, barre d'onglets mobile), Accueil et Répartition.
   Couleurs et rayons viennent uniquement des jetons de app.html : le design classique reste possible. */

/* ── Menu : un bouton Saisir, quatre rubriques ── */
.sb-add {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: calc(100% - 2 * var(--sidebar-pad-x)); margin: 14px var(--sidebar-pad-x) 12px; min-height: 44px;
  border: 0; border-radius: var(--r-sm); background: var(--accent-fill); color: var(--btn-on-active);
  font-weight: 700; font-size: 15px; cursor: pointer;
}
.sb-add:hover { filter: brightness(1.1); }
html.sidebar-compact .sb-add > span:not(.icon) { display: none; }
html.sidebar-compact .sb-add { width: 44px; margin-left: auto; margin-right: auto; }
.sidebar-nav-main { display: flex; flex-direction: column; gap: 4px; padding: 0 var(--sidebar-pad-x); }
.sidebar-nav-main .nav-item { min-height: 44px; }
.sidebar-nav-main .nav-item.is-section-active { background: var(--accent-tint); color: var(--text); font-weight: 600; }

/* ── Onglets de rubrique (dans la barre du haut, donc collés en haut au défilement) ── */
.sect-tabs {
  display: flex; flex-wrap: nowrap; gap: 4px; align-items: stretch; margin: 8px -4px -12px; padding: 0 4px;
  overflow-x: auto; scrollbar-width: none;
}
.sect-tabs::-webkit-scrollbar { display: none; }
.sect-tabs[hidden] { display: none; }
.sect-tab {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--text2);
  font-size: 15px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.sect-tab:hover { color: var(--text); }
.sect-tab[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.sect-tab .ico, .sect-tab .lock { opacity: .7; font-size: 13px; }
/* Sous-choix d'une page (Finanquilibre / Diagnostic) : un .seg, posé sous le titre (apparence : css/ui.css) */
.sect-sub { margin: 0 0 16px; }
.sect-sub:empty { display: none; }

/* ── En-tête : l'essentiel seulement (recherche, notifications, assistant) ── */
.chrome-profile-btn { display: none; }
.chrome-diagnostic-badge { display: none; }
.chrome-diagnostic-badge.is-warn, .chrome-diagnostic-badge.is-local { display: inline-flex; }

/* ── Barre d'onglets mobile (remplace le tiroir) ── */
.tabbar { display: none; }
@media (max-width: 900px) {
  #sidebar, .sidebar-backdrop, .mobile-menu-btn { display: none !important; }
  .chrome-profile-btn { display: inline-flex; }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 900; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: end; padding: 6px 2px calc(10px + env(safe-area-inset-bottom)); background: var(--bg2); border-top: 1px solid var(--border);
  }
  .tabbar .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; border: 0;
    background: transparent; color: var(--text3); font-size: 12px; font-weight: 600; cursor: pointer; position: relative;
  }
  .tabbar .tab .tab-ico { width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; font-size: 20px; }
  .tabbar .tab[aria-current="page"] { color: var(--accent2); }
  .tabbar .tab-add { color: var(--text); }
  .tabbar .tab-add .tab-plus {
    width: 48px; height: 48px; margin-top: -20px; border-radius: 16px; background: var(--accent-fill); color: var(--btn-on-active);
    display: flex; align-items: center; justify-content: center; font-size: 24px; box-shadow: 0 6px 18px rgba(106, 87, 230, .45);
  }
  
  #main { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  #toast { bottom: calc(84px + env(safe-area-inset-bottom)) !important; right: 12px !important; left: 12px; text-align: center; }
  .sect-tabs { margin-left: -12px; margin-right: -12px; padding: 0 8px; }
  .sect-tab { padding: 0 12px; font-size: 14px; }
}

/* ── Accueil : le reste du mois d'abord ── */
.dh-card { background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--r); padding: 24px 28px; margin-bottom: 18px; box-shadow: var(--shadow); }

.dh-kicker { font-size: 14px; font-weight: 600; color: var(--text2); }
.dh-big { font-size: clamp(40px, 7vw, 56px); line-height: 1.08; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--gold); letter-spacing: -.01em; }
.dh-big.is-neg { color: var(--red); }
.dh-sub { font-size: 14px; color: var(--text2); }
.dh-bar { display: flex; gap: 3px; height: 10px; margin-top: 6px; }
.dh-bar i { display: block; min-width: 0; }
.dh-bar i:first-child { border-radius: 5px 0 0 5px; }
.dh-bar i:last-child { border-radius: 0 5px 5px 0; }

.dh-empty { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
@media (max-width: 720px) {
  .dh-card { padding: 18px 16px; }
  
}
.dh-cols { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; margin-bottom: 18px; }
.dh-cols > .dh-col { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.dh-cols > .dh-col.is-wide { flex: 1.5 1 440px; }
.dh-panel { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r); padding: 8px 22px 14px; }
.dh-panel-head { display: flex; align-items: center; gap: 12px; min-height: 56px; }
.dh-panel-head h2 { flex: 1 1 0; font-size: 17px; font-weight: 700; }
.dh-panel-head .hint { font-size: 13px; color: var(--text3); }

.dh-up { display: flex; align-items: center; gap: 12px; min-height: 56px; border-bottom: 1px solid var(--border); }
.dh-up:last-child { border-bottom: 0; }
.dh-up-day { width: 44px; text-align: center; line-height: 1.1; color: var(--gold); }
.dh-up-day b { display: block; font-size: 19px; }
.dh-up-day span { font-size: 13px; color: var(--text3); }
.dh-section-label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text3); margin: 8px 0 10px; }
.dh-foyer { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r); padding: 14px 22px; margin-bottom: 18px; }
.dh-foyer .f1 { flex: 1 1 280px; min-width: 0; }
.dh-foyer b { font-variant-numeric: tabular-nums; }

/* ── Analyses › Répartition ── */
.rp-hero { background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--r); padding: 24px 28px; margin-bottom: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.rp-total { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; }
.rp-total .vis-fig { font-size: clamp(36px, 6vw, 48px); font-weight: 700; }
.rp-bar { display: flex; gap: 3px; height: 12px; }
.rp-bar i { display: block; min-width: 0; }
.rp-bar i:first-child { border-radius: 6px 0 0 6px; }
.rp-bar i:last-child { border-radius: 0 6px 6px 0; }
.rp-people { display: flex; flex-wrap: wrap; gap: 14px 28px; }
.rp-person { flex: 1 1 240px; min-width: 0; display: flex; align-items: center; gap: 12px; }
.rp-av { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: #0f0f12; flex: 0 0 auto; }
.rp-person .col { display: flex; flex-direction: column; min-width: 0; }
.rp-note { font-size: 13px; color: var(--text3); }

/* Icônes du menu et pied de page au-dessus de la barre d'onglets */
.nav-item .icon svg, .sb-add .icon svg { width: 20px; height: 20px; display: block; }
.tabbar .tab-ico svg, .tabbar .tab-plus svg { width: 24px; height: 24px; }
@media (max-width: 900px) {
  .app-footer { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
}
html.theme-light .nav-pill-badge { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }

/* ── Pictogrammes de catégories : pastille ronde à la couleur de la famille ── */
.cp { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; font-size: 20px; line-height: 1;
  background: color-mix(in srgb, var(--fc, var(--accent)) 16%, transparent); color: var(--fc, var(--accent)); }
.cp--s { width: 32px; height: 32px; font-size: 16px; }
.cp .ico { width: 1.15em; height: 1.15em; }

/* ── Accueil : le reste du mois (deux colonnes), les catégories et leur plafond, six mois ── */
.dh-voice { float: none; margin: 0 0 0 auto; width: 44px; height: 44px; }
.dh-voice .ico { font-size: 20px; }
.dh-card { display: flex; flex-direction: column; gap: 10px; }
.dh-big { font-size: clamp(44px, 8vw, 60px); line-height: 1.05; }
.dh-split { flex-direction: row; flex-wrap: wrap; align-items: stretch; gap: 28px; padding: 28px; }
.dh-main { flex: 1.6 1 420px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.dh-kick-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 28px; }
.dh-flag { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.dh-flag .ico { width: 14px; height: 14px; }
.dh-flag--warn { background: color-mix(in srgb, var(--gold) 18%, transparent); color: var(--gold); }
.dh-flag--bad { background: color-mix(in srgb, var(--red) 16%, transparent); color: var(--red); }
.dh-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; font-size: 13px; color: var(--text2); }
.dh-legend span { display: inline-flex; align-items: center; gap: 8px; }
.dh-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.dh-legend i.is-rest { background: var(--bg4); box-shadow: inset 0 0 0 1px var(--border2); }
.dh-side { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; justify-content: center; border-left: 1px solid var(--border); padding-left: 28px; }
.dh-line { display: flex; align-items: center; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--border); color: var(--text2); }
.dh-line:last-child { border-bottom: 0; }
.dh-line span { flex: 1 1 0; min-width: 0; }
.dh-line b { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 17px; color: var(--text); }
.dh-line b.is-pos { color: var(--green); }
.dh-line b.is-neg { color: var(--red); }
.dh-line b.is-gold { color: var(--gold); }
#dash-hero { container-type: inline-size; }
@container (max-width: 687px) { .dh-side { border-left: 0; border-top: 1px solid var(--border); padding-left: 0; padding-top: 8px; } .dh-split { padding: 22px 20px; gap: 20px; } }

.cat-row { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.cat-row:last-child, .cat-more .cat-row:last-child { border-bottom: 0; }
.cat-top { display: flex; align-items: center; gap: 12px; }
.cat-name { flex: 1 1 0; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.cat-amt { font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cat-amt b { font-weight: 700; }
.cat-amt b.is-over { color: var(--red); }
.cat-of { color: var(--text3); }
.cat-flag { display: inline-flex; align-items: center; min-height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.cat-bar { height: 8px; border-radius: 4px; background: var(--bg4); overflow: hidden; }
.cat-bar i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.cat-bar.is-warn i { background: var(--gold); }
.cat-bar.is-over i { background: var(--red); }
.cat-more > summary { display: flex; align-items: center; min-height: 44px; font-size: 14px; font-weight: 600; color: var(--text2); cursor: pointer; list-style: none; }
.cat-more > summary::-webkit-details-marker { display: none; }
.cat-more > summary::after { content: "▾"; margin-left: 8px; color: var(--text3); }
.cat-more[open] > summary::after { transform: rotate(180deg); }
@media (max-width: 520px) { .cat-top { flex-wrap: wrap; } .cat-amt { flex: 1 1 100%; padding-left: 44px; } }

.dh-col:has(> #dash-six:empty) { display: none; }
.dh-chart { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 0 8px; padding: 6px 0 14px; }
.dh-chart-y, .dh-chart-plot { position: relative; height: 180px; }
.dh-chart-y span { position: absolute; right: 0; transform: translateY(50%); font-size: 12px; color: var(--text3); font-variant-numeric: tabular-nums; }
.dh-chart-plot .g { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--border); }
.dh-chart-plot .g.is-base { border-top-color: var(--border2); }
.dh-chart-cols { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.dh-bc { display: flex; align-items: flex-end; justify-content: center; gap: 4px; height: 100%; }
.dh-bc i { display: block; width: min(20px, 28%); min-height: 2px; border-radius: 3px 3px 0 0; }
.dh-bc .b-rev { background: var(--green); }
.dh-bc .b-dep { background: var(--red); }
.dh-bc.is-cur i { opacity: .6; }
.dh-chart-x { grid-column: 2; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin-top: 8px; }
.dh-chart-x span { text-align: center; font-size: 12px; line-height: 1.35; color: var(--text3); }
.dh-chart-x span.is-cur { color: var(--text); font-weight: 600; }
.dh-chart-x small { display: block; font-size: 12px; font-weight: 400; color: var(--text3); }
.dh-panel-head .dh-legend { flex: 0 0 auto; }
@media (max-width: 520px) { .dh-chart { grid-template-columns: 36px minmax(0, 1fr); } .dh-panel-head { flex-wrap: wrap; } }

/* Période et portée : sans cadre, juste les commandes */
.topbar-context-filters-host .sidebar-panel { border: 0; background: transparent; box-shadow: none; padding: 0; }

.dh-up-lib { flex: 1 1 0; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.dh-up-amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.dh-op { display: flex; align-items: center; gap: 12px; min-height: 60px; border-top: 1px solid var(--border); }
.dh-op:first-child { border-top: 0; }
.dh-op-main { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.dh-op-main b { overflow-wrap: anywhere; }
.dh-op-main span { font-size: 13px; color: var(--text3); }
.dh-op-amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.dh-op-amt.is-pos { color: var(--green); }
.dh-op-amt.is-neg { color: var(--text); }
.dh-whos { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 16px; }
.dh-who { display: inline-flex; align-items: center; gap: 8px; }
.rp-av--s { width: 28px; height: 28px; font-size: 13px; }

.dh-more { margin-bottom: 18px; }
.dh-more > summary { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; border: 1px solid var(--border2); border-radius: var(--r-sm);
  cursor: pointer; font-weight: 600; color: var(--text2); list-style: none; }
.dh-more > summary::-webkit-details-marker { display: none; }
.dh-more > summary::after { content: "▾"; font-size: 14px; }
.dh-more[open] > summary::after { content: "▴"; }
.dh-more-body { padding-top: 18px; }
#dash-alert-list .alert-desc { display: none; }
#dash-alert-list .alert-item { padding: 12px 16px; align-items: center; }
#dash-alert-list .alert-title { margin-bottom: 0; font-size: 15px; }

/* ── Répartition : une phrase, deux personnes, un chiffre chacune ── */
.rp-title { font-size: 22px; font-weight: 700; }
.rp-amt { font-size: 28px; font-weight: 700; line-height: 1.15; }
.rp-amt .vis-fig, .rp-total .vis-fig { font-size: inherit; }
.rp-total { font-size: 16px; }

/* Accueil : le choix de la période ne sert qu'aux chiffres détaillés, il apparaît avec eux (navigateurs sans :has : toujours visible) */
#view-dashboard:not(:has(#dash-more[open])) #app-toolbar-period-block { display: none; }

/* ── Saisie simple ── */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#modal-box.modal--simple { width: min(520px, 100vw); max-width: 100vw; max-height: 100vh; overflow-y: auto; border-radius: var(--r-lg); padding: 0; }
.se { display: flex; flex-direction: column; gap: 14px; padding: 20px 20px 22px; }
.se-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.se-head h2 { font-size: 22px; font-weight: 700; }
.se-x { width: 44px; height: 44px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text2); font-size: 18px; cursor: pointer; }
.se-type { display: inline-flex; align-self: flex-start; padding: 3px; gap: 2px; border-radius: var(--r-sm); background: var(--bg3); border: 1px solid var(--border); }
.se-type button { min-height: 44px; padding: 0 20px; border: 0; border-radius: 9px; background: transparent; color: var(--text2); font-size: 16px; font-weight: 600; cursor: pointer; }
.se-type button.is-on { background: var(--bg2); color: var(--text); box-shadow: 0 0 0 1px var(--border2); }
.se-amt { display: flex; align-items: baseline; gap: 8px; padding: 6px 4px; border-bottom: 2px solid var(--border2); }
.se-amt:focus-within { border-bottom-color: var(--accent); }
.se-amt input { flex: 1 1 0; min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 48px; font-weight: 700; font-variant-numeric: tabular-nums; padding: 0; }
.se-amt b { font-size: 32px; color: var(--text2); }
.se-q { font-size: 16px; font-weight: 700; margin-top: 4px; }
.se-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.se-tiles--more { margin-top: 10px; }
.se-tiles[hidden] { display: none; }
.se-tile { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px; min-height: 88px; padding: 10px 4px 8px; border: 2px solid transparent; border-radius: var(--r-sm); background: var(--bg3); color: var(--text); font-size: 13px; font-weight: 600; line-height: 1.15; text-align: center; cursor: pointer; }
.se-tile .cp { width: 44px; height: 44px; font-size: 22px; }
.se-tile.is-on { border-color: var(--accent); background: var(--accent-tint); }
.se-tile:hover { background: var(--bg4); }
.se-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.se-chip { min-height: 44px; padding: 0 18px; border: 1px solid var(--border2); border-radius: 999px; background: transparent; color: var(--text2); font-size: 16px; font-weight: 600; cursor: pointer; }
.se-chip.is-on { background: var(--accent-tint); border-color: var(--accent); color: var(--text); }
.se-field { width: 100%; }
.se-field[hidden] { display: none; }
.se-foot { display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin-top: 4px; }
.se-save { min-height: 56px; font-size: 18px; font-weight: 700; }
.se-link { min-height: 44px; border: 0; background: transparent; color: var(--text3); font-size: 14px; text-decoration: underline; cursor: pointer; }
.se-err { padding: 10px 14px; border-radius: var(--r-sm); background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); font-weight: 600; }
@media (max-width: 520px) {
  #modal-overlay.open { align-items: flex-end; }
  #modal-box.modal--simple { border-radius: var(--r-lg) var(--r-lg) 0 0; width: 100vw; max-height: 92vh; }
  .se-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
}
.se-save { background: var(--accent-fill); color: var(--btn-on-active); border: 0; border-radius: var(--r-sm); cursor: pointer; }
.se-save:hover { filter: brightness(1.1); }

.rp-idea { display: flex; flex-direction: column; gap: 12px; background: var(--bg2); border: 1px solid var(--accent); border-radius: var(--r); padding: 22px 24px; margin-bottom: 18px; }
.rp-idea-row { display: flex; align-items: center; gap: 12px; min-height: 56px; }
.rp-idea-row .col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
.rp-idea-amt { font-size: 20px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-after { font-size: 15px; color: var(--text2); }
.rp-do { align-self: flex-start; min-height: 52px; padding: 0 28px; font-size: 17px; font-weight: 700; background: var(--accent-fill); color: var(--btn-on-active); border: 0; border-radius: var(--r-sm); cursor: pointer; }
.rp-fair { display: flex; align-items: center; gap: 10px; color: var(--green); font-weight: 600; margin: 0 0 18px; }

/* ── Opérations : liste simple ── */
.os { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }
.os-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.os-nav h2 { font-size: 22px; font-weight: 700; }
.os-arrow { width: 48px; height: 48px; border: 1px solid var(--border2); border-radius: var(--r-sm); background: transparent; color: var(--text); font-size: 24px; cursor: pointer; }
.os-arrow:disabled { opacity: .35; cursor: default; }
.os-sum { display: flex; flex-wrap: wrap; gap: 6px 24px; font-size: 16px; color: var(--text2); }
.os-sum b { font-variant-numeric: tabular-nums; }
.os-day { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text3); margin: 16px 0 4px; }
.os-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 6px 0; border: 0; border-top: 1px solid var(--border); background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.os-row:hover { background: var(--bg3); }
.os-main { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.os-main b { overflow-wrap: anywhere; font-size: 16px; }
.os-main span { font-size: 13px; color: var(--text3); }
.os-amt { font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.os-amt.is-pos { color: var(--green); }
.os-search { max-width: 420px; }
#view-transactions.ops-simple-on #app-toolbar-period-block { display: none; }
@media (max-width: 720px) { #chrome-diagnostic-badge:not(.is-warn) { display: none !important; } }

/* ── Charges et revenus : cartes ou tableau, chiffres corrigeables ── */
.ch { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r); padding: 18px 22px 12px; margin-bottom: 18px; }
.ch-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.ch-head h2 { font-size: 19px; font-weight: 700; }
.ch-help { font-size: 14px; color: var(--text3); margin: 6px 0 4px; max-width: none; }
.ch-sec { margin-top: 14px; }
.ch-sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 6px; border-bottom: 2px solid var(--border2); }
.ch-sec-head h3 { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text3); }
.ch-sec-head b { font-variant-numeric: tabular-nums; }
.ch-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; min-height: 68px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.ch-row .cp { align-self: flex-start; margin-top: 4px; }
.ch-main { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.ch-name { border: 0; background: transparent; color: var(--text); font: inherit; font-weight: 700; font-size: 16px; padding: 0; text-align: left; cursor: text; overflow-wrap: anywhere; }
.ch-name--plain { cursor: default; }
.ch-sub { border: 0; background: transparent; color: var(--text3); font: inherit; font-size: 13px; padding: 2px 0; min-height: 28px; text-align: left; cursor: pointer; }
.ch-sub--plain { cursor: default; }
.ch-trace { border: 0; background: transparent; color: var(--text3); font: inherit; font-size: 12px; padding: 0; text-align: left; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.ch-amt { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border: 1px dashed var(--border2); border-radius: var(--r-sm); background: transparent; color: var(--text); font: inherit; font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap; cursor: pointer; }
.ch-amt:hover { background: var(--bg3); border-color: var(--accent); }
.ch-pen { font-size: 13px; color: var(--text3); font-weight: 400; }
.ch-in { min-height: 44px; padding: 0 12px; border: 2px solid var(--accent); border-radius: var(--r-sm); background: var(--bg3); color: var(--text); font: inherit; font-size: 16px; font-weight: 700; min-width: 0; width: min(260px, 60%); }
.ch-in--num { width: 140px; text-align: right; font-size: 18px; font-variant-numeric: tabular-nums; }
.ch-more { flex: 1 1 100%; display: flex; flex-direction: column; gap: 8px; padding: 6px 0 10px 52px; }
.ch-toggle { margin: 0; }
.ch-scroll { overflow-x: auto; margin-top: 10px; border: 1px solid var(--border2); border-radius: var(--r-sm); }
.ch-table { width: 100%; min-width: 880px; border-collapse: collapse; font-size: 14px; }
.ch-table th { position: sticky; top: 0; background: var(--bg3); text-align: left; padding: 10px 10px; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--text3); border-bottom: 2px solid var(--border2); }
.ch-table td { padding: 4px 8px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); vertical-align: middle; }
.ch-table td:last-child, .ch-table th:last-child { border-right: 0; }
.ch-table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--bg3) 45%, transparent); }
.ch-num { text-align: right; font-variant-numeric: tabular-nums; }
.ch-cell { width: 100%; min-height: 36px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--text); font: inherit; }
.ch-cell:hover { border-color: var(--border2); }
.ch-cell:focus { border-color: var(--accent); background: var(--bg3); outline: 0; }
select.ch-cell { cursor: pointer; }
.ch-numin { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.ch-cat { white-space: nowrap; }
.ch-cat .cp { margin-right: 8px; vertical-align: middle; }
.ch-last { font-size: 12px; white-space: nowrap; }
.ch-none { color: var(--text3); }
.ch-total td { font-weight: 700; background: var(--bg3); border-top: 2px solid var(--border2); }
.ch-sep td { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text3); background: var(--bg3); padding: 10px; }
.ch-hist { display: flex; flex-direction: column; }
.ch-h { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; padding: 10px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.ch-h-when { color: var(--text3); font-size: 13px; }
.ch-h-who { font-weight: 700; text-align: right; }
.ch-h-what { grid-column: 1 / -1; color: var(--text2); }
@media (max-width: 520px) { .ch { padding: 16px 14px 10px; } .ch-more { padding-left: 0; } }
.ch-table td:nth-child(1) { min-width: 200px; }
.ch-table td:nth-child(4), .ch-table td:nth-child(5) { min-width: 180px; }
.ch-table td:nth-child(6) { min-width: 120px; }

/* ── Réglages › Budget : ce qui rentre, ce qu'on paie, le bilan (js/budget.js) ── */
.bg-tabs { display: flex; gap: 4px; margin: 0 0 18px; padding: 4px; border-radius: var(--r); background: var(--bg3); border: 1px solid var(--border); }
.bg-tabs .settings-tab-btn { flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 8px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text2); font: inherit; font-size: 16px; font-weight: 600; cursor: pointer; }
.bg-tabs .settings-tab-btn.is-active { background: var(--bg2); color: var(--text); box-shadow: 0 0 0 1px var(--border2); }
.bg-tabs .settings-tab-btn:focus-visible, .bg-add:focus-visible, .ch-open:focus-visible, .ch-add:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bg-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.bg-top--act { justify-content: flex-start; margin: 14px 0 4px; }
.bg-total { display: flex; flex-direction: column; line-height: 1.15; }
.bg-total span { font-size: 15px; color: var(--text3); }
.bg-total b { font-size: 30px; font-variant-numeric: tabular-nums; }
.bg-people { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 16px; margin-top: 8px; }
.bg-person { border: 1px solid var(--border); border-top: 3px solid var(--mc); border-radius: var(--r); padding: 14px 16px 16px; }
.bg-person-head { display: flex; align-items: center; gap: 10px; padding-bottom: 8px; border-bottom: 2px solid var(--border2); }
.bg-person-head .rp-av { background: var(--mc); }
.bg-person-head h3 { flex: 1 1 0; min-width: 0; font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }
.bg-person-head b { font-size: 20px; font-variant-numeric: tabular-nums; }
.bg-add { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; margin-top: 10px; padding: 0 14px; border: 1px dashed var(--border2); border-radius: var(--r-sm); background: transparent; color: var(--text2); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; }
.bg-add:hover { border-color: var(--accent); color: var(--text); }
.bg-add-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.bg-add-row .bg-add { width: auto; margin-top: 0; }

.bg-sum { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 14px; padding: 16px 18px; border-radius: var(--r); background: var(--bg3); }
.bg-sum-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.bg-sum-main > span:first-child { flex: 1 0 100%; font-size: 15px; color: var(--text3); }
.bg-sum-main b { font-size: 30px; font-variant-numeric: tabular-nums; }
.bg-sum-pct { font-size: 16px; color: var(--text2); }
.bg-warn { color: var(--gold); font-weight: 700; cursor: help; }
.bg-bar { height: 10px; border-radius: 99px; background: var(--bg4); overflow: hidden; }
.bg-bar i { display: block; height: 100%; border-radius: 99px; background: var(--accent-fill); }
.bg-bar--l i { background: var(--gold); }
.bg-sum-chips { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 15px; color: var(--text2); }
.bg-sc i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 50%; }
.bg-sc b { color: var(--text); font-variant-numeric: tabular-nums; }
.bg-main-add { min-height: 52px; padding: 0 24px; font-size: 17px; font-weight: 700; }
.bg-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0 4px; }
.bg-sorts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.bg-sorts-l { font-size: 14px; color: var(--text3); margin-right: 2px; }
.se-chip--s { min-height: 40px; padding: 0 14px; font-size: 14px; }
.ch-sec-r { display: inline-flex; align-items: center; gap: 12px; }
.ch-sec-head h3 { display: flex; align-items: center; gap: 8px; }
.ch-add { width: 40px; height: 40px; border: 1px dashed var(--border2); border-radius: 50%; background: transparent; color: var(--text2); font-size: 22px; line-height: 1; cursor: pointer; }
.ch-add:hover { border-color: var(--accent); color: var(--text); }
.ch-open { flex: 1 1 0; min-width: 0; appearance: none; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; padding: 6px 8px; margin: -6px 0 -6px -8px; border-radius: var(--r-sm); }
.ch-open:hover { background: var(--bg3); }
.ch-trace--plain { text-decoration: none; cursor: inherit; }
.ch-st { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--sc); }
.ch-st i, .ch-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--sc, var(--text3)); }
.se-chip .ch-dot { margin-right: 8px; }
.ch-amt--plain { cursor: default; border-style: solid; border-color: transparent; }
.ch-amt--plain:hover { background: transparent; border-color: transparent; }
.ch-per { font-size: 13px; font-weight: 400; color: var(--text3); }
.ch-more-btn { width: 40px; height: 40px; border: 1px solid var(--border2); border-radius: var(--r-sm); background: transparent; color: var(--text); font-size: 20px; line-height: 1; cursor: pointer; }
.ch-more-btn:hover { border-color: var(--accent); }
.ch-act { width: 52px; }
.ch-cell--cat { width: calc(100% - 40px); }
.bg-links { display: flex; flex-wrap: wrap; gap: 4px 22px; margin-top: 12px; }
.bg-empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 28px 12px; text-align: center; font-size: 16px; color: var(--text2); }
.bg-det { margin-top: 16px; border: 1px solid var(--border2); border-radius: var(--r-sm); }
.bg-det > summary { display: flex; align-items: center; min-height: 48px; padding: 0 14px; font-weight: 600; color: var(--text2); cursor: pointer; }
.bg-det[open] > summary { border-bottom: 1px solid var(--border); }
.bg-det > :not(summary) { padding: 12px 14px; }
.bg-more-row { display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: var(--text2); }
.bg-auto { margin: 14px 0 6px; font-size: 14px; line-height: 1.5; color: var(--text3); }
.bg-journal { margin-bottom: 18px; }
#bg-journal-count { margin-left: 6px; color: var(--text3); }

.bg-res { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 16px; padding: 18px 20px; border-radius: var(--r); background: var(--bg3); }
.bg-res-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; font-size: 17px; }
.bg-res-row > span { display: inline-flex; align-items: center; gap: 10px; }
.bg-res-row b { font-size: 20px; font-variant-numeric: tabular-nums; }
.bg-res-big { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; margin-top: 4px; padding-top: 14px; border-top: 2px solid var(--border2); }
.bg-res-big span { font-size: 16px; color: var(--text2); }
.bg-res-big b { font-size: 36px; font-variant-numeric: tabular-nums; color: var(--green); }
.bg-res-big b.is-neg, .bg-left.is-neg { color: var(--red); }
.bg-res-big small { font-size: 14px; color: var(--text3); }
.bg-res-each h3 { padding-bottom: 6px; border-bottom: 2px solid var(--border2); font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text3); }
.bg-left { font-size: 20px; font-variant-numeric: tabular-nums; }

/* La fiche d'une charge, d'une prime ou d'une rente */
.bg-per { font-size: 16px; color: var(--text3); white-space: nowrap; }
.bg-amt--auto b { font-size: 40px; }
.bg-say { margin: 0; font-size: 15px; line-height: 1.45; color: var(--text2); }
.bg-say--s { margin-top: -6px; font-size: 14px; color: var(--text3); }
.bg-say--b { font-weight: 600; color: var(--text); }
.bg-alert { margin: 0; font-size: 14px; font-weight: 600; color: var(--red); }
.bg-parts { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 15px; }
.bg-part i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 50%; }
.bg-box { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1px solid color-mix(in srgb, var(--gold) 55%, transparent); border-radius: var(--r-sm); background: color-mix(in srgb, var(--gold) 8%, transparent); }
.bg-inl { display: flex; align-items: center; gap: 10px; color: var(--text2); }
.bg-small { width: 140px; }
.bg-sheet textarea.se-field { min-height: 72px; padding: 12px 14px; font-family: inherit; resize: vertical; }
.se-chip.is-off { opacity: .45; }
.bg-sugg { margin-top: -4px; }
.bg-foot-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 20px; }
.bg-danger-l { color: var(--red); }
.se-chip.bg-danger { border-color: var(--red); color: var(--red); }
.bg-del p { margin: 0 0 8px; font-weight: 600; }
.bg-legacy { zoom: 1.25; }
@media (max-width: 520px) {
  .bg-tabs .settings-tab-btn { gap: 6px; font-size: 15px; }
  .bg-total b, .bg-sum-main b { font-size: 26px; }
  .bg-res-big b { font-size: 32px; }
  .bg-person { padding: 12px 12px 14px; }
}
.ch-table--m { min-width: 1120px; }
.ch-table select.ch-cell { min-width: 118px; }
.ch-table--m .ch-cell--cat { width: calc(100% - 44px); min-width: 120px; }
.bg-sheet label { text-transform: none; letter-spacing: 0; }
.bg-sheet label.se-q { font-size: 16px; font-weight: 700; color: var(--text); }
.bg-sheet .se-amt input, .bg-sheet .se-amt input:focus { border: 0; outline: 0; box-shadow: none; background: transparent; }
.bg-sheet .bg-per { text-transform: none; letter-spacing: 0; }
.bg-catcur { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 6px 14px 6px 8px; border: 1px solid var(--border2); border-radius: var(--r-sm); background: var(--bg3); color: var(--text); font: inherit; font-size: 16px; font-weight: 600; text-align: left; cursor: pointer; }
.bg-catcur > span:not(.cp) { flex: 1 1 0; }
.bg-catcur em { font-style: normal; font-size: 14px; font-weight: 400; color: var(--text3); text-decoration: underline; }
.bg-catcur:hover { background: var(--bg4); }
/* Le montant de la saisie simple et des fiches reste grand : la règle des champs de 16 px sur téléphone (app.html) l'écrasait */
#modal-box .se-amt input { font-size: 48px !important; }
@media (max-width: 520px) { #modal-box .se-amt input { font-size: 40px !important; } }


/* ======================================================================
   Design bancaire (Nuit / Jour) : une seule police (Inter), un seul accent,
   des composants identiques partout. Les couleurs viennent des jetons de app.html.
   Réservé à l'écran : les règles d'impression d'app.html ne sont pas touchées.
   ====================================================================== */
@media screen {
  html { color-scheme: dark; }
  html.theme-light { color-scheme: light; }
  body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-feature-settings: 'cv11', 'ss03'; }
  #main, #modal-overlay, #ai-panel, #sidebar, .tabbar { font-variant-numeric: tabular-nums; }
  :root { --ui-page-max: 1240px; }

  /* Pages : une seule largeur, des marges régulières */
  .view { max-width: var(--ui-page-max); padding: 28px 32px; margin: 0 auto; }
  @media (max-width: 720px) { .view { padding: 20px 16px; } }

  /* Titres : trois niveaux, jamais d'autre corps ni d'autre graisse */
  .page-title { font-size: 28px; font-weight: 650; letter-spacing: -.025em; line-height: 1.15; color: var(--text); }
  .page-sub { font-size: 14px; color: var(--text3); }
  .table-title, .card-title, .chart-title, .fd-surface-title, .ux-neo-title, .bilan-section-title, .settings-hub-h2, .modal-title {
    font-size: 16px !important; font-weight: 600 !important; letter-spacing: -.01em; text-transform: none !important; color: var(--text) !important;
  }
  .form-group label, .fd-form-label, .tx-filter-label, .context-label, .metric-label, .fd-kpi-label, .fin-mailbox-kpi-label, .bc-kpi-l {
    font-size: 13px !important; font-weight: 500 !important; letter-spacing: 0 !important; text-transform: none !important; color: var(--text2);
  }

  /* Blocs : même fond, même filet, même arrondi, pas de liseré de couleur ni d'ombre */
  .table-card, .ux-neo-card, .fd-surface-card, .chart-card, .metric-card, .bilan-card, .budget-kpi, .fd-kpi, .fin-mailbox-kpi, .bc-kpi, .data-purge-tier {
    background: var(--bg2); background-image: none !important; border: 1px solid var(--border) !important; border-radius: var(--r) !important; box-shadow: none !important;
  }
  .metric-card::before { display: none; }
  .metric-card, .fd-kpi, .fin-mailbox-kpi, .budget-kpi { padding: 18px; }
  .table-header, .card-head, .fd-surface-head, .ux-neo-head { padding: 16px 20px; border-bottom: 1px solid var(--border); }
  .table-card + .table-card, .table-card { margin-bottom: 16px; }

  /* Champs : même hauteur, même fond, même arrondi, toute la largeur de leur colonne */
  #main select, #main textarea, #main input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]):not([type=hidden]):not(.ch-cell):not(.ch-in):not(.lib-edit):not(.lib-card-move):not(.app-chrome-search *):not(.se-amt *):not(.sect-tabs *),
  .filter-select, .combo-input, .fd-input {
    min-height: 44px; padding: 0 14px; background: var(--bg3); color: var(--text); border: 1px solid var(--border2); border-radius: var(--r-sm); font-size: 15px; font-weight: 450; line-height: 1.3;
    transition: border-color .15s, box-shadow .15s;
  }
  #main textarea { padding: 12px 14px; min-height: 96px; }
  #main select, .filter-select { padding-right: 34px; }
  .form-group { margin-bottom: 18px; min-width: 0; }
  .form-group input:not([type=checkbox]):not([type=radio]), .form-group select, .form-group textarea { width: 100%; }
  .form-row { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
  #main :is(select, textarea, input):not([type=checkbox]):not([type=radio]):focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
  input::placeholder, textarea::placeholder { color: var(--text3); opacity: 1; }

  /* Boutons : une hauteur, un arrondi ; le principal est plein, les autres discrets */
  .btn { min-height: 40px; padding: 0 16px; justify-content: center; font-size: 14px; font-weight: 550; border-radius: var(--r-sm); background: var(--bg3); border: 1px solid var(--border2); color: var(--text); }
  .btn:hover:not(:disabled) { background: var(--bg4); border-color: var(--border2); }
  .btn-primary { background: var(--accent-fill); border-color: transparent; color: var(--btn-on-active); font-weight: 600; }
  .btn-primary:hover:not(:disabled) { background: var(--accent-fill); border-color: transparent; filter: brightness(1.12); }
  .btn-danger { background: transparent; border-color: color-mix(in srgb, var(--red) 55%, transparent); color: var(--red); }
  .btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--red) 12%, transparent); border-color: var(--red); }
  .icon-btn { width: 36px; height: 36px; border-radius: var(--r-sm); }

  /* Tableaux et listes */
  .table-card table th, .table-card thead th { font-size: 12.5px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--text3); }
  .table-card tbody td { font-size: 14.5px; }

  /* Fenêtres */
  .modal { border-radius: var(--r-lg); border: 1px solid var(--border2); box-shadow: var(--shadow-window); }
}

@media screen {
  /* Détails : panneau hors écran sans ombre, recherche sans double cadre */
  #bilan-sheet:not(.is-open) { box-shadow: none !important; }
  .app-chrome-search { border: 0; background: transparent; padding: 0; box-shadow: none; }
  .app-chrome-search .search-box { background: var(--bg3); border: 1px solid var(--border2); min-height: 44px; padding: 0 14px; }
  .app-chrome-search .search-box input { font-size: 15px; }

  /* Libellés : jamais de majuscules espacées, partout pareil */
  #main label:not(.ob2-fld), #main th, #main [style*="text-transform:uppercase"], #main [style*="text-transform: uppercase"], .settings-hub-row-label, .dh-section-label, .os-day, .ch-sec-head h3, .bg-res-each h3 {
    text-transform: none !important; letter-spacing: 0 !important;
  }
  #main label:not(.ob2-fld) { font-size: 13px; font-weight: 500; color: var(--text2); }
  .ch-sec-head h3, .dh-section-label, .os-day { font-size: 13px; font-weight: 600; color: var(--text3); }

  /* Blocs de l'accueil, de la répartition et des charges : même marge intérieure et même écart */
  .dh-card, .rp-hero, .rp-idea, .dh-foyer, .ch { padding: 20px 24px; margin-bottom: 16px; box-shadow: none; border: 1px solid var(--border); }
  .dh-panel { padding: 6px 24px 14px; margin-bottom: 16px; }
  .table-header, .card-head, .fd-surface-head, .ux-neo-head { padding: 16px 24px; }
  .dh-panel-head { min-height: 52px; }

  /* Interrupteurs segmentés (Jour/Nuit, période, portée) : l'actif est plein, pareil partout */
  .ui-design-switch button.is-on, .se-type button.is-on, .hm-seg-ctl button.is-on, .ob2-sg button.is-on { background: var(--accent-fill); color: var(--btn-on-active); box-shadow: none; }
}

@media screen {
  .search-box input, .search-box--chrome input { border: 0 !important; background: none !important; box-shadow: none !important; padding: 0 !important; min-height: 40px; }
}

/* Accueil : « À surveiller » est le dernier bloc de son conteneur (la règle .ui-page .table-card:last-child lui retire sa marge) */
#dash-watch { padding-bottom: 18px; }
