/* Cap Budget 1.6 — feuille de style unique, habillage CAP Ecosystem (référence Emergent, directive CAP-UI-DESIGN-001).
   Organisation : polices → couches (reset, tokens, base, layout, components, pages, utilities).
   Les couleurs, tailles, rayons et espacements passent uniquement par les variables de « tokens ».
   Polices : Space Grotesk (titres et montants clés), Plus Jakarta Sans (texte), JetBrains Mono (micro-libellés, données).
   Identité Budget : vert #059669 ; accent de l’écosystème : indigo #4F46E5.
   Point de rupture mobile : 760px (constante MOBILE_BREAKPOINT dans app.js). */

@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('fonts/plus-jakarta-sans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('fonts/plus-jakarta-sans-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('fonts/space-grotesk-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('fonts/space-grotesk-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url('fonts/jetbrains-mono-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url('fonts/jetbrains-mono-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@layer reset, tokens, base, layout, components, pages, utilities;

/* ───────────── reset ───────────── */
@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  body,
  h1,
  h2,
  h3,
  p,
  figure,
  fieldset {
    margin: 0;
  }
  button,
  input,
  select,
  textarea {
    font: inherit;
    color: inherit;
  }
  button {
    border: 0;
    background: none;
    padding: 0;
    cursor: pointer;
  }
  button,
  a,
  input,
  select,
  textarea,
  label {
    -webkit-tap-highlight-color: transparent;
  }
  img,
  svg {
    display: block;
    max-width: 100%;
  }
  .icon {
    display: inline-block;
  }
  [hidden] {
    display: none !important;
  }
}

/* ───────────── tokens ───────────── */
@layer tokens {
  :root {
    color-scheme: light;
    --font: 'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-heading: 'Space Grotesk', 'Plus Jakarta Sans', ui-sans-serif, system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);

    /* Encre : cartes « flux » sombres (héros, barre de sélection, notifications), identiques dans les deux thèmes */
    --ink: #0b1020;
    --ink-2: #1a2235;
    --ink-3: #141b2c;
    --ink-line: rgba(148, 163, 184, 0.16);
    --ink-text: #f8fafc;
    --ink-soft: #cbd5e1;
    --ink-muted: #94a3b8;
    --ink-gradient: radial-gradient(120% 90% at 100% 0%, rgba(99, 102, 241, 0.3), transparent 55%),
      radial-gradient(90% 80% at 0% 100%, rgba(16, 185, 129, 0.2), transparent 60%),
      linear-gradient(160deg, #121a36, #0a0f1e);

    /* Barre latérale vitrée */
    --nav-text: #556074;
    --nav-label: #626c7f;
    --glass: color-mix(in oklab, var(--surface) 78%, transparent);

    /* Surfaces et texte */
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --surface-3: #eef0f6;
    --line: #e3e7ef;
    --line-soft: #edf0f5;
    --field-line: #dce1ea;
    --text: #0f172a;
    --muted: #556074;
    --faint: #626c7f;

    /* Marque Budget (vert) et accent de l’écosystème (indigo) */
    --brand: #047857;
    --brand-strong: #065f46;
    --fill: #059669;
    --button: #047857;
    --button-hover: #065f46;
    --soft: #ecfdf5;
    --soft-line: #a7f3d0;
    --pill-active: #d1fae5;
    --mint: #34d399;
    --positive: #047857;
    --accent: #4f46e5;
    --accent-soft: #eef2ff;
    --glyph: linear-gradient(145deg, #059669, color-mix(in oklab, #059669 70%, black));

    /* Signaux */
    --warn: #b45309;
    --warn-strong: #b45309;
    --warn-soft: #fff7e6;
    --warn-bar: #f59e0b;
    --danger: #c81e1e;
    --danger-soft: #fef2f2;
    --low: #f59e0b;

    /* Flux du héros (sur encre) */
    --seg-actual: #94a3b8;
    --seg-planned: #64748b;
    --seg-transfer: #475569;
    --seg-opening: #f87171;

    /* Lignes de tableau */
    --stripe: #fafbfd;
    --row-hover: #f0f9f5;
    --row-selected: #e3f6ee;

    /* Ambiance : quadrillage de 32 px et halos */
    --grid-line: rgba(15, 23, 42, 0.045);
    --halo-1: rgba(99, 102, 241, 0.16);
    --halo-2: rgba(16, 185, 129, 0.12);
    --halo-3: rgba(56, 189, 248, 0.1);

    /* Ombres */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 1px 0 rgba(15, 23, 42, 0.02), 0 12px 32px -18px rgba(15, 23, 42, 0.14);
    --shadow-lift: 0 2px 4px rgba(15, 23, 42, 0.04), 0 24px 44px -22px rgba(15, 23, 42, 0.28);
    --shadow-lg: 0 30px 80px -20px rgba(2, 6, 23, 0.38);
    --glow: 0 8px 22px -10px rgba(5, 150, 105, 0.7);
    --focus: #6366f1;
    --focus-ring: 0 0 0 4px rgba(99, 102, 241, 0.16);

    /* Rayons */
    --r-sm: 10px;
    --r: 12px;
    --r-lg: 16px;
    --r-xl: 18px;
    --r-2xl: 22px;
    --r-pill: 999px;

    /* Espacements */
    --s1: 4px;
    --s2: 8px;
    --s3: 12px;
    --s4: 16px;
    --s5: 20px;
    --s6: 24px;
    --s8: 32px;

    /* Échelle typographique (6 tailles + affichage) */
    --fs-micro: 0.68rem; /* micro-libellés monospace en capitales */
    --fs-xs: 0.75rem; /* 12px — plancher */
    --fs-sm: 0.8125rem; /* 13px */
    --fs-base: 0.875rem; /* 14px */
    --fs-md: 1rem; /* 16px */
    --fs-lg: 1.25rem; /* 20px */
    --fs-xl: 1.625rem; /* 26px */
    --fs-hero: 3.25rem; /* 52px */

    --sidebar-w: 256px;
    --topbar-h: 64px;
    --nav-h: 66px;
    --safe-b: env(safe-area-inset-bottom, 0px);
  }

  :root[data-theme='dark'] {
    color-scheme: dark;
    --ink: #0b1020;
    --ink-2: #1a2235;
    --ink-3: #141b2c;
    --nav-text: #94a3b8;
    --nav-label: #7d8aa0;
    --bg: #080b13;
    --surface: #0f1420;
    --surface-2: #161d2c;
    --surface-3: #1a2233;
    --line: #222a3a;
    --line-soft: #1a2130;
    --field-line: #2a3346;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --faint: #7d8aa0;
    --brand: #34d399;
    --brand-strong: #6ee7b7;
    --fill: #34d399;
    --button: #047857;
    --button-hover: #04815d; /* Blanc : contraste 4,88:1, y compris au survol. */
    --soft: #0e2a22;
    --soft-line: #1f5a47;
    --pill-active: #123628;
    --positive: #34d399;
    --accent: #818cf8;
    --accent-soft: #1e1b4b;
    --warn: #fbbf24;
    --warn-strong: #fbbf24;
    --warn-soft: #2a2112;
    --warn-bar: #f59e0b;
    --danger: #f87171;
    --danger-soft: #2c1519;
    --low: #fbbf24;
    --stripe: #0c111c;
    --row-hover: #131c2a;
    --row-selected: #12291f;
    --grid-line: rgba(148, 163, 184, 0.06);
    --halo-1: rgba(99, 102, 241, 0.13);
    --halo-2: rgba(16, 185, 129, 0.08);
    --halo-3: rgba(56, 189, 248, 0.06);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 20px 40px -24px rgba(0, 0, 0, 0.6);
    --shadow-lift: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 26px 48px -24px rgba(0, 0, 0, 0.75);
    --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, 0.7);
    --glow: 0 8px 24px -10px rgba(16, 185, 129, 0.55);
    --focus: #818cf8;
    --focus-ring: 0 0 0 4px rgba(129, 140, 248, 0.2);
  }

  /* Avant que le script n’ait choisi le thème : suivre le système. */
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
      color-scheme: dark;
      --bg: #080b13;
      --surface: #0f1420;
      --surface-2: #161d2c;
      --line: #222a3a;
      --text: #f1f5f9;
      --muted: #94a3b8;
      --grid-line: rgba(148, 163, 184, 0.06);
    }
  }
}

/* ───────────── base ───────────── */
@layer base {
  html {
    background: var(--bg);
  }
  body {
    position: relative;
    font-family: var(--font);
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--text);
    background: transparent;
    font-synthesis: none;
    font-feature-settings: 'ss01', 'cv11';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
  /* Ambiance CAP : quadrillage estompé vers le bas et halos lents, derrière tout le contenu. */
  body::before,
  body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
  }
  body::before {
    background-image: linear-gradient(var(--grid-line) 1px, transparent 1px),
      linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 32px 32px;
    -webkit-mask-image: radial-gradient(ellipse at top, #000 20%, transparent 70%);
    mask-image: radial-gradient(ellipse at top, #000 20%, transparent 70%);
  }
  body::after {
    inset: -20% -10%;
    background: radial-gradient(closest-side, var(--halo-1), transparent) 88% 2% / 640px 640px no-repeat,
      radial-gradient(closest-side, var(--halo-3), transparent) 0% 48% / 560px 560px no-repeat,
      radial-gradient(closest-side, var(--halo-2), transparent) 60% 96% / 520px 520px no-repeat;
    animation: drift 28s ease-in-out infinite alternate;
  }
  h1,
  h2,
  h3 {
    font-family: var(--font-heading);
  }
  h1 {
    font-size: var(--fs-xl);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.1;
  }
  h2 {
    font-size: var(--fs-md);
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1.3;
  }
  h3 {
    font-size: var(--fs-base);
    font-weight: 600;
  }
  a {
    color: var(--brand);
    text-decoration: none;
  }
  a:hover {
    text-decoration: underline;
  }
  b,
  strong {
    font-weight: 700;
  }
  /* Taille par défaut : en couche de base pour que les composants puissent la préciser. */
  small {
    font-size: var(--fs-sm);
  }
  :focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
  }
  input:focus-visible,
  select:focus-visible,
  textarea:focus-visible {
    outline: 0;
    border-color: var(--focus);
    box-shadow: var(--focus-ring);
  }
  button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
  }
  input,
  select,
  textarea {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 10px 12px;
    font-size: var(--fs-base);
    border: 1px solid var(--field-line);
    border-radius: var(--r);
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
  }
  input:hover,
  select:hover,
  textarea:hover {
    border-color: color-mix(in oklab, var(--field-line) 60%, var(--muted));
  }
  select {
    appearance: none;
    padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23556074' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
  }
  :root[data-theme='dark'] select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  }
  textarea {
    resize: vertical;
    min-height: 80px;
  }
  input[type='checkbox'],
  input[type='radio'] {
    width: 18px;
    height: 18px;
    min-height: 0;
    padding: 0;
    accent-color: var(--fill);
    flex-shrink: 0;
  }
  input[type='color'] {
    padding: 4px;
    height: 44px;
  }
  input[type='search']::-webkit-search-cancel-button {
    cursor: pointer;
  }
  fieldset {
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: var(--s4);
    min-width: 0;
  }
  legend {
    font-family: var(--font-heading);
    font-weight: 600;
    padding: 0 var(--s1);
  }
  kbd {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 1px 6px;
    background: var(--surface-2);
  }
  code {
    font-family: var(--font-mono);
  }
  ::selection {
    background: color-mix(in oklab, var(--accent) 25%, transparent);
  }
}

