/* Invest — feuille de style unique. Charte : static/DA.md.
   Ordre : polices, jetons (clair puis sombre), base, coquille, composants, écrans, impression. */

/* ---------- Polices (servies localement, SIL OFL 1.1) ---------- */
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
  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: "Inter";
  src: url("/static/fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, 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: "Newsreader";
  src: url("/static/fonts/newsreader-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800; font-style: normal; font-display: swap;
  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: "Newsreader";
  src: url("/static/fonts/newsreader-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 200 800; font-style: normal; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, 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;
}

/* ---------- Jetons : clair ---------- */
:root {
  color-scheme: light;
  --font-ui: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Newsreader", "Iowan Old Style", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;

  /* Surfaces : papier chaud, cartes blanches */
  --bg: #f4f3ef;
  --bg-sunk: #ecebe6;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --surface-hover: #f5f4f0;
  --line: #e4e2db;
  --line-strong: #cfccc2;

  /* Encre */
  --ink: #16181b;
  --ink-2: #3c4148;
  --muted: #5f656e;
  --faint: #8b9098;

  /* Accent pétrole */
  --accent: #1d5866;
  --accent-hover: #164956;
  --accent-ink: #ffffff;
  --accent-soft: #e2eef0;
  --accent-line: #b9d3d8;

  /* Sémantique (toujours doublée d'un signe ou d'une icône) */
  --gain: #1a6e4f;
  --gain-soft: #e3f1ea;
  --loss: #a8402b;
  --loss-soft: #f7e7e2;
  --warn: #8a5b00;
  --warn-soft: #f7eed9;
  --info: #2c5b8f;
  --info-soft: #e5edf6;

  /* Catégories : 12 teintes désaturées, lisibles sur les deux fonds */
  --cat-1: #3f6e9e;  --cat-2: #b4733a;  --cat-3: #4f8a6b;  --cat-4: #8a5a9e;
  --cat-5: #b5545b;  --cat-6: #3e8a8f;  --cat-7: #9a8a3a;  --cat-8: #6a6fb3;
  --cat-9: #a0607e;  --cat-10: #5c7f3c; --cat-11: #7d6a58; --cat-12: #7a8590;

  /* Échelle d'espacements (base 4) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px;
  --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px;

  /* Rayons, ombres, mouvements */
  --r-xs: 4px; --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-pill: 999px;
  --shadow-1: 0 1px 0 rgb(20 22 26 / 0.04), 0 1px 2px rgb(20 22 26 / 0.04);
  --shadow-2: 0 1px 2px rgb(20 22 26 / 0.05), 0 8px 24px -12px rgb(20 22 26 / 0.16);
  --shadow-3: 0 24px 64px -24px rgb(20 22 26 / 0.35), 0 2px 6px rgb(20 22 26 / 0.06);
  --focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* Typo */
  --t-xs: 0.75rem; --t-sm: 0.8125rem; --t-base: 0.9375rem; --t-md: 1.0625rem;
  --t-lg: 1.25rem; --t-xl: 1.625rem; --t-2xl: 2.125rem; --t-hero: 2.75rem;

  --mark-bg: #16181b; --mark-fg: #f4f3ef; --mark-dot: #7fc0c9;
  --sidebar-w: 236px;
  --tabbar-h: 62px;
  --sort-bar-h: 70px; /* 44 px de bouton + 2 × 8 px de marge interne + 8 px d'écart + bordure */
}

/* ---------- Jetons : sombre (auto, sauf choix explicite) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1113; --bg-sunk: #0b0c0e; --surface: #16191c; --surface-2: #1b1f23; --surface-hover: #1f2428;
    --line: #272c31; --line-strong: #363c43;
    --ink: #ecebe6; --ink-2: #c7cacd; --muted: #9ba1a9; --faint: #6f757d;
    --accent: #84c2cb; --accent-hover: #a2d3da; --accent-ink: #0d1416; --accent-soft: #15292d; --accent-line: #2c4b51;
    --gain: #63c49b; --gain-soft: #13281f; --loss: #f0927b; --loss-soft: #2e1914;
    --warn: #e3b75c; --warn-soft: #2a2213; --info: #8db6e6; --info-soft: #172331;
    --cat-1: #7ea6d1; --cat-2: #d89c66; --cat-3: #7fbf9b; --cat-4: #b993cb;
    --cat-5: #dc858b; --cat-6: #71bfc3; --cat-7: #c9b866; --cat-8: #9ea2e0;
    --cat-9: #d08fae; --cat-10: #92b56f; --cat-11: #b39d88; --cat-12: #a3adb7;
    --shadow-1: 0 1px 0 rgb(0 0 0 / 0.3);
    --shadow-2: 0 1px 0 rgb(255 255 255 / 0.02) inset, 0 10px 28px -14px rgb(0 0 0 / 0.7);
    --shadow-3: 0 24px 64px -20px rgb(0 0 0 / 0.8);
    --mark-bg: #ecebe6; --mark-fg: #0f1113; --mark-dot: #1d5866;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1113; --bg-sunk: #0b0c0e; --surface: #16191c; --surface-2: #1b1f23; --surface-hover: #1f2428;
  --line: #272c31; --line-strong: #363c43;
  --ink: #ecebe6; --ink-2: #c7cacd; --muted: #9ba1a9; --faint: #6f757d;
  --accent: #84c2cb; --accent-hover: #a2d3da; --accent-ink: #0d1416; --accent-soft: #15292d; --accent-line: #2c4b51;
  --gain: #63c49b; --gain-soft: #13281f; --loss: #f0927b; --loss-soft: #2e1914;
  --warn: #e3b75c; --warn-soft: #2a2213; --info: #8db6e6; --info-soft: #172331;
  --cat-1: #7ea6d1; --cat-2: #d89c66; --cat-3: #7fbf9b; --cat-4: #b993cb;
  --cat-5: #dc858b; --cat-6: #71bfc3; --cat-7: #c9b866; --cat-8: #9ea2e0;
  --cat-9: #d08fae; --cat-10: #92b56f; --cat-11: #b39d88; --cat-12: #a3adb7;
  --shadow-1: 0 1px 0 rgb(0 0 0 / 0.3);
  --shadow-2: 0 1px 0 rgb(255 255 255 / 0.02) inset, 0 10px 28px -14px rgb(0 0 0 / 0.7);
  --shadow-3: 0 24px 64px -20px rgb(0 0 0 / 0.8);
  --mark-bg: #ecebe6; --mark-fg: #0f1113; --mark-dot: #1d5866;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--bg); color: var(--ink);
  font: 400 var(--t-base)/1.5 var(--font-ui);
  font-feature-settings: "cv11", "ss03";
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.2; color: var(--ink); }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-xs); }
::selection { background: var(--accent-soft); color: var(--ink); }
[hidden] { display: none !important; }
.num, table, .tnum { font-variant-numeric: tabular-nums lining-nums; font-feature-settings: "tnum", "lnum", "cv11"; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: var(--s-4); top: -60px; z-index: 100; padding: var(--s-2) var(--s-4);
  background: var(--ink); color: var(--bg); border-radius: var(--r-sm); }
.skip:focus { top: var(--s-4); }
.muted { color: var(--muted); }
.small { font-size: var(--t-sm); }
.xs { font-size: var(--t-xs); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 22px; height: 22px; }

/* ---------- Coquille ---------- */
/* La colonne de la barre latérale est peinte par .shell sur toute la hauteur du document ;
   la barre elle-même reste collée en haut, pleine hauteur d'écran, avec son propre défilement. */
.shell { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); align-items: start;
  background:
    linear-gradient(to right, transparent calc(var(--sidebar-w) - 1px), var(--line) calc(var(--sidebar-w) - 1px), var(--line) var(--sidebar-w), transparent var(--sidebar-w)),
    linear-gradient(to right, var(--surface-2) var(--sidebar-w), transparent var(--sidebar-w)); }
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh; width: var(--sidebar-w); z-index: 20;
  display: flex; flex-direction: column; gap: var(--s-6);
  padding: var(--s-6) var(--s-4) var(--s-4); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface-2); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 var(--s-2); color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand .mark { width: 28px; height: 28px; }
