/* ==========================================================================
   WAKAKASH — Design System v1
   Move your money forward.
   --------------------------------------------------------------------------
   1. Tokens (light / dark)        6. Composants financiers
   2. Base & typographie           7. App shell (sidebar / rail / bottom bar)
   3. Layout utilitaires           8. Bottom sheet "Ajout rapide"
   4. Boutons, inputs, badges      9. États (skeleton, empty, toast, offline)
   5. Cartes & listes             10. Responsive
   ========================================================================== */

/* 1. TOKENS ------------------------------------------------------------- */
:root {
  /* Marque (issue du logo) */
  --brand: #FF7200;            /* orange Wakakash — actions, progression */
  --brand-hover: #F26500;
  --brand-ink: #B34D00;        /* orange lisible pour du texte sur fond clair (5.3:1) */
  --brand-soft: #FFF1E5;
  --brand-soft-2: #FFE2C7;
  --on-brand: #1A1C1B;         /* texte sur orange : anthracite (6.3:1) */
  --anthracite: #464946;       /* gris du logo */

  /* Neutres */
  --bg: #F6F5F0;               /* blanc cassé chaud */
  --surface: #FFFFFF;
  --surface-2: #F0EFE9;
  --surface-3: #E7E5DE;
  --text: #1C1E1D;
  --text-2: #565A57;           /* muted (7:1) */
  --text-3: #74787A;           /* caption (4.5:1) */
  --border: #E5E3DC;
  --border-strong: #D2CFC6;
  --nav-bg: #1C1E1D;           /* sidebar desktop : anthracite */
  --nav-text: #D9DAD6;

  /* Sémantique */
  --success: #15803D;  --success-soft: #E6F4EA;
  --warning: #A55A00;  --warning-soft: #FFF4DB;
  --error:   #C0362C;  --error-soft:   #FCEBE9;
  --info:    #2458D6;  --info-soft:    #E8EFFD;

  /* Types de flux — la logique financière rendue visible */
  --t-income: #15803D;         /* Revenu : entre réellement */
  --t-expense: #1C1E1D;        /* Dépense : neutre, jamais rouge culpabilisant */
  --t-saving: #FF7200;         /* Épargne : progression (couleur de marque) */
  --t-invest: #0F7B72;         /* Investissement */
  --t-debt: #6E48C9;           /* Dette : ni revenu, ni dépense */
  --t-transfer: #6B6F6C;       /* Transfert : neutre */

  --chart-1: #FF7200; --chart-2: #464946; --chart-3: #F7B27A; --chart-4: #A7AAA6; --chart-5: #0F7B72;

  /* Typo */
  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-display: clamp(2.5rem, 5.2vw, 4.25rem);
  --fs-h1: clamp(1.75rem, 3vw, 2.25rem);
  --fs-h2: clamp(1.375rem, 2.2vw, 1.75rem);
  --fs-h3: 1.125rem;
  --fs-body: 1rem;
  --fs-sm: .875rem;
  --fs-xs: .75rem;
  --fs-amount-xl: clamp(2.25rem, 6vw, 3rem);

  /* Espacement (base 4) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px; --s16: 64px; --s24: 96px;

  /* Rayons */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px; --r-2xl: 28px; --r-pill: 999px;

  /* Ombres (subtiles) */
  --sh-1: 0 1px 2px rgba(28,30,29,.05);
  --sh-2: 0 1px 2px rgba(28,30,29,.04), 0 8px 24px -12px rgba(28,30,29,.12);
  --sh-3: 0 24px 60px -20px rgba(28,30,29,.28);

  --focus: 0 0 0 3px var(--bg), 0 0 0 5px var(--brand);
  --ease: cubic-bezier(.2,.8,.2,1);
  --sidebar-w: 256px;
  --rail-w: 88px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --brand: #FF7A14;
  --brand-hover: #FF8A2E;
  --brand-ink: #FF9A4D;
  --brand-soft: #2E1F12;
  --brand-soft-2: #43290F;
  --on-brand: #141615;
  --bg: #111312;
  --surface: #1A1D1B;
  --surface-2: #222623;
  --surface-3: #2C302D;
  --text: #F1F1ED;
  --text-2: #B6BAB5;
  --text-3: #8F948F;
  --border: #2B2F2C;
  --border-strong: #3A3F3B;
  --nav-bg: #0B0C0C;
  --nav-text: #C9CBC6;
  --success: #4ADE80; --success-soft: #13291B;
  --warning: #FBBF24; --warning-soft: #2E2410;
  --error:   #F87171; --error-soft:   #331716;
  --info:    #8AB0FF; --info-soft:    #162038;
  --t-income: #4ADE80; --t-expense: #F1F1ED; --t-saving: #FF8A2E; --t-invest: #2DD4BF; --t-debt: #B49AF5; --t-transfer: #A3A8A3;
  --chart-2: #C9CBC6; --chart-3: #9A5A26; --chart-4: #4D524E; --chart-5: #2DD4BF;
  --sh-1: none;
  --sh-2: 0 0 0 1px rgba(255,255,255,.02);
  --sh-3: 0 24px 60px -20px rgba(0,0,0,.7);
  color-scheme: dark;
}