/* ───────────── layout ───────────── */
@layer layout {
  .shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: 100dvh;
  }

  /* Barre latérale vitrée */
  .sidebar {
    position: sticky;
    top: 0;
    height: 100dvh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
    display: flex;
    flex-direction: column;
    gap: var(--s1);
    padding: 18px 14px 16px;
    background: var(--glass);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    backdrop-filter: blur(18px) saturate(1.4);
    border-right: 1px solid var(--line);
    color: var(--nav-text);
    z-index: 20;
  }
  .logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 6px 20px;
    color: var(--text);
  }
  .app-glyph {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    flex-shrink: 0;
    background: var(--glyph);
    color: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 6px 16px -8px #059669;
    transition: transform 0.3s var(--ease);
  }
  .app-glyph .icon {
    width: 20px;
    height: 20px;
    stroke-width: 2;
  }
  .logo:hover .app-glyph {
    transform: scale(1.05) rotate(-3deg);
  }
  .logo-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.2;
  }
  .logo-text small {
    font-family: var(--font-mono);
    font-size: 0.625rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--faint);
  }
  .logo-text b {
    font-family: var(--font-heading);
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -0.02em;
  }
  .nav-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 10px;
  }
  .nav-label {
    font-family: var(--font-mono);
    font-size: 0.625rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--nav-label);
    padding: 8px 12px 6px;
  }
  .nav button {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: var(--r);
    text-align: left;
    font-size: var(--fs-base);
    font-weight: 500;
    color: var(--nav-text);
    transition: background-color 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
  }
  .nav button > span:first-of-type {
    flex: 1;
  }
  .nav button:hover {
    background: var(--surface-2);
    color: var(--text);
  }
  .nav button:hover .icon {
    transform: translateX(1px);
  }
  .nav button.active {
    background: var(--surface);
    border-color: var(--line);
    color: var(--text);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
  }
  .nav button.active::before {
    content: '';
    position: absolute;
    left: -15px;
    top: 50%;
    width: 4px;
    height: 22px;
    margin-top: -11px;
    border-radius: 0 4px 4px 0;
    background: var(--fill);
    animation: indicator-in 0.35s var(--ease);
  }
  .nav button.active .icon {
    color: var(--brand);
  }
  .nav .icon {
    width: 18px;
    height: 18px;
    transition: transform 0.2s var(--ease);
  }
  .nav-badge {
    min-width: 20px;
    padding: 1px 7px;
    border: 1px solid color-mix(in oklab, var(--warn-bar) 35%, transparent);
    border-radius: var(--r-pill);
    background: color-mix(in oklab, var(--warn-bar) 14%, var(--surface));
    color: var(--warn);
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 700;
    text-align: center;
  }
  .sidebar-bottom {
    margin-top: auto;
    border-top: 1px solid var(--line);
    padding-top: var(--s3);
    display: flex;
    flex-direction: column;
    gap: var(--s2);
  }
  .profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0 0 6px;
  }
  .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #334155, #0f172a);
    color: #fff;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: var(--fs-base);
    flex-shrink: 0;
  }
  .profile-name {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.3;
  }
  .profile-name b {
    color: var(--text);
    font-size: var(--fs-base);
    font-weight: 600;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .profile-name small {
    color: var(--faint);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.02em;
  }
  .sidebar .icon-button {
    color: var(--nav-text);
  }
  .sidebar .icon-button:hover {
    background: var(--surface-2);
    color: var(--text);
  }

  /* Espace de travail */
  .workspace {
    min-width: 0;
    display: flex;
    flex-direction: column;
  }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 15;
    min-height: var(--topbar-h);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s3) var(--s4);
    padding: 12px 32px;
    background: var(--glass);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    backdrop-filter: blur(18px) saturate(1.4);
    border-bottom: 1px solid var(--line);
  }
  .context {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s2) var(--s4);
    min-width: 0;
  }
  .topbar-title {
    font-family: var(--font-heading);
    font-size: var(--fs-md);
    font-weight: 600;
  }
  .top-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--s2);
  }
  .top-actions .icon-button {
    min-width: 38px;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
  }
  .top-actions .icon-button .icon {
    width: 17px;
    height: 17px;
  }
  .content {
    width: 100%;
    max-width: 1320px;
    padding: 32px 32px 48px;
  }
  .bottom-nav,
  .fab {
    display: none;
  }

  @media (max-width: 1100px) {
    :root {
      --sidebar-w: 228px;
    }
    .content {
      padding: 26px 24px 40px;
    }
    .topbar {
      padding: 10px 20px;
    }
  }

  @media (max-width: 760px) {
    .shell {
      display: block;
    }
    .sidebar {
      display: none;
    }
    .topbar {
      min-height: 0;
      padding: 6px 8px 6px 4px;
      gap: 0 var(--s2);
      border-bottom-color: transparent;
    }
    .topbar.no-context {
      display: none;
    }
    .topbar.no-context + .content {
      padding-top: 20px;
    }
    .topbar.scrolled {
      border-bottom-color: var(--line);
    }
    .context {
      width: 100%;
      justify-content: space-between;
      gap: 0 var(--s2);
    }
    .top-actions {
      display: none;
    }
    .content {
      padding: 8px max(16px, env(safe-area-inset-left)) calc(116px + var(--safe-b))
        max(16px, env(safe-area-inset-right));
    }

    /* Capsule de navigation flottante, vitrée */
    .bottom-nav {
      display: grid;
      grid-template-columns: repeat(5, minmax(0, 1fr));
      gap: 2px;
      position: fixed;
      left: max(12px, env(safe-area-inset-left));
      right: max(12px, env(safe-area-inset-right));
      bottom: calc(12px + var(--safe-b));
      z-index: 25;
      padding: 6px;
      border: 1px solid var(--line);
      border-radius: var(--r-2xl);
      background: var(--glass);
      -webkit-backdrop-filter: blur(18px) saturate(1.4);
      backdrop-filter: blur(18px) saturate(1.4);
      box-shadow: 0 24px 48px -16px rgba(15, 23, 42, 0.22);
    }
    .bottom-nav button {
      position: relative;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 2px;
      min-height: 52px;
      border-radius: var(--r-lg);
      font-size: 0.6875rem;
      font-weight: 600;
      color: var(--muted);
      transition: color 0.2s, background-color 0.25s var(--ease);
    }
    .bottom-nav .nav-pill {
      display: grid;
      place-items: center;
      transition: transform 0.25s var(--ease);
    }
    .bottom-nav .icon {
      width: 21px;
      height: 21px;
    }
    .bottom-nav button.active {
      color: var(--text);
      background: var(--surface-2);
    }
    .bottom-nav button.active .icon {
      stroke-width: 2.2;
      color: var(--brand);
    }
    .bottom-nav button:active .nav-pill {
      transform: scale(0.9);
    }
    body:has(dialog[open]) .bottom-nav,
    body:has(dialog[open]) .fab {
      visibility: hidden;
    }

    .fab {
      display: grid;
      place-items: center;
      position: fixed;
      right: max(16px, env(safe-area-inset-right));
      bottom: calc(12px + var(--nav-h) + var(--safe-b) + 14px);
      z-index: 24;
      width: 56px;
      height: 56px;
      border-radius: 18px;
      background: var(--glyph);
      color: #fff;
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 14px 28px -12px rgba(5, 150, 105, 0.8);
      transition: transform 0.2s var(--ease);
    }
    .fab:active {
      transform: scale(0.94);
    }
    .fab .icon {
      width: 26px;
      height: 26px;
      stroke-width: 2;
    }
    body:has(.selection-bar.active) .fab {
      display: none;
    }
  }
}

