@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter-var.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;    /* le repli système s'affiche immédiatement */
}

/* ============ IMMO Budget — design tokens ============ */
:root {
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --ink: #0F172A;
  --ink-2: #334155;
  --muted: #64748B;
  --line: #E6E9EF;
  --accent: #2563EB;
  --accent-ink: #FFFFFF;
  --success: #059669;
  --success-bg: #ECFDF5;
  --warn: #B45309;
  --warn-bg: #FFFBEB;
  --warn-line: #F59E0B;
  --danger: #DC2626;
  --danger-bg: #FEF2F2;
  --hero-1: #0F172A;
  --hero-2: #1E3A5F;
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;
  --shadow-1: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .06);
  --shadow-2: 0 8px 30px rgba(15, 23, 42, .16);
  --ease: cubic-bezier(.32, .72, 0, 1);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100dvh;
  overscroll-behavior-y: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; border: 0; background: none; color: inherit; cursor: pointer; }
input { font: inherit; }
ul { list-style: none; }
img { max-width: 100%; display: block; }

.hidden { display: none !important; }

#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; position: relative; }

/* ============ Home ============ */
.screen-home {
  padding: calc(var(--sat) + 22px) 20px calc(var(--sab) + 190px);
  animation: fade-in .3s var(--ease);
}

.app-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.app-header .greeting { color: var(--muted); font-size: 14px; font-weight: 500; text-transform: capitalize; }
.app-header h1 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.logo-badge {
  width: 46px; height: 46px; border-radius: 15px;
  background: linear-gradient(135deg, var(--hero-1), var(--hero-2));
  display: grid; place-items: center; color: #fff; box-shadow: var(--shadow-1);
}