/* 2. BASE ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: var(--fs-body); line-height: 1.5;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  transition: background .25s var(--ease), color .25s var(--ease);
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; letter-spacing: -.02em; font-weight: 800; }
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
.display { font-size: var(--fs-display); line-height: 1.02; letter-spacing: -.035em; font-weight: 800; }
.lead { font-size: 1.125rem; color: var(--text-2); line-height: 1.6; }
.muted { color: var(--text-2); }
.caption { font-size: var(--fs-xs); color: var(--text-3); font-weight: 500; }
.small { font-size: var(--fs-sm); }
.eyebrow { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--brand-ink); }
.num, .amount { font-variant-numeric: tabular-nums lining-nums; letter-spacing: -.02em; }
.amount { font-weight: 700; white-space: nowrap; }
.cur { margin-left: .25em; }
.num .cur { margin-left: .25em; font-size: .85em; font-weight: 600; opacity: .75; }
.amount .cur { font-size: .62em; opacity: 1; font-weight: 600; color: var(--text-3); margin-left: .25em; letter-spacing: 0; }
.amount-xl { font-size: var(--fs-amount-xl); font-weight: 800; line-height: 1; letter-spacing: -.04em; }
.amount-lg { font-size: 1.5rem; font-weight: 800; letter-spacing: -.03em; }
.pos { color: var(--t-income); }
.neg { color: var(--t-expense); }
.sav { color: var(--brand-ink); }
.debt-c { color: var(--t-debt); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--brand); color: var(--on-brand); padding: 10px 16px; border-radius: var(--r-md); font-weight: 700; }
.skip-link:focus { top: 12px; }

/* Logo : bascule automatique clair / sombre */
.logo { display: inline-flex; align-items: center; }
.logo img { height: 30px; width: auto; }
.logo .logo-dark { display: none; }
:root[data-theme="dark"] .logo .logo-light { display: none; }
:root[data-theme="dark"] .logo .logo-dark { display: block; }
.logo--on-dark .logo-light { display: none; }
.logo--on-dark .logo-dark { display: block; }

