:root { --c: teal; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: whitesmoke; color: black; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; font-size: 16px; }
body { padding-bottom: 80px; }
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }
.wrap { max-width: 640px; margin: 0 auto; }

/* En-tête */
.top { background: var(--c); color: white; padding: 14px 16px; padding-top: calc(14px + env(safe-area-inset-top, 0px)); position: sticky; top: 0; z-index: 5; }
.top h1 { margin: 0; font-size: 1.15rem; }
.top small { color: honeydew; }
.top .row { display: flex; align-items: center; gap: 10px; }
.top .back { background: none; border: 0; color: white; font-size: 1.6rem; padding: 0 8px 0 0; cursor: pointer; }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Bandeaux */
.banner { margin: 10px 12px 0; padding: 10px 12px; border-radius: 10px; font-size: .9rem; }
.b-info { background: lightyellow; border: 1px solid khaki; }
.b-warn { background: mistyrose; border: 1px solid lightcoral; }
.b-ok { background: honeydew; border: 1px solid palegreen; }
.banner a, .banner button.link { color: var(--c); font-weight: bold; background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }

/* Cartes */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px; }
.stat { background: white; border-radius: 12px; padding: 10px 8px; text-align: center; box-shadow: 0 1px 3px silver; }
.stat b { display: block; font-size: 1.05rem; margin-top: 4px; word-break: break-word; }
.stat span { font-size: .72rem; color: gray; }
.card { background: white; border-radius: 12px; padding: 14px; margin: 12px; box-shadow: 0 1px 3px silver; }
.card h3 { margin: 0 0 10px; font-size: 1rem; color: var(--c); }
.red { color: crimson; } .green { color: seagreen; } .orange { color: darkorange; } .gray { color: gray; }

/* Recherche */
.search { margin: 0 12px 8px; }
.search input { width: 100%; padding: 12px 14px; border: 1px solid lightgray; border-radius: 24px; background: white; }

/* Liste de clients */
.list { margin: 0 12px; }
.item { display: flex; align-items: center; gap: 12px; background: white; border-radius: 12px; padding: 12px; margin-bottom: 8px; box-shadow: 0 1px 2px silver; cursor: pointer; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: darkseagreen; color: white; display: flex; align-items: center; justify-content: center; font-weight: bold; flex-shrink: 0; }
.item .name { font-weight: 600; }
.item .sub { font-size: .8rem; color: gray; }
.item .amt { text-align: right; font-weight: bold; white-space: nowrap; }
.badge { display: inline-block; background: darkorange; color: white; border-radius: 8px; font-size: .68rem; padding: 1px 6px; margin-left: 6px; vertical-align: middle; }
.empty { text-align: center; color: gray; padding: 30px 16px; }

/* Boutons */
.fab { position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); background: var(--c); color: white; border: 0; border-radius: 28px; padding: 14px 20px; font-weight: bold; box-shadow: 0 3px 8px gray; z-index: 6; cursor: pointer; }
.btn { display: inline-block; border: 0; border-radius: 10px; padding: 12px 16px; font-weight: 600; cursor: pointer; background: var(--c); color: white; text-align: center; text-decoration: none; }
.btn.red { background: crimson; color: white; }
.btn.green { background: seagreen; color: white; }
.btn.wa { background: forestgreen; color: white; }
.btn.grey { background: gainsboro; color: black; }
.btn.line { background: white; color: var(--c); border: 1px solid var(--c); }
.btn.full { width: 100%; }
.btn:disabled { opacity: .5; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 12px 12px; }

/* Fiche client */
.big { text-align: center; padding: 18px 12px 8px; }
.big .v { font-size: 2rem; font-weight: bold; }
.tx { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid whitesmoke; }
.tx:last-child { border-bottom: 0; }
.tx .dot { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-weight: bold; flex-shrink: 0; }
.tx .dot.debt { background: crimson; } .tx .dot.payment { background: seagreen; }
.tx .x { background: none; border: 0; color: silver; font-size: 1.1rem; cursor: pointer; }

/* Formulaires */
label { display: block; font-size: .85rem; color: dimgray; margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 12px; border: 1px solid lightgray; border-radius: 10px; background: white; }
.auth { max-width: 420px; margin: 0 auto; padding: 24px 18px; }
.auth h1 { color: var(--c); text-align: center; margin-bottom: 4px; }
.auth p.tag { text-align: center; color: gray; margin-top: 0; }
.link { background: none; border: 0; color: var(--c); text-decoration: underline; cursor: pointer; padding: 8px; }

/* Fenêtre modale */
.modal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: white; width: 100%; max-width: 640px; border-radius: 18px 18px 0 0; padding: 18px; padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); max-height: 92vh; overflow-y: auto; }
.sheet h2 { margin: 0 0 6px; font-size: 1.15rem; }
.sheet .btns { display: flex; gap: 8px; margin-top: 16px; }
.sheet .btns .btn { flex: 1; }

/* Navigation du bas */
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: white; border-top: 1px solid lightgray; display: flex; z-index: 7; padding-bottom: env(safe-area-inset-bottom, 0px); }
.nav button { flex: 1; background: none; border: 0; padding: 10px 0 8px; color: gray; font-size: .75rem; cursor: pointer; }
.nav button span { display: block; font-size: 1.3rem; }
.nav button.on { color: var(--c); font-weight: bold; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom, 0px)); background: black; color: white; padding: 10px 16px; border-radius: 20px; z-index: 30; font-size: .9rem; max-width: 90%; text-align: center; }
.kv { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid whitesmoke; font-size: .92rem; }
.kv:last-child { border-bottom: 0; }