.brand .word { font: 600 1.375rem/1 var(--font-display); letter-spacing: -0.01em; }
.mark .m-bg { fill: var(--mark-bg); }
.mark .m-fg { stroke: var(--mark-fg); fill: none; }
.mark .m-dot { fill: var(--mark-dot); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: var(--t-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); padding: 0 var(--s-3); margin: var(--s-2) 0 var(--s-1); }
.nav a {
  display: flex; align-items: center; gap: var(--s-3); padding: 8px var(--s-3);
  border-radius: var(--r-sm); color: var(--ink-2); font-weight: 500; font-size: var(--t-base);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav a .icon { color: var(--muted); }
.nav a:hover { background: var(--surface-hover); text-decoration: none; color: var(--ink); }
.nav a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line); }
.nav a[aria-current="page"] .icon { color: var(--accent); }
.nav .badge { margin-left: auto; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line); padding-top: var(--s-3); }
.sidebar-foot button { display: flex; align-items: center; gap: var(--s-3); width: 100%; padding: 8px var(--s-3);
  background: none; border: 0; border-radius: var(--r-sm); color: var(--muted); text-align: left; font-size: var(--t-sm); }
.sidebar-foot button:hover { background: var(--surface-hover); color: var(--ink); }

.topbar { display: none; }
.tabbar { display: none; }

.main { min-width: 0; min-height: 100vh; outline: none; }
.page { max-width: 1240px; margin: 0 auto; padding: var(--s-8) var(--s-10) var(--s-16); }
.page.narrow { max-width: 880px; }
.page.wide { max-width: 1440px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-6); }
.page-head h1 { font: 500 var(--t-2xl)/1.1 var(--font-display); letter-spacing: -0.015em; }
.page-head .sub { color: var(--muted); font-size: var(--t-sm); margin-top: 6px; }
.page-head .actions { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
.page-head .actions .select { width: auto; }
.notice a, .kpi .foot span, a.btn { display: inline-flex; align-items: center; gap: 2px; }
.back { display: inline-flex; align-items: center; gap: 4px; font-size: var(--t-sm); color: var(--muted); margin-bottom: var(--s-2); }
.back:hover { color: var(--ink); text-decoration: none; }

@media (max-width: 900px) {
  .shell { display: block; background: none; }
  .sidebar { display: none; }
  .main { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .topbar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
    padding: calc(env(safe-area-inset-top) + 10px) var(--s-4) 10px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--line);
  }
  .topbar .brand .word { font-size: 1.25rem; }
  .topbar .brand .mark { width: 24px; height: 24px; }
  .topbar-actions { display: flex; gap: 2px; }
  .tabbar {
    position: fixed; inset: auto 0 0 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-top: 1px solid var(--line);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--muted); font-size: 0.6875rem; font-weight: 500; position: relative; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a .icon { width: 22px; height: 22px; }
  .tabbar a[aria-current="page"] { color: var(--accent); }
  .tabbar a[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; border-radius: 0 0 2px 2px; background: var(--accent); }
  .tabbar .dot { position: absolute; top: 9px; left: calc(50% + 8px); width: 7px; height: 7px; border-radius: 50%; background: var(--loss); box-shadow: 0 0 0 2px var(--surface); }
  .page { padding: var(--s-5) var(--s-4) var(--s-12); }
  .page-head { margin-bottom: var(--s-5); }
  .page-head h1 { font-size: var(--t-xl); }
}