/* 3. LAYOUT ------------------------------------------------------------- */
.container { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: var(--s4); }
@media (min-width: 768px) { .container { padding-inline: var(--s8); } }
.stack > * + * { margin-top: var(--gap, var(--s4)); }
.row { display: flex; align-items: center; gap: var(--gap, var(--s3)); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: var(--gap, var(--s4)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.center { text-align: center; }
.hide { display: none !important; }

/* 4. BOUTONS, INPUTS, BADGES -------------------------------------------- */
.btn {
  --h: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: var(--h); padding: 0 var(--s5); border-radius: var(--r-pill);
  font-weight: 700; font-size: .9375rem; letter-spacing: -.005em; white-space: nowrap;
  transition: background .15s var(--ease), transform .15s var(--ease), border-color .15s, color .15s;
  border: 1px solid transparent; user-select: none;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-dark { background: var(--text); color: var(--bg); }
.btn-dark:hover { opacity: .9; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--error-soft); color: var(--error); }
.btn-sm { --h: 36px; padding: 0 var(--s4); font-size: var(--fs-sm); }
.btn-lg { --h: 56px; padding: 0 var(--s8); font-size: 1rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }
.btn.is-loading { color: transparent !important; position: relative; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--on-brand); border-right-color: transparent; animation: spin .7s linear infinite; }
.icon-btn {
  width: 44px; height: 44px; border-radius: var(--r-pill); display: inline-grid; place-items: center;
  color: var(--text); transition: background .15s; position: relative; flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .dot { position: absolute; top: 10px; right: 11px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 2px var(--bg); }
.link { color: var(--brand-ink); font-weight: 700; font-size: var(--fs-sm); display: inline-flex; align-items: center; gap: 4px; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.link svg { width: 16px; height: 16px; }

.field { display: grid; gap: 6px; }
.label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 12px 14px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
  transition: border-color .15s, box-shadow .15s; appearance: none;
}
.input::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2374787A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px; }
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-3); pointer-events: none; }
.input-icon .input { padding-left: 42px; }
.field.has-error .input, .field.has-error .select { border-color: var(--error); }
.field-error { font-size: var(--fs-sm); color: var(--error); display: flex; gap: 6px; align-items: center; }
.field-error svg { width: 16px; height: 16px; }
.hint { font-size: var(--fs-xs); color: var(--text-3); }

.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 700; background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.badge svg { width: 13px; height: 13px; }
.badge-brand { background: var(--brand-soft); color: var(--brand-ink); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-error { background: var(--error-soft); color: var(--error); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-debt { background: color-mix(in srgb, var(--t-debt) 14%, transparent); color: var(--t-debt); }
.badge-outline { background: transparent; border: 1px solid var(--border-strong); }

.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: var(--r-pill);
  border: 1px solid var(--border-strong); background: var(--surface); font-size: var(--fs-sm); font-weight: 600; color: var(--text);
  transition: all .15s var(--ease); white-space: nowrap;
}
.chip:hover { border-color: var(--text-3); }
.chip[aria-pressed="true"], .chip.is-active { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .emoji { font-size: 1.05rem; }
.chips { display: flex; gap: var(--s2); overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }

.segmented { display: inline-flex; padding: 4px; border-radius: var(--r-pill); background: var(--surface-2); gap: 2px; }
.segmented button { height: 36px; padding: 0 16px; border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 700; color: var(--text-2); transition: all .15s var(--ease); white-space: nowrap; }
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); }
:root[data-theme="dark"] .segmented button[aria-selected="true"] { background: var(--surface-3); }
.segmented a { height: 36px; padding: 0 16px; border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 700; color: var(--text-2); display: grid; place-items: center; white-space: nowrap; }
.segmented a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); }
:root[data-theme="dark"] .segmented a[aria-current="page"] { background: var(--surface-3); }
.segmented.full { display: flex; width: 100%; }
.segmented.full a { flex: 1; }
.segmented.full button { flex: 1; }

.switch { position: relative; width: 46px; height: 28px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-3); transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s var(--ease); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: var(--focus); }

