/* BuddyGet : feuille de style unique, mobile d'abord.
   Chaque couleur est définie une seule fois pour les deux thèmes avec
   light-dark() ; color-scheme choisit la valeur : selon l'appareil par défaut,
   forcée par l'attribut data-theme posé côté serveur (aucun flash). */

:root {
  color-scheme: light dark;
  --bg: light-dark(#f5f6f8, #101217);
  --surface: light-dark(#ffffff, #1a1d24);
  --hover: light-dark(#eceef2, #262a33);
  --text: light-dark(#1b1e24, #e8eaef);
  --muted: light-dark(#555c69, #a6adba);
  --border: light-dark(#dde1e7, #2e333d);
  --input-bg: light-dark(#ffffff, #12151a);
  --input-border: light-dark(#7d8594, #737b8a);
  --primary: light-dark(#1d5bbf, #8ab4ff);
  --primary-hover: light-dark(#174a9c, #a8c7ff);
  --on-primary: light-dark(#ffffff, #0b1a33);
  --link: light-dark(#1d5bbf, #8ab4ff);
  --focus: light-dark(#1d5bbf, #8ab4ff);
  --danger-bg: light-dark(#fdeceb, #3b1816);
  --danger-border: light-dark(#f2b8b3, #7a2a24);
  --danger-text: light-dark(#8c1d13, #ffb4ab);
  --danger: light-dark(#b3261e, #ffb4ab);
  --on-danger: light-dark(#ffffff, #3b0d09);
  --ok-bg: light-dark(#e8f5ec, #12301d);
  --ok-border: light-dark(#a6dcb5, #2c6b41);
  --ok-text: light-dark(#14532d, #a7f0ba);
  --positive: light-dark(#17703f, #6fdc8c);
  --warning-bg: light-dark(#fff4d6, #3a2c05);
  --warning-text: light-dark(#7a4f00, #ffd27a);
  --warning: light-dark(#b07400, #e6b545);

  --tap: 44px;
  --topbar-h: 56px;
  --tabbar-h: 60px;
  --radius: 12px;
  --content-max: 72rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.5 var(--font);
  overflow-wrap: anywhere;
}

h1 { margin: 0 0 1rem; font-size: 1.5rem; line-height: 1.25; }
h2 { margin: 0 0 .5rem; font-size: 1.125rem; line-height: 1.3; }
p { margin: 0 0 .75rem; }
p:last-child { margin-bottom: 0; }
a { color: var(--link); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: .5rem;
  z-index: 20;
  padding: .75rem 1rem;
  background: var(--primary);
  color: var(--on-primary);
  border-radius: 8px;
}
.skip-link:focus { top: .5rem; }

.muted { color: var(--muted); }

/* En-tête */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  min-height: var(--topbar-h);
  padding: env(safe-area-inset-top) .75rem 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-height: var(--tap);
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 700;
  text-decoration: none;
}

.brand-logo { flex: none; width: 32px; height: 32px; }
/* Sur un petit écran connecté, le nom laisse la place aux actions de
   l'en-tête ; il reste lu par les lecteurs d'écran. */
@media (max-width: 399px) {
  .topbar:has(.topbar-actions) .brand span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}
.brand-logo rect { fill: var(--primary); }
.brand-logo path {
  fill: none;
  stroke: var(--on-primary);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar-actions { display: flex; align-items: center; gap: .25rem; }

.theme-switch fieldset {
  display: flex;
  margin: 0;
  padding: 1px;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--hover); }
.icon-btn[aria-pressed="true"] { color: var(--on-primary); background: var(--primary); }

.icon-btn svg, .tabbar svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn svg .fill { fill: currentColor; stroke: none; }

/* Cloche des alertes : le nombre à lire en pastille. */
.bell { position: relative; }
.bell[aria-current="page"] { color: var(--primary); }
.bell-count {
  position: absolute;
  top: 4px;
  right: 2px;
  min-width: 1.125rem;
  padding: 0 .25rem;
  color: var(--on-danger);
  font-size: .6875rem;
  font-weight: 700;
  line-height: 1.125rem;
  text-align: center;
  background: var(--danger);
  border-radius: 999px;
}

/* Navigation : barre d'onglets en bas sur mobile, sous l'en-tête au-delà. */

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.tabbar a {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--tabbar-h);
  color: var(--muted);
  font-size: .75rem;
  white-space: nowrap;
  text-decoration: none;
}
.tabbar a:hover { color: var(--text); }
.tabbar .nav-secondary { display: none; }
.nav-more svg { stroke-width: 3.5; }
.tabbar a[aria-current="page"], .tabbar a.is-current-narrow { color: var(--primary); font-weight: 600; }

/* Contenu : l'espace bas laisse la place à la barre d'onglets et au bouton
   flottant sur mobile. */

.page {
  display: grid;
  align-content: start;
  gap: 1rem;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 1rem 1rem calc(var(--tabbar-h) + 56px + 2rem + env(safe-area-inset-bottom));
}
.page > h1, .page-head h1, .section-head h2 { margin: 0; }
/* Un élément de grille ne doit pas s'élargir à la taille d'un contenu
   défilant (tableau d'aperçu) : il le contient. */
.page > * { min-width: 0; }

.page-centered {
  justify-items: center;
  padding-block: 2rem;
}

.page-head, .section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.section-head { margin-bottom: .75rem; }

.total { margin: 0; color: var(--muted); }
.total strong { color: var(--text); }

.card {
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.card.empty { display: grid; justify-items: start; gap: .75rem; margin: 0; }

.auth-card { width: 100%; max-width: 26rem; }
.form-card, .danger-zone { width: 100%; max-width: 40rem; }
.danger-zone h2 { font-size: 1rem; }

/* Tuiles des soldes */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: .75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tile {
  display: grid;
  gap: .25rem;
  padding: 1rem 1.25rem;
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.tile:hover { border-color: var(--input-border); }
.tile-label { font-weight: 600; }
.tile-meta { color: var(--muted); font-size: .875rem; }
.tile-value { font-size: 1.375rem; }

/* Listes (comptes, catégories) */

.rows {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-height: 3.5rem;
  padding: .25rem 1rem;
}
.row + .row { border-top: 1px solid var(--border); }
.row-child { padding-left: 2.5rem; }

.row-link, .row-body {
  display: grid;
  flex: 1;
  align-content: center;
  gap: .125rem;
  min-width: 0;
  min-height: var(--tap);
  color: var(--text);
  text-decoration: none;
}
.row-link:hover .row-title { text-decoration: underline; }
.row-title { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
.row-child .row-title { font-weight: 400; }
.row-meta { color: var(--muted); font-size: .875rem; }

.dot { flex: none; width: .75rem; height: .75rem; }

/* Montants : le signe est toujours écrit, la couleur ne fait que souligner. */

.amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount.positive { color: var(--positive); }
.amount.negative { color: var(--danger-text); }

/* Formulaires : champs de 16 px minimum (pas de zoom automatique sur iOS)
   et cibles tactiles de 44 px. */

.form { display: grid; gap: 1rem; margin-top: 1rem; }
.field { display: grid; align-content: start; gap: .375rem; }
.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  gap: 1rem;
}

label, legend { font-weight: 600; }
.optional { color: var(--muted); font-weight: 400; }

fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { margin-bottom: .375rem; padding: 0; }

input, select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: .5rem .75rem;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
}
textarea { min-height: 5rem; resize: vertical; }
input[type="color"] { width: 5rem; padding: .25rem; }
input[type="checkbox"], input[type="radio"] {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  min-height: 0;
  margin: 0;
  accent-color: var(--primary);
}

.hint { margin: 0; color: var(--muted); font-size: .875rem; }

.check {
  display: flex;
  align-items: center;
  gap: .625rem;
  min-height: var(--tap);
  font-weight: 400;
  cursor: pointer;
}

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }

/* Sélecteur segmenté (type d'opération, de catégorie) */

.segmented {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: var(--hover);
  border-radius: 10px;
}
.segmented label { position: relative; flex: 1; }
.segmented input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: .25rem;
  color: var(--muted);
  line-height: 1.2;
  text-align: center;
  border-radius: 8px;
}
.segmented input:checked + span {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1px 3px rgb(0 0 0 / .2);
}
.segmented input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Champs conditionnels, sans script : virement ou opération simple,
   catégorie principale ou sous-catégorie. */

.operation-form:has(input[name="type"][value="virement"]:is(:checked, [type="hidden"])) .if-not-transfer,
.operation-form:not(:has(input[name="shared"]:checked)) .if-shared,
.operation-form:not(:has(input[name="split_mode"][value="libre"]:checked)) .if-free,
.operation-form:not(:has(input[name="type"][value="virement"]:is(:checked, [type="hidden"]))) .if-transfer,
.category-form:not(:has(#parent option[value="0"]:checked)) .if-top-level {
  display: none;
}

.split-member { display: flex; align-items: center; gap: .75rem; }
.split-member .check { flex: 1; }
.split-member input:not([type]) { max-width: 8rem; }

/* Panneaux repliables */

details > summary {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  color: var(--link);
  font-weight: 600;
  cursor: pointer;
}
details.more[open] { display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem; }

.panel {
  padding: 0 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.panel[open] { padding-bottom: 1rem; }
.panel .form { margin-top: 0; }

.filters { display: grid; gap: .75rem; }
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr));
  gap: .75rem 1rem;
  margin-bottom: 1rem;
}

/* Boutons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: .5rem 1.25rem;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  background: var(--hover);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.btn:hover { background: var(--border); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { color: var(--on-primary); background: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--on-danger); background: var(--danger); }
.btn-danger:hover { background: var(--danger-text); }
.btn-icon { flex: none; width: var(--tap); padding: 0; font-size: 1.375rem; }

/* Messages */

.alert, .flash {
  margin: 0;
  padding: .75rem 1rem;
  border-radius: 8px;
}
.alert { color: var(--danger-text); background: var(--danger-bg); border: 1px solid var(--danger-border); }
.flash { color: var(--ok-text); background: var(--ok-bg); border: 1px solid var(--ok-border); }

.badge {
  display: inline-block;
  padding: 0 .375rem;
  color: var(--text);
  font-size: .75rem;
  font-weight: 600;
  background: var(--hover);
  border-radius: 4px;
}

/* Bouton flottant « + Opération », toujours accessible */

.fab {
  position: fixed;
  right: 1rem;
  bottom: calc(var(--tabbar-h) + 1rem + env(safe-area-inset-bottom));
  z-index: 11;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-height: 56px;
  padding: 0 1.25rem 0 1rem;
  color: var(--on-primary);
  font-weight: 700;
  text-decoration: none;
  background: var(--primary);
  border-radius: 16px;
  box-shadow: 0 4px 12px rgb(0 0 0 / .25);
}
.fab:hover { background: var(--primary-hover); }
.fab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }

/* Opérations : cartes sur mobile, lignes en colonnes au-delà. */

.results { display: grid; gap: .75rem; }
.summary { margin: 0; color: var(--muted); }

.tx-list {
  display: grid;
  gap: .5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tx {
  display: grid;
  grid-template-columns: var(--tap) minmax(0, 1fr) auto;
  grid-template-areas:
    "check link amount"
    "check meta meta";
  align-items: center;
  column-gap: .5rem;
  padding: .5rem .75rem .5rem .25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.tx-check {
  display: grid;
  grid-area: check;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  cursor: pointer;
}

.tx-link, .tx-main {
  display: grid;
  grid-area: link;
  align-content: center;
  min-width: 0;
  min-height: var(--tap);
  color: var(--text);
  text-decoration: none;
}
.tx-link:hover .tx-label { text-decoration: underline; }
.tx-label { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.tx-cat { display: flex; align-items: center; gap: .375rem; min-width: 0; color: var(--muted); font-size: .875rem; }

.tx-meta {
  display: flex;
  flex-wrap: wrap;
  grid-area: meta;
  gap: .25rem .75rem;
  color: var(--muted);
  font-size: .875rem;
}

.tx-amount { display: flex; grid-area: amount; align-items: center; justify-self: end; gap: .25rem; }
.cleared {
  width: 1.125rem;
  height: 1.125rem;
  fill: none;
  stroke: var(--positive);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; }

/* Import : étapes, aperçu brut, onglets, résumé */

.steps {
  display: flex;
  gap: .5rem;
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-size: .875rem;
  list-style: none;
}
.steps li { display: flex; align-items: center; gap: .375rem; }
.steps .step-label { white-space: nowrap; }
.steps .step-num {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  font-weight: 700;
  background: var(--hover);
  border-radius: 50%;
}
.steps [aria-current="step"] { color: var(--text); font-weight: 600; }
.steps [aria-current="step"] .step-num { color: var(--on-primary); background: var(--primary); }

/* Sur un écran étroit, seule l'étape courante garde son intitulé visible. */
@media (max-width: 479px) {
  .steps li:not([aria-current]) .step-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
}

.table-scroll { max-width: 100%; overflow-x: auto; }
.raw { border-collapse: collapse; font-size: .875rem; white-space: nowrap; }
.raw th, .raw td { padding: .375rem .625rem; text-align: left; border-bottom: 1px solid var(--border); }
.raw thead th, .raw tbody th { color: var(--muted); font-weight: 600; }
.raw .is-header td { font-weight: 700; background: var(--hover); }
.raw td.amount { text-align: right; }
.raw .is-past td, .raw .is-past th { color: var(--muted); }

.mapping-form:has(input[name="amount_mode"][value="debit-credit"]:checked) .if-single-amount,
.mapping-form:has(input[name="amount_mode"][value="montant"]:checked) .if-debit-credit {
  display: none;
}

.tabs { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 1px solid var(--border); }
.tabs a {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 .75rem;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.tabs a[aria-current="page"] { color: var(--primary); border-bottom-color: var(--primary); }

.summary-card { display: grid; gap: .75rem; }
.counts { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; margin: 0; }
.counts strong { font-size: 1.25rem; }

.badge-error, .badge-over { color: var(--danger-text); background: var(--danger-bg); }
.badge-ok { color: var(--ok-text); background: var(--ok-bg); }
.badge-risk { color: var(--warning-text); background: var(--warning-bg); }

.notice {
  margin: 0;
  padding: .75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
}

/* Virements à rapprocher */

.pairs { display: grid; gap: .75rem; margin: 0; padding: 0; list-style: none; }
.pair { display: grid; gap: .75rem; }
.pair-legs { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: .5rem; }
.pair-legs > div { display: grid; gap: .125rem; min-width: 0; }
.pair-account { font-weight: 700; }
.pair-arrow { color: var(--muted); font-size: 1.5rem; }

.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .75rem; margin: 0 0 1rem; }
.figures div { display: grid; gap: .125rem; }
.figures dt { color: var(--muted); font-size: .875rem; }
.figures dd { margin: 0; font-size: 1.25rem; }
.reconcile { display: grid; justify-items: start; gap: .5rem; }

/* Récurrences */

.candidate { display: grid; gap: .5rem; }
.candidate p { margin: 0; }
.candidate-head { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
.candidate-head .tx-label { white-space: normal; }
.confidence { display: flex; align-items: center; gap: .5rem; font-size: .875rem; }
.confidence label { font-weight: 400; color: var(--muted); }
.confidence meter { flex: 1; max-width: 12rem; height: 1rem; }

.inline-fields { display: flex; gap: .5rem; }
.inline-fields input { max-width: 6rem; }

.recurrence-form:not(:has(#period option[value="autre"]:checked)) .if-custom-period,
.recurrence-form:not(:has(input[name="type"][value="virement"]:checked)) .if-transfer,
.recurrence-form:not(:has(input[name="type"][value="depense"]:checked)) .if-expense,
.recurrence-form:not(:has(input[name="smooth"]:checked)) .if-smooth {
  display: none;
}

/* Scénarios : seuls les champs de la modification choisie sont affichés. */

.scenario-form:not(:has(#kind :is(option[value="ponctuel"], option[value="recurrent"]):checked)) .if-movement,
.scenario-form:not(:has(#kind :is(option[value="ponctuel"], option[value="recurrent"], option[value="credit"]):checked)) .if-named,
.scenario-form:not(:has(#kind option[value="recurrent"]:checked)) .if-repeating,
.scenario-form:not(:has(#kind :is(option[value="suspension"], option[value="variation"]):checked)) .if-rule,
.scenario-form:not(:has(#kind option[value="variation"]:checked)) .if-vary,
.scenario-form:not(:has(#kind option[value="credit"]:checked)) .if-loan,
.scenario-form:not(:has(#kind option[value="anticipe"]:checked)) .if-prepay {
  display: none;
}

/* Sauvegardes */

.backup-form:not(:has(input[name="copy"][value="dossier"]:checked)) .if-folder,
.backup-form:not(:has(input[name="copy"][value="webdav"]:checked)) .if-webdav {
  display: none;
}
.row-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.backup-row { flex-wrap: wrap; padding-block: .5rem; }

/* Un libellé qui englobe son champ (formulaires répétés sur une page). */
label:has(> input:not([type="checkbox"], [type="radio"]), > select) { display: grid; gap: .375rem; }
label > input, label > select { font-weight: 400; }

/* Épargne */

.account-form:not(:has(#kind option[value="epargne"]:checked)) .if-savings,
.account-form:not(:has(input[name="lock"][value="date"]:checked)) .if-lock-date,
.account-form:not(:has(input[name="lock"][value="duree"]:checked)) .if-lock-months,
.account-form:has(input[name="lock"][value="aucun"]:checked) .if-locked {
  display: none;
}
.savings-fields { display: grid; gap: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.savings-fields > legend { font-size: 1.125rem; }

/* Budgets et alertes */

.badge-tag { color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); }
.warning-text { color: var(--warning-text); }
.quick-entry { display: grid; gap: .5rem; margin-bottom: 1rem; }
.quick-entry .chips { margin: 0; padding: 0; list-style: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-height: var(--tap);
  padding: 0 1rem;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.chip:hover { border-color: var(--input-border); }
[data-dictate][aria-pressed="true"] { color: var(--on-primary); background: var(--primary); }
.check-btn {
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  color: transparent;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.check-btn svg {
  width: 26px;
  height: 26px;
  padding: 2px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  border: 2px solid var(--input-border);
  border-radius: 6px;
}
.check-btn[aria-pressed="true"] { color: var(--on-primary); }
.check-btn[aria-pressed="true"] svg { background: var(--positive); border-color: var(--positive); }
.pointage { touch-action: pan-y; }
.pointage.is-cleared .tx-label { color: var(--muted); }
.tag-row { flex-wrap: wrap; }
.tag-row details { flex-basis: 100%; }

.month-nav { display: flex; align-items: center; gap: .75rem; }
.month-nav h2 { flex: 1; margin: 0; text-align: center; }
.month-nav h2::first-letter { text-transform: uppercase; }
.envelopes .row { padding-block: .75rem; }
.envelope { display: grid; flex: 1; gap: .375rem; min-width: 0; }
.envelope-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.envelope-head .row-title { min-height: var(--tap); color: var(--text); text-decoration: none; }
.envelope-head .row-title:hover { text-decoration: underline; }
.envelope p { margin: 0; }
.gauge { display: block; width: 100%; height: .5rem; border-radius: 999px; }
.gauge-track { fill: var(--hover); }
.gauge-ok .gauge-fill { fill: var(--positive); }
.gauge-risk .gauge-fill { fill: var(--warning); }
.gauge-over .gauge-fill { fill: var(--danger); }
.chart-bar { fill: color-mix(in srgb, var(--primary) 70%, transparent); }
.chart-bar.is-over { fill: var(--danger); }

.alert-card { display: grid; gap: .375rem; }
.alert-card p { margin: 0; }
.alert-title { font-weight: 600; }
.alert-kind { display: grid; gap: .5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.channels-form:not(:has(input[name="email_enabled"]:checked)) .if-email,
.channels-form:not(:has(input[name="webhook_enabled"]:checked)) .if-webhook {
  display: none;
}
.outlook { display: grid; gap: .5rem; }
.outlook p, .outlook .breakdown { margin: 0; }
.savings-card { display: grid; gap: .75rem; }
.forecast-summary .figures, .savings-card .figures { grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr)); }
.savings-card p, .savings-card .figures { margin: 0; }
.savings-card .candidate-head a { color: var(--text); }
.deposit-list { margin: 0; padding-left: 1.25rem; color: var(--muted); font-size: .875rem; }
.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem; margin-bottom: 1rem; }
.inline-form .field { flex: 1 1 12rem; }

/* Prévisionnel */

.forecast-query { margin-top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chips a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 1rem;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.chips a:hover { border-color: var(--input-border); }
.chips a[aria-current] { color: var(--on-primary); background: var(--primary); border-color: var(--primary); }

.forecast-summary { display: grid; gap: .5rem; }
.forecast-summary h2, .forecast-summary p, .forecast-summary .figures { margin: 0; }
.forecast-closing { font-size: 2rem; line-height: 1.2; }
.forecast-summary .alert ul { margin: .25rem 0 0; padding-left: 1.25rem; }

.chart { display: grid; gap: .5rem; margin: 0; }
.chart figcaption { font-weight: 600; }
.chart-svg { display: block; width: 100%; height: 14rem; overflow: visible; }
.chart-area { fill: color-mix(in srgb, var(--primary) 12%, transparent); }
.chart-line { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; }
.chart-reference { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-threshold { stroke: var(--danger); stroke-width: 1.5; stroke-dasharray: 6 4; }
.chart-below { fill: var(--danger-bg); }
.chart-low { fill: var(--surface); stroke: var(--danger); stroke-width: 3; }
.chart-label {
  fill: var(--muted);
  font-size: .75rem;
  font-variant-numeric: tabular-nums;
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.chart-x { text-anchor: middle; }

.breakdown { display: grid; margin: 0 0 .75rem; }
.breakdown div { display: flex; justify-content: space-between; gap: 1rem; padding: .375rem 0; }
.breakdown div + div { border-top: 1px solid var(--border); }
.breakdown dt { color: var(--muted); }
.breakdown dd { margin: 0; text-align: right; white-space: nowrap; }
.breakdown .breakdown-total dt, .breakdown .breakdown-total dd { color: var(--text); font-weight: 700; }
.breakdown .breakdown-total { border-top-width: 2px; }
.rows-split .row { justify-content: space-between; }

.month-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .25rem 1rem;
  margin: 1rem 0 .5rem;
  font-size: 1rem;
}
.month-head span:first-child::first-letter { text-transform: uppercase; }
.month-head .muted { font-size: .875rem; font-weight: 400; }

.fc-lines {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.fc-line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto var(--tap);
  grid-template-areas:
    "label label amount action"
    "date meta balance action";
  align-items: center;
  gap: .125rem .5rem;
  min-height: 3.5rem;
  padding: .375rem .25rem .375rem .75rem;
}
.fc-line + .fc-line { border-top: 1px solid var(--border); }
.fc-date { grid-area: date; color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; }
.fc-label { grid-area: label; overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.fc-meta { grid-area: meta; overflow: hidden; color: var(--muted); font-size: .875rem; text-overflow: ellipsis; white-space: nowrap; }
.fc-line .amount { grid-area: amount; justify-self: end; }
.fc-balance { grid-area: balance; justify-self: end; color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fc-balance.negative { color: var(--danger-text); }
.fc-line form { display: grid; grid-area: action; place-items: center; }
.fc-line .btn-icon { background: transparent; }
.fc-line .btn-icon:hover { background: var(--hover); }
.fc-line.is-excluded :is(.fc-label, .amount) { color: var(--muted); text-decoration: line-through; }

@media (min-width: 768px) {
  /* En-tête et navigation alignés sur le bord du contenu centré. */
  .topbar, .tabbar { padding-inline: max(1.5rem, (100% - var(--content-max)) / 2 + 1.5rem); }

  .tabbar {
    position: static;
    gap: .25rem;
    padding-block: 0;
    border-top: 0;
    border-bottom: 1px solid var(--border);
  }
  .tabbar a {
    flex: none;
    flex-direction: row;
    gap: .5rem;
    min-height: var(--tap);
    padding: 0 .75rem;
    font-size: .9375rem;
    border-bottom: 2px solid transparent;
  }
  .tabbar a[aria-current="page"], .tabbar a.is-current-narrow { border-bottom-color: var(--primary); }

  .page { padding: 1.5rem 1.5rem calc(56px + 3rem); }
  .page-centered { padding-top: 4rem; }

  .fab { right: max(1.5rem, (100% - var(--content-max)) / 2 + 1.5rem); bottom: 1.5rem; }

  .tx-list {
    gap: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
  }
  .tx {
    grid-template-columns: var(--tap) 7.5rem minmax(0, 1fr) minmax(7rem, 12rem) 9.5rem;
    grid-template-areas: "check date link account amount";
    padding-block: .25rem;
    border: 0;
    border-radius: 0;
  }
  .tx + .tx { border-top: 1px solid var(--border); }
  .tx-meta { display: contents; }
  .tx-date { grid-area: date; }
  .tx-account { grid-area: account; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .chart-svg { height: 18rem; }
}

/* Petit ordinateur : toutes les rubriques tiennent sur une ligne sans
   leurs icônes. */
@media (min-width: 1024px) and (max-width: 1279px) {
  .tabbar a svg { display: none; }
}

/* Ordinateur : toutes les rubriques sur une ligne (« Plus » devient
   inutile), une échéance du prévisionnel par ligne. */
@media (min-width: 1024px) {
  .tabbar .nav-secondary { display: flex; }
  /* Budgets, Épargne et Rapports sont dans la barre : « Plus » ne les
     signale plus, et sa page ne les répète pas. */
  .tabbar .nav-more.is-current-narrow:not([aria-current]) { color: var(--muted); font-weight: 400; border-bottom-color: transparent; }
  .nav-secondary-entry { display: none; }

  .fc-line {
    grid-template-columns: 6.5rem minmax(0, 1fr) minmax(0, 14rem) 8.5rem 8.5rem var(--tap);
    grid-template-areas: "date label meta amount balance action";
    min-height: var(--tap);
    padding-block: .125rem;
  }
  .fc-balance { font-size: 1rem; }
}
