:root{
    --ink:#0a0a0a;          /* near-black accent */
    --bg:#ffffff;
    --soft:#f4f4f5;         /* light grey surfaces */
    --soft-2:#ececee;
    --line:#e4e4e7;
    --muted:#71717a;
    --muted-2:#a1a1aa;
    --green:#16a34a;
    --red:#dc2626;
    --radius:16px;
    --radius-sm:12px;
    --tabbar-h:64px;
    --topbar-h:54px;
    font-synthesis-weight:none;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent;}
[hidden]{display:none !important;}
html,body{margin:0;padding:0;height:100%;overflow:hidden;}
body{
    font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Open Sans",system-ui,sans-serif;
    background:var(--bg);color:var(--ink);
    -webkit-font-smoothing:antialiased;
    overscroll-behavior-y:none;
}
button{font-family:inherit;cursor:pointer;color:inherit;}
img{max-width:100%;}
.muted{color:var(--muted);}
.xs{font-size:.76rem;} .center{text-align:center;}

/* ===== generic controls ===== */
.lbl{display:block;font-size:.74rem;font-weight:700;color:var(--muted);margin:16px 0 6px;letter-spacing:.01em;}
.inp{width:100%;border:1.5px solid var(--line);border-radius:var(--radius-sm);padding:13px 14px;font-size:1rem;background:var(--bg);color:var(--ink);transition:border-color .15s;}
.inp:focus{outline:none;border-color:var(--ink);}
textarea.inp{resize:vertical;}
.err{color:var(--red);font-weight:700;font-size:.84rem;margin:10px 0 0;}
.hint{color:var(--muted);font-size:.78rem;margin:8px 0 0;}

