:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --label: #000000;
  --label2: rgba(60, 60, 67, .6);
  --label3: rgba(60, 60, 67, .3);
  --sep: rgba(60, 60, 67, .18);
  --fill: rgba(118, 118, 128, .12);
  --tint: #1e7a3c;
  --tint-soft: rgba(30, 122, 60, .12);
  --gold: #b8962e;
  --red: #ff3b30;
  --orange: #ff9500;
  --green: #34c759;
  --blue: #007aff;
  --radius: 12px;
  --bar: rgba(249, 249, 249, .8);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --card: #1c1c1e; --label: #ffffff; --label2: rgba(235, 235, 245, .6);
    --label3: rgba(235, 235, 245, .3); --sep: rgba(84, 84, 88, .6); --fill: rgba(118, 118, 128, .24);
    --tint: #3ccf6e; --tint-soft: rgba(60, 207, 110, .16); --gold: #d8b74c; --bar: rgba(22, 22, 24, .8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --card: #1c1c1e; --label: #ffffff; --label2: rgba(235, 235, 245, .6);
  --label3: rgba(235, 235, 245, .3); --sep: rgba(84, 84, 88, .6); --fill: rgba(118, 118, 128, .24);
  --tint: #3ccf6e; --tint-soft: rgba(60, 207, 110, .16); --gold: #d8b74c; --bar: rgba(22, 22, 24, .8);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--label);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  letter-spacing: -.01em;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--tint); text-decoration: none; }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px 48px; }
.wide { max-width: 1100px; }
.nav.wide { max-width: none; }

/* Nav bar */
.nav {
  position: sticky; top: 0; z-index: 20; background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--sep); padding-top: env(safe-area-inset-top);
}
.nav-in { max-width: 640px; margin: 0 auto; height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; }
.wide .nav-in, .nav.wide .nav-in { max-width: 1100px; }
.nav-title { font-weight: 600; font-size: 17px; }
.nav-btn { background: none; border: 0; color: var(--tint); font: inherit; font-size: 17px; padding: 8px 0; cursor: pointer; }
.nav-btn[hidden] { display: none; }

.large-title { font-size: 34px; font-weight: 700; letter-spacing: .01em; margin: 12px 0 4px; }
.subtitle { color: var(--label2); font-size: 15px; margin: 0 0 8px; }

/* Grouped list */
.section-h { text-transform: uppercase; font-size: 13px; color: var(--label2); margin: 28px 16px 7px; letter-spacing: 0; }
.section-f { font-size: 13px; color: var(--label2); margin: 7px 16px 0; }
.group { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.row {
  display: flex; align-items: center; min-height: 44px; padding: 0 16px; position: relative; gap: 12px;
}
.row + .row::before, .row + .row-wrap::before, .row-wrap + .row::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--sep);
}
.row-wrap { position: relative; }
.row label, .row .k { flex: 0 0 auto; min-width: 96px; }
.row .v { margin-left: auto; color: var(--label2); text-align: right; }
.row input, .row select, .row textarea {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--label);
  font: inherit; padding: 11px 0; outline: none; text-align: right;
}
.row select { appearance: none; -webkit-appearance: none; color: var(--label); cursor: pointer; direction: rtl; }
.row select option { direction: ltr; }
.row select:invalid, .row select.ph { color: var(--label3); }
.row input::placeholder { color: var(--label3); }
.row.chev::after {
  content: ""; width: 8px; height: 8px; border-right: 2px solid var(--label3); border-top: 2px solid var(--label3);
  transform: rotate(45deg); flex: 0 0 auto; margin-left: 2px;
}
.row.tap { cursor: pointer; }
.row.tap:active { background: var(--fill); }
.row .icon {
  width: 29px; height: 29px; border-radius: 7px; display: grid; place-items: center; color: #fff; flex: 0 0 auto;
}
.row .icon svg { width: 18px; height: 18px; }
.row .grow { flex: 1; min-width: 0; padding: 10px 0; }
.row .grow small { display: block; color: var(--label2); font-size: 13px; }
.row.err { background: rgba(255, 59, 48, .08); }

/* Segmented control */
.seg { display: flex; background: var(--fill); border-radius: 9px; padding: 2px; gap: 2px; margin: 0; }
.seg button {
  flex: 1; border: 0; background: transparent; color: var(--label); font-family: inherit; font-size: 13px; font-weight: 500; line-height: 1.15; padding: 8px 6px; border-radius: 7px; cursor: pointer; min-height: 32px;
}
.seg button[aria-pressed="true"] { background: var(--card); box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 3px 1px rgba(0,0,0,.04); font-weight: 600; }

/* Choice cards */
.choices { display: grid; gap: 10px; }
.choice {
  display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; border: 2px solid transparent; text-align: left; font: inherit; color: inherit; width: 100%;
}
.choice[aria-pressed="true"] { border-color: var(--tint); }
.choice .radio { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--label3); flex: 0 0 auto; display: grid; place-items: center; }
.choice[aria-pressed="true"] .radio { border-color: var(--tint); background: var(--tint); }
.choice[aria-pressed="true"] .radio::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff; }
.choice b { display: block; font-weight: 600; }
.choice small { color: var(--label2); font-size: 14px; }
.choice .price { margin-left: auto; font-weight: 700; font-size: 20px; color: var(--tint); }

