:root{
  --cream:#FAF1DC;
  --yellow:#F2C71C;
  --dark:#0A0A0A;
  --gray:#6b6558;
  --line:#e7ddc2;
  --danger:#c1442d;
  --ok:#3a7d44;
  font-family:'Cairo','Manrope',sans-serif;
}
*{box-sizing:border-box;margin:0;padding:0;}
body{
  background:var(--cream);
  color:var(--dark);
  min-height:100vh;
  padding-bottom:80px;
  -webkit-tap-highlight-color:transparent;
}
input{font-family:inherit;}

/* Topbar */
.topbar{
  position:sticky;top:0;z-index:10;
  display:flex;align-items:center;justify-content:space-between;
  background:var(--dark);color:var(--cream);
  padding:14px 16px;
}
.brand{display:flex;align-items:center;gap:8px;font-weight:800;font-size:18px;}
.brand-logo{height:28px;width:auto;}
.status{font-size:12px;color:var(--yellow);}
.status.offline{color:#e07a5f;}

/* Screens */
.screen{display:none;padding:16px;max-width:640px;margin:0 auto;}
.screen.active{display:block;}

/* Fields */
.field{margin-bottom:18px;}
.field label{display:block;font-weight:700;margin-bottom:6px;font-size:14px;}
.field input, .product-search input{
  width:100%;padding:14px;border-radius:12px;border:2px solid var(--line);
  background:#fff;font-size:16px;
}
.field input:focus, .product-search input:focus{outline:none;border-color:var(--yellow);}

.section-head{display:flex;align-items:center;justify-content:space-between;margin:18px 0 10px;}
.section-head h2{font-size:18px;}

.product-search{margin-bottom:10px;}

/* Category filter chips */
.category-filters{display:flex;gap:8px;overflow-x:auto;padding-bottom:10px;margin-bottom:8px;-webkit-overflow-scrolling:touch;}
.category-filters::-webkit-scrollbar{display:none;}
.cat-chip{
  flex:0 0 auto;background:#fff;border:2px solid var(--line);border-radius:20px;
  padding:6px 14px;font-size:12px;font-weight:700;white-space:nowrap;cursor:pointer;color:var(--gray);
}
.cat-chip.active{background:var(--dark);border-color:var(--dark);color:var(--yellow);}

/* Product grid */
.product-grid{display:grid;grid-template-columns:repeat(6,1fr);gap:6px;margin-bottom:100px;}
.product-card{
  background:#fff;border-radius:10px;padding:5px;border:2px solid transparent;
  cursor:pointer;user-select:none;transition:.15s;
}
.product-card.selected{border-color:var(--yellow);background:#fff9e6;}
.product-card.out-of-stock{opacity:.45;cursor:not-allowed;}
.product-card img{width:100%;aspect-ratio:1;object-fit:contain;border-radius:6px;background:var(--cream);padding:3px;}
.product-card .pname{font-size:10px;font-weight:700;margin-top:4px;line-height:1.25;
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;min-height:25px;}
.product-card .pprice{font-size:10px;color:var(--gray);margin-top:1px;}
.product-card .pstock{font-size:9px;margin-top:1px;font-weight:700;}
.product-card .pstock.low{color:#a5710a;}
.product-card .pstock.out{color:var(--danger);}
.product-card .qty-row{display:flex;align-items:center;justify-content:space-between;margin-top:5px;}
.qty-row button{
  width:22px;height:22px;border-radius:6px;border:none;background:var(--dark);color:var(--cream);
  font-size:12px;font-weight:800;
}
.product-card.out-of-stock .qty-row button{background:#ccc;color:#888;pointer-events:none;}
.qty-row span{font-weight:800;font-size:12px;}

@media (max-width:480px){
  .product-grid{grid-template-columns:repeat(3,1fr);gap:8px;}
  .product-card .pname{font-size:11px;min-height:28px;}
}

.empty-state{grid-column:1/-1;text-align:center;padding:40px 20px;color:var(--gray);}
.empty-state p{margin-bottom:14px;}

/* Buttons */
.btn-primary{
  background:var(--yellow);color:var(--dark);border:none;border-radius:12px;
  padding:12px 18px;font-weight:800;font-size:15px;cursor:pointer;
}
.btn-primary.big{width:100%;padding:16px;font-size:16px;margin-top:10px;}
.btn-ghost{
  background:transparent;border:2px solid var(--dark);color:var(--dark);
  border-radius:10px;padding:8px 14px;font-weight:700;font-size:13px;cursor:pointer;
}
.btn-ghost.small{padding:6px 12px;font-size:12px;}
.btn-ghost.danger{border-color:var(--danger);color:var(--danger);}

/* Cart bar */
.cart-bar{
  position:fixed;bottom:66px;left:0;right:0;
  background:var(--dark);color:#fff;
  display:flex;align-items:center;justify-content:space-between;
  padding:14px 18px;max-width:640px;margin:0 auto;
  border-radius:16px 16px 0 0;
}
.cart-info{display:flex;flex-direction:column;font-size:13px;gap:2px;}
.cart-info strong{color:var(--yellow);font-size:16px;}

/* Review screen */
.review-client{background:#fff;padding:12px;border-radius:10px;margin-bottom:14px;}
.review-items{display:flex;flex-direction:column;gap:8px;margin-bottom:14px;}
.review-item{display:flex;justify-content:space-between;background:#fff;padding:10px 14px;border-radius:10px;font-size:14px;}
.review-total{display:flex;justify-content:space-between;font-size:18px;font-weight:800;padding:12px 4px;border-top:2px dashed var(--line);}

/* Order done / send options */
.done-check{font-size:56px;text-align:center;margin-top:20px;}
.done-title{text-align:center;margin-top:8px;}
.done-sub{text-align:center;color:var(--gray);font-size:14px;margin-top:6px;margin-bottom:26px;}
.send-options{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-bottom:20px;}
.send-btn{
  background:#fff;border:2px solid var(--line);border-radius:14px;
  padding:18px 10px;display:flex;flex-direction:column;align-items:center;gap:8px;
  font-weight:700;font-size:13px;cursor:pointer;
}
.send-btn:active{border-color:var(--yellow);background:#fff9e6;}
.send-icon{font-size:26px;}

/* Orders list */
.orders-list{display:flex;flex-direction:column;gap:10px;}
.order-card{background:#fff;border-radius:12px;padding:12px 14px;}
.order-card-top{display:flex;justify-content:space-between;align-items:center;}
.order-card-top strong{font-size:15px;}
.badge{font-size:11px;font-weight:800;padding:3px 10px;border-radius:20px;}
.badge.pending{background:#fdeecb;color:#a5710a;}
.badge.synced{background:#dcefe0;color:var(--ok);}
.badge.cancelled{background:#f4d8d1;color:var(--danger);text-decoration:line-through;}
.order-card-meta{font-size:12px;color:var(--gray);margin-top:4px;}
.order-card-actions{display:flex;gap:8px;margin-top:10px;}

/* Settings */
.settings-row{display:flex;justify-content:space-between;padding:12px 0;border-bottom:1px solid var(--line);}
.hint{font-size:12px;color:var(--gray);margin-top:16px;line-height:1.6;}
#screen-settings .btn-ghost{width:100%;margin-top:10px;}

/* Bottom nav */
.bottom-nav{
  position:fixed;bottom:0;left:0;right:0;
  display:flex;background:#fff;border-top:1px solid var(--line);
  max-width:640px;margin:0 auto;
}
.nav-btn{
  flex:1;padding:12px 4px;border:none;background:none;font-size:12px;font-weight:700;color:var(--gray);
}
.nav-btn.active{color:var(--dark);border-top:3px solid var(--yellow);}

/* ===================== PRINT INVOICE ===================== */
.print-invoice{display:none;}

@media print{
  @page{ size:100mm 150mm; margin:5mm; }
  body *{ visibility:hidden; }
  .print-invoice, .print-invoice *{ visibility:visible; }
  .print-invoice{
    display:block;position:absolute;top:0;right:0;width:90mm;
    font-family:'Cairo',sans-serif;color:#000;
  }
  .inv-logo{text-align:center;margin-bottom:6px;}
  .inv-logo img{max-height:22mm;max-width:60mm;}
  .inv-brand-fallback{font-size:20px;font-weight:900;}
  .inv-line{border-top:1px dashed #000;margin:6px 0;}
  .inv-row{display:flex;justify-content:space-between;font-size:12px;margin:3px 0;}
  .inv-table{width:100%;border-collapse:collapse;font-size:11px;margin:4px 0;}
  .inv-table th{text-align:right;border-bottom:1px solid #000;padding:3px 2px;}
  .inv-table td{padding:3px 2px;border-bottom:1px dotted #999;}
  .inv-total{font-size:14px;font-weight:900;}
  .inv-footer{text-align:center;margin-top:10px;font-size:11px;}
}
