/* ===========================================================
   Budgy — feuille de style principale
   Direction : « Ledger » — registre de compte, sombre et vivant.
   Thème sombre unique (plus de mode clair automatique).
   Source de vérité : design-system/budgy/MASTER.md (à régénérer
   pour refléter cette palette — voir note en fin de fichier).
   Les polices sont chargées par fragments/head.html (pas d'@import :
   un @import retarde le premier rendu d'un aller-retour réseau).
   =========================================================== */

/* ===========================================================
   1. Tokens
   =========================================================== */

:root {
    /* --- Primitives ------------------------------------------------ */
    --ledger-ink: #101915;
    --ledger-panel: #1B2620;
    --ledger-panel-raised: #212F27;
    --ledger-sunken: #141E19;
    --ledger-hover: #22302A;

    --ivory: #EDE6D6;
    --ivory-bright: #F5F1E6;
    --sage-muted: #8A9A90;
    --sage-line: #263A30;
    --sage-line-strong: #38503F;

    --gold-300: #D9BD86;
    --gold-500: #C6A15B;
    --gold-600: #B08B49;

    --rust-300: #E7A98C;
    --rust-500: #A9573A;
    --rust-600: #8F4830;

    --focus-blue: #7FB6EA;

    /* --- Sémantiques (thème sombre unique) -------------------------- */
    --bg: var(--ledger-ink);
    --surface: var(--ledger-panel);
    --surface-sunken: var(--ledger-sunken);
    --surface-raised: var(--ledger-panel-raised);
    --surface-hover: var(--ledger-hover);

    --ink: var(--ivory);
    --ink-muted: var(--sage-muted);

    --line: var(--sage-line);
    --line-strong: var(--sage-line-strong);

    --primary: var(--gold-500);
    --primary-hover: var(--gold-600);
    --on-primary: #14201C;

    --accent: var(--gold-500);
    --accent-soft: rgba(198, 161, 91, 0.16);

    --positive: var(--gold-500);
    --positive-soft: rgba(198, 161, 91, 0.14);

    --negative: var(--rust-500);
    --negative-soft: rgba(169, 87, 58, 0.16);

    --ring: var(--focus-blue);

    /* Palette des catégories (Chart.js). Déclarée ici, et nulle part ailleurs :
       le JS la lit via getComputedStyle. Tons rompus, cohérents avec l'encre
       du fond ; ordonnée pour rester distinguable en deutéranopie. */
    --chart-1: #C6A15B;
    --chart-2: #A9573A;
    --chart-3: #6E9C8B;
    --chart-4: #6C8CAE;
    --chart-5: #8B6C93;
    --chart-6: #9C9482;
    --chart-7: #7C9457;
    --chart-8: #6B7789;

    /* Bandeau héros : dégradé d'encre profonde, un ton au-dessus du fond */
    --hero-bg: linear-gradient(160deg, #23332B 0%, #131D18 100%);
    --hero-ink: var(--ivory-bright);
    --hero-ink-muted: rgba(245, 241, 230, 0.7);
    --hero-negative: var(--rust-300);

    /* --- Typographie ----------------------------------------------- */
    /* Fraunces porte les gros nombres et les titres — le registre où
       l'argent EST le contenu mérite un traitement éditorial.
       Work Sans porte l'interface. IBM Plex Mono reste réservé aux
       montants tabulaires : l'alignement des chiffres n'est pas
       décoratif, il aide à lire un relevé d'un coup d'œil. */
    --font-display: 'Fraunces', Georgia, serif;
    --font-sans: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    --text-2xs: 0.6875rem;
    --text-xs: 0.75rem;
    --text-sm: 0.8125rem;
    --text-base: 0.9375rem;
    --text-md: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.375rem;
    --text-2xl: 1.75rem;
    --text-3xl: 2.25rem;

    /* --- Espacement (densité 7/10) ---------------------------------- */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;
    --space-8: 4rem;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-pill: 999px;

    /* En sombre, les filets remplacent les ombres : elles disparaissent
       presque, sauf pour ce qui flotte réellement au-dessus (modale). */
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);

    /* --- Mouvement --------------------------------------------------- */
    --ease: cubic-bezier(0.2, 0, 0.2, 1);
    --ease-entrance: cubic-bezier(0.22, 0.61, 0.36, 1);
    --dur-control: 120ms;
    --dur-surface: 180ms;
    --dur-entrance: 560ms;

    /* Padding interne des cartes : sert aussi de référence au tableau
       qui scrolle horizontalement (voir .card > .table-scroll) */
    --card-pad: var(--space-5);

    /* Hauteur minimale des cibles tactiles */
    --tap: 44px;

    color-scheme: dark;
}

/* ===========================================================
   2. Base
   =========================================================== */

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

