/* =============================================================================
   RECOUVRA — design system (mobile-first). Un seul fichier pour tout le site.
   ============================================================================= */
/* Police hébergée sur le site (plus de dépendance à Google Fonts : affichage plus rapide) */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('vendor/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #F6F7F5;
  --surface: #FFFFFF;
  --surface-2: #F0F2EF;
  --text: #14201B;
  --text-2: #55635D;
  --text-3: #8A968F;
  --border: #E2E6E2;
  --brand: #1F6F5C;
  --brand-600: #185A4A;
  --brand-50: #E7F3EF;
  --ok: #1B7F4B;      --ok-bg: #E4F4EB;
  --warn: #B26A00;    --warn-bg: #FFF1DB;
  --danger: #C23030;  --danger-bg: #FDE9E9;
  --info: #2457B8;    --info-bg: #E6EEFC;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20,32,27,.05), 0 4px 14px rgba(20,32,27,.06);
  --shadow-lg: 0 12px 40px rgba(20,32,27,.22);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --nav-h: 64px;
  --sidebar-w: 232px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1512; --surface: #151F1B; --surface-2: #1B2723;
    --text: #EAF1EE; --text-2: #A5B3AD; --text-3: #73827B; --border: #263430;
    --brand: #3FB596; --brand-600: #5BCBAD; --brand-50: #183229;
    --ok: #52CB8A; --ok-bg: #153024; --warn: #F2B34F; --warn-bg: #352A12;
    --danger: #FF7C7C; --danger-bg: #3A1B1B; --info: #86A9F5; --info-bg: #182640;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.45;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 800; }
h2 { font-size: 1.125rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: .85rem; }
.xs { font-size: .75rem; }
.bold { font-weight: 700; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 20px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Boutons (zone tactile >= 44px) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 600; cursor: pointer; transition: background .15s, transform .05s, box-shadow .15s;
  text-decoration: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn:focus-visible, .field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 35%, transparent); outline-offset: 1px;
}
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); }
.btn-danger { background: var(--danger-bg); border-color: transparent; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-whatsapp { background: #1FAA59; border-color: #1FAA59; color: #fff; }
.btn-whatsapp:hover { background: #178f4a; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-lg { min-height: 54px; font-size: 1.05rem; padding: 0 24px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-sm { min-height: 44px; padding: 0 14px; font-size: .9rem; }
.btn[disabled], .btn.loading { opacity: .6; pointer-events: none; }
.btn.loading::after, .spinner {
  content: ''; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
.spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Formulaires ---------- */
.field { display: block; }
.field + .field, .field-row + .field, .field + .field-row { margin-top: 14px; }
.field > label, .field > .lbl { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; color: var(--text-2); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); font-size: 16px; /* évite le zoom iOS */
}
.field textarea { min-height: 96px; resize: vertical; }
.field .hint { font-size: .8rem; color: var(--text-3); margin-top: 4px; }
.field-row { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.field-row .field + .field { margin-top: 0; }
.search {
  width: 100%; min-height: 48px; padding: 10px 14px 10px 42px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface) no-repeat 14px center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%238A968F' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='m17 17-4.5-4.5'/%3E%3C/svg%3E");
}

/* ---------- Cartes, listes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.list > .item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); min-height: 64px; }
.list > .item:last-child { border-bottom: 0; }
.list > .item.click { cursor: pointer; }
.list > .item.click:hover { background: var(--surface-2); }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--brand-50); color: var(--brand); font-weight: 800;
}
.item-title { font-weight: 600; }
.item-sub { font-size: .85rem; color: var(--text-2); }
.amount { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: var(--surface-2); color: var(--text-2); }

/* ---------- Statistiques ---------- */
.stats { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .k { font-size: .8rem; color: var(--text-2); font-weight: 600; }
.stat .v { font-size: 1.2rem; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat.danger .v { color: var(--danger); }
.stat.ok .v { color: var(--ok); }

/* Gros boutons d'accueil : les 3 gestes */
.big-actions { display: grid; gap: 12px; }
.big-action {
  display: flex; align-items: center; gap: 16px; padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--text);
  min-height: 84px; transition: transform .08s, border-color .15s;
}
.big-action:hover { border-color: var(--brand); }
.big-action:active { transform: scale(.99); }
.big-action .ico { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 1.6rem; background: var(--brand-50); flex: none; }
.big-action .num { font-size: .8rem; font-weight: 800; color: var(--brand); text-transform: uppercase; letter-spacing: .04em; }
.big-action .t { font-size: 1.15rem; font-weight: 800; }
.big-action.danger .ico { background: var(--danger-bg); }

/* graphique simple */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 110px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 4px; }
.bars .bar i { width: 100%; max-width: 38px; background: var(--brand); border-radius: 6px 6px 2px 2px; min-height: 3px; opacity: .85; }
.bars .bar span { font-size: .7rem; color: var(--text-3); }

/* ---------- Coque d'application ---------- */
.shell { min-height: 100vh; }
.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 16px; background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.topbar .topbar-ent { max-width: 34vw; }
@media (max-width: 479px) { .topbar .topbar-ent { display: none; } }
.topbar .icon-btn { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font-size: 1.25rem; cursor: pointer; text-decoration: none; }
.topbar .icon-btn:active { transform: scale(.96); }
.topbar .title { font-weight: 800; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar .brand span:last-child { display: none; }
@media (min-width: 420px) { .topbar .brand span:last-child { display: inline; } }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--text); }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; overflow: hidden; flex: none; }
.brand .logo img { width: 100%; height: 100%; object-fit: cover; }
.content { padding: 16px 16px calc(var(--nav-h) + 44px); max-width: 960px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.tabbar {
  position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 40; height: 64px;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent); -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border: 1px solid var(--border); border-radius: 22px; box-shadow: 0 8px 28px rgba(20,32,27,.16); padding: 0 4px;
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: .68rem; font-weight: 700; color: var(--text-3); position: relative; height: 100%; -webkit-tap-highlight-color: transparent; }
.tabbar a .i { display: grid; place-items: center; width: 46px; height: 28px; border-radius: 14px; transition: background .18s, color .18s, transform .1s; }
.tabbar a .i svg { width: 23px; height: 23px; }
.tabbar a:active .i { transform: scale(.92); }
.tabbar a.active { color: var(--brand); }
.tabbar a.active .i { background: var(--brand-50); }
.tabbar a.main { color: var(--text-2); }
.tabbar a.main .i { width: 56px; height: 56px; border-radius: 50%; background: var(--brand); color: #fff; margin-top: -26px; box-shadow: 0 6px 16px rgba(31,111,92,.45); border: 4px solid var(--bg); }
.tabbar a.main .i svg { width: 26px; height: 26px; }
.tabbar a.main.active { color: var(--brand); }
.tabbar a.main.active .i { background: var(--brand-600); }
.tabbar a.main span:not(.i):not(.dot) { margin-top: -2px; }
.tabbar a .dot { position: absolute; top: 8px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: .68rem; display: grid; place-items: center; }

.banner { padding: 10px 16px; font-size: .9rem; font-weight: 600; display: flex; gap: 10px; align-items: center; justify-content: center; text-align: center; flex-wrap: wrap; }
.banner-warn { background: var(--warn-bg); color: var(--warn); }
.banner-danger { background: var(--danger-bg); color: var(--danger); }
.banner-info { background: var(--info-bg); color: var(--info); }
.banner a { text-decoration: underline; color: inherit; }

@media (min-width: 900px) {
  .shell { padding-left: var(--sidebar-w); }
  .sidebar {
    display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
    background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px; gap: 4px; z-index: 35;
  }
  .sidebar .brand { padding: 4px 10px 18px; font-size: 1.15rem; }
  .sidebar a.nav {
    display: flex; align-items: center; gap: 12px; padding: 0 12px; min-height: 48px; border-radius: 10px;
    color: var(--text-2); font-weight: 600;
  }
  .sidebar a.nav:hover { background: var(--surface-2); }
  .sidebar a.nav.active { background: var(--brand-50); color: var(--brand); }
  .sidebar a.nav .i { width: 26px; display: grid; place-items: center; } .sidebar a.nav .i svg { width: 22px; height: 22px; }
  .sidebar .count { margin-left: auto; background: var(--danger); color: #fff; font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 9px; }
  .sidebar .foot { margin-top: auto; padding: 10px; border-top: 1px solid var(--border); }
  .tabbar { display: none; }
  .topbar .brand { display: none; }
  .topbar .icon-btn { display: none; }
  .content { padding: 24px 28px 48px; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .big-actions { grid-template-columns: repeat(3, 1fr); }
  .big-action { flex-direction: column; align-items: flex-start; }
}

/* ---------- Modale (feuille du bas sur mobile) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(8,14,11,.55); display: flex;
  align-items: flex-end; justify-content: center; animation: fade .15s ease;
}
.modal {
  background: var(--surface); width: 100%; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); animation: up .2s ease; box-shadow: var(--shadow-lg);
}
.modal h2 { margin-bottom: 14px; }
.modal .actions { display: flex; gap: 10px; margin-top: 18px; }
.modal .actions .btn { flex: 1; }
@media (min-width: 600px) {
  .overlay { align-items: center; padding: 20px; }
  .modal { max-width: 480px; border-radius: 18px; }
  .modal.wide { max-width: 640px; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 200; left: 12px; right: 12px; bottom: calc(var(--nav-h) + 12px); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; max-width: 440px; width: 100%; padding: 12px 16px; border-radius: 12px;
  background: #14201B; color: #fff; font-weight: 600; box-shadow: var(--shadow-lg); animation: up .2s ease;
  display: flex; gap: 10px; align-items: flex-start;
}
.toast.ok { background: #1B7F4B; } .toast.err { background: #C23030; }
@media (min-width: 900px) { .toasts { bottom: 24px; left: auto; right: 24px; align-items: flex-end; } }

/* ---------- Divers ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--text-2); }
.empty .big { font-size: 2.6rem; margin-bottom: 8px; }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; height: 18px; }
.skeleton.row-sk { height: 64px; border-radius: 0; margin-bottom: 1px; }
@keyframes sk { to { background-position: -200% 0; } }
.seg { display: flex; background: var(--surface-2); padding: 4px; border-radius: 12px; gap: 4px; overflow-x: auto; }
.seg button { flex: 1; min-height: 40px; padding: 0 14px; border: 0; background: transparent; border-radius: 9px; font-weight: 700; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.sep { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: .9rem; font-weight: 500; }
.alert-err { background: var(--danger-bg); color: var(--danger); }
.alert-info { background: var(--info-bg); color: var(--info); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.total-line { display: flex; justify-content: space-between; padding: 6px 0; }
.total-line.big { font-size: 1.25rem; font-weight: 800; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.chip { flex: none; min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; cursor: pointer; }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- VENDRE : grille de produits + panier ---------- */
.prod-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.prod {
  text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; min-height: 92px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; position: relative;
}
.prod:hover { border-color: var(--brand); }
.prod:active { transform: scale(.98); }
.prod .n { font-weight: 700; line-height: 1.2; }
.prod .p { color: var(--brand); font-weight: 800; margin-top: auto; }
.prod .s { font-size: .75rem; color: var(--text-3); }
.prod.out { opacity: .5; pointer-events: none; }
.prod .qty-badge { position: absolute; top: 4px; right: 4px; min-width: 48px; height: 40px; border-radius: 12px; background: var(--brand); color: #fff; font-weight: 800; font-size: .8rem; display: grid; place-items: center; padding: 0 6px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.stepper button { width: 44px; height: 44px; border: 0; background: var(--surface-2); font-size: 1.25rem; font-weight: 700; cursor: pointer; }
.stepper input { width: 56px; height: 44px; border: 0; text-align: center; font-weight: 700; background: var(--surface); font-size: 16px; }
.cartbar {
  position: fixed; left: 10px; right: 10px; bottom: calc(var(--nav-h) + 34px + env(safe-area-inset-bottom)); z-index: 38; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 8px 24px rgba(0,0,0,.14);
}
@media (min-width: 900px) {
  .prod-grid { grid-template-columns: repeat(3, 1fr); }
  .cartbar { left: var(--sidebar-w); right: 0; bottom: 0; border-radius: 0; border-width: 1px 0 0; box-shadow: 0 -6px 20px rgba(0,0,0,.08); }
}
@media (min-width: 1100px) { .prod-grid { grid-template-columns: repeat(4, 1fr); } }

/* ---------- Page de connexion ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background:
  radial-gradient(900px 400px at 10% -10%, var(--brand-50), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .brand { justify-content: center; font-size: 1.5rem; margin-bottom: 8px; }

/* ---------- Impression de la facture ---------- */
.invoice { background: #fff; color: #111; padding: 28px; border-radius: var(--radius); border: 1px solid var(--border); }
.invoice table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.invoice th, .invoice td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #e5e5e5; font-size: .92rem; }
.invoice th:nth-child(n+2), .invoice td:nth-child(n+2) { text-align: right; }
@media print {
  .sidebar, .tabbar, .topbar, .banner, .no-print, .toasts, .cartbar { display: none !important; }
  .shell { padding: 0 !important; }
  .content { padding: 0 !important; max-width: none; }
  body { background: #fff; }
  .invoice { border: 0; padding: 0; }
}

/* Import / progress */
.alert-ok { background: var(--ok-bg, #E6F4EA); color: var(--ok, #1E7B3A); }
.progress { height: 10px; border-radius: 999px; background: var(--border, #e5e7eb); overflow: hidden; }
.progress > #bar, .progress > .bar { display: block; height: 100%; width: 0; background: var(--primary, #1F6F5C); transition: width .2s; }

/* Pastille paiements à valider */
.topbar .icon-btn, .sidebar .nav { position: relative; }
.pay-badge { background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: inline-grid; place-items: center; }
.topbar .icon-btn .pay-badge { position: absolute; top: 2px; right: 0; }
.sidebar .nav .pay-badge { margin-left: auto; }

/* Bulle d'aide WhatsApp */
.help-fab { position: fixed; right: 14px; bottom: calc(var(--nav-h) + 30px + env(safe-area-inset-bottom)); z-index: 39; width: 52px; height: 52px; border-radius: 50%; background: #25D366; color: #fff; display: grid; place-items: center; box-shadow: 0 6px 18px rgba(0,0,0,.28); -webkit-tap-highlight-color: transparent; }
.help-fab:active { transform: scale(.94); }
@media (min-width: 900px) { .help-fab { right: 24px; bottom: 24px; } }
@media print { .help-fab { display: none !important; } }

/* Partage de l'application */
.share-qr { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.share-qr img { border: 1px solid var(--border, #E5E7EB); border-radius: 14px; }