/* Buttons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 50px;
  border: 0; border-radius: 14px; background: var(--tint); color: #fff; font-family: inherit; font-size: 17px; font-weight: 600; line-height: 1;
  cursor: pointer; padding: 0 20px; transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.98); opacity: .85; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.secondary { background: var(--tint-soft); color: var(--tint); }
.btn.plain { background: var(--card); color: var(--tint); }
.btn.danger { background: rgba(255,59,48,.12); color: var(--red); }
.btn.sm { min-height: 36px; font-size: 15px; padding: 0 14px; border-radius: 10px; width: auto; }
.btn-row { display: flex; gap: 10px; margin-top: 16px; }
.btn-row .btn { flex: 1; }

/* Progress */
.steps { display: flex; gap: 6px; margin: 14px 0 0; }
.steps i { flex: 1; height: 4px; border-radius: 2px; background: var(--fill); transition: background .3s; }
.steps i.on { background: var(--tint); }
.step-label { font-size: 13px; color: var(--label2); margin-top: 6px; }

/* Hero */
.hero { margin-top: 16px; border-radius: 22px; overflow: hidden; position: relative; background: var(--card); box-shadow: 0 10px 30px rgba(0,0,0,.08); }
.hero img { display: block; width: 100%; height: auto; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.fact { background: var(--card); border-radius: var(--radius); padding: 12px; }
.fact small { display: block; font-size: 12px; color: var(--label2); text-transform: uppercase; }
.fact b { font-size: 15px; font-weight: 600; display: block; margin-top: 2px; }
@media (max-width: 420px) { .facts { grid-template-columns: 1fr; } .fact { display: flex; justify-content: space-between; align-items: baseline; } }

/* Upload */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 120px;
  border: 2px dashed var(--label3); border-radius: var(--radius); background: var(--card); cursor: pointer; padding: 16px; text-align: center; color: var(--label2);
}
.drop.has { border-style: solid; border-color: var(--tint); color: var(--label); }
.drop img { max-height: 180px; max-width: 100%; border-radius: 8px; }
.payqr { background: var(--card); border-radius: var(--radius); padding: 16px; text-align: center; }
.payqr img { width: 100%; max-width: 280px; border-radius: 10px; }

/* Sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; opacity: 0; pointer-events: none; transition: opacity .25s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; background: var(--bg); border-radius: 14px 14px 0 0;
  max-height: 88vh; overflow: auto; transform: translateY(100%); visibility: hidden; transition: transform .32s cubic-bezier(.2,.8,.2,1), visibility 0s .32s;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto;
}
.sheet::before { content: ""; display: block; width: 36px; height: 5px; border-radius: 3px; background: var(--label3); margin: 0 auto 10px; }
.sheet.open { transform: none; visibility: visible; transition: transform .32s cubic-bezier(.2,.8,.2,1); }
.sheet-bg.open { opacity: 1; pointer-events: auto; }
.sheet-h { display: flex; justify-content: space-between; align-items: center; }
.sheet-h h3 { margin: 0; font-size: 20px; }

/* Tentatif */
.tl .row { align-items: flex-start; }
.tl .t { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--tint); min-width: 44px; padding: 12px 0; }
.tl .a { padding: 12px 0; }

/* Ticket */
.ticket { background: var(--card); border-radius: 22px; overflow: hidden; margin-top: 16px; box-shadow: 0 10px 30px rgba(0,0,0,.08); }
.ticket-top { background: linear-gradient(135deg, #14532d, #1e7a3c 60%, #a88a2a); color: #fff; padding: 22px 20px; text-align: center; }
.ticket-top .ok { width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,.2); display: grid; place-items: center; margin: 0 auto 10px; }
.ticket-top h2 { margin: 0; font-size: 22px; }
.ticket-top p { margin: 4px 0 0; opacity: .85; font-size: 15px; }
.code { font: 700 26px/1.1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .02em; margin-top: 14px; word-break: break-all; }
.qrbox { padding: 20px; display: grid; place-items: center; position: relative; }
.qrbox::before, .qrbox::after { content: ""; position: absolute; top: -12px; width: 24px; height: 24px; border-radius: 50%; background: var(--bg); }
.qrbox::before { left: -12px; } .qrbox::after { right: -12px; }
.qr { background: #fff; padding: 12px; border-radius: 12px; }
.qr canvas, .qr img { display: block; width: 200px !important; height: 200px !important; }
.qr-cap { font-size: 13px; color: var(--label2); margin-top: 8px; }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.pill.green { background: rgba(52,199,89,.16); color: #1f9d48; }
.pill.orange { background: rgba(255,149,0,.16); color: #c26a00; }
.pill.red { background: rgba(255,59,48,.14); color: #d1281e; }
.pill.blue { background: rgba(0,122,255,.14); color: #0a63c9; }
.pill.gray { background: var(--fill); color: var(--label2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pill.green { color: #4cd964; } :root:not([data-theme="light"]) .pill.orange { color: #ffb340; } :root:not([data-theme="light"]) .pill.red { color: #ff6961; } :root:not([data-theme="light"]) .pill.blue { color: #409cff; } }

/* Toast */
.toast {
  position: fixed; left: 50%; top: calc(56px + env(safe-area-inset-top)); transform: translate(-50%, -20px); opacity: 0; z-index: 60;
  background: rgba(30,30,30,.92); color: #fff; padding: 10px 16px; border-radius: 14px; font-size: 15px; transition: .25s; pointer-events: none; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.muted { color: var(--label2); }
.center { text-align: center; }
.hide { display: none !important; }
.foot { text-align: center; color: var(--label2); font-size: 13px; margin-top: 32px; }
.spinner { width: 20px; height: 20px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