/* ---------- Boutons, champs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 36px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 500; font-size: var(--t-sm); white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.btn:hover { background: var(--surface-hover); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-hover); }
.btn.danger { color: var(--loss); }
.btn.danger:hover { background: var(--loss-soft); border-color: var(--loss); }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: var(--t-xs); }
.btn.lg { min-height: 44px; padding: 0 18px; font-size: var(--t-base); }
.btn.icon-only { padding: 0; width: 36px; }
.btn.icon-only.sm { width: 30px; }
.btn.block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .field > label { font-size: var(--t-sm); font-weight: 500; color: var(--ink-2); }
.field .hint { font-size: var(--t-xs); color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 38px; padding: 8px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--muted); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.sm, .select.sm { min-height: 32px; padding: 4px 8px; font-size: var(--t-sm); }
.input.num { text-align: right; }
.select.sm { padding-right: 28px; background-position: calc(100% - 14px) 55%, calc(100% - 9px) 55%; }
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.check { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--t-sm); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg-sunk); border-radius: var(--r-md); border: 1px solid var(--line); }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; font-size: var(--t-sm); font-weight: 500; color: var(--muted); min-height: 30px; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }

.switch { display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; font-size: var(--t-sm); user-select: none; }
.switch input { appearance: none; width: 36px; height: 20px; border-radius: 999px; background: var(--line-strong); position: relative; margin: 0; flex: none; transition: background .15s var(--ease); cursor: pointer; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgb(0 0 0 / .25); transition: transform .18s var(--ease); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }
.switch input:focus-visible { box-shadow: var(--focus); }

/* ---------- Cartes, KPI ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); min-width: 0; }
.card-pad { padding: var(--s-5); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-5) 0; }
.card-head h2, .section-title { font-size: var(--t-base); font-weight: 600; letter-spacing: -0.005em; }
.card-head .meta { font-size: var(--t-xs); color: var(--muted); }
.card-body { padding: var(--s-4) var(--s-5) var(--s-5); }
.card-foot { padding: var(--s-3) var(--s-5); border-top: 1px solid var(--line); font-size: var(--t-sm); display: flex; justify-content: space-between; gap: var(--s-3); }
.section { margin-top: var(--s-8); }
.section-sm { margin-top: var(--s-3); }
.show-sm { display: none; }
@media (max-width: 760px) { .table .show-sm { display: block; } }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); flex-wrap: wrap; }
.section-head h2 { font: 500 var(--t-lg)/1.2 var(--font-display); letter-spacing: -0.01em; }

.grid { display: grid; gap: var(--s-4); grid-template-columns: minmax(0, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.split { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.split { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }
@media (max-width: 420px) { .grid.cols-4 { grid-template-columns: 1fr 1fr; gap: var(--s-3); } }

.kpi { padding: var(--s-4) var(--s-5); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi .label { font-size: var(--t-xs); font-weight: 500; color: var(--muted); letter-spacing: .02em; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: var(--t-xl); font-weight: 550; letter-spacing: -0.02em; line-height: 1.1; white-space: nowrap; }
.kpi .foot { font-size: var(--t-xs); color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kpi .spark { margin-top: auto; }
a.kpi, a.card { color: inherit; transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
a.card:hover { text-decoration: none; border-color: var(--line-strong); box-shadow: var(--shadow-2); }
@media (max-width: 420px) { .kpi { padding: var(--s-3) var(--s-4); } .kpi .value { font-size: var(--t-lg); } }

.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: var(--s-8); padding: var(--s-6); align-items: center; }
.hero .eyebrow { font-size: var(--t-xs); color: var(--muted); font-weight: 500; letter-spacing: .06em; text-transform: uppercase; }
.hero .big { font-size: var(--t-hero); font-weight: 500; letter-spacing: -0.035em; line-height: 1; margin: 10px 0 10px; white-space: nowrap; }
.hero .big .cents { color: var(--faint); font-weight: 400; }
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; gap: var(--s-5); padding: var(--s-5); } .hero .big { font-size: 2.25rem; } }

/* Barre de composition (patrimoine) */
.stack { display: flex; height: 10px; border-radius: 999px; overflow: hidden; gap: 2px; background: var(--bg-sunk); }
.stack > span { display: block; height: 100%; flex: 0 0 auto; width: var(--w, 0%); background: var(--c, var(--accent)); }
.stack > span.neg { background: repeating-linear-gradient(135deg, var(--loss) 0 3px, color-mix(in srgb, var(--loss) 55%, transparent) 3px 6px); }
.legend { display: grid; gap: 8px var(--s-5); grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: var(--s-4); }
.legend .item { display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: var(--t-sm); }
.legend .item .lbl { color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend .item .val { font-weight: 500; white-space: nowrap; }
.swatch { width: 9px; height: 9px; border-radius: 3px; flex: none; background: var(--c, var(--accent)); transform: translateY(-1px); }
.swatch.neg { background: var(--loss); }

/* Couleurs de catégories (classes cN posées par le JS) */
.c1 { --c: var(--cat-1); } .c2 { --c: var(--cat-2); } .c3 { --c: var(--cat-3); } .c4 { --c: var(--cat-4); }
.c5 { --c: var(--cat-5); } .c6 { --c: var(--cat-6); } .c7 { --c: var(--cat-7); } .c8 { --c: var(--cat-8); }
.c9 { --c: var(--cat-9); } .c10 { --c: var(--cat-10); } .c11 { --c: var(--cat-11); } .c12 { --c: var(--cat-12); }
.c-accent { --c: var(--accent); } .c-gain { --c: var(--gain); } .c-loss { --c: var(--loss); } .c-muted { --c: var(--line-strong); }
.c-ink { --c: var(--ink-2); }

/* ---------- Puces, badges, deltas ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 2px 9px 2px 7px; border-radius: var(--r-pill);
  font-size: var(--t-xs); font-weight: 500; line-height: 18px; white-space: nowrap;
  background: color-mix(in srgb, var(--c, var(--muted)) 13%, var(--surface)); color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--c, var(--muted)) 28%, transparent); }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--muted)); flex: none; }
.chip > span { overflow: hidden; text-overflow: ellipsis; }
.chip.todo { background: transparent; border-style: dashed; border-color: var(--line-strong); color: var(--muted); }
.chip.todo::before { background: transparent; border: 1.5px solid var(--faint); width: 6px; height: 6px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: var(--r-pill); font-size: var(--t-xs); font-weight: 600; line-height: 18px; background: var(--bg-sunk); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.badge.gain { background: var(--gain-soft); color: var(--gain); border-color: transparent; }
.badge.loss { background: var(--loss-soft); color: var(--loss); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.count { background: var(--ink); color: var(--bg); border-color: transparent; min-width: 20px; justify-content: center; padding: 0 6px; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 500; white-space: nowrap; }
.delta svg { width: 8px; height: 8px; fill: currentColor; }
.delta.up { color: var(--gain); }
.delta.down { color: var(--loss); }
.delta.flat { color: var(--muted); }
.kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px;
  font: 600 11px/1 var(--font-ui); color: var(--ink-2); background: var(--surface); border: 1px solid var(--line-strong); box-shadow: 0 1px 0 var(--line-strong); text-transform: uppercase; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.table th { text-align: left; font-size: var(--t-xs); font-weight: 500; color: var(--muted); padding: 10px var(--s-3); border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--surface); }
.table td { padding: 10px var(--s-3); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table th:first-child, .table td:first-child { padding-left: var(--s-5); }
.table th:last-child, .table td:last-child { padding-right: var(--s-5); }
.table .r { text-align: right; white-space: nowrap; }
.table .c { text-align: center; }
.table .strong { font-weight: 600; }
.table .sub { display: block; font-size: var(--t-xs); color: var(--muted); margin-top: 1px; }
.table tfoot td { font-weight: 600; border-top: 1px solid var(--line-strong); border-bottom: 0; background: var(--surface-2); }
.table .ellipsis { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table.compact td { padding-top: 7px; padding-bottom: 7px; }
@media (max-width: 760px) {
  .table .hide-sm { display: none; }
  .table th:first-child, .table td:first-child { padding-left: var(--s-4); }
  .table th:last-child, .table td:last-child { padding-right: var(--s-4); }
  .table td, .table th { padding-left: 8px; padding-right: 8px; }
}
@media (max-width: 1100px) { .table .hide-md { display: none; } }

/* Liste sobre */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: var(--s-3); padding: 10px var(--s-5); border-bottom: 1px solid var(--line); min-width: 0; }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .meta { font-size: var(--t-xs); color: var(--muted); }

