/* =====================================================================
   Calebasse Boutique — apparence « Wax moderne »

   Idée directrice : l'énergie d'un étal de marché, rangée avec soin.
   - Vert boutique = l'argent gagné et la marque.
   - Safran = l'action principale (vendre).
   - Corail = l'argent qui sort. Indigo = le crédit.
   - Une bande « wax » (triangles colorés) signe les grandes cartes.
   - Titres et grands chiffres en Bricolage Grotesque, le reste en Manrope.
   Les animations répondent toujours à un geste ; un seul « grand moment » :
   la vente encaissée (les pièces tombent dans la calebasse).
   ===================================================================== */

@font-face {
  font-family: 'Manrope';
  src: url('fonts/manrope.woff2') format('woff2');
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('fonts/bricolage.woff2') format('woff2');
  font-weight: 500 800;
  font-display: swap;
}

/* ---------- Couleurs : thème clair ---------- */
:root {
  --bg: #f3f6f2;
  --card: #ffffff;
  --text: #13241e;
  --muted: #5b6b64;
  --line: #e1e8e3;

  --green: #0e5e4a;
  --green-deep: #083f32;
  --green-soft: #e2f1eb;
  --saffron: #f4b41a;
  --saffron-deep: #9a6a00;
  --saffron-soft: #fff3d1;
  --coral: #e9542f;
  --coral-soft: #fde6de;
  --indigo: #3446b8;
  --indigo-deep: #232f80;
  --indigo-soft: #e6e9fb;
  --cream: #fff6e0;

  --in: #0f7a57;          /* texte « entrée d'argent » */
  --out: #c9431f;         /* texte « sortie d'argent » */
  --over: #c42d1c;        /* alerte */
  --brand: var(--green);
  --action: var(--saffron);
  --on-action: #1c1503;
  --scrim: rgba(8, 25, 20, .5);
  --shadow: 0 1px 2px rgba(19, 36, 30, .06), 0 6px 18px rgba(19, 36, 30, .06);
  --shadow-lift: 0 10px 30px rgba(8, 63, 50, .22);

  --display: 'Bricolage Grotesque', 'Manrope', system-ui, sans-serif;
  --sans: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.45, .55, 1);

  /* bande wax : triangles corail, vert et crème sur fond safran */
  --wax: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='14' viewBox='0 0 48 14'%3E%3Crect width='48' height='14' fill='%23F4B41A'/%3E%3Cpath d='M0 14L8 1L16 14Z' fill='%23E9542F'/%3E%3Cpath d='M16 14L24 1L32 14Z' fill='%23083F32'/%3E%3Cpath d='M32 14L40 1L48 14Z' fill='%23FFF6E0'/%3E%3Ccircle cx='16' cy='3' r='1.5' fill='%23083F32'/%3E%3Ccircle cx='32' cy='3' r='1.5' fill='%23E9542F'/%3E%3Ccircle cx='0' cy='3' r='1.5' fill='%23FFF6E0'/%3E%3Ccircle cx='48' cy='3' r='1.5' fill='%23FFF6E0'/%3E%3C/svg%3E");
  /* motif en losanges, très discret, pour le fond des grandes cartes */
  --lattice: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='36' viewBox='0 0 36 36'%3E%3Cg fill='none' stroke='white' stroke-opacity='.07' stroke-width='1.2'%3E%3Cpath d='M18 2L34 18L18 34L2 18Z'/%3E%3Cpath d='M18 11L25 18L18 25L11 18Z'/%3E%3C/g%3E%3C/svg%3E");
  color-scheme: light;
}

/* ---------- Thème sombre (automatique ou choisi) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #09130f; --card: #11201b; --text: #e9f2ee; --muted: #93a69e; --line: #1f332c;
    --green: #3cc69a; --green-soft: #133227; --saffron-deep: #f4b41a; --saffron-soft: #2e2510;
    --coral: #ff7d58; --coral-soft: #351b13; --indigo: #8f9dff; --indigo-soft: #1b2045;
    --in: #4fd3a5; --out: #ff8a66; --over: #ff6b5b; --brand: #3cc69a;
    --scrim: rgba(0, 0, 0, .62); --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #09130f; --card: #11201b; --text: #e9f2ee; --muted: #93a69e; --line: #1f332c;
  --green: #3cc69a; --green-soft: #133227; --saffron-deep: #f4b41a; --saffron-soft: #2e2510;
  --coral: #ff7d58; --coral-soft: #351b13; --indigo: #8f9dff; --indigo-soft: #1b2045;
  --in: #4fd3a5; --out: #ff8a66; --over: #ff6b5b; --brand: #3cc69a;
  --scrim: rgba(0, 0, 0, .62); --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2.5px solid var(--saffron); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Chiffres : alignés, pour qu'ils ne « dansent » pas quand ils défilent */
.amt, .balance, .facts strong, .stock b, .debt b, .hbar-val, .ledger-row b, .sale-total b,
.qty-n, .pick small, .day span:last-child, .mini-note b, .split strong {
  font-variant-numeric: lining-nums tabular-nums;
}