/* ───────────── components ───────────── */
@layer components {
  .icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    vertical-align: middle;
  }

  /* Micro-libellé et sur-titre (« —— CAP BUDGET · OPÉRATIONS ») */
  .eyebrow {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .eyebrow::before {
    content: '';
    width: 24px;
    height: 1px;
    background: var(--fill);
  }
  .eyebrow.with-dot::before {
    display: none;
  }
  .pulse-dot {
    position: relative;
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--fill);
    flex-shrink: 0;
  }
  .pulse-dot::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: inherit;
    animation: pulse-ring 2.2s var(--ease) infinite;
  }

  /* Boutons */
  .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: var(--r-pill);
    background: var(--button);
    color: #fff;
    font-size: var(--fs-base);
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    text-decoration: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), var(--glow);
    transition: background-color 0.2s, box-shadow 0.2s, transform 0.2s var(--ease), border-color 0.2s, color 0.2s;
  }
  .button:hover {
    background: var(--button-hover);
    text-decoration: none;
    transform: translateY(-1px);
  }
  .button:active {
    transform: scale(0.98);
  }
  .button .icon {
    width: 18px;
    height: 18px;
    transition: transform 0.2s var(--ease);
  }
  .button:hover .icon:last-child:not(:first-child) {
    transform: translateX(2px);
  }
  .button.secondary {
    background: var(--surface);
    border-color: var(--line);
    color: var(--text);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
  }
  .button.secondary:hover {
    background: var(--surface-2);
    border-color: var(--field-line);
  }
  .button.secondary.active {
    border-color: var(--fill);
    color: var(--brand);
    background: var(--soft);
  }
  .button.subtle {
    background: transparent;
    color: var(--brand);
    padding: 0 10px;
    min-height: 40px;
    box-shadow: none;
  }
  .button.subtle:hover {
    background: var(--soft);
    transform: none;
  }
  .button.danger {
    background: #dc2626;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 8px 22px -12px rgba(220, 38, 38, 0.7);
  }
  .button.danger:hover {
    background: #b91c1c;
  }
  .button.small {
    min-height: 36px;
    padding: 0 14px;
    font-size: var(--fs-sm);
  }
  .button.block {
    width: 100%;
  }
  .icon-button {
    display: inline-grid;
    place-items: center;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    color: var(--muted);
    flex-shrink: 0;
    transition: background-color 0.2s, color 0.2s, transform 0.2s var(--ease), border-color 0.2s;
  }
  .icon-button:hover {
    background: var(--surface-2);
    color: var(--text);
  }
  .icon-button:active {
    transform: scale(0.94);
  }
  .check-button {
    display: inline-grid;
    place-items: center;
    min-width: 44px;
    min-height: 44px;
    color: var(--muted);
  }
  .check-button.checked {
    color: var(--brand);
  }
  .actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
  }

  /* Contrôle de période et compte suivi */
  .period-nav {
    display: inline-flex;
    align-items: stretch;
    padding: 2px;
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }
  .period-nav .icon-button {
    min-width: 34px;
    min-height: 34px;
    border-radius: 50%;
    color: var(--muted);
  }
  .period-nav .icon-button .icon {
    width: 16px;
    height: 16px;
  }
  .period-button {
    min-height: 34px;
    padding: 0 12px;
    border-radius: var(--r-pill);
    font-family: var(--font-heading);
    font-size: var(--fs-base);
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
    transition: background-color 0.2s;
  }
  .period-button:first-letter {
    text-transform: uppercase;
  }
  .period-button:hover,
  .period-nav .icon-button:hover {
    background: var(--surface-2);
    color: var(--text);
  }
  .period-range {
    font-family: var(--font-mono);
    font-size: 0.71875rem;
    font-weight: 500;
    color: var(--muted);
    white-space: nowrap;
  }
  .account-chip {
    position: relative;
    display: inline-flex;
  }
  .account-chip select {
    min-height: 38px;
    width: auto;
    max-width: 260px;
    border-color: var(--line);
    border-radius: var(--r-pill);
    padding: 0 34px 0 14px;
    font-weight: 600;
    background-color: var(--surface);
    box-shadow: var(--shadow-sm);
    text-overflow: ellipsis;
  }
  .top-search {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    width: 260px;
    max-width: 100%;
    padding: 0 6px 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--muted);
    font-size: var(--fs-sm);
    text-align: left;
    transition: color 0.2s, border-color 0.2s;
  }
  .top-search:hover {
    color: var(--text);
    border-color: var(--field-line);
  }
  .top-search span {
    flex: 1;
  }
  @media (max-width: 1600px) {
    .top-search {
      width: auto;
    }
    .top-search span {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip-path: inset(50%);
    }
  }
  .top-search .icon {
    width: 16px;
    height: 16px;
  }
  .top-actions .button {
    min-height: 38px;
  }

  /* Calendrier des périodes */
  .period-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--s2);
  }
  .period-grid button {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-height: 60px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    text-align: left;
    transition: background-color 0.2s, border-color 0.2s, transform 0.2s var(--ease);
  }
  .period-grid button b {
    font-family: var(--font-heading);
    font-size: var(--fs-base);
    font-weight: 600;
  }
  .period-grid button b:first-letter {
    text-transform: uppercase;
  }
  .period-grid button small {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    color: var(--muted);
  }
  .period-grid button:hover {
    background: var(--surface-2);
    transform: translateY(-1px);
  }
  .period-grid button.active {
    border-color: var(--fill);
    background: var(--soft);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--fill) 14%, transparent);
  }
  .period-grid button.today b::after {
    content: ' •';
    color: var(--fill);
  }
  .period-grid button.special {
    border-style: dashed;
  }
  .period-special {
    color: var(--fill);
  }
  /* Mois à durée particulière (Préférences de suivi) */
  .exceptions-block h4 {
    margin: var(--s4) 0 var(--s2);
    font-size: var(--fs-sm, 0.875rem);
    color: var(--muted);
    font-weight: 600;
  }
  .exception-list {
    display: grid;
    gap: var(--s2);
    margin: 0;
    padding: 0;
    list-style: none;
  }
  .exception-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s2) var(--s3);
    padding: var(--s2) var(--s3);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    animation: exception-in 0.25s var(--ease);
  }
  .exception-row b {
    min-width: 7.5rem;
    font-family: var(--font-heading);
    font-weight: 600;
  }
  .exception-row b:first-letter {
    text-transform: uppercase;
  }
  .exception-text {
    color: var(--muted);
  }
  .exception-day input {
    width: 5.25rem;
    flex-shrink: 0;
  }
  .exception-remove {
    margin-left: auto;
  }
  .exception-add {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 0.8fr) auto;
    align-items: end;
    gap: var(--s3);
    margin-top: var(--s4);
  }
  .exception-add .field + .field {
    margin: 0;
  }
  .exception-status:empty {
    display: none;
  }
  .exception-status {
    margin: var(--s2) 0 0;
    font-size: var(--fs-sm, 0.875rem);
    color: var(--brand-strong);
  }
  .exception-status.form-error {
    color: var(--danger, #c0392b);
  }
  .exception-history {
    margin-top: var(--s3);
    font-size: var(--fs-sm, 0.875rem);
  }
  .exception-history summary {
    cursor: pointer;
    color: var(--muted);
  }
  .exception-history ul {
    margin: var(--s2) 0;
    padding-left: 1.2em;
  }
  #cycle-example .cycle-line {
    display: block;
  }
  #cycle-example .cycle-line + .cycle-line {
    margin-top: var(--s1, 4px);
  }
  @keyframes exception-in {
    from {
      opacity: 0;
      transform: translateY(-4px);
    }
  }
  @media (max-width: 640px) {
    .exception-add {
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }
    .exception-row b {
      min-width: 0;
      flex-basis: 100%;
    }
  }
  @media (prefers-reduced-motion: reduce) {
    .exception-row {
      animation: none;
    }
  }
  .year-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--s3);
    font-family: var(--font-heading);
    font-size: var(--fs-md);
    font-weight: 600;
  }

  /* En-tête de page */
  .page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--s3) var(--s4);
    margin-bottom: var(--s6);
  }
  .page-heading > div:first-child {
    min-width: 0;
  }
  .page-heading h1 {
    font-size: clamp(1.75rem, 2.6vw, 2.5rem);
    letter-spacing: -0.035em;
  }
  .page-heading p {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.9375rem;
  }
  .page-heading .actions {
    gap: var(--s2);
  }

  /* Cartes et panneaux */
  .panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow);
    min-width: 0;
    overflow: hidden;
  }
  .panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s3);
    flex-wrap: wrap;
    padding: 20px 20px 0;
  }
  .panel-head > div:first-child,
  .panel-head > h2:first-child {
    flex: 1 1 220px;
    min-width: 0;
  }
  .panel-head h2 {
    font-size: 0.9688rem;
    letter-spacing: -0.01em;
  }
  .panel-head p {
    margin-top: 2px;
    font-size: var(--fs-xs);
    color: var(--muted);
  }
  .panel-head .actions {
    gap: var(--s1);
  }
  .panel-body {
    padding: 16px 20px 20px;
  }
  .panel-divider {
    border: 0;
    border-top: 1px solid var(--line);
    margin: var(--s5) 0;
  }
  .panel-link {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--brand);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 32px;
  }
  .panel-link .icon {
    width: 15px;
    height: 15px;
    transition: transform 0.2s var(--ease);
  }
  .panel-link:hover .icon {
    transform: translateX(3px);
  }

  /* Indicateurs (cartes KPI) */
  .kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--s4);
    margin-bottom: var(--s5);
  }
  .kpi-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .kpi {
    position: relative;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow);
    padding: 20px;
    min-width: 0;
    transition: transform 0.3s var(--ease), box-shadow 0.3s;
  }
  @media (hover: hover) and (pointer: fine) {
    .kpi:hover {
      transform: translateY(-3px);
      box-shadow: var(--shadow-lift);
    }
  }
  .kpi.primary {
    background: var(--ink-gradient);
    border-color: var(--ink-line);
    color: var(--ink-text);
  }
  .kpi-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--s2);
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .kpi-label .icon {
    width: 32px;
    height: 32px;
    padding: 7px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    color: var(--muted);
    transition: color 0.3s;
  }
  .kpi:hover .kpi-label .icon {
    color: var(--brand);
  }
  .kpi.primary .kpi-label {
    color: var(--ink-muted);
  }
  .kpi.primary .kpi-label .icon {
    border-color: var(--ink-line);
    background: rgba(255, 255, 255, 0.06);
    color: var(--mint);
  }
  .kpi-value {
    font-family: var(--font-heading);
    font-size: 1.875rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin: 12px 0 6px;
    overflow-wrap: anywhere;
  }
  .kpi-foot {
    font-size: var(--fs-xs);
    color: var(--muted);
  }
  .kpi.primary .kpi-foot,
  .kpi.primary .muted {
    color: var(--ink-soft);
  }

  /* Notes */
  .note-box {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid color-mix(in oklab, var(--fill) 26%, transparent);
    border-radius: var(--r-lg);
    background: var(--soft);
    color: var(--brand-strong);
    font-size: var(--fs-base);
    line-height: 1.45;
  }
  .note-box .icon {
    width: 18px;
    height: 18px;
    margin-top: 1px;
  }
  .note-box .button.subtle {
    min-height: 0;
    padding: 0 2px;
    display: inline;
    font-size: inherit;
    text-decoration: underline;
  }
  .note-box .button.subtle .icon {
    display: none;
  }
  .note-box.warning {
    border-color: color-mix(in oklab, var(--warn-bar) 32%, transparent);
    background: var(--warn-soft);
    color: var(--warn);
  }
  .note-box.danger {
    border-color: color-mix(in oklab, var(--danger) 28%, transparent);
    background: var(--danger-soft);
    color: var(--danger);
  }
  .badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border: 1px solid color-mix(in oklab, var(--fill) 30%, transparent);
    border-radius: var(--r-pill);
    background: color-mix(in oklab, var(--fill) 10%, var(--surface));
    color: var(--brand-strong);
    font-size: var(--fs-xs);
    font-weight: 600;
    line-height: 1.4;
  }
  .badge.warning {
    border-color: color-mix(in oklab, var(--warn-bar) 35%, transparent);
    background: var(--warn-soft);
    color: var(--warn);
  }
  .badge.danger {
    border-color: color-mix(in oklab, var(--danger) 30%, transparent);
    background: var(--danger-soft);
    color: var(--danger);
  }
  .category-tag {
    display: inline-block;
    padding: 2px 9px;
    border: 1px solid color-mix(in oklab, var(--fill) 28%, transparent);
    border-radius: var(--r-pill);
    font-size: var(--fs-xs);
    font-weight: 600;
    background: var(--soft);
    color: var(--brand-strong);
  }

  /* Lignes de synthèse */
  .summary-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--s4);
    padding: 12px 0;
    border-bottom: 1px solid var(--line-soft);
    font-size: var(--fs-base);
  }
  .summary-line:first-child {
    padding-top: 0;
  }
  .summary-line:last-child {
    border-bottom: 0;
  }
  .summary-line > span {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .summary-line .num {
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 0.8438rem;
    font-weight: 600;
  }
  .equation-total {
    border-top: 1px solid var(--line);
    margin-top: var(--s2);
    padding-top: 14px !important;
    color: var(--brand-strong);
    font-size: var(--fs-md);
  }
  .equation-total b {
    font-family: var(--font-heading);
    font-weight: 600;
  }
  .summary-line.equation-total .num {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    letter-spacing: -0.02em;
  }

  /* Jauges (budgets, objectifs) */
  .progress,
  .meter {
    display: block;
    position: relative;
    height: 6px;
    border-radius: var(--r-pill);
    background: var(--line-soft);
  }
  .progress > div,
  .meter > i {
    display: block;
    height: 100%;
    max-width: 100%;
    border-radius: var(--r-pill);
    background: var(--fill);
    transform-origin: left center;
  }
  .progress {
    overflow: hidden;
  }
  .progress.large,
  .meter.large {
    height: 10px;
  }
  .meter.warn > i {
    background: var(--warn-bar);
  }
  .meter.over > i {
    background: var(--danger);
  }
  .meter-tick {
    position: absolute;
    top: -4px;
    bottom: -4px;
    width: 2px;
    margin-left: -1px;
    border-radius: 1px;
    background: var(--text);
    opacity: 0.55;
  }
  .budget-row {
    margin-bottom: var(--s4);
  }
  .budget-row:last-child {
    margin-bottom: 0;
  }
  .budget-label {
    display: flex;
    justify-content: space-between;
    gap: var(--s3);
    font-size: var(--fs-base);
    margin-bottom: 7px;
  }
  .legend {
    display: flex;
    align-items: center;
    gap: var(--s3);
    font-size: var(--fs-xs);
    font-weight: 500;
    color: var(--muted);
  }
  .legend span {
    display: inline-flex;
    gap: 6px;
    align-items: center;
  }
  .legend i {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: var(--fill);
  }

  /* Tableaux génériques */
  .table-scroll {
    overflow-x: auto;
  }
  table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-base);
  }
  th {
    text-align: left;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 11px 16px;
    background: var(--surface-2);
    white-space: nowrap;
  }
  td {
    padding: 12px 16px;
    border-top: 1px solid var(--line-soft);
    vertical-align: middle;
  }
  tbody tr {
    transition: background-color 0.15s;
  }
  tbody tr:hover,
  tbody tr:focus-within {
    background: var(--row-hover);
  }
  .cell-title {
    display: flex;
    align-items: center;
    gap: 11px;
  }
  .row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 2px;
  }

  /* Recherche, filtres et puces */
  .search {
    position: relative;
    display: flex;
    align-items: center;
  }
  .search .icon {
    position: absolute;
    left: 14px;
    width: 17px;
    height: 17px;
    color: var(--muted);
    pointer-events: none;
  }
  .search input {
    padding-left: 40px;
    border-radius: var(--r-pill);
    background: var(--surface);
  }
  .segmented {
    display: flex;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    background: var(--surface-2);
  }
  .segmented button {
    flex: 1;
    min-height: 36px;
    padding: 0 14px;
    border-radius: var(--r-pill);
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--muted);
    white-space: nowrap;
    transition: background-color 0.25s var(--ease), color 0.2s, box-shadow 0.25s;
  }
  .segmented button:hover {
    color: var(--text);
  }
  .segmented button.active,
  .segmented button[aria-pressed='true'] {
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    box-shadow: var(--shadow-sm), 0 0 0 1px var(--line);
  }
  .filter-pill {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding-left: 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    background: var(--surface);
    font-size: var(--fs-sm);
    transition: border-color 0.2s, background-color 0.2s;
  }
  .filter-pill:hover {
    border-color: var(--field-line);
  }
  .filter-pill > span {
    color: var(--muted);
    font-weight: 500;
    white-space: nowrap;
  }
  .filter-pill select {
    border: 0;
    min-height: 38px;
    width: auto;
    max-width: 210px;
    padding: 0 30px 0 6px;
    font-size: var(--fs-sm);
    font-weight: 600;
    background-color: transparent;
    background-position: right 10px center;
    box-shadow: none;
  }
  .filter-pill.active {
    border-color: color-mix(in oklab, var(--fill) 40%, transparent);
    background: var(--soft);
  }
  .filter-pill.active select {
    color: var(--brand-strong);
  }
  .chip-row {
    display: flex;
    gap: var(--s2);
    overflow-x: auto;
    scrollbar-width: none;
    margin: 0 -16px;
    padding: 2px 16px;
  }
  .chip-row::-webkit-scrollbar {
    display: none;
  }
  .chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    background: var(--surface);
    font-size: var(--fs-sm);
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s, transform 0.2s var(--ease);
  }
  .chip:active {
    transform: scale(0.97);
  }
  .chip .icon {
    width: 14px;
    height: 14px;
  }
  .chip.active,
  .chip:has(input:checked) {
    background: var(--text);
    border-color: var(--text);
    color: var(--surface);
    font-weight: 600;
  }
  :root[data-theme='dark'] .chip.active,
  :root[data-theme='dark'] .chip:has(input:checked) {
    background: var(--text);
    border-color: var(--text);
    color: #0b1020;
  }
  .chip:has(input:focus-visible) {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
  }
  label.chip {
    cursor: pointer;
  }
  .count-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--button);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 700;
    display: grid;
    place-items: center;
  }

  /* Liste d’opérations (Accueil et Opérations) */
  .op-list {
    --op-cols: 44px minmax(0, 1fr) minmax(0, 11rem) minmax(0, 10rem) 8rem 8.5rem 48px;
  }
  .op-list.no-account {
    --op-cols: 44px minmax(0, 1fr) minmax(0, 12rem) 8rem 8.5rem 48px;
  }
  .op-list.compact {
    --op-cols: minmax(0, 1fr) auto;
  }
  .op-header,
  .op-row {
    display: grid;
    grid-template-columns: var(--op-cols);
    align-items: center;
  }
  .op-header {
    min-height: 40px;
    background: var(--surface-2);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }
  .op-header > *,
  .op-row > * {
    padding: 0 12px;
    min-width: 0;
  }
  .op-header > :first-child,
  .op-row > .op-check {
    padding: 0 0 0 16px;
  }
  .op-header .right,
  .op-row .op-amount {
    text-align: right;
  }
  .op-group-head {
    display: flex;
    justify-content: space-between;
    gap: var(--s3);
    min-height: 36px;
    align-items: center;
    padding: 0 60px 0 60px;
    border-top: 1px solid var(--line);
    background: color-mix(in oklab, var(--surface-2) 70%, var(--surface));
    font-family: var(--font-heading);
    font-size: var(--fs-sm);
    font-weight: 600;
  }
  .op-group-head:first-letter {
    text-transform: uppercase;
  }
  .op-group-head.future {
    background: var(--surface-3);
    color: var(--muted);
  }
  .op-group-head .num {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
  }
  .op-list.compact .op-group-head {
    padding: 0 16px;
  }
  .op-row {
    min-height: 54px;
    border-top: 1px solid var(--line-soft);
    background: var(--surface);
    transition: background-color 0.15s;
  }
  .op-row.striped {
    background: var(--stripe);
  }
  .op-row:focus-within {
    background: var(--row-hover);
  }
  @media (hover: hover) and (pointer: fine) {
    .op-row:hover {
      background: var(--row-hover);
    }
  }
  .op-row.selected {
    background: var(--row-selected);
  }
  .op-check label {
    display: grid;
    place-items: center start;
    min-height: 44px;
    cursor: pointer;
  }
  .op-main {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 54px;
    padding: 6px 12px;
    text-align: left;
    border-radius: 0;
  }
  .op-main:hover .op-label {
    text-decoration: underline;
    text-decoration-color: var(--faint);
    text-underline-offset: 3px;
  }
  .op-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
  }
  .op-label {
    font-size: var(--fs-base);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .op-meta.mob {
    display: none;
  }
  .op-list.compact .op-meta.mob {
    display: block;
  }
  .op-meta {
    font-size: var(--fs-xs);
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .cat-badge {
    --c: var(--muted);
    width: 36px;
    height: 36px;
    border-radius: var(--r-sm);
    display: grid;
    place-items: center;
    font-family: var(--font-heading);
    font-size: var(--fs-sm);
    font-weight: 600;
    background: color-mix(in srgb, var(--c) 14%, var(--surface));
    color: color-mix(in srgb, var(--c) 78%, var(--text));
  }
  .cat-badge .icon {
    width: 17px;
    height: 17px;
  }
  .op-category {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: var(--fs-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--c, var(--muted));
  }
  .op-account {
    font-size: var(--fs-sm);
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .op-amount {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
  }
  .op-amount.positive {
    color: var(--positive);
  }
  .op-edit {
    padding: 0 4px !important;
    text-align: right;
  }
  .op-side {
    display: contents;
  }
  .status-pill {
    --tone: var(--muted);
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 26px;
    padding: 0 10px;
    border-radius: var(--r-pill);
    border: 1px solid color-mix(in oklab, var(--tone) 30%, transparent);
    background: color-mix(in oklab, var(--tone) 10%, var(--surface));
    color: color-mix(in oklab, var(--tone) 82%, var(--text));
    font-size: var(--fs-xs);
    font-weight: 600;
    white-space: nowrap;
    position: relative;
    transition: filter 0.2s, transform 0.2s var(--ease);
  }
  .status-pill::after {
    content: '';
    position: absolute;
    inset: -8px -4px;
  }
  .status-pill .icon {
    width: 13px;
    height: 13px;
  }
  .status-pill.cleared {
    --tone: var(--fill);
    color: var(--brand);
  }
  .status-pill.pending {
    --tone: var(--warn-bar);
    color: var(--warn);
  }
  .status-pill.planned {
    border-style: dashed;
    border-color: var(--faint);
    background: transparent;
    color: var(--muted);
  }
  button.status-pill:hover {
    filter: brightness(0.97);
    transform: translateY(-1px);
  }
  .op-list.compact .op-row {
    padding: 0 8px 0 0;
  }
  .op-list.compact .op-main {
    padding-left: 16px;
  }
  .op-list.compact .op-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    padding-right: 8px;
  }
  .op-list.compact .op-amount {
    padding: 0;
    order: -1;
  }
  .op-list.compact .op-side .op-meta {
    text-align: right;
  }
  .rec-list {
    --op-cols: minmax(0, 1fr) auto 52px !important;
  }
  .rec-list .op-row > .icon-button {
    justify-self: center;
  }
  div.op-main {
    cursor: default;
  }

  /* Largeurs intermédiaires (tablette, petite fenêtre) */
  @media (min-width: 761px) and (max-width: 1100px) {
    .op-list,
    .op-list.no-account {
      --op-cols: 44px minmax(0, 1fr) minmax(0, 9rem) 7.5rem 7.5rem 44px;
    }
    .op-list .op-account,
    .op-header .h-account {
      display: none;
    }
  }
  @media (min-width: 761px) and (max-width: 960px) {
    .op-list,
    .op-list.no-account {
      --op-cols: 44px minmax(0, 1fr) auto 44px;
    }
    .op-list .op-category,
    .op-header .h-category,
    .op-header .h-status {
      display: none;
    }
    .op-list.full .op-side {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      gap: 3px;
    }
    .op-list.full .op-side .op-amount {
      order: -1;
      padding: 0;
    }
    .op-list.full .op-meta.desk {
      display: none;
    }
    .op-list.full .op-meta.mob {
      display: block;
    }
  }

  /* Barre de sélection contextuelle */
  .selection-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--s2) var(--s3);
    margin-bottom: var(--s3);
    padding: 8px 8px 8px 18px;
    border: 1px solid var(--ink-line);
    border-radius: var(--r-xl);
    background: var(--ink-gradient);
    color: #fff;
    box-shadow: var(--shadow);
    animation: rise 0.3s var(--ease);
  }
  .selection-bar b {
    font-family: var(--font-heading);
    font-size: var(--fs-base);
    font-weight: 600;
  }
  .selection-bar .muted {
    color: var(--ink-muted);
  }
  .selection-bar .actions {
    margin-left: auto;
    gap: 6px;
  }
  .selection-bar .button {
    min-height: 36px;
    padding: 0 14px;
    font-size: var(--fs-sm);
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.08);
    color: #fff;
    box-shadow: none;
  }
  .selection-bar .button:hover {
    background: rgba(255, 255, 255, 0.18);
  }
  .selection-bar .icon-button {
    color: #fff;
    min-width: 36px;
    min-height: 36px;
  }
  .selection-bar .icon-button:hover {
    background: rgba(255, 255, 255, 0.12);
  }
  .selection-bar .check-label {
    min-height: 36px;
    color: #fff;
  }

  /* Liste « À faire » */
  .todo-list {
    display: flex;
    flex-direction: column;
  }
  .todo-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 60px;
    padding: 9px 16px;
    text-align: left;
    border-top: 1px solid var(--line-soft);
    background: var(--surface);
    transition: background-color 0.2s;
  }
  .todo-item:first-child {
    border-top: 0;
  }
  button.todo-item:hover {
    background: var(--surface-2);
  }
  button.todo-item:hover .todo-cta .icon {
    transform: translateX(3px);
    color: var(--brand);
  }
  .todo-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--r-sm);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    background: var(--surface-3);
    color: var(--muted);
  }
  .todo-icon .icon {
    width: 17px;
    height: 17px;
  }
  .todo-item.ok .todo-icon {
    background: color-mix(in oklab, var(--fill) 14%, var(--surface));
    color: var(--brand);
  }
  .todo-item.warn .todo-icon {
    background: color-mix(in oklab, var(--warn-bar) 16%, var(--surface));
    color: var(--warn-strong);
  }
  .todo-item.danger .todo-icon {
    background: color-mix(in oklab, var(--danger) 13%, var(--surface));
    color: var(--danger);
  }
  .todo-item.info .todo-icon {
    background: color-mix(in oklab, var(--accent) 12%, var(--surface));
    color: var(--accent);
  }
  .todo-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
  }
  .todo-text b {
    font-size: var(--fs-base);
    font-weight: 600;
  }
  .todo-text small {
    font-size: var(--fs-xs);
    color: var(--muted);
  }
  .todo-cta {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--brand);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
  }
  .todo-cta .icon {
    width: 17px;
    height: 17px;
    color: var(--faint);
    transition: transform 0.2s var(--ease), color 0.2s;
  }

  /* Graphiques */
  .chart-wrap {
    padding: 12px 16px 4px;
  }
  .interactive-chart {
    position: relative;
    min-width: 0;
  }
  .chart {
    width: 100%;
    height: auto;
    display: block;
    overflow: visible;
    touch-action: pan-y;
    cursor: crosshair;
  }
  .chart text {
    fill: var(--faint);
    font-family: var(--font-mono);
    font-size: 10.5px;
  }
  .chart .chart-line {
    stroke: var(--line);
    stroke-dasharray: 3 6;
  }
  .chart .chart-base {
    stroke: var(--field-line);
  }
  .chart .chart-trace {
    stroke: var(--fill);
  }
  .chart .chart-future {
    stroke: var(--fill);
    stroke-dasharray: 6 5;
    stroke-opacity: 0.85;
  }
  .chart .chart-area {
    fill: var(--fill);
    fill-opacity: 0.1;
  }
  :is(.page-enter, .view-change) .chart polygon {
    animation: fade-in 0.8s var(--ease) 0.15s backwards;
  }
  .chart .chart-threshold {
    stroke: var(--danger);
    stroke-dasharray: 2 4;
    stroke-opacity: 0.6;
  }
  .chart .chart-today {
    stroke: var(--text);
    stroke-dasharray: 2 3;
    stroke-opacity: 0.5;
  }
  .chart .chart-today-dot {
    fill: var(--text);
    stroke: var(--surface);
    stroke-width: 2;
  }
  .chart .chart-low-dot {
    fill: var(--low);
    stroke: var(--surface);
    stroke-width: 2;
  }
  .chart text.chart-label {
    fill: var(--text);
    font-family: var(--font);
    font-weight: 700;
    font-size: 11.5px;
  }
  .chart text.chart-label.low {
    fill: var(--warn);
  }
  .chart:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 3px;
    border-radius: 8px;
  }
  .chart-marker {
    color: var(--muted);
  }
  .chart-marker circle {
    fill: var(--surface);
    stroke: var(--fill);
  }
  :is(.page-enter, .view-change) .chart-trace {
    stroke-dasharray: 1;
    animation: trace-in 0.9s var(--ease);
  }
  .chart-tooltip {
    position: absolute;
    pointer-events: none;
    padding: 7px 11px;
    max-width: calc(100% - 16px);
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 600;
    background: color-mix(in oklab, #0b1020 92%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: #f8fafc;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-lg);
    z-index: 2;
    white-space: nowrap;
  }
  .chart-hint {
    font-size: var(--fs-xs);
    color: var(--muted);
    padding: 6px 4px 0;
  }
  .chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: var(--fs-xs);
    font-weight: 500;
    color: var(--muted);
  }
  .chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .chart-legend i {
    width: 16px;
    border-top: 2px solid var(--fill);
  }
  .chart-legend i.dashed {
    border-top-style: dashed;
  }

  /* Liste de comptes, objectifs */
  .cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--s4);
  }
  .account-card {
    position: relative;
    padding: 20px;
    border-top: 3px solid var(--fill);
    transition: transform 0.3s var(--ease), box-shadow 0.3s;
  }
  @media (hover: hover) and (pointer: fine) {
    .account-card:hover,
    .goal-card:hover {
      transform: translateY(-3px);
      box-shadow: var(--shadow-lift);
    }
  }
  .account-row {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .account-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--r);
    display: grid;
    place-items: center;
    flex-shrink: 0;
  }
  .account-info {
    flex: 1;
    min-width: 0;
  }
  .account-info b {
    display: block;
    font-size: var(--fs-base);
    font-weight: 600;
    overflow-wrap: anywhere;
  }
  .account-info small {
    font-size: var(--fs-xs);
    color: var(--muted);
  }
  .account-card .balance {
    font-family: var(--font-heading);
    font-size: 1.875rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    margin: 18px 0 2px;
  }
  .account-card .meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--s3);
    border-top: 1px solid var(--line-soft);
    margin-top: var(--s4);
    padding-top: var(--s3);
  }
  .goal-card {
    padding: 20px;
    transition: transform 0.3s var(--ease), box-shadow 0.3s;
  }
  .goal-card .target {
    font-family: var(--font-heading);
    font-size: 1.625rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    margin: 18px 0 10px;
  }
  .goal-card .target span {
    font-family: var(--font);
    font-size: var(--fs-base);
    font-weight: 500;
    color: var(--muted);
    letter-spacing: 0;
  }
  .goal-card footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: var(--s4);
  }

  /* États vides et chargement */
  .empty {
    text-align: center;
    padding: 44px 24px;
  }
  .empty .empty-icon {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    margin: 0 auto 16px;
    display: grid;
    place-items: center;
    background: var(--glyph);
    color: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 10px 24px -10px #059669;
  }
  .empty h2 {
    font-size: var(--fs-lg);
  }
  .empty p {
    max-width: 440px;
    margin: 6px auto 18px;
    color: var(--muted);
    font-size: var(--fs-base);
  }
  .empty .actions {
    justify-content: center;
  }
  .skeleton-wrap {
    padding: 8px 0;
  }
  .skeleton-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--s4);
  }
  .skeleton-card,
  .skeleton-table {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow);
    padding: 22px;
  }
  .skeleton-card i,
  .skeleton-table i {
    display: block;
    height: 13px;
    margin: 12px 0;
    border-radius: var(--r-sm);
    background: linear-gradient(
      90deg,
      var(--surface-2) 0%,
      color-mix(in oklab, var(--surface-2) 40%, var(--surface)) 50%,
      var(--surface-2) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.6s linear infinite;
  }
  .skeleton-card i:nth-child(2) {
    height: 32px;
    width: 75%;
  }
  .skeleton-card i:last-child {
    width: 55%;
  }
  .skeleton-table {
    margin-top: var(--s4);
  }
  .skeleton-table i {
    height: 28px;
    margin: 14px 0;
  }
  .skeleton-table i:last-child {
    width: 70%;
  }
  .initial-loading {
    max-width: 1100px;
    margin: 12vh auto;
    padding: 24px;
  }

  /* Formulaires */
  .field {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .field label {
    font-size: var(--fs-sm);
    font-weight: 600;
  }
  .field small {
    font-size: var(--fs-xs);
    color: var(--muted);
  }
  .field + .field {
    margin-top: var(--s4);
  }
  .form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s4);
  }
  .form-grid .field + .field {
    margin: 0;
  }
  .form-grid .full {
    grid-column: 1 / -1;
  }
  .check-label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    font-size: var(--fs-base);
    cursor: pointer;
  }
  .form-error {
    color: var(--danger);
    font-size: var(--fs-base);
    font-weight: 600;
    margin: 10px 0;
  }
  .form-error:empty {
    display: none;
  }
  .file-drop {
    border: 2px dashed var(--field-line);
    border-radius: var(--r-lg);
    padding: 24px;
    text-align: center;
    background: var(--surface-2);
    transition: border-color 0.2s, background-color 0.2s;
  }
  .file-drop:hover {
    border-color: var(--fill);
    background: var(--soft);
  }
  .mapping {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }
  .import-preview {
    max-height: 260px;
    max-width: 100%;
    overflow: auto;
    margin-top: 18px;
    border: 1px solid var(--line);
    border-radius: var(--r);
  }
  .import-preview th {
    position: sticky;
    top: 0;
  }
  .import-pair {
    padding: 12px;
    margin-top: 10px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    align-items: flex-start;
    overflow-wrap: anywhere;
  }
  .secret-key,
  .recovery-codes {
    padding: 14px;
    border-radius: var(--r);
    background: var(--soft);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    user-select: all;
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
  }

  /* Dialogues */
  dialog {
    width: min(680px, calc(100% - 24px));
    max-width: calc(100vw - 24px);
    max-height: 90dvh;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--r-2xl);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
  }
  dialog::backdrop {
    background: rgba(2, 6, 23, 0.45);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
  }
  dialog[open] {
    animation: dialog-in 0.28s var(--ease);
  }
  dialog[open]::backdrop {
    animation: backdrop-in 0.28s var(--ease);
  }
  dialog.closing {
    animation: dialog-out 0.14s ease-in forwards;
  }
  dialog.closing::backdrop {
    animation: backdrop-in 0.14s ease-in reverse forwards;
  }
  .dialog-header {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s3);
    padding: 14px 12px 14px 22px;
    border-bottom: 1px solid var(--line);
    background: var(--glass);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    backdrop-filter: blur(18px) saturate(1.4);
  }
  .dialog-header h2 {
    font-size: 1.125rem;
    letter-spacing: -0.02em;
  }
  .dialog-body {
    padding: 20px 22px 22px;
  }
  .dialog-body > p {
    margin-bottom: var(--s4);
  }
  .dialog-footer {
    display: flex;
    justify-content: space-between;
    gap: var(--s3);
    flex-wrap: wrap;
    padding-top: var(--s5);
  }
  .dialog-footer .actions {
    margin-left: auto;
  }
  .sheet-footer {
    position: sticky;
    bottom: -22px;
    margin: 20px -22px -22px;
    padding: 12px 22px calc(16px + var(--safe-b));
    background: var(--glass);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    backdrop-filter: blur(18px) saturate(1.4);
    border-top: 1px solid var(--line-soft);
  }
  .sheet-section + .sheet-section {
    margin-top: 18px;
  }
  .sheet-section > h3 {
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 10px;
  }
  .chip-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s2);
  }
  .more-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .more-nav .button {
    justify-content: flex-start;
    border-radius: var(--r-lg);
  }
  .help-content {
    line-height: 1.8;
  }

  /* Notification (toast) — totalement masquée hors affichage (corrige la pastille visible sous la navigation) */
  #toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 10px;
    width: max-content;
    max-width: calc(100% - 32px);
    padding: 12px 18px 12px 14px;
    border: 1px solid color-mix(in oklab, var(--fill) 35%, var(--line));
    border-radius: var(--r-lg);
    background: color-mix(in oklab, var(--surface) 90%, transparent);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    backdrop-filter: blur(18px) saturate(1.4);
    color: var(--text);
    font-size: var(--fs-base);
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, 16px) scale(0.98);
    filter: blur(2px);
    transition: opacity 0.28s var(--ease), transform 0.28s var(--ease), filter 0.28s var(--ease),
      visibility 0s linear 0.28s;
  }
  #toast::before {
    content: '';
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--fill)
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12 4 4 8-8'/%3E%3C/svg%3E")
      center / 13px no-repeat;
  }
  #toast.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
    filter: none;
    transition: opacity 0.28s var(--ease), transform 0.28s var(--ease), filter 0.28s var(--ease), visibility 0s;
  }
  #toast.error {
    border-color: color-mix(in oklab, var(--danger) 40%, var(--line));
    color: var(--danger);
  }
  #toast.error::before {
    background: var(--danger)
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M12 7v6m0 4v.5'/%3E%3C/svg%3E")
      center / 13px no-repeat;
  }

  .skip {
    position: fixed;
    top: -80px;
    left: 20px;
    z-index: 100;
    padding: 12px 16px;
    border-radius: var(--r);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
  }
  .skip:focus {
    top: 10px;
  }

  @media (min-width: 761px) {
    #toast {
      left: auto;
      right: 24px;
      transform: translateY(16px) scale(0.98);
    }
    #toast.show {
      transform: none;
    }
  }

  @media (max-width: 760px) {
    input,
    select,
    textarea {
      font-size: 1rem; /* évite le zoom automatique d’iOS */
    }
    .period-nav {
      padding: 0;
      border: 0;
      background: transparent;
      box-shadow: none;
    }
    .period-nav .icon-button {
      min-width: 44px;
      min-height: 44px;
    }
    .period-button {
      min-height: 44px;
      padding: 0 4px;
      font-size: var(--fs-lg);
      letter-spacing: -0.025em;
    }
    .period-range {
      width: 100%;
      padding: 0 0 4px 14px;
      font-size: 0.6875rem;
    }
    .account-chip {
      order: 2;
    }
    .period-range {
      order: 3;
    }
    .account-chip select {
      min-height: 40px;
      max-width: 170px;
      font-size: var(--fs-base);
    }
    .page-heading {
      margin-bottom: var(--s4);
    }
    .page-heading h1 {
      font-size: 1.75rem;
    }
    .page-heading .button.collapsible {
      width: 44px;
      padding: 0;
    }
    .page-heading .button.collapsible .label {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip-path: inset(50%);
      white-space: nowrap;
    }
    .panel {
      border-radius: var(--r-lg);
    }
    .panel-head {
      padding: 16px 16px 0;
    }
    .panel-body {
      padding: 14px 16px 16px;
    }
    .kpi-grid,
    .kpi-grid.three {
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
    }
    .kpi-grid > .kpi:first-child:nth-last-child(odd) {
      grid-column: 1 / -1;
    }
    .kpi {
      padding: 14px;
      border-radius: var(--r-lg);
    }
    .kpi-label {
      font-size: 0.6rem;
      letter-spacing: 0.1em;
    }
    .kpi-label .icon {
      width: 28px;
      height: 28px;
      padding: 6px;
    }
    .kpi-value {
      font-size: clamp(1.25rem, 5.6vw, 1.6rem);
      white-space: nowrap;
    }
    .form-grid,
    .mapping {
      grid-template-columns: 1fr;
    }
    .form-grid .full {
      grid-column: auto;
    }
    .skeleton-grid {
      grid-template-columns: 1fr 1fr;
    }
    .skeleton-card:first-child {
      grid-column: 1 / -1;
    }
    .more-nav {
      grid-template-columns: 1fr;
    }
    td,
    th {
      padding: 10px 12px;
    }

    /* Dialogues en feuille, accessibles au pouce */
    dialog {
      width: 100%;
      max-width: 100%;
      max-height: 92dvh;
      margin: auto 0 0;
      border-radius: 28px 28px 0 0;
      border-bottom: 0;
    }
    dialog[open] {
      animation: sheet-in 0.32s var(--ease);
    }
    dialog.closing {
      animation: sheet-out 0.16s ease-in forwards;
    }
    .dialog-header {
      padding: 20px 8px 10px 20px;
      border-bottom-color: transparent;
    }
    .dialog-header::before {
      content: '';
      position: absolute;
      top: 8px;
      left: 50%;
      width: 40px;
      height: 4px;
      margin-left: -20px;
      border-radius: 3px;
      background: var(--field-line);
    }
    .dialog-body {
      padding: 6px 20px calc(22px + var(--safe-b));
    }
    .sheet-footer {
      margin: 20px -20px calc(-22px - var(--safe-b));
      padding: 12px 20px calc(16px + var(--safe-b));
    }
    .dialog-footer .actions {
      width: 100%;
    }
    .dialog-footer .actions .button {
      flex: 1;
    }

    /* Opérations en lignes compactes */
    .op-list,
    .op-list.no-account {
      --op-cols: minmax(0, 1fr) auto;
    }
    .op-list.selecting {
      --op-cols: 40px minmax(0, 1fr) auto;
    }
    .op-header {
      display: none;
    }
    .op-row {
      min-height: 62px;
      padding-right: 16px;
    }
    .op-row > .op-check {
      display: none;
    }
    .op-list.selecting .op-row > .op-check {
      display: block;
      padding-left: 12px;
    }
    .op-main {
      padding: 8px 12px 8px 16px;
      min-height: 62px;
    }
    .op-list.selecting .op-main {
      padding-left: 4px;
    }
    .op-category,
    .op-account,
    .op-edit {
      display: none !important;
    }
    .op-side {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      gap: 3px;
    }
    .op-side > * {
      padding: 0;
    }
    .op-amount {
      font-size: 0.875rem;
      order: -1;
    }
    .op-meta.desk {
      display: none;
    }
    .op-meta.mob {
      display: block;
    }
    .status-pill {
      min-height: 22px;
      padding: 0 8px;
      font-size: 0.6875rem;
    }
    .op-group-head {
      padding: 0 16px;
    }
    .op-panel {
      margin: 0 -16px;
      border-radius: 0;
      border-left: 0;
      border-right: 0;
    }

    /* Barre de sélection au-dessus de la navigation */
    .selection-bar.active {
      position: fixed;
      left: 12px;
      right: 12px;
      bottom: calc(12px + var(--nav-h) + var(--safe-b) + 12px);
      z-index: 26;
      margin: 0;
      box-shadow: var(--shadow-lg);
    }
    .selection-bar .actions {
      width: 100%;
      margin-left: 0;
    }
    .selection-bar .actions .button {
      flex: 1;
    }
    #toast {
      bottom: calc(12px + var(--nav-h) + var(--safe-b) + 14px);
    }
  }
}