/* ---------- Graphiques ---------- */
.chart { width: 100%; height: auto; overflow: visible; }
.chart text { font: 500 10.5px var(--font-ui); fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-zero { stroke: var(--line-strong); }
.chart .bar-rev { fill: var(--accent); }
.chart .bar-dep { fill: var(--cat-2); }
.chart .bar-ep { fill: var(--cat-8); }
.chart .bar-hover { fill: transparent; }
.chart .bar-hover:hover { fill: color-mix(in srgb, var(--ink) 5%, transparent); }
.chart .arc { fill: none; stroke: var(--c, var(--accent)); }
.chart .track { fill: none; stroke: var(--bg-sunk); }
.chart .target-ring { fill: none; stroke: var(--c, var(--accent)); opacity: .45; }
.chart .spark-line { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .spark-area { fill: var(--accent); opacity: .08; }
.chart .spark-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .center-big { font: 600 15px var(--font-ui); fill: var(--ink); }
.chart .center-small { font: 500 10px var(--font-ui); fill: var(--muted); }
.chart-legend { display: flex; gap: var(--s-4); flex-wrap: wrap; font-size: var(--t-xs); color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Jauge avec repère de cible */
.meter { position: relative; height: 6px; border-radius: 999px; background: var(--bg-sunk); }
.meter > .fill { position: absolute; inset: 0 auto 0 0; width: var(--w, 0%); border-radius: 999px; background: var(--c, var(--accent)); }
.meter > .fill.over { background: var(--warn); }
.meter > .mark { position: absolute; top: -4px; bottom: -4px; left: var(--x, 0%); width: 2px; margin-left: -1px; border-radius: 1px; background: var(--ink); }

.alloc { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: var(--s-5); align-items: center; }
.alloc > .chart { width: 148px; height: 148px; }
.chart.spark { width: auto; max-width: 100%; }
.alloc-rows { display: flex; flex-direction: column; gap: 12px; }
.alloc-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px var(--s-3); align-items: baseline; font-size: var(--t-sm); }
.alloc-row .name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.alloc-row .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alloc-row .meter { grid-column: 1 / -1; }
.alloc-row .vals { white-space: nowrap; color: var(--muted); font-size: var(--t-xs); }
.alloc-row .vals strong { color: var(--ink); font-weight: 600; font-size: var(--t-sm); }
@media (max-width: 480px) { .alloc { grid-template-columns: 1fr; justify-items: center; } .alloc-rows { width: 100%; } .legend { grid-template-columns: 1fr; } }

/* ---------- États ---------- */
.state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: var(--s-3); padding: var(--s-12) var(--s-6); color: var(--muted); }
.state .glyph { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--bg-sunk); color: var(--muted); border: 1px solid var(--line); }
.state .glyph.ok { background: var(--gain-soft); color: var(--gain); border-color: transparent; }
.state .glyph.err { background: var(--loss-soft); color: var(--loss); border-color: transparent; }
.state h3 { color: var(--ink); font: 500 var(--t-lg)/1.2 var(--font-display); }
.state p { max-width: 42ch; font-size: var(--t-sm); }
.state.compact { padding: var(--s-8) var(--s-4); }
.skel { position: relative; overflow: hidden; background: var(--bg-sunk); border-radius: var(--r-sm); }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 60%, transparent), transparent);
  animation: shimmer 1.4s infinite; }