/* 5. CARTES & LISTES ---------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
  padding: var(--s5); box-shadow: var(--sh-1);
}
.card-lg { padding: var(--s6); }
.card-flat { background: var(--surface-2); border-color: transparent; box-shadow: none; }
.card-dark { background: var(--nav-bg); color: #F1F1ED; border-color: transparent; }
.card-dark .muted, .card-dark .caption { color: #A9ADA8; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.card-head h3 { font-size: 1rem; }
.card.is-link { transition: border-color .15s, transform .2s var(--ease); }
.card.is-link:hover { border-color: var(--border-strong); }
.divider { height: 1px; background: var(--border); border: 0; margin: var(--s4) 0; }

.list { display: grid; }
.list > * { min-width: 0; }
/* Les colonnes de grille peuvent rétrécir sous la largeur de leur contenu (évite le débordement à 360 px) */
.grid > *, .dash > *, .tx-layout > *, .b-layout > *, .d-layout > *, .i-layout > *, .r-grid > *, .goals > *, .st-grid > *, .kpis > *, .kv > *, .filters > *, .comp-grid > * { min-width: 0; }
.list-item {
  display: flex; align-items: center; gap: var(--s3); padding: var(--s3) 0; min-height: 60px;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: 0; }
.list-item.is-btn { cursor: pointer; margin-inline: calc(var(--s3) * -1); padding-inline: var(--s3); border-radius: var(--r-md); border-bottom-color: transparent; }
.list-item.is-btn:hover { background: var(--surface-2); }
.list-item .title { font-weight: 650; font-size: .9375rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .sub { font-size: var(--fs-xs); color: var(--text-3); margin-top: 1px; display: flex; gap: 6px; align-items: center; white-space: nowrap; overflow: hidden; }
.list-item .end { text-align: right; flex-shrink: 0; }
.group-label { font-size: var(--fs-xs); font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .08em; padding: var(--s5) 0 var(--s2); display: flex; justify-content: space-between; }

.cat {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; flex-shrink: 0;
  font-size: 1.2rem; background: var(--surface-2);
}
.cat svg { width: 20px; height: 20px; }
.cat-sm { width: 34px; height: 34px; border-radius: 11px; font-size: 1rem; }
.cat-income { background: var(--success-soft); color: var(--t-income); }
.cat-saving { background: var(--brand-soft); color: var(--brand-ink); }
.cat-debt { background: color-mix(in srgb, var(--t-debt) 13%, transparent); color: var(--t-debt); }
.cat-transfer { background: var(--surface-2); color: var(--t-transfer); }
.cat-invest { background: color-mix(in srgb, var(--t-invest) 13%, transparent); color: var(--t-invest); }

.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: var(--fs-sm); background: var(--brand-soft-2); color: var(--brand-ink); flex-shrink: 0; }
.avatar-sm { width: 32px; height: 32px; font-size: var(--fs-xs); }
.avatar-lg { width: 72px; height: 72px; font-size: 1.5rem; }

/* 6. COMPOSANTS FINANCIERS ---------------------------------------------- */
.progress { height: 10px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; position: relative; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--brand); width: var(--v, 0%); transition: width .8s var(--ease); }
.progress.thin { height: 6px; }
.progress.thick { height: 14px; }
.progress.is-ok > span { background: var(--success); }
.progress.is-warn > span { background: var(--warning); }
.progress.is-over > span { background: var(--error); }
.progress.is-neutral > span { background: var(--text); }
.progress .marker { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); left: var(--m); border-radius: 2px; opacity: .55; }

.ring { --v: 50; --size: 120px; --stroke: 12px; width: var(--size); height: var(--size); border-radius: 50%; display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--ring-c, var(--brand)) calc(var(--v) * 1%), var(--surface-3) 0); }
.ring::before { content: ""; position: absolute; inset: var(--stroke); border-radius: 50%; background: var(--surface); }
.ring > * { position: relative; }

.pace { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 700; }
.pace::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pace-ahead { color: var(--success); }
.pace-on { color: var(--info); }
.pace-behind { color: var(--warning); }

