:root {
  --bg: var(--tg-theme-bg-color, #fff);
  --text: var(--tg-theme-text-color, #0f1115);
  --hint: var(--tg-theme-hint-color, #707579);
  --card: var(--tg-theme-secondary-bg-color, #f3f4f7);
  --sep: var(--tg-theme-section-separator-color, rgba(128, 128, 128, .25));
  --accent: #6c5cff;
  --accent2: #2dd4ff;
  --radius: 20px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

/* ---- Portefeuille ---- */
.wallet { margin: 12px 14px 0; padding: 16px; border-radius: 26px; color: #fff; background: radial-gradient(120% 140% at 0% 0%, #8b5cf6 0%, #4f46e5 45%, #0ea5e9 100%); box-shadow: 0 14px 34px -14px rgba(79, 70, 229, .7); position: relative; overflow: hidden; }
.wallet::after { content: ""; position: absolute; width: 220px; height: 220px; right: -70px; top: -90px; border-radius: 50%; background: rgba(255, 255, 255, .14); }
.wallet-top, .wallet-bottom { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; }
.wallet-bottom { justify-content: space-between; margin-top: 18px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: rgba(255, 255, 255, .25) center/cover; display: grid; place-items: center; font-weight: 700; flex: none; border: 2px solid rgba(255, 255, 255, .5); }
.who { min-width: 0; }
.hello { font-size: 12px; opacity: .8; }
.name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label { font-size: 12px; opacity: .85; }
.amount { font-size: 32px; font-weight: 800; letter-spacing: -.5px; line-height: 1.1; }

/* ---- Boutons ---- */
.btn { appearance: none; border: 0; border-radius: 14px; padding: 12px 16px; font: inherit; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: transform .12s ease, opacity .2s; }
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .5; }
.btn.glass { background: rgba(255, 255, 255, .22); color: #fff; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid rgba(255, 255, 255, .35); padding: 10px 14px; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #4f46e5); color: #fff; }
.btn.danger { background: rgba(239, 68, 68, .12); color: #ef4444; }
.btn.ghost { background: transparent; color: var(--hint); }
.btn.wide { width: 100%; margin-top: 8px; padding: 15px; }

/* ---- Onglets ---- */
.tabs { display: flex; gap: 6px; margin: 14px 14px 0; padding: 4px; background: var(--card); border-radius: 14px; }
.tab { flex: 1; border: 0; background: transparent; color: var(--hint); font: inherit; font-weight: 700; padding: 10px; border-radius: 11px; cursor: pointer; transition: background .2s, color .2s; }
.tab.on { background: var(--bg); color: var(--text); box-shadow: 0 2px 8px -3px rgba(0, 0, 0, .25); }

/* ---- Recherche ---- */
main { padding: 16px 14px 0; }
.search { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 14px; padding: 0 14px; color: var(--hint); }
.search input { flex: 1; border: 0; background: transparent; color: var(--text); font: inherit; padding: 13px 0; outline: none; min-width: 0; }
.hint { color: var(--hint); font-size: 14px; margin: 12px 2px; }
.hint:empty { display: none; }

/* ---- Produits ---- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 14px; }
.card { background: var(--card); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; animation: pop .35s ease both; }
.logo { aspect-ratio: 1.25; display: grid; place-items: center; position: relative; }
.logo img { width: 46%; max-height: 52%; object-fit: contain; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .25)); }
.logo.wm { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.logo.wm img { width: 34%; max-height: 40%; }
.logo .label { font-weight: 800; font-size: 14px; color: #fff; text-align: center; padding: 0 8px; line-height: 1.1; text-shadow: 0 2px 8px rgba(0, 0, 0, .3); }
.logo.dark img { filter: brightness(0) drop-shadow(none); }
.logo.dark .label { color: #111; text-shadow: none; }
.logo.mini .label { display: none; }
.logo.mini.wm img { width: 56%; max-height: 56%; }
.logo .initial { font-size: 40px; font-weight: 800; color: #fff; text-shadow: 0 4px 12px rgba(0, 0, 0, .3); }
.info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.title { font-weight: 650; font-size: 14px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.5em; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.price { font-weight: 800; }
.buy { width: 100%; padding: 10px; background: var(--text); color: var(--bg); border-radius: 12px; font-size: 14px; }
.skeleton { border-radius: var(--radius); aspect-ratio: .82; background: linear-gradient(90deg, var(--card) 25%, var(--sep) 50%, var(--card) 75%); background-size: 200% 100%; animation: sh 1.3s infinite; }
@keyframes sh { to { background-position: -200% 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---- Recharge ---- */
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); display: flex; align-items: flex-end; z-index: 20; animation: fade .2s; }
.backdrop[hidden] { display: none; }
.sheet { width: 100%; background: var(--bg); border-radius: 26px 26px 0 0; padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); animation: up .28s ease; max-height: 92vh; overflow-y: auto; }
.grab { width: 40px; height: 4px; border-radius: 4px; background: var(--sep); margin: 0 auto 14px; }
.sheet h3 { margin: 0 0 4px; font-size: 20px; }
.amount-field { display: flex; align-items: baseline; justify-content: center; gap: 6px; margin: 14px 0 10px; padding: 14px; border-radius: 18px; background: var(--card); border: 2px solid transparent; }
.amount-field:focus-within { border-color: var(--accent); }
.amount-field input { width: 60%; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 44px; font-weight: 800; text-align: right; outline: none; }
.amount-field span { font-size: 30px; font-weight: 700; color: var(--hint); }
.chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.chip { border: 1px solid var(--sep); background: transparent; color: var(--text); border-radius: 999px; padding: 8px 16px; font: inherit; font-weight: 650; cursor: pointer; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.limits { text-align: center; color: var(--hint); font-size: 13px; margin: 6px 0 6px; }
.coin-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 16px 0 6px; }
.coin-opt { border: 2px solid transparent; background: var(--card); color: var(--text); border-radius: 16px; padding: 10px 4px 8px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.coin-opt.on { border-color: var(--accent); }
.coin { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.coin img { width: 55%; height: 55%; }
.coin.big { width: 44px; height: 44px; }
.hint.tight { margin: 0; }
.pay-head { display: flex; align-items: center; gap: 12px; }
.pay-head > div:nth-child(2) { flex: 1; min-width: 0; }
.pay-title { font-weight: 800; font-size: 18px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 22px; padding: 6px 12px; border-radius: 12px; background: var(--card); }
.timer.low { color: #ef4444; }
.bar { height: 5px; border-radius: 5px; background: var(--card); margin: 12px 0; overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width 1s linear; }
.qr-wrap { display: grid; place-items: center; margin: 6px 0 12px; }
.qr { width: 210px; height: 210px; padding: 10px; background: #fff; border-radius: 18px; box-shadow: 0 8px 24px -10px rgba(0, 0, 0, .35); }
.qr svg { width: 100%; height: 100%; display: block; }
.qr.dim { opacity: .15; filter: blur(3px); }
.field { margin-top: 10px; }
.field-label { font-size: 12px; color: var(--hint); margin: 0 2px 4px; }
.copy { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--sep); background: var(--card); color: var(--text); border-radius: 14px; padding: 12px 14px; font: inherit; font-weight: 700; text-align: left; cursor: pointer; }
.copy span { min-width: 0; overflow-wrap: anywhere; }
.copy em { font-style: normal; color: var(--accent); font-size: 13px; flex: none; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; font-weight: 600; }
.status { text-align: center; color: var(--hint); font-size: 14px; margin: 14px 0 4px; }
.status.ok { color: #16a34a; font-weight: 700; }
.status.bad { color: #ef4444; font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #111; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 40; animation: fade .2s; }
.toast[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

/* ---- Mes achats ---- */
.orders { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.order { background: var(--card); border-radius: var(--radius); overflow: hidden; animation: pop .3s ease both; }
.order-head { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px; border: 0; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.logo.mini { width: 48px; height: 48px; aspect-ratio: auto; border-radius: 14px; flex: none; }
.logo.mini img { width: 56%; max-height: 56%; }
.logo.mini .initial { font-size: 22px; }
.order-meta { flex: 1; min-width: 0; }
.order-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-sub { font-size: 12px; color: var(--hint); }
.chev { color: var(--hint); transition: transform .2s; flex: none; }
.order.open .chev { transform: rotate(90deg); }
.order-body { padding: 0 12px 14px; display: none; }
.order.open .order-body { display: block; }
.doc { margin-top: 10px; }
.doc-title { font-size: 12px; color: var(--hint); margin: 0 2px 4px; }
.doc-text { background: var(--bg); border-radius: 12px; padding: 10px 12px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(245, 158, 11, .15); color: #d97706; margin-left: 6px; }

/* ---- Offres ---- */
.offers-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.offers-head h3 { margin: 0; font-size: 18px; }
.offer-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 4px; }
.offer { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 16px; padding: 12px; }
.offer.out { opacity: .5; }
.offer-info { flex: 1; min-width: 0; }
.offer-name { font-weight: 650; overflow-wrap: anywhere; }
.offer-stock { font-size: 12px; color: var(--hint); }
.offer-price { font-weight: 800; white-space: nowrap; }
.offer .buy { width: auto; padding: 9px 14px; }
.from { font-size: 12px; font-weight: 600; color: var(--hint); }