.skel.line { height: 12px; margin: 8px 0; }
.skel.block { height: 120px; }
.skel.kpi { height: 92px; border-radius: var(--r-lg); }
@keyframes shimmer { to { transform: translateX(100%); } }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.notice { display: flex; gap: var(--s-3); align-items: flex-start; padding: 12px var(--s-4); border-radius: var(--r-md); font-size: var(--t-sm); border: 1px solid var(--line); background: var(--surface); }
.notice .icon { margin-top: 1px; }
.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.notice.warn .icon { color: var(--warn); }
.notice.crit { background: var(--loss-soft); border-color: color-mix(in srgb, var(--loss) 25%, transparent); }
.notice.crit .icon { color: var(--loss); }
.notice.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 22%, transparent); }
.notice.info .icon { color: var(--info); }
.notice .grow { flex: 1; min-width: 0; }
.notices { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-5); }

/* Toast */
.toasts { position: fixed; z-index: 90; left: 50%; bottom: var(--s-6); transform: translateX(-50%); display: flex; flex-direction: column; gap: var(--s-2); align-items: center; pointer-events: none; width: min(560px, calc(100vw - 32px)); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: var(--s-3); padding: 10px 10px 10px var(--s-4); border-radius: var(--r-md);
  background: var(--ink); color: var(--bg); font-size: var(--t-sm); box-shadow: var(--shadow-3); animation: toast-in .22s var(--ease); max-width: 100%; }
.toast .grow { flex: 1; min-width: 0; }
.toast .btn { background: transparent; color: var(--bg); border-color: color-mix(in srgb, var(--bg) 30%, transparent); }
.toast .btn:hover { background: color-mix(in srgb, var(--bg) 12%, transparent); }
.toast.error { background: var(--loss); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (max-width: 900px) { .toasts { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px); } }

/* Dialogues */
dialog.modal { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0; width: min(620px, calc(100vw - 24px)); max-height: calc(100dvh - 48px);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-3); }
dialog.modal::backdrop { background: rgb(10 12 14 / .42); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-5) var(--s-6) 0; }
.modal-head h2 { font: 500 var(--t-lg)/1.2 var(--font-display); }
.modal-body { padding: var(--s-5) var(--s-6); display: flex; flex-direction: column; gap: var(--s-4); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-4) var(--s-6); border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.form-error { color: var(--loss); font-size: var(--t-sm); display: flex; gap: 6px; align-items: center; }

/* ---------- Tableau de bord ---------- */
.dash-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(12, minmax(0, 1fr)); }
.dash-grid > .span-12 { grid-column: span 12; } .dash-grid > .span-8 { grid-column: span 8; }
.dash-grid > .span-7 { grid-column: span 7; } .dash-grid > .span-6 { grid-column: span 6; }
.dash-grid > .span-5 { grid-column: span 5; } .dash-grid > .span-4 { grid-column: span 4; }
@media (max-width: 1100px) { .dash-grid > .span-8, .dash-grid > .span-7, .dash-grid > .span-5, .dash-grid > .span-4 { grid-column: span 12; } .dash-grid > .span-6 { grid-column: span 6; } }
@media (max-width: 760px) { .dash-grid > .span-6 { grid-column: span 12; } }
.budget-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px var(--s-3); align-items: baseline; }
.budget-line .meter { grid-column: 1 / -1; height: 8px; }
.fresh-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gain); flex: none; }
.fresh-dot.stale { background: transparent; border: 2px solid var(--warn); }