html {
    /* Le header n'est pas collant, mais on garde une marge d'ancrage
       pour que le focus ne se retrouve jamais collé au bord haut */
    scroll-padding-top: var(--space-5);
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: var(--text-md);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Anneau de focus unique pour toute l'application. Jamais supprimé,
   seulement remplacé par ce style. Bleu délibérément hors palette :
   un focus ne doit jamais se confondre avec un montant ou un accent. */
:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

a {
    color: var(--primary);
}

/* Icônes SVG inline : elles suivent la couleur du texte et ne captent
   jamais le pointeur (le label voisin reste la cible). */
.icon {
    width: 1.125em;
    height: 1.125em;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

/* Contenu réservé aux technologies d'assistance (légendes de tableau) */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* Lien d'évitement : invisible jusqu'au premier Tab */
.skip-link {
    position: absolute;
    left: var(--space-3);
    top: var(--space-3);
    z-index: 100;
    transform: translateY(-200%);
    background: var(--primary);
    color: var(--on-primary);
    font-size: var(--text-sm);
    font-weight: 600;
    text-decoration: none;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius);
    transition: transform var(--dur-control) var(--ease);
}

.skip-link:focus-visible {
    transform: translateY(0);
}

/* ===========================================================
   3. Rail de navigation latéral
   Desktop : fixe à gauche, icônes seules (libellé visually-hidden +
   infobulle native via title). Mobile : voir §21 (devient barre + tiroir).
   Le décalage du contenu (body:has) est en §4.
   =========================================================== */

.app-rail {
    position: fixed;
    inset: 0 auto 0 0;
    width: 76px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-4) 0 var(--space-3);
    z-index: 40;
}

.rail-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-bottom: var(--space-5);
    border-radius: var(--radius);
    color: var(--accent);
    text-decoration: none;
}

/* Marque : anneau = budget total, quartier plein = part consommée */
.brand-mark {
    width: 1.6em;
    height: 1.6em;
    flex: none;
}

.brand-mark-ring {
    fill: none;
    stroke: var(--sage-muted);
    stroke-width: 2;
}

.brand-mark-slice {
    fill: var(--accent);
}

.rail-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: var(--tap);
    height: var(--tap);
    padding: 0;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--ink);
}

.rail-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform var(--dur-control) var(--ease),
                opacity var(--dur-control) var(--ease);
}

.rail-toggle.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.rail-toggle.is-open span:nth-child(2) { opacity: 0; }
.rail-toggle.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.rail-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    flex: 1;
    width: 100%;
}

.rail-link {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 52px;
    height: 52px;
    border-radius: var(--radius);
    color: var(--ink-muted);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    transition: background-color var(--dur-control) var(--ease),
                color var(--dur-control) var(--ease);
}

.rail-link:hover {
    background: var(--surface-hover);
    color: var(--ink);
}

/* Page courante : fond + icône accentuée + aria-current="page" côté HTML.
   La couleur seule ne suffit pas à signaler la position. */
.rail-link.is-active {
    background: var(--surface-hover);
    color: var(--accent);
}

.rail-link .icon {
    width: 20px;
    height: 20px;
}

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

.rail-logout-form {
    width: 100%;
    display: flex;
    justify-content: center;
    margin: 0;
    margin-top: var(--space-2);
}

/* ===========================================================
   4. Conteneur de page
   =========================================================== */

.page {
    max-width: 960px;
    margin: 0 auto;
    padding: var(--space-6) var(--space-5) var(--space-8);
}

/* Les pages qui incluent le rail (toutes sauf les écrans d'authentification)
   voient leur contenu décalé d'autant — sans qu'aucun autre template n'ait
   besoin d'un wrapper dédié. Contrepartie du :has() : navigateurs récents
   uniquement (Chrome/Edge/Safari, Firefox 121+) ; sans support, le rail
   recouvre le début du contenu sur desktop — acceptable en dégradation,
   à surveiller si votre socle de navigateurs cibles est plus ancien. */
body:has(.app-rail) {
    padding-left: 76px;
}

.page.page-wide {
    max-width: 1120px;
}

.page h1 {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.005em;
    color: var(--ink);
    margin: 0 0 var(--space-5);
    overflow-wrap: break-word;
    text-wrap: balance;
}

/* En-tête de page : titre à gauche, actions à droite */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.page-header h1 {
    margin: 0;
}

.section-title {
    font-size: var(--text-lg);
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin: var(--space-6) 0 var(--space-3);
}

.section-title:first-child {
    margin-top: 0;
}

/* Texte explicatif secondaire (notes, états vides) */
.note,
.stats-empty {
    font-size: var(--text-base);
    color: var(--ink-muted);
    margin: 0;
    padding: var(--space-2) 0;
}

/* Une note peut être préfixée d'une icône sans casser le flux du texte :
   l'icône reste en ligne, contrairement aux alertes qui sont en flex. */
.note > .icon {
    vertical-align: -0.2em;
    margin-right: var(--space-1);
}

.note strong {
    color: var(--ink);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* Fil d'Ariane / retour arrière */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--ink-muted);
    text-decoration: none;
    margin-bottom: var(--space-4);
    min-height: var(--tap);
    transition: color var(--dur-control) var(--ease);
}

.back-link:hover {
    color: var(--ink);
}

/* ===========================================================
   5. Messages (alerte / succès)
   Icône + texte : le sens n'est jamais porté par la couleur seule.
   =========================================================== */

.alert,
.form-error,
.form-success {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    font-size: var(--text-base);
    padding: var(--space-3) var(--space-4);
    border: 1px solid transparent;
    border-radius: var(--radius);
    margin: 0 0 var(--space-4);
}

.form-error {
    background: var(--negative-soft);
    border-color: var(--negative);
    color: var(--negative);
}

