:root {
  --bg: #fffaf5; --card: #ffffff; --ink: #1c1917; --muted: #78716c; --line: #ece4dc;
  --brand: #c2410c; --brand-ink: #ffffff; --brand-soft: #fff1e6;
  --green: #15803d; --green-soft: #e7f6ec; --red: #b91c1c; --red-soft: #fdecec;
  --amber: #a16207; --amber-soft: #fdf4dc; --blue: #1d4ed8; --blue-soft: #e8efff;
  --wa: #128c4a; --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #171412; --card: #221e1b; --ink: #f5f0eb; --muted: #a8a29e; --line: #37312c;
    --brand: #f97316; --brand-soft: #3a2416; --green-soft: #15301f; --red-soft: #3a1a1a; --amber-soft: #352b12; --blue-soft: #1a2440; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: .4rem 0 .8rem; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: 1rem; margin: 0 0 .4rem; }
img { max-width: 100%; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 16px; padding-bottom: 32px; min-height: 70vh; }
.row { display: flex; align-items: center; gap: 8px; }
.row.gap { gap: 8px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.wrap-row { flex-wrap: wrap; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.center { text-align: center; align-items: center; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .big { font-size: 1.15rem; }
.pre { white-space: pre-line; }
.inline { display: inline; margin: 0; }

/* En-tête */
.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.top .row { height: 56px; justify-content: space-between; }
.logo { font-weight: 800; font-size: 1.2rem; color: var(--brand); letter-spacing: -.02em; }
.right { display: flex; align-items: center; gap: 14px; }
.bell { position: relative; font-size: 1.15rem; }
.bell b { position: absolute; top: -6px; right: -10px; background: var(--red); color: #fff; border-radius: 10px; font-size: .7rem; padding: 0 5px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.tabs a { white-space: nowrap; padding: 6px 12px; border-radius: 999px; color: var(--ink); font-size: .9rem; }
.tabs a.on, .tabs a:hover { background: var(--brand-soft); color: var(--brand); text-decoration: none; }
footer { padding: 24px 16px 40px; }

/* Boutons et champs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--brand); color: var(--brand-ink);
  border: 0; border-radius: 10px; padding: 11px 18px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; min-height: 44px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { padding: 7px 12px; min-height: 36px; font-size: .9rem; }
.btn.big { padding: 14px 22px; font-size: 1.05rem; }
.btn.full { width: 100%; }
.btn.ghost { background: transparent; color: var(--brand); border: 1.5px solid var(--brand); }
.btn.danger { background: var(--red); }
.btn.wa { background: var(--wa); }
.btn.geo { background: var(--ink); color: var(--bg); }
.link { background: none; border: 0; color: var(--brand); font: inherit; cursor: pointer; padding: 0; }
.link.danger, .danger { color: var(--red); }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1.5px solid var(--line);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-weight: 600; font-size: .9rem; }
.field small { color: var(--muted); font-size: .8rem; }
.check { display: flex; gap: 8px; align-items: center; }
.check input { width: auto; min-height: 0; }
details summary { cursor: pointer; font-weight: 600; padding: 4px 0; }

/* Cartes et blocs */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; display: block; color: inherit; }
a.card:hover { text-decoration: none; border-color: var(--brand); }
.card.narrow, .narrow { max-width: 560px; margin-left: auto; margin-right: auto; }
.card.warn { background: var(--amber-soft); border-color: transparent; }
.card.warn ul { margin: 6px 0 0; padding-left: 20px; }
.box { border: 1px dashed var(--line); border-radius: 12px; padding: 12px; }
.flash { border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; }
.flash.ok { background: var(--green-soft); color: var(--green); }
.flash.err, .err { background: var(--red-soft); color: var(--red); }
.flash.info { background: var(--blue-soft); }
.flash.block { display: block; }
.empty { color: var(--muted); padding: 20px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); } .badge.red { background: var(--red-soft); color: var(--red); }
.badge.amber { background: var(--amber-soft); color: var(--amber); } .badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.grey { background: var(--line); color: var(--muted); }

/* Accueil */
.hero { padding: 24px 0 8px; }
.hero h1 { font-size: 2rem; }
.hero p { color: var(--muted); max-width: 620px; }
.search { display: flex; gap: 8px; margin: 12px 0 16px; }
.search select { width: auto; }

/* Produits */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.pwrap { display: flex; flex-direction: column; gap: 6px; }
.pcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: inherit; display: flex; flex-direction: column; }
.pcard:hover { text-decoration: none; border-color: var(--brand); }
.pimg { aspect-ratio: 1; background: var(--brand-soft); display: flex; align-items: center; justify-content: center; font-size: 2.5rem; overflow: hidden; }
.pimg img { width: 100%; height: 100%; object-fit: cover; }
.pbody { padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.price { font-weight: 800; color: var(--brand); }
.price.big { font-size: 1.6rem; margin: 0; }
.product { display: grid; grid-template-columns: minmax(0, 420px) 1fr; gap: 20px; margin-bottom: 16px; }
@media (max-width: 720px) { .product { grid-template-columns: 1fr; } }
.pimg.big { border-radius: var(--radius); }
.tiers ul { margin: 6px 0; padding-left: 18px; }
.total { background: var(--brand-soft); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.total > div { display: flex; justify-content: space-between; }
.total .strong { font-size: 1.1rem; border-top: 1px solid var(--line); padding-top: 6px; }
.roles { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.roles legend { font-weight: 600; margin-bottom: 6px; }
.roles label { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; }
.roles label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.roles input { width: auto; min-height: 0; grid-row: span 2; }
.roles small { color: var(--muted); }

/* Tableaux de bord */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 8px 0 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; color: inherit; display: flex; flex-direction: column; }
a.stat:hover { text-decoration: none; border-color: var(--brand); }
.stat b { font-size: 1.3rem; }
.stat.big b { font-size: 2rem; color: var(--brand); }
.stat span { color: var(--muted); font-size: .85rem; }
table.list { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.list td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: .92rem; }
table.list tr:last-child td { border-bottom: 0; }
@media (max-width: 560px) { table.list, table.list tbody, table.list tr, table.list td { display: block; } table.list tr { border-bottom: 1px solid var(--line); padding: 6px 0; } table.list td { border: 0; padding: 3px 12px; } }
table.kv { width: 100%; border-collapse: collapse; }
table.kv td { padding: 6px 0; border-bottom: 1px solid var(--line); }
table.kv td:last-child { text-align: right; white-space: nowrap; }
table.kv .strong td { font-weight: 800; border-bottom: 0; }
.pos { color: var(--green); white-space: nowrap; } .neg { color: var(--red); white-space: nowrap; }
.thumb { width: 56px; font-size: 1.6rem; text-align: center; }
.thumb img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; display: block; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink); font-size: .88rem; }
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.imgpick { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.imgpick img { max-height: 220px; border-radius: 12px; }
.tier-head, .tier-row { display: grid; grid-template-columns: 1fr 1fr 32px; gap: 8px; align-items: center; margin-bottom: 6px; }
.tier-head { font-size: .8rem; color: var(--muted); font-weight: 600; }
.dgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.hire { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; }
.hire input, .hire select { min-height: 36px; padding: 6px 8px; font-size: .9rem; }
.link-card { display: flex; gap: 12px; }
.copy { display: flex; gap: 6px; }
.copy input { font-size: .85rem; min-height: 36px; }
.deliv { display: flex; flex-direction: column; gap: 4px; }
.notif.unread { border-left: 4px solid var(--brand); }
.notif p { margin: 4px 0 0; }
.steps { display: flex; list-style: none; padding: 0; margin: 0; gap: 4px; counter-reset: s; }
.steps li { flex: 1; text-align: center; font-size: .78rem; color: var(--muted); padding-top: 26px; position: relative; }
.steps li::before { counter-increment: s; content: counter(s); position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 22px; height: 22px; border-radius: 50%; background: var(--line); color: var(--muted); font-weight: 700; line-height: 22px; }
.steps li.done { color: var(--ink); font-weight: 600; }
.steps li.done::before { background: var(--green); color: #fff; content: "✓"; }

/* Paiement */
.paycard { padding: 24px 18px; }
.amount { font-size: 2.2rem; font-weight: 800; color: var(--brand); margin: 0; }
.qr { background: #fff; padding: 14px; border-radius: 14px; display: inline-block; margin: 0 auto; }
.qr img, .qr canvas { display: block; }
.paid { font-size: 3.5rem; }

/* Installation */
.install-ios { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg);
  border-radius: 12px; padding: 12px 14px; z-index: 50; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.install-ios .link { color: var(--brand); margin-left: 8px; font-weight: 700; }
#install-btn { min-height: 32px; padding: 4px 10px; }
@media (max-width: 420px) { .right { gap: 8px; } }

/* Administration : avatars, pièces d'identité, affiches */
.avatar { border-radius: 50%; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.avatar.initials { background: var(--green-soft); color: var(--green); font-weight: 700; }
.thumb .avatar { width: 44px; height: 44px; }
.idgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.idgrid figure { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.idgrid figcaption { font-weight: 600; font-size: .9rem; color: var(--muted); }
.idgrid img { width: 100%; max-height: 360px; object-fit: contain; background: var(--line); border-radius: 12px; }
.banner-img { width: 100%; aspect-ratio: 16 / 7; object-fit: cover; border-radius: 12px; background: var(--line); }
.photo-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.photo-pick .imgpick img { width: 100%; max-height: 180px; object-fit: cover; }
.grow { flex: 1; min-width: 0; }