/* ---------- Thèses ---------- */
.thesis-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); }
.thesis { display: flex; flex-direction: column; gap: var(--s-4); padding: var(--s-5); }
.thesis-top { display: flex; justify-content: space-between; gap: var(--s-3); align-items: flex-start; }
.thesis-top h3 { font-size: var(--t-md); font-weight: 600; }
.thesis-top .tick { font-size: var(--t-xs); color: var(--muted); margin-top: 2px; }
.thesis .price { text-align: right; }
.thesis .price .v { font-size: var(--t-md); font-weight: 600; }
.thesis-text { font-size: var(--t-sm); color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.thesis-text.open { display: block; }
.thesis .more { align-self: flex-start; padding-left: 0; margin-top: calc(-1 * var(--s-3)); }
.thesis-meta { display: flex; gap: var(--s-2) var(--s-4); flex-wrap: wrap; font-size: var(--t-xs); color: var(--muted); }
.thesis-meta b { color: var(--ink-2); font-weight: 500; }
.thesis-actions { display: flex; gap: var(--s-2); margin-top: auto; padding-top: var(--s-2); border-top: 1px solid var(--line); }
.rail { position: relative; padding: 18px 0 22px; }
.rail .line { position: relative; height: 4px; border-radius: 999px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--loss) 55%, var(--surface)), var(--bg-sunk) 35%, var(--bg-sunk) 65%, color-mix(in srgb, var(--gain) 55%, var(--surface))); }
.rail .pin { position: absolute; top: 50%; left: var(--x, 50%); transform: translate(-50%, -50%); }
.rail .pin.now { width: 14px; height: 14px; border-radius: 50%; background: var(--ink); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--ink); }
.rail .pin.entry { width: 2px; height: 14px; background: var(--muted); border-radius: 1px; }
.rail .lbl { position: absolute; font-size: 10.5px; color: var(--muted); white-space: nowrap; transform: translateX(-50%); left: var(--x, 50%); }
.rail .lbl.top { top: 0; }
.rail .lbl.bottom { bottom: 0; }
.rail .lbl.start { transform: none; left: 0; }
.rail .lbl.end { transform: none; left: auto; right: 0; }
.dist { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.dist > div { padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); font-size: var(--t-xs); color: var(--muted); }
.dist strong { display: flex; align-items: center; gap: 4px; font-size: var(--t-base); color: var(--ink); font-weight: 600; }
.dist .near strong { color: var(--loss); }
.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--line); margin-bottom: var(--s-5); overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 4px; margin-right: var(--s-4); font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.verdict { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* ---------- Discussion ---------- */
.chat { display: grid; grid-template-columns: 300px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.chat-list { border-right: 1px solid var(--line); background: var(--surface-2); display: flex; flex-direction: column; min-height: 0; }
.chat-list-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-6) var(--s-4) var(--s-3) var(--s-5); }
.chat-list-head h1 { font: 500 var(--t-xl)/1.1 var(--font-display); }
.convs { list-style: none; margin: 0; padding: 0 var(--s-2) var(--s-4); overflow-y: auto; flex: 1; }
.convs a { display: block; padding: 10px var(--s-3); border-radius: var(--r-sm); color: var(--ink); }
.convs a:hover { background: var(--surface-hover); text-decoration: none; }
.convs a[aria-current="page"] { background: var(--surface); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line); }
.convs .t { display: flex; justify-content: space-between; gap: var(--s-2); font-weight: 500; font-size: var(--t-sm); }
.convs .t span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convs .t time { color: var(--muted); font-size: var(--t-xs); font-weight: 400; flex: none; }
.convs .p { font-size: var(--t-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.thread { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.thread-head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-6); border-bottom: 1px solid var(--line); background: var(--bg); min-height: 64px; }
.thread-head .back-btn { display: none; }
.thread-head h2 { font-size: var(--t-md); font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.messages { flex: 1; overflow-y: auto; padding: var(--s-6) var(--s-6) var(--s-4); display: flex; flex-direction: column; gap: var(--s-5); }
.messages > .inner { max-width: 760px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: var(--s-5); }
.msg { display: flex; gap: var(--s-3); max-width: 100%; }
.msg .av { width: 28px; height: 28px; flex: none; }
.msg .av svg { width: 28px; height: 28px; }
.msg .body { min-width: 0; flex: 1; }
.msg .who { font-size: var(--t-xs); color: var(--muted); margin-bottom: 4px; display: flex; gap: var(--s-2); }
.msg.user { justify-content: flex-end; }
.msg.user > div { max-width: min(560px, 88%); }
.msg.user .bubble { background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--ink); padding: 10px 14px; border-radius: 14px 14px 4px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user .time { text-align: right; font-size: var(--t-xs); color: var(--muted); margin-top: 4px; }
.msg.system .bubble { font-size: var(--t-xs); color: var(--muted); text-align: center; width: 100%; }
.msg.error .md { color: var(--loss); }
.typing { display: inline-flex; gap: 4px; align-items: center; padding: 8px 0; color: var(--muted); font-size: var(--t-sm); }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
.composer { padding: var(--s-3) var(--s-6) var(--s-5); background: var(--bg); }
.composer form { max-width: 760px; margin: 0 auto; display: flex; align-items: flex-end; gap: var(--s-2); padding: 8px 8px 8px 14px; border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-2); }
.composer form:focus-within { border-color: var(--accent); }
.composer textarea:focus-visible { box-shadow: none; }
.composer textarea { flex: 1; border: 0; background: transparent; resize: none; min-height: 24px; max-height: 200px; padding: 6px 0; line-height: 1.5; outline: none; }
.composer-opts { max-width: 760px; margin: 0 auto 6px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-2); }
.composer-opts[hidden] { display: none; }
.composer-opts .select { width: auto; max-width: 100%; }
.msg .who .who-model { margin-left: auto; color: var(--muted); }
.composer .hint { max-width: 760px; margin: 6px auto 0; font-size: var(--t-xs); color: var(--muted); text-align: center; }
.suggest { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: center; margin-top: var(--s-4); }
.suggest button { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-pill); padding: 6px 12px; font-size: var(--t-sm); color: var(--ink-2); }
.suggest button:hover { border-color: var(--accent-line); color: var(--ink); }
@media (max-width: 900px) {
  .chat { grid-template-columns: 1fr; height: calc(100dvh - var(--tabbar-h) - env(safe-area-inset-bottom) - 57px); }
  .chat.has-thread .chat-list { display: none; }
  .chat:not(.has-thread) .thread { display: none; }
  .chat-list { border-right: 0; background: var(--bg); }
  .chat-list-head { padding: var(--s-5) var(--s-4) var(--s-3); }
  .thread-head { padding: var(--s-3) var(--s-4); min-height: 52px; }
  .thread-head .back-btn { display: inline-flex; }
  .messages { padding: var(--s-4); }
  .composer { padding: var(--s-2) var(--s-3) var(--s-3); }
  .composer .hint { display: none; }
}

/* Markdown rendu */
.md { font-size: var(--t-base); line-height: 1.6; color: var(--ink); overflow-wrap: anywhere; }
.md > * + * { margin-top: 0.7em; }
.md ul, .md ol { padding-left: 1.3em; margin-bottom: 0; }
.md li + li { margin-top: 0.2em; }
.md code { font-family: var(--font-mono); font-size: 0.86em; padding: 1px 5px; border-radius: 4px; background: var(--bg-sunk); border: 1px solid var(--line); }
.md h3, .md h4 { font-size: var(--t-base); font-weight: 600; margin-top: 1.1em; }
.md table { border-collapse: collapse; font-size: var(--t-sm); display: block; overflow-x: auto; max-width: 100%; }
.md th, .md td { border-bottom: 1px solid var(--line); padding: 6px 12px 6px 0; text-align: left; }
.md th { font-weight: 600; color: var(--muted); font-size: var(--t-xs); }
.md td.r, .md th.r { text-align: right; }
.md blockquote { margin: 0; padding-left: var(--s-3); border-left: 2px solid var(--line-strong); color: var(--ink-2); }