.btn{border:1.5px solid var(--ink);border-radius:999px;padding:14px 20px;font-weight:800;font-size:.96rem;background:var(--bg);color:var(--ink);transition:transform .08s,opacity .15s;}
.btn:active{transform:scale(.985);}
.btn.primary{background:var(--ink);color:#fff;}
.btn.validate{background:var(--green);border-color:var(--green);color:#fff;}
.btn.danger{background:#fff;border-color:var(--red);color:var(--red);}
.btn.block{display:block;width:100%;}
.btn:disabled{opacity:.5;}

/* ===== LOGIN ===== */
.login{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;padding:24px;background:var(--bg);}
.login-card{width:100%;max-width:380px;text-align:center;}
.login-logo{width:200px;max-width:62%;margin:0 auto 6px;display:block;}
.login-tag{font-size:.8rem;font-weight:700;color:var(--muted);letter-spacing:.18em;text-transform:uppercase;margin:0 0 22px;}
.login form{text-align:left;}
.login .btn{margin-top:22px;}
.login .muted{margin-top:18px;}

/* ===== APP SHELL ===== */
/* Fixed-height shell. The bars overlay the scroller so content passes behind
   their frosted glass; .views is the only thing that scrolls. height:100% (of
   the locked html/body) is stable on iOS — unlike 100dvh. */
.app{position:relative;height:100%;overflow:hidden;}
.topbar{
    position:absolute;top:0;left:0;right:0;z-index:10;
    display:flex;align-items:center;gap:8px;padding:0 10px;
    padding-top:env(safe-area-inset-top);height:calc(var(--topbar-h) + env(safe-area-inset-top));
    background:rgba(255,255,255,.7);
    -webkit-backdrop-filter:saturate(180%) blur(18px);backdrop-filter:saturate(180%) blur(18px);
    border-bottom:1px solid rgba(228,228,231,.7);
}
.topbar-title{flex:1;display:flex;align-items:center;justify-content:center;min-width:0;}
.topbar-logo{height:24px;width:auto;}
.topbar-title.text{font-weight:800;font-size:1.05rem;letter-spacing:-.01em;}
.topbar-spacer{width:38px;flex:0 0 auto;}
.iconbtn{width:38px;height:38px;flex:0 0 auto;display:flex;align-items:center;justify-content:center;background:transparent;border:0;border-radius:10px;}
.iconbtn:active{background:var(--soft);}
.iconbtn svg{width:22px;height:22px;fill:none;stroke:var(--ink);stroke-width:2;stroke-linecap:round;stroke-linejoin:round;}
.iconbtn.fav.on svg{fill:var(--ink);}
/* Keep the back button's slot reserved so the logo stays centered when it's off. */
.topbar .back{visibility:hidden;}
.topbar .back.show{visibility:visible;}

.views{position:absolute;inset:0;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;
    padding:calc(var(--topbar-h) + env(safe-area-inset-top) + 14px) 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 18px);}
/* Home hides the top bar, so the content doesn't need to clear it. */
.app.no-topbar .views{padding-top:calc(env(safe-area-inset-top) + 12px);}
.view-title{font-size:1.5rem;font-weight:900;letter-spacing:-.02em;margin:4px 2px 14px;}
.view-hint{color:var(--muted);font-size:.86rem;margin:-8px 2px 16px;}

/* ===== HOME ===== */
.home{max-width:520px;margin:0 auto;padding:8px 4px 0;text-align:center;}
.home-logo{width:210px;max-width:60%;margin:8px auto 22px;display:block;}
.home-title{font-size:1.7rem;line-height:1.12;font-weight:900;letter-spacing:-.025em;margin:0 0 12px;}
.home-sub{color:var(--muted);font-size:.95rem;line-height:1.5;margin:0 auto 26px;max-width:38ch;}
.steps{list-style:none;margin:0 0 28px;padding:0;text-align:left;position:relative;}
.steps:before{content:"";position:absolute;left:34px;top:24px;bottom:24px;width:2px;background:var(--line);}
.step{display:grid;grid-template-columns:auto auto 1fr;align-items:center;gap:14px;padding:12px 0;position:relative;}
.step-num{width:30px;height:30px;border-radius:50%;background:var(--ink);color:#fff;display:flex;align-items:center;justify-content:center;font-weight:800;font-size:.9rem;z-index:1;}
.step-ico{width:44px;height:44px;border-radius:12px;background:var(--soft);display:flex;align-items:center;justify-content:center;}
.step-ico svg{width:22px;height:22px;fill:none;stroke:var(--ink);stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round;}
.step-txt h3{margin:0 0 2px;font-size:.98rem;font-weight:800;}
.step-txt p{margin:0;color:var(--muted);font-size:.82rem;line-height:1.4;}

/* ===== BRAND GRID ===== */
.brand-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px;}
.brand-card{text-align:left;background:var(--bg);border:1.5px solid var(--line);border-radius:var(--radius);
    padding:14px;display:flex;flex-direction:column;gap:12px;transition:border-color .15s,transform .08s;}
.brand-card:active{transform:scale(.985);}
.bc-logo{height:56px;display:flex;align-items:center;justify-content:center;}
.bc-logo img{max-height:56px;max-width:88%;object-fit:contain;}
.bc-row{display:flex;align-items:center;gap:7px;}
.bc-name{font-weight:850;font-size:1.05rem;letter-spacing:-.01em;line-height:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.bc-count{font-size:.72rem;color:var(--muted);font-weight:700;flex:0 0 auto;}
.bc-arrow{margin-left:auto;display:flex;flex:0 0 auto;}
.bc-arrow svg{width:18px;height:18px;fill:none;stroke:var(--muted-2);stroke-width:2;stroke-linecap:round;stroke-linejoin:round;}

/* ===== KEY LIST / CARDS ===== */
.key-list{display:flex;flex-direction:column;gap:12px;}
.key-card{position:relative;display:flex;align-items:center;gap:14px;background:var(--bg);border:1.5px solid var(--line);border-radius:var(--radius);padding:12px;transition:border-color .15s;}
.key-card:active{transform:scale(.995);}
.kc-thumb{flex:0 0 34%;max-width:140px;aspect-ratio:1;border-radius:12px;background:var(--soft);display:flex;align-items:center;justify-content:center;overflow:hidden;}
.kc-thumb img{width:100%;height:100%;object-fit:contain;padding:6px;}
.kc-thumb svg{width:34px;height:34px;fill:none;stroke:var(--muted-2);stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;}
.kc-main{flex:1;min-width:0;cursor:pointer;display:flex;flex-direction:column;justify-content:center;gap:5px;padding-right:30px;}
.kc-brand{font-size:.66rem;font-weight:800;letter-spacing:.06em;text-transform:uppercase;color:var(--muted-2);}
.kc-name{font-weight:800;font-size:1rem;line-height:1.25;}
.kc-price{font-weight:850;font-size:.92rem;margin-top:2px;}
.kc-price .ttc{display:block;color:var(--muted);font-weight:600;font-size:.78rem;margin-top:1px;}
.kc-fav{position:absolute;top:8px;right:8px;width:38px;height:38px;display:flex;align-items:center;justify-content:center;background:transparent;border:0;border-radius:10px;}
.kc-fav svg{width:21px;height:21px;fill:none;stroke:var(--muted-2);stroke-width:2;stroke-linecap:round;stroke-linejoin:round;}
.kc-fav.on svg{fill:var(--ink);stroke:var(--ink);}

.empty{text-align:center;color:var(--muted-2);font-weight:700;padding:60px 20px;}

/* ===== ORDERS ===== */
.order-list{display:flex;flex-direction:column;gap:10px;}
.order-card{display:flex;align-items:center;gap:12px;background:var(--bg);border:1.5px solid var(--line);border-radius:var(--radius);padding:14px;}
.order-card:active{transform:scale(.995);}
.oc-main{flex:1;min-width:0;}
.oc-num{font-weight:850;font-size:1rem;}
.oc-date{color:var(--muted);font-size:.78rem;margin-top:3px;}
.oc-badges{margin-top:8px;display:flex;flex-wrap:wrap;gap:6px;}
.oc-side{text-align:right;display:flex;flex-direction:column;align-items:flex-end;gap:6px;}
.oc-total{font-weight:850;white-space:nowrap;}
.oc-arrow svg{width:18px;height:18px;fill:none;stroke:var(--muted-2);stroke-width:2;stroke-linecap:round;stroke-linejoin:round;}
.badge{display:inline-block;font-size:.62rem;font-weight:800;text-transform:uppercase;letter-spacing:.04em;padding:4px 9px;border-radius:999px;background:var(--soft-2);color:var(--ink);}
.badge.pay{background:#fee2e2;color:#991b1b;}
.badge.done{background:#dcfce7;color:#166534;}

/* Order detail rows */
.od-meta{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:14px;}
.od-line{display:flex;justify-content:space-between;gap:12px;border:1.5px solid var(--line);border-radius:12px;padding:12px;margin-bottom:8px;}
.od-line .odl-name{font-weight:800;font-size:.92rem;}
.od-line .odl-meta{color:var(--muted);font-size:.78rem;margin-top:3px;}
.od-line .odl-price{font-weight:800;white-space:nowrap;}
.od-total{display:flex;justify-content:space-between;font-weight:900;font-size:1.05rem;margin-top:12px;padding-top:12px;border-top:1px solid var(--line);}

/* ===== SEARCH ===== */
.searchbar{display:flex;align-items:center;gap:10px;background:var(--soft);border-radius:999px;padding:12px 16px;margin-bottom:16px;}
.searchbar svg{width:20px;height:20px;flex:0 0 auto;fill:none;stroke:var(--muted);stroke-width:2;stroke-linecap:round;stroke-linejoin:round;}
.searchbar input{flex:1;border:0;background:transparent;font-size:1rem;color:var(--ink);outline:none;}

/* ===== CART ===== */
.cart-line{display:flex;gap:12px;background:var(--bg);border:1.5px solid var(--line);border-radius:var(--radius);padding:12px;margin-bottom:10px;}
.cl-main{flex:1;min-width:0;}
.cl-name{font-weight:800;font-size:.92rem;}
.cl-meta{color:var(--muted);font-size:.78rem;margin:2px 0 8px;}
.cl-side{display:flex;flex-direction:column;align-items:flex-end;justify-content:space-between;gap:8px;}
.cl-price{font-weight:850;white-space:nowrap;}
.cl-remove{background:none;border:0;color:var(--red);font-weight:700;font-size:.78rem;padding:0;}
.cart-foot{margin-top:8px;}
.cart-total{text-align:right;font-size:1.1rem;font-weight:900;margin:4px 2px 8px;}
.cart-total .ttc{color:var(--muted);font-weight:600;font-size:.9rem;}
.cart-foot .btn{margin-top:16px;}

/* ===== TAB BAR ===== */
.tabbar{position:absolute;left:0;right:0;bottom:0;z-index:10;display:grid;grid-template-columns:repeat(5,1fr);
    background:rgba(255,255,255,.72);
    -webkit-backdrop-filter:saturate(180%) blur(18px);backdrop-filter:saturate(180%) blur(18px);
    border-top:1px solid rgba(228,228,231,.7);padding-bottom:env(safe-area-inset-bottom);}
.tab{height:var(--tabbar-h);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;
    background:transparent;border:0;color:var(--muted-2);font-size:.64rem;font-weight:700;letter-spacing:.01em;}
.tab svg{width:23px;height:23px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;}
.tab.active{color:var(--ink);}
.tab-cart{position:relative;display:flex;}
.cart-badge{position:absolute;top:-6px;right:-9px;min-width:17px;height:17px;border-radius:999px;background:var(--ink);color:#fff;
    font-size:.6rem;font-weight:800;display:flex;align-items:center;justify-content:center;padding:0 4px;}

/* ===== SHEETS (product / confirm) ===== */
.sheet{position:fixed;inset:0;z-index:60;background:rgba(0,0,0,.4);display:flex;align-items:flex-end;
    animation:fade .2s ease;}
.sheet.center{align-items:center;justify-content:center;padding:24px;}
@keyframes fade{from{opacity:0}to{opacity:1}}
.sheet-card{width:100%;max-height:92dvh;max-height:92vh;background:var(--bg);border-radius:22px 22px 0 0;display:flex;flex-direction:column;
    animation:slideup .26s cubic-bezier(.2,.8,.2,1);}
@keyframes slideup{from{transform:translateY(100%)}to{transform:translateY(0)}}
.sheet-head{display:flex;align-items:center;gap:8px;padding:8px 8px 6px;border-bottom:1px solid var(--line);}
.sheet-title{flex:1;text-align:center;font-weight:800;font-size:.92rem;}
.sheet-body{flex:1;overflow-y:auto;padding:16px 18px;}
.sheet-foot{padding:12px 18px;padding-bottom:calc(14px + env(safe-area-inset-bottom));border-top:1px solid var(--line);}

.p-head{display:flex;gap:14px;align-items:center;margin-bottom:6px;}
.p-thumb{width:74px;height:74px;flex:0 0 auto;border-radius:14px;background:var(--soft);display:flex;align-items:center;justify-content:center;overflow:hidden;}
.p-thumb img{width:100%;height:100%;object-fit:contain;padding:6px;}
.p-thumb svg{width:32px;height:32px;fill:none;stroke:var(--muted-2);stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;}
.p-brand{font-size:.68rem;font-weight:800;letter-spacing:.06em;text-transform:uppercase;color:var(--muted-2);}
.p-name{font-size:1.2rem;font-weight:850;letter-spacing:-.01em;margin:2px 0 5px;}
.p-price{font-weight:800;}
.p-price .ttc{color:var(--muted);font-weight:600;}

.stepper{display:flex;align-items:center;gap:10px;}
.step-btn{width:46px;height:46px;border:1.5px solid var(--line);border-radius:12px;background:var(--bg);font-size:1.4rem;font-weight:700;display:flex;align-items:center;justify-content:center;}
.step-btn:active{background:var(--soft);}
.inp.qty{text-align:center;max-width:90px;}

.seg{display:flex;gap:8px;}
.seg-btn{flex:1;background:var(--bg);border:1.5px solid var(--line);border-radius:12px;padding:13px;font-weight:800;color:var(--muted);}
.seg-btn.active{background:var(--ink);color:#fff;border-color:var(--ink);}

.upload-row{display:flex;align-items:center;justify-content:space-between;gap:10px;background:var(--bg);border:1.5px solid var(--line);border-radius:12px;padding:11px 13px;margin-top:8px;}
.ul-label{font-weight:700;font-size:.85rem;}
.ul-btn{display:inline-flex;align-items:center;gap:6px;border:1.5px solid var(--ink);border-radius:999px;padding:7px 13px;font-size:.78rem;font-weight:800;background:var(--bg);}
.ul-btn.ok{background:var(--ink);color:#fff;}
.ul-btn input{display:none;}

/* ===== CONFIRM ===== */
.confirm{background:var(--bg);border-radius:22px;padding:34px 26px;max-width:360px;width:100%;text-align:center;
    animation:slideup .26s cubic-bezier(.2,.8,.2,1);}
.confirm-ico{width:68px;height:68px;border-radius:50%;background:var(--green);display:flex;align-items:center;justify-content:center;margin:0 auto 14px;}
.confirm-ico svg{width:34px;height:34px;fill:none;stroke:#fff;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;}
.confirm h2{margin:0 0 8px;font-size:1.3rem;font-weight:900;}
.confirm .btn{margin-top:22px;}

/* ===== TOAST ===== */
.toast{position:fixed;left:50%;bottom:calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);transform:translateX(-50%);
    background:var(--ink);color:#fff;padding:12px 18px;border-radius:12px;font-weight:700;font-size:.86rem;z-index:80;max-width:88%;text-align:center;
    box-shadow:0 10px 30px rgba(0,0,0,.25);animation:fade .2s ease;}
.toast.error{background:var(--red);}