/* ───────────── pages ───────────── */
@layer pages {
  /* Accueil */
  .dash-greeting {
    margin-bottom: var(--s6);
  }
  .dash-greeting h1 {
    font-size: clamp(1.9rem, 3vw, 2.75rem);
    letter-spacing: -0.035em;
  }
  .dash-greeting h1 .soft {
    color: color-mix(in oklab, var(--muted) 70%, var(--bg));
  }
  .dash-greeting p {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.9375rem;
  }
  .dash-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s5);
    margin-bottom: var(--s5);
  }
  .dash-row > * {
    min-width: 0;
  }
  .dash-row .hero {
    flex: 5 1 360px;
  }
  .dash-row .trajectory {
    flex: 7 1 460px;
  }
  .dash-row .third {
    flex: 1 1 300px;
  }
  .dash-row .wide {
    flex: 1 1 100%;
  }

  /* Carte héros « flux » : sombre, quadrillée, halos indigo et vert */
  .hero {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 22px 24px;
    border: 1px solid var(--ink-line);
    border-radius: var(--r-2xl);
    background: var(--ink-gradient);
    color: var(--ink-text);
    box-shadow: 0 24px 48px -28px rgba(11, 16, 32, 0.65);
  }
  .hero::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background-image: linear-gradient(rgba(148, 163, 184, 0.07) 1px, transparent 1px),
      linear-gradient(90deg, rgba(148, 163, 184, 0.07) 1px, transparent 1px);
    background-size: 28px 28px;
    -webkit-mask-image: linear-gradient(160deg, #000 10%, transparent 75%);
    mask-image: linear-gradient(160deg, #000 10%, transparent 75%);
    pointer-events: none;
  }
  /* La carte s’adapte à sa propre largeur (colonne étroite sur ordinateur comme sur téléphone). */
  .hero {
    container-type: inline-size;
  }
  :root[data-theme='dark'] .hero {
    border-color: rgba(148, 163, 184, 0.22);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 24px 48px -28px rgba(0, 0, 0, 0.9);
  }
  .hero-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--s3);
  }
  .hero .kpi-label {
    flex-wrap: wrap;
    justify-content: flex-start;
    color: var(--ink-muted);
  }
  .hero-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border: 1px solid rgba(165, 180, 252, 0.35);
    border-radius: var(--r-pill);
    background: rgba(99, 102, 241, 0.18);
    color: #c7d2fe;
    font-size: 0.625rem;
    letter-spacing: 0.08em;
  }
  .hero-detail {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--r-pill);
    background: rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
    font-size: var(--fs-xs);
    font-weight: 600;
    white-space: nowrap;
    transition: background-color 0.2s, border-color 0.2s;
  }
  .hero-detail:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
  }
  .hero-detail .icon {
    width: 15px;
    height: 15px;
  }
  .hero .kpi-value {
    font-size: var(--fs-hero);
    letter-spacing: -0.045em;
    line-height: 1.05;
    margin: 10px 0 0;
  }
  .hero .kpi-value.negative {
    color: #fca5a5;
  }
  .flow-head {
    display: flex;
    justify-content: space-between;
    gap: var(--s3);
    margin: 20px 0 8px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-muted);
  }
  .flow-head b {
    color: #fff;
    letter-spacing: 0;
    font-weight: 600;
  }
  .flow-bar {
    position: relative;
    display: flex;
    gap: 3px;
    height: 10px;
    border-radius: var(--r-pill);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.07);
  }
  .flow-bar i {
    display: block;
    height: 100%;
    min-width: 3px;
    border-radius: 3px;
    transform-origin: left center;
  }
  .seg-actual {
    background: var(--seg-actual);
  }
  .seg-planned {
    background: var(--seg-planned);
  }
  .seg-transfer {
    background: var(--seg-transfer);
  }
  .seg-opening {
    background: var(--seg-opening);
  }
  .seg-net {
    background: linear-gradient(90deg, #10b981, var(--mint));
    box-shadow: 0 0 12px rgba(52, 211, 153, 0.55);
  }
  .flow-limit {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    margin-left: -1px;
    background: #fca5a5;
  }
  .flow-legend {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px 18px;
    margin-top: 12px;
    font-size: var(--fs-sm);
    color: var(--ink-soft);
  }
  .flow-legend > span {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
  }
  .flow-legend i {
    width: 9px;
    height: 9px;
    border-radius: 3px;
    flex-shrink: 0;
  }
  .flow-legend em {
    font-style: normal;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .flow-legend b {
    margin-left: auto;
    color: #fff;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
  }
  .hero-foot {
    display: grid;
    grid-template-columns: repeat(3, auto);
    justify-content: space-between;
    gap: var(--s3);
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--ink-line);
  }
  .hero-flow + .hero-foot {
    margin-top: 20px;
  }
  .hero-stat {
    min-width: 0;
  }
  .hero-stat small {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-muted);
  }
  .hero-stat b {
    display: block;
    margin-top: 4px;
    font-family: var(--font-heading);
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
  }
  .hero-stat b span {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--ink-soft);
  }
  .hero-stat .low-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--low);
    box-shadow: 0 0 8px var(--low);
  }
  .hero-stat.alert b {
    color: #fca5a5;
  }
  .hero-stat.ok b,
  .hero-stat.wait b {
    white-space: normal;
  }
  .hero-stat.ok b {
    font-size: var(--fs-base);
    color: #6ee7b7;
    margin-top: 6px;
  }
  .hero-stat.wait b {
    font-size: var(--fs-base);
    color: #fcd34d;
    margin-top: 6px;
  }
  @container (max-width: 500px) {
    .flow-legend {
      grid-template-columns: 1fr;
      gap: 5px;
    }
    .hero-foot {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .hero-foot .hero-stat:nth-child(3) {
      grid-column: 1 / -1;
    }
  }
  .trajectory .chart-wrap {
    padding: 10px 14px 0;
  }
  .trajectory .chart-hint {
    padding: 0 20px 14px;
  }
  .section-title {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--s3);
    margin: 0 4px 8px;
  }
  .section-title h2 {
    font-size: var(--fs-md);
  }
  .budget-mini {
    padding: 4px 20px 16px;
  }
  .budget-mini .envelope {
    padding: 10px 0;
    border: 0;
  }

  /* Budgets */
  .budget-summary {
    padding: 22px 24px;
    margin-bottom: var(--s5);
  }
  .budget-summary .kpi-label {
    justify-content: flex-start;
  }
  .budget-summary .big {
    font-family: var(--font-heading);
    font-size: 2.375rem;
    font-weight: 600;
    letter-spacing: -0.035em;
    line-height: 1.15;
    margin: 6px 0 2px;
  }
  .budget-summary .meter {
    margin-top: 16px;
  }
  .meter-legend {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-top: 10px;
    font-size: var(--fs-xs);
    color: var(--muted);
  }
  .meter-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .meter-legend .tick-key {
    width: 2px;
    height: 12px;
    background: var(--text);
    opacity: 0.55;
  }
  .envelope-list {
    overflow: hidden;
  }
  .envelope {
    display: block;
    width: 100%;
    padding: 14px 20px 15px;
    text-align: left;
    border-top: 1px solid var(--line-soft);
    transition: background-color 0.2s;
  }
  .envelope:first-child {
    border-top: 0;
  }
  button.envelope:hover {
    background: var(--surface-2);
  }
  .envelope-head,
  .envelope-foot {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--s3);
  }
  .envelope-head {
    font-size: var(--fs-base);
  }
  .envelope-head > span {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    min-width: 0;
  }
  .envelope-head > b {
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
  }
  .envelope-head > b.over {
    color: var(--danger);
  }
  .envelope-head > b.warn {
    color: var(--warn);
  }
  .envelope .meter {
    margin: 9px 0 6px;
  }
  .envelope .meter:not(.warn, .over) > i {
    background: var(--c, var(--fill));
  }
  .envelope-foot {
    font-size: var(--fs-xs);
    color: var(--muted);
  }
  .envelope-foot .pace {
    color: var(--warn);
    font-weight: 600;
  }
  .envelope-add {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    min-height: 50px;
    border-top: 1px solid var(--line-soft);
    color: var(--brand);
    font-size: var(--fs-base);
    font-weight: 600;
    transition: background-color 0.2s;
  }
  .envelope-add:hover {
    background: var(--soft);
  }

  /* Opérations */
  .ops-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s2);
    align-items: center;
    margin-bottom: var(--s3);
  }
  .ops-toolbar .search {
    flex: 1 1 280px;
  }
  .ops-toolbar .search input {
    min-height: 42px;
  }
  .ops-toolbar .segmented {
    padding: 3px;
  }
  .ops-toolbar .segmented button {
    min-height: 34px;
  }
  .filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s2);
    width: 100%;
  }
  .filter-reset {
    min-height: 40px;
    padding: 0 10px;
    border-radius: var(--r-pill);
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--brand);
  }
  .filter-reset:hover {
    background: var(--soft);
  }
  .filter-button {
    position: relative;
    display: none;
  }
  .mobile-filters {
    display: none;
  }
  .ops-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 24px;
    margin: 0 2px var(--s3);
    font-size: var(--fs-sm);
    color: var(--muted);
  }
  .ops-summary b {
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
  }
  .ops-summary b.positive {
    color: var(--positive);
  }
  .op-list.full {
    overflow: hidden;
  }
  .pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s3);
    padding: 10px 16px;
    border-top: 1px solid var(--line);
    font-size: var(--fs-sm);
    color: var(--muted);
  }
  .pagination label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
  }
  .pagination select {
    width: auto;
    min-height: 36px;
    border-radius: var(--r-pill);
  }
  .pagination .actions {
    gap: 4px;
  }

  /* Prévisionnel */
  .forecast-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px;
    padding: 18px 20px;
    margin-bottom: var(--s5);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .forecast-controls .field {
    flex: 1;
    min-width: 170px;
  }
  .forecast-controls .field + .field {
    margin-top: 0;
  }

  /* Pointage et rapprochement */
  .monthly-equation .summary-line {
    font-size: var(--fs-base);
  }
  .pending-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    margin-top: var(--s4);
    background: var(--line);
    border-top: 1px solid var(--line);
    border-radius: 0 0 var(--r-xl) var(--r-xl);
    overflow: hidden;
  }
  .pending-card {
    padding: 20px;
    background: var(--surface);
  }
  .pending-card h3 {
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .pending-total {
    display: block;
    margin: 10px 0 2px;
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.03em;
  }
  .pending-card .summary-line {
    font-size: var(--fs-sm);
  }
  .pending-card > .button {
    margin-top: var(--s3);
  }
  .reconcile-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--s4);
  }
  .reconcile-grid > div {
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface-2);
  }
  .reconcile-grid span {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .reconcile-grid strong {
    display: block;
    margin-top: 6px;
    font-family: var(--font-heading);
    font-size: 1.375rem;
    font-weight: 600;
    letter-spacing: -0.02em;
  }
  .reconcile-list {
    max-height: 330px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
  }
  .reconcile-operation {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    cursor: pointer;
    border-top: 1px solid var(--line-soft);
    transition: background-color 0.15s;
  }
  .reconcile-operation:first-child {
    border-top: 0;
  }
  .reconcile-operation:hover {
    background: var(--row-hover);
  }
  .reconcile-operation span {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .reconcile-operation small {
    display: block;
    color: var(--muted);
  }
  .reconcile-operation strong {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
  }
  .statement-list {
    margin-top: var(--s3);
  }
  .statement {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    padding: 16px 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .statement > div {
    flex: 1;
    min-width: 180px;
  }
  .duplicate-list {
    display: grid;
    gap: var(--s3);
  }
  .duplicate-item {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
  }
  .duplicate-date {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
  }
  .duplicate-date input {
    flex: 1;
    width: auto;
    min-width: 150px;
  }

  /* Paramètres */
  .settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s5);
  }
  .settings-grid p {
    margin: 0 0 var(--s4);
    color: var(--muted);
    font-size: var(--fs-base);
  }
  .category-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s2);
  }
  .category-edit {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    background: var(--surface);
    font-size: var(--fs-sm);
    font-weight: 500;
    transition: background-color 0.2s, border-color 0.2s, transform 0.2s var(--ease);
  }
  .category-edit:hover {
    background: var(--surface-2);
    border-color: var(--field-line);
    transform: translateY(-1px);
  }
  .category-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-right: 7px;
    border-radius: 50%;
  }
  .two-col {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr);
    gap: var(--s5);
    margin-bottom: var(--s5);
  }
  .equal-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Connexion */
  .auth {
    min-height: 100dvh;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .auth-story {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 56px 12%;
    background: var(--ink-gradient);
    color: #fff;
  }
  .auth-story::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background-image: linear-gradient(rgba(148, 163, 184, 0.07) 1px, transparent 1px),
      linear-gradient(90deg, rgba(148, 163, 184, 0.07) 1px, transparent 1px);
    background-size: 32px 32px;
    -webkit-mask-image: radial-gradient(ellipse at top left, #000 25%, transparent 75%);
    mask-image: radial-gradient(ellipse at top left, #000 25%, transparent 75%);
  }
  .auth-story .logo {
    padding: 0;
    color: #fff;
  }
  .auth-story .logo-text small {
    color: var(--ink-muted);
  }
  .auth-story .eyebrow {
    margin: 56px 0 0;
    color: var(--ink-muted);
  }
  .auth-story h1 {
    font-size: clamp(2.6rem, 4.4vw, 4.6rem);
    font-weight: 600;
    line-height: 1.02;
    letter-spacing: -0.05em;
    margin: 18px 0 22px;
  }
  .auth-story h1 em {
    font-style: normal;
    color: #8a93a6;
  }
  .auth-story p {
    max-width: 420px;
    color: var(--ink-soft);
    line-height: 1.7;
  }
  .auth-story footer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 64px;
    font-size: var(--fs-sm);
    color: var(--ink-muted);
  }
  .auth-story footer .icon {
    color: var(--mint);
  }
  .auth-form-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 24px;
  }
  .auth-form {
    width: 100%;
    max-width: 400px;
    padding: 32px;
    border: 1px solid var(--line);
    border-radius: var(--r-2xl);
    background: var(--glass);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    backdrop-filter: blur(18px) saturate(1.4);
    box-shadow: var(--shadow-lift);
    animation: rise 0.6s var(--ease) 0.1s backwards;
  }
  .auth-form h2 {
    font-size: 1.75rem;
    letter-spacing: -0.035em;
    margin-bottom: 8px;
  }
  .auth-form > p {
    margin-bottom: 24px;
    color: var(--muted);
  }
  .auth-form .button {
    width: 100%;
    margin-top: 8px;
  }

  @media (max-width: 1100px) {
    .two-col,
    .settings-grid {
      grid-template-columns: 1fr;
    }
  }
  @media (max-width: 960px) {
    .reconcile-grid {
      gap: var(--s3);
    }
    .reconcile-grid strong {
      font-size: 1.2rem;
    }
  }
  @media (max-width: 760px) {
    .dash-greeting {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip-path: inset(50%);
    }
    /* Sur mobile : l’actionnable d’abord (héros, à faire, à venir), l’analyse ensuite. */
    .dash {
      display: flex;
      flex-direction: column;
      gap: var(--s4);
    }
    .dash-row {
      display: contents;
    }
    .dash .hero {
      order: 1;
    }
    .dash .todo-panel {
      order: 2;
    }
    .dash .upcoming-panel {
      order: 3;
    }
    .dash .trajectory {
      order: 4;
    }
    .dash .budgets-panel {
      order: 5;
    }
    .dash .latest-panel {
      order: 6;
    }
    .dash-row .hero,
    .dash-row .trajectory,
    .dash-row .third {
      flex-basis: 100%;
    }
    .hero {
      padding: 18px 18px 16px;
      border-radius: var(--r-xl);
    }
    .hero .kpi-value {
      font-size: 2.625rem;
    }
    .flow-legend {
      grid-template-columns: 1fr;
      gap: 5px;
    }
    .hero-foot {
      grid-template-columns: repeat(2, auto);
    }
    .hero-foot .hero-stat:nth-child(3) {
      display: none;
    }
    .hero .kpi-label,
    .hero-stat small,
    .flow-head {
      letter-spacing: 0.04em;
    }
    .section-title {
      margin: 4px 4px 8px;
    }
    .budget-summary {
      padding: 16px;
    }
    .budget-summary .big {
      font-size: 2.125rem;
    }
    .envelope {
      padding: 12px 14px;
    }

    .ops-toolbar {
      flex-wrap: nowrap;
    }
    .ops-toolbar .segmented,
    .ops-toolbar .filter-row {
      display: none;
    }
    .ops-toolbar .search {
      flex: 1;
    }
    .ops-toolbar .search input {
      min-height: 44px;
    }
    .filter-button {
      display: inline-grid;
      border: 1px solid var(--line);
      background: var(--surface);
      color: var(--text);
    }
    .mobile-filters {
      display: flex;
      margin-bottom: 10px;
    }
    .ops-summary {
      margin-bottom: 10px;
    }
    .ops-summary span:not(:first-child) {
      display: none;
    }
    .ops-summary.has-selection span {
      display: inline;
    }
    .pagination {
      padding: 12px 16px;
    }

    .forecast-controls {
      padding: 16px;
    }
    .pending-grid {
      grid-template-columns: 1fr;
    }
    .pending-card {
      padding: 16px;
    }
    .reconcile-grid {
      grid-template-columns: 1fr;
      gap: 8px;
    }
    .reconcile-grid > div {
      display: flex;
      justify-content: space-between;
      align-items: baseline;
      gap: var(--s4);
      padding: 10px 14px;
    }
    .reconcile-grid strong {
      margin: 0;
      font-size: 1.1rem;
    }
    .reconcile-grid span {
      max-width: 60%;
    }
    .duplicate-date {
      display: block;
    }
    .duplicate-date input {
      width: 100%;
      margin-top: 6px;
    }
    .cards {
      grid-template-columns: 1fr;
    }

    .auth {
      display: block;
    }
    .auth-story {
      padding: 28px 24px 32px;
    }
    .auth-story .eyebrow {
      margin-top: 28px;
    }
    .auth-story h1 {
      font-size: 2.25rem;
      margin: 12px 0 0;
    }
    .auth-story footer,
    .auth-story > div > p {
      display: none;
    }
    .auth-form-wrap {
      padding: 24px 16px 40px;
    }
    .auth-form {
      padding: 24px 20px;
    }
  }
}