.form-success {
    background: var(--positive-soft);
    border-color: var(--positive);
    color: var(--positive);
}

.alert .icon,
.form-error .icon,
.form-success .icon {
    margin-top: 0.15em;
}

/* ===========================================================
   6. Cartes
   =========================================================== */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--card-pad);
    margin-bottom: var(--space-5);
    min-width: 0;
}

.card:last-child {
    margin-bottom: 0;
}

/* ===========================================================
   7. Boutons
   =========================================================== */

/* Tout bouton porte une classe .btn-*. Les sélecteurs d'élément
   (`form.entry-form button`) sont volontairement absents ici : à 0,1,1 ils
   l'emportent sur `.btn-secondary` à 0,1,0 et écrasent silencieusement la
   variante — c'est ainsi que le « Annuler » d'une modale se retrouvait
   peint comme l'action principale. Le filet pour un bouton sans classe est
   plus bas, via :not([class]), qui ne peut par construction jamais entrer
   en conflit avec une variante. */
.btn,
.btn-primary,
.btn-secondary,
.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--tap);
    padding: 0 var(--space-5);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background-color var(--dur-control) var(--ease),
                border-color var(--dur-control) var(--ease),
                color var(--dur-control) var(--ease),
                transform var(--dur-control) var(--ease);
}

.btn-primary {
    background: var(--primary);
    color: var(--on-primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-secondary {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--line-strong);
}

.btn-secondary:hover {
    background: var(--surface-hover);
    border-color: var(--ink-muted);
}

.btn-ghost {
    background: none;
    color: var(--ink-muted);
    border-color: transparent;
    padding: 0 var(--space-3);
}

.btn-ghost:hover {
    background: var(--surface-hover);
    color: var(--ink);
}

/* Variante compacte, utilisée dans les cellules de tableau */
.btn-sm {
    min-height: 34px;
    padding: 0 var(--space-3);
    font-size: var(--text-sm);
}

/* Action en cours : le bouton reste lisible mais clairement inopérant */
.btn:disabled,
.btn-primary:disabled,
.btn-secondary:disabled,
.btn-ghost:disabled {
    opacity: 0.6;
    cursor: progress;
}

/* Filet : un bouton de formulaire qui aurait été oublié sans classe.
   :not([class]) ne matche que les éléments sans attribut class, il ne peut
   donc jamais supplanter une variante .btn-*. */
form.entry-form button:not([class]),
form.filter-form button:not([class]) {
    min-height: var(--tap);
    padding: 0 var(--space-5);
    font: 600 var(--text-base)/1 var(--font-sans);
    color: var(--on-primary);
    background: var(--primary);
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
}

/* ===========================================================
   8. Formulaires
   =========================================================== */

form.filter-form,
form.entry-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-3) var(--space-4);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-4);
    margin-bottom: var(--space-5);
}

form.filter-form {
    background: var(--surface-sunken);
    box-shadow: none;
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-4);
}

form.filter-form label,
form.entry-form label,
.auth-form label {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--ink-muted);
}

form.filter-form input,
form.filter-form select,
form.entry-form input,
form.entry-form select,
.auth-form input {
    font-family: var(--font-sans);
    /* 16px : en dessous, iOS zoome automatiquement au focus */
    font-size: var(--text-md);
    min-height: var(--tap);
    padding: 0 var(--space-3);
    min-width: 150px;
    color: var(--ink);
    background: var(--surface-sunken);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    transition: border-color var(--dur-control) var(--ease);
}

form.filter-form input,
form.filter-form select {
    min-width: 120px;
    background: var(--surface);
}

form.entry-form input::placeholder,
.auth-form input::placeholder {
    color: var(--ink-muted);
    opacity: 1;
}

form.filter-form input:hover,
form.filter-form select:hover,
form.entry-form input:hover,
form.entry-form select:hover,
.auth-form input:hover {
    border-color: var(--ink-muted);
}

form.filter-form input:focus-visible,
form.filter-form select:focus-visible,
form.entry-form input:focus-visible,
form.entry-form select:focus-visible,
.auth-form input:focus-visible {
    border-color: var(--primary);
}

/* Les montants se saisissent en mono : on voit tout de suite l'ordre
   de grandeur, et le champ s'aligne avec les colonnes du tableau. */
form input[type="number"] {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* ===========================================================
   9. Tableau « registre »
   =========================================================== */

table.ledger {
    width: 100%;
    border-collapse: collapse;
}

table.ledger thead th {
    text-align: left;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-muted);
    font-weight: 600;
    padding: 0 var(--space-3) var(--space-2);
    border-bottom: 1px solid var(--line-strong);
    white-space: nowrap;
}

table.ledger tbody tr {
    border-bottom: 1px solid var(--line);
    transition: background-color var(--dur-control) var(--ease);
}

table.ledger tbody tr:last-child {
    border-bottom: none;
}

table.ledger tbody tr:hover {
    background: var(--surface-hover);
}

table.ledger td {
    padding: var(--space-3);
    font-size: var(--text-base);
    color: var(--ink);
    white-space: nowrap;
}

table.ledger td:first-child,
table.ledger th:first-child {
    padding-left: 0;
}

table.ledger td:last-child,
table.ledger th:last-child {
    padding-right: 0;
}