/* Barre de flux : revenus vs dépenses vs épargne */
.flow { display: flex; height: 14px; border-radius: var(--r-pill); overflow: hidden; gap: 3px; }
.flow span { display: block; height: 100%; }
.flow .f-exp { background: var(--text); }
.flow .f-sav { background: var(--brand); }
.flow .f-left { background: var(--surface-3); }
.legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); font-size: var(--fs-xs); color: var(--text-2); font-weight: 600; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* Mini histogramme */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 140px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .bar span { width: 100%; max-width: 36px; border-radius: 8px 8px 4px 4px; background: var(--surface-3); height: var(--h); transition: height .8s var(--ease); }
.bars .bar.is-current span { background: var(--brand); }
.bars .bar small { font-size: 11px; color: var(--text-3); font-weight: 600; }

.stat { display: grid; gap: 4px; }
.stat .k { font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat .k i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.stat .v { font-size: 1.125rem; font-weight: 800; }
.delta { font-size: var(--fs-xs); font-weight: 700; display: inline-flex; align-items: center; gap: 2px; }
.delta svg { width: 14px; height: 14px; }
.delta.up { color: var(--success); }
.delta.down { color: var(--warning); }

/* Insight : calculé vs recommandation IA */
.insight { display: flex; gap: var(--s3); padding: var(--s4); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); }
.insight .ico { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-2); }
.insight .ico svg { width: 18px; height: 18px; }
.insight--calc .ico { background: var(--info-soft); color: var(--info); }
.insight--ai { border-style: dashed; border-color: color-mix(in srgb, var(--brand) 45%, var(--border)); background: linear-gradient(180deg, var(--brand-soft), var(--surface) 70%); }
.insight--ai .ico { background: var(--brand); color: var(--on-brand); }
.source-tag { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; display: inline-flex; align-items: center; gap: 4px; }
.source-tag svg { width: 12px; height: 12px; }
.source-tag.calc { color: var(--info); }
.source-tag.ai { color: var(--brand-ink); }

.banner { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s4); border-radius: var(--r-lg); font-size: var(--fs-sm); }
.banner svg { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.banner-info { background: var(--info-soft); color: var(--info); }
.banner-warning { background: var(--warning-soft); color: var(--warning); }
.banner-error { background: var(--error-soft); color: var(--error); }
.banner-success { background: var(--success-soft); color: var(--success); }
.banner-brand { background: var(--brand-soft); color: var(--text); }
.banner b { color: inherit; }

/* 7. APP SHELL ---------------------------------------------------------- */
.app-shell { min-height: 100dvh; }
.main { min-width: 0; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: var(--s2);
  height: 64px; padding: 0 var(--s4); 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 transparent; transition: border-color .2s;
}
.topbar.is-scrolled { border-bottom-color: var(--border); }
.topbar .page-title { font-size: 1.125rem; font-weight: 800; letter-spacing: -.02em; }
.topbar .logo img { height: 24px; }
.topbar .t-desktop { display: none; }
.content { padding: var(--s2) var(--s4) var(--s8); max-width: 1320px; margin-inline: auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); margin: var(--s2) 0 var(--s5); flex-wrap: wrap; }
.page-head h1 { font-size: var(--fs-h1); }

/* Bottom bar (mobile) */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.bottomnav a, .bottomnav button.nav-add-wrap { display: grid; justify-items: center; gap: 3px; padding: 6px 0; font-size: 11px; font-weight: 700; color: var(--text-3); min-height: 52px; }
.bottomnav a svg { width: 22px; height: 22px; }
.bottomnav a[aria-current="page"] { color: var(--text); }
.bottomnav a[aria-current="page"] svg { color: var(--brand); }
.nav-add {
  width: 56px; height: 56px; margin-top: -22px; border-radius: 20px; display: grid; place-items: center;
  background: var(--brand); color: var(--on-brand); box-shadow: 0 10px 24px -8px color-mix(in srgb, var(--brand) 70%, transparent);
  transition: transform .2s var(--ease);
}
.nav-add svg { width: 26px; height: 26px; stroke-width: 2.5; }
.nav-add-wrap:active .nav-add { transform: scale(.94); }