/* ───────────── utilities ───────────── */
@layer utilities {
  .muted {
    color: var(--muted);
  }
  .positive {
    color: var(--positive);
  }
  .negative {
    color: var(--danger);
  }
  .num {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }
  .small {
    font-size: var(--fs-sm);
  }
  .right {
    text-align: right;
  }
  .section-spacer {
    margin-top: var(--s5);
  }
  .page-note {
    margin-top: var(--s4);
    font-size: var(--fs-xs);
    color: var(--muted);
    line-height: 1.6;
  }
  .page-note .icon-button {
    min-width: 32px;
    min-height: 32px;
    vertical-align: middle;
  }
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
  .print-only {
    display: none;
  }
  @media (max-width: 760px) {
    .desktop-only {
      display: none !important;
    }
  }
  @media (min-width: 761px) {
    .mobile-only {
      display: none !important;
    }
  }
}

/* ───────────── transitions et entrées (habillage 1.6) ─────────────
   « page-enter » est posée par render() uniquement quand la rubrique change (pas à chaque action),
   « view-change » quand la période ou le compte suivi change. Les animations ne modifient aucun contenu. */
.content.page-enter {
  animation: page-in 0.28s var(--ease) backwards;
}
.content.view-change {
  animation: view-in 0.24s var(--ease) backwards;
}
.page-enter :is(.kpi-grid, .cards, .plan-list, .settings-grid, .pending-grid, .two-col) > *,
.page-enter :is(.dash-row, .account-summary .dash-row) > *,
.page-enter > :is(.panel, .budget-summary, .forecast-controls, .account-summary, .ops-toolbar, .note-box) {
  animation: rise 0.45s var(--ease) backwards;
}
.page-enter :is(.kpi-grid, .cards, .plan-list, .settings-grid, .pending-grid, .two-col, .dash-row) > :nth-child(2),
.page-enter > :nth-child(3) {
  animation-delay: 0.05s;
}
.page-enter :is(.kpi-grid, .cards, .plan-list, .settings-grid, .pending-grid, .two-col, .dash-row) > :nth-child(3),
.page-enter > :nth-child(4) {
  animation-delay: 0.1s;
}
.page-enter :is(.kpi-grid, .cards, .plan-list, .settings-grid, .pending-grid, .two-col, .dash-row) > :nth-child(4),
.page-enter > :nth-child(5) {
  animation-delay: 0.15s;
}
.page-enter :is(.cards, .plan-list) > :nth-child(n + 5),
.page-enter > :nth-child(n + 6) {
  animation-delay: 0.2s;
}
.page-enter .dash > .dash-row:nth-child(2) > * {
  animation-delay: 0.12s;
}
.page-enter .dash > :last-child {
  animation-delay: 0.2s;
}
:is(.page-enter, .view-change) :is(.meter > i, .progress > div, .flow-bar i) {
  animation: grow-x 0.9s var(--ease) 0.15s backwards;
}
/* Changement de thème : respecter aussi la préférence système pendant la bascule. */
@media (prefers-reduced-motion: no-preference) {
  :root.theme-switching *,
  :root.theme-switching *::before,
  :root.theme-switching *::after {
    transition: background-color 0.35s var(--ease), border-color 0.35s var(--ease), color 0.35s var(--ease),
      fill 0.35s var(--ease), stroke 0.35s var(--ease) !important;
  }
}

