:root{--navy:#0f304d;--blue:#205b85;--bg:#f4f7fb;--card:#fff;--line:#dfe7ef;--text:#132238;--muted:#66758a;--danger:#b42318;--ok:#067647}*{box-sizing:border-box}body{margin:0;font:14px system-ui,-apple-system,Segoe UI,sans-serif;color:var(--text);background:var(--bg)}button,input,select,textarea{font:inherit}.hidden{display:none!important}.login-view{min-height:100vh;display:grid;place-items:center;background:linear-gradient(135deg,#eaf3fb,#fff)}.login-card{width:min(420px,92vw);background:#fff;padding:30px;border:1px solid var(--line);border-radius:16px;box-shadow:0 18px 50px #18324b22}.login-card h1{margin:0 0 6px}.login-card p{color:var(--muted);margin:0 0 22px}label{display:grid;gap:6px;margin:12px 0;font-weight:600}input,select,textarea{width:100%;padding:10px 12px;border:1px solid #cfd9e5;border-radius:9px;background:#fff}textarea{min-height:84px;resize:vertical}button{border:0;border-radius:9px;padding:10px 14px;cursor:pointer}.primary{background:var(--blue);color:#fff;font-weight:700}.secondary{background:#eaf0f6}.danger{background:#fee4e2;color:var(--danger)}.app{display:grid;grid-template-columns:222px 1fr;min-height:100vh}.sidebar{background:var(--navy);color:#fff;padding:18px 8px;display:flex;flex-direction:column}.brand{font-size:19px;font-weight:800;padding:6px 8px 16px}.sidebar nav{display:grid;gap:4px}.sidebar nav button,.logout{background:transparent;color:#fff;text-align:left}.sidebar nav button.active,.sidebar nav button:hover{background:var(--blue)}.logout{margin-top:auto}main{min-width:0}header{height:62px;background:#fff;border-bottom:1px solid var(--line);display:flex;justify-content:space-between;align-items:center;padding:0 22px}header small{display:block;color:var(--muted);margin-top:3px}#content{padding:22px}.page-head{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:16px}.page-head h2{margin:0}.actions{display:flex;gap:8px;flex-wrap:wrap}.cards{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px}.card{background:var(--card);border:1px solid var(--line);border-radius:14px;padding:16px;box-shadow:0 3px 12px #1c36520a}.metric span{color:var(--muted)}.metric strong{display:block;font-size:25px;margin-top:8px}.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:14px}.table-wrap{overflow:auto;background:#fff;border:1px solid var(--line);border-radius:14px}table{width:100%;border-collapse:collapse}th,td{padding:11px 12px;border-bottom:1px solid var(--line);text-align:left;white-space:nowrap}th{font-size:12px;color:var(--muted);background:#fbfcfe;text-transform:uppercase}tr.clickable:hover{background:#f3f8fc}.toolbar{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:12px}.toolbar input,.toolbar select{width:auto;min-width:160px}.pill{display:inline-block;padding:3px 8px;border-radius:999px;background:#eef3f8}.pill.ok{background:#dcfae6;color:var(--ok)}.pill.bad{background:#fee4e2;color:var(--danger)}.muted{color:var(--muted)}.right{text-align:right}.modal-backdrop{position:fixed;inset:0;background:#0b1f33a8;display:grid;place-items:center;padding:18px;z-index:20}.modal{background:#fff;width:min(760px,96vw);max-height:92vh;overflow:auto;border-radius:15px;padding:20px}.modal.wide{width:min(1050px,97vw)}.modal-head{display:flex;justify-content:space-between;align-items:center}.modal-head h3{margin:0}.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}.form-grid .full{grid-column:1/-1}.sale-layout{display:grid;grid-template-columns:1.35fr .65fr;gap:14px}.item-row{display:grid;grid-template-columns:2fr .7fr .9fr .8fr auto;gap:8px;align-items:end;margin-bottom:8px}.summary-row{display:flex;justify-content:space-between;padding:7px 0;border-bottom:1px dashed var(--line)}.message{margin-top:12px;color:var(--danger)}#toastRoot{position:fixed;right:18px;bottom:18px;z-index:40}.toast{background:#102f4b;color:#fff;padding:11px 14px;border-radius:9px;margin-top:8px;box-shadow:0 8px 25px #0003}.empty{padding:28px;text-align:center;color:var(--muted)}@media(max-width:900px){.app{grid-template-columns:1fr}.sidebar{position:sticky;top:0;z-index:10;flex-direction:row;overflow:auto;align-items:center;padding:8px}.brand{display:none}.sidebar nav{display:flex}.sidebar nav button{white-space:nowrap}.logout{margin:0 0 0 auto}.cards{grid-template-columns:repeat(2,1fr)}.grid-2,.sale-layout{grid-template-columns:1fr}header{display:none}#content{padding:12px}.form-grid{grid-template-columns:1fr}.form-grid .full{grid-column:auto}.item-row{grid-template-columns:1fr 1fr}.item-row>*:first-child{grid-column:1/-1}}@media(max-width:520px){.cards{grid-template-columns:1fr}.page-head{align-items:flex-start;flex-direction:column}}

.metric small{display:block;color:var(--muted);margin-top:7px}.quick-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;margin:14px 0}.quick-grid button{background:#fff;border:1px solid var(--line);text-align:left;padding:15px}.quick-grid button:hover{border-color:var(--blue);box-shadow:0 5px 15px #17334c12}.quick-grid b,.quick-grid span{display:block}.quick-grid span{color:var(--muted);margin-top:5px;font-size:12px}.profile-actions{display:flex;gap:8px;margin:14px 0}.customer-info{display:grid;grid-template-columns:repeat(2,1fr);gap:10px;margin:14px 0}.customer-info>div{background:#f7f9fc;border:1px solid var(--line);padding:12px;border-radius:10px}.customer-info b,.customer-info span{display:block}.customer-info span{margin-top:4px}.sale-customer-row{display:grid;grid-template-columns:2fr 1fr;gap:12px}.customer-snapshot{background:#f5f9fd;border:1px solid var(--line);border-radius:10px;padding:12px;margin:8px 0 14px;line-height:1.6}.product-shortcuts{display:flex;gap:7px;flex-wrap:wrap;margin-bottom:12px}.product-shortcuts button{background:#edf4fa;color:#174c72;padding:8px 10px}.sticky-summary{align-self:start;position:sticky;top:76px}.split-actions{display:grid;grid-template-columns:1fr 1fr;gap:7px}.summary-row.total{font-size:16px;border-top:2px solid var(--line);margin-top:5px;padding-top:11px}.text-danger{color:var(--danger)}button:disabled{opacity:.6;cursor:not-allowed}.report-filter label{margin:0}.report-filter{align-items:end}
@media(max-width:900px){.quick-grid{grid-template-columns:repeat(2,1fr)}.sticky-summary{position:static}.sale-customer-row{grid-template-columns:1fr}.customer-info{grid-template-columns:1fr}}
@media(max-width:520px){.quick-grid{grid-template-columns:1fr}.profile-actions{flex-direction:column}.split-actions{grid-template-columns:1fr}}

.money-input{font-variant-numeric:tabular-nums;font-weight:600}.field-help{display:block;margin-top:6px;color:var(--muted);font-weight:400;line-height:1.35}
.nav-sale-fast{background:#0f6fa4!important;color:#fff!important;font-weight:800;margin:4px 6px 8px;width:calc(100% - 12px)!important}
.floating-sale{position:fixed;right:22px;bottom:22px;z-index:80;border:0;border-radius:999px;padding:14px 20px;background:#0f6fa4;color:#fff;font-weight:800;box-shadow:0 10px 28px rgba(15,111,164,.35);cursor:pointer}
.invoice-preview{background:#fff;border:1px solid var(--line);border-radius:14px;padding:24px;overflow:auto}.invoice-preview .invoice{max-width:760px;margin:auto}.invoice-preview h1{text-align:center;margin:0}.invoice-preview .sub{text-align:center;margin:6px 0 24px;font-weight:800}.invoice-preview .info{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:18px 0}.invoice-preview table{width:100%;border-collapse:collapse}.invoice-preview th,.invoice-preview td{border-bottom:1px solid #ddd;padding:10px;text-align:left}.invoice-preview .right{text-align:right}.invoice-preview .total{font-size:18px;font-weight:800}.invoice-preview .sign{display:grid;grid-template-columns:1fr 1fr;text-align:center;margin-top:48px}.invoice-preview .no-print{display:none}
@media(max-width:760px){.floating-sale{right:14px;bottom:14px}.invoice-preview{padding:12px}.invoice-preview .info{grid-template-columns:1fr}.invoice-preview table{font-size:12px}.invoice-preview th,.invoice-preview td{padding:7px}}
hr{border:0;border-top:1px solid var(--line);margin:18px 0}.summary-section{margin:16px 0 6px;padding:8px 10px;background:#eef4f8;border-radius:8px;font-size:12px;letter-spacing:.04em}.metric-alert{border-color:#ef9a9a;background:#fff7f7}.row-warning{background:#fff8f0}.debt-alert{margin:12px 0;padding:12px 14px;border-radius:10px}.debt-alert.danger{background:#fff0f0;border:1px solid #efb2b2;color:#9b1c1c}.debt-alert.info{background:#eef6ff;border:1px solid #b8d8f5}.hidden{display:none!important}
.health-hero{display:grid;grid-template-columns:.65fr 1.35fr;gap:18px;margin-bottom:14px;padding:20px;border-radius:16px;background:linear-gradient(135deg,#0f304d,#205b85);color:#fff}.health-hero span,.health-hero strong,.health-hero b{display:block}.health-hero strong{font-size:42px;margin:5px 0}.health-notes{display:grid;gap:8px;align-content:center}.health-notes p{margin:0;padding:9px 12px;border-radius:9px;background:#ffffff18}.health-notes .good:before{content:'✓ ';font-weight:900}.health-notes .warn:before{content:'⚠ ';font-weight:900}.dashboard-grid{margin:14px 0}.bar-chart{height:230px;display:flex;align-items:stretch;gap:5px;padding-top:28px}.bar-col{min-width:0;flex:1;display:grid;grid-template-rows:20px 1fr 22px;text-align:center}.bar-value{font-size:9px;color:var(--muted);overflow:hidden}.bar-track{height:100%;display:flex;align-items:flex-end;background:#eef3f8;border-radius:5px 5px 0 0;overflow:hidden}.bar-fill{width:100%;background:linear-gradient(180deg,#3a8cc1,#205b85);border-radius:5px 5px 0 0;min-height:0}.bar-label{font-size:10px;color:var(--muted);padding-top:5px}.cash-split{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}.cash-split>div{background:#f6f9fc;border:1px solid var(--line);padding:12px;border-radius:10px}.cash-split span,.cash-split strong{display:block}.cash-split span{color:var(--muted);font-size:12px}.cash-split strong{margin-top:5px;font-size:17px}.invoice-preview .payment-box{margin-top:16px;border:2px solid var(--text);border-radius:8px;padding:12px}.invoice-preview .payment-row{display:flex;justify-content:space-between;gap:16px;padding:7px 0;border-bottom:1px dashed var(--line)}.invoice-preview .payment-row:last-child{border:0}.invoice-preview .grand{font-size:18px;font-weight:800}@media(max-width:760px){.health-hero{grid-template-columns:1fr}.cash-split{grid-template-columns:1fr}.bar-chart{height:190px}}
/* Stable 1.2 - CEO Dashboard */
.dashboard-kpis{grid-template-columns:repeat(4,minmax(0,1fr))}.metric-delta{display:block;margin:4px 0 6px;font-weight:700}.good-text{color:#149447}.bad-text{color:#d33b32}.health-scale{height:7px;background:rgba(255,255,255,.18);border-radius:999px;margin-top:12px;overflow:hidden;max-width:250px}.health-scale i{display:block;height:100%;background:#fff;border-radius:999px}.card-title-row{display:flex;align-items:center;justify-content:space-between;gap:12px}.insight-list{display:grid;gap:10px;margin-top:14px}.insight{display:flex;gap:10px;align-items:flex-start;padding:11px 12px;border-radius:10px;background:#f3f7fb}.insight>span{display:grid;place-items:center;flex:0 0 24px;height:24px;border-radius:50%;font-weight:800;background:#dfeaf5}.insight p{margin:2px 0 0;line-height:1.45}.insight.good{background:#effaf3}.insight.good>span{background:#ccefd8;color:#13743a}.insight.bad{background:#fff3f1}.insight.bad>span{background:#ffd8d3;color:#b42d24}.rank-list{display:grid;margin-top:10px}.rank-list>div{display:flex;align-items:center;gap:10px;padding:11px 0;border-bottom:1px solid #e5edf4}.rank-list>div:last-child{border-bottom:0}.rank-list .rank{display:grid;place-items:center;width:28px;height:28px;border-radius:8px;background:#eaf2f9;font-weight:800}.rank-list p{display:flex;flex-direction:column;margin:0;flex:1}.rank-list small{color:#708397;margin-top:2px}.attention-card{margin-top:14px;border-left:4px solid #e7a928}.inactive-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin-top:12px}.inactive-grid>div{display:flex;flex-direction:column;padding:12px;background:#fff8e8;border-radius:10px}.inactive-grid span{font-size:12px;color:#8a671d;margin-top:4px}@media(max-width:1100px){.dashboard-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}.inactive-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}@media(max-width:700px){.dashboard-kpis,.inactive-grid{grid-template-columns:1fr}.card-title-row{align-items:flex-start;flex-direction:column}}

/* Stable 1.4.2 - Invoice preview layout fix */
.invoice-preview{padding:16px;container-type:inline-size}
.invoice-preview .invoice{max-width:840px;width:100%;margin:0 auto}
.invoice-preview .invoice h1.title{margin:0 0 14px;text-align:center}
.invoice-preview .invoice table.items{border-collapse:separate;border-spacing:0}
.invoice-preview .invoice .sign{margin-top:22px}
@container (max-width:760px){
  .invoice-preview .invoice .header{grid-template-columns:120px minmax(180px,1fr) 220px;gap:8px;padding:10px 12px}
  .invoice-preview .invoice .logo{width:115px;height:78px}
  .invoice-preview .invoice .brand .over{font-size:17px}
  .invoice-preview .invoice .brand .name{font-size:25px}
  .invoice-preview .invoice .brand .slogan{font-size:11px;margin-top:6px}
  .invoice-preview .invoice .contacts{font-size:10.5px;line-height:1.35}
  .invoice-preview .invoice .title{font-size:22px}
  .invoice-preview .invoice .bottom{grid-template-columns:1fr 1fr}
  .invoice-preview .invoice .bottom .panel:last-child{grid-column:1/-1;min-height:auto}
}
@container (max-width:580px){
  .invoice-preview .invoice .header{grid-template-columns:1fr;text-align:center}
  .invoice-preview .invoice .logo{margin:auto;width:150px;height:92px}
  .invoice-preview .invoice .brand{border-right:0;padding-right:0}
  .invoice-preview .invoice .contacts{text-align:left}
  .invoice-preview .invoice .meta,.invoice-preview .invoice .bottle,.invoice-preview .invoice .bottom{grid-template-columns:1fr}
  .invoice-preview .invoice .bottom .panel:last-child{grid-column:auto}
}
/* Stable 1.6 - Mobile/PWA */
.menu-btn,.menu-close{display:none}.mobile-bottom-nav{display:none}.member-form{display:grid;grid-template-columns:2fr 1fr auto;gap:10px;align-items:end}.member-form label{margin:0}.member-form button{height:42px}
@media(max-width:900px){
 body{padding-bottom:68px}.app{display:block}.sidebar{position:fixed;left:0;top:0;bottom:0;width:min(310px,86vw);z-index:120;display:flex;flex-direction:column;align-items:stretch;overflow-y:auto;padding:18px 10px;transform:translateX(-105%);transition:transform .2s ease;box-shadow:12px 0 30px #071a2b40}.menu-open .sidebar{transform:translateX(0)}.menu-open:after{content:'';position:fixed;inset:0;background:#06192b88;z-index:110}.brand{display:block;padding-right:42px}.menu-close{display:block;position:absolute;right:10px;top:10px;background:#ffffff18;color:#fff}.sidebar nav{display:grid}.sidebar nav button{width:100%;white-space:normal}.logout{margin-top:auto}
 header{display:flex;height:58px;padding:0 12px;position:sticky;top:0;z-index:60}.menu-btn{display:block;background:#eaf0f6;font-size:20px;padding:7px 11px;margin-right:10px}#today{font-size:12px}#content{padding:12px 10px 18px}.page-head{margin-bottom:12px}.page-head h2{font-size:20px}.actions button{padding:9px 11px}.floating-sale{display:none!important}.mobile-bottom-nav{position:fixed;left:0;right:0;bottom:0;height:62px;z-index:100;background:#fff;border-top:1px solid var(--line);display:flex;align-items:stretch;justify-content:space-around;box-shadow:0 -6px 18px #17334c12}.mobile-bottom-nav button{flex:1;background:#fff;border-radius:0;padding:7px 3px;font-size:11px;color:#53677b}.mobile-bottom-nav button.active{color:#0f6fa4;font-weight:800;background:#edf6fb}.mobile-bottom-nav button:nth-child(2){color:#fff;background:#0f6fa4;font-size:12px;font-weight:800;margin:5px;border-radius:10px}
 .modal-backdrop{padding:0;align-items:end}.modal,.modal.wide{width:100%;max-height:94vh;border-radius:18px 18px 0 0;padding:15px}.table-wrap{border-radius:10px}.table-wrap table{min-width:680px}.cards{gap:9px}.card{padding:13px}.metric strong{font-size:21px}.toolbar{display:grid;grid-template-columns:1fr 1fr}.toolbar input,.toolbar select{width:100%;min-width:0}.sale-layout{display:block}.sale-layout>.card{margin-bottom:10px}.sticky-summary{position:static}.item-row{grid-template-columns:1fr 1fr}.item-row>*:first-child{grid-column:1/-1}.member-form{grid-template-columns:1fr}.health-hero{padding:15px}.health-hero strong{font-size:34px}
}
@media(max-width:520px){header #businessName{font-size:13px}header small{font-size:10px}.cards,.dashboard-kpis{grid-template-columns:1fr}.toolbar{grid-template-columns:1fr}.quick-grid{grid-template-columns:1fr 1fr}.sale-customer-row,.form-grid{grid-template-columns:1fr}.product-shortcuts{overflow-x:auto;flex-wrap:nowrap;padding-bottom:5px}.product-shortcuts button{white-space:nowrap}.invoice-preview{padding:0;border:0;background:transparent;overflow:visible}.invoice-preview .invoice{min-width:0;width:100%;transform:none}.page-head{flex-direction:column;align-items:stretch}.actions{display:grid;grid-template-columns:1fr 1fr}.actions button{width:100%}}

/* Stable 1.7 - Mobile sales workflow */
.header-status{display:flex;align-items:center;gap:12px}.online-status{display:inline-flex;align-items:center;gap:6px;padding:4px 9px;border-radius:999px;background:#e8f7ed;color:#087443;font-size:11px;font-weight:800}.online-status:before{content:'';width:7px;height:7px;border-radius:50%;background:#18a957}.online-status.offline{background:#fff0ee;color:#b42318}.online-status.offline:before{background:#d92d20}.mobile-step-title{display:flex;align-items:center;gap:10px;margin:2px 0 12px}.mobile-step-title>span{display:grid;place-items:center;width:30px;height:30px;border-radius:50%;background:#0f6fa4;color:#fff;font-weight:900}.mobile-step-title b,.mobile-step-title small{display:block}.mobile-step-title small{margin-top:2px;color:var(--muted);font-weight:400}.customer-search-label{margin-bottom:4px}.customer-search-label input{background:#f7fbfe;border-color:#9fc8e2}.mobile-payment-presets{display:grid;grid-template-columns:repeat(3,1fr);gap:7px;margin-bottom:12px}.mobile-payment-presets button{background:#eef6fb;color:#0f5f96;font-weight:800;border:1px solid #cfe4f1}.qty-control{display:grid;grid-template-columns:38px minmax(60px,1fr) 38px;gap:5px}.qty-control button{padding:8px 4px;background:#eaf3f9;color:#0f5f96;font-size:18px;font-weight:900}.qty-control input{text-align:center}.mobile-sale-bar{display:none}
@media(max-width:900px){.header-status{margin-left:auto}.online-status{font-size:10px;padding:3px 7px}.mobile-sale-form{padding-bottom:78px}.mobile-sale-bar{position:fixed;left:0;right:0;bottom:62px;z-index:105;background:#0f304d;color:#fff;display:flex;align-items:center;justify-content:space-between;padding:9px 12px;box-shadow:0 -7px 20px #071a2b38}.mobile-sale-bar.hidden{display:none!important}.mobile-sale-bar small,.mobile-sale-bar strong{display:block}.mobile-sale-bar small{opacity:.75}.mobile-sale-bar strong{font-size:18px}.mobile-sale-bar button{background:#fff;color:#0f5f96;font-weight:900;min-width:130px}.mobile-payment-presets{grid-template-columns:1fr}.item-row{padding:12px;border:1px solid var(--line);border-radius:12px;background:#fbfdff;margin-bottom:10px}.item-row>.danger{align-self:end;height:42px}.customer-snapshot{font-size:13px}.product-shortcuts{scroll-snap-type:x mandatory}.product-shortcuts button{scroll-snap-align:start;min-height:42px}.mobile-step-title{margin-top:0}}
@media(max-width:520px){input,select,textarea,button{min-height:44px;font-size:16px}.login-card{padding:22px 18px}.mobile-bottom-nav{height:66px}.mobile-sale-bar{bottom:66px}.item-row{grid-template-columns:1fr 1fr}.item-row>label:first-child{grid-column:1/-1}.item-row>label:nth-child(3),.item-row>label:nth-child(4){grid-column:auto}.item-row>.danger{grid-column:1/-1;background:#fff1f0}.sale-customer-row{gap:6px}.mobile-payment-presets button{font-size:14px}.quick-grid button{min-height:72px}.header-status #today{display:none}}


/* Stable 1.7.1 - Invoice/mobile hardening */
.invoice-preview>.npinv{width:100%;max-width:820px}
@media(max-width:900px){.modal.wide .invoice-preview{margin:0 -4px}.modal.wide .profile-actions{position:sticky;top:-15px;z-index:5;background:#fff;padding:8px 0}.npinv{box-shadow:none!important}.npinv-brandbar{align-items:start!important}.npinv-brand,.npinv-contact,.npinv-meta>div,.npinv-row span,.npinv-row strong{min-width:0;overflow-wrap:anywhere}.npinv-table{display:table;table-layout:auto}.npinv-table th,.npinv-table td{white-space:normal!important}.npinv-table th:nth-child(1),.npinv-table td:nth-child(1){width:42px}.npinv-table th:nth-child(3),.npinv-table td:nth-child(3){width:64px}.npinv-table th:nth-child(4),.npinv-table td:nth-child(4){width:52px}}
@media(max-width:520px){.npinv-topline{height:8px!important}.npinv-brandbar{padding:10px!important}.npinv-logo{width:118px!important;height:68px!important}.npinv-brand-top{font-size:16px!important}.npinv-brand-name{font-size:24px!important}.npinv-brand-slogan{font-size:12px!important}.npinv-contact{font-size:11px!important;line-height:1.35!important}.npinv-body{padding:10px 8px 12px!important}.npinv-title{font-size:19px!important;margin-bottom:10px!important}.npinv-title:after{width:150px!important}.npinv-meta{gap:6px!important;padding:9px!important;margin-bottom:10px!important}.npinv-meta div{font-size:12.5px!important}.npinv-table th{font-size:10px!important;padding:7px 3px!important}.npinv-table td{font-size:11.5px!important;padding:7px 4px!important}.npinv-table th:nth-child(1),.npinv-table td:nth-child(1){display:none}.npinv-table th:nth-child(3),.npinv-table td:nth-child(3){display:none}.npinv-row{gap:8px!important;padding:8px 9px!important}.npinv-row strong{max-width:52%}.npinv-row.total{align-items:center!important}.npinv-row.total span{font-size:13px}.npinv-row.total strong{font-size:17px!important}.npinv-qrbox{padding:9px!important}.npinv-qr{width:150px!important;height:150px!important}.npinv-box{min-height:0!important}.npinv-sign{padding-bottom:22px!important}.npinv-thanks{font-size:12.5px!important;padding:10px!important}.npinv-thanks strong{font-size:14px!important}.npinv-footer{grid-template-columns:1fr!important;font-size:10px!important}.profile-actions{display:grid!important;grid-template-columns:1fr 1fr}.profile-actions button{width:100%}}

/* Stable 1.7.3 - Mobile-first sales entry inspired by real field workflow */
@media (max-width: 900px){
  body.mobile-sales-open{background:#f4f7fb}
  .mobile-sale-form{display:block!important;padding-bottom:150px}
  .mobile-sale-form>.card{border:0;border-radius:0;box-shadow:none;margin:0 -10px 10px;padding:14px 12px;background:#fff}
  .mobile-sale-form .mobile-step-title{position:sticky;top:58px;z-index:18;background:#fff;margin:-14px -12px 12px;padding:10px 12px;border-bottom:1px solid var(--line)}
  .mobile-sale-form .mobile-step-title>span{width:28px;height:28px;font-size:13px}
  .mobile-sale-form .customer-search-label input{height:48px;border-radius:14px;padding-left:14px;background:#f7f9fc}
  .mobile-sale-form .sale-customer-row{display:grid;grid-template-columns:1fr 118px;gap:8px}
  .mobile-sale-form .sale-customer-row select,.mobile-sale-form .sale-customer-row input{height:46px;border-radius:12px}
  .mobile-sale-form .customer-snapshot{background:#eef7fd;border:1px solid #cfe7f7;border-radius:12px;padding:10px 12px;color:#154d70}
  .mobile-sale-form .product-shortcuts{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(145px,1fr);gap:8px;overflow-x:auto;padding:2px 0 10px;margin:0 -2px;scrollbar-width:none}
  .mobile-sale-form .product-shortcuts::-webkit-scrollbar{display:none}
  .mobile-sale-form .product-shortcuts button{min-height:58px;border-radius:14px;background:#f5f9fc;border:1px solid #d9e6ef;color:#173c57;text-align:left;padding:10px 12px;white-space:normal;line-height:1.25}
  .mobile-sale-form .product-shortcuts button:active{transform:scale(.98);background:#e9f5fc}
  .mobile-sale-form #saleItems{display:grid;gap:10px}
  .mobile-sale-form .item-row{display:grid!important;grid-template-columns:1fr 110px!important;gap:8px!important;padding:12px!important;border-radius:14px!important;background:#fff!important;box-shadow:0 4px 14px #153b5512}
  .mobile-sale-form .item-row>label:first-child{grid-column:1/-1}
  .mobile-sale-form .item-row>label:nth-child(2){grid-column:1/2}
  .mobile-sale-form .item-row>label:nth-child(3){grid-column:2/3}
  .mobile-sale-form .item-row>label:nth-child(4){grid-column:1/2}
  .mobile-sale-form .item-row>.danger{grid-column:2/3;align-self:end;height:46px}
  .mobile-sale-form .item-row label{font-size:12px;color:#65788a}
  .mobile-sale-form .item-row input,.mobile-sale-form .item-row select{height:46px;border-radius:11px;font-size:16px;background:#fff}
  .mobile-sale-form .qty-control{grid-template-columns:44px 1fr 44px}
  .mobile-sale-form .qty-control button{height:46px;border-radius:10px;font-size:21px}
  .mobile-sale-form textarea{min-height:72px;border-radius:12px}
  .mobile-sale-form .sticky-summary{position:static!important}
  .mobile-sale-form .mobile-payment-presets{display:grid;grid-template-columns:repeat(3,1fr);gap:6px;position:sticky;top:106px;z-index:17;background:#fff;padding:8px 0}
  .mobile-sale-form .mobile-payment-presets button{min-height:44px;border-radius:12px;font-size:12px;padding:7px 5px}
  .mobile-sale-form h3{font-size:15px;margin:16px 0 8px;padding-top:4px}
  .mobile-sale-form hr{margin:16px 0;border:0;border-top:1px solid #e7edf3}
  .mobile-sale-form .split-actions{display:none}
  .mobile-sale-form #saveSaleBtn{display:none}
  .mobile-sale-bar{height:74px;padding:9px 12px calc(9px + env(safe-area-inset-bottom));background:#fff;color:#173c57;border-top:1px solid #dce6ee;box-shadow:0 -8px 22px #0c2c4220}
  .mobile-sale-bar>div{min-width:0}
  .mobile-sale-bar small{color:#6f8191;opacity:1}
  .mobile-sale-bar strong{font-size:20px;color:#0b4168}
  .mobile-sale-bar button{min-width:145px;min-height:50px;background:#0877c9;color:#fff;border-radius:14px;font-size:15px}
  .mobile-bottom-nav{z-index:110}
}
@media (max-width:520px){
  .mobile-sale-form .sale-customer-row{grid-template-columns:1fr}
  .mobile-sale-form .mobile-payment-presets{grid-template-columns:repeat(3,1fr)}
  .mobile-sale-form .mobile-payment-presets button{font-size:11px}
  .mobile-sale-form .item-row{grid-template-columns:1fr 104px!important}
  .mobile-sale-form>.card{margin-left:-10px;margin-right:-10px}
}


/* Stable 1.7.5 - Mobile navigation and usability overhaul */
.mobile-menu-backdrop{display:none}
@media(max-width:900px){
  body{padding-bottom:76px;overflow-x:hidden}
  #content{padding:10px 10px 22px}
  header{height:56px;padding:0 10px;background:#fff;box-shadow:0 2px 10px #17334c0d}
  header>div:first-of-type{min-width:0}
  #businessName{display:block;max-width:47vw;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  #userEmail{display:none}
  .menu-btn{width:42px;min-width:42px;height:42px;padding:0;display:grid;place-items:center;border-radius:12px;background:#edf4f8;color:#0f5f96}
  .mobile-menu-backdrop{position:fixed;inset:0;z-index:111;background:rgba(6,25,43,.55);backdrop-filter:blur(2px)}
  .mobile-menu-backdrop:not(.hidden){display:block}
  .menu-open:after{display:none!important}
  .sidebar{width:min(300px,84vw);z-index:120;padding:16px 12px 14px;border-radius:0 18px 18px 0}
  .sidebar .brand{font-size:20px;padding:8px 44px 14px 8px}
  .sidebar nav{gap:6px}
  .sidebar nav button,.logout{min-height:46px;border-radius:12px;padding:11px 13px;font-size:15px}
  .sidebar nav button.active{background:#1c6f9f;box-shadow:inset 3px 0 0 #7dd3fc}
  .menu-close{width:40px;height:40px;min-height:40px;padding:0;border-radius:12px;font-size:18px}
  .mobile-bottom-nav{height:72px;padding:5px 6px calc(5px + env(safe-area-inset-bottom));gap:2px;border-top:1px solid #dce6ee;box-shadow:0 -8px 24px #153b5517}
  .mobile-bottom-nav button{min-width:0;min-height:58px;padding:4px 2px;border-radius:12px!important;margin:0!important;background:transparent!important;color:#607487!important;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;font-size:10.5px!important;font-weight:650!important;line-height:1.1;touch-action:manipulation}
  .mobile-bottom-nav button .mnav-icon{font-size:20px;line-height:1}
  .mobile-bottom-nav button.active{color:#0b6fa8!important;background:#edf7fc!important}
  .mobile-bottom-nav .mnav-sale{position:relative;color:#fff!important;transform:translateY(-13px);background:#0b7fc1!important;box-shadow:0 8px 20px rgba(11,127,193,.32);border:4px solid #fff!important;min-height:66px;border-radius:20px!important}
  .mobile-bottom-nav .mnav-sale.active{background:#075f91!important;color:#fff!important}
  .mnav-plus{font-size:28px;line-height:.8;font-weight:400}
  .page-head{gap:8px;margin-bottom:10px}
  .page-head h2{font-size:19px;line-height:1.25}
  .actions{grid-template-columns:1fr 1fr;gap:7px}
  .actions button{min-height:42px}
  .table-wrap{margin-left:-2px;margin-right:-2px;-webkit-overflow-scrolling:touch}
  .modal-backdrop{z-index:150}
  .toast{max-width:calc(100vw - 24px)}
  #toastRoot{left:12px;right:12px;bottom:86px}
}
@media(max-width:520px){
  .header-status{gap:5px}
  .online-status{max-width:112px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
  .mobile-bottom-nav button{font-size:10px!important}
  .quick-grid{gap:8px}
  .quick-grid button{padding:12px;min-height:68px}
  .card{border-radius:12px}
  .modal,.modal.wide{padding:12px}
}

/* ===== Stable 1.8.0 · PWA hoàn chỉnh ===== */
html,body{width:100%;height:100%;overscroll-behavior-y:none;overscroll-behavior-x:none}
body{overflow:hidden;min-height:100dvh;-webkit-tap-highlight-color:transparent;touch-action:manipulation}
.login-view{min-height:100dvh;height:100dvh;overflow:auto;overscroll-behavior:contain}
.app{height:100dvh;min-height:0;overflow:hidden}
.app>main{height:100dvh;min-height:0;display:flex;flex-direction:column;overflow:hidden}
.app>main>header{flex:0 0 62px}
#content{flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;scrollbar-gutter:stable}
.sidebar{height:100dvh;min-height:0;overflow-y:auto;overscroll-behavior:contain}
.modal-backdrop{height:100dvh;overscroll-behavior:contain}
.modal{max-height:calc(100dvh - 36px);overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
.pwa-prompt{position:fixed;left:50%;bottom:18px;transform:translateX(-50%);z-index:80;width:min(560px,calc(100vw - 24px));display:flex;align-items:center;gap:12px;padding:12px 14px;border:1px solid #b9d8ee;border-radius:14px;background:#fff;box-shadow:0 14px 40px #0f304d38;color:var(--text)}
.pwa-prompt>div{min-width:0;display:grid;gap:2px;flex:1}.pwa-prompt small{color:var(--muted);white-space:normal}.pwa-prompt>button:not(.pwa-prompt-close){background:#0f5f96;color:#fff;font-weight:800;white-space:nowrap}.pwa-prompt-close{padding:6px 8px;background:transparent;color:var(--muted)}
.pwa-update{border-color:#f3c86a;background:#fffaf0}.pwa-update>button:not(.pwa-prompt-close){background:#b54708}
body.pwa-standalone .pwa-install-only{display:none!important}
.safe-bottom{padding-bottom:env(safe-area-inset-bottom)}
@media(max-width:900px){
  body{position:fixed;inset:0;width:100%;height:100dvh}
  .app{height:100dvh;grid-template-columns:1fr}
  .app>main{height:100dvh;padding-bottom:calc(72px + env(safe-area-inset-bottom))}
  #content{padding-bottom:calc(92px + env(safe-area-inset-bottom));scroll-behavior:auto}
  .sidebar{position:fixed;height:100dvh;max-height:100dvh;overflow-y:auto}
  .mobile-bottom-nav{padding-bottom:env(safe-area-inset-bottom);height:calc(66px + env(safe-area-inset-bottom))}
  .mobile-sale-bar{bottom:calc(66px + env(safe-area-inset-bottom))}
  .pwa-prompt{bottom:calc(78px + env(safe-area-inset-bottom));align-items:flex-start}
  body.mobile-sales-open .pwa-prompt{bottom:calc(142px + env(safe-area-inset-bottom))}
}
@media(display-mode:standalone){
  body{user-select:none}
  input,textarea,select{user-select:text}
}
