:root{
  --bg:#f4f1ea; --card:#fffdf8; --ink:#1f2a24; --mute:#6f7a6e; --line:#e6e0d4;
  --green:#2f7d4f; --green-soft:#e3f0e6; --amber:#e8a33d; --amber-soft:#fbf0dc; --red:#c0503a;
  --r:18px; --shadow:0 1px 2px rgba(0,0,0,.05),0 8px 24px rgba(31,42,36,.07);
}
*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
body{font-family:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;background:#d9d4c7;color:var(--ink);-webkit-tap-highlight-color:transparent}
.app{max-width:520px;margin:0 auto;height:100dvh;background:var(--bg);display:flex;flex-direction:column;position:relative;overflow:hidden}
@media(min-width:560px){.app{box-shadow:0 20px 60px rgba(0,0,0,.18)}}
[hidden]{display:none!important}
header{padding:calc(14px + env(safe-area-inset-top)) 18px 10px;display:flex;align-items:center;gap:8px}
header h1{font-size:23px;letter-spacing:-.5px;flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.avatars{display:flex;border:0;background:none;cursor:pointer;padding-left:8px}
.av{width:30px;height:30px;border-radius:50%;display:grid;place-items:center;color:#fff;font-size:13px;font-weight:700;border:2px solid var(--bg);margin-left:-8px;flex:0 0 auto}
.av.big{width:40px;height:40px;margin:0;font-size:16px;border:0}
.gear{border:0;background:var(--card);width:36px;height:36px;border-radius:12px;font-size:17px;cursor:pointer;box-shadow:var(--shadow)}
.dot{width:8px;height:8px;border-radius:50%;background:#3cc06b;display:inline-block;margin-right:6px;box-shadow:0 0 0 3px #3cc06b33}
.dot.off{background:#bbb;box-shadow:none}
.sub{padding:0 18px 10px;font-size:13px;color:var(--mute);display:flex;justify-content:space-between;align-items:center;gap:10px}
select,input,button{font:inherit;color:inherit}
select{font-size:14px;border:1px solid var(--line);background:var(--card);border-radius:10px;padding:6px 8px;max-width:55%}
main{flex:1;overflow-y:auto;padding:0 14px 110px;overscroll-behavior:contain}
.offline{background:var(--amber-soft);color:#7a5414;font-size:13px;text-align:center;padding:8px calc(10px + env(safe-area-inset-top)) 8px}
.add{display:flex;gap:8px;background:var(--card);border-radius:var(--r);padding:8px;box-shadow:var(--shadow);margin-bottom:10px}
.add input{flex:1;border:0;font-size:16px;background:transparent;outline:none;padding:0 8px;min-width:0}
.btn{border:0;border-radius:12px;font-weight:600;cursor:pointer}
.btn.icon{width:42px;height:42px;background:var(--green-soft);color:var(--green);font-size:18px}
.btn.go{background:var(--green);color:#fff;padding:0 16px;min-height:42px}
.btn.ghost{background:var(--line);color:var(--ink)}
.btn.danger{background:var(--red);color:#fff}
.btn:disabled{opacity:.45;cursor:not-allowed}
.btn.wide{width:100%;min-height:46px;margin-top:10px;font-size:15px}
.hint{font-size:12px;color:var(--mute);margin:-2px 6px 10px}
.sugg{display:flex;gap:8px;overflow-x:auto;padding-bottom:6px;margin-bottom:6px;scrollbar-width:none}
.chip{flex:0 0 auto;background:var(--amber-soft);border:1px dashed var(--amber);border-radius:14px;padding:7px 11px;font-size:13px;cursor:pointer;text-align:left}
.chip small{display:block;color:#8a5a12;font-size:11px}
h3{font-size:12px;text-transform:uppercase;letter-spacing:1px;color:var(--mute);margin:16px 6px 8px;display:flex;justify-content:space-between;gap:8px}
.group{background:var(--card);border-radius:var(--r);box-shadow:var(--shadow);overflow:hidden}
.item{display:flex;align-items:center;gap:12px;padding:12px 14px;border-bottom:1px solid var(--line);cursor:pointer;transition:background .15s;width:100%;background:none;border-left:0;border-right:0;border-top:0;text-align:left}
.item:last-child{border-bottom:0}
.item:active{background:var(--green-soft)}
.emo{font-size:24px;width:34px;text-align:center;flex:0 0 auto}
.name{flex:1;font-size:15px;min-width:0;overflow-wrap:anywhere}
.name small{display:block;color:var(--mute);font-size:12px}
.qty{font-size:13px;color:var(--green);background:var(--green-soft);border-radius:8px;padding:3px 8px;font-weight:600;white-space:nowrap}
.paid{font-size:12px;color:var(--mute);white-space:nowrap}
.check{width:30px;height:30px;border-radius:50%;border:2px solid var(--line);display:grid;place-items:center;color:#fff;font-size:15px;background:#fff;cursor:pointer;flex:0 0 auto}
.item.done{opacity:.45}.item.done .name{text-decoration:line-through}
.item.done .check{background:var(--green);border-color:var(--green)}
.item.new{animation:flash 1.6s}
@keyframes flash{0%{background:#fff3c4}100%{background:transparent}}
nav{position:absolute;bottom:0;left:0;right:0;background:var(--card);border-top:1px solid var(--line);display:flex;padding:6px 6px calc(10px + env(safe-area-inset-bottom))}
nav button{flex:1;background:none;border:0;font-size:11px;color:var(--mute);cursor:pointer;padding:6px}
nav button b{display:block;font-size:22px;margin-bottom:2px}
nav button.on{color:var(--green);font-weight:700}
.toast{position:absolute;top:calc(64px + env(safe-area-inset-top));left:50%;transform:translate(-50%,-20px);background:var(--ink);color:#fff;padding:10px 16px;border-radius:14px;font-size:13px;opacity:0;transition:.3s;pointer-events:none;z-index:9;max-width:90%;text-align:center}
.toast.show{opacity:1;transform:translate(-50%,0)}
.store .item{padding:16px}.store .emo{font-size:32px}.store .name{font-size:19px;font-weight:600}
.store .check{width:36px;height:36px}
.progress{height:10px;background:var(--line);border-radius:10px;overflow:hidden;margin:4px 4px 6px}
.progress i{display:block;height:100%;background:var(--green);transition:width .3s}
.stats{display:flex;justify-content:space-between;font-size:13px;color:var(--mute);margin:0 6px 8px}
.wake{display:flex;align-items:center;justify-content:space-between;background:var(--card);border-radius:var(--r);padding:12px 14px;box-shadow:var(--shadow);font-size:14px;margin-bottom:10px;gap:10px}
.sw2{flex:0 0 44px;height:26px;border-radius:20px;background:var(--line);position:relative;cursor:pointer;transition:.2s;border:0}
.sw2::after{content:"";position:absolute;left:3px;top:3px;width:20px;height:20px;border-radius:50%;background:#fff;transition:.2s;box-shadow:0 1px 3px rgba(0,0,0,.2)}
.sw2.on{background:var(--green)}.sw2.on::after{left:21px}
.pay{width:100%;min-height:56px;font-size:17px;margin-top:16px;box-shadow:0 6px 18px rgba(47,125,79,.35)}
.aisle{display:flex;align-items:center;gap:12px;padding:12px 14px;border-bottom:1px solid var(--line)}
.aisle:last-child{border-bottom:0}
.aisle .n{width:26px;height:26px;border-radius:8px;background:var(--green-soft);color:var(--green);display:grid;place-items:center;font-weight:700;font-size:13px}
.mv{margin-left:auto;display:flex;gap:4px}
.mv button{width:34px;height:34px;border-radius:10px;border:1px solid var(--line);background:#fff;cursor:pointer}
.note{background:var(--green-soft);color:var(--green);border-radius:14px;padding:12px 14px;font-size:13px;margin:10px 0}
.empty{text-align:center;color:var(--mute);padding:40px 10px;font-size:15px}
.card{background:var(--card);border-radius:var(--r);box-shadow:var(--shadow);padding:14px}
.small{font-size:12px;color:var(--mute);line-height:1.45}
.cmp{display:flex;align-items:center;gap:10px;margin:8px 0;font-size:14px}
.cmp .s{width:110px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.cmp .bar{flex:1;height:12px;background:var(--line);border-radius:8px;overflow:hidden}
.cmp .bar i{display:block;height:100%;background:var(--mute);border-radius:8px}
.cmp.best .bar i{background:var(--green)}.cmp.best .s,.cmp.best b{color:var(--green)}
.cmp b{width:70px;text-align:right}
.months{display:flex;align-items:flex-end;gap:6px;height:120px;margin-top:6px}
.months div{flex:1;max-width:48px;text-align:center;font-size:10px;color:var(--mute)}
.months{justify-content:center}
.months i{display:block;background:var(--green-soft);border-radius:8px 8px 4px 4px;margin-bottom:4px;min-height:2px}
.months div:last-child i{background:var(--green)}
.trend{font-size:12px;font-weight:700;border-radius:8px;padding:3px 7px;white-space:nowrap}
.up{background:#f8e0da;color:var(--red)}.down{background:var(--green-soft);color:var(--green)}.flat{background:var(--line);color:var(--mute)}
.detail{padding:4px 14px 14px;border-bottom:1px solid var(--line);background:#fbfaf5}
.detail table{width:100%;border-collapse:collapse;font-size:13px;margin-top:6px}
.detail td,.detail th{padding:6px 4px;text-align:right}.detail td:first-child,.detail th:first-child{text-align:left}
.detail th{color:var(--mute);font-weight:500;font-size:11px}
.detail tr.best{color:var(--green);font-weight:700}
.leg i{display:inline-block;width:10px;height:10px;border-radius:3px;margin:0 4px 0 10px}
/* Fiches (bas d'écran) */
.sheet{position:absolute;inset:0;background:rgba(31,42,36,.35);display:flex;align-items:flex-end;opacity:0;pointer-events:none;transition:.2s;z-index:8}
.sheet.show{opacity:1;pointer-events:auto}
.sh-card{background:var(--card);width:100%;border-radius:26px 26px 0 0;padding:20px 20px calc(24px + env(safe-area-inset-bottom));transform:translateY(40px);transition:.25s;max-height:90%;overflow-y:auto}
.sheet.show .sh-card{transform:none}
.sh-h{font-size:20px;font-weight:700;margin-bottom:14px}
.sh-card label,.form label{display:block;font-size:13px;color:var(--mute);margin-bottom:12px}
.field{display:flex;align-items:center;border:2px solid var(--line);border-radius:14px;margin-top:5px;padding:0 14px;background:#fff;gap:8px}
.field:focus-within{border-color:var(--green)}
.field input,.field select{flex:1;border:0;outline:none;font-size:17px;padding:11px 0;min-width:0;background:transparent;max-width:none}
.field.money input{font-size:22px;font-weight:700}
.field span{color:var(--mute);font-weight:600}
.sh-info{background:var(--amber-soft);border-radius:12px;padding:10px 12px;font-size:13px;margin-bottom:14px;line-height:1.5}
.sh-btns{display:flex;gap:10px}.sh-btns .btn{flex:1;min-height:50px;font-size:16px}
.recap{display:flex;justify-content:space-between;font-size:13px;color:var(--mute);margin-bottom:8px}
.recap.big{font-size:16px;color:var(--ink);background:var(--green-soft);border-radius:12px;padding:12px 14px;margin-bottom:14px;align-items:center}
.recap.big b{font-size:22px;color:var(--green)}
.keep{display:flex;flex-direction:column;gap:6px;margin-top:8px}
.keep label{margin:0!important;color:var(--ink)!important;font-size:14px!important;display:flex!important;gap:8px;align-items:center}
.keep input,.consent input{width:18px;height:18px;accent-color:var(--green);flex:0 0 auto}
/* Famille / RGPD / admin */
.del{border:1px solid #efc7bd;background:#fff;color:var(--red);border-radius:10px;padding:6px 10px;font-size:13px;cursor:pointer}
.code{font:700 30px ui-monospace,Consolas,monospace;letter-spacing:4px;text-align:center;color:var(--green);background:var(--green-soft);border-radius:14px;padding:12px;margin:8px 0}
.link{text-align:center;word-break:break-all}
.rgpd .row{display:flex;gap:10px;font-size:14px;padding:9px 0;border-bottom:1px solid var(--line)}
.rgpd .row>span{font-size:20px}.rgpd .tg{justify-content:space-between;align-items:center}
.center{text-align:center;margin-top:12px}
a{color:var(--green)}
.stats4{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.stats4 div{background:var(--card);border-radius:var(--r);box-shadow:var(--shadow);padding:12px 14px;font-size:12px;color:var(--mute)}
.stats4 b{display:block;font-size:26px;color:var(--ink)}
.mrow{display:flex;justify-content:space-between;align-items:center;padding:6px 0;font-size:14px;gap:8px}
/* Connexion */
.auth{padding:calc(40px + env(safe-area-inset-top)) 22px 40px;overflow-y:auto;height:100%}
.logo{font-size:56px;text-align:center}
.auth h2{text-align:center;font-size:28px;letter-spacing:-.5px;margin:6px 0 4px}
.auth .tag{text-align:center;color:var(--mute);margin-bottom:22px}
.tabs{display:flex;background:var(--line);border-radius:14px;padding:4px;margin-bottom:18px}
.tabs button{flex:1;border:0;background:none;padding:10px;border-radius:11px;font-weight:600;cursor:pointer;color:var(--mute)}
.tabs button.on{background:var(--card);color:var(--ink);box-shadow:var(--shadow)}
.consent{display:flex!important;gap:10px;align-items:flex-start;color:var(--ink)!important;font-size:13px!important;line-height:1.4}
.err{color:var(--red);font-size:14px;min-height:20px;margin:4px 0}
.linkbtn{background:none;border:0;color:var(--green);text-decoration:underline;cursor:pointer;font-size:13px}