/* ───────────── animations ───────────── */
@keyframes value-in {
  from {
    opacity: 0.3;
    transform: translateY(3px);
  }
}
@keyframes trace-in {
  from {
    stroke-dashoffset: 1;
  }
  to {
    stroke-dashoffset: 0;
  }
}
@keyframes pulse {
  to {
    opacity: 0.4;
  }
}
@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}
@keyframes pulse-ring {
  0% {
    transform: scale(0.8);
    opacity: 0.7;
  }
  80%,
  100% {
    transform: scale(2.4);
    opacity: 0;
  }
}
@keyframes drift {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(-4%, 3%, 0) scale(1.08);
  }
}
@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(10px);
    filter: blur(4px);
  }
}
@keyframes view-in {
  from {
    opacity: 0.4;
    filter: blur(2px);
  }
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
@keyframes grow-x {
  from {
    transform: scaleX(0);
  }
}
@keyframes indicator-in {
  from {
    transform: scaleY(0.2);
    opacity: 0;
  }
}
@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
    filter: blur(4px);
  }
}
@keyframes dialog-out {
  to {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    filter: blur(2px);
  }
}
@keyframes sheet-in {
  from {
    transform: translateY(100%);
  }
}
@keyframes sheet-out {
  to {
    transform: translateY(100%);
  }
}
@keyframes backdrop-in {
  from {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after,
  ::backdrop {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .sidebar,
  .topbar,
  .bottom-nav,
  .fab,
  .page-heading .actions,
  .ops-toolbar,
  .mobile-filters,
  .selection-bar,
  .pagination,
  .op-check,
  .op-edit,
  .row-actions,
  .button,
  .icon-button,
  .chart-hint,
  .chart-tooltip,
  #toast,
  dialog {
    display: none !important;
  }
  body::before,
  body::after,
  .hero::before {
    display: none;
  }
  .shell {
    display: block;
  }
  .content {
    max-width: none;
    padding: 0;
  }
  body {
    background: #fff;
    color: #000;
  }
  .panel,
  .kpi,
  .hero {
    break-inside: avoid;
    box-shadow: none;
  }
  .hero,
  .kpi.primary {
    background: #fff;
    color: #000;
    border: 1px solid #ccc;
  }
  .print-only {
    display: block;
  }
  .table-scroll {
    overflow: visible;
  }
}

/* ───────────── 1.5 : résumé du compte, facilités de paiement, version ───────────── */
@layer pages {
  /* Résumé du compte en tête des opérations filtrées */
  .account-summary {
    margin-bottom: var(--s6);
  }
  .account-summary-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s3);
    margin-bottom: var(--s2);
  }
  .back-link {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    min-height: 36px;
    margin-left: -6px;
    padding: 0 10px 0 6px;
    border-radius: var(--r-pill);
    color: var(--brand);
    font-size: var(--fs-sm);
    font-weight: 600;
    transition: background-color 0.2s;
  }
  .back-link .icon {
    width: 16px;
    height: 16px;
    transition: transform 0.2s var(--ease);
  }
  .back-link:hover {
    background: var(--soft);
  }
  .back-link:hover .icon {
    transform: translateX(-2px);
  }
  .account-title {
    display: flex;
    align-items: center;
    gap: var(--s3);
    margin-bottom: var(--s4);
  }
  .account-title > div {
    flex: 1;
    min-width: 0;
  }
  .account-title h2 {
    font-size: 1.5rem;
    letter-spacing: -0.03em;
    overflow-wrap: anywhere;
  }
  .account-title small {
    color: var(--muted);
    font-size: var(--fs-sm);
  }
  .account-summary.collapsed {
    padding-bottom: var(--s4);
    border-bottom: 1px solid var(--line);
  }
  .account-summary.collapsed .account-title {
    margin-bottom: 0;
  }
  .account-summary .dash-row {
    margin-bottom: 0;
  }
  .mobile-trajectory > summary,
  .plan-archive > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 52px;
    padding: 0 var(--s5);
    font-family: var(--font-heading);
    font-weight: 600;
    cursor: pointer;
    list-style: none;
  }
  .mobile-trajectory > summary::-webkit-details-marker,
  .plan-archive > summary::-webkit-details-marker {
    display: none;
  }
  .mobile-trajectory > summary::after,
  .plan-archive > summary::after {
    content: '';
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg);
    transition: transform 0.25s var(--ease);
  }
  .mobile-trajectory[open] > summary::after,
  .plan-archive[open] > summary::after {
    transform: rotate(-135deg);
  }
  .mobile-trajectory .chart-wrap {
    padding: 0 var(--s2) var(--s3);
  }

  /* Facilités de paiement */
  .plan-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr));
    gap: var(--s5);
    margin-top: var(--s5);
    align-items: start;
  }
  .plan-progress {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--s1) var(--s3);
    margin-bottom: var(--s2);
    font-size: var(--fs-sm);
    color: var(--muted);
  }
  .plan-progress b {
    color: var(--text);
  }
  .plan-alert {
    display: flex;
    align-items: flex-start;
    flex-wrap: nowrap;
    gap: 6px 8px;
    margin-top: var(--s3);
    padding: 8px 12px;
    border: 1px solid color-mix(in oklab, var(--warn-bar) 30%, transparent);
    border-radius: var(--r);
    background: var(--warn-soft);
    color: var(--warn);
    font-size: var(--fs-sm);
    font-weight: 600;
  }
  .plan-alert .icon {
    width: 16px;
    height: 16px;
    margin-top: 2px;
    flex-shrink: 0;
  }
  .plan-alert .button {
    flex-shrink: 0;
    margin-left: auto;
  }
  .plan-alert .button.subtle {
    min-height: 30px;
    padding: 0 8px;
  }
  .plan-rows {
    margin-top: var(--s3);
    border-top: 1px solid var(--line-soft);
  }
  .plan-row {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto 152px;
    align-items: center;
    gap: var(--s3);
    min-height: 48px;
    padding: 6px 0;
    border-bottom: 1px solid var(--line-soft);
    font-size: var(--fs-base);
  }
  .plan-row:last-child {
    border-bottom: 0;
  }
  .plan-rank {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--faint);
    font-variant-numeric: tabular-nums;
  }
  .plan-date {
    overflow-wrap: anywhere;
  }
  .plan-amount {
    font-family: var(--font-mono);
    font-size: 0.8438rem;
    font-weight: 600;
    text-align: right;
  }
  .plan-row .status-pill {
    justify-self: end;
  }
  .plan-row.paid .plan-date,
  .plan-row.paid .plan-amount,
  .plan-row.external .plan-date,
  .plan-row.external .plan-amount {
    color: var(--muted);
  }
  .plan-row.late .plan-date {
    color: var(--warn);
    font-weight: 600;
  }
  .status-pill.external {
    --tone: var(--faint);
    color: var(--muted);
  }
  .status-pill.missing {
    --tone: var(--danger);
    color: var(--danger);
  }
  .plan-archive {
    padding-bottom: 0;
  }
  .plan-archive[open] {
    padding-bottom: var(--s5);
  }
  .plan-archive .plan-list {
    margin-top: 0;
    padding: 0 var(--s5);
  }
  .plan-archive .plan-card {
    background: var(--surface-2);
    box-shadow: none;
  }

  /* Éditeur d’échéancier */
  .plan-params {
    margin-top: var(--s4);
  }
  .count-row {
    display: flex;
    align-items: center;
    gap: var(--s2);
  }
  .count-row input {
    flex: 1 1 64px;
    max-width: 96px;
  }
  .count-row .chip {
    min-height: 44px;
  }
  .plan-preview {
    margin: var(--s3) 0 var(--s4);
  }
  .plan-edit-rows {
    display: flex;
    flex-direction: column;
    gap: var(--s2);
  }
  .plan-edit-row {
    display: grid;
    grid-template-columns: 40px minmax(140px, 1fr) minmax(96px, 128px) auto;
    align-items: center;
    gap: var(--s2) var(--s3);
    padding: var(--s2) var(--s3);
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface-2);
  }
  .plan-edit-row.locked {
    background: var(--soft);
    border-color: var(--soft-line);
  }
  .plan-edit-row .check-label {
    min-height: 36px;
    font-size: var(--fs-sm);
    white-space: nowrap;
  }
  .plan-edit-row .status-pill {
    justify-self: start;
  }
  .plan-edit-row .plan-link {
    grid-column: 2 / -1;
    white-space: normal;
    color: var(--brand-strong);
  }
  .plan-total {
    display: flex;
    justify-content: space-between;
    gap: var(--s3);
    margin-top: var(--s3);
    padding: var(--s3) var(--s3) 0;
    border-top: 1px solid var(--line);
    font-weight: 600;
  }
  .plan-total + .note-box {
    margin-top: var(--s3);
  }

  /* Chéquiers (1.6) */
  .plan-list.cheque-list {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 560px), 1fr));
  }
  .note-box + .field {
    margin-top: var(--s4);
  }
  .cheque-actions {
    margin-top: var(--s4);
    gap: var(--s2);
  }
  .cheque-title {
    margin-top: var(--s5);
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .cheque-empty {
    margin-top: var(--s4);
  }
  .cheque-rows {
    margin-top: var(--s2);
    border-top: 1px solid var(--line-soft);
  }
  .cheque-row {
    display: grid;
    grid-template-columns: 6.75rem minmax(0, 1fr) auto auto;
    grid-template-areas: 'num main amount pill';
    align-items: center;
    gap: var(--s3);
    min-height: 54px;
    padding: 6px 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .cheque-row:last-child {
    border-bottom: 0;
  }
  .cheque-number {
    grid-area: num;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
  }
  .cheque-main {
    grid-area: main;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 4px 0;
    text-align: left;
  }
  .cheque-main b {
    font-size: var(--fs-base);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .cheque-main small {
    font-size: var(--fs-xs);
    color: var(--muted);
  }
  .cheque-main:hover b {
    text-decoration: underline;
    text-decoration-color: var(--faint);
    text-underline-offset: 3px;
  }
  .cheque-amount {
    grid-area: amount;
    font-family: var(--font-mono);
    font-size: 0.8438rem;
    font-weight: 600;
    text-align: right;
  }
  .cheque-row .status-pill {
    grid-area: pill;
    justify-self: end;
  }
  .cheque-row.cashed .cheque-amount,
  .cheque-row.void .cheque-amount,
  .cheque-row.stopped .cheque-amount {
    color: var(--muted);
  }
  .cheque-row.void .cheque-amount,
  .cheque-row.stopped .cheque-amount {
    text-decoration: line-through;
  }
  .cheque-more {
    margin-top: var(--s3);
    border-top: 1px solid var(--line-soft);
  }
  .cheque-more > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 44px;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    list-style: none;
  }
  .cheque-more > summary::-webkit-details-marker {
    display: none;
  }
  .cheque-more > summary::after {
    content: '';
    width: 7px;
    height: 7px;
    margin-right: 4px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg);
    transition: transform 0.25s var(--ease);
  }
  .cheque-more[open] > summary::after {
    transform: rotate(-135deg);
  }
  .cheque-more > .cheque-rows {
    margin-top: 0;
  }
  .cheque-choices {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: var(--s2);
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface-2);
  }
  .cheque-choices .check-label {
    align-items: flex-start;
    padding: 10px 0;
    font-size: var(--fs-sm);
  }
  .cheque-choices input {
    margin-top: 1px;
  }
  .cheque-results {
    display: flex;
    flex-direction: column;
    max-height: 340px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
  }
  .cheque-results .reconcile-operation {
    width: 100%;
    text-align: left;
  }
  .cheque-results .cheque-empty {
    margin: 0;
    padding: 16px;
  }
  .cheque-sheet {
    padding: 4px 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface-2);
  }
  .cheque-sheet .cheque-row {
    border: 0;
  }
  @media (max-width: 760px) {
    .cheque-row {
      grid-template-columns: minmax(0, 1fr) auto;
      grid-template-areas: 'num amount' 'main pill';
      gap: 0 var(--s2);
      padding: 8px 0;
    }
    .cheque-main {
      padding-top: 0;
    }
  }

  /* Version installée (Paramètres) */
  .version-panel .panel-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--s2) var(--s5);
  }
  .version-panel .panel-body > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .version-number {
    font-family: var(--font-heading);
    font-size: var(--fs-md);
  }
  .version-panel code,
  .page-note code {
    padding: 1px 6px;
    border-radius: 6px;
    background: var(--surface-3);
    font-size: 0.86em;
    overflow-wrap: anywhere;
  }

  @media (max-width: 760px) {
    .account-summary:not(.collapsed) {
      display: flex;
      flex-direction: column;
      gap: var(--s4);
    }
    .account-summary .account-summary-top,
    .account-summary .account-title {
      margin-bottom: 0;
    }
    .account-summary-top + .account-title {
      margin-top: calc(-1 * var(--s3));
    }
    .account-summary .dash-row {
      display: contents;
    }
    .plan-row {
      grid-template-columns: 34px minmax(0, 1fr) auto;
      gap: 2px var(--s2);
      padding: 8px 0;
    }
    .plan-row .status-pill {
      grid-column: 2 / -1;
      justify-self: start;
    }
    .plan-edit-row {
      grid-template-columns: 32px minmax(0, 1fr) minmax(0, 0.8fr);
    }
    .plan-edit-row > .check-label,
    .plan-edit-row > .status-pill {
      grid-column: 2 / -1;
    }
    .plan-archive .plan-list {
      padding: 0 var(--s3);
    }
  }
}