/* ---------- Dépenses ---------- */
.toolbar { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: center; margin-bottom: var(--s-5); }
.toolbar .grow { flex: 1; }
.toolbar-group { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.toolbar .input, .toolbar .select { width: auto; }
.acct-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.acct-chips button { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-pill); padding: 4px 10px; font-size: var(--t-xs); color: var(--muted); }
.acct-chips button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.cat-bars { display: flex; flex-direction: column; margin-top: var(--s-3); }
.cat-bar { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr) 96px 52px; gap: var(--s-3); align-items: center; padding: 9px var(--s-5); border-bottom: 1px solid var(--line); font-size: var(--t-sm); }
.cat-bar:last-child { border-bottom: 0; }
.cat-bar .meter { height: 6px; }
.cat-bar .amt { text-align: right; font-weight: 500; }
.cat-bar .share { text-align: right; color: var(--muted); font-size: var(--t-xs); }
@media (max-width: 760px) { .cat-bar { grid-template-columns: minmax(0, 1fr) auto; padding: 10px var(--s-4); } .cat-bar .meter { grid-column: 1 / -1; grid-row: 2; } .cat-bar .share { display: none; } }

/* Mode tri */
.sort { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--s-5); align-items: start; }
.sort-card { padding: var(--s-6); display: flex; flex-direction: column; gap: var(--s-4); }
.sort-card .tiers { font: 500 var(--t-2xl)/1.1 var(--font-display); letter-spacing: -0.015em; overflow-wrap: anywhere; }
.sort-card .amount { font-size: var(--t-xl); font-weight: 600; letter-spacing: -0.02em; }
.sort-card .sample { font-family: var(--font-mono); font-size: var(--t-xs); color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); padding: 8px 10px; border-radius: var(--r-sm); overflow-wrap: anywhere; }
.sort-progress { display: flex; align-items: center; gap: var(--s-3); font-size: var(--t-sm); color: var(--muted); }
.sort-progress .meter { flex: 1; }
.cat-keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.cat-group-title { font-size: var(--t-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: var(--s-4) 0 var(--s-2); }
.cat-group-title:first-child { margin-top: 0; }
.cat-key { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 10px 6px 6px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); text-align: left; font-size: var(--t-sm); color: var(--ink); transition: border-color .12s var(--ease), background .12s var(--ease), transform .08s var(--ease); }
.cat-key:hover { border-color: var(--c, var(--line-strong)); background: color-mix(in srgb, var(--c, var(--muted)) 7%, var(--surface)); }
.cat-key:active { transform: scale(.98); }
.cat-key .kbd { flex: none; }
.cat-key .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.cat-key .lbl { flex: 1; min-width: 0; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cat-key.suggested { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cat-key.flash { background: color-mix(in srgb, var(--c) 22%, var(--surface)); }
.sort-side { display: flex; flex-direction: column; gap: var(--s-4); position: sticky; top: var(--s-6); }
.keys-card h2 { margin-bottom: var(--s-3); }
.keys-help { font-size: var(--t-xs); color: var(--muted); display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; align-items: center; }
.sort-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.sort-bar { display: none; }
@media (max-width: 1000px) {
  .sort { grid-template-columns: 1fr; }
  .sort-side { position: static; }
  .sort-side .keys-card { display: none; }
}
@media (max-width: 900px) {
  .sort-card { padding: var(--s-5); gap: var(--s-3); }
  .sort-card .tiers { font-size: var(--t-xl); }
  .cat-keys { grid-template-columns: 1fr 1fr; }
  .cat-key { min-height: 48px; }
  .cat-key .kbd { display: none; }
  .sort-actions.desk { display: none; }
  /* Barre d'actions fixe au-dessus des onglets ; la page réserve sa hauteur pour que les
     dernières catégories restent atteignables. */
  .page.sorting { padding-bottom: calc(var(--sort-bar-h) + var(--s-6)); }
  .sort-bar { display: flex; gap: var(--s-2); position: fixed; left: var(--s-3); right: var(--s-3); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); z-index: 25; padding: 8px;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-2); }
  .sort-bar .btn { flex: 1; min-height: 44px; }
}