/* Colonnes de montant : mono, chiffres de largeur fixe, alignées à droite */
.amount,
table.ledger td.amount,
table.ledger th.amount {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    text-align: right;
    font-weight: 500;
}

/* Signe explicite : la couleur ne porte jamais le sens à elle seule */
.amount.is-positive {
    color: var(--positive);
}

.amount.is-positive::before {
    content: '+';
}

.amount.is-negative {
    color: var(--negative);
}

.amount.is-negative::before {
    content: '\2212';
}

/* Lien principal d'une ligne : c'est lui qui rend la ligne accessible
   au clavier (le clic sur la ligne n'est qu'un raccourci à la souris). */
table.ledger .row-link {
    color: var(--ink);
    font-weight: 500;
    text-decoration: none;
}

table.ledger .row-link:hover {
    color: var(--primary);
    text-decoration: underline;
}

table.ledger tbody tr.clickable-row {
    cursor: pointer;
}

table.ledger td.actions,
table.ledger th.actions {
    text-align: right;
}

table.ledger td.actions form {
    display: inline-block;
    margin: 0;
}

/* En-tête de groupe (dépenses regroupées par jour, cf. depenses.html) :
   pas une ligne de données, donc pas de fond hover ni de bordure basse
   pleine largeur — juste un repère typographique discret. */
table.ledger tr.ledger-date-row th {
    padding: var(--space-4) var(--space-3) var(--space-2) 0;
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: capitalize;
    letter-spacing: 0.01em;
    color: var(--ink-muted);
    border-bottom: none;
    background: none;
}

table.ledger tr.ledger-date-row:first-child th {
    padding-top: 0;
}

/* ===========================================================
   10. Badges (catégories, statuts, types)
   =========================================================== */

.badge,
table.ledger td.category-tag span,
.account-line .value.category-tag span {
    display: inline-block;
    max-width: 100%;
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 500;
    line-height: 1.6;
    letter-spacing: 0.01em;
    padding: var(--space-1) var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--surface-sunken);
    color: var(--ink-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.badge.is-positive {
    background: var(--positive-soft);
    border-color: transparent;
    color: var(--positive);
}

.badge.is-negative {
    background: var(--negative-soft);
    border-color: transparent;
    color: var(--negative);
}

.badge.is-accent {
    background: var(--accent-soft);
    border-color: transparent;
    color: var(--accent);
}

/* ===========================================================
   11. Zone de scroll horizontal des tableaux
   =========================================================== */

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
}

/* Le tableau prend la largeur de son contenu, jamais moins que le wrapper :
   il ne scrolle donc que lorsque c'est réellement nécessaire. */
.table-scroll > table.ledger,
table.ledger.wide {
    width: max-content;
    min-width: 100%;
}

/* Dans une carte, la zone scrollable affleure exactement les bords internes
   (la marge négative est toujours égale au padding de la carte). */
.card > .table-scroll {
    margin-inline: calc(var(--card-pad) * -1);
    padding-inline: var(--card-pad);
}

/* Les boutons d'action gardent leur taille naturelle dans un tableau,
   même quand la règle mobile passe les boutons en pleine largeur. */
table.ledger .btn,
table.ledger .btn-secondary {
    width: auto;
    min-height: 34px;
    padding: 0 var(--space-3);
    font-size: var(--text-sm);
}

/* ===========================================================
   12. Résumé de compte (paires label / valeur)
   =========================================================== */

.account-summary {
    display: grid;
}

.account-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-4);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--line);
}

.account-line:first-child {
    padding-top: 0;
}

.account-line:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

.account-line .label {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-base);
    color: var(--ink-muted);
}

.account-line .value {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: var(--text-md);
    font-weight: 500;
    color: var(--ink);
    text-align: right;
    white-space: nowrap;
}

.account-line.balance .value {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 500;
    color: var(--primary);
}

/* Solde dans le rouge. La couleur ne suffit pas : le libellé porte en plus
   une icône d'alerte (cf. MASTER.md §1). Pas de classe .amount ici, sinon
   un second signe « − » viendrait s'ajouter à celui du montant. */
.account-line.balance .value.is-negative {
    color: var(--negative);
}

.account-line.balance .label .icon {
    color: var(--negative);
}

/* Le badge dans une valeur reprend la typo sans-serif du badge */
.account-line .value.category-tag {
    font-family: var(--font-sans);
}

/* ===========================================================
   12b. Bandeau de statistiques (compte.html) — les repères clés du
   compte en un coup d'œil, plutôt qu'empilés en paires label/valeur.
   =========================================================== */

.stat-strip {
    display: flex;
    gap: var(--space-3);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: 2px;
}

.stat-card {
    flex: 1 1 180px;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-4);
    background: var(--surface-sunken);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    transition: border-color var(--dur-control) var(--ease),
                transform var(--dur-control) var(--ease);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--line-strong);
}

.stat-card-label {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--ink-muted);
}

.stat-card-value {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 500;
    color: var(--ink);
}

/* Les dates ne sont pas des montants : elles restent en sans-serif,
   taille normale, pour ne pas prétendre à une importance qu'elles n'ont
   pas dans la hiérarchie de la page. */
.stat-card-value-text {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    font-weight: 500;
}

.stat-card.is-negative .stat-card-value {
    color: var(--negative);
}