/* Sidebar (tablette = rail, desktop = complète) */
.sidebar { display: none; }
.sidebar .nav-item {
  display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px; border-radius: var(--r-md);
  color: var(--nav-text); font-weight: 600; font-size: .9375rem; transition: background .15s, color .15s;
}
.sidebar .nav-item svg { width: 20px; height: 20px; flex-shrink: 0; opacity: .85; }
.sidebar .nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .nav-item[aria-current="page"] { background: rgba(255,122,20,.14); color: #fff; }
.sidebar .nav-item[aria-current="page"] svg { color: var(--brand); opacity: 1; }
.sidebar .nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; color: #7E837F; padding: 18px 12px 6px; }
.sidebar .kbd { margin-left: auto; font-size: 11px; padding: 2px 6px; border-radius: 6px; background: rgba(255,255,255,.1); color: #C9CBC6; font-weight: 700; }

.tabs-page { margin: 0 0 var(--s5); }

/* 8. BOTTOM SHEET / MODAL ---------------------------------------------- */
.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(12,13,13,.5); opacity: 0; pointer-events: none; transition: opacity .25s var(--ease); }
.scrim.is-open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; z-index: 61; left: 0; right: 0; bottom: 0; max-height: 94dvh; overflow: auto;
  background: var(--surface); border-radius: var(--r-2xl) var(--r-2xl) 0 0; box-shadow: var(--sh-3);
  transform: translateY(105%); visibility: hidden; transition: transform .32s var(--ease), visibility 0s linear .32s; padding: 8px var(--s4) calc(var(--s4) + env(safe-area-inset-bottom));
}
.sheet.is-open { transform: none; visibility: visible; transition-delay: 0s; }
.sheet .grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 4px auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s4); }

.amount-input { text-align: center; padding: var(--s3) 0 var(--s2); }
.amount-input .val { font-size: 3rem; font-weight: 800; letter-spacing: -.04em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.amount-input .val.is-empty { color: var(--text-3); }
.amount-input .cur { font-size: 1rem; font-weight: 700; color: var(--text-3); margin-left: 6px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.keypad button { height: 52px; border-radius: var(--r-md); font-size: 1.375rem; font-weight: 700; background: var(--surface-2); transition: background .1s; font-variant-numeric: tabular-nums; }
.keypad button:active { background: var(--surface-3); }
.keypad button svg { width: 22px; height: 22px; margin: auto; }
.pick-row { display: flex; align-items: center; gap: var(--s3); padding: 10px 0; border-bottom: 1px solid var(--border); min-height: 52px; }
.pick-row .k { width: 84px; font-size: var(--fs-sm); color: var(--text-3); font-weight: 600; flex-shrink: 0; }
.type-hint { font-size: var(--fs-xs); color: var(--text-2); display: flex; gap: 6px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); }
.type-hint svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 2px; }

/* 9. ÉTATS -------------------------------------------------------------- */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; border-radius: var(--r-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .5s var(--ease) both; }
.empty { text-align: center; padding: var(--s8) var(--s4); display: grid; justify-items: center; gap: var(--s3); }
.empty .ill { width: 88px; height: 88px; border-radius: 28px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); margin-bottom: var(--s2); }
.empty .ill svg { width: 38px; height: 38px; }
.empty p { max-width: 340px; color: var(--text-2); }
.toast-wrap { position: fixed; z-index: 80; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom)); display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r-lg); background: var(--text); color: var(--bg); box-shadow: var(--sh-3); font-size: var(--fs-sm); font-weight: 600; animation: rise .3s var(--ease); pointer-events: auto; }
.toast svg { width: 20px; height: 20px; color: var(--brand); flex-shrink: 0; }
.toast .link { color: var(--brand); margin-left: auto; }
.offline-bar { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 16px; font-size: var(--fs-xs); font-weight: 700; background: var(--warning-soft); color: var(--warning); }
.offline-bar svg { width: 14px; height: 14px; }