main { max-width: 560px; margin: 0 auto; padding: 0 16px; }

.card {
  background: var(--card);
  border-radius: 20px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 8px; font-family: var(--display); font-size: 1.08rem; font-weight: 700; letter-spacing: -.01em; }
.card p.hint, p.hint { color: var(--muted); font-size: .86rem; margin: 0 0 10px; }
.muted { color: var(--muted); }
.in { color: var(--in); }
.out { color: var(--out); }
.over-text { color: var(--over); font-weight: 700; }
.hint.pad { font-size: .82rem; padding: 4px 4px 0; margin: 12px 0 0; }

/* Retour au toucher : tout ce qui se touche s'enfonce un peu */
.btn, .tx, .pick, .chip, .prod-main, .cust-head, .icon-btn, .qa, .bottom button, .keypad button {
  transition: transform .16s var(--ease), background-color .2s, box-shadow .2s;
}
.btn:active, .tx:active, .pick:active, .prod-main:active, .cust-head:active, .icon-btn:active,
.qa:active, .keypad button:active { transform: scale(.96); }

/* ---------- En-tête ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  max-width: 560px; margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.top-title { min-width: 0; }
.top-title small { display: block; color: var(--muted); font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top h1 {
  margin: 0; font-family: var(--display); font-weight: 800; font-size: 1.55rem;
  letter-spacing: -.02em; line-height: 1.1; text-transform: capitalize;
}
.month-nav { display: flex; gap: 6px; flex: none; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 14px; border: 0;
  background: var(--card); box-shadow: var(--shadow);
  font-size: 1.3rem; line-height: 1; display: grid; place-items: center; color: var(--text);
}
.icon-btn.sm { width: 34px; height: 34px; font-size: 1.05rem; border-radius: 11px; flex: none; }

/* ---------- La grande carte (bénéfice, crédits, bilan) ---------- */
.summary, .total-card {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--green-deep) var(--lattice);
  color: #f4fbf8;
  border-radius: 26px;
  padding: 26px 20px 18px;
  box-shadow: var(--shadow-lift);
}
.summary::before, .total-card::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 12px;
  background: var(--wax) 0 0 / 48px 12px repeat-x;
}
/* À l'ouverture, la bande wax se déroule (le seul mouvement qui n'est pas un geste) */
.summary.intro::before { animation: wax-in 1s var(--ease) both; }
@keyframes wax-in { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

.summary .label, .total-card .label { color: rgba(244, 251, 248, .72); font-size: .88rem; font-weight: 600; }
.summary .balance, .total-card .balance {
  font-family: var(--display); font-size: 2.75rem; font-weight: 800; line-height: 1.05;
  letter-spacing: -.03em; margin: 4px 0 14px;
}
.summary .balance.out, .total-card .balance.out { color: #ffb39c; }
.total-card small { color: rgba(244, 251, 248, .8); font-size: .88rem; }
.total-card .in-ink { color: #8ff0c8; font-weight: 700; }
.total-card .out-ink { color: #ffb39c; font-weight: 700; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.split > div { background: rgba(255, 255, 255, .08); border-radius: 14px; padding: 10px 12px; }
.split .label { display: block; font-size: .76rem; }
.split strong { display: block; font-family: var(--display); font-size: 1.15rem; font-weight: 700; margin-top: 2px; }
.split .in { color: #8ff0c8; }
.split .out { color: #ffb39c; }
.note-line {
  display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  margin-top: 12px; font-size: .85rem; color: rgba(244, 251, 248, .78);
}
.note-line b { color: var(--saffron); font-weight: 800; }
/* le crédit a sa propre couleur */
#tab-credit .total-card { background-color: var(--indigo-deep); box-shadow: 0 10px 30px rgba(35, 47, 128, .25); }

/* ---------- Actions rapides (sous la grande carte) ---------- */
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0 12px; }
.qa {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: 0; background: var(--card); border-radius: 18px; padding: 12px 6px 10px;
  box-shadow: var(--shadow); font-size: .8rem; font-weight: 700; color: var(--text); text-align: center;
}
.qa i {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center;
  font-style: normal; font-size: 1.3rem;
}
.qa.buy i { background: var(--saffron-soft); }
.qa.spend i { background: var(--coral-soft); }
.qa.credit i { background: var(--indigo-soft); }

/* ---------- Cahier de caisse ---------- */
.day {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 18px 6px 8px; font-size: .8rem; color: var(--muted); font-weight: 600;
}
.day span:first-child { display: inline-block; font-weight: 800; color: var(--text); font-size: .9rem; }
.day span:first-child::first-letter { text-transform: uppercase; } /* « Mercredi 21 octobre », « Clients à jour » */
.list { background: var(--card); border-radius: 20px; overflow: hidden; box-shadow: var(--shadow); }
.tx {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; border: 0; background: none; text-align: left;
}
.tx + .tx { border-top: 1px solid var(--line); }
.bubble {
  flex: none; width: 42px; height: 42px; border-radius: 14px;
  display: grid; place-items: center; font-size: 1.25rem; background: var(--bg);
}
.bubble.sm { width: 38px; height: 38px; font-size: 1.1rem; border-radius: 12px; }
.tx .info { flex: 1; min-width: 0; }
.tx .info b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .info small { display: block; color: var(--muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amt { font-weight: 800; font-size: 1rem; white-space: nowrap; }
.amt.in { color: var(--in); }
.amt.neutral { color: var(--muted); }
.amt.credit { color: var(--indigo); }

.empty { text-align: center; color: var(--muted); padding: 34px 24px; }
.empty div { font-size: 2.4rem; margin-bottom: 8px; }

/* Nouvelle opération mise en évidence */
@keyframes fresh {
  0% { opacity: 0; transform: translateY(-10px) scale(.98); background: var(--saffron-soft); }
  25% { opacity: 1; transform: none; background: var(--saffron-soft); }
  100% { background: transparent; }
}
.tx.fresh { animation: fresh 1.6s var(--ease); }

/* ---------- Bandeaux (rappels, alertes) ---------- */
.reminder { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: start; }
.reminder::before {
  content: ''; grid-row: span 2; width: 6px; align-self: stretch; border-radius: 3px; background: var(--saffron);
}
.reminder.over-banner::before { background: var(--coral); }
.reminder-text b { display: block; font-weight: 800; }
.reminder-text small { color: var(--muted); font-size: .84rem; }
.reminder-actions { display: flex; gap: 8px; margin-top: 8px; grid-column: 2; }
.reminder-actions .btn { flex: 1; padding: 10px; }

/* ---------- Boutons ---------- */
.btn { border: 0; border-radius: 14px; padding: 12px 16px; font-weight: 800; font-size: .95rem; }
.btn.primary { background: var(--green-deep); color: #fff; }
:root[data-theme="dark"] .btn.primary { background: var(--green); color: #04140e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { background: var(--green); color: #04140e; } }
.btn.ghost { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
/* dans une carte ou une fenêtre (fond blanc), le bouton discret prend la couleur du fond */
.card .btn.ghost, .dialog .btn.ghost, .sheet .btn.ghost, .install-card .btn.ghost { background: var(--bg); box-shadow: none; }
.btn.danger { background: var(--coral-soft); color: var(--over); }
.btn.small { padding: 7px 12px; font-size: .82rem; border-radius: 11px; }
.btn:disabled { opacity: .55; }
.btn-col { display: grid; gap: 8px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.link-btn { border: 0; background: none; color: var(--brand); font-weight: 800; padding: 8px; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }

/* ---------- Barre de navigation ---------- */
.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
}
.bottom button {
  position: relative; z-index: 1;
  border: 0; background: none; padding: 0; font-size: .7rem; font-weight: 700; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.bottom svg {
  width: 26px; height: 32px; padding: 4px 0;
  fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.bottom button.active { color: var(--green); }
.bottom button.active svg { animation: nav-hop .35s var(--spring); }
@keyframes nav-hop { 40% { transform: translateY(-3px) scale(1.08); } }
/* la pastille glisse d'un onglet à l'autre */
.nav-pill {
  position: absolute; z-index: 0; top: 8px; left: 4px; width: calc((100% - 8px) / 6); height: 32px;
  display: flex; justify-content: center; pointer-events: none;
  transform: translateX(calc(var(--i, 0) * 100%));
  transition: transform .42s var(--spring);
}
.nav-pill::before { content: ''; width: 52px; height: 32px; border-radius: 16px; background: var(--green-soft); }

/* Le bouton « Vendre » : rond, safran, au milieu de la barre ; il ne cache jamais la liste */
.bottom .fab {
  position: relative; z-index: 2; color: var(--text); gap: 3px;
}
.fab-plus {
  display: grid; place-items: center; width: 56px; height: 56px; margin-top: -30px; border-radius: 50%;
  background: var(--action); color: var(--on-action); border: 4px solid var(--card);
  font-family: var(--display); font-size: 2rem; font-weight: 700; line-height: 1;
  box-shadow: 0 8px 20px rgba(201, 138, 0, .4);
  transition: transform .2s var(--spring);
}
.bottom .fab:active .fab-plus { transform: scale(.9) rotate(90deg); }
.bottom .fab { font-weight: 800; }

/* ---------- Changement d'onglet ---------- */
.tab.from-right { animation: tab-right .28s var(--ease) both; }
.tab.from-left { animation: tab-left .28s var(--ease) both; }
@keyframes tab-right { from { opacity: 0; transform: translateX(22px); } }
@keyframes tab-left { from { opacity: 0; transform: translateX(-22px); } }

/* ---------- Champs ---------- */
.field { display: block; font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: 10px; }
.field-hint { display: block; margin-top: 4px; color: var(--saffron-deep); font-weight: 600; }
.field-hint.muted { color: var(--muted); font-weight: 500; }
.field input, .field select, .sale-search, .search input {
  display: block; width: 100%; margin-top: 5px; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--text); font-weight: 600;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field select:focus, .sale-search:focus, .search input:focus {
  outline: none; border-color: var(--green); box-shadow: 0 0 0 4px var(--green-soft);
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.search { margin: 0 0 12px; }
.search input { margin: 0; }

/* ---------- Choix segmenté (paiement) ---------- */
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px;
  background: var(--bg); border-radius: 16px; padding: 4px;
}
.seg button {
  border: 0; background: none; border-radius: 12px; padding: 8px 4px; font-weight: 800; color: var(--muted);
  transition: background-color .25s, color .25s, transform .16s;
}
.seg button.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
#salePay button { font-size: .8rem; line-height: 1.2; display: flex; flex-direction: column; align-items: center; white-space: nowrap; }
#salePay button span { font-size: 1.2rem; transition: transform .3s var(--spring); }
#salePay button.active span { transform: scale(1.18); }
#salePay button[data-pay="cash"].active { color: var(--in); }
#salePay button[data-pay="mm"].active { color: var(--saffron-deep); }
#salePay button[data-pay="credit"].active { color: var(--indigo); }

/* ---------- Fenêtres du bas (panier) ---------- */
.backdrop { position: fixed; inset: 0; background: var(--scrim); z-index: 10; animation: fade .2s ease-out; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11;
  max-width: 560px; margin: 0 auto;
  background: var(--card); border-radius: 28px 28px 0 0; overflow: hidden;
  padding: 22px 16px calc(14px + env(safe-area-inset-bottom));
  animation: sheet-up .34s var(--ease);
}
.sheet::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 8px; background: var(--wax) 0 0 / 34px 8px repeat-x; }
@keyframes sheet-up { from { transform: translateY(60px); opacity: 0; } }
.grab { display: none; }
.sheet h2 { font-family: var(--display); font-weight: 800; font-size: 1.3rem; letter-spacing: -.02em; margin: 2px 0 12px; }
/* hauteur fixe : les produits ne bougent pas sous le doigt quand le panier se remplit (c'est le panier qui défile) */
#sale { height: min(90vh, 790px); display: flex; flex-direction: column; }
#sale > * { flex: none; }
#sale > .cart { flex: 1 1 auto; min-height: 104px; overflow-y: auto; }
/* sur un petit écran, c'est la grille des produits qui rétrécit (elle défile), jamais les boutons du bas */
#sale > .picks { flex: 0 1 auto; min-height: 118px; }
.sale-search { margin: 0 0 10px; }

.picks {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px;
  max-height: 27vh; overflow-y: auto; overflow-x: hidden; padding: 8px 4px 4px; margin: -4px -4px 10px;
}
.pick {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0;
  border: 0; background: var(--bg); border-radius: 16px; padding: 8px 4px 7px;
}
.pick > span:not(.thumb) { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 1.3rem; background: var(--card); margin-bottom: 3px; box-shadow: var(--shadow); }
.pick b { font-size: .8rem; font-weight: 800; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick small { font-size: .7rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.pick.empty-stock { opacity: .6; }
.pick.empty-stock small { color: var(--over); }
.pick-free { background: transparent; border: 2px dashed var(--line); }
.pick-free span { background: var(--saffron-soft); }
.pick-n {
  position: absolute; top: -6px; right: -2px; min-width: 24px; height: 24px; padding: 0 7px;
  border-radius: 12px; background: var(--green-deep); color: #fff; border: 2px solid var(--card);
  font-style: normal; font-size: .75rem; font-weight: 800; display: grid; place-items: center;
}
:root[data-theme="dark"] .pick-n { background: var(--green); color: #04140e; }
.pick-n.pop { animation: pop .38s var(--spring); }
@keyframes pop { 0% { transform: scale(.4); } 100% { transform: scale(1); } }
.pick.tapped > span { animation: tapped .35s var(--spring); }
@keyframes tapped { 40% { transform: scale(1.18) rotate(-6deg); } }

/* « +1 » qui s'envole du produit touché */
.plus-one {
  position: fixed; z-index: 30; pointer-events: none;
  font-family: var(--display); font-weight: 800; font-size: 1rem; color: var(--green);
  background: var(--card); border-radius: 10px; padding: 1px 8px; box-shadow: var(--shadow);
  animation: plus-one .7s var(--ease) forwards;
}
@keyframes plus-one { 0% { opacity: 0; transform: translate(-50%, 0) scale(.6); } 20% { opacity: 1; transform: translate(-50%, -10px) scale(1); } 100% { opacity: 0; transform: translate(-50%, -46px); } }

.cart { border-top: 1.5px dashed var(--line); }
.cart-empty { text-align: center; padding: 16px 8px 4px; margin: 0; }
.cart-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; padding: 9px 0; }
.cart-row + .cart-row { border-top: 1px solid var(--line); }
.cart-row.new { animation: row-in .3s var(--ease); }
@keyframes row-in { from { opacity: 0; transform: translateX(-14px); } }
.cart-row .info { min-width: 0; }
.cart-row .info b { display: block; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.price-btn { padding: 0; font-size: .76rem; font-weight: 700; color: var(--saffron-deep); }
.qty { display: flex; align-items: center; gap: 2px; background: var(--bg); border-radius: 14px; padding: 3px; }
.qty .icon-btn { box-shadow: none; background: var(--card); }
.qty-n { min-width: 34px; height: 34px; border: 0; background: none; font-weight: 800; font-size: 1rem; }
.cart-row .amt { min-width: 84px; text-align: right; }
.sale-total {
  display: flex; justify-content: space-between; align-items: baseline;
  border-top: 2px solid var(--text); margin: 6px 0 12px; padding-top: 10px;
}
.sale-total span { font-weight: 800; }
.sale-total b { font-family: var(--display); font-size: 2rem; font-weight: 800; letter-spacing: -.02em; }
.sale-total b.bump { animation: bump .3s var(--spring); }
@keyframes bump { 40% { transform: scale(1.08); color: var(--green); } }
.cust-field { margin: 10px 0 0; }
.actions { display: flex; gap: 6px; margin-top: 10px; }
.actions .primary { flex: 1; }
#sale .actions .btn { white-space: nowrap; padding-left: 12px; padding-right: 12px; }
#saleReceipt, #saleDelete { flex: none; }
#sale .actions .primary { font-family: var(--display); font-size: 1.05rem; }

/* ---------- Fenêtre de dialogue ---------- */
.dlg-backdrop { z-index: 26; }
.dialog {
  position: fixed; z-index: 27; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: calc(100% - 32px); max-width: 390px; max-height: 88vh; overflow-y: auto;
  background: var(--card); border-radius: 26px; padding: 22px 18px 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
  animation: dlg-in .3s var(--spring);
}
@keyframes dlg-in { from { opacity: 0; transform: translate(-50%, -46%) scale(.94); } }
.dialog h2 { font-family: var(--display); font-weight: 800; font-size: 1.3rem; letter-spacing: -.02em; margin: 0 0 6px; }
.dialog .hint { color: var(--muted); font-size: .88rem; margin: 0 0 14px; line-height: 1.45; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.swatch input { position: absolute; opacity: 0; }
.swatch i { display: block; width: 30px; height: 30px; border-radius: 50%; border: 3px solid transparent; }
.swatch input:checked + i { border-color: var(--text); }

/* ---------- Produits ---------- */
.subhead { display: flex; align-items: center; gap: 8px; margin: 4px 0 14px; flex-wrap: wrap; }
.subhead h2 { font-family: var(--display); font-weight: 800; font-size: 1.5rem; letter-spacing: -.02em; margin: 0; flex: 1; }
.subhead .btn { flex: none; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.facts div { background: var(--card); border-radius: 18px; padding: 13px 14px; box-shadow: var(--shadow); }
.facts small { color: var(--muted); display: block; font-size: .76rem; font-weight: 600; }
.facts strong { display: block; font-family: var(--display); font-size: 1.25rem; font-weight: 800; letter-spacing: -.01em; margin: 2px 0; }
.prod-row { display: flex; align-items: center; gap: 8px; padding-right: 12px; }
.prod-row + .prod-row { border-top: 1px solid var(--line); }
.prod-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px;
  border: 0; background: none; text-align: left; padding: 12px 0 12px 14px;
}
.prod-main .bubble.sm { background: var(--bg); }
.prod-main .info { flex: 1; min-width: 0; }
.prod-main .info b { display: block; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prod-main .info small { display: block; color: var(--muted); font-size: .76rem; }
.stock {
  text-align: center; flex: none; min-width: 54px; padding: 4px 8px; border-radius: 12px;
  background: var(--green-soft);
}
.stock b { display: block; font-family: var(--display); font-size: 1.1rem; font-weight: 800; color: var(--green); line-height: 1.15; }
.stock small { color: var(--muted); font-size: .66rem; font-weight: 700; }
.stock.low { background: var(--saffron-soft); }
.stock.low b, .stock.low small { color: var(--saffron-deep); }
.stock.out-stock { background: var(--coral-soft); }
.stock.out-stock b, .stock.out-stock small { color: var(--over); }
.restock { flex: none; }

/* ---------- Crédits ---------- */
.cust { padding: 14px; }
.cust-head { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; padding: 0 0 12px; text-align: left; }
.cust-head .info { flex: 1; min-width: 0; }
.cust-head .info b { display: block; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cust-head .info small { color: var(--muted); font-size: .8rem; }
#tab-credit .bubble.sm { font-family: var(--display); font-weight: 800; color: var(--indigo); background: var(--indigo-soft); }
.debt { text-align: right; flex: none; }
.debt b { display: block; font-family: var(--display); font-size: 1.2rem; font-weight: 800; }
.debt small { color: var(--muted); font-size: .74rem; }
.cust .row-actions .btn { flex: 1; }

/* ---------- Bilan ---------- */
.ledger-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 0; font-size: .95rem; }
.ledger-row small { display: block; color: var(--muted); font-size: .76rem; }
.ledger-row b { font-weight: 800; white-space: nowrap; }
.ledger-row.minus b { color: var(--muted); }
.ledger-row.sum { border-top: 1.5px solid var(--line); font-weight: 800; }
.ledger-row.total { border-top: 2px solid var(--text); font-size: 1.05rem; }
.ledger-row.total b { font-family: var(--display); font-size: 1.3rem; }
.ledger .ledger-row { animation: line-in .4s var(--ease) both; }
.ledger .ledger-row:nth-of-type(2) { animation-delay: .06s; }
.ledger .ledger-row:nth-of-type(3) { animation-delay: .12s; }
.ledger .ledger-row:nth-of-type(4) { animation-delay: .18s; }
.ledger .ledger-row:nth-of-type(5) { animation-delay: .26s; }
@keyframes line-in { from { opacity: 0; transform: translateY(6px); } }
.hbar-row { display: grid; grid-template-columns: 7.5rem 1fr auto; align-items: center; gap: 10px; padding: 7px 0; font-size: .88rem; }
.hbar-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.hbar { height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden; }
.hbar i { display: block; height: 100%; border-radius: 5px; transform-origin: left center; animation: grow .9s var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } }
.hbar-val { font-weight: 800; text-align: right; white-space: nowrap; }
.hbar-val small { display: block; color: var(--muted); font-weight: 600; font-size: .72rem; }

/* ---------- Réglages ---------- */
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; }
.setting + .setting { border-top: 1px solid var(--line); }
.setting > span { font-weight: 700; font-size: .92rem; }
.setting select, .setting input {
  border: 1.5px solid var(--line); background: var(--bg); border-radius: 12px;
  padding: 8px 10px; max-width: 160px; color: var(--text); font-weight: 600;
}
.setting.stack { flex-direction: column; align-items: stretch; gap: 10px; }

/* Premium */
.pm-card { position: relative; overflow: hidden; padding-top: 24px; }
.pm-card::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 8px; background: var(--wax) 0 0 / 34px 8px repeat-x; }
.pm-card.on::before { opacity: .5; }
.pm-star { font-size: .8em; }
.pm-perks { margin: 0 0 10px; padding-left: 0; list-style: none; font-size: .9rem; }
.pm-perks li { padding: 5px 0; font-weight: 600; }
.pm-price { font-family: var(--display); font-size: 1.5rem; font-weight: 800; margin: 4px 0 10px; color: var(--saffron-deep); letter-spacing: -.01em; }
.pm-steps { margin: 0 0 12px; padding-left: 20px; font-size: .88rem; color: var(--muted); }
.pm-steps li { padding: 3px 0; }
.pm-steps .link-btn { padding: 0 4px; }
.pm-device { font-family: var(--display); letter-spacing: .06em; color: var(--text); }
#pmCode { font-family: monospace; font-size: .85rem; }
#premiumCard { scroll-margin-top: 80px; }

/* ---------- Proposition d'installation ---------- */
.install-backdrop { z-index: 24; }
.install-card {
  position: fixed; z-index: 25; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: calc(100% - 40px); max-width: 350px; overflow: hidden;
  background: var(--card); border-radius: 28px; padding: 30px 20px 18px;
  text-align: center; box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
  animation: dlg-in .35s var(--spring);
}
.install-card::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 10px; background: var(--wax) 0 0 / 40px 10px repeat-x; }
.install-card img { border-radius: 18px; box-shadow: var(--shadow-lift); }
.install-card h2 { font-family: var(--display); font-weight: 800; font-size: 1.35rem; letter-spacing: -.02em; margin: 12px 0 6px; }
.install-card p { color: var(--muted); font-size: .9rem; margin: 0 0 14px; line-height: 1.45; }
.install-card .install-how { color: var(--text); background: var(--green-soft); border-radius: 14px; padding: 10px 12px; text-align: left; }
.install-actions { display: grid; gap: 8px; }

/* ---------- Écran du code PIN ---------- */
.lock {
  position: fixed; inset: 0; z-index: 50; /* au-dessus de tout, même des messages */
  background: var(--green-deep) var(--lattice); color: #f4fbf8;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.lock::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 14px; background: var(--wax) 0 0 / 48px 14px repeat-x; }
.lock-box { width: 100%; max-width: 320px; text-align: center; }
.lock-icon { font-size: 2rem; }
.lock h2 { font-family: var(--display); font-weight: 800; font-size: 1.45rem; margin: 8px 0 4px; }
.lock-msg { min-height: 1.3em; color: rgba(244, 251, 248, .75); font-size: .9rem; margin: 0 0 18px; }
.lock-msg.err { color: #ffb39c; font-weight: 700; }
.dots { display: flex; justify-content: center; gap: 16px; margin-bottom: 28px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(244, 251, 248, .6); transition: background-color .15s, transform .2s var(--spring); }
.dots i.on { background: var(--saffron); border-color: var(--saffron); transform: scale(1.15); }
.dots.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; justify-items: center; }
.keypad button {
  width: 72px; height: 72px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, .1); color: #fff;
  font-family: var(--display); font-size: 1.7rem; font-weight: 700;
}
.keypad button:active { background: rgba(255, 255, 255, .22); }
.keypad .ghost-key { background: none; font-family: var(--sans); font-size: 1.4rem; }
.lock .link-btn { margin-top: 22px; color: var(--saffron); }

/* ---------- Message temporaire ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 40; width: max-content; max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: #10231c; color: #f4fbf8; padding: 11px 12px 11px 16px; border-radius: 16px; font-size: .9rem; font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .25);
  animation: toast-in .35s var(--spring);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 14px) scale(.96); } }
.toast[hidden] { display: none !important; }
.toast-btn { flex: none; border: 0; border-radius: 11px; padding: 7px 12px; font-weight: 800; font-size: .86rem; background: var(--saffron); color: var(--on-action); }

/* ---------- Mini-carte quand on fait défiler ---------- */
.mini-note {
  position: absolute; left: 16px; right: 16px; top: calc(100% - 2px);
  display: flex; align-items: baseline; gap: 10px;
  border: 0; text-align: left;
  background: var(--green-deep); color: #f4fbf8;
  border-radius: 16px; padding: 9px 14px;
  box-shadow: 0 10px 24px rgba(8, 63, 50, .28);
  opacity: 0; transform: translateY(-8px); pointer-events: none;
  transition: opacity .22s ease, transform .3s var(--spring);
}
.top.show-mini .mini-note { opacity: 1; transform: none; pointer-events: auto; }
.mini-note > span { color: rgba(244, 251, 248, .7); font-size: .8rem; font-weight: 600; }
.mini-note b { font-family: var(--display); font-size: 1.15rem; font-weight: 800; }
.mini-note b.neg { color: #ffb39c; }
.mini-note small { margin-left: auto; display: flex; gap: 10px; font-size: .82rem; font-weight: 700; }
.mini-note .in { color: #8ff0c8; }
.mini-note .out { color: #ffb39c; }

/* ---------- Le grand moment : la vente encaissée ---------- */
.celebrate {
  position: fixed; inset: 0; z-index: 45; display: grid; place-items: center;
  background: rgba(8, 63, 50, .0); pointer-events: auto; cursor: pointer;
  animation: cel-bg 1.5s ease both;
}
.celebrate.credit { --cel: 35, 47, 128; }
@keyframes cel-bg { 0% { background: rgba(var(--cel, 8, 63, 50), 0); } 15%, 75% { background: rgba(var(--cel, 8, 63, 50), .88); } 100% { background: rgba(var(--cel, 8, 63, 50), 0); } }
.cel-box { text-align: center; color: #fff; animation: cel-box 1.5s var(--ease) both; }
@keyframes cel-box { 0% { opacity: 0; transform: scale(.7); } 18% { opacity: 1; transform: scale(1); } 78% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-20px) scale(.96); } }
.cel-box svg { width: 150px; height: 150px; overflow: visible; }
.cel-coin { animation: coin-drop .55s cubic-bezier(.5, 0, .75, 0) both; }
.cel-coin.c2 { animation-delay: .12s; }
.cel-coin.c3 { animation-delay: .24s; }
@keyframes coin-drop { from { transform: translateY(-90px); opacity: 0; } 30% { opacity: 1; } to { transform: none; opacity: 0; } }
.cel-bowl { transform-origin: 75px 120px; animation: bowl-bounce .5s var(--spring) .5s both; }
@keyframes bowl-bounce { 0% { transform: scale(1); } 40% { transform: scale(1.08, .94); } 100% { transform: scale(1); } }
.cel-amount { font-family: var(--display); font-size: 2.3rem; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; animation: amount-up .45s var(--spring) .45s both; }
.cel-sub { font-weight: 700; color: rgba(255, 255, 255, .82); animation: amount-up .45s var(--spring) .55s both; }
@keyframes amount-up { from { opacity: 0; transform: translateY(14px); } }

/* Confettis wax (dette entièrement payée) */
.confetti { position: fixed; inset: 0; z-index: 44; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute; top: -20px; left: var(--x); width: 0; height: 0;
  border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 12px solid var(--c);
  animation: fall var(--d) cubic-bezier(.3, .6, .5, 1) var(--delay) forwards;
}
@keyframes fall { to { transform: translate(var(--dx), 110vh) rotate(var(--r)); } }
/* la grille des produits s'efface en bas : on comprend qu'elle défile */
.picks { -webkit-mask-image: linear-gradient(to bottom, #000 82%, transparent); mask-image: linear-gradient(to bottom, #000 82%, transparent); padding-bottom: 18px; }
.prod-main .info small .gain { color: var(--in); font-weight: 700; }
.cust .row-actions .btn { white-space: nowrap; font-size: .8rem; padding-left: 8px; padding-right: 8px; }
/* résumé des crédits (sur des ventes / autres dettes) dans la grande carte indigo */
.credit-split { margin-top: 14px; }
.credit-split strong { color: #fff; }

/* ---------- Image des produits : photo, emoji ou initiales ---------- */
.thumb { display: grid; place-items: center; overflow: hidden; flex: none; }
.thumb.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.initials {
  font-family: var(--display); font-weight: 800; letter-spacing: .02em; font-size: .95rem;
  background: var(--t-bg); color: var(--t-fg);
}
/* 8 couleurs, toujours la même pour un produit donné */
.tint-0 { --t-bg: #e2f1eb; --t-fg: #0e5e4a; }
.tint-1 { --t-bg: #fff3d1; --t-fg: #8a5a00; }
.tint-2 { --t-bg: #fde6de; --t-fg: #b23a1c; }
.tint-3 { --t-bg: #e6e9fb; --t-fg: #2f3fa8; }
.tint-4 { --t-bg: #dff3f4; --t-fg: #0b6870; }
.tint-5 { --t-bg: #f3e6f5; --t-fg: #7a2f86; }
.tint-6 { --t-bg: #f4ecdc; --t-fg: #7a5420; }
.tint-7 { --t-bg: #e8ecef; --t-fg: #3a4752; }
:root[data-theme="dark"] .thumb.initials { background: color-mix(in srgb, var(--t-fg) 30%, #11201b); color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .thumb.initials { background: color-mix(in srgb, var(--t-fg) 30%, #11201b); color: #fff; } }
/* tailles */
.thumb.bubble.sm { width: 42px; height: 42px; border-radius: 13px; }
.pick .thumb.pick-img { width: 40px; height: 40px; border-radius: 50%; margin-bottom: 3px; box-shadow: var(--shadow); font-size: .85rem; }
.pick .thumb.pick-img.emoji { background: var(--card); font-size: 1.3rem; }
.bubble .thumb.fill { width: 100%; height: 100%; border-radius: inherit; }
.thumb.mini { display: inline-grid; width: 20px; height: 20px; border-radius: 6px; font-size: .6rem; vertical-align: -5px; margin-right: 4px; }
.thumb.mini.emoji { font-size: .95rem; background: none; }
/* champ photo dans la fenêtre du produit */
.photo-field > span:first-child { display: block; margin-bottom: 6px; }
.photo-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.photo-prev .thumb { width: 64px; height: 64px; border-radius: 16px; background: var(--bg); font-size: 1.4rem; }
.photo-prev:empty { display: none; }

/* ---------- Cadre « Calebasse » : toutes les photos se ressemblent ---------- */
/* liseré blanc + fin anneau safran + légère ombre, et un voile très doux qui unifie la lumière */
.thumb.photo { position: relative; background: var(--card); box-shadow: 0 0 0 2px var(--card), 0 0 0 3.5px rgba(244, 180, 26, .6), 0 3px 8px rgba(19, 36, 30, .18); }
.thumb.photo::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(circle at 50% 38%, transparent 55%, rgba(8, 63, 50, .16) 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
}
.thumb.mini.photo { box-shadow: 0 0 0 1.5px rgba(244, 180, 26, .7); }
.photo-prev .thumb.photo { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px rgba(244, 180, 26, .6), 0 4px 12px rgba(19, 36, 30, .2); }

/* ---------- Écran de préparation de la photo ---------- */
.photo-edit {
  position: fixed; inset: 0; z-index: 29; display: grid; place-items: center; padding: 16px;
  background: rgba(6, 18, 14, .86); animation: fade .2s ease-out;
}
.pe-box {
  width: 100%; max-width: 380px; background: var(--card); border-radius: 26px; padding: 18px 16px 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .4); animation: dlg-in .3s var(--spring); position: relative; overflow: hidden;
}
.pe-box::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 8px; background: var(--wax) 0 0 / 34px 8px repeat-x; }
.pe-box h2 { font-family: var(--display); font-weight: 800; font-size: 1.3rem; margin: 6px 0 2px; letter-spacing: -.02em; }
.pe-tip { color: var(--muted); font-size: .8rem; margin: 0 0 12px; }
.pe-view {
  position: relative; width: min(100%, 300px); aspect-ratio: 1; margin: 0 auto; border-radius: 22px; overflow: hidden;
  background: #10231c; touch-action: none; cursor: grab;
}
.pe-view:active { cursor: grabbing; }
.pe-view canvas { width: 100%; height: 100%; display: block; }
.pe-view.loading::after { content: '⏳'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 2rem; }
/* repères de cadrage (tiers) + bord safran = ce que montrera la vignette */
.pe-frame {
  position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  box-shadow: inset 0 0 0 3px rgba(244, 180, 26, .85);
  background:
    linear-gradient(to right, transparent calc(33.33% - .5px), rgba(255,255,255,.35) 33.33%, transparent calc(33.33% + .5px), transparent calc(66.66% - .5px), rgba(255,255,255,.35) 66.66%, transparent calc(66.66% + .5px)),
    linear-gradient(to bottom, transparent calc(33.33% - .5px), rgba(255,255,255,.35) 33.33%, transparent calc(33.33% + .5px), transparent calc(66.66% - .5px), rgba(255,255,255,.35) 66.66%, transparent calc(66.66% + .5px));
}
.pe-warn { background: var(--saffron-soft); color: var(--text); border-radius: 12px; padding: 8px 10px; font-size: .82rem; margin: 10px 0 0; }
.pe-warn .link-btn { padding: 0; font-size: inherit; }
.pe-zoom { display: flex; align-items: center; gap: 10px; margin: 12px 4px 4px; }
.pe-zoom input { flex: 1; accent-color: var(--green); }
.pe-auto { margin: 6px 2px 4px; font-size: .86rem; font-weight: 600; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 18px; height: 18px; accent-color: var(--green); }