.stat-card.is-negative .stat-card-label .icon {
    color: var(--negative);
}

/* ===========================================================
   12c. Ligne graphique + catégories (compte.html)
   =========================================================== */

.compte-charts-row {
    display: flex;
    gap: var(--space-5);
    align-items: stretch;
    margin-bottom: var(--space-5);
}

.compte-charts-row > .card {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
}

@media (max-width: 900px) {
    .compte-charts-row {
        flex-direction: column;
    }
}

/* ===========================================================
   13. Bandeau « reste à vivre »
   =========================================================== */

/* Dégradé d'encre, un ton au-dessus du fond. Pas de texture : les filets
   « papier réglé » rayaient la surface au lieu de l'évoquer, même à très
   faible opacité. */
.reste-banner {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    background: var(--hero-bg);
    color: var(--hero-ink);
    padding: var(--space-5);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-5);
    border: 1px solid var(--line);
}

.reste-banner .reste-label {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--hero-ink-muted);
}

/* Reste à vivre négatif : rouille clair, lisible sur le dégradé d'encre */
.reste-banner.is-negative .reste-value {
    color: var(--hero-negative);
}

.reste-banner .reste-value {
    font-family: var(--font-display);
    font-variant-numeric: tabular-nums;
    font-size: var(--text-3xl);
    font-weight: 500;
    line-height: 1.1;
    letter-spacing: -0.01em;
    color: var(--hero-ink);
}

/* ===========================================================
   14. Listes simples et statistiques
   =========================================================== */

ul.simple-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

ul.simple-list li {
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--line);
    font-size: var(--text-base);
    color: var(--ink);
}

ul.simple-list li:first-child {
    padding-top: 0;
}

ul.simple-list li:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

.stats-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.stats-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--line);
}

.stats-item:first-child {
    padding-top: 0;
}

.stats-item:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

.stats-label {
    font-size: var(--text-base);
    color: var(--ink-muted);
    min-width: 0;
    overflow-wrap: break-word;
}

.stats-value {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--ink);
    white-space: nowrap;
}

/* ===========================================================
   15. Graphique (Chart.js)
   =========================================================== */

.chart-wrap {
    position: relative;
    width: 100%;
    height: 240px;
    margin-bottom: var(--space-4);
}

/* ===========================================================
   16. Modale (<dialog> natif)
   =========================================================== */

.modal {
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-lg);
    padding: 0;
    width: 100%;
    max-width: 440px;
    max-height: calc(100dvh - var(--space-6));
    overflow-y: auto;
    background: var(--surface-raised);
    color: var(--ink);
    box-shadow: var(--shadow-lg);
}

.modal::backdrop {
    background: rgba(6, 10, 8, 0.65);
}

.modal .entry-form {
    flex-direction: column;
    align-items: stretch;
    background: none;
    border: none;
    box-shadow: none;
    padding: var(--space-5);
    margin: 0;
}

.modal .section-title {
    margin: 0 0 var(--space-4);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    margin-top: var(--space-2);
}

/* ===========================================================
   17. Pages d'authentification (écran splitté)
   =========================================================== */

.auth-body {
    margin: 0;
}

.auth-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
}

/* Panneau gauche : identité de marque. Dégradé d'encre, sans texture. */
.auth-visual {
    flex: 1 1 44%;
    position: relative;
    overflow: hidden;
    background: var(--hero-bg);
    color: var(--hero-ink);
    display: flex;
    align-items: center;
    padding: var(--space-8) var(--space-7);
}

/* Courbe décorative : motif de marque, pas une donnée. Se dessine une
   seule fois au chargement (stroke-dasharray/offset), respecte
   prefers-reduced-motion via la règle globale §23. */
.auth-visual-curve {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    color: var(--gold-500);
    opacity: 0.5;
    pointer-events: none;
}

.auth-visual-curve-line {
    stroke-dasharray: 620;
    stroke-dashoffset: 620;
    animation: budgy-draw-curve 1800ms 200ms var(--ease-entrance) both;
}

@keyframes budgy-draw-curve {
    to { stroke-dashoffset: 0; }
}

.auth-visual-content {
    position: relative;
    z-index: 1;
    max-width: 400px;
}

.auth-brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 500;
    letter-spacing: -0.01em;
}

/* Sur le panneau d'encre, l'anneau de la marque s'éclaircit pour rester
   lisible ; le quartier plein reprend l'accent or par défaut. */
.auth-brand .brand-mark-ring {
    stroke: rgba(245, 241, 230, 0.85);
}

.auth-brand .brand-mark-slice {
    fill: var(--accent);
}

.auth-tagline {
    margin: var(--space-4) 0 var(--space-7);
    font-size: var(--text-lg);
    line-height: 1.45;
    color: var(--hero-ink-muted);
    text-wrap: balance;
}

.auth-features {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.auth-features li {
    display: flex;
    align-items: baseline;
    gap: var(--space-3);
    font-size: var(--text-base);
    color: rgba(245, 241, 230, 0.9);
}

.auth-feature-mark {
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    font-weight: 500;
    color: var(--hero-ink);
    border: 1px solid rgba(245, 241, 230, 0.3);
    border-radius: var(--radius-sm);
    padding: 0.1rem 0.4rem;
}

/* Panneau droit : formulaire */
.auth-form-panel {
    flex: 1 1 56%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-8) var(--space-5);
    background: var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 380px;
}

