:root{
  --bg:#f3f5f1;
  --surface:#ffffff;
  --surface-2:#f7f9f6;
  --line:#dfe5de;
  --text:#17211e;
  --muted:#6d7974;
  --primary:#173c34;
  --primary-2:#24584c;
  --accent:#e9a23b;
  --danger:#b53a35;
  --success:#2e7d59;
  --warning:#9a6516;
  --shadow:0 10px 30px rgba(23,60,52,.08);
  --radius:16px;
}
*{box-sizing:border-box}
html,body{margin:0;min-height:100%;background:var(--bg);color:var(--text);font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}
body{min-height:100vh}
button,input,select,textarea{font:inherit}
button{cursor:pointer}
a{color:inherit}
.hidden{display:none!important}
.muted{color:var(--muted)}
.mono{font-variant-numeric:tabular-nums;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
.text-right{text-align:right}
.text-center{text-align:center}
.strong{font-weight:750}
.negative{color:var(--danger)!important}
.positive{color:var(--success)!important}

.boot-loader{min-height:100vh;display:grid;place-items:center;align-content:center;gap:14px;color:var(--muted)}
.spinner{width:34px;height:34px;border:3px solid #d9e1dd;border-top-color:var(--primary);border-radius:50%;animation:spin .8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

.auth-page{min-height:100vh;display:grid;grid-template-columns:minmax(0,1.1fr) minmax(360px,.9fr);background:linear-gradient(135deg,#0f302a,#24584c)}
.auth-hero{padding:clamp(36px,7vw,100px);color:#fff;display:flex;flex-direction:column;justify-content:center;position:relative;overflow:hidden}
.auth-hero:before,.auth-hero:after{content:"";position:absolute;border-radius:50%;background:rgba(255,255,255,.06)}
.auth-hero:before{width:420px;height:420px;right:-160px;top:-150px}
.auth-hero:after{width:280px;height:280px;left:-100px;bottom:-120px}
.auth-mark{width:74px;height:74px;border-radius:22px;background:var(--accent);display:grid;place-items:center;color:#173c34;font-weight:900;font-size:27px;box-shadow:0 18px 50px rgba(0,0,0,.18);z-index:1}
.auth-hero h1{font-size:clamp(38px,6vw,72px);line-height:.98;margin:28px 0 18px;letter-spacing:-.045em;max-width:760px;z-index:1}
.auth-hero p{font-size:18px;line-height:1.7;max-width:660px;color:rgba(255,255,255,.78);z-index:1}
.auth-features{display:flex;flex-wrap:wrap;gap:10px;margin-top:26px;z-index:1}
.auth-features span{border:1px solid rgba(255,255,255,.16);background:rgba(255,255,255,.07);padding:10px 14px;border-radius:999px;font-size:13px}
.auth-panel{background:var(--surface);padding:clamp(28px,5vw,72px);display:flex;align-items:center;justify-content:center}
.auth-card{width:min(440px,100%)}
.auth-card h2{font-size:30px;margin:0 0 8px;letter-spacing:-.025em}
.auth-card>.muted{margin:0 0 28px;line-height:1.6}

.app-shell{min-height:100vh;display:grid;grid-template-columns:250px minmax(0,1fr)}
.sidebar{background:var(--primary);color:#fff;padding:18px 14px;position:fixed;left:0;top:0;bottom:0;width:250px;z-index:30;display:flex;flex-direction:column;overflow:auto}
.brand{display:flex;align-items:center;gap:12px;padding:8px 10px 22px}
.brand-mark{width:42px;height:42px;border-radius:13px;background:var(--accent);color:#173c34;display:grid;place-items:center;font-size:16px;font-weight:900}
.brand-title{font-weight:850;font-size:17px;line-height:1.1}
.brand-sub{font-size:11px;color:rgba(255,255,255,.62);margin-top:4px}
.nav-group{display:grid;gap:5px}
.nav-btn{border:0;background:transparent;color:rgba(255,255,255,.72);display:flex;align-items:center;gap:11px;width:100%;padding:11px 12px;border-radius:11px;text-align:left;font-weight:650;font-size:14px}
.nav-btn:hover{background:rgba(255,255,255,.08);color:#fff}
.nav-btn.active{background:#fff;color:var(--primary);box-shadow:0 8px 24px rgba(0,0,0,.12)}
.nav-icon{width:20px;text-align:center;font-size:16px}
.sidebar-bottom{margin-top:auto;padding-top:18px}
.user-card{padding:12px;border-radius:13px;background:rgba(255,255,255,.08);margin-bottom:8px}
.user-card strong{display:block;font-size:13px}
.user-card span{display:block;font-size:11px;color:rgba(255,255,255,.62);margin-top:4px}
.main-wrap{grid-column:2;min-width:0}
.topbar{height:72px;background:rgba(255,255,255,.92);backdrop-filter:blur(12px);border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:0 28px;position:sticky;top:0;z-index:20}
.topbar-left{display:flex;align-items:center;gap:13px;min-width:0}
.menu-toggle{display:none;border:1px solid var(--line);background:var(--surface);border-radius:10px;width:40px;height:40px}
.page-title{font-size:20px;font-weight:850;letter-spacing:-.02em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.page-subtitle{font-size:12px;color:var(--muted);margin-top:3px}
.topbar-clock{text-align:right}
.topbar-clock strong{display:block;font-size:13px}
.topbar-clock span{font-size:11px;color:var(--muted)}
.main-content{padding:26px;max-width:1700px;margin:0 auto}

.page-head{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;margin-bottom:20px}
.page-head h1{margin:0;font-size:27px;letter-spacing:-.03em}
.page-head p{margin:7px 0 0;color:var(--muted);line-height:1.55;font-size:14px}
.page-actions{display:flex;align-items:center;gap:9px;flex-wrap:wrap;justify-content:flex-end}
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow)}
.card-pad{padding:20px}
.card-head{padding:18px 20px;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;gap:12px}
.card-head h3{margin:0;font-size:15px;letter-spacing:-.01em}
.card-body{padding:20px}
.grid{display:grid;gap:18px}
.grid-2{grid-template-columns:repeat(2,minmax(0,1fr))}
.grid-3{grid-template-columns:repeat(3,minmax(0,1fr))}
.grid-4{grid-template-columns:repeat(4,minmax(0,1fr))}
.stat-card{padding:18px;position:relative;overflow:hidden}
.stat-card:after{content:"";position:absolute;width:90px;height:90px;border-radius:50%;right:-35px;bottom:-35px;background:rgba(23,60,52,.05)}
.stat-label{font-size:12px;color:var(--muted);font-weight:650;margin-bottom:11px}
.stat-value{font-size:25px;font-weight:880;letter-spacing:-.035em;font-variant-numeric:tabular-nums}
.stat-note{font-size:11px;color:var(--muted);margin-top:8px}
.stat-card.highlight{background:var(--primary);color:#fff;border-color:var(--primary)}
.stat-card.highlight .stat-label,.stat-card.highlight .stat-note{color:rgba(255,255,255,.68)}
.stat-card.highlight:after{background:rgba(255,255,255,.08)}

label{display:block;font-size:12px;font-weight:720;margin:0 0 7px;color:#45514d}
.input,.select,.textarea,input[type="date"],input[type="month"],input[type="number"],input[type="text"],input[type="password"],select,textarea{
  width:100%;border:1px solid #ccd6d1;background:#fff;color:var(--text);border-radius:10px;padding:10px 12px;outline:none;min-height:42px
}
textarea{min-height:90px;resize:vertical}
input:focus,select:focus,textarea:focus{border-color:var(--primary-2);box-shadow:0 0 0 3px rgba(36,88,76,.12)}
.form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:15px}
.form-grid-3{grid-template-columns:repeat(3,minmax(0,1fr))}
.form-field.full{grid-column:1/-1}
.help{font-size:11px;color:var(--muted);line-height:1.5;margin-top:6px}
.checkbox-line{display:flex;align-items:center;gap:9px;font-size:13px}
.checkbox-line input{width:auto;min-height:auto}

.btn{border:1px solid transparent;border-radius:10px;padding:10px 14px;min-height:40px;font-weight:750;font-size:13px;display:inline-flex;align-items:center;justify-content:center;gap:8px;transition:.15s ease}
.btn:hover{transform:translateY(-1px)}
.btn:disabled{opacity:.45;cursor:not-allowed;transform:none}
.btn-primary{background:var(--primary);color:#fff}
.btn-primary:hover{background:var(--primary-2)}
.btn-accent{background:var(--accent);color:#2a2418}
.btn-ghost{background:#fff;border-color:var(--line);color:var(--text)}
.btn-danger{background:#fff3f2;border-color:#efc8c5;color:var(--danger)}
.btn-success{background:#edf8f2;border-color:#c7e7d5;color:var(--success)}
.btn-sm{padding:7px 10px;min-height:32px;font-size:11px;border-radius:8px}
.icon-btn{width:34px;height:34px;border-radius:9px;border:1px solid var(--line);background:#fff;display:inline-grid;place-items:center}

.toolbar{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:16px}
.toolbar .search{min-width:240px;flex:1}
.search-wrap{position:relative}
.search-wrap input{padding-left:38px}
.search-wrap .search-icon{position:absolute;left:13px;top:50%;transform:translateY(-50%);color:var(--muted);pointer-events:none}
.table-wrap{overflow:auto;border-radius:0 0 var(--radius) var(--radius)}
table{width:100%;border-collapse:collapse;font-size:13px}
th{font-size:11px;text-transform:uppercase;letter-spacing:.045em;color:var(--muted);text-align:left;background:var(--surface-2);padding:12px 14px;border-bottom:1px solid var(--line);white-space:nowrap}
td{padding:13px 14px;border-bottom:1px solid #edf0ed;vertical-align:middle}
tbody tr:last-child td{border-bottom:0}
tbody tr:hover{background:#fafcf9}
.empty-state{padding:46px 20px;text-align:center;color:var(--muted)}
.empty-icon{width:56px;height:56px;border-radius:18px;background:var(--surface-2);display:grid;place-items:center;margin:0 auto 14px;font-size:24px}
.empty-state strong{display:block;color:var(--text);margin-bottom:6px}
.badge{display:inline-flex;align-items:center;padding:5px 8px;border-radius:999px;font-size:10px;font-weight:800;white-space:nowrap}
.badge-success{background:#eaf6ef;color:#27704f}
.badge-danger{background:#fff0ef;color:#a93631}
.badge-warning{background:#fff5df;color:#8b5b13}
.badge-neutral{background:#eef1ef;color:#59645f}
.badge-primary{background:#e9f1ee;color:var(--primary)}

.pos-layout{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(340px,.75fr);gap:18px;align-items:start}
.pos-products{min-width:0}
.scan-bar{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:9px;padding:16px;border-bottom:1px solid var(--line)}
.scan-input{font-size:16px;font-weight:750;min-height:48px!important;padding-left:15px!important}
.product-results{display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:11px;padding:16px;max-height:calc(100vh - 240px);overflow:auto}
.product-tile{border:1px solid var(--line);background:#fff;border-radius:13px;padding:14px;text-align:left;min-height:122px;display:flex;flex-direction:column;transition:.14s ease}
.product-tile:hover{border-color:var(--primary-2);box-shadow:0 8px 18px rgba(23,60,52,.09);transform:translateY(-1px)}
.product-tile:disabled{opacity:.52;transform:none;box-shadow:none}
.product-name{font-weight:800;line-height:1.3;margin-bottom:6px}
.product-code{font-size:10px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.product-price{font-size:16px;font-weight:880;margin-top:auto;padding-top:12px}
.product-stock{font-size:10px;margin-top:4px;color:var(--muted)}
.cart-card{position:sticky;top:90px;overflow:hidden}
.cart-items{max-height:390px;overflow:auto;padding:0 16px}
.cart-row{padding:13px 0;border-bottom:1px solid #edf0ed}
.cart-row-top{display:flex;justify-content:space-between;gap:12px}
.cart-row-name{font-size:13px;font-weight:780;line-height:1.35}
.cart-row-price{font-size:12px;color:var(--muted);margin-top:3px}
.cart-row-bottom{display:flex;align-items:center;justify-content:space-between;margin-top:10px;gap:10px}
.qty-control{display:flex;align-items:center;border:1px solid var(--line);border-radius:9px;overflow:hidden;background:#fff}
.qty-control button{border:0;background:#f6f8f5;width:30px;height:30px;font-weight:850}
.qty-control input{border:0!important;box-shadow:none!important;width:54px!important;min-height:30px!important;height:30px;padding:3px;text-align:center;border-radius:0}
.cart-summary{padding:16px;background:var(--surface-2);border-top:1px solid var(--line)}
.summary-line{display:flex;justify-content:space-between;gap:14px;font-size:13px;margin:8px 0}
.summary-line.total{font-size:19px;font-weight:900;padding-top:10px;border-top:1px dashed #c9d1cd;margin-top:12px}
.payment-box{padding:16px;border-top:1px solid var(--line);display:grid;gap:12px}
.payment-methods{display:grid;grid-template-columns:repeat(4,1fr);gap:6px}
.payment-method{border:1px solid var(--line);background:#fff;padding:9px 5px;border-radius:9px;font-size:10px;font-weight:800}
.payment-method.active{border-color:var(--primary);background:#eaf1ee;color:var(--primary)}

.chart-bars{height:190px;display:flex;align-items:flex-end;gap:5px;padding-top:20px;overflow-x:auto}
.chart-col{min-width:18px;flex:1;max-width:44px;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;height:100%;gap:7px}
.chart-bar{width:100%;min-height:2px;background:var(--primary-2);border-radius:6px 6px 2px 2px;position:relative}
.chart-bar.expense{background:var(--accent)}
.chart-label{font-size:9px;color:var(--muted)}
.chart-legend{display:flex;gap:16px;font-size:11px;color:var(--muted)}
.chart-legend span:before{content:"";display:inline-block;width:9px;height:9px;border-radius:3px;background:var(--primary-2);margin-right:6px}
.chart-legend span:last-child:before{background:var(--accent)}

.purchase-builder{display:grid;grid-template-columns:minmax(0,.85fr) minmax(0,1.15fr);gap:18px}
.purchase-search-results{max-height:310px;overflow:auto;border:1px solid var(--line);border-radius:11px;margin-top:9px}
.purchase-result{display:flex;justify-content:space-between;gap:10px;width:100%;border:0;border-bottom:1px solid #edf0ed;background:#fff;padding:11px;text-align:left}
.purchase-result:last-child{border-bottom:0}
.purchase-result:hover{background:var(--surface-2)}
.purchase-item{display:grid;grid-template-columns:minmax(0,1fr) 110px 150px 42px;gap:9px;align-items:end;padding:11px 0;border-bottom:1px solid #edf0ed}
.purchase-item:last-child{border-bottom:0}
.purchase-item-name{align-self:center}
.purchase-item-name strong{display:block;font-size:13px}
.purchase-item-name span{font-size:10px;color:var(--muted)}

.formula-box{background:#edf4f1;border:1px solid #d4e2dc;border-radius:13px;padding:15px;line-height:1.65;font-size:13px}
.formula-box code{background:#fff;padding:3px 7px;border-radius:6px;font-weight:800;color:var(--primary)}
.profit-positive{color:var(--success);font-weight:850}
.profit-negative{color:var(--danger);font-weight:850}

.modal-backdrop{position:fixed;inset:0;background:rgba(12,25,21,.58);z-index:100;display:flex;align-items:center;justify-content:center;padding:18px;animation:fadein .14s ease}
@keyframes fadein{from{opacity:0}to{opacity:1}}
.modal{width:min(620px,100%);max-height:calc(100vh - 36px);overflow:auto;background:#fff;border-radius:18px;box-shadow:0 28px 80px rgba(0,0,0,.28)}
.modal-lg{width:min(920px,100%)}
.modal-head{padding:18px 20px;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;position:sticky;top:0;background:#fff;z-index:2}
.modal-head h3{margin:0;font-size:17px}
.modal-close{border:1px solid var(--line);background:#fff;width:34px;height:34px;border-radius:9px;font-size:18px}
.modal-body{padding:20px}
.modal-actions{padding:15px 20px;border-top:1px solid var(--line);display:flex;justify-content:flex-end;gap:9px;position:sticky;bottom:0;background:#fff}
.camera-wrap{background:#111;border-radius:12px;overflow:hidden;position:relative;aspect-ratio:4/3}
.camera-wrap video{width:100%;height:100%;object-fit:cover}
.camera-guide{position:absolute;inset:18% 8%;border:2px solid var(--accent);border-radius:12px;box-shadow:0 0 0 999px rgba(0,0,0,.25)}

.receipt-preview{width:min(330px,100%);margin:0 auto;background:#fff;color:#111;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;line-height:1.45}
.receipt-preview h2{text-align:center;margin:0 0 5px;font-size:18px}
.receipt-center{text-align:center}
.receipt-line{border-top:1px dashed #555;margin:10px 0}
.receipt-row{display:flex;justify-content:space-between;gap:12px}
.receipt-item{margin:8px 0}
.receipt-item-name{font-weight:700}

.toast-root{position:fixed;right:18px;bottom:18px;z-index:300;display:grid;gap:9px;width:min(390px,calc(100vw - 36px))}
.toast{background:#17211e;color:#fff;border-radius:12px;padding:13px 15px;box-shadow:0 14px 34px rgba(0,0,0,.22);font-size:13px;line-height:1.45;animation:toastin .2s ease}
.toast.error{background:#8f2f2b}
.toast.success{background:#236548}
@keyframes toastin{from{transform:translateY(10px);opacity:0}to{transform:none;opacity:1}}

.skeleton{background:linear-gradient(90deg,#edf0ed 25%,#f7f9f6 50%,#edf0ed 75%);background-size:200% 100%;animation:shimmer 1.2s infinite;border-radius:8px;height:16px}
@keyframes shimmer{to{background-position:-200% 0}}

@media(max-width:1150px){
  .grid-4{grid-template-columns:repeat(2,minmax(0,1fr))}
  .pos-layout{grid-template-columns:minmax(0,1fr) 360px}
  .purchase-builder{grid-template-columns:1fr}
}
@media(max-width:900px){
  .auth-page{grid-template-columns:1fr}.auth-hero{display:none}.auth-panel{min-height:100vh}
  .app-shell{display:block}.sidebar{transform:translateX(-105%);transition:.2s ease}.sidebar.open{transform:translateX(0);box-shadow:20px 0 50px rgba(0,0,0,.25)}
  .main-wrap{grid-column:auto}.menu-toggle{display:block}.main-content{padding:18px}.topbar{padding:0 18px}
  .pos-layout{grid-template-columns:1fr}.cart-card{position:static}.product-results{max-height:none}
  .grid-3{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:640px){
  .main-content{padding:13px}.topbar{height:64px;padding:0 13px}.topbar-clock{display:none}
  .page-head{display:block}.page-actions{justify-content:flex-start;margin-top:13px}.page-head h1{font-size:23px}
  .grid-2,.grid-3,.grid-4,.form-grid,.form-grid-3{grid-template-columns:1fr}
  .stat-value{font-size:22px}.card-pad,.card-body{padding:15px}.card-head{padding:15px}
  .toolbar{align-items:stretch}.toolbar>*{width:100%}.toolbar .btn{width:100%}
  .product-results{grid-template-columns:repeat(2,minmax(0,1fr));padding:10px;gap:8px}
  .product-tile{min-height:126px;padding:11px}.product-name{font-size:12px}.product-price{font-size:14px}
  .scan-bar{grid-template-columns:1fr;padding:11px}.scan-bar .btn{width:100%}
  .payment-methods{grid-template-columns:repeat(2,1fr)}
  .purchase-item{grid-template-columns:1fr 1fr}.purchase-item-name{grid-column:1/-1}.purchase-item .icon-btn{width:100%}
  th,td{padding:11px 10px}.modal-backdrop{padding:8px}.modal{max-height:calc(100vh - 16px);border-radius:14px}
}