/* Utilitaires d'affichage responsive */
@media (max-width: 767px) { .only-desktop { display: none !important; } }
@media (min-width: 768px) { .only-mobile { display: none !important; } }

/* 10. RESPONSIVE -------------------------------------------------------- */
/* Tablette : rail de navigation, contenu 2 colonnes */
@media (min-width: 768px) {
  .app-shell { display: grid; grid-template-columns: var(--rail-w) minmax(0,1fr); }
  .bottomnav { display: none; }
  .main { padding-bottom: var(--s10); }
  .sidebar {
    display: flex; flex-direction: column; align-items: center; gap: 4px; position: sticky; top: 0; height: 100dvh;
    background: var(--nav-bg); padding: 16px 10px; overflow-y: auto;
  }
  .sidebar .sb-logo-full, .sidebar .nav-group, .sidebar .label-txt, .sidebar .kbd, .sidebar .sb-card { display: none; }
  .sidebar .sb-mark { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; background: #F6F5F0; margin-bottom: 12px; }
  .sidebar .sb-mark img { width: 40px; height: auto; }
  .sidebar .nav-item { width: 64px; height: auto; flex-direction: column; gap: 4px; padding: 10px 4px; font-size: 10.5px; justify-content: center; }
  .sidebar .nav-item .label-rail { display: block; }
  .sidebar .sb-add { width: 52px; height: 52px; border-radius: 16px; padding: 0; justify-content: center; margin: 4px 0 12px; }
  .sidebar .sb-add .label-txt { display: none; }
  .sidebar .sb-bottom { margin-top: auto; display: grid; gap: 4px; justify-items: center; }
  .content { padding: var(--s4) var(--s8) var(--s10); }
  .topbar { padding: 0 var(--s8); height: 72px; }
  .topbar .t-mobile { display: none; }
  .topbar .t-desktop { display: flex; }
  .toast-wrap { bottom: 24px; }
  .sheet { left: 50%; right: auto; bottom: 50%; width: min(560px, 92vw); border-radius: var(--r-2xl); transform: translate(-50%, 55%) scale(.98); opacity: 0; pointer-events: none; transition: transform .28s var(--ease), opacity .2s, visibility 0s linear .28s; }
  .sheet.is-open { transform: translate(-50%, 50%); opacity: 1; pointer-events: auto; transition-delay: 0s; }
  .sheet .grabber { display: none; }
}
.sidebar .label-rail { display: none; }

/* Desktop : sidebar complète */
@media (min-width: 1200px) {
  .app-shell { grid-template-columns: var(--sidebar-w) minmax(0,1fr); }
  .sidebar { align-items: stretch; padding: 22px 16px; }
  .sidebar .sb-mark { display: none; }
  .sidebar .sb-logo-full { display: block; padding: 4px 12px 18px; }
  .sidebar .sb-logo-full img { height: 28px; width: auto; }
  .sidebar .nav-group, .sidebar .label-txt, .sidebar .kbd { display: revert; }
  .sidebar .sb-card { display: block; }
  .sidebar .nav-item .label-rail { display: none; }
  .sidebar .nav-item { width: auto; flex-direction: row; padding: 0 12px; height: 44px; font-size: .9375rem; justify-content: flex-start; }
  .sidebar .sb-add { width: auto; height: 48px; padding: 0 16px; border-radius: var(--r-md); justify-content: flex-start; margin: 4px 0 8px; }
  .sidebar .sb-add .label-txt { display: inline; }
  .sidebar .sb-bottom { justify-items: stretch; }
  .content { padding: var(--s4) var(--s10) var(--s12); }
  .topbar { padding: 0 var(--s10); }
}
@media (min-width: 1920px) { .content { max-width: 1480px; } }

/* 11. AUTHENTIFICATION (inscription / connexion) ------------------------ */
.auth { min-height: 100dvh; display: grid; }
.auth-side { display: none; }
.auth-main { display: flex; flex-direction: column; min-height: 100dvh; width: 100%; max-width: 480px; margin: 0 auto; padding: 12px 20px calc(24px + env(safe-area-inset-bottom)); }
.auth-top { display: flex; align-items: center; justify-content: space-between; height: 60px; margin-bottom: 12px; }
.auth-top .logo img { height: 26px; }
.auth h1 { font-size: clamp(1.625rem, 5vw, 2rem); }
.auth .lead { font-size: 1rem; margin-top: 8px; }
.auth-form { display: grid; gap: 16px; margin-top: 24px; }
.auth-main > *, .auth-form > *, .auth-form .field > * { min-width: 0; }
.auth-foot { margin-top: 20px; text-align: center; font-size: var(--fs-sm); color: var(--text-2); }
.auth-sep { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: var(--fs-xs); font-weight: 600; }
.auth-sep::before, .auth-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-perks { display: grid; gap: 14px; position: relative; z-index: 1; }
.auth-perks div { display: flex; gap: 12px; align-items: flex-start; color: #C9CBC6; font-size: .9375rem; }
.auth-perks svg { width: 20px; height: 20px; color: var(--brand); flex-shrink: 0; margin-top: 2px; }
@media (min-width: 900px) {
  .auth { grid-template-columns: minmax(360px, 42%) 1fr; }
  .auth-side { display: flex; flex-direction: column; justify-content: space-between; gap: 32px; padding: 40px 48px; background: var(--nav-bg); color: #F1F1ED; position: sticky; top: 0; height: 100dvh; overflow: hidden; }
  .auth-side::after { content: ""; position: absolute; right: -140px; bottom: -140px; width: 460px; height: 460px; border-radius: 50%; border: 60px solid rgba(255,114,0,.12); }
  .auth-side > img { align-self: flex-start; height: 34px; width: auto; position: relative; z-index: 1; }
  .auth-main { justify-content: center; padding: 40px; }
  .auth-top .logo { display: none; }
}

/* Champ avec préfixe (indicatif) et champ mot de passe avec bouton afficher */
.input-group { display: flex; align-items: stretch; border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.input-group:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.input-group .input { border: 0; box-shadow: none !important; background: transparent; min-width: 0; flex: 1; }
.input-group .prefix { display: flex; align-items: center; gap: 6px; padding: 0 12px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-2); border-right: 1px solid var(--border); white-space: nowrap; }
.input-group .suffix-btn { padding: 0 14px; color: var(--text-2); font-size: var(--fs-sm); font-weight: 700; border-radius: 0 var(--r-md) var(--r-md) 0; }
.input-group .suffix-btn:hover { color: var(--text); }
.input-group .suffix-btn svg { width: 18px; height: 18px; }
.field.has-error .input-group { border-color: var(--error); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: var(--fs-sm); color: var(--text-2); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--brand); flex-shrink: 0; }
.check a { color: var(--brand-ink); font-weight: 700; }
.field.has-error .check { color: var(--error); }
.strength { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 2px; }
.strength i { height: 4px; border-radius: 4px; background: var(--surface-3); transition: background .2s; }
.strength[data-level="1"] i:nth-child(1) { background: var(--error); }
.strength[data-level="2"] i:nth-child(-n+2) { background: var(--warning); }
.strength[data-level="3"] i { background: var(--success); }
.rules { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: var(--fs-xs); color: var(--text-3); }
.rules span { display: inline-flex; align-items: center; gap: 4px; }
.rules span::before { content: "○"; font-size: 10px; }
.rules span.ok { color: var(--success); }
.rules span.ok::before { content: "✓"; font-weight: 800; }

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