.auth-card h1 {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin: 0 0 var(--space-2);
}

.auth-subtitle {
    color: var(--ink-muted);
    font-size: var(--text-base);
    margin: 0 0 var(--space-5);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.auth-form button {
    margin-top: var(--space-2);
    width: 100%;
}

.auth-footnote {
    margin: var(--space-6) 0 0;
    font-size: var(--text-xs);
    color: var(--ink-muted);
    text-align: center;
}

/* ===========================================================
   18. Mise en page /compte : deux colonnes desktop
   =========================================================== */

.compte-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 340px);
    gap: var(--space-6);
    align-items: start;
}

.compte-main {
    min-width: 0;
}

.compte-stats {
    min-width: 0;
    position: sticky;
    top: var(--space-5);
}

/* ===========================================================
   19. Mouvement — une app vivante, sans excès
   Une seule séquence d'entrée orchestrée par page (pas un effet par
   composant), et une révélation au scroll pour les listes longues.
   prefers-reduced-motion (section 23) neutralise tout ceci d'un coup.
   =========================================================== */

@keyframes budgy-fade-up {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.reste-banner,
.page-header,
.compte-layout > *,
form.filter-form,
form.entry-form,
.card,
.auth-card {
    animation: budgy-fade-up var(--dur-entrance) var(--ease-entrance) both;
}

.page-header             { animation-delay: 0ms; }
.reste-banner             { animation-delay: 40ms; }
form.filter-form          { animation-delay: 60ms; }
form.entry-form           { animation-delay: 90ms; }
.card                     { animation-delay: 140ms; }
.compte-layout > * + *    { animation-delay: 180ms; }
.auth-card                { animation-delay: 80ms; }

/* Lignes et éléments répétés : une révélation liée au scroll plutôt qu'à
   un minuteur, pour que les listes longues (dépenses, prélèvements,
   projets) restent vivantes au défilement plutôt que figées d'un bloc. */
table.ledger tbody tr,
.stats-item,
ul.simple-list li {
    opacity: 1;
    transform: none;
}

@supports (animation-timeline: view()) {
    table.ledger tbody tr,
    .stats-item,
    ul.simple-list li {
        animation: budgy-reveal-row linear both;
        animation-timeline: view();
        animation-range: entry 0% cover 25%;
    }

    @keyframes budgy-reveal-row {
        from { opacity: 0; transform: translateY(12px); }
        to   { opacity: 1; transform: translateY(0); }
    }
}

/* ===========================================================
   19b. Composants analytiques
   Barre de progression (projets), frise du mois (prélèvements),
   grille de badges (catégories) — tous animés à l'entrée, tous
   calculés depuis les vraies données, jamais de valeur inventée.
   =========================================================== */

/* --- Barre de progression : épargne vs objectif -----------------
   Deux segments dont la largeur relative vient de flex-grow sur les
   valeurs brutes (épargné / reste à épargner) : pas de division, donc
   aucun risque d'erreur d'arrondi ou de division par zéro côté template. */
@keyframes budgy-grow-x {
    from { transform: scaleX(0); }
}

.progress-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--surface-hover);
    margin-top: var(--space-2);
}

.progress-fill {
    background: var(--accent);
    transform-origin: left;
    animation: budgy-grow-x 900ms var(--ease-entrance) both;
}

.progress-remaining {
    background: transparent;
}

.progress-caption {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-xs);
    color: var(--ink-muted);
    margin-top: var(--space-1);
}

/* --- Comparaison à deux barres : nécessaire vs capacité ---------- */
.compare-bars {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-top: var(--space-2);
}

.compare-bar-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    align-items: center;
    gap: var(--space-3);
}

.compare-bar-label {
    font-size: var(--text-sm);
    color: var(--ink-muted);
}

.compare-bar-track {
    height: 10px;
    border-radius: 4px;
    background: var(--surface-hover);
    overflow: hidden;
}

.compare-bar-fill {
    height: 100%;
    border-radius: 4px;
    transform-origin: left;
    animation: budgy-grow-x 900ms var(--ease-entrance) both;
}

.compare-bar-fill.is-required { background: var(--negative); }
.compare-bar-fill.is-capacity { background: var(--accent); }

/* --- Frise du mois : où tombent les prélèvements ----------------- */
.month-timeline {
    position: relative;
    height: 6px;
    background: var(--surface-hover);
    border-radius: 4px;
    margin: var(--space-4) 0 var(--space-6);
}

.month-timeline-marker {
    position: absolute;
    top: 50%;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--surface);
    transform: translate(-50%, -50%) scale(0);
    cursor: default;
    animation: budgy-pop-dot 360ms var(--ease-entrance) both;
    transition: transform .15s var(--ease);
}

.month-timeline-marker:hover,
.month-timeline-marker:focus-visible {
    transform: translate(-50%, -50%) scale(1.35);
}

@keyframes budgy-pop-dot {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.month-timeline-scale {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-2xs);
    color: var(--ink-muted);
    margin-top: calc(var(--space-6) * -1 + 2px);
}