/* ---------- Partages ---------- */
.part-list { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.part-card { padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-3); }
.part-card h3 { font: 500 var(--t-lg)/1.2 var(--font-display); }
.part-card .owe { font-size: var(--t-sm); color: var(--ink-2); }
.part-card .owe strong { font-size: var(--t-md); }
.owe-band { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-5); align-items: center; padding: var(--s-6); }
.owe-band .sentence { font: 500 var(--t-2xl)/1.15 var(--font-display); letter-spacing: -0.015em; }
.owe-band .sentence .amt { color: var(--accent); white-space: nowrap; }
.owe-band .sentence.even { color: var(--muted); }
.totals { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.totals > div { padding: var(--s-4) var(--s-5); border-right: 1px solid var(--line); min-width: 0; }
.totals > div:last-child { border-right: 0; }
.totals .l { font-size: var(--t-xs); color: var(--muted); }
.totals .v { font-size: var(--t-md); font-weight: 600; margin-top: 2px; white-space: nowrap; }
@media (max-width: 900px) {
  .owe-band { grid-template-columns: 1fr; padding: var(--s-5); gap: var(--s-3); }
  .owe-band .sentence { font-size: var(--t-xl); }
  .totals { grid-template-columns: 1fr 1fr; }
  .totals > div { border-bottom: 1px solid var(--line); }
  .totals > div:nth-child(2n) { border-right: 0; }
  .totals > div:last-child { grid-column: 1 / -1; border-bottom: 0; }
}
.models { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-3); }
.model { display: flex; flex-direction: column; gap: 6px; padding: var(--s-4); border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); text-align: left; cursor: pointer; }
.model:hover { border-color: var(--line-strong); }
.model[aria-checked="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.model .icon { color: var(--accent); }
.model b { font-weight: 600; }
.model span { font-size: var(--t-xs); color: var(--muted); }
@media (max-width: 600px) { .models { grid-template-columns: 1fr; } }
.steps { display: flex; gap: var(--s-2); margin-bottom: var(--s-5); counter-reset: step; }
.steps li { list-style: none; flex: 1; font-size: var(--t-xs); color: var(--muted); padding-top: 8px; border-top: 2px solid var(--line); }
.steps li[aria-current="step"], .steps li.done { color: var(--ink); border-top-color: var(--accent); }
.steps { padding: 0; margin-top: 0; }
.range-row { display: flex; align-items: center; gap: var(--s-3); }
.range-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.range-row output { min-width: 64px; text-align: right; font-weight: 600; }
.lines .input.sm, .lines .select.sm { min-width: 0; }
.lines td.edit { padding-top: 5px; padding-bottom: 5px; }
.lines .pct { width: 72px; }
.lines .who { width: 118px; }
.lines .cmt { min-width: 140px; }
.lines tr.offert td:not(.keep) { color: var(--muted); }
.lines tr.offert .amt { text-decoration: line-through; text-decoration-color: var(--muted); }
.sugg-list { max-height: 420px; overflow-y: auto; }
.sugg-list label { display: grid; grid-template-columns: auto 88px minmax(0, 1fr) auto; gap: var(--s-3); align-items: center; padding: 8px var(--s-5); border-bottom: 1px solid var(--line); font-size: var(--t-sm); cursor: pointer; }
.sugg-list label:hover { background: var(--surface-2); }
.sugg-list input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.sugg-list .lbl { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sugg-list .lbl > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sugg-list .lbl .sub { font-size: var(--t-xs); color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.sugg-list label.elsewhere { background: var(--surface-2); }
.sugg-group + .sugg-group { border-top: 1px solid var(--line); }
.sugg-group > .section-title { padding: var(--s-3) var(--s-5) var(--s-2); margin: 0; }
.lines .lbl-cell { max-width: 320px; }
.lines .lbl-cell .ellipsis { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avoir { color: var(--gain); }
.alloc-quiet { border-top: 1px solid var(--line); padding-top: var(--s-3); }
@media (max-width: 600px) { .sugg-list label { grid-template-columns: auto minmax(0, 1fr) auto; padding: 10px var(--s-4); } .sugg-list .d { display: none; } }
.link-box { display: flex; gap: var(--s-2); align-items: center; padding: 8px 8px 8px 12px; border: 1px dashed var(--accent-line); border-radius: var(--r-sm); background: var(--accent-soft); }
.link-box code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: var(--t-xs); }
.edit-line-mobile { display: none; }
@media (max-width: 760px) {
  .lines-table { display: none; }
  .edit-line-mobile { display: block; }
  .mline { padding: var(--s-4); border-bottom: 1px solid var(--line); display: grid; gap: var(--s-2); }
  .mline:last-child { border-bottom: 0; }
  .mline .top { display: flex; justify-content: space-between; gap: var(--s-3); }
  .mline .top .lbl { font-weight: 500; overflow-wrap: anywhere; }
  .mline .ctrls { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }
}

/* ---------- Connexion et page publique ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: var(--s-6) var(--s-4); }
.auth-card { width: min(400px, 100%); padding: var(--s-8); display: flex; flex-direction: column; gap: var(--s-5); }
.auth-card .brand { padding: 0; }
.auth-card .brand .mark { width: 34px; height: 34px; }
.auth-card .brand .word { font-size: 1.75rem; }
.auth-card h1 { font: 500 var(--t-lg)/1.3 var(--font-display); color: var(--ink-2); }
.auth-foot { display: flex; justify-content: center; align-items: center; gap: 6px; text-align: center; font-size: var(--t-xs); color: var(--muted); margin-top: var(--s-4); }
.public-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); padding: var(--s-5) 0; border-bottom: 1px solid var(--line); margin-bottom: var(--s-6); }
.public .page { padding-top: 0; }

/* Thème : bouton bascule */
.theme-ico-dark { display: none; }
:root[data-theme="dark"] .theme-ico-dark { display: block; }
:root[data-theme="dark"] .theme-ico-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-ico-dark { display: block; }
  :root:not([data-theme="light"]) .theme-ico-light { display: none; }
}

/* ---------- Mouvement réduit ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---------- Impression (partages et rapport) ---------- */
.print-only { display: none; }
@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #fff; --ink: #000; --ink-2: #222; --muted: #555; --line: #ccc; --line-strong: #999; --accent: #1d5866; color-scheme: light; }
  body { background: #fff; font-size: 10.5pt; }
  .sidebar, .topbar, .tabbar, .toasts, .no-print, .btn, .page-head .actions, .back { display: none !important; }
  .print-only { display: block; }
  .shell { display: block; }
  .main { margin: 0; padding: 0; }
  .page { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #bbb; break-inside: avoid; }
  .lines-table { display: block !important; }
  .edit-line-mobile { display: none !important; }
  .table th { position: static; }
  .lines input, .lines select { border: 0; padding: 0; min-height: 0; background: none; appearance: none; }
  .owe-band .sentence { font-size: 18pt; }
  .totals { grid-template-columns: repeat(5, 1fr) !important; }
  .totals > div { border-bottom: 0 !important; border-right: 1px solid #ccc !important; }
  a { color: inherit; }
  @page { margin: 14mm; }
}

/* Hub de thèses */
.prop-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.prop-head .small { max-width: 640px; }
.prop .prop-more summary { cursor: pointer; font-size: var(--t-sm); color: var(--muted); }
.prop .prop-more p { margin: 6px 0 0; }

.link-box { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.link-box .link-url { flex: 1 1 220px; min-width: 0; font-family: var(--font-mono, monospace); font-size: var(--t-xs); }