/* balance card */
.balance-card {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--hero-1) 0%, var(--hero-2) 100%);
  color: #fff; border-radius: var(--r-lg);
  padding: 26px 24px 22px; box-shadow: var(--shadow-2);
}
.balance-card::after {
  content: ""; position: absolute; right: -70px; top: -70px; width: 220px; height: 220px;
  border-radius: 50%; background: radial-gradient(circle, rgba(59,130,246,.35), transparent 65%);
}
.balance-label { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #A5B4CC; }
.balance-value {
  font-size: clamp(34px, 9.5vw, 42px); font-weight: 800; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums; margin-top: 6px; line-height: 1.15;
}
.balance-stats { display: flex; gap: 12px; margin-top: 20px; position: relative; z-index: 1; }
.stat {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.10);
  border-radius: var(--r-md); padding: 10px 12px;
}
.stat-ico { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.stat-ico.in  { background: rgba(16,185,129,.22); color: #6EE7B7; }
.stat-ico.out { background: rgba(248,113,113,.18); color: #FCA5A5; }
.stat p:first-child { font-size: 12px; color: #A5B4CC; font-weight: 500; }
.stat p:last-child  { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat > div { min-width: 0; flex: 1; }

/* transactions */
.tx-section { margin-top: 26px; }
.tx-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.tx-head h2 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.tx-head span { font-size: 13px; color: var(--muted); font-weight: 500; }

.tx-item {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  background: var(--surface); border-radius: var(--r-md); padding: 13px 14px;
  margin-bottom: 10px; box-shadow: var(--shadow-1);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease);
}
.tx-item:active { transform: scale(.98); }
.tx-ico {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: none;
  background: #EFF3FB; color: var(--accent);
}
.tx-ico.out { background: #FDF0EF; color: var(--danger); }
.tx-body { flex: 1; min-width: 0; }
.tx-label { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.tx-amount { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-amount.in { color: var(--success); }
.tx-amount.out { color: var(--danger); }

/* empty state */
.empty-state { text-align: center; padding: 44px 24px 30px; color: var(--muted); }
.empty-state svg { margin: 0 auto 14px; opacity: .8; }
.empty-state h3 { color: var(--ink-2); font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.empty-state p { font-size: 14px; max-width: 260px; margin: 0 auto; }

/* ============ Projects ============ */
.screen-projects {
  padding: calc(var(--sat) + 22px) 20px calc(var(--sab) + 190px);
  animation: fade-in .3s var(--ease);
}
.head-btn {
  width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center;
  background: var(--ink); color: #fff; box-shadow: var(--shadow-1);
  transition: transform .15s var(--ease);
}
.head-btn:active { transform: scale(.92); }

.project-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: 999px; padding: 5px 12px 5px 9px; margin-bottom: 4px;
  font-size: 13px; font-weight: 700; color: var(--ink-2); max-width: 62vw;
  transition: transform .15s var(--ease);
}
.project-chip:active { transform: scale(.96); }
.project-chip span:nth-child(2) {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.project-chip .dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none;
}

.project-item {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  background: var(--surface); border-radius: var(--r-md); padding: 15px 15px;
  margin-bottom: 10px; box-shadow: var(--shadow-1);
  border-left: 4px solid var(--accent);
  transition: transform .15s var(--ease);
}
.project-item:active { transform: scale(.98); }
.project-item.active-project { box-shadow: 0 0 0 2px var(--accent), var(--shadow-1); }
.project-body { flex: 1; min-width: 0; }
.project-name { font-size: 16px; font-weight: 750; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.project-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.project-total { font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums;
  white-space: nowrap; }
.project-total.in { color: var(--success); }
.project-total.out { color: var(--danger); }

/* form field inside the scan sheet */
.sheet-field { display: block; margin-bottom: 6px; }
.sheet-field > span { display: block; font-size: 13px; font-weight: 700;
  color: var(--ink-2); margin-bottom: 6px; }
.sheet-field > span small { font-weight: 500; color: var(--muted); }
.sheet-field input {
  width: 100%; min-height: 50px; border-radius: var(--r-sm);
  border: 1.5px solid var(--line); background: var(--surface);
  padding: 0 14px; font-size: 16px; color: var(--ink); outline: none;
}
.sheet-field input:focus { border-color: var(--accent); }
.sheet-field-hint { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }

/* ============ Documents archive ============ */
.screen-docs {
  padding: calc(var(--sat) + 22px) 20px calc(var(--sab) + 190px);
  animation: fade-in .3s var(--ease);
}

.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: 15px; padding: 0 14px; min-height: 50px; margin-bottom: 14px;
  box-shadow: var(--shadow-1); color: var(--muted);
}
.search-bar:focus-within { border-color: var(--accent); }
.search-bar input {
  flex: 1; border: 0; outline: none; background: transparent; min-width: 0;
  font-size: 16px; color: var(--ink); padding: 12px 0;
}
.search-bar input::placeholder { color: #A9B3C2; }
.search-bar button {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--muted-bg, #EEF1F6); color: var(--ink-2); flex: none;
}

.chips {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 38px; padding: 0 15px; border-radius: 19px;
  border: 1.5px solid var(--line); background: var(--surface);
  font-size: 14px; font-weight: 650; color: var(--ink-2); white-space: nowrap;
  transition: all .15s var(--ease);
}
.chip:active { transform: scale(.95); }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }

.docs-count { font-size: 13px; color: var(--muted); font-weight: 600; margin: 6px 0 12px; }

.doc-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--surface); border-radius: var(--r-md); padding: 11px 12px;
  margin-bottom: 10px; box-shadow: var(--shadow-1);
  transition: transform .15s var(--ease);
}
.doc-item:active { transform: scale(.98); }
.doc-thumb {
  width: 62px; height: 46px; border-radius: 10px; object-fit: cover;
  background: #E8EDF5; flex: none;
}
.doc-body { flex: 1; min-width: 0; }
.doc-title { font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-amount { font-weight: 700; font-size: 14.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc-amount.in { color: var(--success); }
.doc-amount.out { color: var(--danger); }

/* ============ Voice command ============ */
/* Lives in the same row as the scan bar: one action group, no stacked
   floating circles fighting the tab bar for space. */
.mic-fab {
  pointer-events: auto; position: relative; flex: none;
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, var(--accent, #2563EB), #1D4ED8);
  box-shadow: 0 10px 26px rgba(37, 99, 235, .40);
  transition: transform .18s var(--ease), background .2s ease;
}
.mic-fab:active { transform: scale(.92); }
.mic-fab.recording { background: linear-gradient(135deg, #DC2626, #B91C1C); }
.mic-fab.busy { background: linear-gradient(135deg, #475569, #334155); }
.mic-fab .mic-pulse {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(220, 38, 38, .55); opacity: 0;
}
.mic-fab.recording .mic-pulse { animation: mic-ring 1.5s ease-out infinite; }
@keyframes mic-ring {
  0% { transform: scale(1); opacity: .8; }
  100% { transform: scale(1.85); opacity: 0; }
}

.voice-panel {
  position: fixed; inset: 0; z-index: 85;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(10, 15, 26, .55); 
  animation: fade-in .2s ease;
}
.voice-card {
  width: 100%; max-width: 480px;
  background: var(--surface); border-radius: 24px 24px 0 0;
  padding: 24px 22px calc(var(--sab) + 22px);
  box-shadow: 0 -12px 40px rgba(15, 23, 42, .25);
  animation: slide-up .28s var(--ease);
  text-align: center;
}
.voice-wave { display: flex; align-items: center; justify-content: center;
  gap: 5px; height: 46px; margin-bottom: 14px; }
.voice-wave i {
  width: 5px; border-radius: 3px; background: var(--accent);
  height: 10px; transition: height .09s linear;
}
.voice-state { font-size: 17px; font-weight: 750; color: var(--ink); }
.voice-hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.voice-heard {
  margin-top: 12px; padding: 11px 14px; border-radius: 12px;
  background: var(--bg); border: 1.5px solid var(--line);
  font-size: 15px; font-weight: 600; color: var(--ink-2); text-align: left;
}
.voice-heard b { color: var(--ink); }
.voice-actions { display: flex; gap: 10px; margin-top: 16px; }
.btn-md.primary { background: var(--accent); color: #fff; border: 0; }

/* ============ Bottom tab bar ============ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  max-width: 480px; margin: 0 auto;
  display: flex; background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(var(--sab) + 6px); gap: 2px;
}
.tab {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  align-items: center; gap: 3px; padding: 0 2px;
  min-height: 52px; justify-content: center; color: var(--muted);
  font-size: 9.5px; font-weight: 650; letter-spacing: -0.015em;
  border-radius: 12px; transition: color .15s var(--ease);
}
.tab span {
  max-width: 100%; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.tab.on { color: var(--accent); }

/* FAB */
.fab-wrap {
  position: fixed; left: 0; right: 0; z-index: 46;
  bottom: calc(var(--sab) + 64px);          /* sits above the tab bar */
  padding: 14px 20px 12px;
  background: linear-gradient(to top, var(--bg) 62%, transparent);
  display: flex; align-items: center; gap: 12px; pointer-events: none;
  max-width: 480px; margin: 0 auto;
}
.fab {
  pointer-events: auto; display: flex; align-items: center; justify-content: center; gap: 10px;
  flex: 1; min-width: 0; min-height: 56px; padding: 0 12px;
  background: var(--ink); color: #fff; border-radius: 18px;
  font-size: clamp(14.5px, 4.2vw, 16.5px); font-weight: 700;
  box-shadow: 0 10px 26px rgba(15,23,42,.35);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease);
}
.fab:active { transform: scale(.97); }

/* ============ Bottom sheet (scan flow) ============ */
.backdrop {
  position: fixed; inset: 0; z-index: 60; background: rgba(10, 15, 26, .52);
   opacity: 0; transition: opacity .25s ease;
}
.backdrop.show { opacity: 1; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  max-width: 480px; margin: 0 auto;
  background: var(--surface); border-radius: 24px 24px 0 0;
  padding: 10px 20px calc(var(--sab) + 24px);
  transform: translateY(103%); transition: transform .34s var(--ease);
  box-shadow: 0 -12px 40px rgba(15,23,42,.22);
}
.sheet.show { transform: translateY(0); }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 14px; }

.sheet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; min-height: 40px; }
.sheet-back {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  color: var(--ink-2); background: var(--bg); flex: none;
  transition: transform .15s var(--ease);
}
.sheet-back:active { transform: scale(.92); }
.sheet-title { flex: 1; }
.sheet-title h3 { font-size: 18px; font-weight: 750; letter-spacing: -.01em; }
.sheet-title p { font-size: 13px; color: var(--muted); }
.step-dots { display: flex; gap: 5px; }
.step-dots i { width: 7px; height: 7px; border-radius: 4px; background: var(--line); transition: all .25s var(--ease); }
.step-dots i.on { background: var(--accent); width: 18px; }

.sheet-body { padding-top: 14px; }

/* step 1: doc types */
.doc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.doc-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  border: 1.5px solid var(--line); border-radius: var(--r-md);
  padding: 16px 15px; min-height: 104px; text-align: left;
  transition: border-color .15s ease, background .15s ease, transform .15s var(--ease);
}
.doc-card:active { transform: scale(.97); }
.doc-card.selected { border-color: var(--accent); background: #F4F8FF; }
.doc-card .ico {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  background: #EFF3FB; color: var(--accent);
}
.doc-card b { font-size: 15px; font-weight: 700; }
.doc-card small { font-size: 12px; color: var(--muted); margin-top: -6px; }

/* step 2: cases */
.case-list { display: flex; flex-direction: column; gap: 12px; }
.case-card {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  border: 1.5px solid var(--line); border-radius: var(--r-md); padding: 16px 15px;
  transition: border-color .15s ease, background .15s ease, transform .15s var(--ease);
}
.case-card:active { transform: scale(.98); }
.case-card .ico { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.case-card .ico.in  { background: var(--success-bg); color: var(--success); }
.case-card .ico.out { background: var(--danger-bg); color: var(--danger); }
.case-card b { font-size: 15.5px; font-weight: 700; display: block; }
.case-card small { font-size: 13px; color: var(--muted); }

/* step 3: capture */
.capture-list { display: flex; flex-direction: column; gap: 12px; }
.capture-btn {
  display: flex; align-items: center; justify-content: center; gap: 11px;
  min-height: 58px; border-radius: var(--r-md); font-size: 16px; font-weight: 700;
  transition: transform .15s var(--ease), opacity .2s ease;
}
.capture-btn:active { transform: scale(.97); }
.capture-btn.primary { background: var(--ink); color: #fff; box-shadow: 0 8px 22px rgba(15,23,42,.28); }
.capture-btn.secondary { background: var(--bg); color: var(--ink); border: 1.5px solid var(--line); }
.capture-sample {
  margin-top: 4px; text-align: center; font-size: 14px; font-weight: 600; color: var(--accent);
  padding: 12px; border-radius: var(--r-sm);
}
.capture-note { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px;
  font-size: 12.5px; color: var(--muted); background: var(--bg); border-radius: var(--r-sm); padding: 10px 12px; }
.capture-note svg { flex: none; margin-top: 1px; }

/* ============ Processing overlay ============ */
.overlay {
  position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0; padding: 32px;
  /* No backdrop-filter here: at 96% opacity the blur is invisible, and on
     iOS it is expensive enough to stall the scan animation for seconds. */
  background: rgba(10, 14, 24, .96); color: #fff;
  animation: fade-in .25s ease;
}
.scan-frame { position: relative; width: min(78vw, 330px); border-radius: 18px; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.scan-frame img { width: 100%; height: auto; }
.scan-beam {
  position: absolute; left: 0; right: 0; top: 0; height: 34%;
  background: linear-gradient(to bottom, transparent, rgba(59,130,246,.38) 78%, rgba(147,197,253,.95));
  animation: beam 1.6s var(--ease) infinite alternate;
  /* keep the sweep on the compositor so a busy main thread cannot stall it */
  will-change: transform; transform: translateZ(0);
}
@keyframes beam { from { transform: translateY(-40%); } to { transform: translateY(240%); } }
.processing-title { margin-top: 26px; font-size: 18px; font-weight: 700; }
.processing-sub { margin-top: 5px; font-size: 14px; color: #9FB0CC; text-align: center; }
.overlay-cancel {
  margin-top: 30px; min-height: 50px; min-width: 170px; border-radius: 15px;
  font-size: 15px; font-weight: 700; color: #fff;
  background: rgba(255,255,255,.10); border: 1.5px solid rgba(255,255,255,.28);
  transition: transform .15s var(--ease), background .2s ease;
}
.overlay-cancel:active { transform: scale(.96); background: rgba(255,255,255,.18); }

/* ============ Review screen ============ */
.screen-review {
  position: fixed; inset: 0; z-index: 70; background: var(--bg);
  display: flex; flex-direction: column; max-width: 480px; margin: 0 auto;
  animation: slide-up .32s var(--ease);
}
.review-top {
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--sat) + 12px) 16px 12px; background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.review-top .sheet-back { background: var(--bg); }
.review-top h2 { font-size: 17.5px; font-weight: 750; flex: 1; }
.review-scroll { flex: 1; overflow-y: auto; padding: 16px 20px 130px; -webkit-overflow-scrolling: touch; }

.review-alert {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--warn-bg); border: 1px solid #FDE9C8; color: var(--warn);
  border-radius: var(--r-md); padding: 12px 14px; font-size: 13.5px; font-weight: 600;
  margin-bottom: 14px;
}
.review-alert svg { flex: none; margin-top: 1px; }
.review-alert.ok { background: var(--success-bg); border-color: #C7F0DD; color: var(--success); }

.doc-viewer {
  position: relative; border-radius: var(--r-md); overflow: hidden;
  box-shadow: var(--shadow-1); background: #1E293B; margin-bottom: 18px;
}
.doc-viewer img { width: 100%; height: auto; }
.ocr-box { position: absolute; border-radius: 6px; pointer-events: none; transition: all .25s ease; }
.ocr-box.ok { border: 2px solid rgba(16,185,129,.85); background: rgba(16,185,129,.10); }
.ocr-box.warn {
  border: 2.5px solid #F59E0B; background: rgba(245,158,11,.16);
  animation: pulse-warn 1.6s ease infinite;
}
.ocr-box.active { border-color: var(--accent); background: rgba(59,130,246,.16); box-shadow: 0 0 0 4px rgba(59,130,246,.25); animation: none; }
.ocr-box .tag {
  position: absolute; top: -22px; left: -2px; font-size: 10.5px; font-weight: 800;
  background: #F59E0B; color: #fff; border-radius: 5px; padding: 2px 6px; white-space: nowrap;
  letter-spacing: .02em;
}
.ocr-box.ok .tag { background: var(--success); }
.ocr-box.active .tag { background: var(--accent); }
.ocr-box .tag.below { top: auto; bottom: -22px; }

/* A search area (value not located). Hidden until its field is focused —
   drawing every one at once buries the document under overlapping boxes. */
.ocr-box.zone-hint:not(.active) { opacity: 0; animation: none; }
.ocr-box.zone-hint:not(.active) .tag { display: none; }
.ocr-box.zone-hint.active {
  border-style: dashed; border-color: var(--accent);
  background: rgba(59, 130, 246, .12); animation: none;
}
.ocr-box.zone-hint.active .tag { background: var(--accent); }
@keyframes pulse-warn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245,158,11,.45); }
  55% { box-shadow: 0 0 0 9px rgba(245,158,11,0); }
}

/* field cards */
.field {
  display: block; background: var(--surface); border: 1.5px solid var(--line);
  border-radius: var(--r-md); padding: 13px 15px 14px; margin-bottom: 12px;
  box-shadow: var(--shadow-1); transition: border-color .2s ease;
}
.field.warn { border-color: var(--warn-line); }
.field.done { border-color: #BBE5D2; }
.field.focus { border-color: var(--accent); }
.field-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.field-label { font-size: 13px; font-weight: 700; color: var(--ink-2); letter-spacing: .01em; }
.badge {
  font-size: 11px; font-weight: 800; border-radius: 7px; padding: 3px 8px; letter-spacing: .03em;
  display: inline-flex; align-items: center; gap: 4px;
}
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.ok { background: var(--success-bg); color: var(--success); }
.badge.miss { background: var(--danger-bg); color: var(--danger); }
.field-input {
  width: 100%; border: 0; outline: none; background: transparent;
  font-size: 17px; font-weight: 650; color: var(--ink); padding: 2px 0;
  font-variant-numeric: tabular-nums;
}
.field-input::placeholder { color: #B3BCCA; font-weight: 500; }
.field-hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; display: flex; gap: 6px; align-items: flex-start; }
.field-hint.warn { color: var(--warn); font-weight: 600; }
/* magnified crop of the exact zone, shown inside the field being corrected */
.zoom-view {
  position: relative; margin: 4px 0 10px; border-radius: 10px; overflow: hidden;
  border: 1.5px solid var(--warn-line); background: #10192B;
}
.zoom-img { width: 100%; background-repeat: no-repeat; image-rendering: auto; }
.zoom-cap {
  position: absolute; right: 6px; bottom: 6px;
  background: rgba(15, 23, 42, .78); color: #fff;
  font-size: 10.5px; font-weight: 700; border-radius: 5px; padding: 2px 6px;
}

.field-alt {
  margin-top: 10px; margin-right: 8px; display: inline-flex; align-items: center; gap: 7px;
  min-height: 40px; padding: 0 14px; border-radius: 11px;
  background: #EEF4FF; border: 1.5px solid #C7DBFB; color: #1D4ED8;
  font-size: 13.5px; font-weight: 750;
  transition: transform .15s var(--ease);
}
.field-alt:active { transform: scale(.96); }

.field-confirm {
  margin-top: 10px; display: inline-flex; align-items: center; gap: 7px;
  min-height: 40px; padding: 0 14px; border-radius: 11px;
  background: var(--warn-bg); border: 1.5px solid var(--warn-line); color: var(--warn);
  font-size: 13.5px; font-weight: 750;
  transition: transform .15s var(--ease);
}
.field-confirm:active { transform: scale(.96); }

.review-actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 71;
  max-width: 480px; margin: 0 auto;
  padding: 12px 20px calc(var(--sab) + 16px);
  background: linear-gradient(to top, var(--bg) 62%, transparent);
  display: flex; gap: 10px;
}
.btn-lg {
  flex: 1; min-height: 56px; border-radius: 17px; font-size: 16px; font-weight: 750;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  transition: transform .15s var(--ease), opacity .2s ease, background .2s ease;
}
.btn-lg:active { transform: scale(.97); }
.btn-lg.primary { background: var(--accent); color: #fff; box-shadow: 0 10px 24px rgba(37,99,235,.34); }
.btn-lg.primary:disabled { background: #B9C4D6; box-shadow: none; cursor: not-allowed; }
.btn-lg.ghost { flex: 0 0 auto; padding: 0 18px; background: var(--surface); border: 1.5px solid var(--line); color: var(--ink-2); }

/* ============ Success overlay ============ */
.success-pop { text-align: center; animation: pop-in .4s var(--ease); }
.success-ring {
  width: 96px; height: 96px; margin: 0 auto 18px; border-radius: 50%;
  background: rgba(16,185,129,.15); display: grid; place-items: center;
}
.success-ring svg circle { stroke-dasharray: 166; stroke-dashoffset: 166; animation: draw .5s .15s var(--ease) forwards; }
.success-ring svg path { stroke-dasharray: 48; stroke-dashoffset: 48; animation: draw .35s .5s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.success-pop h3 { font-size: 20px; font-weight: 800; }
.success-pop p { margin-top: 6px; color: #9FB0CC; font-size: 15px; }
.success-pop .amount { color: #6EE7B7; font-weight: 800; font-size: 26px; margin-top: 10px; font-variant-numeric: tabular-nums; }

/* ============ Detail overlay ============ */
.detail-card {
  width: min(92vw, 420px); background: var(--surface); color: var(--ink);
  border-radius: var(--r-lg); overflow: hidden; animation: pop-in .3s var(--ease);
  max-height: 86dvh; display: flex; flex-direction: column;
}
.detail-card img { width: 100%; max-height: 38dvh; object-fit: contain; background: #10192B; }
.detail-body { padding: 18px 20px 20px; overflow-y: auto; }
.detail-body h3 { font-size: 18px; font-weight: 800; }
.detail-amount { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; margin: 2px 0 12px; }
.detail-amount.in { color: var(--success); }
.detail-amount.out { color: var(--danger); }
.detail-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.detail-row b { color: var(--muted); font-weight: 600; }
.detail-row span { font-weight: 650; text-align: right; }
.detail-actions { display: flex; gap: 10px; margin-top: 16px; }
.btn-md {
  flex: 1; min-height: 48px; border-radius: 14px; font-size: 15px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .15s var(--ease);
}
.btn-md:active { transform: scale(.96); }
.btn-md.neutral { background: var(--bg); border: 1.5px solid var(--line); color: var(--ink-2); }
.btn-md.danger { background: var(--danger-bg); color: var(--danger); border: 1.5px solid #F6CBCB; }

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--sab) + 96px); transform: translateX(-50%) translateY(20px);
  z-index: 90; background: var(--ink); color: #fff; font-size: 14px; font-weight: 600;
  border-radius: 13px; padding: 12px 18px; max-width: 88vw; text-align: center;
  opacity: 0; pointer-events: none; transition: all .3s var(--ease);
  box-shadow: 0 10px 30px rgba(15,23,42,.4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

/* ocr engine banner */
.ocr-banner {
  display: flex; align-items: center; gap: 10px; margin-top: 14px;
  background: #EEF4FF; border: 1px solid #DCE7FB; color: #1D4ED8;
  border-radius: var(--r-md); padding: 11px 14px; font-size: 13.5px; font-weight: 600;
}
.spinner {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  border: 2.5px solid rgba(37,99,235,.25); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.spinner.light { border-color: rgba(255,255,255,.25); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ shared animations ============ */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { transform: translateY(26px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes pop-in { from { transform: scale(.86); opacity: 0; } to { transform: none; opacity: 1; } }

:focus-visible { outline: 3px solid rgba(37, 99, 235, .55); outline-offset: 2px; border-radius: 6px; }

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

/* ============ Responsive: small phones / tablets / landscape ============ */
/* Compact phones (<=360px): tighter paddings, nothing may overflow */
@media (max-width: 360px) {
  .screen-home, .screen-docs, .screen-projects { padding-left: 14px; padding-right: 14px; }
  .fab-wrap { padding-left: 14px; padding-right: 14px; gap: 10px; }
  .mic-fab { width: 52px; height: 52px; }
  .fab { min-height: 52px; }
  .stat-grid { gap: 8px; }
  .voice-card { padding-left: 16px; padding-right: 16px; }
}

/* Tablets and wide phones: widen the column, everything stays centred */
@media (min-width: 700px) {
  #app, .fab-wrap, .tabbar, .sheet, .voice-card { max-width: 640px; }
  .review-card { max-width: 640px; margin-left: auto; margin-right: auto; }
}
@media (min-width: 1000px) {
  #app, .fab-wrap, .tabbar, .sheet, .voice-card { max-width: 720px; }
}

/* Landscape phones: the document photo must not eat the whole height */
@media (max-height: 480px) {
  #doc-viewer img, .zoom-view .zoom-img { max-height: 42vh; object-fit: contain; }
  .voice-wave { height: 30px; margin-bottom: 8px; }
  .fab-wrap { bottom: calc(var(--sab) + 58px); }
}

/* Respect the keyboard: inputs scroll into view inside the review screen */
@supports (height: 100dvh) {
  .voice-panel, .backdrop, .sheet-backdrop { height: 100dvh; }
}

/* ============ Réglages ============ */
.screen-settings {
  padding: calc(var(--sat) + 22px) 20px calc(var(--sab) + 120px);
  animation: fade-in .3s var(--ease);
}
.set-group { margin-bottom: 26px; }
.set-title { font-size: 17px; font-weight: 750; letter-spacing: -.01em; margin-bottom: 4px; }
.set-hint { font-size: 13px; color: var(--muted); margin-bottom: 12px; }

.set-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border-radius: var(--r-md);
  padding: 12px 12px 12px 14px; margin-bottom: 9px; box-shadow: var(--shadow-1);
}
.set-row-body { flex: 1; min-width: 0; }
.set-row-name { display: block; font-weight: 650; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.set-row-meta { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.set-row-actions { display: flex; gap: 6px; flex: none; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--bg); color: var(--ink-2); border: 1.5px solid var(--line);
  transition: transform .15s var(--ease), background .15s ease;
}
.icon-btn:active { transform: scale(.9); }
.icon-btn.danger { color: var(--danger); border-color: #F6D6D4; background: var(--danger-bg); }

.btn-outline {
  width: 100%; min-height: 48px; border-radius: var(--r-sm);
  border: 1.5px dashed var(--line); background: transparent;
  color: var(--ink-2); font-weight: 650; font-size: 14.5px;
  transition: border-color .15s ease, color .15s ease;
}
.btn-outline:active { border-color: var(--accent); color: var(--accent); }

.set-info li {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border-radius: var(--r-sm);
  padding: 12px 14px; margin-bottom: 8px; font-size: 14.5px;
  box-shadow: var(--shadow-1);
}
.set-info b { font-weight: 700; font-size: 13.5px; }
.set-info .s-ready { color: var(--success); }
.set-info .s-loading { color: var(--warn); }
.set-info .s-error { color: var(--danger); }
.set-info .s-disabled, .set-info .s-cold { color: var(--muted); }

/* four tabs need a little more room on narrow phones */
@media (max-width: 360px) {
  .tab { font-size: 9.5px; }
  .tab svg { width: 20px; height: 20px; }
}

/* big stop control inside the voice panel (the mic FAB is behind the overlay) */
.voice-stop {
  width: 74px; height: 74px; border-radius: 50%;
  margin: 14px auto 2px; display: grid; place-items: center;
  background: linear-gradient(140deg, #DC2626, #B91C1C); color: #fff;
  box-shadow: 0 10px 26px rgba(220, 38, 38, .40);
  animation: stop-breathe 1.6s ease-in-out infinite;
  transition: transform .15s var(--ease);
}
.voice-stop:active { transform: scale(.9); }
@keyframes stop-breathe {
  0%, 100% { box-shadow: 0 10px 26px rgba(220,38,38,.40); }
  50% { box-shadow: 0 10px 34px rgba(220,38,38,.65); }
}
@media (prefers-reduced-motion: reduce) { .voice-stop { animation: none; } }

/* long amounts shrink instead of wrapping or spilling */
.balance-value { white-space: nowrap; overflow: hidden; }
.stat p:last-child { white-space: nowrap; overflow: hidden; }
.tx-amount, .doc-amount, .project-total { max-width: 38vw; overflow: hidden; text-overflow: ellipsis; }


/* ---- signs of life during the long OCR wait ---- */
.proc-steps { display: flex; gap: 8px; margin-top: 18px; }
.proc-step {
  width: 34px; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,.18); transition: background .4s ease;
}
.proc-step.on { background: #93C5FD; }
.proc-elapsed { margin-top: 10px; font-size: 13px; color: #7E8FAC;
  font-variant-numeric: tabular-nums; min-height: 18px; }

/* skeleton placeholders so lists never appear frozen while loading */
.skel { background: var(--surface); border-radius: var(--r-md);
  padding: 13px 14px; margin-bottom: 10px; box-shadow: var(--shadow-1);
  display: flex; align-items: center; gap: 13px; }
.skel-box { border-radius: 12px; background: linear-gradient(90deg,
  #EDF1F7 25%, #F7F9FC 50%, #EDF1F7 75%); background-size: 240% 100%;
  animation: shimmer 1.25s ease-in-out infinite; }
.skel-ico { width: 44px; height: 44px; flex: none; }
.skel-lines { flex: 1; }
.skel-l1 { height: 12px; width: 62%; margin-bottom: 8px; }
.skel-l2 { height: 10px; width: 38%; }
@keyframes shimmer { to { background-position: -240% 0; } }
@media (prefers-reduced-motion: reduce) { .skel-box { animation: none; } }

/* the scan bar shows it is working, never a dead button */
.fab.working { opacity: .75; pointer-events: none; }

/* Idle "listening" wave — CSS so a busy main thread can never freeze it. */
.voice-wave.idle i {
  height: 12px;
  animation: wave-idle 1s ease-in-out infinite;
  will-change: transform;
}
.voice-wave.idle i:nth-child(1) { animation-delay: 0s; }
.voice-wave.idle i:nth-child(2) { animation-delay: .09s; }
.voice-wave.idle i:nth-child(3) { animation-delay: .18s; }
.voice-wave.idle i:nth-child(4) { animation-delay: .27s; }
.voice-wave.idle i:nth-child(5) { animation-delay: .36s; }
.voice-wave.idle i:nth-child(6) { animation-delay: .45s; }
.voice-wave.idle i:nth-child(7) { animation-delay: .54s; }
@keyframes wave-idle {
  0%, 100% { transform: scaleY(.6); }
  50%      { transform: scaleY(2.6); }
}
@media (prefers-reduced-motion: reduce) {
  .voice-wave.idle i { animation-duration: 2.4s; }
}


/* ---- long amounts in lists: never overlap, never push the layout ---- */
.doc-item, .tx-item { overflow: hidden; }
.doc-amount, .tx-amount, .project-total {
  flex: none; max-width: 42%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.doc-amount.long, .tx-amount.long, .project-total.long { font-size: 12.5px; }
.doc-body, .tx-body, .project-body { min-width: 0; }

/* Labels are <span>s: without display:block, overflow/ellipsis are IGNORED on
   inline boxes and long text paints straight through the amount next to it. */
.tx-label, .tx-meta, .doc-title, .doc-sub { display: block; }

/* ============ Dépenses par catégorie ============ */
.link-btn { font-size: 13.5px; font-weight: 700; color: var(--accent); }
.link-btn:active { opacity: .6; }

.dep-cat {
  background: var(--surface); border-radius: var(--r-md);
  box-shadow: var(--shadow-1); margin-bottom: 10px; overflow: hidden;
}
.dep-cat-head {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 14px 14px; text-align: left;
}
.dep-cat-head .chev { transition: transform .2s var(--ease); color: var(--muted); flex: none; }
.dep-cat.open .chev { transform: rotate(90deg); }
.dep-cat-name { flex: 1; min-width: 0; font-weight: 750; font-size: 15.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dep-cat-total { font-weight: 800; font-variant-numeric: tabular-nums;
  white-space: nowrap; flex: none; }
.dep-cat-body { display: none; border-top: 1px solid var(--line); }
.dep-cat.open .dep-cat-body { display: block; }

.dep-sub {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 12px 14px 12px 22px; text-align: left;
  border-bottom: 1px solid var(--bg);
}
.dep-sub:active { background: var(--bg); }
.dep-sub-body { flex: 1; min-width: 0; }
.dep-sub-name { display: block; font-weight: 650; font-size: 14.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dep-sub-meta { display: flex; gap: 6px; margin-top: 3px; flex-wrap: wrap; }
.dep-sub-total { font-weight: 700; font-variant-numeric: tabular-nums;
  white-space: nowrap; flex: none; font-size: 14px; }
.dep-add-sub {
  width: 100%; padding: 11px 22px; text-align: left; font-size: 13.5px;
  font-weight: 650; color: var(--accent);
}
.dep-empty {
  background: var(--surface); border: 1.5px dashed var(--line);
  border-radius: var(--r-md); padding: 18px 16px; text-align: center;
  color: var(--muted); font-size: 14px;
}
.dep-empty b { color: var(--ink-2); }
.dep-empty .btn-outline { margin-top: 12px; }

/* status badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 750; padding: 2.5px 8px; border-radius: 999px;
  white-space: nowrap;
}
.badge.ok      { background: var(--success-bg); color: var(--success); }
.badge.warn    { background: var(--warn-bg); color: var(--warn); }
.badge.danger  { background: var(--danger-bg); color: var(--danger); }
.badge.neutral { background: #EEF1F6; color: var(--ink-2); }

/* alert banner on the budget screen */
.alert-banner {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: var(--warn-bg); border: 1.5px solid #FBE3B7;
  color: var(--warn); border-radius: var(--r-md);
  padding: 12px 14px; margin: 14px 0 2px; font-weight: 650; font-size: 14px;
  transition: transform .15s var(--ease);
}
.alert-banner:active { transform: scale(.98); }
.alert-banner.overdue { background: var(--danger-bg); border-color: #F6C6C2; color: var(--danger); }
.alert-banner .alert-ico { flex: none; display: grid; place-items: center; }
.alert-banner .alert-text { flex: 1; min-width: 0; text-align: left; }

/* ============ Fournisseurs ============ */
.screen-fournisseurs {
  padding: calc(var(--sat) + 22px) 20px calc(var(--sab) + 190px);
  animation: fade-in .3s var(--ease);
}
.fournisseur-item {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  background: var(--surface); border-radius: var(--r-md); padding: 14px;
  margin-bottom: 10px; box-shadow: var(--shadow-1);
  transition: transform .15s var(--ease);
}
.fournisseur-item:active { transform: scale(.98); }
.fournisseur-avatar {
  width: 46px; height: 46px; border-radius: 15px; flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: 17px;
  background: #EFF3FB; color: var(--accent);
}
.fournisseur-body { flex: 1; min-width: 0; }
.fournisseur-name { display: block; font-weight: 750; font-size: 15.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fournisseur-meta { display: block; font-size: 12.5px; color: var(--muted);
  margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fournisseur-total { font-weight: 700; font-size: 13.5px; color: var(--ink-2);
  white-space: nowrap; flex: none; }

/* ============ Formulaire générique ============ */
.form-card {
  width: min(92vw, 420px); max-height: 86dvh; overflow-y: auto;
  background: var(--surface); border-radius: var(--r-lg);
  padding: 22px 20px calc(var(--sab) + 18px);
  animation: pop-in .3s var(--ease);
}
.form-card h3 { font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.form-sub { font-size: 13.5px; color: var(--muted); margin: 4px 0 14px; }
.form-card .sheet-field { margin-bottom: 12px; }
.form-card select {
  width: 100%; min-height: 50px; border-radius: var(--r-sm);
  border: 1.5px solid var(--line); background: var(--surface);
  padding: 0 12px; font: inherit; color: var(--ink);
}
.form-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ============ Détail sous-catégorie ============ */
.cat-body { max-height: 68dvh; overflow-y: auto; }
.cat-total-row { display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 12px; }
.cat-total-label { font-size: 12px; font-weight: 650; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; }
.cat-total { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.cat-badges { display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }
.cat-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.cat-actions .btn-md { flex: 1; min-width: 120px; }

.pay-item {
  display: flex; align-items: center; gap: 11px;
  background: var(--bg); border-radius: var(--r-sm);
  padding: 11px 12px; margin-bottom: 8px;
}
.pay-ico { width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center; background: var(--surface);
  color: var(--ink-2); box-shadow: var(--shadow-1); }
.pay-body { flex: 1; min-width: 0; }
.pay-line1 { display: flex; align-items: baseline; gap: 8px; }
.pay-amount { font-weight: 750; font-variant-numeric: tabular-nums; }
.pay-meta { display: block; font-size: 12px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pay-actions { display: flex; gap: 6px; flex: none; }

/* relevé & alertes & facture picker lists */
#releve-matches, #alerts-list, #facture-list { margin: 6px 0 14px; max-height: 46dvh; overflow-y: auto; }
.match-item, .alert-item, .facture-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 4px; border-bottom: 1px solid var(--line);
}
.match-item label { flex: 1; min-width: 0; font-size: 14.5px; }
.match-item input { width: 20px; height: 20px; accent-color: var(--accent); }
.alert-item { align-items: flex-start; }
.alert-item .alert-txt { flex: 1; min-width: 0; font-size: 14px; }
.alert-item .alert-txt small { color: var(--muted); display: block; margin-top: 2px; }
.alert-call {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700; color: var(--accent);
  border: 1.5px solid var(--line); border-radius: 999px; padding: 7px 12px;
  text-decoration: none;
}
.facture-item { width: 100%; text-align: left; }
.facture-item:active { background: var(--bg); }
.facture-thumb { width: 52px; height: 40px; border-radius: 8px; object-fit: cover;
  background: #E8EDF5; flex: none; }
.facture-item .fi-body { flex: 1; min-width: 0; }
.facture-item .fi-name { display: block; font-weight: 650; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.facture-item .fi-meta { display: block; font-size: 12px; color: var(--muted); }

/* relevé card accent in the scan sheet */
.doc-card.releve { grid-column: 1 / -1; }
.doc-card.releve .ico { background: #EEF6F1; color: var(--success); }

/* ============ Revenus par client ============ */
.client-item {
  display: flex; flex-direction: column; gap: 8px; width: 100%; text-align: left;
  background: var(--surface); border-radius: var(--r-md); padding: 13px 14px;
  margin-bottom: 10px; box-shadow: var(--shadow-1);
  transition: transform .15s var(--ease);
}
.client-item:active { transform: scale(.98); }
.client-row1 { display: flex; align-items: center; gap: 11px; }
.client-avatar {
  width: 42px; height: 42px; border-radius: 14px; flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
  background: #EEF6F1; color: var(--success);
}
.client-body { flex: 1; min-width: 0; }
.client-name { display: block; font-weight: 750; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-meta { display: block; font-size: 12px; color: var(--muted); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-reste { flex: none; text-align: right; }
.client-reste b { display: block; font-size: 14px; font-weight: 800;
  font-variant-numeric: tabular-nums; white-space: nowrap; }
.client-reste small { font-size: 11px; color: var(--muted); }

.cp-bar { height: 7px; border-radius: 4px; background: var(--bg); overflow: hidden; }
.cp-fill { height: 100%; border-radius: 4px; width: 0;
  background: linear-gradient(90deg, var(--success), #34D399);
  transition: width .5s var(--ease); }

.client-progress { margin-bottom: 14px; }
.cp-row { display: flex; justify-content: space-between; margin-bottom: 8px; }
.cp-right { text-align: right; }
.cp-avance { font-size: 22px; font-weight: 800; color: var(--success);
  font-variant-numeric: tabular-nums; }
.cp-reste { font-size: 22px; font-weight: 800; color: var(--ink);
  font-variant-numeric: tabular-nums; }
.cp-prevu { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* estimation (devis) dans les sous-catégories */
.dep-estimate { font-size: 11.5px; color: var(--muted); display: block; margin-top: 2px; }
.dep-estimate.over { color: var(--danger); font-weight: 700; }
.est-bar { height: 4px; border-radius: 2px; background: var(--bg);
  overflow: hidden; margin-top: 4px; }
.est-fill { height: 100%; background: var(--accent); border-radius: 2px; }
.est-fill.over { background: var(--danger); }

/* ============ carte budget : trois tuiles ============ */
.balance-stats.three { gap: 8px; }
.balance-stats.three .stat { padding: 9px 10px; gap: 8px; }
.balance-stats.three .stat p:first-child { font-size: 11px; }
.balance-stats.three .stat p:last-child { font-size: 13.5px; }
.balance-stats.three .stat-ico { width: 30px; height: 30px; border-radius: 9px; }
.stat-ico.diff { background: rgba(147,197,253,.20); color: #93C5FD; }
.stat-ico.diff.gain { background: rgba(16,185,129,.22); color: #6EE7B7; }
.stat-ico.diff.loss { background: rgba(248,113,113,.18); color: #FCA5A5; }
@media (max-width: 360px) {
  .balance-stats.three { flex-direction: column; }
}

/* ============ devis / estimation dans la feuille de sous-catégorie ==== */
.cat-devis-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.devis-chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1.5px dashed var(--line); border-radius: 999px;
  padding: 8px 14px; font-size: 13px; font-weight: 650; color: var(--ink-2);
  transition: border-color .15s ease, color .15s ease;
}
.devis-chip:active { border-color: var(--accent); color: var(--accent); }

.cat-group-title {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 13px; font-weight: 750; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: .05em;
  margin: 14px 2px 8px;
}
.cat-group-title span { font-weight: 600; color: var(--muted);
  text-transform: none; letter-spacing: 0; font-size: 12.5px; }
.cp-bar .cp-fill.over, .cp-fill.over {
  background: linear-gradient(90deg, var(--danger), #F87171);
}

/* ============ profil fournisseur ============ */
.fp-hero { text-align: center; padding: 18px 16px 6px; }
.fp-avatar {
  width: 76px; height: 76px; border-radius: 26px; margin: 0 auto 12px;
  display: grid; place-items: center; font-weight: 800; font-size: 26px;
  background: linear-gradient(135deg, var(--hero-1), var(--hero-2)); color: #fff;
  box-shadow: var(--shadow-2);
}
.fp-hero h3 { font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.fp-contact { color: var(--muted); font-size: 14px; margin-top: 2px; }
.fp-actions { display: flex; justify-content: center; gap: 10px; margin-top: 14px; }
.fp-actions .btn-md { min-width: 150px; display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; }

.fp-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin: 18px 16px 6px;
}
.fp-stat {
  background: var(--surface); border-radius: var(--r-md);
  box-shadow: var(--shadow-1); padding: 12px 8px; text-align: center;
}
.fp-stat b { display: block; font-size: 16px; font-weight: 800;
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }
.fp-stat span { font-size: 11px; color: var(--muted); font-weight: 600; }

.fp-block { margin: 16px 16px 0; }
.fp-block h4 { font-size: 13px; font-weight: 750; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.fp-block > p { background: var(--surface); border-radius: var(--r-sm);
  padding: 12px 14px; font-size: 14.5px; box-shadow: var(--shadow-1); }
.fp-group {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 12px 2px 6px; font-size: 14px;
}
.fp-group b { font-weight: 750; }
.fp-group span { color: var(--muted); font-size: 13px;
  font-variant-numeric: tabular-nums; }
#fp-history .pay-item { background: var(--surface); box-shadow: var(--shadow-1); }
.review-top #fp-title-bar { flex: 1; text-align: center; font-size: 16px; }

/* ============ tableau clients du carnet : Cash | Chèque | Avance | Reste == */
.client-modes {
  /* minmax(0,…) : sans lui une piste ne peut pas devenir plus étroite que son
     contenu insécable — les tuiles sortaient de l'écran entre 400 et 480px */
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px;
}
.cm { background: var(--bg); border-radius: 10px; padding: 7px 6px; text-align: center; }
.cm small { display: block; font-size: 10px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; }
.cm b { display: block; font-size: 12.5px; font-weight: 750; margin-top: 1px;
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.cm:nth-child(3) b { color: var(--success); }
.cm:nth-child(4) b { color: var(--ink); }

/* classement sur l'écran de vérification */
.classify-block {
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: var(--r-md); padding: 14px 14px 4px; margin: 0 0 14px;
}
.classify-block select {
  width: 100%; min-height: 48px; border-radius: var(--r-sm);
  border: 1.5px solid var(--line); background: var(--surface);
  padding: 0 12px; font: inherit; color: var(--ink);
}


/* ============ lien facture <-> chèque : un vrai contrôle, pas une icône ==== */
.pay-line3 { display: block; margin-top: 6px; }
.fchip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px;
  border: 1.5px dashed var(--line); color: var(--accent); background: var(--surface);
  transition: transform .12s var(--ease);
}
.fchip:active { transform: scale(.96); }
.fchip.linked { border-style: solid; border-color: #BBF7D0; background: var(--success-bg); color: var(--success); }
.fchip.missing { border-style: solid; border-color: #F6C6C2; background: var(--danger-bg); color: var(--danger); }

/* ============ documents rangés par usage : grille sur les profils ======== */
ul.doc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.doc-tile {
  display: flex; flex-direction: column; width: 100%; text-align: left;
  background: var(--surface); border-radius: var(--r-sm); overflow: hidden;
  box-shadow: var(--shadow-1); transition: transform .15s var(--ease);
}
.doc-tile:active { transform: scale(.97); }
.doc-tile img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #E8EDF5; }
.doc-tile-cap { padding: 7px 8px 8px; }
.doc-tile-cap b { display: block; font-size: 11.5px; font-weight: 750; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.doc-tile-cap small { display: block; font-size: 10.5px; color: var(--muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.fp-avatar.client { background: linear-gradient(135deg, #065F46, #059669); }
@media (max-width: 360px) { ul.doc-grid { grid-template-columns: repeat(2, 1fr); } }

/* ============ % au bout des barres de progression ======================== */
.cp-bar-row { display: flex; align-items: center; gap: 9px; }
.cp-bar-row .cp-bar { flex: 1; }
.cp-pct {
  font-size: 12.5px; font-weight: 800; color: var(--ink-2);
  min-width: 40px; text-align: right; font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.cp-pct.over { color: var(--danger); }

/* ============ devis / estimation : la référence mise en avant ============ */
.ref-price {
  display: flex; align-items: center; gap: 11px;
  margin: 2px 0 10px; padding: 11px 13px;
  background: linear-gradient(135deg, #FFFBEB, #FEF3C7);
  border: 1.5px solid #F59E0B; border-radius: var(--r-md);
}
.ref-ico {
  width: 36px; height: 36px; border-radius: 12px; flex: none;
  display: grid; place-items: center; background: #F59E0B; color: #fff;
}
.ref-body { flex: 1; min-width: 0; }
.ref-body small {
  display: block; font-size: 11.5px; font-weight: 700; color: #92400E;
  text-transform: uppercase; letter-spacing: .05em;
}
.ref-body b {
  display: block; font-size: 19px; font-weight: 800; color: #78350F;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ref-tag {
  flex: none; font-size: 10.5px; font-weight: 800; color: #92400E;
  background: rgba(245, 158, 11, .18); border-radius: 999px;
  padding: 4px 9px; text-transform: uppercase; letter-spacing: .06em;
}

/* ============ rappel WhatsApp dans les alertes =========================== */
.alert-call.wa {
  display: inline-flex; align-items: center; gap: 6px;
  background: #059669; color: #fff; border-color: #059669;
}
.alert-call.wa:active { transform: scale(.96); }

/* ============ encaissement manuel : badge-interrupteur + confirmation ==== */
.badge-switch {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 800; letter-spacing: .01em;
  border-radius: 999px; padding: 4px 10px 4px 8px; flex: none;
  border: 1.5px solid transparent; cursor: pointer;
  transition: transform .15s var(--ease), box-shadow .15s var(--ease);
}
.badge-switch:active { transform: scale(.94); }
.badge-switch.ok {
  background: var(--success-bg); color: var(--success);
  border-color: rgba(5, 150, 105, .35);
}
.badge-switch.warn {
  background: var(--warn-bg); color: var(--warn);
  border-color: rgba(245, 158, 11, .45);
  box-shadow: 0 1px 3px rgba(180, 83, 9, .12);
}
.badge-switch .bs-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--warn-line);
  animation: bs-blink 2.2s ease-in-out infinite;
}
@keyframes bs-blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.enc-cheque {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg); border-radius: var(--r-md);
  padding: 12px 14px; margin: 10px 0 12px;
}
.enc-ico {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: #EFF3FB; color: var(--accent);
}
.enc-body { min-width: 0; }
.enc-body b {
  display: block; font-size: 18px; font-weight: 800;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.enc-body small {
  display: block; font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.btn-md.danger-solid {
  background: var(--danger); color: #fff;
}

/* ==========================================================================
   RESPONSIVE — les nombres ne se compriment jamais : quand la place manque,
   la carte prend la ligne entière et le reste s'empile proprement.
   ========================================================================== */

/* garde-fou global : jamais de défilement horizontal */
#app { overflow-x: clip; }

/* la carte solde : sous 420px, chaque statistique prend sa propre ligne —
   étiquette à gauche, montant à droite, toute la largeur pour les chiffres */
@media (max-width: 459px) {
  .balance-stats { flex-direction: column; gap: 8px; }
  .balance-stats .stat { width: 100%; padding: 10px 14px; }
  .balance-stats .stat > div {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 10px;
  }
  .balance-stats .stat p:last-child { font-size: 16px; text-align: right; }
}

/* tuiles client (Virement | Chèque | Avance | Reste) : 2×2 sous 400px */
@media (max-width: 479px) {
  .client-modes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cm b { font-size: 14px; }
}

/* Payé/Reste et Avance/Reste : deux colonnes à largeur FIXE (grille) —
   jamais de retour à la ligne bancal : chaque montant rétrécit dans SA
   colonne (fitAmount mesure enfin un conteneur borné). */
.cp-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 4px 14px; align-items: end; }
.cp-row > div { min-width: 0; }
.cp-avance, .cp-reste { white-space: nowrap; }  /* fitAmount rétrécit, jamais de pli */
@media (max-width: 359px) {
  .cp-row { display: block; }
  .cp-row > div {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 10px;
  }
  .cp-row .cp-right { text-align: right; margin-top: 4px; }
  .cp-avance, .cp-reste { font-size: 19px; }
}

/* stats des profils : sous 360px, une ligne par stat */
@media (max-width: 359px) {
  .fp-stats { grid-template-columns: 1fr; gap: 6px; }
  .fp-stat {
    display: flex; align-items: center; justify-content: space-between;
    text-align: left; padding: 10px 14px;
  }
  .fp-stat b { font-size: 15px; }
}

/* lignes de paiement : le badge passe sous le montant plutôt que de
   l'écraser quand la largeur manque */
.pay-line1 { flex-wrap: wrap; row-gap: 3px; }
.pay-amount { min-width: 0; }

/* montants des transactions/documents : le libellé cède, jamais le chiffre */
.tx-amount, .doc-amount { flex: none; }

/* la carte référence (devis/estimation) : le montant garde sa ligne */
@media (max-width: 359px) {
  .ref-price { flex-wrap: wrap; }
  .ref-body { flex-basis: 100%; order: 3; margin-top: 2px; }
  .ref-body b { font-size: 18px; }
}

/* marges plus fines sur très petits écrans : chaque pixel va aux chiffres */
@media (max-width: 359px) {
  .screen-home, .screen-projects, .screen-docs,
  .screen-settings, .screen-fournisseurs {
    padding-left: 12px; padding-right: 12px;
  }
  .balance-card { padding: 20px 16px 18px; }
}

/* annuaire clients : même carte que les fournisseurs, teinte revenus */
.fournisseur-avatar.client { background: linear-gradient(135deg, #065F46, #059669); }
.fournisseur-item.client { border-left: 4px solid var(--success); }

/* ============ WhatsApp : état de la passerelle + code d'appairage ======== */
.wa-state {
  display: flex; align-items: center; gap: 9px;
  background: var(--bg); border-radius: var(--r-sm);
  padding: 10px 12px; margin: 4px 0 12px;
  font-size: 13.5px; font-weight: 650; color: var(--ink-2);
}
.wa-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.wa-dot.on { background: var(--success); box-shadow: 0 0 0 3px rgba(5,150,105,.18); }
.wa-dot.wait { background: var(--warn-line); animation: bs-blink 1.6s ease-in-out infinite; }
.wa-dot.off { background: var(--danger); }

.wa-code {
  background: linear-gradient(135deg, #ECFDF5, #D1FAE5);
  border: 1.5px solid #059669; border-radius: var(--r-md);
  padding: 14px; margin: 4px 0 12px; text-align: center;
}
.wa-code-label {
  font-size: 11px; font-weight: 800; letter-spacing: .07em;
  text-transform: uppercase; color: #065F46;
}
.wa-code-value {
  font-size: clamp(26px, 8vw, 34px); font-weight: 800; letter-spacing: .12em;
  color: #064E3B; margin: 4px 0 8px; font-variant-numeric: tabular-nums;
}
.wa-code-help { font-size: 12.5px; color: #065F46; line-height: 1.5; }

.switch-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.switch-row > span { flex: 1; min-width: 0; }
.switch-row b { display: block; font-size: 14px; font-weight: 700; }
.switch-row small { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.switch-row input[type="checkbox"] { width: 22px; height: 22px; flex: none; margin-top: 2px; accent-color: var(--accent); }

/* ============ badges des cartes : jamais hors de la carte =============== */
/* Un badge « insécable » posé à côté d'un texte flexible dépassait du bord
   sur petit écran. Il a désormais sa propre ligne, et s'il reste trop long
   il passe à la ligne au lieu de déborder. */
.client-flags { display: flex; flex-wrap: wrap; gap: 6px; }
.client-flags .badge { white-space: normal; max-width: 100%; }

/* garde-fou général : aucun badge ne peut dépasser son conteneur */
.badge { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

/* ==========================================================================
   FINITION — boutons d'action, icônes, petits textes.
   Règle : une étiquette peut passer à la ligne, jamais s'écraser ; une icône
   garde sa taille ; un petit texte a toujours sa marge de respiration.
   ========================================================================== */

/* boutons moyens : du vrai rembourrage et un interligne prévu pour 2 lignes */
.btn-md {
  padding: 10px 14px;
  line-height: 1.25;
}
/* les icônes ne se déforment JAMAIS, quel que soit le texte à côté */
.btn-md svg, .btn-outline svg, .devis-chip svg, .fchip svg,
.alert-call svg, .capture-btn svg, .badge-switch svg, .head-btn svg,
.fp-actions svg { flex: none; }

/* les rangées d'actions des fiches (client, sous-catégorie, réglages) :
   sur écran étroit chaque action prend SA ligne entière — icône à gauche,
   étiquette lisible — au lieu de quatre boutons écrasés à 3 lignes chacun */
.cat-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
  gap: 8px;
}
.cat-actions .btn-md {
  min-width: 0;
  justify-content: flex-start;
  text-align: left;
}
.cat-actions .btn-md svg { margin-right: 2px; }

/* chips (contrat, profil, devis, estimation) : à leur aise ou pleine ligne */
.cat-devis-row { gap: 8px; }
.devis-chip { flex: 1 1 auto; justify-content: center; min-width: 0; }
.devis-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* petits textes : un rythme unique dans toute l'application */
.set-hint { line-height: 1.55; margin: 2px 0 12px; }
.form-sub { line-height: 1.55; }
.field-hint { line-height: 1.5; margin-top: 4px; }
.cp-prevu { line-height: 1.5; }
.sheet-field > span { line-height: 1.45; }
.sheet-field > span small { display: block; font-weight: 500; color: var(--muted);
  margin-top: 1px; }
.tx-meta, .pay-meta, .doc-sub, .fournisseur-meta, .client-meta {
  line-height: 1.45;
}

/* titres de groupes dans les fiches : la respiration au-dessus est
   proportionnelle — jamais collés au bloc précédent */
.cat-group-title { margin-top: 18px; }
.cat-group-title:first-of-type { margin-top: 14px; }

/* actions du profil (Appeler…) : centrées, icône alignée sur le texte */
.fp-actions .btn-md { flex: none; }

/* modales : le contenu ne colle jamais aux bords sur petit écran */
@media (max-width: 359px) {
  .form-card { padding-left: 16px; padding-right: 16px; }
  .cat-actions { grid-template-columns: 1fr; }
}

/* ============ carte projet : nom + montant, puis le détail dessous ======= */
.project-item { flex-direction: column; align-items: stretch; gap: 3px; }
.project-row1 {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; min-width: 0;
}
.project-row1 .project-name { flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; }
.project-row1 .project-total { flex: none; max-width: none; }
.project-meta { line-height: 1.5; margin-top: 0; }

/* ============ modale d'alertes : texte au-dessus, actions dessous ======== */
.alert-item { display: flex; flex-direction: column; align-items: stretch;
  gap: 9px; }
.alert-item .alert-txt { line-height: 1.5; }
.alert-actions { display: flex; flex-wrap: wrap; gap: 7px; }

/* ============ carte client compacte (une ligne, détail dans la fiche) ==== */
.client-item.compact {
  flex-direction: row; align-items: center; gap: 11px;
}
.client-item.compact .client-body { flex: 1; min-width: 0; }
.client-item.compact .client-meta.warn { color: var(--warn); font-weight: 650; }
.client-amount { flex: none; text-align: right; }
.client-amount b { display: block; font-size: 14.5px; font-weight: 800;
  color: var(--success); font-variant-numeric: tabular-nums; white-space: nowrap; }
.client-amount small { font-size: 10.5px; color: var(--muted); font-weight: 650;
  text-transform: uppercase; letter-spacing: .05em; }

/* ==========================================================================
   COMPTABILITÉ — quatre grandes cartes, zéro détail avant le toucher.
   ========================================================================== */
.kpi-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.kpi {
  position: relative; display: flex; flex-direction: column;
  align-items: flex-start; gap: 3px; text-align: left;
  background: var(--surface); border-radius: var(--r-lg);
  padding: 15px 16px 14px; box-shadow: var(--shadow-1);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease);
  min-height: 108px;
}
.kpi:active { transform: scale(.97); }
.kpi-ico {
  width: 36px; height: 36px; border-radius: 12px;
  display: grid; place-items: center; margin-bottom: 3px;
}
.kpi.rev .kpi-ico { background: var(--success-bg); color: var(--success); }
.kpi.dep .kpi-ico { background: var(--danger-bg); color: var(--danger); }
.kpi.ben .kpi-ico { background: #EFF3FB; color: var(--accent); }
.kpi.cred .kpi-ico { background: var(--warn-bg); color: var(--warn); }
.kpi-label {
  font-size: 11.5px; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.kpi-value {
  font-size: 17px; font-weight: 800; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kpi.rev .kpi-value { color: var(--success); }
.kpi.dep .kpi-value { color: var(--danger); }
.kpi.ben .kpi-value { color: var(--accent); }
.kpi.ben.loss .kpi-value { color: var(--danger); }
.kpi.cred .kpi-value { color: var(--warn); }
.kpi-more {
  position: absolute; top: 14px; right: 14px;
  font-size: 18px; font-weight: 700; color: var(--muted); opacity: .55;
}

/* le héros de la sous-page de détail */
.cd-hero {
  margin: 14px 16px 6px; border-radius: var(--r-lg); color: #fff;
  padding: 22px 20px 18px; box-shadow: var(--shadow-2);
  background: linear-gradient(135deg, var(--hero-1), var(--hero-2));
}
.cd-hero.rev  { background: linear-gradient(135deg, #064E3B, #059669); }
.cd-hero.dep  { background: linear-gradient(135deg, #7F1D1D, #DC2626); }
.cd-hero.ben  { background: linear-gradient(135deg, var(--hero-1), #2563EB); }
.cd-hero.ben.loss { background: linear-gradient(135deg, #7F1D1D, #B91C1C); }
.cd-hero.cred { background: linear-gradient(135deg, #78350F, #D97706); }
.cd-hero-label { font-size: 12px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; opacity: .8; }
.cd-hero-value { font-size: clamp(28px, 8.5vw, 36px); font-weight: 800;
  letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin-top: 4px; }
.cd-hero-sub { font-size: 12.5px; opacity: .85; margin-top: 6px; line-height: 1.5; }
#cd-body { padding: 4px 16px 30px; }
.cd-amt { flex: none; font-weight: 800; font-size: 14px;
  font-variant-numeric: tabular-nums; white-space: nowrap; }
.cd-amt.in { color: var(--success); }
.cd-amt.out { color: var(--danger); }
.cd-ben-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px; margin: 14px 0; }
.cd-ben { background: var(--surface); border-radius: var(--r-md);
  box-shadow: var(--shadow-1); padding: 14px; }
.cd-ben small { display: block; font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.cd-ben b { display: block; font-size: 17px; font-weight: 800; margin-top: 3px;
  font-variant-numeric: tabular-nums; }
.cd-ben.rev b { color: var(--success); }
.cd-ben.dep b { color: var(--danger); }

/* ==========================================================================
   FICHES — les groupes (chèques, espèces, virements) sont des cartes
   repliées : le compte et le total suffisent, le détail s'ouvre au toucher.
   ========================================================================== */
.group-card {
  background: var(--bg); border-radius: var(--r-md);
  margin: 10px 0; overflow: hidden;
}
.group-card .cat-group-title {
  margin: 0; padding: 13px 14px; cursor: pointer; user-select: none;
}
.group-card .cat-group-title::after {
  content: "›"; font-size: 17px; font-weight: 700; color: var(--muted);
  transform: rotate(90deg); transition: transform .2s var(--ease);
  margin-left: 8px;
}
.group-card.open .cat-group-title::after { transform: rotate(-90deg); }
.group-card > ul { display: none; padding: 0 10px 10px; }
.group-card.open > ul { display: block; }
.group-card .pay-item { background: var(--surface); }

/* très petits écrans : les cartes KPI passent en liste — le chiffre entier
   vaut plus que la grille */
@media (max-width: 359px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi { min-height: 0; flex-direction: row; align-items: center; gap: 12px;
         padding: 12px 14px; }
  .kpi-ico { margin-bottom: 0; }
  .kpi-label { flex: 1; }
  .kpi-value { font-size: 16px; }
  .kpi-more { position: static; }
}


/* ==========================================================================
   QUALITÉ TACTILE — chaque commande atteint 44px de zone de toucher.
   Deux moyens : grandir pour de vrai, ou étendre la zone au-delà du visuel
   (::after) quand l'esthétique doit rester légère.
   ========================================================================== */

/* grandissent pour de vrai */
.icon-btn, .sheet-back, .head-btn { width: 44px; height: 44px; }
.chip { min-height: 44px; display: inline-flex; align-items: center; }
.devis-chip { min-height: 44px; }
.dep-add-sub { min-height: 44px; }
.btn-outline { min-height: 48px; }
.overlay-cancel { min-height: 44px; }

/* zone étendue, visuel inchangé */
.link-btn, .project-chip, .badge-switch, .fchip, .alert-call, .rev-proof,
#doc-search-clear {
  position: relative;
}
.link-btn::after, .project-chip::after, .badge-switch::after, .fchip::after,
.alert-call::after, .rev-proof::after, #doc-search-clear::after {
  content: ""; position: absolute; inset: -9px;
}

/* retour visuel au toucher pour les commandes légères */
.chip:active, .tab:active, .link-btn:active, .badge-switch:active,
.fchip:active { opacity: .55; }
.head-btn.neutral {
  background: var(--surface); color: var(--ink-2);
  border: 1.5px solid var(--line); box-shadow: none;
}
.head-btn.neutral:active { transform: scale(.92); }

/* plancher typographique : rien sous 11px */
.cm small { font-size: 11px; }
.doc-tile-cap small { font-size: 11px; }
.client-amount small { font-size: 11px; }
.ref-tag { font-size: 11px; }
.wa-code-label { font-size: 11px; }

/* les liens-boutons sont fins (20px) : leur zone déborde davantage */
.link-btn::after { inset: -12px; }


/* ==========================================================================
   VIBE PREMIUM — les détails qui font « vraie application ».
   Recette High-Tech Boutique : cartes blanches à liseré net + ombre douce,
   barre translucide floutée, pressions à ressort, entrées en fondu décalé.
   ========================================================================== */

/* --- cartes : liseré 1px + ombre en deux couches (net de près, doux de loin) */
:root {
  --shadow-1: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 20px rgba(15, 23, 42, .06);
  --shadow-2: 0 2px 6px rgba(15, 23, 42, .08), 0 16px 40px rgba(15, 23, 42, .16);
}
.kpi, .tx-item, .project-item, .client-item, .fournisseur-item,
.fp-stat, .cd-ben, .doc-item {
  border: 1px solid rgba(226, 232, 240, .8);
}

/* --- barre d'onglets : translucide et floutée, avec pastille active ------- */
.tabbar {
  background: rgba(255, 255, 255, .82);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid rgba(226, 232, 240, .9);
}
.tab { position: relative; transition: color .18s var(--ease); }
.tab::before {
  content: ""; position: absolute; top: 2px; left: 50%;
  width: 44px; height: 30px; border-radius: 999px;
  background: #EFF3FB; opacity: 0;
  transform: translateX(-50%) scale(.6);
  transition: opacity .22s var(--ease), transform .22s var(--ease);
  z-index: -1;
}
.tab.on::before { opacity: 1; transform: translateX(-50%) scale(1); }
.tab svg { position: relative; }

/* --- pression unifiée : ressort discret partout ---------------------------- */
.kpi:active, .tx-item:active, .project-item:active, .client-item:active,
.fournisseur-item:active, .doc-item:active, .doc-tile:active,
.group-card .cat-group-title:active {
  transform: scale(.98);
  transition-duration: .08s;
}

/* --- entrée de page : contenu en fondu montant, décalé ---------------------
   (le bloc reduced-motion global neutralise tout ceci automatiquement) */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
.kpi-grid .kpi { animation: rise-in .34s cubic-bezier(.32,.72,0,1) backwards; }
.kpi-grid .kpi:nth-child(2) { animation-delay: .05s; }
.kpi-grid .kpi:nth-child(3) { animation-delay: .10s; }
.kpi-grid .kpi:nth-child(4) { animation-delay: .15s; }
.tx-section, .dep-section, .clients-section { animation: rise-in .38s cubic-bezier(.32,.72,0,1) .12s backwards; }

/* --- modales : apparition depuis le geste (échelle + fondu) --------------- */
@keyframes card-pop {
  from { opacity: 0; transform: translateY(18px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.overlay:not(.hidden) .form-card { animation: card-pop .26s cubic-bezier(.32,.72,0,1); }

/* --- sous-pages de détail : glissement latéral (continuité spatiale) ------ */
@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(26px); }
  to   { opacity: 1; transform: none; }
}
#compta-detail:not(.hidden) .review-scroll,
#cprofile:not(.hidden) .review-scroll,
#fprofile:not(.hidden) .review-scroll {
  animation: slide-in-right .28s cubic-bezier(.32,.72,0,1);
}

/* --- héros : la signature radiale de la marque ----------------------------- */
.cd-hero { position: relative; overflow: hidden; }
.cd-hero::after {
  content: ""; position: absolute; right: -60px; top: -60px;
  width: 190px; height: 190px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.16), transparent 65%);
  pointer-events: none;
}

/* --- états vides : halo doux derrière l'icône ------------------------------ */
.empty-state svg, .dep-empty svg {
  background: radial-gradient(circle, #EFF3FB 0%, transparent 72%);
  border-radius: 50%;
  padding: 14px;
  box-sizing: content-box;
}

/* --- titres : Inter serrée, chiffres soignés -------------------------------- */
h1 { letter-spacing: -.03em; }
.kpi-value, .cd-hero-value, .cp-avance, .cp-reste, .pay-amount,
.tx-amount, .doc-amount, .project-total, .client-amount b {
  font-feature-settings: "tnum" 1, "cv05" 1;
}

/* --- barres de progression : fine touche de relief -------------------------- */
.cp-fill {
  background: linear-gradient(180deg, #34D399, var(--success));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35);
}


/* ==========================================================================
   SOUS-PAGES Dépenses / Revenus : elles portent maintenant TOUT le détail
   (prestations, clients). Les feuilles s'ouvrent AU-DESSUS d'elles.
   ========================================================================== */
.sheet-backdrop { z-index: 78; }
.sheet { z-index: 79; }

#cd-home-sections { padding: 0 16px; }
#cd-home-sections .tx-section { margin-top: 20px; }
#cd-home-sections .tx-section.hidden { display: none; }
#cd-body .group-card { margin: 18px 0 0; }
#cd-body .group-card .pay-item { background: var(--surface); }

/* ==========================================================================
   v12 — la barre reste visible sur les sous-pages ; cartes navigantes ;
   FAB espèces ; page Projets raffinée.
   ========================================================================== */

/* pile : sous-pages (70) < barre (72) < feuilles (74/75) < écran de
   vérification du scan (76/77) < modales (80) < toasts (90) */
.tabbar { z-index: 76; }
#screen-review { z-index: 77; }
#screen-review .review-actions, .review-actions { z-index: 78; }
.with-tabbar .review-scroll { padding-bottom: calc(var(--sab) + 86px); }

/* héros navigant : il s'enfonce comme une carte */
.cd-hero.nav { cursor: pointer; transition: transform .15s var(--ease); }
.cd-hero.nav:active { transform: scale(.98); }

/* cartes de type : chevron « › » fixe (navigation, pas accordéon) */
#client-cheques-card .cat-group-title::after,
#client-especes-card .cat-group-title::after,
#cat-cheques-card .cat-group-title::after,
#cat-especes-card .cat-group-title::after {
  transform: none;
}
#client-cheques-card, #client-especes-card,
#cat-cheques-card, #cat-especes-card {
  background: var(--surface); border: 1px solid rgba(226, 232, 240, .8);
  box-shadow: var(--shadow-1);
  transition: transform .15s var(--ease);
}
#client-cheques-card:active, #client-especes-card:active,
#cat-cheques-card:active, #cat-especes-card:active { transform: scale(.98); }

/* héros de la sous-page de type */
.td-hero {
  display: flex; align-items: center; gap: 13px;
  margin: 14px 16px 8px; padding: 16px;
  background: var(--surface); border: 1px solid rgba(226, 232, 240, .8);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
.td-hero-ico {
  width: 42px; height: 42px; border-radius: 13px; flex: none;
  display: grid; place-items: center;
  background: #EFF3FB; color: var(--accent);
}
.td-hero-body { min-width: 0; }
.td-hero-body b {
  display: block; font-size: 22px; font-weight: 800; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.td-hero-body small { font-size: 12.5px; color: var(--muted); font-weight: 600; }
#td-list { padding: 4px 16px 10px; }
#td-list .pay-item { background: var(--surface); border: 1px solid rgba(226,232,240,.8); }

/* FAB espèces : cercle vert, même famille que la barre de scan */
.cash-fab {
  pointer-events: auto; flex: none;
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #047857, var(--success));
  color: #fff; box-shadow: 0 8px 22px rgba(5, 150, 105, .35);
  transition: transform .15s var(--ease);
}
.cash-fab:active { transform: scale(.92); }

/* choix Espèces : deux grandes tuiles */
.cash-choices { display: grid; grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px; margin: 8px 0 14px; }
.cash-choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  text-align: left; padding: 14px; border-radius: var(--r-md);
  border: 1.5px solid var(--line); background: var(--surface);
  transition: transform .15s var(--ease);
}
.cash-choice:active { transform: scale(.96); }
.cash-choice-ico { width: 34px; height: 34px; border-radius: 11px;
  display: grid; place-items: center; margin-bottom: 2px; }
.cash-choice.in .cash-choice-ico { background: var(--success-bg); color: var(--success); }
.cash-choice.out .cash-choice-ico { background: var(--danger-bg); color: var(--danger); }
.cash-choice b { font-size: 15px; font-weight: 800; }
.cash-choice small { font-size: 12px; color: var(--muted); line-height: 1.4; }
@media (max-width: 359px) { .cash-choices { grid-template-columns: 1fr; } }

/* ---- page Projets : cartes raffinées ------------------------------------ */
.project-item { border: 1px solid rgba(226, 232, 240, .8); }
.project-flow { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.pm-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 750; border-radius: 999px; padding: 3px 9px;
  font-variant-numeric: tabular-nums;
}
.pm-chip.in { background: var(--success-bg); color: var(--success); }
.pm-chip.out { background: var(--danger-bg); color: var(--danger); }
.pm-chip.soc { background: #EFF3FB; color: var(--accent); }


/* ==========================================================================
   VISIONNEUSE — le document en plein écran, zoom au toucher, téléchargement.
   ========================================================================== */
#detail-img { cursor: zoom-in; }
.doc-tools { margin-bottom: 8px; }
.doc-tools .btn-md { text-decoration: none; }

.doc-fullscreen {
  position: fixed; inset: 0; z-index: 88;
  background: #0B0F17;
  display: flex; flex-direction: column;
}
.doc-full-bar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--sat) + 10px) 14px 10px;
  color: #fff;
}
.doc-full-btn {
  width: 44px; height: 44px; border-radius: 14px; flex: none;
  display: grid; place-items: center; color: #fff;
  background: rgba(255, 255, 255, .12);
}
.doc-full-btn:active { transform: scale(.92); }
.doc-full-title {
  flex: 1; min-width: 0; text-align: center;
  font-size: 14px; font-weight: 700; color: #E2E8F0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.doc-full-scroll {
  flex: 1; overflow: auto; display: grid; place-items: center;
  touch-action: pinch-zoom pan-x pan-y;
  padding-bottom: calc(var(--sab) + 10px);
}
#df-img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  cursor: zoom-in;
}
#df-img.zoomed {
  max-width: none; max-height: none; width: auto;
  cursor: zoom-out;
}
.doc-full-hint {
  position: absolute; left: 50%; bottom: calc(var(--sab) + 18px);
  transform: translateX(-50%);
  background: rgba(255, 255, 255, .14); color: #E2E8F0;
  font-size: 12.5px; font-weight: 600;
  padding: 8px 14px; border-radius: 999px; white-space: nowrap;
  transition: opacity .4s ease;
}
.doc-full-hint.hidden { display: none; }


/* ============ appairage WhatsApp guidé =================================== */
.wa-guide {
  background: linear-gradient(160deg, #ECFDF5, #F0FDF9);
  border: 1.5px solid #059669; border-radius: var(--r-lg);
  padding: 16px 14px; margin: 4px 0 12px;
}
.wa-guide-title { font-size: 13.5px; font-weight: 800; color: #065F46;
  margin-bottom: 12px; }
.wa-way { background: #fff; border-radius: var(--r-md); padding: 13px 14px;
  border: 1px solid rgba(5, 150, 105, .25); }
.wa-way + .wa-way { margin-top: 10px; }
.wa-way-head { font-size: 14px; font-weight: 750; color: var(--ink);
  margin-bottom: 10px; display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; }
.wa-way-badge {
  font-size: 10.5px; font-weight: 800; letter-spacing: .05em;
  text-transform: uppercase; color: #fff; background: var(--success);
  border-radius: 999px; padding: 3px 9px;
}
.wa-way-badge.alt { background: var(--muted); }
.wa-qr {
  display: block; width: min(210px, 62vw); margin: 0 auto 10px;
  border-radius: 12px; border: 1px solid var(--line);
  image-rendering: pixelated;
}
.wa-steps { margin: 0; padding-left: 20px; }
.wa-steps li { font-size: 13px; color: var(--ink-2); line-height: 1.55;
  margin-bottom: 3px; }
.wa-code-row { display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px; flex-wrap: wrap; }
.wa-code-row .wa-code-value { margin: 0; flex: 1; text-align: left;
  font-size: clamp(24px, 7.5vw, 32px); }
.wa-code-row .btn-md { flex: none; min-height: 44px; }
#wa-newcode { margin-top: 8px; color: var(--accent); font-weight: 650;
  font-size: 13px; }


/* ============ prestations : cartes navigantes ============================ */
.prest-card {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid rgba(226, 232, 240, .8);
  border-radius: var(--r-md); padding: 14px 12px 14px 16px;
  margin-bottom: 10px; box-shadow: var(--shadow-1);
  transition: transform .15s var(--ease);
}
.prest-card:active { transform: scale(.98); }
.prest-body { flex: 1; min-width: 0; }
.prest-name { display: block; font-size: 15.5px; font-weight: 750;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prest-meta { display: block; font-size: 12px; color: var(--muted);
  margin-top: 1px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.prest-total { flex: none; font-size: 15px; font-weight: 800;
  font-variant-numeric: tabular-nums; white-space: nowrap; }
.prest-chev { flex: none; font-size: 17px; font-weight: 700;
  color: var(--muted); opacity: .55; }
.dep-sub { position: relative; }
.dep-sub .prest-chev { position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%); }
#td-list .dep-sub {
  width: 100%; text-align: left;
  background: var(--surface); border: 1px solid rgba(226, 232, 240, .8);
  border-radius: var(--r-md); box-shadow: var(--shadow-1);
  margin-bottom: 10px; padding: 14px 34px 14px 16px;
  display: flex; align-items: center; gap: 10px;
}
.group-card.nav .cat-group-title::after { transform: none; }
.group-card.nav {
  background: var(--surface); border: 1px solid rgba(226, 232, 240, .8);
  box-shadow: var(--shadow-1); margin: 10px 0;
  transition: transform .15s var(--ease);
}
.group-card.nav:active { transform: scale(.98); }

/* historiques de profils : la carte remplace la liste */
#cp-history-card .cat-group-title, #fp-history-card .cat-group-title {
  margin: 0; padding: 13px 14px;
}
#cp-history-card, #fp-history-card {
  background: var(--bg); border-radius: var(--r-md); cursor: pointer;
}

/* ==========================================================================
   v14 — fiches pleine page, menu espèces jaillissant, crédit redessiné.
   ========================================================================== */

/* les fiches (prestation, client) sont des sous-pages entières */
.screen-fiche {
  position: fixed; inset: 0; z-index: 75; background: var(--bg);
  display: flex; flex-direction: column; max-width: 480px; margin: 0 auto;
}
.screen-fiche:not(.hidden) { animation: slide-in-right .28s cubic-bezier(.32,.72,0,1); }
.screen-fiche .sheet-grip { display: none; }
.screen-fiche .sheet-head {
  display: flex; align-items: center; gap: 10px; flex: none;
  padding: calc(var(--sat) + 10px) 16px 10px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.screen-fiche .sheet-title { flex: 1; min-width: 0; }
.screen-fiche .sheet-title h3 { font-size: 17px; font-weight: 800;
  letter-spacing: -.01em; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.screen-fiche .sheet-title p { font-size: 12px; color: var(--muted); }
.screen-fiche .sheet-body {
  flex: 1; overflow-y: auto; padding: 14px 16px calc(var(--sab) + 96px);
}

/* le texte des modales ne doit JAMAIS hériter du blanc de l'overlay */
.form-card { color: var(--ink); }

/* sélecteur de projet : rangées dessinées */
.pp-item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid rgba(226, 232, 240, .9);
  border-radius: var(--r-md); padding: 13px 14px; margin-bottom: 8px;
  box-shadow: var(--shadow-1); transition: transform .15s var(--ease);
}
.pp-item:active { transform: scale(.97); }
.pp-item .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.pp-body { flex: 1; min-width: 0; }
.pp-body b { display: block; font-size: 15px; font-weight: 750; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-body small { font-size: 12px; color: var(--muted); }

/* crédit : deux cartes directionnelles */
.cred-card {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid rgba(226, 232, 240, .8);
  border-radius: var(--r-md); padding: 14px; margin: 10px 0 0;
  box-shadow: var(--shadow-1); transition: transform .15s var(--ease);
}
.cred-card:active { transform: scale(.98); }
.cred-ico { width: 38px; height: 38px; border-radius: 12px; flex: none;
  display: grid; place-items: center; }
.cred-card.in .cred-ico { background: var(--success-bg); color: var(--success); }
.cred-card.out .cred-ico { background: var(--danger-bg); color: var(--danger); }
.cred-body { flex: 1; min-width: 0; }
.cred-body b { display: block; font-size: 14.5px; font-weight: 750;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cred-body small { display: block; font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cred-amt { flex: none; font-size: 14.5px; font-weight: 800;
  font-variant-numeric: tabular-nums; white-space: nowrap; }
.cred-card.in .cred-amt { color: var(--success); }
.cred-card.out .cred-amt { color: var(--danger); }

/* ---- espèces : le cercle et la barre partagent la même matière ---------- */
.cash-fab {
  background: var(--ink);
  color: #34D399;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .28);
  position: relative; z-index: 47;
  transition: transform .2s var(--ease);
}
.cash-fab.open { transform: rotate(45deg) scale(.96); }
.cash-fab.open svg { transform: rotate(0deg); }

/* les deux options jaillissent du cercle */
.cash-menu {
  position: absolute; right: 20px; bottom: calc(100% + 10px);
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
  pointer-events: none; z-index: 47;
}
.cash-pill {
  pointer-events: auto;
  display: flex; align-items: center; gap: 11px; text-align: left;
  background: var(--surface); border: 1px solid rgba(226, 232, 240, .9);
  border-radius: 18px; padding: 11px 16px 11px 12px;
  box-shadow: var(--shadow-2);
  opacity: 0; transform: translateY(16px) scale(.6);
  transform-origin: bottom right;
  transition: opacity .22s var(--ease), transform .26s var(--ease);
}
.cash-menu.open .cash-pill { opacity: 1; transform: none; }
.cash-menu.open .cash-pill:nth-child(1) { transition-delay: .05s; }
.cash-menu.open .cash-pill:nth-child(2) { transition-delay: 0s; }
.cash-menu:not(.open) { visibility: hidden; }
.cash-menu.open { visibility: visible; }
.cash-pill:active { transform: scale(.96); }
.cash-pill-ico { width: 36px; height: 36px; border-radius: 12px; flex: none;
  display: grid; place-items: center; }
.cash-pill-ico.in { background: var(--success-bg); color: var(--success); }
.cash-pill-ico.out { background: var(--danger-bg); color: var(--danger); }
.cash-pill-txt b { display: block; font-size: 14.5px; font-weight: 800; }
.cash-pill-txt small { display: block; font-size: 11.5px; color: var(--muted); }



/* ---- v24 : scan + espèces — azur vivant, anneau glacier ------------------
   La vie vient de la lumière du bleu, pas de sa noirceur : un azur lumineux
   qui plonge vers le bleu de l'app, poli d'un reflet haut, cerclé de
   l'anneau glacier animé. Plat, sans ombre. */
.fab, .cash-fab {
  border: 2px solid transparent;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .18), rgba(255, 255, 255, 0) 45%) padding-box,
    linear-gradient(160deg, #55A6F6, #2B72DB 55%, #1F5BC4) padding-box,
    linear-gradient(120deg, #B8E0FA, #8FC6F5 25%, #EAF6FF 50%, #8FC6F5 75%, #B8E0FA) border-box;
  background-size: 100% 100%, 100% 100%, 340% 100%;
  color: #FFFFFF;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .45);
  animation: fab-azur 8s linear infinite;
}
@keyframes fab-azur {
  0% { background-position: 0 0, 0 0, 0% 50%; }
  100% { background-position: 0 0, 0 0, 340% 50%; }
}
.fab svg { color: #EAF6FF; }
.fab:active { transform: scale(.97); }
.cash-fab { color: #EAF6FF; }
.cash-fab.open { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .45); }

/* ---- v18 : cartes clients de la page Clients ----------------------------- */
.clp-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid rgba(226, 232, 240, .9);
  border-radius: var(--r-md); padding: 13px 14px; margin-bottom: 10px;
  transition: transform .15s var(--ease);
}
.clp-item:active { transform: scale(.98); }
.clp-avatar {
  width: 46px; height: 46px; border-radius: 15px; flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: 16px;
}
.clp-body { flex: 1; min-width: 0; }
.clp-name { display: block; font-weight: 750; font-size: 15.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clp-meta { display: block; font-size: 12px; color: var(--muted); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clp-meta.warn { color: var(--warn); font-weight: 650; }
.clp-bar { display: block; height: 4px; border-radius: 2px; background: var(--bg);
  overflow: hidden; margin-top: 7px; }
.clp-bar i { display: block; height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, var(--success), #34D399); }
.clp-amount { flex: none; text-align: right; }
.clp-amount b { display: block; font-size: 14.5px; font-weight: 800;
  color: var(--success); font-variant-numeric: tabular-nums; white-space: nowrap; }
.clp-amount small { font-size: 10.5px; color: var(--muted); font-weight: 700;
  font-variant-numeric: tabular-nums; }
.clp-item .prest-chev { flex: none; }

/* ---- v20 : échelle des couches ------------------------------------------
   pages (70-75) < TABBAR 76 (toujours visible sur toute page) < scan 77-78 <
   feuilles 78-79 < modales 80+. Les fiches (73) sous les sous-pages (74-75) ;
   la sous-page d'une prestation se masque quand sa fiche s'ouvre (JS). */
.screen-fiche { z-index: 73 !important; }
#compta-detail, #cprofile, #fprofile { z-index: 74; }
#type-detail, #facture-picker { z-index: 75 !important; }

/* ---- v19 : filtres Documents — segment + puces d'usage comptées ---------- */
.doc-filterbar { margin: 2px 0 4px; }
.seg {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px;
  background: #E9EDF3; border-radius: 14px; padding: 4px; margin-bottom: 10px;
}
.seg-btn {
  min-height: 40px; border-radius: 11px; font-size: 13.5px; font-weight: 700;
  color: var(--muted);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.seg-btn.on {
  background: var(--surface); color: var(--ink);
  border: 1px solid rgba(226, 232, 240, .9);
}
.seg-btn:active { transform: scale(.97); }
.use-chips { padding-bottom: 2px; }
.chip .chip-n {
  margin-left: 7px; font-size: 11px; font-weight: 800; opacity: .55;
  font-variant-numeric: tabular-nums;
}
.chip.on .chip-n { opacity: .85; }
.docs-count-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.docs-count-row .docs-count { margin: 6px 0 10px; }
.docs-count-row .link-btn { flex: none; font-size: 13px; }

/* ---- v20 : Bénéfice = chiffre informatif, pas un bouton ------------------ */
#kpi-ben { pointer-events: none; }

/* ---- v20 : lignes de chèques sur la page Crédit -------------------------- */
.cred-row { cursor: pointer; transition: transform .15s var(--ease); }
.cred-row:active { transform: scale(.98); }
.cred-row .prest-chev { flex: none; margin-left: 2px; }

/* ---- v25 : croix de fermeture du détail ---------------------------------- */
.detail-card { position: relative; }
.detail-x {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(15, 23, 42, .55); color: #fff;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.detail-x:active { transform: scale(.92); }

/* ---- v25 : menu déroulant du projet actif -------------------------------- */
.app-header > div:first-child { position: relative; }
.project-chip svg { transition: transform .18s var(--ease); }
.project-chip.open svg { transform: rotate(180deg); }
.proj-menu {
  position: absolute; top: 34px; left: 0; z-index: 60;
  min-width: 230px; max-width: 300px; max-height: 320px; overflow-y: auto;
  background: var(--surface); border: 1px solid rgba(226, 232, 240, .9);
  border-radius: 16px; padding: 6px; box-shadow: var(--shadow-2);
  opacity: 0; transform: translateY(-6px) scale(.97);
  transform-origin: top left;
  transition: opacity .16s var(--ease), transform .18s var(--ease);
}
.proj-menu.show { opacity: 1; transform: none; }
.proj-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 44px; padding: 0 12px; border-radius: 11px;
  font-size: 14.5px; font-weight: 650; color: var(--ink); text-align: left;
}
.proj-item .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.proj-item .nm { flex: 1; min-width: 0; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.proj-item svg { color: var(--accent); flex: none; }
.proj-item.on { background: #EFF3FB; }
.proj-item:active { background: var(--bg); }
.proj-item.manage { border-top: 1px solid var(--line); border-radius: 0 0 11px 11px;
  margin-top: 4px; color: var(--muted); font-weight: 600; }

/* ---- v29 : avertissement qualité photo sur l'écran de vérification ------ */
.review-quality {
  margin: 10px 16px 0; padding: 11px 13px; border-radius: var(--r-sm);
  background: var(--warn-bg); border: 1px solid var(--warn-line);
  color: var(--warn); font-size: 13px; font-weight: 650; line-height: 1.45;
}