/* --- Grille de badges (catégories) -------------------------------- */
.chip-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    min-height: var(--tap);
    background: var(--surface-sunken);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    font-size: var(--text-base);
    color: var(--ink);
    opacity: 0;
    animation: budgy-fade-up var(--dur-entrance) var(--ease-entrance) both;
    transition: border-color var(--dur-control) var(--ease),
                transform var(--dur-control) var(--ease),
                background-color var(--dur-control) var(--ease);
}

.chip:hover {
    border-color: var(--accent);
    background: var(--surface-hover);
    transform: translateY(-2px);
}

.chip:nth-child(1)  { animation-delay: 0ms; }
.chip:nth-child(2)  { animation-delay: 40ms; }
.chip:nth-child(3)  { animation-delay: 80ms; }
.chip:nth-child(4)  { animation-delay: 120ms; }
.chip:nth-child(5)  { animation-delay: 160ms; }
.chip:nth-child(6)  { animation-delay: 200ms; }
.chip:nth-child(7)  { animation-delay: 240ms; }
.chip:nth-child(8)  { animation-delay: 280ms; }
.chip:nth-child(9)  { animation-delay: 320ms; }
.chip:nth-child(n+10) { animation-delay: 360ms; }

/* --- Révélation des grands nombres : un léger dévoilement plutôt
   qu'un simple fondu, réservé aux valeurs qui portent le regard. ----- */
@keyframes budgy-value-reveal {
    from { clip-path: inset(0 100% 0 0); }
    to   { clip-path: inset(0 0 0 0); }
}

.reste-banner .reste-value,
.stat-card-value,
.account-line.balance .value {
    animation: budgy-value-reveal 640ms 100ms var(--ease-entrance) both;
}

/* ===========================================================
   20. Responsive : tablette (≤ 900px)
   =========================================================== */

@media (max-width: 900px) {
    .page {
        max-width: 100%;
    }

    /* La colonne latérale de 340px laisserait moins de 320px à la colonne
       principale : on empile dès la tablette. */
    .compte-layout {
        grid-template-columns: 1fr;
        gap: var(--space-5);
    }

    .compte-stats {
        position: static;
    }

    .auth-shell {
        flex-direction: column;
    }

    .auth-visual {
        flex: none;
        padding: var(--space-6) var(--space-5);
    }

    .auth-features {
        display: none;
    }

    .auth-form-panel {
        flex: none;
        padding: var(--space-7) var(--space-4);
    }
}

/* ===========================================================
   21. Responsive : mobile & tablette étroite (≤ 768px)
   =========================================================== */

@media (max-width: 768px) {

    /* Les cartes se resserrent : la zone de scroll des tableaux suit
       automatiquement (elle est calée sur --card-pad) */
    :root {
        --card-pad: var(--space-4);
    }

    /* Le rail devient une barre horizontale : plus de décalage du contenu */
    body:has(.app-rail) {
        padding-left: 0;
    }

    .app-rail {
        position: sticky;
        top: 0;
        inset: auto;
        width: auto;
        height: auto;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        border-right: none;
        border-bottom: 1px solid var(--line);
        padding: var(--space-2) var(--space-4);
    }

    .rail-brand {
        margin-bottom: 0;
    }

    .rail-toggle {
        display: flex;
    }

    /* Tiroir replié par défaut, déplié en plein écran au clic sur le
       hamburger ; libellés visibles (l'icône seule est trop ambiguë au
       toucher, sans l'infobulle native de la souris). */
    .rail-nav {
        display: none;
        position: fixed;
        inset: 57px 0 0 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        background: var(--surface);
        padding: var(--space-3) var(--space-4);
        overflow-y: auto;
        z-index: 39;
    }

    .rail-nav.is-open {
        display: flex;
    }

    .rail-link {
        flex-direction: row;
        justify-content: flex-start;
        width: 100%;
        height: auto;
        min-height: var(--tap);
        padding: var(--space-3) var(--space-2);
        gap: var(--space-3);
        border-bottom: 1px solid var(--line);
        border-left: 2px solid transparent;
        border-radius: 0;
    }

    /* En tiroir, le fond n'a plus assez de contraste seul : un filet
       vertical marque en plus la page courante. */
    .rail-link.is-active {
        border-left-color: var(--accent);
        padding-left: calc(var(--space-2) + 2px);
    }

    .rail-label {
        position: static;
        width: auto;
        height: auto;
        margin: 0;
        padding: 0;
        overflow: visible;
        clip-path: none;
        white-space: normal;
        border: 0;
        font-size: var(--text-base);
    }

    .rail-logout-form {
        margin-top: auto;
        width: 100%;
    }

    .rail-logout-form .rail-link {
        justify-content: flex-start;
        border-bottom: none;
    }

    .page {
        padding: var(--space-5) var(--space-4) var(--space-7);
    }

    .page h1 {
        font-size: var(--text-xl);
    }

    .page-header {
        align-items: stretch;
        flex-direction: column;
    }

    .section-title {
        font-size: var(--text-md);
    }

    .reste-banner {
        padding: var(--space-4);
    }

    .reste-banner .reste-value {
        font-size: var(--text-2xl);
    }

    .account-line {
        flex-wrap: wrap;
        gap: var(--space-1);
    }

    .account-line .value {
        font-size: var(--text-base);
    }

    .account-line.balance .value {
        font-size: var(--text-lg);
    }

    /* Formulaires : un champ par ligne, boutons pleine largeur */
    form.filter-form,
    form.entry-form {
        flex-direction: column;
        align-items: stretch;
    }

    form.filter-form label,
    form.entry-form label {
        width: 100%;
    }

    form.filter-form input,
    form.filter-form select,
    form.entry-form input,
    form.entry-form select {
        width: 100%;
        min-width: 0;
    }

    .btn,
    .btn-primary,
    .btn-secondary,
    form.entry-form button,
    form.filter-form button {
        width: 100%;
    }

    /* Tableau : cellules plus compactes, .table-scroll gère le débordement */
    table.ledger td,
    table.ledger th {
        padding: var(--space-3) var(--space-2);
        font-size: var(--text-sm);
    }

    .modal {
        width: calc(100% - (var(--space-4) * 2));
    }

    .modal .entry-form {
        padding: var(--space-4);
    }

    .modal-actions {
        flex-direction: column-reverse;
    }

    /* Camembert + légende empilée : 240px ne suffit plus une fois
       la colonne repliée sur toute la largeur */
    .chart-wrap {
        height: 280px;
    }

    .compare-bar-row {
        grid-template-columns: 1fr;
        gap: var(--space-1);
    }

    .stat-strip {
        gap: var(--space-2);
    }
}

