/* Layout: POS 2 cột trên máy tính, 1 cột + thanh menu dưới trên điện thoại. Một giao diện sáng. */
:root{--blue:#1f5fe0;--blue-d:#1749b3;--blue-s:#e8f0fe;--ink:#17202e;--mute:#667085;--line:#e3e7ee;--bg:#eef0f4;--card:#fff;--good:#0a7a3d;--bad:#c4281c;--warn:#9a5b00;--warn-s:#fff3d6;--s1:#2a78d6;--s2:#eb6834;color-scheme:light}
*{box-sizing:border-box}
html,body{height:100%}
body{margin:0;background:var(--bg);color:var(--ink);font:14px/1.45 "Be Vietnam Pro",system-ui,sans-serif;font-variant-numeric:tabular-nums}
button,input,select,textarea{font:inherit;color:inherit}
button{cursor:pointer;border:1px solid var(--line);background:var(--card);border-radius:8px;padding:8px 14px;min-height:36px}
button:disabled{opacity:.45;cursor:default}
button.pri{background:var(--blue);border-color:var(--blue);color:#fff;font-weight:600}
button.pri:hover:not(:disabled){background:var(--blue-d)}
button.danger{color:var(--bad)}
button.link{border:0;background:none;color:var(--blue);padding:4px 6px;min-height:28px}
button.ico{padding:4px 10px;border:0;background:none}
input,select,textarea{border:1px solid var(--line);border-radius:8px;padding:7px 10px;background:#fff;min-width:0;max-width:100%}
:focus-visible{outline:2px solid var(--blue);outline-offset:1px}
h1{font-size:19px;margin:0}h2{font-size:15px;margin:0}
.mute{color:var(--mute);font-size:12.5px}.num{text-align:right}.good{color:var(--good)}.bad{color:var(--bad)}.blue{color:var(--blue)}
#app{height:100%;display:flex;flex-direction:column}
header{background:var(--blue);color:#fff;display:flex;align-items:center;gap:8px;padding:8px max(16px,env(safe-area-inset-right,0px)) 8px max(16px,env(safe-area-inset-left,0px));flex-wrap:wrap}
header b{font-size:15px;margin-right:8px}
header nav{display:flex;gap:2px;flex:1;flex-wrap:wrap}
header nav button,header .hbtn{background:transparent;border:0;color:#fff}
header nav button.on{background:#fff;color:var(--blue);font-weight:600}
.sync{border-radius:99px;padding:3px 11px;min-height:28px;font-size:12px;border:0;background:#ffffff2b;color:#fff}
.sync.wait{background:var(--warn-s);color:var(--warn)}
main{flex:1;min-height:0;overflow:auto}
.page{padding:16px max(16px,env(safe-area-inset-right,0px)) 24px max(16px,env(safe-area-inset-left,0px));max-width:1200px;margin:0 auto;display:flex;flex-direction:column;gap:12px}
.bar{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.bar .grow{flex:1;min-width:160px}
.card{background:var(--card);border-radius:12px;padding:14px;min-width:0}
.tw{overflow-x:auto}
table{width:100%;border-collapse:collapse}
th,td{padding:9px 8px;text-align:left;border-bottom:1px solid var(--line)}
th{font-size:12px;color:var(--mute);font-weight:600;white-space:nowrap}
td.num,th.num{text-align:right;white-space:nowrap}
tr.click{cursor:pointer}tr.click:hover{background:var(--blue-s)}
tr.void td{text-decoration:line-through;color:var(--mute)}
.tag{display:inline-block;border-radius:6px;padding:1px 8px;font-size:12px;background:var(--blue-s);color:var(--blue-d);white-space:nowrap}
.tag.warn{background:var(--warn-s);color:var(--warn)}.tag.bad{background:#fde8e6;color:var(--bad)}
/* bán hàng */
.pos{height:100%;display:grid;grid-template-columns:minmax(0,1.35fr) minmax(0,1fr);gap:10px;padding:10px}
.col{display:flex;flex-direction:column;gap:8px;min-height:0;min-width:0}
.scroll{flex:1;overflow:auto;min-height:0}
.tabs{display:flex;gap:4px;overflow-x:auto;flex:none}
.tabs button{white-space:nowrap}.tabs button.on{background:var(--blue);color:#fff;border-color:var(--blue)}
.line{background:var(--card);border-radius:10px;padding:10px 12px;margin-bottom:6px;display:grid;grid-template-columns:minmax(0,1fr) auto;gap:6px}
.line .ctl{grid-column:1/-1;display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.step{display:inline-flex;border:1px solid var(--line);border-radius:8px;overflow:hidden}
.step button{border:0;border-radius:0;width:36px}.step input{border:0;width:52px;text-align:center;border-radius:0;padding:4px}
.ctl label{font-size:12px;color:var(--mute);display:flex;gap:4px;align-items:center}
.ctl input.m{width:92px;text-align:right}
.ctl .tt{margin-left:auto;font-weight:700}
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(170px,1fr));gap:6px;align-content:start}
.prod{display:flex;gap:8px;align-items:center;text-align:left;border:1px solid transparent;padding:8px;min-width:0}
.prod:hover{border-color:var(--blue)}
.prod span:last-child{min-width:0}.prod .nm{display:block;overflow-wrap:anywhere}.prod .pr{color:var(--blue);font-weight:700}
.thumb{width:44px;height:44px;border-radius:8px;flex:none;display:grid;place-items:center;font-weight:700;color:#41506b;object-fit:cover}
.sum{display:flex;justify-content:space-between;align-items:baseline;gap:12px;padding:5px 0}
.sum.big{font-size:19px;font-weight:700}
.empty{padding:36px 16px;text-align:center;color:var(--mute)}
.chips{display:flex;gap:6px;flex-wrap:wrap}.chips button{border-radius:99px}.chips button.on{background:var(--blue-s);border-color:var(--blue);color:var(--blue-d);font-weight:600}
.suggest{position:relative}.suggest .list{position:absolute;left:0;right:0;top:100%;z-index:20;background:#fff;border:1px solid var(--line);border-radius:10px;box-shadow:0 10px 30px #0002;max-height:300px;overflow:auto}
.suggest .list:empty{display:none}.suggest .list button{display:flex;justify-content:space-between;gap:8px;width:100%;border:0;border-radius:0;text-align:left}
.mob{display:none}
/* hộp thoại */
.ov{position:fixed;inset:0;background:#0b122080;z-index:50;display:flex;justify-content:flex-end}
.ov.mid{justify-content:center;align-items:center;padding:16px}
.sheet{background:#fff;width:440px;max-width:100%;height:100%;display:flex;flex-direction:column}
.mid .sheet{height:auto;max-height:100%;border-radius:14px;width:520px}.mid .sheet.wide{width:820px}
.sh,.sf{padding:12px 16px;display:flex;gap:8px;align-items:center;border-bottom:1px solid var(--line)}
.sh h2{flex:1}.sf{border:0;border-top:1px solid var(--line);flex-wrap:wrap}.sf button{flex:1}
.sb{padding:14px 16px;overflow:auto;flex:1;display:flex;flex-direction:column;gap:10px}
.sb>*{flex:none}
.f{display:flex;flex-direction:column;gap:4px;font-size:12.5px;color:var(--mute)}.f>*{font-size:14px;color:var(--ink)}
.two{display:grid;grid-template-columns:1fr 1fr;gap:10px}
#toast{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(76px + env(safe-area-inset-bottom,0px));z-index:90;display:flex;flex-direction:column;gap:6px;width:min(420px,calc(100% - 32px))}
#toast div{background:#17202e;color:#fff;border-radius:10px;padding:10px 14px}#toast div.err{background:var(--bad)}
/* tổng quan */
.kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px}
.kpi b{display:block;font-size:22px;margin-top:2px;overflow-wrap:anywhere}
.cols{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.plot{display:flex;gap:2px;align-items:flex-end;height:170px;border-bottom:1px solid #b9c0cc;margin-top:18px}
.slot{flex:1;height:100%;display:flex;gap:2px;align-items:flex-end;justify-content:center;min-width:0}
.slot i{display:block;width:100%;max-width:22px;background:var(--s1);border-radius:4px 4px 0 0}.slot i.o{background:var(--s2)}
.slot:hover,.slot:focus{background:var(--blue-s)}
.xl{display:flex;gap:2px}.xl span{flex:1;text-align:center;font-size:11px;color:var(--mute);min-width:0;white-space:nowrap}
.key{display:inline-block;width:10px;height:10px;border-radius:3px;background:var(--s1);margin-right:4px}.key.o{background:var(--s2)}
.hbar{height:8px;background:var(--s1);border-radius:0 4px 4px 0;margin-top:3px}
#tip{position:fixed;z-index:80;pointer-events:none;background:#17202e;color:#fff;padding:6px 10px;border-radius:8px;font-size:12px;white-space:pre}
/* phiếu in */
.paper{background:#fff;color:#000;border:1px dashed #aab;margin:0 auto;font-size:12px;line-height:1.4}
.paper.k58{width:48mm;padding:2mm;font-size:11px}
.paper.a5{width:100%;max-width:138mm;padding:5mm}
.paper.a4{width:100%;max-width:190mm;padding:6mm}
.paper h3{margin:2px 0;text-align:center;font-size:14px}.paper .c{text-align:center}
.paper th,.paper td{padding:3px 2px;border-bottom:1px dotted #999;color:#000;font-size:inherit}
.paper .sum{padding:1px 0}
#printarea{display:none}
@media print{#app,#modal,#toast,#tip{display:none!important}#printarea{display:block}body{background:#fff}.paper{border:0;margin:0}}
@media(max-width:820px){
 header nav{display:none}header b{flex:1}
 .pos{display:flex;flex-direction:column;padding:8px}
 .pos>.col{flex:1}
 .desk{display:none!important}.mob{display:flex}
 .bottom{background:#fff;border-top:1px solid var(--line);padding:4px 4px calc(4px + env(safe-area-inset-bottom,0px))}
 .bottom button{flex:1;border:0;font-size:11.5px;padding:6px 2px;color:var(--mute)}
 .bottom button.on{color:var(--blue);font-weight:700;background:var(--blue-s)}
 .kpis{grid-template-columns:repeat(2,minmax(0,1fr))}.cols,.two{grid-template-columns:1fr}
 .grid{grid-template-columns:1fr}
 .ov .sheet,.ov.mid .sheet{width:100%}
 .xl span:nth-child(even){visibility:hidden}
}
@media(prefers-reduced-motion:reduce){*{transition:none!important}}
header select{color:var(--ink);padding:4px 6px;font-size:12.5px}
#toast{bottom:auto;top:calc(60px + env(safe-area-inset-top,0px))}
#toast{pointer-events:none}
.sb th,.sb td{padding-left:4px;padding-right:4px}
@media(max-width:820px){header{flex-wrap:nowrap;gap:6px}header b{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}header .hbtn{padding:4px;font-size:12px;white-space:nowrap}.sync{white-space:nowrap}
 .sb table{font-size:11.5px}.sb td small{font-size:10px}}
@media(max-width:820px){header .sync{margin-left:auto}}
.ic{width:18px;height:18px;flex:none;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
header nav button{display:inline-flex;align-items:center;gap:6px;padding:7px 10px;white-space:nowrap}
.prod{position:relative}
.prod.in{background:var(--blue-s);border:2px solid var(--blue);padding:7px}
.badge{position:absolute;top:0;right:0;background:var(--blue);color:#fff;font-style:normal;font-weight:700;font-size:12px;border-radius:0 6px 0 8px;padding:1px 8px}
.prod.flash{animation:pick .6s ease-out}
.cartbtn{justify-content:space-between;min-height:48px}.cartbtn.flash{animation:bump .4s ease-out}
@keyframes pick{0%{background:var(--blue);transform:scale(.95)}100%{transform:scale(1)}}
@keyframes bump{50%{transform:scale(1.04)}}
button.mini{padding:3px 10px;min-height:30px;white-space:nowrap;color:var(--blue);border-color:var(--blue)}
.pay{display:flex;flex-direction:column;gap:8px;margin-top:8px}
.paybar{background:#fff;border-radius:12px;padding:8px 12px;flex:none}.paybar .grow{min-width:0}
.qr{border:1px dashed var(--line);text-align:center}.qr img{width:180px}
.logo{max-height:48px}.bankinfo img{width:30mm}
.stack{display:flex;flex-direction:column;gap:10px}
.chk{display:flex;gap:8px;align-items:center;min-height:30px}.chk input{width:18px;height:18px;flex:none}
.pick{height:64px;border:1px solid var(--line);border-radius:8px}
.savebar{position:sticky;bottom:0;background:var(--bg);padding:8px 0;display:flex;justify-content:flex-end}
.kpis.totals{margin:10px 0}.totals .card{border:1px solid var(--line)}.totals b{font-size:18px}
.flow{max-height:420px;overflow:auto}.flow th{position:sticky;top:0;background:#fff}
@media(min-width:821px){.cartbtn.mob{display:none}}
@media(min-width:821px) and (max-width:1280px){header b{display:none}header nav button{flex-direction:column;gap:2px;font-size:11.5px;padding:4px 7px}}
@media(max-width:820px){
 .pos.phonecart{display:flex}
 .pos>.col.desk{display:none!important}
 .phonecart>.col.cart{display:flex!important;flex:1}
 .bottom button{display:flex;flex-direction:column;align-items:center;gap:2px}
 .bottom .ic{width:21px;height:21px}
 .kpis .kpi b{font-size:18px}
 .flow table{font-size:12px}
 .savebar button{width:100%}
}
.mob-inline,.editline{display:none}
@media(max-width:820px){
 .wide-only{display:none}.mob-inline{display:inline}
 .editline{display:inline-block}
 .ctl label.price{display:none}.ctl label.price.open{display:flex}
 .line{padding:8px 10px;gap:2px}
 .paybar .chips{flex-wrap:nowrap;overflow-x:auto;margin-bottom:8px}.paybar .chips button{white-space:nowrap;padding:5px 11px}
 .paybar .sum.big{padding:0 0 6px}
 .flow th:first-child,.flow td:first-child{position:sticky;left:0;background:#fff}.flow th:first-child{z-index:1}
}
.sync.err{background:#fde8e6;color:var(--bad)}
header .user{max-width:130px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#login:not(:empty){position:fixed;inset:0;z-index:40;background:var(--bg);display:grid;place-items:center;padding:16px;overflow:auto}
.login{width:min(360px,100%)}
@media(max-width:820px){header .user{margin-left:0}}
