/* BUD G : composants communs, une seule apparence pour toute la plateforme.
   Chargé en dernier (après app.html et shell.css) : à égalité de force, c'est lui qui décide.
   Couleurs, rayons et espaces viennent des jetons de app.html : le thème clair et le design classique suivent.

   Ce qui est standard :
     Bouton ........ .btn (secondaire) · .btn-primary · .btn-ghost · .btn-danger · tailles .btn-sm / .btn-lg · .btn-icon · .btn-block
     Fermer ........ .btn-close (44 px, même croix partout)
     Pastille ...... .chip (filtres, choix) · .seg (choix à deux ou trois états, un seul est actif) · .tabs-card (onglets dans une carte)
     Champ ......... input, select, textarea : 44 px, même bord, même anneau de focus
     Carte ......... .card et ses anciens noms : même rayon, même bord
   Un bouton ne porte plus de style en ligne pour sa taille, sa police ou son fond : il prend la classe qui convient.
   Doigt : sur un écran tactile, rien de cliquable ne fait moins de 44 px. */

:root {
  --ctl-h: 44px;          /* hauteur d'un bouton ou d'un champ */
  --ctl-h-sm: 36px;       /* petit bouton, dans une ligne ou une carte dense (44 px sur écran tactile) */
  --ctl-h-lg: 52px;       /* action principale d'une fenêtre ou d'une page */
  --ctl-r: var(--r-sm);   /* rayon des boutons et des champs */
  --ctl-fs: 15px;
  --ctl-fs-sm: 13px;
  --ctl-px: 18px;
  --ctl-px-sm: 12px;
  --ctl-gap: 8px;
  --card-r: var(--r);
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}
@media (pointer: coarse) { :root { --ctl-h-sm: 44px; } }

/* ═══ Boutons ═══════════════════════════════════════════════════════════════ */
.btn, .auth-btn-primary, .onboarding-btn, .settings-partner-remove-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--ctl-gap);
  min-height: var(--ctl-h); padding: 0 var(--ctl-px); box-sizing: border-box;
  border: 1px solid var(--btn-edge); border-radius: var(--ctl-r);
  background: var(--btn-surface); color: var(--text);
  font-family: inherit; font-size: var(--ctl-fs); font-weight: 600; line-height: 1.2; letter-spacing: 0; text-decoration: none; text-align: center;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s, filter .15s;
}
.btn:hover:not(:disabled), .onboarding-btn:hover:not(:disabled), .settings-partner-remove-btn:hover:not(:disabled) {
  background: var(--btn-surface-hover); border-color: var(--btn-edge); color: var(--text);
}
.btn:disabled, .btn[aria-disabled="true"], .auth-btn-primary:disabled, .onboarding-btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .auth-btn-primary:focus-visible, .onboarding-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:active:not(:disabled) { transform: translateY(1px); }

/* Principal : plein, une seule par écran ou par fenêtre */
.btn-primary, .btn.btn-primary, .auth-btn-primary, .onboarding-btn.primary, .btn-charge-fixe-cta, .btn.is-active {
  background: var(--accent-fill); border-color: var(--accent-fill); color: var(--btn-on-active);
  box-shadow: none; letter-spacing: 0; border-radius: var(--ctl-r);
}
.btn-primary:hover:not(:disabled), .btn.btn-primary:hover:not(:disabled), .auth-btn-primary:hover:not(:disabled), .onboarding-btn.primary:hover:not(:disabled), .btn-charge-fixe-cta:hover:not(:disabled) {
  background: var(--accent-fill); border-color: var(--accent-fill); color: var(--btn-on-active); filter: brightness(1.1); box-shadow: none;
}
html.theme-light .btn-charge-fixe-cta { box-shadow: none; }
.auth-btn-primary { width: 100%; }

/* Discret : sans bord, pour annuler, revenir, une action secondaire de plus */
.btn-ghost, .btn.btn-ghost {
  background: transparent; border-color: transparent; color: var(--text2);
}
.btn-ghost:hover:not(:disabled), .btn.btn-ghost:hover:not(:disabled) { background: var(--accent-tint); border-color: transparent; color: var(--text); }

