  @font-face {
    font-family: 'Cabinet Grotesk';
    src: url('fonts/CabinetGrotesk-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
  }
  @font-face {
    font-family: 'Cabinet Grotesk';
    src: url('fonts/CabinetGrotesk-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
  }
  @font-face {
    font-family: 'Cabinet Grotesk';
    src: url('fonts/CabinetGrotesk-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
  }
  @font-face {
    font-family: 'Cabinet Grotesk';
    src: url('fonts/CabinetGrotesk-Extrabold.woff2') format('woff2');
    font-weight: 800;
    font-style: normal;
    font-display: swap;
  }

  :root {
    --bg: #faf9f7;
    --card: #ffffff;
    --ink: #1f2420;
    --muted: #6b6f6c;
    --line: #e7e4de;
    --accent: #2f5d4f;
    --accent-soft: #e4efe9;
    --danger: #b3543f;
    --danger-soft: #f6e6e1;
    --gold: #b98a3d;
    --savings: #0e8a7d;
  }
  body.dark-mode {
    --bg: #161917;
    --card: #212523;
    --ink: #ece9e3;
    --muted: #8b8f8a;
    --line: #343936;
    --accent: #4a8a74;
    --accent-soft: #21332c;
    --danger: #d17a68;
    --danger-soft: #3a2622;
    --gold: #d4a24d;
    --savings: #2fa89a;
  }
  body { transition: background-color 0.2s ease, color 0.2s ease; }
  * {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
  }
  html {
    touch-action: manipulation;
    /* Empêche Safari iOS d'ajuster automatiquement la taille du texte selon sa propre
       heuristique à chaque fois que la géométrie de la page change (donc à chaque
       changement d'onglet) — c'est ce qui donnait l'impression que le contenu "vibrait"
       (rétrécit puis regrandit). Sans lien avec le zoom pincé de l'utilisateur, qu'on
       laisse volontairement actif pour l'accessibilité. */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  body {
    margin: 0;
    font-family: 'Cabinet Grotesk', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    padding: calc(24px + env(safe-area-inset-top, 0px)) 16px calc(84px + env(safe-area-inset-bottom, 0px));
    touch-action: manipulation;
  }
  .wrap { max-width: 720px; margin: 0 auto; }
  /* Contenu réservé aux technologies d'assistance : visible pour un lecteur d'écran, jamais
     à l'écran. Utilisé notamment pour les régions aria-live qui annoncent un état sans
     dupliquer visuellement une info déjà affichée. */
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  h1 {
    font-size: 30px;
    font-weight: 800;
    margin: 0 0 4px;
    letter-spacing: -0.01em;
  }
  .subtitle { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
  .app-header-icon {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(0,0,0,0.18);
  }
  .app-greeting {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin: 0;
  }
  .app-header-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
  }
  /* Sans la phrase de résumé qui suivait auparavant (retirée), le bloc titre a besoin d'un
     peu plus de respiration avant la première carte. */
  .app-header-row-solo {
    margin-bottom: 22px;
  }
  .offline-banner {
    display: none;
    align-items: center;
    gap: 6px;
    width: fit-content;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 11.5px;
    font-weight: 700;
    padding: 5px 10px 5px 8px;
    border-radius: 999px;
    margin-bottom: 12px;
    cursor: default;
  }
  .offline-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
    animation: offline-dot-pulse 1.6s ease-in-out infinite;
  }
  /* Ne s'affiche que si une sauvegarde a réellement échoué et repasse en tentative — teinte
     danger douce (jamais alarmante) plutôt que la teinte neutre de la bannière hors-ligne,
     pour rester visible sans ajouter de stress inutile au cas courant (ça finit toujours
     par se resynchroniser tout seul). */
  .save-status-banner {
    display: none;
    align-items: center;
    gap: 6px;
    width: fit-content;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 11.5px;
    font-weight: 700;
    padding: 5px 10px 5px 8px;
    border-radius: 999px;
    margin-bottom: 12px;
    cursor: default;
  }
  .save-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--danger);
    flex-shrink: 0;
    animation: offline-dot-pulse 1.6s ease-in-out infinite;
  }
  @keyframes offline-dot-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
  }
  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    background: var(--card);
    border-top: 1px solid var(--line);
    max-width: 720px;
    margin: 0 auto;
    box-sizing: border-box;
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 14px rgba(0,0,0,0.06);
    /* Son propre calque de rendu stable : sans ça, Safari iOS peut faire "vibrer" cette barre
       fixe pendant que le panneau juste à côté anime un translateX (repaint qui déborde sur
       les éléments voisins). */
    transform: translateZ(0);
  }
  .bottom-nav-item {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: none;
    background: none;
    color: var(--muted);
    padding: 6px 2px;
    cursor: pointer;
    transition: color 0.15s ease;
  }
  .bottom-nav-item svg {
    width: 22px;
    height: 22px;
  }
  .bottom-nav-item span {
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
  }
  .bottom-nav-icon-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 28px;
    border-radius: 14px;
    transition: background 0.2s ease, transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .bottom-nav-badge {
    position: absolute;
    top: 2px;
    right: 9px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--danger);
    border: 1.5px solid var(--card);
  }
  .bottom-nav-item.active { color: var(--accent); }
  .bottom-nav-item.active .bottom-nav-icon-wrap {
    background: var(--accent-soft);
    transform: scale(1.06);
  }
  .bottom-nav-item.active svg {
    stroke-width: 2.4;
  }
  .bottom-nav-fab {
    flex: 0 0 auto;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 4px;
    margin-top: -26px;
    border: 4px solid var(--bg);
    box-shadow: 0 4px 14px rgba(47, 93, 79, 0.4);
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .bottom-nav-fab:active { transform: scale(0.9); }
  .bottom-nav-fab svg {
    width: 26px;
    height: 26px;
  }

  /* Le tout premier onglet affiché (chargement de l'app) reçoit un simple fondu — la
     notion de "direction" n'a pas de sens avant qu'il y ait un onglet précédent. */
  .tab-panel.tab-panel-in {
    animation: tab-panel-in 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  }
  @keyframes tab-panel-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* Changement d'onglet : le panneau ciblé glisse depuis la direction réelle de la navigation
     (ordre des 4 onglets dans la barre du bas), plutôt qu'une coupure sèche. Le panneau quitté
     est masqué immédiatement (jamais animé en sortie) pour qu'un seul panneau reste dans le
     flux à la fois — sinon leur hauteur cumulée peut faire apparaître/disparaître la barre de
     défilement verticale et déplacer la barre de navigation fixe, centrée sur la largeur de la
     fenêtre. */
  .tab-panel.entering-from-left,
  .tab-panel.entering-from-right {
    /* Calque de rendu dédié pendant l'animation seulement : évite que le repaint du
       translateX déborde visuellement sur la barre de navigation fixe juste en dessous. */
    will-change: transform, opacity;
    /* Empêche tout scintillement de barre de défilement horizontale pendant le glissement
       (translateX de quelques pixels) — mais seulement le temps de l'animation : posé ici
       plutôt que sur .tab-panel en permanence, sinon il rogne aussi l'ombre portée de la
       carte "Aujourd'hui" sur les côtés au repos (jamais sur body/html : Safari iOS a un
       bug connu où un overflow non-visible sur body casse position:fixed et fait défiler
       la barre de navigation avec la page au lieu de la garder fixée en bas). Le JS retire
       cette classe à la fin de l'animation (voir setActiveTab), donc le rognage ne dure que
       les ~220ms du glissement. */
    overflow-x: hidden;
  }
  .tab-panel.entering-from-left { animation: tab-enter-from-left 0.22s cubic-bezier(0.16, 1, 0.3, 1); }
  .tab-panel.entering-from-right { animation: tab-enter-from-right 0.22s cubic-bezier(0.16, 1, 0.3, 1); }
  @keyframes tab-enter-from-left {
    from { opacity: 0; transform: translateX(-14px); }
    to { opacity: 1; transform: translateX(0); }
  }
  @keyframes tab-enter-from-right {
    from { opacity: 0; transform: translateX(14px); }
    to { opacity: 1; transform: translateX(0); }
  }
  @media (prefers-reduced-motion: reduce) {
    .tab-panel.tab-panel-in,
    .tab-panel.entering-from-left,
    .tab-panel.entering-from-right {
      animation: none;
    }
  }

  .card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px 20px;
    margin-bottom: 16px;
  }
  .card h2 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin: 0 0 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .card-danger {
    background: var(--danger-soft);
    border-color: var(--danger);
  }
  .card-danger h2 { color: var(--danger); }
  .danger-btn {
    border: 1px solid var(--danger);
    background: var(--card);
    color: var(--danger);
    font-size: 13px;
    font-weight: 700;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
  }
  .danger-btn:hover { background: var(--danger); color: #fff; }

  .row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
    transition: opacity 0.15s ease, border-color 0.15s ease;
  }
  .row:last-child { border-bottom: none; }
  .row input[type="text"] {
    flex: 1;
    min-width: 0;
    border: none;
    border-radius: 0;
    padding: 4px 2px;
    font-size: 14px;
    background: transparent;
    color: var(--ink);
  }
  .date-input {
    width: 100px;
    flex-shrink: 0;
    border: none;
    padding: 4px 2px;
    font-size: 12px;
    background: transparent;
    color: var(--muted);
  }
  .date-input:focus { outline: none; color: var(--ink); }

  .category-select-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    flex-shrink: 0;
  }
  .category-select-placeholder { visibility: hidden; }
  .category-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    color: #fff;
    flex-shrink: 0;
    pointer-events: none;
  }

  .category-chart-row {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
  }
  .donut-wrap {
    position: relative;
    width: 140px;
    height: 140px;
    flex-shrink: 0;
  }
  .donut {
    width: 140px;
    height: 140px;
    border-radius: 50%;
  }
  .donut-segment {
    cursor: pointer;
    transition: opacity 0.15s ease;
  }
  .donut-segment:hover { opacity: 0.75; }
  .donut-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: var(--card);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
  }
  .donut-total { font-size: 14px; font-weight: 700; color: var(--ink); }
  .donut-label { font-size: 11px; color: var(--muted); }
  .category-legend {
    flex: 1;
    min-width: 160px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .category-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    cursor: pointer;
    padding: 3px 4px;
    margin: -3px -4px;
    border-radius: 6px;
    transition: background 0.15s ease;
  }
  .category-legend-item:hover { background: var(--accent-soft); }
  .category-legend-item.active { background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
  .category-legend-item .cat-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
  }
  .category-legend-item .cat-name {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--ink);
  }
  .category-legend-item .cat-name-text {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .category-legend-item .cat-amount {
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
  }
  .category-legend-item .cat-amount.over-budget {
    color: var(--danger);
    font-weight: 700;
  }
  .category-legend-item .cat-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .category-legend-item .cat-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
  }
  .cat-budget-bar-wrap {
    height: 4px;
    border-radius: 3px;
    background: var(--line);
    overflow: hidden;
  }
  .cat-budget-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--accent);
    transition: width 0.3s ease;
  }
  .cat-budget-bar-fill.over {
    background: var(--danger);
  }
  .category-legend-empty {
    font-size: 13px;
    color: var(--muted);
  }
  .category-budget-row { gap: 10px; }
  .category-budget-label {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--ink);
  }
  .category-budget-emoji {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 20px;
    color: var(--muted);
  }
  .category-budget-input {
    width: 100px;
    flex-shrink: 0;
    text-align: right;
    padding: 8px 10px;
    font-size: 14px;
  }

  .savings-chart-svg {
    width: 100%;
    height: 150px;
    display: block;
    overflow: visible;
  }
  .savings-chart-legend {
    display: flex;
    justify-content: center;
    gap: 16px;
    font-size: 11px;
    color: var(--muted);
    margin-top: 6px;
  }
  .legend-line {
    display: inline-block;
    width: 16px;
    height: 0;
    border-top: 2px solid var(--accent);
    margin-right: 5px;
    vertical-align: middle;
  }
  .legend-line.dashed {
    border-top: 2px dashed var(--gold);
  }
  .savings-chart-legend .legend-line.solid + span { color: var(--accent); font-weight: 600; }
  .savings-chart-legend .legend-line.dashed + span { color: var(--gold); font-weight: 600; }

  .savings-move-heading {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
  }
  .savings-movements-list {
    margin-top: 10px;
    max-height: 220px;
    overflow-y: auto;
  }
  .savings-move-empty,
  .list-empty {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    padding: 10px 0;
  }
  .savings-move-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
  }
  .savings-move-row:last-child { border-bottom: none; }
  .savings-move-icon {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
  }
  .savings-move-icon svg { width: 15px; height: 15px; }
  .savings-move-icon.contribution { background: var(--accent); }
  .savings-move-icon.withdrawal { background: var(--danger); }
  .savings-move-name {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .savings-move-date {
    font-size: 12px;
    color: var(--muted);
    flex-shrink: 0;
  }
  .savings-move-amount {
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
  }
  .savings-move-amount.pos { color: var(--accent); }
  .savings-move-amount.neg { color: var(--danger); }

  .savings-forecast {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
  }
  .savings-forecast-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 10px;
  }
  .savings-forecast-input {
    width: 60px;
    text-align: center;
    padding: 6px 4px;
  }
  .savings-forecast-result {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    color: var(--ink);
    line-height: 1.5;
  }
  .savings-forecast-result b { color: var(--accent); }
  .row input[type="number"] {
    width: 80px;
    border: none;
    border-radius: 0;
    padding: 4px 2px;
    font-size: 14px;
    font-weight: 700;
    text-align: right;
    background: transparent;
    color: var(--ink);
  }
  /* Montant d'une ligne de mouvement : signe + devise + montant (comme dans la liste des
     mouvements d'épargne), jamais un chiffre nu — plus de sens sans avoir à distinguer une
     nuance de vert d'une nuance de rouge. */
  .row-amount {
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
    flex-shrink: 0;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }
  .row-income .row-amount { color: var(--accent); }
  .row-expense .row-amount { color: var(--danger); }
  .row input:focus { outline: none; }
  .row input[type="text"]:focus,
  .row input[type="number"]:focus {
    background: var(--accent-soft);
    border-radius: 6px;
  }
  .row .chf { display: none; }
  /* Le crayon et la corbeille individuels ne sont plus affichés : partout où une ligne
     est modifiable/supprimable, le bouton "..." (row-more-btn) ouvre la feuille d'actions. */
  .edit-btn,
  .del-btn {
    display: none;
  }

  .row-more-btn {
    display: flex;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    width: 40px;
    height: 40px;
    padding: 0;
    flex-shrink: 0;
    border-radius: 9px;
    align-items: center;
    justify-content: center;
  }
  .row-more-btn svg { width: 18px; height: 18px; }
  .row:hover .row-more-btn { color: var(--ink); }
  .row-more-btn:hover { background: var(--bg); color: var(--ink); }

  .row-action-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    border: none;
    background: none;
    padding: 14px 6px;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    border-radius: 10px;
    text-align: left;
  }
  .row-action-btn svg { width: 19px; height: 19px; flex-shrink: 0; color: var(--muted); }
  .row-action-btn.danger { color: var(--danger); }
  .row-action-btn.danger svg { color: var(--danger); }
  .row-action-btn:active { background: var(--bg); }

  .add-btn {
    border: 1px dashed var(--line);
    background: transparent;
    color: var(--accent);
    font-size: 13px;
    padding: 12px 14px;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
    margin-top: 4px;
  }
  .add-btn:hover { background: var(--accent-soft); }
  .add-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
  }
  .add-btn-icon svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    stroke-width: 2.3;
  }
  .add-btn-warn {
    border: 1px solid var(--gold);
    color: var(--gold);
    font-weight: 700;
  }
  .add-btn-warn:hover { background: rgba(185, 138, 61, 0.1); }
  .archive-warn-hint {
    font-weight: 600;
    color: var(--ink);
  }

  .day-group-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    padding: 14px 0 6px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 2px;
  }
  .day-group-header:first-child { padding-top: 0; }
  .day-group-total {
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
    color: var(--ink);
    font-size: 12px;
  }

  /* Double filet : la marque comptable d'une somme finale, pour la distinguer d'un simple
     trait de séparation entre deux lignes de la liste au-dessus. */
  .subtotal {
    text-align: right;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
    margin-top: 12px;
    padding-top: 11px;
    border-top: 3px double var(--line);
  }
  .subtotal-label {
    color: var(--muted);
    font-weight: 500;
  }
  #todayExpensesSubtotal {
    border-top: none;
    padding-top: 0;
  }

  .sort-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 12px;
  }
  .sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--muted);
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 999px;
    cursor: pointer;
  }
  .sort-btn svg { width: 12px; height: 12px; flex-shrink: 0; }
  .sort-btn:hover { border-color: var(--accent); color: var(--accent); }
  .sort-btn.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 600; }

  .chart-scroll {
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .day-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 130px;
    min-width: fit-content;
    padding-top: 22px;
    position: relative;
  }
  .day-bar-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 21px;
    flex: 0 0 auto;
    position: relative;
    height: 100%;
    justify-content: flex-end;
  }
  .day-bar-amount {
    font-size: 10px;
    color: var(--muted);
    white-space: nowrap;
    margin-bottom: 2px;
  }
  .day-bar {
    width: 14px;
    background: var(--gold);
    border-radius: 3px 3px 0 0;
    min-height: 2px;
    transition: height 0.3s ease;
    position: relative;
  }
  .day-bar.today { background: var(--accent); }
  .day-bar.empty { background: var(--line); }
  .day-bar.over::after {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 5px solid var(--danger);
  }
  .day-label {
    font-size: 10.5px;
    color: var(--muted);
    margin-top: 4px;
  }
  .day-label.today { color: var(--accent); font-weight: 700; }
  .chart-hint {
    font-size: 11px;
    color: var(--muted);
    text-align: center;
    margin-top: 6px;
  }
  .day-bar-wrap { cursor: pointer; }
  .day-bar-wrap:hover .day-bar { opacity: 0.8; }
  .day-bar.selected { box-shadow: 0 0 0 2px var(--gold) inset; }
  .day-bar.today { box-shadow: 0 0 0 2px var(--ink) inset; }
  .day-bar.ok { background: var(--accent); }
  .day-bar.over { background: var(--danger); }
  .day-label.selected, .day-label.today { color: var(--ink); font-weight: 700; }
  .day-month-label {
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--gold);
    font-weight: 700;
    margin-top: 1px;
  }

  .target-line {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
    text-align: center;
  }
  .target-line b { color: var(--ink); }

  .target-ref-line {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 2px dashed var(--muted);
    pointer-events: none;
  }
  .target-ref-line.negative {
    border-top-color: var(--danger);
  }
  .target-ref-negative-label {
    position: absolute;
    left: 0;
    bottom: 2px;
    font-size: 10px;
    font-weight: 700;
    color: var(--danger);
    background: var(--danger-soft);
    padding: 1px 6px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
  }

  .day-tooltip {
    position: fixed;
    z-index: 50;
    background: #23272a;
    color: #fff;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 12px;
    max-width: 220px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    pointer-events: none;
  }
  .day-tooltip .dt-date {
    font-weight: 700;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
  }
  .day-tooltip .dt-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 2px 0;
  }
  .day-tooltip .dt-row .dt-name {
    color: rgba(255,255,255,0.85);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    overflow: hidden;
  }
  .day-tooltip .dt-row .dt-name-text {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .day-tooltip .dt-row .dt-amount {
    font-weight: 600;
    white-space: nowrap;
  }
  .day-tooltip .dt-total {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255,255,255,0.2);
    font-weight: 700;
    display: flex;
    justify-content: space-between;
  }
  .day-tooltip .dt-empty {
    color: rgba(255,255,255,0.7);
    font-style: italic;
  }

  .chart-legend {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-top: 8px;
    font-size: 11px;
    color: var(--muted);
    flex-wrap: wrap;
  }
  .chart-legend .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
  }
  .chart-legend .dot.ok { background: var(--accent); }
  .chart-legend .dot.over { background: var(--danger); }
  .chart-legend .dot.today-ring { background: #fff; box-shadow: 0 0 0 2px var(--ink) inset; }

  .status-banner {
    margin-top: 12px;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 13px;
    text-align: center;
    line-height: 1.5;
  }
  .status-banner.good { background: var(--accent-soft); color: var(--accent); }
  .status-banner.bad { background: var(--danger-soft); color: var(--danger); }
  .status-banner b { font-weight: 700; }

  .collapsible-header {
    cursor: pointer;
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0 !important;
    user-select: none;
  }
  .collapsible-header:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 6px;
  }
  .collapsible-card .collapsible-header {
    margin-bottom: 14px;
  }
  .collapsible-card.collapsed .collapsible-header {
    margin-bottom: 0;
  }
  .collapse-toggle-icon {
    position: relative;
    display: inline-block;
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    transition: transform 0.15s ease;
  }
  .collapsible-header:active .collapse-toggle-icon {
    transform: scale(0.8);
  }
  .collapse-toggle-icon .ct-line {
    position: absolute;
    top: 50%;
    left: 50%;
    background: var(--muted);
    border-radius: 2px;
  }
  .collapse-toggle-icon .ct-h {
    width: 13px;
    height: 2px;
    margin: -1px 0 0 -6.5px;
  }
  .collapse-toggle-icon .ct-v {
    width: 2px;
    height: 13px;
    margin: -6.5px 0 0 -1px;
    transform: scaleY(0);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
  }
  .collapse-toggle-icon.is-collapsed .ct-v {
    transform: scaleY(1);
    opacity: 1;
  }
  .collapsible-content {
    overflow: hidden;
    transition: height 0.25s ease;
  }
  .period-inline-header {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 12px !important;
  }

  .day-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--accent-soft);
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 12px;
    font-size: 12px;
    color: var(--accent);
  }
  .day-filter-bar button {
    border: none;
    background: none;
    color: var(--accent);
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    margin: -8px -4px -8px 0;
  }
  .day-filter-bar button svg { width: 14px; height: 14px; }

  .category-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 12px;
    font-size: 12px;
    font-weight: 600;
  }
  .category-filter-bar button {
    border: none;
    background: none;
    font-weight: 700;
    cursor: pointer;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    margin: -8px -4px -8px 0;
  }
  .category-filter-bar button svg { width: 14px; height: 14px; }

  .history-list { margin-bottom: 10px; }
  .history-empty {
    font-size: 13px;
    color: var(--muted);
    text-align: center;
    padding: 10px 0;
  }
  .history-item {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 8px;
  }
  .history-item .h-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
  }
  .history-item .h-month {
    font-size: 14px;
    font-weight: 700;
  }
  .history-item .h-balance {
    font-size: 14px;
    font-weight: 700;
  }
  .history-item .h-balance.pos { color: var(--accent); }
  .history-item .h-balance.neg { color: var(--danger); }
  .history-item .h-rows {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    font-size: 12px;
    color: var(--muted);
  }
  .history-item .h-rows b { color: var(--ink); }
  .history-item .h-trend {
    font-size: 11px;
    margin-left: 4px;
  }
  .history-item .h-trend.up { color: var(--danger); }
  .history-item .h-trend.down { color: var(--accent); }
  .history-hint {
    font-size: 11px;
    color: var(--muted);
    text-align: center;
    margin-top: 8px;
  }
  .settings-hint {
    font-size: 12px;
    color: var(--muted);
    margin-top: 8px;
  }
  .settings-group-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin: 22px 4px 8px;
  }
  .settings-group-label:first-child { margin-top: 0; }
  .settings-divider {
    height: 1px;
    background: var(--line);
    margin: 16px 0;
  }
  .settings-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    color: var(--ink);
  }
  .settings-switch {
    position: relative;
    width: 46px;
    height: 26px;
    border-radius: 999px;
    border: none;
    background: var(--line);
    cursor: pointer;
    padding: 0;
    transition: background 0.2s ease;
    flex-shrink: 0;
  }
  .settings-switch.on { background: var(--accent); }
  .settings-switch-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    transition: transform 0.2s ease;
  }
  .settings-switch.on .settings-switch-knob {
    transform: translateX(20px);
  }
  .theme-swatch-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
  }
  .theme-swatch {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    padding: 0;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.18);
    transition: transform 0.15s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.15s ease;
  }
  .theme-swatch:active { transform: scale(0.9); }
  /* Anneau de sélection à l'extérieur du disque (plutôt qu'une bordure interne qui rognait
     visuellement la couleur du thème sur le pastille active) — le disque garde toute sa
     couleur, l'anneau se dessine autour, avec un léger espace de la couleur de la carte. */
  .theme-swatch.active {
    transform: scale(1.12);
    box-shadow: 0 2px 6px rgba(0,0,0,0.18), 0 0 0 2px var(--card), 0 0 0 4px var(--ink);
  }

  .currency-picker-row, .language-picker-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }
  .currency-picker-btn {
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
  }
  .currency-picker-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
  }

  .summary {
    display: flex;
    gap: 3px;
    margin-bottom: 16px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 3px;
  }
  .summary .box {
    flex: 1;
    border-radius: 11px;
    padding: 12px 16px;
    text-align: left;
  }
  .summary .box.clickable {
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
  }
  .summary .box.income { color: var(--accent); }
  .summary .box.expense { color: var(--danger); }
  .summary .box .label { font-size: 12px; color: inherit; opacity: 0.75; margin-bottom: 4px; }
  .summary .box .val { font-size: 20px; font-weight: 700; }
  .summary .box.income.active { background: var(--accent); color: #fff; }
  .summary .box.expense.active { background: var(--danger); color: #fff; }
  .summary .box.clickable.inactive { color: var(--muted); }
  .summary .box.clickable.inactive .label { opacity: 1; }

  .today-status-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
  }
  .today-status-label {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
  }
  .today-status-date {
    font-size: 12px;
    color: var(--muted);
  }
  .today-status-amounts {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 2px;
  }
  /* Moment authored unique par session : l'arrivée sur le chiffre du jour à l'ouverture de l'app. */
  .today-status-amounts.today-figure-reveal {
    animation: today-figure-reveal 0.55s cubic-bezier(0.16, 1, 0.3, 1);
  }
  @keyframes today-figure-reveal {
    from { opacity: 0; transform: translateY(6px); filter: blur(4px); }
    to { opacity: 1; transform: translateY(0); filter: blur(0); }
  }
  @media (prefers-reduced-motion: reduce) {
    .today-status-amounts.today-figure-reveal { animation: none; }
  }
  .today-status-spent {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--ink);
    transition: color 0.3s ease;
  }
  .today-status-sep { font-size: 18px; color: var(--muted); }
  .today-status-total-available {
    font-size: 18px;
    font-weight: 600;
    color: var(--muted);
  }
  .today-status-target {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 12px;
  }
  .today-status-card.over .today-status-spent { color: var(--danger); }
  .today-status-card.ok .today-status-spent { color: var(--accent); }

  /* La carte "Aujourd'hui" porte le seul chiffre qui compte vraiment au quotidien — elle
     s'en distingue par une véritable élévation (elle flotte au-dessus des deux autres cartes,
     restées plates) plutôt que par la couleur ou la taille du texte, pour ne jamais jurer avec
     l'état affiché à l'intérieur (vert/terracotta selon que le budget du jour tient ou non).
     Seule exception assumée à la règle des cartes plates au repos, réservée à cette carte-ci. */
  .today-status-card.today-featured {
    border: none;
    box-shadow: 0 10px 24px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.06);
  }

  .today-status-bar-wrap {
    height: 10px;
    border-radius: 6px;
    background: var(--line);
    overflow: hidden;
    margin-bottom: 8px;
  }
  .today-status-bar-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s ease, background 0.3s ease;
  }
  .today-status-card.over .today-status-bar-fill { background: var(--danger); }

  .today-status-msg {
    font-size: 13px;
    color: var(--muted);
  }
  .today-status-card.over .today-status-msg { color: var(--danger); }
  .today-status-card.ok .today-status-msg { color: var(--accent); }
  .today-tomorrow-hint {
    font-size: 11.5px;
    color: var(--muted);
    font-style: italic;
    margin-top: 2px;
  }
  /* Jauge de cycle de paye : un trait par jour de la période, celui d'aujourd'hui plein —
     rend visible la position dans le cycle plutôt que de la laisser implicite dans le texte
     (remplace l'ancienne ligne "prochaine paye" à icône, dont la date est reprise ici). */
  .cycle-strip {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
  }
  .cycle-ticks {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 22px;
  }
  .cycle-tick {
    flex: 1;
    min-width: 2px;
    border-radius: 999px;
    background: var(--line);
    height: 10px;
  }
  .cycle-tick.elapsed { background: var(--muted); opacity: 0.5; }
  .cycle-tick.today {
    background: var(--accent);
    height: 22px;
    width: 3px;
    flex: 0 0 3px;
    border-radius: 999px;
  }
  .cycle-caption {
    margin-top: 9px;
    font-size: 12.5px;
    color: var(--muted);
    line-height: 1.5;
  }
  .cycle-caption b { color: var(--ink); font-weight: 700; }
  .cycle-caption .cycle-days-left { color: var(--accent); font-weight: 700; }

  .today-expenses-list {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
  }
  .today-expenses-list .date-input { display: none; }
  .today-expenses-empty {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    padding: 6px 0;
  }
  .today-movements-count {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    padding-bottom: 6px;
  }
  .row-income input[type="number"] { color: var(--accent); }
  .row-expense input[type="number"] { color: var(--danger); }
  .today-net-pos { color: var(--accent); font-weight: 700; }
  .today-net-neg { color: var(--danger); font-weight: 700; }

  .balance-card {
    text-align: left;
  }
  .today-status-spent.pos { color: var(--accent); }
  .today-status-spent.neg { color: var(--danger); }
  .period-info {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
  }
  .period-field-label {
    font-size: 12px;
    color: var(--muted);
    width: 72px;
    flex-shrink: 0;
  }
  .collapsed-summary {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 12px;
  }

  .bar-wrap {
    margin-top: 12px;
    height: 10px;
    border-radius: 6px;
    background: var(--line);
    overflow: hidden;
    display: flex;
  }
  .bar-fill {
    height: 100%;
    transition: width 0.3s ease;
  }
  .bar-fill:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 1px;
  }
  .bar-fill.fixed { background: var(--accent); }
  .bar-fill.variable { background: var(--gold); }
  .bar-fill.epargne { background: var(--savings); }

  .bar-legend {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 8px;
    font-size: 11px;
    color: var(--muted);
  }
  .bar-legend .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
  }
  .bar-legend .dot.fixed { background: var(--accent); }
  .bar-legend .dot.variable { background: var(--gold); }
  .bar-legend .dot.epargne { background: var(--savings); }
  .bar-legend .dot.fixed + span { color: var(--accent); font-weight: 600; }
  .bar-legend .dot.variable + span { color: var(--gold); font-weight: 600; }
  .bar-legend .dot.epargne + span { color: var(--savings); font-weight: 600; }

  .status {
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    margin-top: 18px;
    min-height: 16px;
  }

  @media (max-width: 480px) {
    body { padding: calc(16px + env(safe-area-inset-top, 0px)) 8px calc(78px + env(safe-area-inset-bottom, 0px)); }
    h1 { font-size: 25px; }
    .card { padding: 14px 10px; }
    .balance-card .today-status-spent { font-size: 24px; }
    .summary { gap: 8px; }
    .summary .box { padding: 12px; }
    .summary .box .val { font-size: 17px; }

    .row {
      flex-wrap: nowrap;
      gap: 6px;
      padding: 8px 0;
    }
    .chf { display: none; }
    .category-select-wrap {
      order: 1;
      width: 26px;
      height: 30px;
      min-width: 26px;
      flex: 0 0 auto;
    }
    .category-badge svg { width: 14px; height: 14px; }
    .row input[type="text"] {
      order: 2;
      flex: 1 1 auto;
      min-width: 0;
      font-size: 13px;
      padding: 4px 2px;
    }
    .date-input {
      order: 3;
      width: 62px;
      min-width: 62px;
      flex: 0 0 auto;
      font-size: 10px;
      padding: 4px 1px;
    }
    .row input[type="number"] {
      order: 4;
      width: 56px;
      min-width: 56px;
      flex: 0 0 auto;
      font-size: 13px;
      padding: 4px 2px;
    }
    .row-amount {
      order: 4;
      flex: 0 0 auto;
      font-size: 12.5px;
    }
    .row-more-btn {
      order: 5;
      width: 40px;
      height: 40px;
      flex: 0 0 auto;
    }

    .category-chart-row {
      flex-direction: column;
      align-items: center;
      gap: 14px;
    }
    .donut-wrap {
      width: 120px;
      height: 120px;
    }
    .donut { width: 120px; height: 120px; }
    .donut-center { width: 72px; height: 72px; }
    .category-legend {
      width: 100%;
      min-width: 0;
    }
  }

  .quick-add-confirmation {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
    transition: opacity 0.5s ease;
  }
  .quick-add-confirmation.fade-out { opacity: 0; }
  .qac-check {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
  }
  .qac-check svg { width: 30px; height: 30px; }
  .qac-title { font-size: 20px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
  .qac-detail { font-size: 15px; color: var(--muted); margin-bottom: 14px; }
  .qac-hint { font-size: 12px; color: var(--muted); }

  .modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(31, 36, 32, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
  }
  .modal-box {
    background: var(--card);
    width: 100%;
    max-width: 420px;
    max-height: calc(100vh - 40px);
    /* dvh suit la hauteur réellement visible (clavier ouvert compris) sur les navigateurs
       qui le supportent — vh ci-dessus reste le repli pour les autres. */
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    animation: modal-pop-in 0.2s ease-out;
  }
  @keyframes modal-pop-in {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
  }
  .modal-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 16px;
  }
  .modal-label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
    margin-top: 12px;
  }
  .modal-label:first-of-type { margin-top: 0; }
  /* Resserre Catégorie contre Montant juste au-dessus : les deux forment le vrai cœur du
     formulaire (remplis à chaque ajout), tandis que Date/Nom en dessous sont déjà pré-remplis
     ou optionnels — la respiration supplémentaire avant Date (.modal-label-section) marque
     ce passage du "cœur" aux "détails" plutôt qu'un espacement identique et indifférencié
     partout. */
  .modal-label-tight { margin-top: 6px; }
  .modal-label-section { margin-top: 22px; }
  .modal-input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 11px 12px;
    font-size: 16px;
    background: var(--card);
    color: var(--ink);
  }
  .modal-input:focus { outline: none; border-color: var(--accent); }
  .modal-input.invalid { border-color: var(--danger); }
  .modal-field-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: 6px;
  }
  input[type="date"].modal-input {
    padding: 11px 12px;
    font-size: 16px;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    -webkit-appearance: none;
    appearance: none;
  }
  .modal-row-split {
    display: flex;
    gap: 10px;
  }
  .modal-col { flex: 1; min-width: 0; }
  /* Reste rare à l'usage (une grosse dépense inhabituelle, pas une décision à chaque café) :
     traité comme un addendum discret sous Nom plutôt qu'une rangée avec le même poids que
     les champs principaux — plus proche, plus petit, plus sourd. */
  .modal-checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
  }
  .modal-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
  }
  .modal-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    flex-shrink: 0;
  }
  .info-tooltip-wrap { position: relative; display: inline-flex; align-items: center; }
  .info-tooltip-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: var(--bg);
    color: var(--muted);
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
  }
  .info-tooltip-btn svg { width: 13px; height: 13px; }
  .info-tooltip-bubble {
    position: absolute;
    bottom: calc(100% + 9px);
    right: -8px;
    background: var(--ink);
    color: var(--card);
    font-size: 12px;
    line-height: 1.4;
    padding: 10px 12px;
    border-radius: 10px;
    width: 220px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    z-index: 20;
    display: none;
  }
  .info-tooltip-bubble.visible { display: block; }
  .info-tooltip-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 12px;
    border: 6px solid transparent;
    border-top-color: var(--ink);
  }
  .modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
  }
  .modal-btn {
    flex: 1;
    border: none;
    border-radius: 10px;
    padding: 13px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
  }
  .modal-btn.cancel { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
  .modal-btn.submit { background: var(--accent); color: #fff; }
  .modal-btn.submit:hover { background: #274e42; }
  .modal-btn.submit.danger { background: var(--danger); }
  .modal-btn.submit.danger:hover { background: #963f2d; }

  .confirm-action-preview {
    background: var(--bg);
    border-radius: 10px;
    padding: 12px 14px;
    margin-top: 10px;
    font-size: 13px;
  }
  .confirm-action-preview .cap-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    color: var(--muted);
  }
  .confirm-action-preview .cap-row b {
    color: var(--ink);
    font-variant-numeric: tabular-nums;
  }
  .confirm-action-preview.danger {
    background: var(--danger-soft);
    color: var(--danger);
  }

  .category-picker {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    margin-bottom: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    mask-image: linear-gradient(to right, black calc(100% - 28px), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 28px), transparent 100%);
  }
  .category-picker.scrolled-end {
    mask-image: none;
    -webkit-mask-image: none;
  }
  .category-picker-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 58px;
    flex-shrink: 0;
    border: none;
    background: none;
    padding: 4px 2px;
    cursor: pointer;
    border-radius: 10px;
  }
  .category-picker-item:active .category-picker-icon { transform: scale(0.9); }
  .category-picker-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    border: 2px solid transparent;
    transition: transform 0.15s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.15s ease;
  }
  .category-picker-icon svg { width: 16px; height: 16px; }
  .category-picker-label {
    font-size: 10.5px;
    color: var(--muted);
    text-align: center;
    line-height: 1.2;
    max-width: 58px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .category-picker-item.active .category-picker-icon {
    border-color: var(--ink);
    transform: scale(1.12);
  }
  .category-picker-item.active .category-picker-label { color: var(--ink); font-weight: 700; }

  .onboarding-box {
    position: relative;
    text-align: center;
    max-width: 380px;
  }
  .onboarding-skip {
    position: absolute;
    top: 18px;
    right: 18px;
    border: none;
    background: none;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
    padding: 4px;
  }
  .onboarding-back {
    position: absolute;
    top: 18px;
    left: 18px;
    border: none;
    background: none;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
    padding: 4px;
  }
  .onboarding-progress {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 22px;
  }
  .onboarding-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--muted);
    opacity: 0.35;
    transition: background 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
  }
  .onboarding-dot.active { background: var(--accent); opacity: 1; transform: scale(1.2); }
  .onboarding-icon-circle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    color: #fff;
  }
  .onboarding-icon-circle svg { width: 26px; height: 26px; }
  .onboarding-icon-circle.income { background: var(--accent); }
  .onboarding-icon-circle.expense { background: var(--danger); }
  .onboarding-icon-circle.neutral { background: var(--accent); }
  .onboarding-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 8px;
  }
  .onboarding-text {
    font-size: 14px;
    color: var(--muted);
    line-height: 1.5;
    margin-bottom: 20px;
  }
  .onboarding-box .modal-label { text-align: left; }
  .onboarding-cta { width: 100%; margin-top: 8px; }
  .onboarding-added-list {
    text-align: left;
    margin-bottom: 14px;
  }
  .onboarding-added-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--bg);
    font-size: 13px;
    color: var(--ink);
    margin-bottom: 6px;
  }
  .onboarding-added-item span:first-child {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .onboarding-added-item span:last-child {
    color: var(--muted);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
  }
  .onboarding-tour-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    text-align: left;
    margin-bottom: 16px;
  }
  .onboarding-tour-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
  }
  .onboarding-tour-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--accent-soft);
    color: var(--accent);
  }
  .onboarding-tour-icon svg { width: 18px; height: 18px; }
  .onboarding-tour-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 2px;
  }
  .onboarding-tour-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
  }
  .onboarding-tour-desc {
    font-size: 12.5px;
    color: var(--muted);
    line-height: 1.4;
  }
  .onboarding-skip-step {
    display: block;
    width: 100%;
    text-align: center;
    border: none;
    background: none;
    color: var(--muted);
    font-size: 13px;
    padding: 14px 0 2px;
    cursor: pointer;
  }

  .sheet-overlay {
    align-items: flex-end;
    padding: 0;
    transition: background-color 0.25s ease;
  }
  .sheet-box {
    width: 100%;
    max-width: 480px;
    background: var(--card);
    border-radius: 22px 22px 0 0;
    padding: 10px 20px calc(20px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -8px 32px rgba(0,0,0,0.2);
    animation: sheet-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .sheet-box.closing {
    animation: sheet-out 0.15s cubic-bezier(0.4, 0, 1, 1) forwards;
  }
  @keyframes sheet-in {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }
  @keyframes sheet-out {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(30px); opacity: 0; }
  }
  .sheet-handle {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--line);
    margin: 6px auto 18px;
  }
  .sheet-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
    text-align: center;
    margin-bottom: 18px;
  }
  .quick-add-choice-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .quick-add-choice-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    border: none;
    border-radius: 16px;
    padding: 22px 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    transition: transform 0.15s cubic-bezier(0.22, 1, 0.36, 1), background 0.15s ease;
  }
  .quick-add-choice-tile:active { transform: scale(0.96); }
  .quick-add-choice-tile.expense { background: var(--danger-soft); color: var(--danger); }
  .quick-add-choice-tile.income { background: var(--accent-soft); color: var(--accent); }
  .quick-add-choice-icon {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
  }
  .quick-add-choice-tile.expense .quick-add-choice-icon { background: var(--danger); }
  .quick-add-choice-tile.income .quick-add-choice-icon { background: var(--accent); }
  .quick-add-choice-icon svg { width: 22px; height: 22px; }
  .sheet-cancel-link {
    display: block;
    width: 100%;
    text-align: center;
    border: none;
    background: none;
    color: var(--muted);
    font-size: 13px;
    padding: 16px 0 4px;
    cursor: pointer;
  }

  .undo-toast {
    position: fixed;
    left: 50%;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    z-index: 180;
    /* Teinte sombre fixe, indépendante du mode clair/sombre — comme .day-tooltip. `--ink`
       s'inverse en mode sombre (devient clair, puisque c'est la couleur du texte principal
       sur fond sombre) : l'utiliser ici rendait ce toast illisible en dark mode (fond clair,
       texte blanc dessus). */
    background: #23272a;
    color: #fff;
    border-radius: 12px;
    padding: 12px 14px 12px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    max-width: calc(100vw - 32px);
    animation: undo-toast-in 0.2s ease-out;
  }
  .undo-toast.fade-out { animation: undo-toast-out 0.3s ease forwards; }
  @keyframes undo-toast-in {
    from { transform: translateX(-50%) translateY(10px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
  }
  @keyframes undo-toast-out {
    to { transform: translateX(-50%) translateY(10px); opacity: 0; }
  }
  #undoToastBtn {
    border: none;
    background: none;
    color: var(--gold);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    padding: 4px 6px;
  }

  .app-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 310;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    opacity: 1;
    transition: opacity 0.25s ease;
  }
  .app-loading.fade-out {
    opacity: 0;
    pointer-events: none;
  }
  .app-loading-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: auth-spin 0.7s linear infinite;
  }
  .auth-screen {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 1;
    transition: opacity 0.3s ease;
  }
  .auth-screen.fade-out {
    opacity: 0;
    pointer-events: none;
  }
  .auth-box {
    width: 100%;
    max-width: 360px;
    text-align: center;
    animation: auth-box-in 0.4s ease-out;
  }
  @keyframes auth-box-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
  }
  .auth-logo {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    overflow: hidden;
    margin: 0 auto 14px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  }
  .auth-logo img {
    display: block;
    width: 100%;
    height: 100%;
  }
  .auth-spinner {
    display: inline-block;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 8px;
    animation: auth-spin 0.6s linear infinite;
  }
  @keyframes auth-spin {
    to { transform: rotate(360deg); }
  }
  @keyframes app-wrap-in {
    from { opacity: 0; transform: translateY(10px) scale(0.99); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }
  .app-wrap-in {
    animation: app-wrap-in 0.45s ease-out;
  }
  .auth-title { font-size: 24px; font-weight: 800; margin: 0 0 6px; }
  .auth-subtitle { font-size: 13px; color: var(--muted); margin: 0 0 20px; }
  .auth-box .modal-label { text-align: left; }
  .auth-error {
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 13px;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 14px;
    text-align: left;
  }
  .auth-success {
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 13px;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 14px;
    text-align: left;
    line-height: 1.5;
  }
  .auth-forgot-link {
    text-align: right;
    margin-top: 8px;
  }
  .auth-forgot-link button {
    border: none;
    background: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 12px;
    padding: 2px;
    text-decoration: underline;
  }
  .auth-forgot-link button:hover { color: var(--accent); }
  .auth-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 0;
    color: var(--muted);
    font-size: 12px;
  }
  .auth-divider::before,
  .auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--line);
  }
  .google-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
    font-size: 14px;
    font-weight: 600;
    padding: 11px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
  }
  .google-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
  .google-btn:disabled { opacity: 0.6; cursor: default; }
  .auth-switch {
    margin-top: 18px;
    font-size: 13px;
    color: var(--muted);
  }
  .auth-switch button {
    border: none;
    background: none;
    color: var(--accent);
    font-weight: 700;
    cursor: pointer;
    padding: 0 4px;
    font-size: 13px;
  }