.modal::before { content: ''; position: absolute; inset: 0; background: black; opacity: .5; }
.sheet { position: relative; }

textarea { width: 100%; padding: 12px; border: 1px solid lightgray; border-radius: 10px; background: white; min-height: 70px; }
.pill { display: inline-block; border-radius: 8px; font-size: .68rem; padding: 2px 7px; color: white; font-weight: bold; white-space: nowrap; }
.p-paid, .p-accepted { background: seagreen; } .p-partial { background: darkorange; } .p-unpaid { background: dimgray; } .p-late, .p-refused { background: crimson; } .p-open { background: steelblue; }
.seg { display: flex; gap: 6px; margin: 8px 12px; overflow-x: auto; }
.seg button { flex: 0 0 auto; border: 1px solid lightgray; background: white; border-radius: 18px; padding: 7px 14px; font-size: .85rem; cursor: pointer; }
.seg button.on { background: var(--c); color: white; border-color: var(--c); }
.itm { border: 1px solid gainsboro; border-radius: 10px; padding: 8px; margin-bottom: 8px; background: white; }
.r3 { display: grid; grid-template-columns: 1fr 1.4fr 1.2fr auto; gap: 6px; align-items: center; margin-top: 6px; }
.r3 .lt { font-weight: bold; text-align: right; font-size: .85rem; }
.tot { background: whitesmoke; border-radius: 10px; padding: 10px; margin-top: 10px; }
.tot .kv { border: 0; padding: 3px 0; }
.stickybar { position: fixed; left: 0; right: 0; bottom: 0; background: white; border-top: 1px solid lightgray; padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); display: flex; gap: 8px; z-index: 8; }
.stickybar .btn { flex: 1; }
.logo { max-height: 60px; max-width: 160px; display: block; margin: 6px 0; }
.big2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 12px 12px; }

/* ---- Boutique publique ---- */
.shophead { background: var(--c); color: white; padding: 18px 16px 14px; padding-top: calc(18px + env(safe-area-inset-top, 0px)); }
.shophead .row { display: flex; gap: 12px; align-items: center; }
.shophead img.lg { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; background: white; flex-shrink: 0; }
.shophead h1 { margin: 0; font-size: 1.25rem; }
.shophead p { margin: 6px 0 0; font-size: .85rem; color: whitesmoke; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px; }
.chips button { flex: 0 0 auto; border: 1px solid lightgray; background: white; border-radius: 18px; padding: 7px 14px; font-size: .85rem; cursor: pointer; }
.chips button.on { background: var(--c); color: white; border-color: var(--c); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 12px 110px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.pcard { background: white; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 3px silver; display: flex; flex-direction: column; }
.pimg { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; background: gainsboro; display: flex; align-items: center; justify-content: center; font-size: 2.2rem; color: gray; cursor: pointer; }
.pbody { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.pname { font-weight: 600; font-size: .92rem; line-height: 1.2; }
.pprice { color: var(--c); font-weight: bold; }
.soldout { opacity: .55; }
.tag { display: inline-block; background: crimson; color: white; border-radius: 6px; font-size: .68rem; padding: 1px 6px; }
.addbtn { margin-top: auto; border: 0; background: var(--c); color: white; border-radius: 8px; padding: 9px; font-weight: 600; cursor: pointer; }
.addbtn:disabled { background: lightgray; color: gray; }
.step { display: flex; align-items: center; justify-content: space-between; margin-top: auto; background: whitesmoke; border-radius: 8px; }
.step button { border: 0; background: var(--c); color: white; width: 38px; height: 36px; border-radius: 8px; font-size: 1.2rem; cursor: pointer; }
.cartbar { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); background: var(--c); color: white; border: 0; border-radius: 14px; padding: 14px 16px; display: flex; justify-content: space-between; font-weight: bold; box-shadow: 0 3px 10px gray; z-index: 9; cursor: pointer; font-size: 1rem; }
.cartrow { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid whitesmoke; }
.cartrow .grow { font-size: .9rem; }
.cartrow .step { margin: 0; }
.cartrow .step span { min-width: 26px; text-align: center; font-weight: bold; }
.bigimg { width: 100%; max-height: 320px; object-fit: contain; background: whitesmoke; border-radius: 10px; }
.thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: gainsboro; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: gray; }
.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; z-index: 2; }
.switch span { position: absolute; inset: 0; background: silver; border-radius: 13px; transition: .15s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: white; transition: .15s; }
.switch input:checked + span { background: seagreen; }
.switch input:checked + span::after { left: 23px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.swatches button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid white; box-shadow: 0 0 0 1px silver; cursor: pointer; }
.swatches button.on { box-shadow: 0 0 0 3px black; }
.linkbox { background: whitesmoke; border-radius: 10px; padding: 10px; word-break: break-all; font-size: .9rem; margin: 8px 0; }
.photo { width: 100%; max-height: 220px; object-fit: contain; border-radius: 10px; background: whitesmoke; margin-top: 6px; }