/* Danger : bord rouge, jamais plein sauf confirmation (.btn-danger.btn-primary) */
.btn-danger, .btn.btn-danger {
  background: transparent; border-color: color-mix(in srgb, var(--red) 60%, transparent); color: var(--red);
}
.btn-danger:hover:not(:disabled), .btn.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--red) 14%, transparent); border-color: var(--red); color: var(--red); }
.btn-danger.btn-primary, .btn.btn-danger.btn-primary { background: var(--red2); border-color: var(--red2); color: #fff; }

/* Tailles */
.btn-sm, .btn.btn-sm { min-height: var(--ctl-h-sm); padding: 0 var(--ctl-px-sm); font-size: var(--ctl-fs-sm); }
.btn-lg, .btn.btn-lg, .se-save { min-height: var(--ctl-h-lg); padding: 0 28px; font-size: 17px; }
.btn-block { width: 100%; }
.btn-icon { width: var(--ctl-h); padding: 0; flex: 0 0 auto; }
.btn-icon.btn-sm { width: var(--ctl-h-sm); }
.btn .icon, .btn svg { flex: 0 0 auto; }

/* Fermer : la même croix, 44 px, partout (fenêtres, panneaux, bandeaux) */
.btn-close, .auth-close, .ob-close, .modal-close-ce, .se-x, .settings-bar-icon--close, .sidebar-close-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; box-sizing: border-box;
  width: var(--ctl-h); height: var(--ctl-h); min-height: var(--ctl-h); padding: 0;
  border: 0; border-radius: var(--ctl-r); background: transparent; color: var(--text2);
  font-size: 22px; line-height: 1; cursor: pointer; transition: background .15s, color .15s;
}
.btn-close:hover, .auth-close:hover, .ob-close:hover, .modal-close-ce:hover, .se-x:hover, .settings-bar-icon--close:hover, .sidebar-close-btn:hover { background: var(--accent-tint); color: var(--text); }
.auth-close { position: absolute; top: 10px; right: 10px; }
.btn-close:focus-visible, .auth-close:focus-visible, .ob-close:focus-visible, .modal-close-ce:focus-visible, .se-x:focus-visible, .settings-bar-icon--close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Titre de fenêtre ou de panneau : un seul niveau, entre le titre de page (28) et le titre de carte (16) */
.modal-header-ce .modal-title, .se-head h2, .bw-title, .ai-title {
  font-size: 20px !important; font-weight: 650 !important; letter-spacing: -.015em; line-height: 1.25; color: var(--text) !important;
}

/* ═══ Pastilles : filtres et choix ═════════════════════════════════════════ */
.chip, .se-chip, .filter-chip, .tx-smart-chip, .ai-quick, .budget-mini-btn, .fiscal-ticker-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; box-sizing: border-box;
  min-height: var(--ctl-h-sm); padding: 0 14px; border: 1px solid var(--border2); border-radius: 999px;
  background: transparent; color: var(--text2); font-family: inherit; font-size: var(--ctl-fs-sm); font-weight: 600; line-height: 1.2; white-space: nowrap; text-decoration: none;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.chip:hover, .se-chip:hover, .filter-chip:hover, .tx-smart-chip:hover, .ai-quick:hover, .budget-mini-btn:hover, .fiscal-ticker-btn:hover {
  background: var(--accent-tint); border-color: var(--accent); color: var(--text);
}
.chip.is-on, .chip.is-active, .se-chip.is-on, .filter-chip.is-active, .filter-chip.is-on, .tx-smart-chip.is-active {
  background: var(--accent-tint); border-color: var(--accent); color: var(--text);
}
.chip:focus-visible, .se-chip:focus-visible, .filter-chip:focus-visible, .tx-smart-chip:focus-visible, .ai-quick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Pré-question fiscale : le texte peut passer sur deux lignes */
.ai-quick-fiscal { white-space: normal; text-align: left; max-width: 100%; padding-top: 6px; padding-bottom: 6px; }
/* Les choix de la fiche (qui paie, comment c'est partagé) restent grands : on y réfléchit, on y touche */
.se-chip:not(.se-chip--s) { min-height: var(--ctl-h); padding: 0 18px; font-size: var(--ctl-fs); }

