:root{
  --blue:#0057d9;
  --blue-dark:#00399c;
  --bg:#f4f6f9;
  --card:#ffffff;
  --text:#1c2430;
  --muted:#6b7684;
  --border:#e3e7ee;
  --radius:10px;
}
*{box-sizing:border-box;}
body{
  margin:0;
  font-family:'Segoe UI',Arial,sans-serif;
  background:var(--bg);
  color:var(--text);
}
.container{max-width:1240px;margin:0 auto;padding:0 20px;}
a{color:inherit;}

/* Topbar */
.topbar{
  background:linear-gradient(90deg,var(--blue),var(--blue-dark));
  color:#fff;
  position:sticky;
  top:0;
  z-index:50;
  box-shadow:0 2px 8px rgba(0,0,0,.15);
}
.topbar-inner{
  display:flex;
  align-items:center;
  gap:24px;
  padding:14px 20px;
}
.brand{display:flex;flex-direction:column;line-height:1.1;}
.brand-mark{font-weight:800;font-size:22px;letter-spacing:1px;}
.brand-sub{font-size:12px;opacity:.85;}
.search-wrap{flex:1;}
#searchInput{
  width:100%;
  padding:10px 14px;
  border-radius:20px;
  border:none;
  font-size:14px;
  outline:none;
}
.cart-btn{
  background:#fff;
  color:var(--blue-dark);
  border:none;
  padding:10px 16px;
  border-radius:20px;
  font-weight:600;
  cursor:pointer;
  display:flex;
  align-items:center;
  gap:6px;
  white-space:nowrap;
}
.cart-count{
  background:var(--blue-dark);
  color:#fff;
  border-radius:50%;
  padding:1px 7px;
  font-size:12px;
}

/* Layout */
.layout{
  display:grid;
  grid-template-columns:220px 1fr;
  gap:28px;
  padding:28px 20px 60px;
}
.sidebar h3{
  font-size:14px;
  text-transform:uppercase;
  letter-spacing:.5px;
  color:var(--muted);
  margin:0 0 12px;
}
.category-list{list-style:none;padding:0;margin:0;}
.category-list li{
  padding:10px 12px;
  border-radius:8px;
  cursor:pointer;
  font-size:14px;
  margin-bottom:4px;
  color:var(--text);
}
.category-list li.active,
.category-list li:hover{
  background:var(--blue);
  color:#fff;
}
.content-header h1{margin:0 0 4px;font-size:24px;}
.muted{color:var(--muted);font-size:14px;margin:0 0 20px;}

.subcategory-bar{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-bottom:18px;
}
.subcat-pill{
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
  padding:7px 14px;
  border-radius:16px;
  font-size:13px;
  font-weight:600;
  cursor:pointer;
}
.subcat-pill:hover{border-color:var(--blue);}
.subcat-pill.active{
  background:var(--blue);
  border-color:var(--blue);
  color:#fff;
}

.product-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(220px,1fr));
  gap:18px;
}
.product-card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  overflow:hidden;
  display:flex;
  flex-direction:column;
  transition:box-shadow .15s;
}
.product-card:hover{box-shadow:0 4px 16px rgba(0,0,0,.08);}
.product-img{
  aspect-ratio:1/1;
  background:#f0f2f6;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
}
.product-img img{width:100%;height:100%;object-fit:contain;padding:8px;}
.product-body{padding:12px 14px;display:flex;flex-direction:column;gap:6px;flex:1;}
.product-ref{font-size:11px;color:var(--muted);}
.product-name{font-size:13.5px;font-weight:600;line-height:1.3;min-height:36px;}
.product-actions{
  margin-top:auto;
  display:flex;
  align-items:center;
  gap:8px;
}
.qty-input{
  width:52px;
  padding:6px;
  border:1px solid var(--border);
  border-radius:6px;
  text-align:center;
}
.btn{
  border:none;
  border-radius:8px;
  padding:10px 14px;
  font-weight:600;
  cursor:pointer;
  font-size:14px;
}
.btn-primary{background:var(--blue);color:#fff;}
.btn-primary:hover{background:var(--blue-dark);}
.btn-block{width:100%;}
.btn-add{flex:1;}

.empty-state{padding:60px 0;text-align:center;color:var(--muted);}

/* Overlay */
.overlay{
  position:fixed;inset:0;
  background:rgba(0,0,0,.4);
  display:none;
  z-index:90;
}
.overlay.show{display:block;}

/* Cart drawer */
.cart-drawer{
  position:fixed;
  top:0;right:-420px;
  width:400px;max-width:92vw;
  height:100%;
  background:#fff;
  z-index:100;
  display:flex;flex-direction:column;
  transition:right .25s ease;
  box-shadow:-4px 0 20px rgba(0,0,0,.15);
}
.cart-drawer.open{right:0;}
.cart-drawer-header{
  display:flex;justify-content:space-between;align-items:center;
  padding:18px 20px;border-bottom:1px solid var(--border);
}
.cart-drawer-header h2{margin:0;font-size:18px;}
.icon-btn{background:none;border:none;font-size:18px;cursor:pointer;color:var(--muted);}
.cart-items{flex:1;overflow-y:auto;padding:12px 20px;}
.cart-empty-msg{padding:20px;text-align:center;color:var(--muted);display:none;}
.cart-item{
  display:flex;gap:10px;padding:12px 0;border-bottom:1px solid var(--border);
  align-items:center;
}
.cart-item img{width:50px;height:50px;object-fit:contain;background:#f0f2f6;border-radius:6px;}
.cart-item-info{flex:1;}
.cart-item-name{font-size:13px;font-weight:600;line-height:1.3;}
.cart-item-ref{font-size:11px;color:var(--muted);}
.cart-item-qty{
  display:flex;align-items:center;gap:6px;margin-top:4px;
}
.cart-item-qty button{
  width:22px;height:22px;border:1px solid var(--border);background:#fff;
  border-radius:4px;cursor:pointer;
}
.cart-item-remove{
  background:none;border:none;color:#c0392b;cursor:pointer;font-size:12px;
}
.cart-drawer-footer{padding:16px 20px;border-top:1px solid var(--border);}

/* Modal */
.modal{
  position:fixed;top:50%;left:50%;
  transform:translate(-50%,-50%);
  background:#fff;
  width:480px;max-width:92vw;
  max-height:88vh;
  overflow-y:auto;
  border-radius:12px;
  z-index:110;
  display:none;
  box-shadow:0 10px 40px rgba(0,0,0,.25);
}
.modal.open{display:block;}
.modal-header{
  display:flex;justify-content:space-between;align-items:center;
  padding:18px 22px;border-bottom:1px solid var(--border);
}
.modal-header h2{margin:0;font-size:18px;}
.modal-body{padding:20px 22px;display:flex;flex-direction:column;gap:14px;}
.modal-body label{
  display:flex;flex-direction:column;gap:6px;
  font-size:13px;font-weight:600;color:var(--text);
}
.modal-body input,.modal-body textarea{
  border:1px solid var(--border);
  border-radius:8px;
  padding:10px 12px;
  font-size:14px;
  font-family:inherit;
  font-weight:400;
}
.form-msg{font-size:13px;min-height:18px;}
.form-msg.error{color:#c0392b;}
.form-msg.success{color:#1a8a3f;}

@media(max-width:800px){
  .layout{grid-template-columns:1fr;}
  .sidebar{order:2;}
  .search-wrap{display:none;}
}