/* ===========================================================
   22. Responsive : très petit écran (≤ 360px)
   =========================================================== */

@media (max-width: 360px) {
    /* On récupère de la largeur utile pour les tableaux */
    :root {
        --card-pad: var(--space-3);
    }

    .app-rail,
    .page {
        padding-left: var(--space-3);
        padding-right: var(--space-3);
    }

    .page h1 {
        font-size: var(--text-lg);
    }

    .reste-banner .reste-value {
        font-size: var(--text-xl);
    }
}

/* ===========================================================
   23. Préférences système
   =========================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@media print {
    .app-rail,
    .skip-link,
    .page-actions,
    form.filter-form,
    form.entry-form,
    .modal {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
    }

    .card {
        border-color: #999;
        box-shadow: none;
        break-inside: avoid;
    }
}

/* ===========================================================
   Note de migration :
   - fragments/head.html doit charger Fraunces + Work Sans (+ IBM Plex
     Mono, conservé pour les montants) à la place d'IBM Plex Sans/Mono
     seuls. Voir le message associé pour le <link> exact à coller.
   - Les deux <meta name="theme-color"> (clair/sombre) de head.html
     peuvent être réduits à un seul, sur #101915.
   - design-system/budgy/MASTER.md doit être régénéré pour refléter
     cette palette si le skill ui-ux-pro-max est réutilisé plus tard.
   =========================================================== */

/* ===========================================================
   24. Attribut hidden, pied du rail, page « Installer »
   =========================================================== */

/* Les classes de composants fixent un display (.btn-primary, .badge...) et
   l'emporteraient sinon sur l'attribut hidden : un élément masqué en HTML
   resterait visible. */
[hidden] {
    display: none !important;
}

/* Pied du rail (installer + déconnexion) : plaqué en bas du rail desktop et
   du tiroir mobile, car il vit dans le même conteneur que les liens. */
.rail-footer {
    margin-top: auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
}

.rail-footer .rail-logout-form {
    margin-top: 0;
}

/* Fenêtre « Installer Budgy » (bouton « ? » du rail) */
.modal-body {
    padding: var(--space-5);
}

.modal-body > .note {
    padding-top: 0;
}

.install-groups {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    margin: var(--space-4) 0 var(--space-5);
}

.install-group {
    padding-top: var(--space-4);
    border-top: 1px solid var(--line);
}

.install-group:first-child {
    padding-top: 0;
    border-top: none;
}

/* L'appareil de l'utilisateur passe en premier */
.install-group.is-current {
    order: -1;
}

.install-group.is-current:not(:first-child) {
    padding-top: 0;
    border-top: none;
}

.install-group h3 {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0 0 var(--space-3);
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--ink);
}

ol.steps {
    list-style: none;
    counter-reset: step;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

ol.steps li {
    counter-increment: step;
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    font-size: var(--text-base);
    color: var(--ink);
}

ol.steps li::before {
    content: counter(step);
    flex: none;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--accent);
}

ol.steps .steps-text {
    padding-top: 2px;
}

/* Les icônes citées dans le texte reprennent celles de l'interface du
   téléphone : alignées sur la ligne, jamais seules porteuses du sens. */
ol.steps .icon {
    vertical-align: -0.25em;
    margin: 0 2px;
    color: var(--accent);
}

@media (max-width: 768px) {
    .modal-body {
        padding: var(--space-4);
    }

    .rail-footer {
        align-items: stretch;
    }
}


/* ===========================================================
   25. Vidéo de bienvenue (première connexion)
   =========================================================== */

.modal-video {
    width: min(920px, calc(100vw - 32px));
    max-width: none;
}

.tuto-video {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    margin: var(--space-4) 0;
    background: #000;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
}

.tuto-resume {
    margin: 0 0 var(--space-4);
    color: var(--ink-muted);
    font-size: var(--text-sm);
}

.tuto-resume summary {
    cursor: pointer;
    color: var(--ink);
}

.tuto-resume ol {
    margin: var(--space-2) 0 0;
    padding-left: 1.25rem;
}