/* ═══ Choix à états exclusifs : Portée, Cartes / Tableau, Jour / Nuit, Dépenses / Revenus ═══ */
.seg, .se-type, .data-view-tabs, .settings-tab-bar, .ch-toggle {
  display: inline-flex; align-items: stretch; gap: 2px; padding: 3px; box-sizing: border-box;
  border: 1px solid var(--border); border-radius: calc(var(--ctl-r) + 3px); background: var(--bg3);
}
.seg > button, .se-type > button, .data-view-tabs > button, .settings-tab-bar > button, .data-view-tab {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-sizing: border-box;
  min-height: var(--ctl-h-sm); padding: 0 16px; border: 0; border-radius: var(--ctl-r);
  background: transparent; color: var(--text2); font-family: inherit; font-size: var(--ctl-fs-sm); font-weight: 600; line-height: 1.2; white-space: nowrap;
  cursor: pointer; transition: background .15s, color .15s;
}
.seg > button:hover, .se-type > button:hover, .data-view-tabs > button:hover, .settings-tab-bar > button:hover, .data-view-tab:hover { color: var(--text); background: var(--accent-tint); }
.seg > button.is-on, .seg > button.is-active, .seg > button[aria-pressed="true"], .seg > button[aria-current="page"],
.se-type > button.is-on, .se-type > button[aria-pressed="true"],
.data-view-tabs > button.is-active, .settings-tab-bar > button.is-active, .data-view-tab.is-active {
  background: var(--accent-fill); color: var(--btn-on-active); box-shadow: none;
}
.seg > button:focus-visible, .se-type > button:focus-visible, .settings-tab-bar > button:focus-visible, .data-view-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Onglets de carte : pleine largeur, un peu plus grands */
.settings-tab-bar { display: flex; width: 100%; }
.settings-tab-bar > button { flex: 1 1 0; min-height: var(--ctl-h); font-size: var(--ctl-fs); }
.bg-tabs { background: var(--bg3); border: 1px solid var(--border); padding: 3px; gap: 2px; }
.bg-tabs .settings-tab-btn { min-height: var(--ctl-h); font-size: var(--ctl-fs); border-radius: var(--ctl-r); }
.bg-tabs .settings-tab-btn.is-active { background: var(--accent-fill); color: var(--btn-on-active); box-shadow: none; }

/* ═══ Champs ════════════════════════════════════════════════════════════════
   Force zéro (:where) : c'est le réglage par défaut, toute règle propre à un composant (.ch-in, .se-amt input, .bw-input, .combo-input…) l'emporte.
   Pour qu'un champ reste « nu » (édition sur place), lui donner la classe .field-bare. */
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]):not([type="color"]):not([type="button"]):not([type="submit"]):not(.field-bare),
       select:not(.field-bare), textarea:not(.field-bare)) {
  min-height: var(--ctl-h); box-sizing: border-box; padding: 0 14px;
  border: 1px solid var(--border2); border-radius: var(--ctl-r);
  background-color: var(--bg3); color: var(--text);
  font-family: inherit; font-size: var(--ctl-fs); line-height: 1.3;
  transition: border-color .15s, box-shadow .15s;
}
:where(textarea:not(.field-bare)) { padding: 12px 14px; min-height: 88px; line-height: 1.45; }
:where(select:not(.field-bare)) { padding-right: 36px; }
:where(input:not([type="checkbox"]):not([type="radio"]):not(.field-bare), select:not(.field-bare), textarea:not(.field-bare)):focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--text3); opacity: 1; }
input:disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; }
label { font-weight: 600; }

/* ═══ Cartes : même rayon, même bord ═══════════════════════════════════════ */
.card, .table-card, .ux-neo-card, .dh-panel, .ch, .rp-idea, .metric-card {
  border-radius: var(--card-r);
}
.table-card, .ux-neo-card, .ch { border: 1px solid var(--border); }

/* ═══ Texte d'aide et liens-boutons ════════════════════════════════════════ */
.se-link, .btn-link {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--ctl-h); padding: 0 8px; border: 0; background: transparent;
  color: var(--text2); font-family: inherit; font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.se-link:hover, .btn-link:hover { color: var(--text); }

/* ═══ Petits boutons d'icône ═══════════════════════════════════════════════ */
.icon-btn, .chrome-icon-btn, .sidebar-compact-toggle, .vo-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; box-sizing: border-box;
  min-width: var(--ctl-h-sm); min-height: var(--ctl-h-sm); border-radius: var(--ctl-r);
}
@media (pointer: coarse) { .icon-btn, .chrome-icon-btn, .sidebar-compact-toggle, .vo-btn { min-width: 44px; min-height: 44px; } }

/* ═══ Menu déroulant : une entrée par ligne ════════════════════════════════ */
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: var(--ctl-h); padding: 0 14px; box-sizing: border-box;
  border: 0; border-radius: var(--ctl-r); background: transparent; color: var(--text);
  font-family: inherit; font-size: 14px; font-weight: 600; line-height: 1.3; text-align: left; cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--accent-tint); outline: none; }
.chip--tab { min-height: 32px; padding: 0 10px; font-size: 13px; }
@media (pointer: coarse) { .chip--tab { min-height: 44px; } }