/* ───────────── Relevés (v1.7) ─────────────
   Rubrique Relevés : liste par année et aperçu détaillé. Uniquement des variables de « tokens ». */
@layer pages {
  .statement-table th.num,
  .statement-table td.num {
    text-align: right;
  }
  .statement-table td small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: var(--fs-xs);
    overflow-wrap: anywhere;
  }
  .statement-link {
    display: inline-flex;
    align-items: center;
    gap: var(--s3);
    padding: 2px 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
  }
  .statement-link span:last-child {
    display: grid;
  }
  .statement-link small {
    font-family: var(--font-mono);
  }
  .statement-link:hover b,
  .statement-link:focus-visible b {
    color: var(--brand);
    text-decoration: underline;
    text-underline-offset: 3px;
  }
  .statement-source {
    display: inline-grid;
    place-items: center;
    min-width: 42px;
    padding: 4px 6px;
    border-radius: var(--r-sm);
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    font-weight: 600;
    letter-spacing: 0.08em;
  }
  .statement-source.pdf {
    background: var(--soft);
    border: 1px solid var(--soft-line);
    color: var(--brand-strong);
  }
  .statement-source.ofx {
    background: var(--accent-soft);
    border: 1px solid color-mix(in oklab, var(--accent) 28%, transparent);
    color: var(--accent);
  }
  .statement-checks {
    display: grid;
    gap: var(--s3);
    margin: 0;
    padding: 0;
    list-style: none;
  }
  .statement-check {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    gap: var(--s3);
    padding: var(--s3) var(--s4);
    border: 1px solid var(--line);
    border-left-width: 3px;
    border-radius: var(--r);
    background: var(--surface);
  }
  .statement-check .icon {
    width: 20px;
    height: 20px;
    margin-top: 1px;
    color: var(--muted);
  }
  .statement-check div {
    display: grid;
    gap: 2px;
    min-width: 0;
  }
  .statement-check span {
    color: var(--muted);
    font-size: var(--fs-sm);
    line-height: 1.55;
  }
  .statement-check.ok {
    border-left-color: var(--fill);
  }
  .statement-check.ok > .icon {
    color: var(--positive);
  }
  .statement-check.ko {
    border-left-color: var(--danger);
    background: var(--danger-soft);
  }
  .statement-check.ko > .icon {
    color: var(--danger);
  }
  .statement-check details {
    margin-top: var(--s2);
  }
  .statement-check summary {
    cursor: pointer;
    color: var(--text);
    font-size: var(--fs-sm);
    font-weight: 600;
  }
  .statement-mini {
    display: grid;
    gap: 0;
    margin: var(--s2) 0 0;
    padding: 0;
    list-style: none;
    font-size: var(--fs-sm);
  }
  .statement-mini li {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr) auto;
    gap: var(--s3);
    padding: 7px 0;
    border-top: 1px solid var(--line-soft);
    color: var(--text);
  }
  .statement-mini li:first-child {
    border-top: 0;
  }
  .statement-mini li span {
    color: inherit;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .statement-mini li .muted {
    color: var(--muted);
  }
  .statement-mini.wide {
    margin: 0;
    font-size: var(--fs-base);
  }
  .statement-mini.wide li {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto;
    padding: 9px 0;
  }
  .statement-bar {
    width: 100%;
    min-width: 80px;
    height: 8px;
    border-radius: var(--r-pill);
    background: var(--surface-2);
    overflow: hidden;
  }
  .statement-bar i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--fill);
  }
  .statement-search {
    display: inline-flex;
    align-items: center;
    gap: var(--s2);
    min-height: 38px;
    padding: 0 var(--s3);
    border: 1px solid var(--field-line);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--muted);
  }
  .statement-search:focus-within {
    border-color: var(--fill);
  }
  .statement-search .icon {
    width: 16px;
    height: 16px;
  }
  .statement-search input {
    width: 250px;
    max-width: 100%;
    min-height: 0;
    padding: 0;
    border: 0;
    outline: 0;
    background: none;
    box-shadow: none;
    color: var(--text);
    font: inherit;
  }
  .statement-lines td:nth-child(2) {
    min-width: 240px;
  }
  .statement-result-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s3);
  }
  .statement-result-head b {
    overflow-wrap: anywhere;
  }
  .statement-result p {
    margin: var(--s2) 0;
  }
  .statement-manual {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s3);
    font-size: var(--fs-sm);
  }
  .statement-manual input {
    width: auto;
    min-height: 36px;
  }
  @media (max-width: 760px) {
    .statement-mini li,
    .statement-mini.wide li {
      grid-template-columns: minmax(0, 1fr) auto;
    }
    .statement-mini li span:nth-child(2) {
      grid-column: 1 / -1;
      grid-row: 2;
      white-space: normal;
    }
    .statement-mini:not(.wide) li span:first-child {
      color: var(--muted);
    }
    .statement-search,
    .statement-search input {
      width: 100%;
    }
    .statement-account select {
      max-width: 100%;
    }
  }
}
