:root {
  --green: #0B5D46; --green-2: #0E7A5C; --green-soft: #E3F0EB;
  --gold: #F2C14E; --ink: #1B1F1D; --muted: #66706B; --line: #E4E1D9;
  --bg: #F6F4EF; --card: #FFFFFF; --red: #C0392B; --red-soft: #FBE9E7;
  --amber: #B7791F; --amber-soft: #FFF4DC; --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--green); }
.app { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(96px + var(--safe-b)); }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--green); color: #fff; }
.brand { font-weight: 800; letter-spacing: .12em; font-size: 20px; }
.brand::after { content: ""; display: inline-block; width: 7px; height: 7px; background: var(--gold); border-radius: 50%; margin-left: 4px; }
.spacer { flex: 1; }
.icon-btn { background: transparent; border: 0; color: inherit; font-size: 22px; width: 40px; height: 40px; border-radius: 10px; cursor: pointer; }
.icon-btn:active { background: rgba(255,255,255,.15); }
.badge-mode { background: var(--gold); color: #3a2c00; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }

.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; background: #fff; border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabbar a { flex: 1; text-align: center; padding: 10px 4px 12px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600; }
.tabbar a .ti { display: flex; justify-content: center; margin-bottom: 3px; }
.tabbar a .ico { stroke-width: 1.7; }
.tabbar a.on .ico { stroke-width: 2.2; }
.tabbar a.on { color: var(--green); }

h1 { font-size: 24px; margin: 8px 0 4px; }
h2 { font-size: 18px; margin: 24px 0 10px; }
.sub { color: var(--muted); margin: 0 0 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.card.tap { cursor: pointer; }
.card.tap:active { transform: scale(.99); }
.row { display: flex; align-items: center; gap: 12px; }
.row .grow { flex: 1; min-width: 0; }
.title { font-weight: 700; }
.muted { color: var(--muted); font-size: 14px; }
.amount { font-weight: 800; font-size: 20px; white-space: nowrap; }
.big-amount { font-size: 34px; font-weight: 800; letter-spacing: -.02em; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn { display: block; width: 100%; border: 0; border-radius: 14px; padding: 15px 18px; font-weight: 700; font-size: 16px; cursor: pointer; text-align: center; text-decoration: none; background: var(--green); color: #fff; margin-top: 12px; }
.btn:active { background: var(--green-2); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.secondary { background: var(--green-soft); color: var(--green); }
.btn.ghost { background: transparent; color: var(--green); border: 1.5px solid var(--line); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.small { display: inline-block; width: auto; padding: 9px 14px; font-size: 14px; margin: 0; border-radius: 10px; }
.btn-row { display: flex; gap: 10px; } .btn-row .btn { flex: 1; }

label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 6px; }
input, select { width: 100%; padding: 14px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; font-size: 16px; }
input:focus, select:focus { outline: none; border-color: var(--green); }
.hint { color: var(--muted); font-size: 13px; margin-top: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.otp { letter-spacing: .5em; text-align: center; font-size: 24px; font-weight: 700; }

.choice { display: grid; gap: 10px; }
.choice button { display: flex; align-items: center; gap: 14px; text-align: left; padding: 16px; background: #fff; border: 2px solid var(--line); border-radius: 14px; cursor: pointer; }
.choice button.on { border-color: var(--green); background: var(--green-soft); }
.choice .ci { width: 48px; height: 48px; display: grid; place-items: center; background: var(--green-soft); color: var(--green); border-radius: 12px; flex: none; }
.ops { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ops button { padding: 12px 6px; border: 2px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; font-weight: 700; font-size: 14px; }
.ops button.on { border-color: var(--green); background: var(--green-soft); color: var(--green); }

.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.pill.paid, .pill.SUCCESS, .pill.active { background: var(--green-soft); color: var(--green); }
.pill.due, .pill.PENDING, .pill.PROCESSING, .pill.pending { background: var(--amber-soft); color: var(--amber); }
.pill.late, .pill.FAILED, .pill.CANCELLED, .pill.EXPIRED, .pill.rejected { background: var(--red-soft); color: var(--red); }

.hero { background: var(--green); color: #fff; border-radius: 20px; padding: 20px; margin: 4px 0 12px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: rgba(242,193,78,.18); }
.hero .muted { color: rgba(255,255,255,.75); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.stats div { background: rgba(255,255,255,.12); border-radius: 12px; padding: 10px; text-align: center; }
.stats b { display: block; font-size: 22px; }
.stats span { font-size: 12px; color: rgba(255,255,255,.8); }

.qr-box { background: #fff; border-radius: 20px; padding: 20px; text-align: center; border: 1px solid var(--line); }
.qr-box img { width: 100%; max-width: 280px; image-rendering: pixelated; }
.code-big { font-family: ui-monospace, Menlo, monospace; font-size: 26px; font-weight: 800; letter-spacing: .18em; margin: 10px 0 2px; }
.timer { color: var(--muted); font-size: 14px; }

.scanner { position: relative; background: #000; border-radius: 20px; overflow: hidden; aspect-ratio: 1; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame { position: absolute; inset: 15%; border: 3px solid var(--gold); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }

.lines { margin: 0; padding: 0; list-style: none; }
.lines li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.lines li:last-child { border-bottom: 0; }
.lines li.total { font-weight: 800; font-size: 18px; border-top: 2px solid var(--ink); border-bottom: 0; margin-top: 4px; }

.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty .ei { display: grid; place-items: center; width: 76px; height: 76px; margin: 0 auto 12px; border-radius: 50%; background: var(--green-soft); color: var(--green); }
.alert { background: var(--amber-soft); color: #6b4a10; border-radius: 12px; padding: 12px 14px; font-size: 14px; margin: 12px 0; }
.alert.err { background: var(--red-soft); color: var(--red); }
.spinner { width: 54px; height: 54px; border: 5px solid var(--green-soft); border-top-color: var(--green); border-radius: 50%; animation: spin 1s linear infinite; margin: 24px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.check { width: 72px; height: 72px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; margin: 12px auto; }
.fail { background: var(--red); }

.toast { position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; max-width: 90vw; z-index: 50; }
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); }

.login-hero { text-align: center; padding: 36px 8px 8px; }
.login-hero .logo { width: 84px; height: 84px; margin: 0 auto 10px; }
.login-hero h1 { font-size: 34px; letter-spacing: .1em; margin: 0; }

/* Quittance imprimable */
.receipt { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.receipt .rh { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--green); padding-bottom: 12px; margin-bottom: 12px; }
.receipt .rh .brand { color: var(--green); }
@media print {
  .topbar, .tabbar, .no-print, .toast { display: none !important; }
  body, .app { background: #fff; padding: 0; }
  .receipt { border: 0; }
}

/* Écran de confirmation du paiement */
.confirm { padding: 4px 16px; }
.confirm .ci { padding: 12px 0; border-bottom: 1px solid var(--line); }
.confirm .ci:last-child { border-bottom: 0; }
.confirm .cl { color: var(--muted); font-size: 13px; margin-bottom: 2px; }
.confirm .cv { font-size: 17px; font-weight: 600; }
.confirm .cs { color: var(--muted); font-size: 13px; }
.confirm .tot .cv { font-size: 22px; font-weight: 800; color: var(--green); }

/* Icônes */
.ico { display: block; flex: none; }
.icon-btn { display: grid; place-items: center; }
.btn-ico { display: inline-flex; vertical-align: -4px; margin-right: 8px; }
.row .ci.avatar { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: var(--green-soft); color: var(--green); flex: none; }
.icon-btn[hidden] { display: none; }
.choice button.on .ci { background: #fff; }
[hidden] { display: none !important; }

@font-face { font-family: Questrial; src: url('/fonts/questrial.woff2') format('woff2'); font-weight: 400; font-display: swap; }

/* =====================================================================
   Mise en forme inspirée de cv-professionnel.com (couleurs BILL conservées)
   Police Century Gothic, fond blanc, boutons « pilule » avec ombre douce,
   cartes arrondies à fine bordure, petite barre d'accent sur les titres.
   ===================================================================== */
:root { --radius: 18px; --ink: #111827; --text: #1F2937; --muted: #6B7280; --line: #E5E7EB; --bg: #FFFFFF; --soft: #F4F7F5;
  --shadow: 0 6px 18px rgba(11, 93, 70, .25); --card-shadow: 0 2px 10px rgba(17, 24, 39, .05); }
html, body { background: var(--bg); color: var(--text);
  font-family: "Century Gothic", CenturyGothic, Questrial, "URW Gothic L", AppleGothic, system-ui, sans-serif; line-height: 1.6; }
button, input, select { font-family: inherit; }

/* En-tête blanc : logo carré + nom + slogan */
.topbar { background: #fff; color: var(--ink); border-bottom: 1px solid var(--line); padding: 10px 14px; }
.brandmark { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.logo-sq { width: 38px; height: 38px; border-radius: 10px; background: var(--green); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 18px; position: relative; }
.logo-sq::after { content: ""; position: absolute; right: 5px; bottom: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }
.bm-text { display: flex; flex-direction: column; line-height: 1.15; }
.topbar .brand { font-size: 18px; letter-spacing: .02em; font-weight: 700; color: var(--ink); }
.topbar .brand::after { display: none; }
.tagline { font-size: 12px; color: var(--muted); }
.icon-btn { color: var(--ink); border-radius: 99px; }
.icon-btn:active { background: var(--soft); }
.badge-mode { background: var(--green-soft); color: var(--green); border: 1px solid rgba(11,93,70,.2); }

/* Titres : grands, serrés, avec barre d'accent */
h1 { font-size: 28px; line-height: 1.15; letter-spacing: -.015em; color: var(--ink); margin: 14px 0 6px; }
h1::before { content: ""; display: block; width: 40px; height: 3px; border-radius: 3px; background: var(--green); margin-bottom: 12px; }
.login-hero h1::before, .receipt h1::before { display: none; }
h2 { font-size: 20px; color: var(--ink); letter-spacing: -.01em; }
.sub { color: var(--muted); font-size: 15px; }
.muted { color: var(--muted); }

/* Boutons « pilule » */
.btn { border-radius: 99px; padding: 15px 26px; box-shadow: var(--shadow); letter-spacing: .01em; }
.btn.secondary { box-shadow: none; }
.btn.ghost { background: #fff; color: var(--ink); border: 1.5px solid var(--line); box-shadow: none; }
.btn.danger { box-shadow: none; }
.btn.small { border-radius: 99px; padding: 8px 16px; box-shadow: none; }

/* Cartes */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--card-shadow); padding: 18px; }
.qr-box, .receipt { border-radius: var(--radius); box-shadow: var(--card-shadow); }
.hero { border-radius: 22px; padding: 22px; box-shadow: 0 10px 30px rgba(11, 93, 70, .22); }
.stats div { border-radius: 14px; }

/* Champs */
label { color: var(--ink); }
input, select { border-radius: 14px; border: 1.5px solid var(--line); }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(11, 93, 70, .1); }

/* Choix (moyen de paiement, rôle, opérateur) : style « puce » */
.choice button { border-radius: var(--radius); border: 1.5px solid var(--line); box-shadow: var(--card-shadow); }
.choice button.on { border: 1.5px solid var(--green); box-shadow: 0 0 0 4px rgba(11, 93, 70, .08); }
.ops button { border-radius: 99px; border: 1.5px solid var(--line); font-weight: 600; font-size: 13px; padding: 10px 6px; }
.ops button.on { border-color: var(--green); }
.pill { font-weight: 600; padding: 4px 12px; }

/* Lignes de montants : séparateurs fins */
.lines li { border-bottom: 1px solid var(--line); }
.lines li.total { border-top: 1.5px solid var(--ink); }

/* Barre d'onglets : onglet actif en « puce » douce */
.tabbar { border-top: 1px solid var(--line); padding: 6px 6px calc(6px + var(--safe-b)); gap: 4px; }
.tabbar a { border-radius: 14px; padding: 8px 4px; font-weight: 600; }
.tabbar a.on { background: var(--green-soft); color: var(--green); }

/* Pages vides et alertes */
.empty { background: var(--soft); border-radius: var(--radius); }
.alert { border-radius: 14px; }
.login-hero h1 { letter-spacing: .04em; }
.toast { border-radius: 99px; }

/* ---------- Salaires des agents ---------- */
.agent-row { padding-top: 12px; padding-bottom: 12px; }
.agent-row input[type=checkbox], .check-all input { width: 22px; height: 22px; accent-color: var(--green); flex: none; margin: 0; }
.agent-row .amount { font-size: 17px; }
.agent-row .icon-btn { width: 36px; height: 36px; color: var(--muted); }
.check-all { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--muted); cursor: pointer; margin: 0; }
.run-stats { margin: 6px 0 12px; }
.run-stats div { background: var(--green-soft); color: var(--green); }
.run-stats span { color: var(--muted); }
.lines li.tap { cursor: pointer; }
.pill.WAITING, .pill.REVIEW { background: var(--amber-soft); color: var(--amber); }
.lines li.run-line > span:first-child { flex: 1; min-width: 0; }
.lines li.run-line > span:last-child { flex: none; }
/* Interrupteur (option « Payer des salaires ») */
.switch-row { display: flex; align-items: center; gap: 14px; margin: 0; cursor: pointer; font-weight: 400; }
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 48px; height: 28px; border-radius: 99px; background: var(--line); position: relative; cursor: pointer; transition: background .2s; margin: 0; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(20px); }
.switch:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
